Merge cherrypicks of [2908873, 2908950, 2908867, 2908868, 2908791, 2908793, 2908989, 2908796, 2908798, 2908800, 2908802, 2908804, 2908806, 2908808, 2908632, 2908634, 2908914, 2909049, 2909051, 2908973, 2908874] into nyc-bugfix-release

Change-Id: Id8a41d6076d93a29fecd55e50b2aa33d0950ad77
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 1903f91..7e0d3b6 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -16,7 +16,6 @@
 */
 package com.android.packageinstaller;
 
-import android.app.Activity;
 import android.app.ActivityManagerNative;
 import android.app.AlertDialog;
 import android.app.Dialog;
@@ -52,6 +51,8 @@
 import android.widget.TextView;
 import com.android.packageinstaller.permission.utils.Utils;
 
+import com.android.packageinstaller.permission.ui.OverlayTouchActivity;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -68,7 +69,8 @@
  * Based on the user response the package is then installed by launching InstallAppConfirm
  * sub activity. All state transitions are handled in this activity
  */
-public class PackageInstallerActivity extends Activity implements OnCancelListener, OnClickListener {
+public class PackageInstallerActivity extends OverlayTouchActivity implements OnCancelListener,
+        OnClickListener {
     private static final String TAG = "PackageInstaller";
 
     private static final int REQUEST_ENABLE_UNKNOWN_SOURCES = 1;
@@ -214,6 +216,25 @@
         }
     }
 
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        if (mOk != null) {
+            mOk.setEnabled(mOkCanInstall);
+        }
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+
+        if (mOk != null) {
+            // Don't allow the install button to be clicked as there might be overlays
+            mOk.setEnabled(false);
+        }
+    }
+
     private void showDialogInner(int id) {
         // TODO better fix for this? Remove dialog so that it gets created again
         removeDialog(id);