From 94302570e69be237fdf84f984fe048bf818a10c8 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 18 Oct 2019 12:04:25 -0700 Subject: [PATCH] Skip updating launcher state if it's already destroyed - Prior to ag/9526193, there were a mixture of getCreatedActivity() and passed in Activity calls. In the cases where we used the passed in activity, it would happily make the call even if the activity is already destroyed, but since we migrated to using the unified getCreatedActivity() call, it results in an NPE. Since it's unnecessary to update the destroyed activity, we can simply skip this work. Long term, we should consider baking the activity associated with the call into the activity interface, and ensure that the interface itself is updated whenever the activity is recreated. Bug: 141886704 Change-Id: I4f043e455d8d0d1c1b86362cc72618018bfbd900 Signed-off-by: Winson Chung --- .../quickstep/FallbackActivityInterface.java | 9 +++++ .../quickstep/LauncherActivityInterface.java | 35 +++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java index 3d1ecef466..f889bc1c1c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java @@ -75,6 +75,9 @@ public final class FallbackActivityInterface implements @Override public void onSwipeUpToRecentsComplete() { RecentsActivity activity = getCreatedActivity(); + if (activity == null) { + return; + } RecentsView recentsView = activity.getOverviewPanel(); recentsView.getClearAllButton().setVisibilityAlpha(1); recentsView.setDisallowScrollToClearAll(false); @@ -236,12 +239,18 @@ public final class FallbackActivityInterface implements public void onLaunchTaskFailed() { // TODO: probably go back to overview instead. RecentsActivity activity = getCreatedActivity(); + if (activity == null) { + return; + } activity.getOverviewPanel().startHome(); } @Override public void onLaunchTaskSuccess() { RecentsActivity activity = getCreatedActivity(); + if (activity == null) { + return; + } activity.onTaskLaunched(); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index 44063143d4..48b8fc6063 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -94,6 +94,9 @@ public final class LauncherActivityInterface implements BaseActivityInterface