From 7f8e57ed68f4b890d1136e16c404001115f28c7b Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Mon, 10 Jan 2022 18:00:58 +0800 Subject: [PATCH] Fix NPE when consuming snapshots for recent animation Fix: 207716265 Test: no exception throws after recent animation Change-Id: Ic35aea2285fb120f7d0b5215137ad9450518702f --- .../src/com/android/quickstep/GestureState.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 01f6e23f7e..ed0623da24 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; +import android.annotation.Nullable; import android.annotation.TargetApi; import android.app.ActivityManager; import android.content.Intent; @@ -397,11 +398,15 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL * while STATE_RECENTS_ANIMATION_CANCELED state is being set, and the caller is responsible for * calling {@link RecentsAnimationController#cleanupScreenshot()}. */ + @Nullable HashMap consumeRecentsAnimationCanceledSnapshot() { - HashMap data = - new HashMap(mRecentsAnimationCanceledSnapshots); - mRecentsAnimationCanceledSnapshots = null; - return data; + if (mRecentsAnimationCanceledSnapshots != null) { + HashMap data = + new HashMap(mRecentsAnimationCanceledSnapshots); + mRecentsAnimationCanceledSnapshots = null; + return data; + } + return null; } void setSwipeUpStartTimeMs(long uptimeMs) {