Back-port ag/2491664
Bug: 62196835
Test: Verify overlays disappear on a11y capabilities
dialog.
Change-Id: Ic675012dd9faa8e53d1d4b126b3ba68fecdab992
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ad84ff9..95f562f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -70,6 +70,7 @@
<uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" />
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
<uses-permission android:name="android.permission.OEM_UNLOCK_STATE" />
+ <uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS" />
<application android:label="@string/settings_label"
android:icon="@mipmap/ic_launcher_settings"
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 0b7600b..d321831 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -33,6 +33,8 @@
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -49,6 +51,8 @@
import java.util.List;
import java.util.Set;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
public class ToggleAccessibilityServicePreferenceFragment
extends ToggleFeaturePreferenceFragment implements DialogInterface.OnClickListener {
@@ -182,6 +186,10 @@
.create();
ad.create();
ad.getButton(AlertDialog.BUTTON_POSITIVE).setFilterTouchesWhenObscured(true);
+ Window window = ad.getWindow();
+ WindowManager.LayoutParams params = window.getAttributes();
+ params.privateFlags |= PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+ window.setAttributes(params);
return ad;
}
case DIALOG_ID_DISABLE_WARNING: {