From dc3ef62960cae6b3341a7566533af3e181049ad6 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Wed, 10 Nov 2021 14:02:08 -0800 Subject: [PATCH] Check if recents exists before trying to relz to it In some situations (SUW) recents doesn't exist at the time of the gesture. In these situations, don't try to reference it. Bug: 205062356 Test: Dismiss AllSetActivity via swipe-up in SUW, observe no crash Change-Id: I3f1bfd04cfa4874475cd6d033376f24cb5b192a7 --- .../java/com/android/server/wm/InputMonitor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index d17c10906f069..83fd3fa3bbfe3 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -497,12 +497,16 @@ final class InputMonitor { resetInputConsumers(mInputTransaction); // Update recents input consumer layer if active - if (mAddRecentsAnimationInputConsumerHandle - && getWeak(mActiveRecentsActivity) != null) { - final WindowContainer layer = getWeak(mActiveRecentsLayerRef); - mRecentsAnimationInputConsumer.show(mInputTransaction, - layer != null ? layer : getWeak(mActiveRecentsActivity)); - mAddRecentsAnimationInputConsumerHandle = false; + final ActivityRecord activeRecents = getWeak(mActiveRecentsActivity); + if (mAddRecentsAnimationInputConsumerHandle && activeRecents != null + && activeRecents.getSurfaceControl() != null) { + WindowContainer layer = getWeak(mActiveRecentsLayerRef); + layer = layer != null ? layer : activeRecents; + // Handle edge-case for SUW where windows don't exist yet + if (layer.getSurfaceControl() != null) { + mRecentsAnimationInputConsumer.show(mInputTransaction, layer); + mAddRecentsAnimationInputConsumerHandle = false; + } } mDisplayContent.forAllWindows(this, true /* traverseTopToBottom */); updateInputFocusRequest(mRecentsAnimationInputConsumer);