From 4f25e1d5e3f94b761345a3286bf9c91a4df20f75 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 2 Mar 2011 22:39:49 -0800 Subject: [PATCH] Fix issue #3324032: 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: Iea1ff64c054452d307f91f349a815c0b244e9af5 --- src/com/android/settings/DeviceAdminAdd.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index 63998e53fd8..b2145b04594 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -19,6 +19,7 @@ package com.android.settings; import org.xmlpull.v1.XmlPullParserException; import android.app.Activity; +import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.Dialog; import android.app.admin.DeviceAdminInfo; @@ -35,6 +36,7 @@ import android.content.res.Resources; import android.os.Bundle; import android.os.Handler; import android.os.RemoteCallback; +import android.os.RemoteException; import android.text.TextUtils.TruncateAt; import android.util.Log; import android.view.Display; @@ -193,6 +195,12 @@ public class DeviceAdminAdd extends Activity { } finish(); } 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(), new RemoteCallback(mHandler) { @Override @@ -202,6 +210,10 @@ public class DeviceAdminAdd extends Activity { DeviceAdminReceiver.EXTRA_DISABLE_WARNING) : null; if (msg == null) { + try { + ActivityManagerNative.getDefault().resumeAppSwitches(); + } catch (RemoteException e) { + } mDPM.removeActiveAdmin(mDeviceAdmin.getComponent()); finish(); } else {