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

Commit 35956bfc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Add UserChange data to TransitionRequestInfo"" into main

parents 3eccd5bd cf1d678c
Loading
Loading
Loading
Loading
+147 −10
Original line number Diff line number Diff line
@@ -65,6 +65,11 @@ public final class TransitionRequestInfo implements Parcelable {
     */
    private @Nullable TransitionRequestInfo.RequestedLocation mRequestedLocation;

    /**
     * If non-null, this request was triggered by a request to change the current user.
     */
    private @Nullable TransitionRequestInfo.UserChange mUserChange;

    /** The transition flags known at the time of the request. These may not be complete. */
    private final int mFlags;

@@ -77,7 +82,8 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable RemoteTransition remoteTransition) {
        this(type, triggerTask, null /* pipChange */, remoteTransition, null /* displayChange */,
                null /* requestedLocation */, 0 /* flags */, -1 /* debugId */);
                null /* requestedLocation */, null /* userChange */, 0 /* flags */,
                -1 /* debugId */);
    }

    /** constructor override */
@@ -87,7 +93,7 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable RemoteTransition remoteTransition,
            int flags) {
        this(type, triggerTask, null /* pipChange */, remoteTransition, null /* displayChange */,
                null /* requestedLocation */, flags, -1 /* debugId */);
                null /* requestedLocation */, null /* userChange */, flags, -1 /* debugId */);
    }

        /** constructor override */
@@ -98,7 +104,7 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            int flags) {
        this(type, triggerTask, null /* pipChange */, remoteTransition, displayChange,
                null /* requestedLocation */, flags, -1 /* debugId */);
                null /* requestedLocation */, null /* userChange */, flags, -1 /* debugId */);
    }

    /** constructor override */
@@ -111,8 +117,8 @@ public final class TransitionRequestInfo implements Parcelable {
            int flags) {
        this(type, triggerTask,
                pipTask != null ? new TransitionRequestInfo.PipChange(pipTask) : null,
                remoteTransition, displayChange, null /* requestedLocation */, flags,
                -1 /* debugId */);
                remoteTransition, displayChange, null /* requestedLocation */,
                null /* userChange */, flags, -1 /* debugId */);
    }

    /** @hide */
