summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/UninstallAppProgress.java
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2014-12-12 19:09:25 +0000
committerRubin Xu <rubinxu@google.com>2014-12-17 17:45:32 +0000
commitf16d8735066ead696943177d4884e00f298508c9 (patch)
tree43157dd6590275d205213baaa132a3c88f2a686f /src/com/android/packageinstaller/UninstallAppProgress.java
parent5d1c66f9e07f0ea2ffcd68e2dd10f4cdb68c27ba (diff)
downloadandroid_packages_apps_PackageInstaller-f16d8735066ead696943177d4884e00f298508c9.tar.gz
android_packages_apps_PackageInstaller-f16d8735066ead696943177d4884e00f298508c9.tar.bz2
android_packages_apps_PackageInstaller-f16d8735066ead696943177d4884e00f298508c9.zip
Show appropriate UI when uninstalling fails due to being device admin.
If the app being uninstalled is a secondary user's device admin rather than the current user or profile owner, the uninstallation failure activity should state so clearly, and it should not lead the user to the device administrator settings of the current user. Bug: 17668398 Change-Id: Ib81840b7b2928624bc57cce949cfb2a2d9de604a
Diffstat (limited to 'src/com/android/packageinstaller/UninstallAppProgress.java')
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index 68d053ae..ec3295a2 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -17,6 +17,7 @@
package com.android.packageinstaller;
import android.app.Activity;
+import android.app.admin.IDevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -54,7 +55,6 @@ import java.util.List;
*/
public class UninstallAppProgress extends Activity implements OnClickListener {
private final String TAG="UninstallAppProgress";
- private boolean localLOGV = false;
private ApplicationInfo mAppInfo;
private boolean mAllUsers;
@@ -109,13 +109,46 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
Toast.makeText(ctx, statusText, Toast.LENGTH_LONG).show();
setResultAndFinish(mResultCode);
return;
- case PackageManager.DELETE_FAILED_DEVICE_POLICY_MANAGER:
- Log.d(TAG, "Uninstall failed because " + packageName
- + " is a device admin");
- mDeviceManagerButton.setVisibility(View.VISIBLE);
- statusText = getString(R.string.uninstall_failed_device_policy_manager);
+ case PackageManager.DELETE_FAILED_DEVICE_POLICY_MANAGER: {
+ UserManager userManager =
+ (UserManager) getSystemService(Context.USER_SERVICE);
+ IDevicePolicyManager dpm = IDevicePolicyManager.Stub.asInterface(
+ ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
+ // Find out if the package is an active admin for some non-current user.
+ int myUserId = UserHandle.myUserId();
+ UserInfo otherBlockingUser = null;
+ for (UserInfo user : userManager.getUsers()) {
+ if (user.id == myUserId) continue;
+ UserInfo parentUser = userManager.getProfileParent(user.id);
+ // User in question is a profile of current user
+ if (parentUser != null && parentUser.id == myUserId) continue;
+
+ try {
+ if (dpm.packageHasActiveAdmins(packageName, user.id)) {
+ otherBlockingUser = user;
+ break;
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to talk to package manager", e);
+ }
+ }
+ if (otherBlockingUser == null) {
+ Log.d(TAG, "Uninstall failed because " + packageName
+ + " is a device admin");
+ mDeviceManagerButton.setVisibility(View.VISIBLE);
+ statusText = getString(
+ R.string.uninstall_failed_device_policy_manager);
+ } else {
+ Log.d(TAG, "Uninstall failed because " + packageName
+ + " is a device admin of user " + otherBlockingUser);
+ mDeviceManagerButton.setVisibility(View.GONE);
+ statusText = String.format(
+ getString(R.string.uninstall_failed_device_policy_manager_of_user),
+ otherBlockingUser.name);
+ }
break;
- case PackageManager.DELETE_FAILED_OWNER_BLOCKED:
+ }
+ case PackageManager.DELETE_FAILED_OWNER_BLOCKED: {
UserManager userManager =
(UserManager) getSystemService(Context.USER_SERVICE);
IPackageManager packageManager = IPackageManager.Stub.asInterface(
@@ -149,6 +182,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
userName);
}
break;
+ }
default:
Log.d(TAG, "Uninstall failed for " + packageName + " with code "
+ msg.arg1);