summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2014-03-14 19:16:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-14 19:16:07 +0000
commit5e0e7b56a98ecf8e13100b4b6c7e2c2a64c3d938 (patch)
tree79ad7e2b4676a73620a36c2289e7e5162642fda9 /core/java
parent09d47bbb43fcda1d1cc05f88849ed011a84d0d60 (diff)
parent0598d7075ed739c9fcf115b4f3a417483ee32f84 (diff)
Merge "Make RegisteredServicesCache understand ASEC-based updates"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/pm/RegisteredServicesCache.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java
index 875e8de2daed..4a743a50261f 100644
--- a/core/java/android/content/pm/RegisteredServicesCache.java
+++ b/core/java/android/content/pm/RegisteredServicesCache.java
@@ -140,12 +140,33 @@ public abstract class RegisteredServicesCache<V> {
mContext.registerReceiver(mExternalReceiver, sdFilter);
}
+ private final void handlePackageEvent(Intent intent, int userId) {
+ // Don't regenerate the services map when the package is removed or its
+ // ASEC container unmounted as a step in replacement. The subsequent
+ // _ADDED / _AVAILABLE call will regenerate the map in the final state.
+ final String action = intent.getAction();
+ // it's a new-component action if it isn't some sort of removal
+ final boolean isRemoval = Intent.ACTION_PACKAGE_REMOVED.equals(action)
+ || Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action);
+ // if it's a removal, is it part of an update-in-place step?
+ final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
+
+ if (isRemoval && replacing) {
+ // package is going away, but it's the middle of an upgrade: keep the current
+ // state and do nothing here. This clause is intentionally empty.
+ } else {
+ // either we're adding/changing, or it's a removal without replacement, so
+ // we need to recalculate the set of available services
+ generateServicesMap(userId);
+ }
+ }
+
private final BroadcastReceiver mPackageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
if (uid != -1) {
- generateServicesMap(UserHandle.getUserId(uid));
+ handlePackageEvent(intent, UserHandle.getUserId(uid));
}
}
};
@@ -154,7 +175,7 @@ public abstract class RegisteredServicesCache<V> {
@Override
public void onReceive(Context context, Intent intent) {
// External apps can't coexist with multi-user, so scan owner
- generateServicesMap(UserHandle.USER_OWNER);
+ handlePackageEvent(intent, UserHandle.USER_OWNER);
}
};