resolve merge conflicts of 94c5202965 to oc-dr1-dev

Bug: 62196835
Test: I solemnly swear I tested this conflict resolution.

Merged-In: I7c8d8b4143a5dd1cb684c31c4503608c8d5be0e3
Change-Id: I1bd77f165d1206ea139961bc0c42ad74c1d4bfaf
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a5affc9..5419fac 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -84,6 +84,7 @@
     <uses-permission android:name="android.permission.DELETE_PACKAGES"/>
     <uses-permission android:name="android.permission.MANAGE_APP_OPS_RESTRICTIONS"/>
     <uses-permission android:name="android.permission.NETWORK_SETTINGS" />
+    <uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
 
     <application android:label="@string/settings_label"
             android:icon="@drawable/ic_launcher_settings"
diff --git a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
index 0a6932f..c1c8a64 100644
--- a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
+++ b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
@@ -27,6 +27,8 @@
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -37,6 +39,8 @@
 import java.util.List;
 import java.util.Locale;
 
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
 /**
  * Utility class for creating the dialog that asks users for explicit permission to grant
  * all of the requested capabilities to an accessibility service before the service is enabled
@@ -65,6 +69,10 @@
             return false;
         };
 
+        Window window = ad.getWindow();
+        WindowManager.LayoutParams params = window.getAttributes();
+        params.privateFlags |= PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+        window.setAttributes(params);
         ad.create();
         ad.getButton(AlertDialog.BUTTON_POSITIVE).setOnTouchListener(filterTouchListener);
         ad.setCanceledOnTouchOutside(true);
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
index ae57f06..04456c2 100644
--- a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -16,6 +16,7 @@
 package com.android.settings.accessibility;
 
 import static android.content.DialogInterface.BUTTON_POSITIVE;
+
 import static com.android.settings.Utils.setOverlayAllowed;
 
 import android.accessibilityservice.AccessibilityServiceInfo;
@@ -147,22 +148,6 @@
         }
 
         @Override
-        public void onResume() {
-            super.onResume();
-            if (mToken != null) {
-                setOverlayAllowed(getActivity(), mToken, false);
-            }
-        }
-
-        @Override
-        public void onPause() {
-            super.onPause();
-            if (mToken != null) {
-                setOverlayAllowed(getActivity(), mToken, true);
-            }
-        }
-
-        @Override
         public void onClick(DialogInterface dialog, int which) {
             final Fragment fragment = getTargetFragment();
             if ((which == BUTTON_POSITIVE) && (fragment instanceof DefaultAppPickerFragment)) {
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 976a743..433a954 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -72,8 +72,6 @@
 
     private int mShownDialogId;
 
-    private final IBinder mToken = new Binder();
-
     @Override
     public int getMetricsCategory() {
         return MetricsEvent.ACCESSIBILITY_SERVICE;
@@ -96,18 +94,12 @@
     public void onResume() {
         mSettingsContentObserver.register(getContentResolver());
         updateSwitchBarToggleSwitch();
-        if (mToken != null) {
-            setOverlayAllowed(getActivity(), mToken, false);
-        }
         super.onResume();
     }
 
     @Override
     public void onPause() {
         mSettingsContentObserver.unregister(getContentResolver());
-        if (mToken != null) {
-            setOverlayAllowed(getActivity(), mToken, true);
-        }
         super.onPause();
     }