summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2014-12-18 16:50:48 +0000
committerRubin Xu <rubinxu@google.com>2014-12-18 17:18:42 +0000
commit90d74b0df18331b9d7493757cb9e4da9a3e9fff7 (patch)
tree30424a89e8ad8ad8a38a40e3ea365bd4a62b2edf
parentf16d8735066ead696943177d4884e00f298508c9 (diff)
downloadandroid_packages_apps_PackageInstaller-90d74b0df18331b9d7493757cb9e4da9a3e9fff7.tar.gz
android_packages_apps_PackageInstaller-90d74b0df18331b9d7493757cb9e4da9a3e9fff7.tar.bz2
android_packages_apps_PackageInstaller-90d74b0df18331b9d7493757cb9e4da9a3e9fff7.zip
Show appropriate UI when uninstalling blocked by device admin.
If the uninstallation is blocked by device admin in secondary user, the UI shouldn't lead the user to the admin settings of current user. Bug: 17668398 Change-Id: I0b2ae67d434bdc4f5c439e8b7b05cdcc798f2f31
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index ec3295a2..5b50acd4 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -70,6 +70,14 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
private static final int UNINSTALL_COMPLETE = 1;
+ private boolean isProfileOfOrSame(UserManager userManager, int userId, int profileId) {
+ if (userId == profileId) {
+ return true;
+ }
+ UserInfo parentUser = userManager.getProfileParent(profileId);
+ return parentUser != null && parentUser.id == userId;
+ }
+
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -118,10 +126,9 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
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;
+ // We only catch the case when the user in question is neither the
+ // current user nor its profile.
+ if (isProfileOfOrSame(userManager, myUserId, user.id)) continue;
try {
if (dpm.packageHasActiveAdmins(packageName, user.id)) {
@@ -168,7 +175,12 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
Log.e(TAG, "Failed to talk to package manager", e);
}
}
- mDeviceManagerButton.setVisibility(View.VISIBLE);
+ int myUserId = UserHandle.myUserId();
+ if (isProfileOfOrSame(userManager, myUserId, blockingUserId)) {
+ mDeviceManagerButton.setVisibility(View.VISIBLE);
+ } else {
+ mDeviceManagerButton.setVisibility(View.GONE);
+ }
if (blockingUserId == UserHandle.USER_OWNER) {
statusText = getString(R.string.uninstall_blocked_device_owner);
} else if (blockingUserId == UserHandle.USER_NULL) {