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

Commit 4ff502da authored by Evan Rosky's avatar Evan Rosky Committed by Chris Li
Browse files

Replace direct AR.mVisibleRequested access with getter/setter

This abstraction is required for later changes and is also
generally more idiomatic.

the getter for AR is a true getter, so it shouldn't have
a performance impact.

Bug: 260059642
Test: existing tests pass, this is a drop-in refactor
Change-Id: I84bacde8656d98870631d3bd92fa970d72614b93
parent d743e023
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -740,7 +740,7 @@ class ActivityMetricsLogger {
        // visible such as after the top task is finished.
        for (int i = mTransitionInfoList.size() - 2; i >= 0; i--) {
            final TransitionInfo prevInfo = mTransitionInfoList.get(i);
            if (prevInfo.mIsDrawn || !prevInfo.mLastLaunchedActivity.mVisibleRequested) {
            if (prevInfo.mIsDrawn || !prevInfo.mLastLaunchedActivity.isVisibleRequested()) {
                scheduleCheckActivityToBeDrawn(prevInfo.mLastLaunchedActivity, 0 /* delay */);
            }
        }
@@ -867,7 +867,7 @@ class ActivityMetricsLogger {
            return;
        }
        if (DEBUG_METRICS) {
            Slog.i(TAG, "notifyVisibilityChanged " + r + " visible=" + r.mVisibleRequested
            Slog.i(TAG, "notifyVisibilityChanged " + r + " visible=" + r.isVisibleRequested()
                    + " state=" + r.getState() + " finishing=" + r.finishing);
        }
        if (r.isState(ActivityRecord.State.RESUMED) && r.mDisplayContent.isSleeping()) {
@@ -876,7 +876,7 @@ class ActivityMetricsLogger {
            // the tracking of launch event.
            return;
        }
        if (!r.mVisibleRequested || r.finishing) {
        if (!r.isVisibleRequested() || r.finishing) {
            // Check if the tracker can be cancelled because the last launched activity may be
            // no longer visible.
            scheduleCheckActivityToBeDrawn(r, 0 /* delay */);
@@ -909,7 +909,7 @@ class ActivityMetricsLogger {
            // activities in this task may be finished, invisible or drawn, so the transition event
            // should be cancelled.
            if (t != null && t.forAllActivities(
                    a -> a.mVisibleRequested && !a.isReportedDrawn() && !a.finishing)) {
                    a -> a.isVisibleRequested() && !a.isReportedDrawn() && !a.finishing)) {
                return;
            }

+6 −5
Original line number Diff line number Diff line
@@ -800,7 +800,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // it will sometimes be true a little earlier: when the activity record has
    // been shown, but is still waiting for its app transition to execute
    // before making its windows shown.
    boolean mVisibleRequested;
    private boolean mVisibleRequested;

    // Last visibility state we reported to the app token.
    boolean reportedVisible;
@@ -3622,7 +3622,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // implied that the current finishing activity should be added into stopping list rather
        // than destroy immediately.
        final boolean isNextNotYetVisible = next != null
                && (!next.nowVisible || !next.mVisibleRequested);
                && (!next.nowVisible || !next.isVisibleRequested());

        // Clear last paused activity to ensure top activity can be resumed during sleeping.
        if (isNextNotYetVisible && mDisplayContent.isSleeping()
@@ -4440,7 +4440,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    void transferStartingWindowFromHiddenAboveTokenIfNeeded() {
        task.forAllActivities(fromActivity -> {
            if (fromActivity == this) return true;
            return !fromActivity.mVisibleRequested && transferStartingWindow(fromActivity);
            return !fromActivity.isVisibleRequested() && transferStartingWindow(fromActivity);
        });
    }

@@ -5105,7 +5105,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * This is the only place that writes {@link #mVisibleRequested} (except unit test). The caller
     * outside of this class should use {@link #setVisibility}.
     */
    private void setVisibleRequested(boolean visible) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    void setVisibleRequested(boolean visible) {
        if (visible == mVisibleRequested) {
            return;
        }
@@ -6549,7 +6550,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (associatedTask == null) {
            removeStartingWindow();
        } else if (associatedTask.getActivity(
                r -> r.mVisibleRequested && !r.firstWindowDrawn) == null) {
                r -> r.isVisibleRequested() && !r.firstWindowDrawn) == null) {
            // The last drawn activity may not be the one that owns the starting window.
            final ActivityRecord r = associatedTask.topActivityContainsStartingWindow();
            if (r != null) {
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class ActivityServiceConnectionsHolder<T> {

    public boolean isActivityVisible() {
        synchronized (mService.mGlobalLock) {
            return mActivity.mVisibleRequested || mActivity.isState(RESUMED, PAUSING);
            return mActivity.isVisibleRequested() || mActivity.isState(RESUMED, PAUSING);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -561,7 +561,7 @@ public class ActivityStartController {
        if (rootTask == null) return false;
        final RemoteTransition remote = options.getRemoteTransition();
        final ActivityRecord r = rootTask.topRunningActivity();
        if (r == null || r.mVisibleRequested || !r.attachedToProcess() || remote == null
        if (r == null || r.isVisibleRequested() || !r.attachedToProcess() || remote == null
                || !r.mActivityComponent.equals(intent.getComponent())
                // Recents keeps invisible while device is locked.
                || r.mDisplayContent.isKeyguardLocked()) {
+1 −1
Original line number Diff line number Diff line
@@ -2630,7 +2630,7 @@ class ActivityStarter {
                    // If the activity is visible in multi-windowing mode, it may already be on
                    // the top (visible to user but not the global top), then the result code
                    // should be START_DELIVERED_TO_TOP instead of START_TASK_TO_FRONT.
                    final boolean wasTopOfVisibleRootTask = intentActivity.mVisibleRequested
                    final boolean wasTopOfVisibleRootTask = intentActivity.isVisibleRequested()
                            && intentActivity.inMultiWindowMode()
                            && intentActivity == mTargetRootTask.topRunningActivity();
                    // We only want to move to the front, if we aren't going to launch on a
Loading