Merge "Log last appeared task id instead of target" into ub-launcher3-rvc-dev
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 7a73e50..1fe3643 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 @@
         }
         if (mAppPredictor != null) {
             mAppPredictor.destroy();
+            mAppPredictor = null;
         }
         WeakReference<HotseatPredictionController> controllerRef = new WeakReference<>(this);
 
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index b240f0b..475305f 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -35,50 +35,50 @@
     }
 
     public enum LauncherEvent implements EventEnum {
-        @LauncherUiEvent(doc = "App launched from workspace, hotseat or folder in launcher")
+        @UiEvent(doc = "App launched from workspace, hotseat or folder in launcher")
         LAUNCHER_APP_LAUNCH_TAP(338),
 
-        @LauncherUiEvent(doc = "Task launched from overview using TAP")
+        @UiEvent(doc = "Task launched from overview using TAP")
         LAUNCHER_TASK_LAUNCH_TAP(339),
 
-        @LauncherUiEvent(doc = "Task launched from overview using SWIPE DOWN")
+        @UiEvent(doc = "Task launched from overview using SWIPE DOWN")
         LAUNCHER_TASK_LAUNCH_SWIPE_DOWN(340),
 
-        @LauncherUiEvent(doc = "TASK dismissed from overview using SWIPE UP")
+        @UiEvent(doc = "TASK dismissed from overview using SWIPE UP")
         LAUNCHER_TASK_DISMISS_SWIPE_UP(341),
 
-        @LauncherUiEvent(doc = "User dragged a launcher item")
+        @UiEvent(doc = "User dragged a launcher item")
         LAUNCHER_ITEM_DRAG_STARTED(383),
 
-        @LauncherUiEvent(doc = "A dragged launcher item is successfully dropped")
+        @UiEvent(doc = "A dragged launcher item is successfully dropped")
         LAUNCHER_ITEM_DROP_COMPLETED(385),
 
-        @LauncherUiEvent(doc = "A dragged launcher item is successfully dropped on another item "
+        @UiEvent(doc = "A dragged launcher item is successfully dropped on another item "
                 + "resulting in a new folder creation")
         LAUNCHER_ITEM_DROP_FOLDER_CREATED(386),
 
-        @LauncherUiEvent(doc = "User action resulted in or manually updated the folder label to "
+        @UiEvent(doc = "User action resulted in or manually updated the folder label to "
                 + "new/same value.")
         LAUNCHER_FOLDER_LABEL_UPDATED(460),
 
-        @LauncherUiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar")
+        @UiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar")
         LAUNCHER_ITEM_DROPPED_ON_REMOVE(465),
 
-        @LauncherUiEvent(doc = "A dragged item is dropped on 'Cancel' button in the target bar")
+        @UiEvent(doc = "A dragged item is dropped on 'Cancel' button in the target bar")
         LAUNCHER_ITEM_DROPPED_ON_CANCEL(466),
 
-        @LauncherUiEvent(doc = "A predicted item is dragged and dropped on 'Don't suggest app'"
+        @UiEvent(doc = "A predicted item is dragged and dropped on 'Don't suggest app'"
                 + " button in the target bar")
         LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST(467),
 
-        @LauncherUiEvent(doc = "A dragged item is dropped on 'Uninstall' button in target bar")
+        @UiEvent(doc = "A dragged item is dropped on 'Uninstall' button in target bar")
         LAUNCHER_ITEM_DROPPED_ON_UNINSTALL(468),
 
-        @LauncherUiEvent(doc = "User completed uninstalling the package after dropping on "
+        @UiEvent(doc = "User completed uninstalling the package after dropping on "
                 + "the icon onto 'Uninstall' button in the target bar")
         LAUNCHER_ITEM_UNINSTALL_COMPLETED(469),
 
-        @LauncherUiEvent(doc = "User cancelled uninstalling the package after dropping on "
+        @UiEvent(doc = "User cancelled uninstalling the package after dropping on "
                 + "the icon onto 'Uninstall' button in the target bar")
         LAUNCHER_ITEM_UNINSTALL_CANCELLED(470);
         // ADD MORE
diff --git a/src/com/android/launcher3/logging/LauncherUiEvent.java b/src/com/android/launcher3/logging/UiEvent.java
similarity index 80%
rename from src/com/android/launcher3/logging/LauncherUiEvent.java
rename to src/com/android/launcher3/logging/UiEvent.java
index 4507ff7..20d6c72 100644
--- a/src/com/android/launcher3/logging/LauncherUiEvent.java
+++ b/src/com/android/launcher3/logging/UiEvent.java
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package com.android.launcher3.logging;
 
 import static java.lang.annotation.ElementType.FIELD;
@@ -23,8 +24,11 @@
 
 @Retention(SOURCE)
 @Target(FIELD)
-public @interface LauncherUiEvent {
-    /** An explanation, suitable for Android analysts, of the UI event that this log represents. */
+//  Copy of frameworks/base/core/java/com/android/internal/logging/UiEvent.java
+public @interface UiEvent {
+
+    /**
+     * An explanation, suitable for Android analysts, of the UI event that this log represents.
+     */
     String doc();
 }
-
diff --git a/src/com/android/launcher3/model/PredictionModel.java b/src/com/android/launcher3/model/PredictionModel.java
index f8140eb..1429843 100644
--- a/src/com/android/launcher3/model/PredictionModel.java
+++ b/src/com/android/launcher3/model/PredictionModel.java
@@ -43,7 +43,6 @@
     private static final int MAX_CACHE_ITEMS = 5;
 
     protected Context mContext;
-    private ArrayList<ComponentKey> mCachedComponentKeys;
     private SharedPreferences mDevicePrefs;
     private UserCache mUserCache;
 
@@ -78,7 +77,6 @@
                 builder.append("\n");
             }
             mDevicePrefs.edit().putString(CACHED_ITEMS_KEY, builder.toString()).apply();
-            mCachedComponentKeys = null;
         });
     }
 
@@ -89,17 +87,16 @@
     @WorkerThread
     public List<ComponentKey> 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<ComponentKey> 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) {
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index b333100..4493279 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1323,6 +1323,16 @@
                 if (mCheckEventsForSuccessfulGestures) {
                     final String message = sEventChecker.verify(WAIT_TIME_MS, true);
                     if (message != null) {
+                        try {
+                            Log.e("b/156287114", "Input:");
+                            for (String line : mDevice.executeShellCommand("dumpsys input").split(
+                                    "\\n")) {
+                                Log.d("b/156287114", line);
+                            }
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+
                         checkForAnomaly();
                         Assert.fail(formatSystemHealthMessage(
                                 "http://go/tapl : successful gesture produced " + message));