Fix issue #2643754: Launcher is caching widget layouts for too long
With the .apk file names now changing during an update, we need
to make sure to flush all caches related to a package when the
package is removed. Otherwise we can continue to use the old
package, since its old file may still exist if we try to load it
too soon.
Change-Id: I15f08dffca3feac999dbca4f24bef12a30ca0a66
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 8383ca3..706e15a 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -12269,6 +12269,18 @@
}
}
+ private final void sendPackageBroadcastLocked(int cmd, String[] packages) {
+ for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) {
+ ProcessRecord r = mLruProcesses.get(i);
+ if (r.thread != null) {
+ try {
+ r.thread.dispatchPackageBroadcast(cmd, packages);
+ } catch (RemoteException ex) {
+ }
+ }
+ }
+ }
+
private final int broadcastIntentLocked(ProcessRecord callerApp,
String callerPackage, Intent intent, String resolvedType,
IIntentReceiver resultTo, int resultCode, String resultData,
@@ -12315,6 +12327,8 @@
for (String pkg : list) {
forceStopPackageLocked(pkg, -1, false, true, true);
}
+ sendPackageBroadcastLocked(
+ IApplicationThread.EXTERNAL_STORAGE_UNAVAILABLE, list);
}
} else {
Uri data = intent.getData();
@@ -12324,6 +12338,10 @@
forceStopPackageLocked(ssp,
intent.getIntExtra(Intent.EXTRA_UID, -1), false, true, true);
}
+ if (intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
+ sendPackageBroadcastLocked(IApplicationThread.PACKAGE_REMOVED,
+ new String[] {ssp});
+ }
}
}
}