summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy/java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-12-09 00:18:07 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-12-09 00:18:07 +0000
commitf66a43e398cc0be60aaf1a16a7b77f1cf0ff8f11 (patch)
tree7c28b182cd3e9b6fa9774db67afb2b9a12271054 /services/devicepolicy/java
parent6828d32772a8de221c0a83bae71d98c995d0fddc (diff)
parent81b27f4c9fcdb1e3379152d08a3abc0fb5e62c53 (diff)
downloadframeworks_base-f66a43e398cc0be60aaf1a16a7b77f1cf0ff8f11.zip
frameworks_base-f66a43e398cc0be60aaf1a16a7b77f1cf0ff8f11.tar.gz
frameworks_base-f66a43e398cc0be60aaf1a16a7b77f1cf0ff8f11.tar.bz2
am 81b27f4c: am b2905092: am 0702752c: Merge "Potential fix for accidental deactivation of profile owner" into lmp-mr1-dev
* commit '81b27f4c9fcdb1e3379152d08a3abc0fb5e62c53': Potential fix for accidental deactivation of profile owner
Diffstat (limited to 'services/devicepolicy/java')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 4d12111..54cca9b 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -304,8 +304,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
if (Intent.ACTION_USER_REMOVED.equals(action)) {
removeUserData(userHandle);
} else if (Intent.ACTION_USER_STARTED.equals(action)
- || Intent.ACTION_PACKAGE_CHANGED.equals(action)
- || Intent.ACTION_PACKAGE_REMOVED.equals(action)
|| Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
if (Intent.ACTION_USER_STARTED.equals(action)) {
@@ -314,8 +312,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
mUserData.remove(userHandle);
}
}
-
- handlePackagesChanged(userHandle);
+ handlePackagesChanged(null /* check all admins */, userHandle);
+ } else if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
+ || (Intent.ACTION_PACKAGE_ADDED.equals(action)
+ && intent.getBooleanExtra(Intent.EXTRA_REPLACING, false))) {
+ handlePackagesChanged(intent.getData().getSchemeSpecificPart(), userHandle);
+ } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)
+ && !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
+ handlePackagesChanged(intent.getData().getSchemeSpecificPart(), userHandle);
}
}
};
@@ -900,7 +904,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
- private void handlePackagesChanged(int userHandle) {
+ private void handlePackagesChanged(String packageName, int userHandle) {
boolean removed = false;
if (DBG) Slog.d(LOG_TAG, "Handling package changes for user " + userHandle);
DevicePolicyData policy = getUserData(userHandle);
@@ -909,11 +913,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
for (int i = policy.mAdminList.size() - 1; i >= 0; i--) {
ActiveAdmin aa = policy.mAdminList.get(i);
try {
- if (pm.getPackageInfo(aa.info.getPackageName(), 0, userHandle) == null
- || pm.getReceiverInfo(aa.info.getComponent(), 0, userHandle) == null) {
- removed = true;
- policy.mAdminList.remove(i);
- policy.mAdminMap.remove(aa.info.getComponent());
+ // If we're checking all packages or if the specific one we're checking matches,
+ // then check if the package and receiver still exist.
+ final String adminPackage = aa.info.getPackageName();
+ if (packageName == null || packageName.equals(adminPackage)) {
+ if (pm.getPackageInfo(adminPackage, 0, userHandle) == null
+ || pm.getReceiverInfo(aa.info.getComponent(), 0, userHandle)
+ == null) {
+ removed = true;
+ policy.mAdminList.remove(i);
+ policy.mAdminMap.remove(aa.info.getComponent());
+ }
}
} catch (RemoteException re) {
// Shouldn't happen