From 33b07be41984ee3b750c361104a67df5095f2f51 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 2 Feb 2023 15:21:42 +0800 Subject: [PATCH] Check null for top activity when updating orientation Ideally if 'r' is non-null, topRunningActivity() should at least find it. But there may be corner cases such as all activities in the display are finishing, or other places didn't clear orientation source correctly for an empty display. Bug: 266896543 Test: DisplayContentTests Change-Id: I86a1395e3fcfc3a0338cacd85256c442c5299b1d --- services/core/java/com/android/server/wm/DisplayContent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 5767730abd82b..68d1dcae7a9fa 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1679,7 +1679,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } // The orientation source may not be the top if it uses SCREEN_ORIENTATION_BEHIND. final ActivityRecord topCandidate = !r.isVisibleRequested() ? topRunningActivity() : r; - if (handleTopActivityLaunchingInDifferentOrientation( + if (topCandidate != null && handleTopActivityLaunchingInDifferentOrientation( topCandidate, r, true /* checkOpening */)) { // Display orientation should be deferred until the top fixed rotation is finished. return false;