Disabling the activate button when paused
am: af5d8b9b03
Change-Id: Icf4cd1c4ff5a520a72f9deedf85c486e892da250
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