From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Thomas Stuart Date: Wed, 28 Sep 2022 09:40:14 -0700 Subject: [PATCH] prevent overlays on the phone settings A report came in showing a 3rd party app could overlay a button on the phone settings causing unwanted behavior. In order to prevent this, a new system flag has been added that only allows system overlays. bug: 246933785 Test: manual Change-Id: I427b65bc6c1acf06676e1753a34a7a38e21bbae0 Merged-In: I427b65bc6c1acf06676e1753a34a7a38e21bbae0 (cherry picked from commit e827d8f13c1c92622474fa2bf9e41a1f4ce21e2c) Merged-In: I427b65bc6c1acf06676e1753a34a7a38e21bbae0 --- .../phone/settings/AccessibilitySettingsActivity.java | 6 +++++- .../phone/settings/PhoneAccountSettingsActivity.java | 4 ++++ .../android/phone/settings/VoicemailChangePinActivity.java | 3 +++ .../android/phone/settings/VoicemailSettingsActivity.java | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/android/phone/settings/AccessibilitySettingsActivity.java b/src/com/android/phone/settings/AccessibilitySettingsActivity.java index 769ef615f..ebe7a1afe 100644 --- a/src/com/android/phone/settings/AccessibilitySettingsActivity.java +++ b/src/com/android/phone/settings/AccessibilitySettingsActivity.java @@ -19,15 +19,19 @@ package com.android.phone.settings; import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.MenuItem; +import android.view.WindowManager; import com.android.phone.R; public class AccessibilitySettingsActivity extends PreferenceActivity { - @Override + @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); + getWindow().addPrivateFlags( + WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + getActionBar().setTitle(R.string.accessibility_settings_activity_title); getFragmentManager().beginTransaction().replace( android.R.id.content, new AccessibilitySettingsFragment()).commit(); diff --git a/src/com/android/phone/settings/PhoneAccountSettingsActivity.java b/src/com/android/phone/settings/PhoneAccountSettingsActivity.java index 71ae8cfa4..88a70df18 100644 --- a/src/com/android/phone/settings/PhoneAccountSettingsActivity.java +++ b/src/com/android/phone/settings/PhoneAccountSettingsActivity.java @@ -19,6 +19,7 @@ package com.android.phone.settings; import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.MenuItem; +import android.view.WindowManager; import com.android.phone.R; @@ -28,6 +29,9 @@ public class PhoneAccountSettingsActivity extends PreferenceActivity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); + getWindow().addPrivateFlags( + WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + getActionBar().setTitle(R.string.phone_accounts); getFragmentManager().beginTransaction().replace( android.R.id.content, new PhoneAccountSettingsFragment()).commit(); diff --git a/src/com/android/phone/settings/VoicemailChangePinActivity.java b/src/com/android/phone/settings/VoicemailChangePinActivity.java index 33da27a53..cf852ec3d 100644 --- a/src/com/android/phone/settings/VoicemailChangePinActivity.java +++ b/src/com/android/phone/settings/VoicemailChangePinActivity.java @@ -343,6 +343,9 @@ public class VoicemailChangePinActivity extends Activity implements OnClickListe public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + getWindow().addPrivateFlags( + WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + mPhoneAccountHandle = getIntent().getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE); mConfig = new OmtpVvmCarrierConfigHelper(this, mPhoneAccountHandle); setContentView(R.layout.voicemail_change_pin); diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java index fea702bf5..1b3f31bb1 100644 --- a/src/com/android/phone/settings/VoicemailSettingsActivity.java +++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java @@ -37,6 +37,7 @@ import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.util.Log; import android.view.MenuItem; +import android.view.WindowManager; import android.widget.ListAdapter; import android.widget.Toast; @@ -217,6 +218,9 @@ public class VoicemailSettingsActivity extends PreferenceActivity @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); + getWindow().addPrivateFlags( + WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + // Make sure we are running as the primary user only if (UserHandle.myUserId() != UserHandle.USER_OWNER) { Toast.makeText(this, R.string.voice_number_setting_primary_user_only,