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. Test: CtsVerifier -> Device Administration -> Device Admin Tapjacking Test Bug: 35056974 Change-Id: I292a44e713ea4a4b0305ca3b3b21f1c82fd73c2b Merged-In: I292a44e713ea4a4b0305ca3b3b21f1c82fd73c2b
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
@@ -72,7 +74,6 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
Handler mHandler;
|
Handler mHandler;
|
||||||
|
|
||||||
DevicePolicyManager mDPM;
|
DevicePolicyManager mDPM;
|
||||||
AppOpsManager mAppOps;
|
|
||||||
DeviceAdminInfo mDeviceAdmin;
|
DeviceAdminInfo mDeviceAdmin;
|
||||||
CharSequence mAddMsgText;
|
CharSequence mAddMsgText;
|
||||||
String mProfileOwnerName;
|
String mProfileOwnerName;
|
||||||
@@ -94,17 +95,15 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
boolean mWaitingForRemoveMsg;
|
boolean mWaitingForRemoveMsg;
|
||||||
boolean mAddingProfileOwner;
|
boolean mAddingProfileOwner;
|
||||||
boolean mAdminPoliciesInitialized;
|
boolean mAdminPoliciesInitialized;
|
||||||
int mCurSysAppOpMode;
|
|
||||||
int mCurToastAppOpMode;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||||
|
|
||||||
mHandler = new Handler(getMainLooper());
|
mHandler = new Handler(getMainLooper());
|
||||||
|
|
||||||
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE);
|
|
||||||
PackageManager packageManager = getPackageManager();
|
PackageManager packageManager = getPackageManager();
|
||||||
|
|
||||||
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
|
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
|
||||||
@@ -377,24 +376,14 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
mActionButton.setEnabled(true);
|
||||||
updateInterface();
|
updateInterface();
|
||||||
// As long as we are running, don't let this admin overlay stuff on top of the screen.
|
|
||||||
final int uid = mDeviceAdmin.getActivityInfo().applicationInfo.uid;
|
|
||||||
final String pkg = mDeviceAdmin.getActivityInfo().applicationInfo.packageName;
|
|
||||||
mCurSysAppOpMode = mAppOps.checkOp(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg);
|
|
||||||
mCurToastAppOpMode = mAppOps.checkOp(AppOpsManager.OP_TOAST_WINDOW, uid, pkg);
|
|
||||||
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, AppOpsManager.MODE_IGNORED);
|
|
||||||
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, AppOpsManager.MODE_IGNORED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
// As long as we are running, don't let this admin overlay stuff on top of the screen.
|
mActionButton.setEnabled(false);
|
||||||
final int uid = mDeviceAdmin.getActivityInfo().applicationInfo.uid;
|
|
||||||
final String pkg = mDeviceAdmin.getActivityInfo().applicationInfo.packageName;
|
|
||||||
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, mCurSysAppOpMode);
|
|
||||||
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, mCurToastAppOpMode);
|
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().resumeAppSwitches();
|
ActivityManagerNative.getDefault().resumeAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
Reference in New Issue
Block a user