Remove activityInfo from cache on package uninstall

We were keeping stale activityInfo objects from
package manager after an application got uninstalled.
We also were not removing task icons from the
cache after they were removed, which meant killing an
app and then re-opening would put 2 entries in the cache
since the two had unique process IDs.

fixes: 137731960
Test: Download app from play store, open it,
go to overview and observe that correct icon showing.
Uninstall it, download same app again, open it, and
in overview confirm that correct app icon is still showing

Change-Id: Icf482b0ad0ae66c10d52547582d8eeb2a544fb88
This commit is contained in:
Vinit Nayak committed 2019-08-08 11:11:03 -07:00
1 parent e529a86fbd
commit 268e4ff95c
3 files changed
+51 -13

No files matched your search

@@ -25,9 +25,12 @@ import android.os.Build;
import android.os.HandlerThread;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.LauncherAppsCompat.OnAppsChangedCallbackCompat;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
@@ -71,6 +74,7 @@ public class RecentsModel extends TaskStackChangeListener {
mIconCache = new TaskIconCache(context, loaderThread.getLooper());
mThumbnailCache = new TaskThumbnailCache(context, loaderThread.getLooper());
ActivityManagerWrapper.getInstance().registerTaskStackListener(this);
setupPackageListener();
}
public TaskIconCache getIconCache() {
@@ -169,6 +173,7 @@ public class RecentsModel extends TaskStackChangeListener {
public void onTaskRemoved(int taskId) {
Task.TaskKey dummyKey = new Task.TaskKey(taskId, 0, null, null, 0, 0);
mThumbnailCache.remove(dummyKey);
mIconCache.onTaskRemoved(dummyKey);
}
public void setSystemUiProxy(ISystemUiProxy systemUiProxy) {
@@ -203,6 +208,21 @@ public class RecentsModel extends TaskStackChangeListener {
}
}
private void setupPackageListener() {
LauncherAppsCompat.getInstance(mContext)
.addOnAppsChangedCallback(new OnAppsChangedCallbackCompat() {
@Override
public void onPackageRemoved(String packageName, UserHandle user) {
mIconCache.invalidatePackage(packageName);
}
@Override
public void onPackageChanged(String packageName, UserHandle user) {
mIconCache.invalidatePackage(packageName);
}
});
}
public void addThumbnailChangeListener(TaskThumbnailChangeListener listener) {
mThumbnailChangeListeners.add(listener);
}