Merge the 2021-02-05 SPL branch from AOSP-Partner

* security-aosp-pi-release:
  DO NOT MERGE: Hide overlays over uninstall confirm dialog
  RESTRICT AUTOMERGE Don't allow tapjacking permissioncontroller

Change-Id: I92104994fb0d31cd1d17eec59e412675a159cb68
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 67e0b4c..9a094d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -133,7 +133,7 @@
         <activity android:name=".permission.ui.GrantPermissionsActivity"
                 android:configChanges="orientation|keyboardHidden|screenSize"
                 android:excludeFromRecents="true"
-                android:theme="@style/GrantPermissions"
+                android:theme="@style/GrantPermissions.FilterTouches"
                 android:visibleToInstantApps="true">
             <intent-filter android:priority="1">
                 <action android:name="android.content.pm.action.REQUEST_PERMISSIONS" />
@@ -145,7 +145,7 @@
                   android:configChanges="orientation|keyboardHidden|screenSize"
                   android:excludeFromRecents="true"
                   android:label="@string/app_permissions"
-                  android:theme="@style/Settings"
+                  android:theme="@style/Settings.FilterTouches"
                   android:permission="android.permission.GRANT_RUNTIME_PERMISSIONS">
             <intent-filter android:priority="1">
                 <action android:name="android.intent.action.MANAGE_PERMISSIONS" />
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 649b303..b07b103 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -42,6 +42,7 @@
         <item name="android:textAppearanceMedium">@style/MediumText</item>
         <item name="android:textAppearanceSmall">@style/SmallText</item>
         <item name="android:titleTextStyle">@style/TitleText</item>
+        <item name="android:filterTouchesWhenObscured">true</item>
     </style>
 
     <style name="DialogWhenLargeNoAnimation" parent="DialogWhenLarge">
@@ -58,4 +59,20 @@
     </style>
 
 
+
+
+<!-- Do not allow OEMs to overlay these themes.
+ Must Guarantee that filterTouches is set for these activities -->
+    <style name="FilterTouches">
+        <item name="android:filterTouchesWhenObscured">true</item>
+    </style>
+
+    <style name="Settings.FilterTouches">
+        <item name="android:filterTouchesWhenObscured">true</item>
+    </style>
+
+    <style name="GrantPermissions.FilterTouches">
+        <item name="android:filterTouchesWhenObscured">true</item>
+    </style>
+
 </resources>
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index d50cf19..3172c16 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -17,8 +17,8 @@
 package com.android.packageinstaller;
 
 import static android.app.AppOpsManager.MODE_ALLOWED;
-
 import static com.android.packageinstaller.PackageUtil.getMaxTargetSdkVersionForUid;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
 
 import android.Manifest;
 import android.app.Activity;
@@ -87,6 +87,8 @@
 
     @Override
     public void onCreate(Bundle icicle) {
+        getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
         // Never restore any state, esp. never create any fragments. The data in the fragment might
         // be stale, if e.g. the app was uninstalled while the activity was destroyed.
         super.onCreate(null);