Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6c4a986 authored by lumark's avatar lumark Committed by Ming-Shin Lu
Browse files

Prevent NPEs when no focusable stack.

Fallback to home stack when no focusable stack
(e.g. launcher force stopped & enter PIP mode with no other app task),
Fix NPEs for logWindowState & getTopRunningActivity from null stack.

Change-Id: I0a0134661dfc20ff844a0bc19ce6833242f4a865
Fixes: 110078217
Test: Manual
Test: atest ActivityStackSupervisorTests ActivityStackTests ActivityStarterTests
parent 1a61e0ea
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -185,6 +185,10 @@ class ActivityMetricsLogger {

        mWindowState = WINDOW_STATE_INVALID;
        ActivityStack stack = mSupervisor.getFocusedStack();
        if (stack == null) {
            return;
        }

        if (stack.isActivityTypeAssistant()) {
            mWindowState = WINDOW_STATE_ASSISTANT;
            return;
+5 −0
Original line number Diff line number Diff line
@@ -708,6 +708,11 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        if (!focusCandidate.isFocusable()) {
            // The focus candidate isn't focusable. Move focus to the top stack that is focusable.
            focusCandidate = getNextFocusableStackLocked(focusCandidate, false /* ignoreCurrent */);
            if (focusCandidate == null) {
                Slog.w(TAG,
                        "setFocusStackUnchecked: No focusable stack found, focus home as default");
                focusCandidate = mHomeStack;
            }
        }

        if (focusCandidate != mFocusedStack) {