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

Commit fc7cedd0 authored by Bryce Lee's avatar Bryce Lee
Browse files

Do not call checkReadyForSleep recursively.

resumeTopActivityUncheckedLocked can be recusively called. There are
currently measures in place to guard against
resumeTopActivityInnerLocked from being called inside recursively.
However, calls to checkReadyForSleep in the same method are not
protected in the same way. This can lead to a stack overflow.

This changelist moves the call to inside the scope protected from
recusive invocations.

Change-Id: Id5a7e04a354032ad10cf285f8d6b26d666734e6e
Fixes: 66344012
Test: go/wm-smoke-auto
parent 5f6980af
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -2263,21 +2263,21 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            // Protect against recursion.
            mStackSupervisor.inResumeTopActivity = true;
            result = resumeTopActivityInnerLocked(prev, options);
        } finally {
            mStackSupervisor.inResumeTopActivity = false;
        }

            // When resuming the top activity, it may be necessary to pause the top activity (for
            // example, returning to the lock screen. We suppress the normal pause logic in
        // {@link #resumeTopActivityUncheckedLocked}, since the top activity is resumed at the end.
        // We call the {@link ActivityStackSupervisor#checkReadyForSleepLocked} again here to ensure
        // any necessary pause logic occurs. In the case where the Activity will be shown regardless
        // of the lock screen, the call to {@link ActivityStackSupervisor#checkReadyForSleepLocked}
        // is skipped.
            // {@link #resumeTopActivityUncheckedLocked}, since the top activity is resumed at the
            // end. We call the {@link ActivityStackSupervisor#checkReadyForSleepLocked} again here
            // to ensure any necessary pause logic occurs. In the case where the Activity will be
            // shown regardless of the lock screen, the call to
            // {@link ActivityStackSupervisor#checkReadyForSleepLocked} is skipped.
            final ActivityRecord next = topRunningActivityLocked(true /* focusableOnly */);
            if (next == null || !next.canTurnScreenOn()) {
                checkReadyForSleep();
            }
        } finally {
            mStackSupervisor.inResumeTopActivity = false;
        }

        return result;
    }