From 4dd6ab3ca1cca7149cbf3877eed424591ae462d1 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Fri, 15 May 2020 11:01:06 -0700 Subject: [PATCH] Deference mAppPredictor on destroy + Also remove PredictionModel.mCachedComponentKeys Bug: 156747920 Bug: 156041043 Test: Manual Change-Id: I56dac1c6ac0a1bb93363342006232fc1ba42a3b4 --- .../HotseatPredictionController.java | 1 + .../launcher3/model/PredictionModel.java | 19 ++++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 7a73e50da8..1fe364386e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -274,6 +274,7 @@ public class HotseatPredictionController implements DragController.DragListener, } if (mAppPredictor != null) { mAppPredictor.destroy(); + mAppPredictor = null; } WeakReference controllerRef = new WeakReference<>(this); diff --git a/src/com/android/launcher3/model/PredictionModel.java b/src/com/android/launcher3/model/PredictionModel.java index f8140eb87a..1429843b7e 100644 --- a/src/com/android/launcher3/model/PredictionModel.java +++ b/src/com/android/launcher3/model/PredictionModel.java @@ -43,7 +43,6 @@ public class PredictionModel implements ResourceBasedOverride { private static final int MAX_CACHE_ITEMS = 5; protected Context mContext; - private ArrayList mCachedComponentKeys; private SharedPreferences mDevicePrefs; private UserCache mUserCache; @@ -78,7 +77,6 @@ public class PredictionModel implements ResourceBasedOverride { builder.append("\n"); } mDevicePrefs.edit().putString(CACHED_ITEMS_KEY, builder.toString()).apply(); - mCachedComponentKeys = null; }); } @@ -89,17 +87,16 @@ public class PredictionModel implements ResourceBasedOverride { @WorkerThread public List getPredictionComponentKeys() { Preconditions.assertWorkerThread(); - if (mCachedComponentKeys == null) { - mCachedComponentKeys = new ArrayList<>(); - String cachedBlob = mDevicePrefs.getString(CACHED_ITEMS_KEY, ""); - for (String line : cachedBlob.split("\n")) { - ComponentKey key = getComponentKeyFromSerializedString(line); - if (key != null) { - mCachedComponentKeys.add(key); - } + ArrayList items = new ArrayList<>(); + String cachedBlob = mDevicePrefs.getString(CACHED_ITEMS_KEY, ""); + for (String line : cachedBlob.split("\n")) { + ComponentKey key = getComponentKeyFromSerializedString(line); + if (key != null) { + items.add(key); } + } - return mCachedComponentKeys; + return items; } private String serializeComponentKeyToString(ComponentKey componentKey) {