From de5df8b0902070c949dd9fdab8bbedfff61f43ab Mon Sep 17 00:00:00 2001 From: Suprabh Shukla Date: Tue, 15 Aug 2017 02:11:26 +0000 Subject: [PATCH] Disabling the activate button when paused This revises the previous attempt to drop taps when another window is obscuring the device admin details. Any system alert windows or toasts are disabled when the activity is in focus, otherwise the button is disabled so no floating activities can obscure it and delegate taps back to the security sensitive "Activate" button. Bug: 35056974 Change-Id: I292a44e713ea4a4b0305ca3b3b21f1c82fd73c2b Merged-In: I292a44e713ea4a4b0305ca3b3b21f1c82fd73c2b --- src/com/android/settings/DeviceAdminAdd.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index 62340380051..5e05a22ff7e 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -16,6 +16,8 @@ package com.android.settings; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + import org.xmlpull.v1.XmlPullParserException; import android.app.Activity; @@ -88,7 +90,7 @@ public class DeviceAdminAdd extends Activity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); - + getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); mHandler = new Handler(getMainLooper()); mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); @@ -264,13 +266,20 @@ public class DeviceAdminAdd extends Activity { } }); } - + @Override protected void onResume() { super.onResume(); + mActionButton.setEnabled(true); updateInterface(); } - + + @Override + protected void onPause() { + super.onPause(); + mActionButton.setEnabled(false); + } + @Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) {