Cherry-pick from master: Fix issue #3324032:

(I forgot to commit this before the MR2 branch was made.)

It is possible to create an app that cannot...
...be uninstalled using device policy managers

Don't allow app switches while we are bringing up the confirmation
dialog.  This prevents the app from pushing us out of the intended
settings app flow.

Change-Id: Id670e231ac47346478d22a3f59bb4a44a68ef7b2
This commit is contained in:
Dianne Hackborn
2011-03-02 22:39:49 -08:00
parent d85ce3c9ea
commit e2e7cf650d

View File

@@ -19,6 +19,7 @@ package com.android.settings;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.admin.DeviceAdminInfo; import android.app.admin.DeviceAdminInfo;
@@ -35,6 +36,7 @@ import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.RemoteCallback; import android.os.RemoteCallback;
import android.os.RemoteException;
import android.text.TextUtils.TruncateAt; import android.text.TextUtils.TruncateAt;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
@@ -193,6 +195,12 @@ public class DeviceAdminAdd extends Activity {
} }
finish(); finish();
} else { } else {
try {
// Don't allow the admin to put a dialog up in front
// of us while we interact with the user.
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) {
}
mDPM.getRemoveWarning(mDeviceAdmin.getComponent(), mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),
new RemoteCallback(mHandler) { new RemoteCallback(mHandler) {
@Override @Override
@@ -202,6 +210,10 @@ public class DeviceAdminAdd extends Activity {
DeviceAdminReceiver.EXTRA_DISABLE_WARNING) DeviceAdminReceiver.EXTRA_DISABLE_WARNING)
: null; : null;
if (msg == null) { if (msg == null) {
try {
ActivityManagerNative.getDefault().resumeAppSwitches();
} catch (RemoteException e) {
}
mDPM.removeActiveAdmin(mDeviceAdmin.getComponent()); mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
finish(); finish();
} else { } else {