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

Commit 8d30f5da authored by Louis Chang's avatar Louis Chang
Browse files

Reset mCurrentLaunchCanTurnScreenOn state after new Activity launched

The ActivityRecord#mCurrentLaunchCanTurnScreenOn state is used to
be reset whenever executing a new launch request. With this CL,
the state is reset after the launch request is executed and
the activity is no longer the top-most focusable activity.

Doing so in order to cover the cases like 1) the launch failed
or 2) the new activity is launched without moved to the top.

Bug: 343450217
Test: verified locally
Change-Id: I542fc0bc413c76a350cff2b37bad8b9d6d90518f
parent 0bd33674
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -936,13 +936,8 @@ class ActivityStarter {
        }
        mLastStartReason = request.reason;
        mLastStartActivityTimeMs = System.currentTimeMillis();
        // Reset the ActivityRecord#mCurrentLaunchCanTurnScreenOn state of last start activity in
        // case the state is not yet consumed during rapid activity launch.
        if (mLastStartActivityRecord != null) {
            mLastStartActivityRecord.setCurrentLaunchCanTurnScreenOn(false);
        }
        mLastStartActivityRecord = null;

        final ActivityRecord previousStart = mLastStartActivityRecord;
        final IApplicationThread caller = request.caller;
        Intent intent = request.intent;
        NeededUriGrants intentGrants = request.intentGrants;
@@ -1370,6 +1365,18 @@ class ActivityStarter {
            request.outActivity[0] = mLastStartActivityRecord;
        }

        // Reset the ActivityRecord#mCurrentLaunchCanTurnScreenOn state of activity started
        // before this one if it is no longer the top-most focusable activity.
        // Doing so in case the state is not yet consumed during rapid activity launch.
        if (previousStart != null && !previousStart.finishing && previousStart.isAttached()
                && previousStart.currentLaunchCanTurnScreenOn()) {
            final ActivityRecord topFocusable = previousStart.getDisplayContent().getActivity(
                    ar -> ar.isFocusable() && !ar.finishing);
            if (previousStart != topFocusable) {
                previousStart.setCurrentLaunchCanTurnScreenOn(false);
            }
        }

        return mLastStartActivityResult;
    }