From a31c72511a855a7a50a7f370ca757ab75a7250a6 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Wed, 10 Feb 2016 16:21:18 -0800 Subject: [PATCH] Use DPM.uninstallPackageWithActiveAdmins() ... so that uninstall won't fail even if the package has other active admins. It's pretty much an edge case, so we don't show the deactivation confirmation in this case. Bug 27107878 Change-Id: I7e8b0843ac6e39e3db3bfc643eed6940e8577417 --- src/com/android/settings/DeviceAdminAdd.java | 25 ++------------------ 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index 0c928f6cfb0..364700be692 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -75,8 +75,6 @@ public class DeviceAdminAdd extends Activity { private static final int MAX_ADD_MSG_LINES_LANDSCAPE = 2; private static final int MAX_ADD_MSG_LINES = 15; - private static final int REQUEST_CODE_UNINSTALL = 1; - /** * Optional key to map to the package name of the Device Admin. * Currently only used when uninstalling an active device admin. @@ -325,7 +323,8 @@ public class DeviceAdminAdd extends Activity { public void onClick(View v) { EventLog.writeEvent(EventLogTags.EXP_DET_DEVICE_ADMIN_UNINSTALLED_BY_USER, mDeviceAdmin.getActivityInfo().applicationInfo.uid); - uninstall(); + mDPM.uninstallPackageWithActiveAdmins(mDeviceAdmin.getPackageName()); + finish(); } }); @@ -486,18 +485,6 @@ public class DeviceAdminAdd extends Activity { } } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) { - case REQUEST_CODE_UNINSTALL: - if (resultCode == RESULT_OK) { - finish(); - } - return; - } - super.onActivityResult(requestCode, resultCode, data); - } - void updateInterface() { mAdminIcon.setImageDrawable(mDeviceAdmin.loadIcon(getPackageManager())); mAdminName.setText(mDeviceAdmin.loadLabel(getPackageManager())); @@ -626,12 +613,4 @@ public class DeviceAdminAdd extends Activity { // System apps can't be uninstalled. return !mDeviceAdmin.getActivityInfo().applicationInfo.isSystemApp(); } - - private void uninstall() { - final Uri packageURI = Uri.parse("package:" + mDeviceAdmin.getPackageName()); - final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI); - uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, false); - uninstallIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); - startActivityForResult(uninstallIntent, REQUEST_CODE_UNINSTALL); - } }