@@ -327,7 +333,7 @@ public final class TransitionRequestInfo implements Parcelable {
        };

        @DataClass.Generated(
                time = 1749648471713L,
                time = 1750809098330L,
                codegenVersion = "1.0.23",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                inputSignatures = "private final  int mDisplayId\nprivate @android.annotation.Nullable android.graphics.Rect mStartAbsBounds\nprivate @android.annotation.Nullable android.graphics.Rect mEndAbsBounds\nprivate  int mStartRotation\nprivate  int mEndRotation\nprivate  boolean mPhysicalDisplayChanged\nprivate  int mDisconnectReparentDisplay\nclass DisplayChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
@@ -464,7 +470,7 @@ public final class TransitionRequestInfo implements Parcelable {
        };

        @DataClass.Generated(
                time = 1749648471731L,
                time = 1750809098343L,
                codegenVersion = "1.0.23",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                inputSignatures = "private @android.annotation.NonNull android.window.WindowContainerToken mTaskFragmentToken\nprivate @android.annotation.NonNull android.app.ActivityManager.RunningTaskInfo mTaskInfo\nclass PipChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
@@ -585,7 +591,7 @@ public final class TransitionRequestInfo implements Parcelable {
        };

        @DataClass.Generated(
                time = 1749648471736L,
                time = 1750809098347L,
                codegenVersion = "1.0.23",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                inputSignatures = "private  int mDisplayId\nprivate @android.annotation.NonNull android.graphics.Rect mBounds\nclass RequestedLocation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
@@ -598,6 +604,111 @@ public final class TransitionRequestInfo implements Parcelable {

    }

    @DataClass(genToString = true, genSetters = true, genBuilder = false, genConstructor = false)
    public static final class UserChange implements Parcelable {
        private final int mPreviousUserId;
        private final int mNewUserId;

        public UserChange(int previousUserId, int newUserId) {
            mPreviousUserId = previousUserId;
            mNewUserId = newUserId;
        }



        // Code below generated by codegen v1.0.23.
        //
        // DO NOT MODIFY!
        // CHECKSTYLE:OFF Generated code
        //
        // To regenerate run:
        // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/window/TransitionRequestInfo.java
        //
        // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
        //   Settings > Editor > Code Style > Formatter Control
        //@formatter:off


        @DataClass.Generated.Member
        public int getPreviousUserId() {
            return mPreviousUserId;
        }

        @DataClass.Generated.Member
        public int getNewUserId() {
            return mNewUserId;
        }

        @Override
        @DataClass.Generated.Member
        public String toString() {
            // You can override field toString logic by defining methods like:
            // String fieldNameToString() { ... }

            return "UserChange { " +
                    "previousUserId = " + mPreviousUserId + ", " +
                    "newUserId = " + mNewUserId +
            " }";
        }

        @Override
        @DataClass.Generated.Member
        public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) {
            // You can override field parcelling by defining methods like:
            // void parcelFieldName(Parcel dest, int flags) { ... }

            dest.writeInt(mPreviousUserId);
            dest.writeInt(mNewUserId);
        }

        @Override
        @DataClass.Generated.Member
        public int describeContents() { return 0; }

        /** @hide */
        @SuppressWarnings({"unchecked", "RedundantCast"})
        @DataClass.Generated.Member
        /* package-private */ UserChange(@android.annotation.NonNull android.os.Parcel in) {
            // You can override field unparcelling by defining methods like:
            // static FieldType unparcelFieldName(Parcel in) { ... }

            int previousUserId = in.readInt();
            int newUserId = in.readInt();

            this.mPreviousUserId = previousUserId;
            this.mNewUserId = newUserId;

            // onConstructed(); // You can define this method to get a callback
        }

        @DataClass.Generated.Member
        public static final @android.annotation.NonNull Parcelable.Creator<UserChange> CREATOR
                = new Parcelable.Creator<UserChange>() {
            @Override
            public UserChange[] newArray(int size) {
                return new UserChange[size];
            }

            @Override
            public UserChange createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
                return new UserChange(in);
            }
        };

        @DataClass.Generated(
                time = 1750809098350L,
                codegenVersion = "1.0.23",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                inputSignatures = "private final  int mPreviousUserId\nprivate final  int mNewUserId\nclass UserChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
        @Deprecated
        private void __metadata() {}


        //@formatter:on
        // End of generated code

    }




@@ -633,6 +744,8 @@ public final class TransitionRequestInfo implements Parcelable {
     *   (if size is changing).
     * @param requestedLocation
     *   If non-null, this request was triggered by an app's request to move the trigger task.
     * @param userChange
     *   If non-null, this request was triggered by a request to change the current user.
     * @param flags
     *   The transition flags known at the time of the request. These may not be complete.
     * @param debugId
@@ -646,6 +759,7 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            @Nullable TransitionRequestInfo.RequestedLocation requestedLocation,
            @Nullable TransitionRequestInfo.UserChange userChange,
            int flags,
            int debugId) {
        this.mType = type;
@@ -656,6 +770,7 @@ public final class TransitionRequestInfo implements Parcelable {
        this.mRemoteTransition = remoteTransition;
        this.mDisplayChange = displayChange;
        this.mRequestedLocation = requestedLocation;
        this.mUserChange = userChange;
        this.mFlags = flags;
        this.mDebugId = debugId;

@@ -714,6 +829,14 @@ public final class TransitionRequestInfo implements Parcelable {
        return mRequestedLocation;
    }

    /**
     * If non-null, this request was triggered by a request to change the current user.
     */
    @DataClass.Generated.Member
    public @Nullable TransitionRequestInfo.UserChange getUserChange() {
        return mUserChange;
    }

    /**
     * The transition flags known at the time of the request. These may not be complete.
     */
@@ -779,6 +902,15 @@ public final class TransitionRequestInfo implements Parcelable {
        return this;
    }

    /**
     * If non-null, this request was triggered by a request to change the current user.
     */
    @DataClass.Generated.Member
    public @android.annotation.NonNull TransitionRequestInfo setUserChange(@android.annotation.NonNull TransitionRequestInfo.UserChange value) {
        mUserChange = value;
        return this;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
@@ -792,6 +924,7 @@ public final class TransitionRequestInfo implements Parcelable {
                "remoteTransition = " + mRemoteTransition + ", " +
                "displayChange = " + mDisplayChange + ", " +
                "requestedLocation = " + mRequestedLocation + ", " +
                "userChange = " + mUserChange + ", " +
                "flags = " + mFlags + ", " +
                "debugId = " + mDebugId +
        " }";
@@ -809,6 +942,7 @@ public final class TransitionRequestInfo implements Parcelable {
        if (mRemoteTransition != null) flg |= 0x8;
        if (mDisplayChange != null) flg |= 0x10;
        if (mRequestedLocation != null) flg |= 0x20;
        if (mUserChange != null) flg |= 0x40;
        dest.writeInt(flg);
        dest.writeInt(mType);
        if (mTriggerTask != null) dest.writeTypedObject(mTriggerTask, flags);
@@ -816,6 +950,7 @@ public final class TransitionRequestInfo implements Parcelable {
        if (mRemoteTransition != null) dest.writeTypedObject(mRemoteTransition, flags);
        if (mDisplayChange != null) dest.writeTypedObject(mDisplayChange, flags);
        if (mRequestedLocation != null) dest.writeTypedObject(mRequestedLocation, flags);
        if (mUserChange != null) dest.writeTypedObject(mUserChange, flags);
        dest.writeInt(mFlags);
        dest.writeInt(mDebugId);
    }
@@ -838,6 +973,7 @@ public final class TransitionRequestInfo implements Parcelable {
        RemoteTransition remoteTransition = (flg & 0x8) == 0 ? null : (RemoteTransition) in.readTypedObject(RemoteTransition.CREATOR);
        TransitionRequestInfo.DisplayChange displayChange = (flg & 0x10) == 0 ? null : (TransitionRequestInfo.DisplayChange) in.readTypedObject(TransitionRequestInfo.DisplayChange.CREATOR);
        TransitionRequestInfo.RequestedLocation requestedLocation = (flg & 0x20) == 0 ? null : (TransitionRequestInfo.RequestedLocation) in.readTypedObject(TransitionRequestInfo.RequestedLocation.CREATOR);
        TransitionRequestInfo.UserChange userChange = (flg & 0x40) == 0 ? null : (TransitionRequestInfo.UserChange) in.readTypedObject(TransitionRequestInfo.UserChange.CREATOR);
        int flags = in.readInt();
        int debugId = in.readInt();

@@ -849,6 +985,7 @@ public final class TransitionRequestInfo implements Parcelable {
        this.mRemoteTransition = remoteTransition;
        this.mDisplayChange = displayChange;
        this.mRequestedLocation = requestedLocation;
        this.mUserChange = userChange;
        this.mFlags = flags;
        this.mDebugId = debugId;

@@ -870,10 +1007,10 @@ public final class TransitionRequestInfo implements Parcelable {
    };

    @DataClass.Generated(
            time = 1749648471752L,
            time = 1750809098362L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.PipChange mPipChange\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.DisplayChange mDisplayChange\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.RequestedLocation mRequestedLocation\nprivate final  int mFlags\nprivate final  int mDebugId\n  java.lang.String typeToString()\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.PipChange mPipChange\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.DisplayChange mDisplayChange\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.RequestedLocation mRequestedLocation\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.UserChange mUserChange\nprivate final  int mFlags\nprivate final  int mDebugId\n  java.lang.String typeToString()\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
    @Deprecated
    private void __metadata() {}

+8 −0
Original line number Diff line number Diff line
@@ -2868,6 +2868,14 @@ class DesktopTasksController(
                transition,
            )
        }
        val userChange = request.userChange
        if (
            DesktopExperienceFlags.ENABLE_APPLY_DESK_ACTIVATION_ON_USER_SWITCH.isTrue &&
                userChange != null
        ) {
            // TODO: b/420858253 - deactivate the outgoing user's active desks and reactivate the
            //  active desks of the incoming user.
        }
        // Check if we should skip handling this transition
        var reason = ""
        val triggerTask = request.triggerTask
+18 −2
Original line number Diff line number Diff line
@@ -819,11 +819,27 @@ class TransitionController {
        return newTransition;
    }

    /** Asks the transition player (shell) to start a created but not yet started transition. */
    @NonNull
    Transition requestStartUserTransition(@NonNull Transition transition,
            @Nullable TransitionRequestInfo.UserChange userChange) {
        return requestStartTransition(transition, null /* startTask */,
                null /* remoteTransition */, null /* displayChange */, userChange);
    }

    @NonNull
    Transition requestStartTransition(@NonNull Transition transition, @Nullable Task startTask,
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange) {
        return requestStartTransition(transition, startTask, remoteTransition, displayChange,
                null /* userChange */);
    }

    /** Asks the transition player (shell) to start a created but not yet started transition. */
    @NonNull
    Transition requestStartTransition(@NonNull Transition transition, @Nullable Task startTask,
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            @Nullable TransitionRequestInfo.UserChange userChange) {
        if (mIsWaitingForDisplayEnabled) {
            ProtoLog.v(WmProtoLogGroups.WM_DEBUG_WINDOW_TRANSITIONS,
                    "Disabling player for transition #%d because display isn't enabled yet",
@@ -870,7 +886,7 @@ class TransitionController {

            final TransitionRequestInfo request = new TransitionRequestInfo(transition.mType,
                    startTaskInfo, pipChange, remoteTransition, displayChange,
                    transition.getRequestedLocation(), transition.getFlags(),
                    transition.getRequestedLocation(), userChange, transition.getFlags(),
                    transition.getSyncId());

            transition.mLogger.mRequestTimeNs = SystemClock.elapsedRealtimeNanos();
+63 −39
Original line number Diff line number Diff line
@@ -328,6 +328,7 @@ import android.window.ScreenCaptureInternal.ScreenshotHardwareBuffer;
import android.window.SystemPerformanceHinter;
import android.window.TaskSnapshot;
import android.window.TaskSnapshotManager;
import android.window.TransitionRequestInfo;
import android.window.TrustedPresentationThresholds;
import android.window.WindowContainerToken;
import android.window.WindowContextInfo;
@@ -3932,12 +3933,7 @@ public class WindowManagerService extends IWindowManager.Stub
    public void setCurrentUser(@UserIdInt int newUserId) {
        synchronized (mGlobalLock) {
            final TransitionController controller = mAtmService.getTransitionController();
            final ActionChain chain = mAtmService.mChainTracker.startTransit("setUser");
            if (!chain.isCollecting() && controller.isShellTransitionsEnabled()) {
                chain.attachTransition(controller.createTransition(TRANSIT_OPEN));
                controller.requestStartTransition(chain.getTransition(),
                        null /* trigger */, null /* remote */, null /* disp */);
            }
            final Runnable applyUserChange = () -> {
                mCurrentUserId = newUserId;
                mDisplayWindowSettingsProvider.setOverrideSettingsForUser(newUserId);
                mPolicy.setCurrentUserLw(newUserId);
@@ -3958,9 +3954,9 @@ public class WindowManagerService extends IWindowManager.Stub
                            ? forcedDensity : displayContent.getInitialDisplayDensity();
                    displayContent.setForcedDensity(targetDensity, UserHandle.USER_CURRENT);

                // Because DisplayWindowSettingsProvider.mOverrideSettings has been reset for the
                // new user, we need to update DisplayWindowSettings.mShouldShowSystemDecors to
                // ensure it reflects the latest value.
                    // Because DisplayWindowSettingsProvider.mOverrideSettings has been reset for
                    // the new user, we need to update DisplayWindowSettings.mShouldShowSystemDecors
                    // to ensure it reflects the latest value.
                    if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()) {
                        final int displayCount = mRoot.mChildren.size();
                        for (int i = 0; i < displayCount; ++i) {
@@ -3974,6 +3970,34 @@ public class WindowManagerService extends IWindowManager.Stub
                // is correctly re-evaluated and applied for the new user.
                mSettingsObserver.updateMagnifyIme();
                mAtmService.mChainTracker.end();
            };
            if (!controller.isShellTransitionsEnabled()) {
                applyUserChange.run();
                return;
            }
            if (!DesktopExperienceFlags.ENABLE_APPLY_DESK_ACTIVATION_ON_USER_SWITCH.isTrue()) {
                final ActionChain chain = mAtmService.mChainTracker.startTransit("setUser");
                if (!chain.isCollecting()) {
                    chain.attachTransition(controller.createTransition(TRANSIT_OPEN));
                    controller.requestStartTransition(chain.getTransition(),
                            null /* trigger */, null /* remote */, null /* disp */);
                }
                applyUserChange.run();
                return;
            }
            final Transition transition = new Transition(TRANSIT_OPEN, 0 /* flags */,
                    controller, mAtmService.mWindowManager.mSyncEngine);
            controller.startCollectOrQueue(transition, (deferred) -> {
                final ActionChain chain = mAtmService.mChainTracker.start("setUser",
                        transition);
                final TransitionRequestInfo.UserChange userChange =
                        DesktopExperienceFlags.ENABLE_APPLY_DESK_ACTIVATION_ON_USER_SWITCH.isTrue()
                                ? new TransitionRequestInfo.UserChange(mCurrentUserId,
                                newUserId)
                                : null;
                controller.requestStartUserTransition(chain.getTransition(), userChange);
                applyUserChange.run();
            });
        }
    }