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

Commit a841c154 authored by Evan Rosky's avatar Evan Rosky
Browse files

Use clientVisibility and visibleRequested model for wallpaper

This is to maintain similarity to ActivityRecord. ClientVisiblility
is now moved up to WindowToken and shared. VisibleRequested is still
separated since other windowtokens don't support it.

This lets us replace wallpaper-specific logic like deferHideWallpaper
in favor of the same visibility model as activity.

This model is effectively:
X calls setVisibility(v)
  sets visibleRequested = v
  if there's a transition, only commit the visibility when appearing.
  othrewise, commit here.
If there was an ongoing transition, once the transition is over,
  call commitVisibility.

Bug: 180143925
Test: Everything should behave the same and existing test should pass
      atest WallpaperControllerTests
Change-Id: I7bd216922983c6bca5a3b39e5a09c55889f788ee
parent 1c2df9c5
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -43,6 +43,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-2093859262": {
      "message": "setClientVisible: %s clientVisible=%b Callers=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/WindowToken.java"
    },
    "-2072089308": {
      "message": "Attempted to add window with token that is a sub-window: %s.  Aborting.",
      "level": "WARN",
@@ -823,12 +829,6 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/NonAppWindowAnimationAdapter.java"
    },
    "-1144293044": {
      "message": "SURFACE SET FREEZE LAYER: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowStateAnimator.java"
    },
    "-1142279614": {
      "message": "Looking for focus: %s, flags=%d, canReceive=%b, reason=%s",
      "level": "VERBOSE",
@@ -1831,6 +1831,12 @@
      "group": "WM_DEBUG_TASKS",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "63329306": {
      "message": "commitVisibility: %s: visible=%b mVisibleRequested=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/WallpaperWindowToken.java"
    },
    "73987756": {
      "message": "ControlAdapter onAnimationCancelled mSource: %s mControlTarget: %s",
      "level": "INFO",
@@ -2461,6 +2467,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "691515534": {
      "message": "  Commit wallpaper becoming invisible: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/Transition.java"
    },
    "693423992": {
      "message": "setAnimationLocked: setting mFocusMayChange true",
      "level": "INFO",
+9 −15
Original line number Diff line number Diff line
@@ -580,9 +580,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    private Task mLastParent;

    // Have we told the window clients to show themselves?
    private boolean mClientVisible;

    boolean firstWindowDrawn;
    /** Whether the visible window(s) of this activity is drawn. */
    private boolean mReportedDrawn;
@@ -998,7 +995,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        pw.print(prefix); pw.print("mOrientation=");
        pw.println(ActivityInfo.screenOrientationToString(mOrientation));
        pw.println(prefix + "mVisibleRequested=" + mVisibleRequested
                + " mVisible=" + mVisible + " mClientVisible=" + mClientVisible
                + " mVisible=" + mVisible + " mClientVisible=" + isClientVisible()
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + " reportedDrawn=" + mReportedDrawn + " reportedVisible=" + reportedVisible);
        if (paused) {
@@ -1695,7 +1692,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        keysPaused = false;
        inHistory = false;
        nowVisible = false;
        mClientVisible = true;
        super.setClientVisible(true);
        idle = false;
        hasBeenLaunched = false;
        mTaskSupervisor = supervisor;
@@ -3735,7 +3732,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    setVisibleRequested(true);
                    mVisibleSetFromTransferredStartingWindow = true;
                }
                setClientVisible(fromActivity.mClientVisible);
                setClientVisible(fromActivity.isClientVisible());

                if (fromActivity.isAnimating()) {
                    transferAnimation(fromActivity);
@@ -5836,18 +5833,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return mReportedDrawn;
    }

    boolean isClientVisible() {
        return mClientVisible;
    }

    @Override
    void setClientVisible(boolean clientVisible) {
        if (mClientVisible == clientVisible || (!clientVisible && mDeferHidingClient)) {
            return;
        }
        // TODO(shell-transitions): Remove mDeferHidingClient once everything is shell-transitions.
        //                          pip activities should just remain in clientVisible.
        if (!clientVisible && mDeferHidingClient) return;
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "setClientVisible: %s clientVisible=%b Callers=%s", this, clientVisible,
                Debug.getCallers(5));
        mClientVisible = clientVisible;
        super.setClientVisible(clientVisible);
        sendAppVisibilityToClients();
    }

@@ -8134,7 +8128,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        proto.write(TRANSLUCENT, !occludesParent());
        proto.write(VISIBLE, mVisible);
        proto.write(VISIBLE_REQUESTED, mVisibleRequested);
        proto.write(CLIENT_VISIBLE, mClientVisible);
        proto.write(CLIENT_VISIBLE, isClientVisible());
        proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient);
        proto.write(REPORTED_DRAWN, mReportedDrawn);
        proto.write(REPORTED_VISIBLE, reportedVisible);
+1 −1
Original line number Diff line number Diff line
@@ -4822,7 +4822,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        mNoAnimationNotifyOnTransitionFinished.clear();

        mWallpaperController.hideDeferredWallpapersIfNeeded();
        mWallpaperController.hideDeferredWallpapersIfNeededLegacy();

        onAppTransitionDone();

+3 −0
Original line number Diff line number Diff line
@@ -99,6 +99,9 @@ class EnsureActivitiesVisibleHelper {
        mTask.forAllActivities(a -> {
            setActivityVisibilityState(a, starting, resumeTopActivity);
        });
        if (mTask.mAtmService.getTransitionController().getTransitionPlayer() != null) {
            mTask.getDisplayContent().mWallpaperController.adjustWallpaperWindows();
        }
    }

    private void setActivityVisibilityState(ActivityRecord r, ActivityRecord starting,
+15 −5
Original line number Diff line number Diff line
@@ -135,6 +135,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        mSyncId = mSyncEngine.startSyncSet(this);
    }

    @VisibleForTesting
    int getSyncId() {
        return mSyncId;
    }

    /**
     * Formally starts the transition. Participants can be collected before this is started,
     * but this won't consider itself ready until started -- even if all the participants have
@@ -271,13 +276,18 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        // Commit all going-invisible containers
        for (int i = 0; i < mParticipants.size(); ++i) {
            final ActivityRecord ar = mParticipants.valueAt(i).asActivityRecord();
            if (ar == null || ar.mVisibleRequested) {
                continue;
            }
            if (ar != null && !ar.isVisibleRequested()) {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                        "  Commit activity becoming invisible: %s", ar);
                ar.commitVisibility(false /* visible */, false /* performLayout */);
            }
            final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
            if (wt != null && !wt.isVisibleRequested()) {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                        "  Commit wallpaper becoming invisible: %s", ar);
                wt.commitVisibility(false /* visible */);
            }
        }
    }

    void abort() {
Loading