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

Commit d0017348 authored by Ben Lin's avatar Ben Lin
Browse files

Move displayId out of KeyguardState Transition object.

Since SystemUI/Shell can't access certain displays (e.g. private ones),
we won't be able to have shell choose which displays to send keyguard
state to - it will have to be delegated to Core which will choose to
send to all displays. Becuase of this, we will also change the call to
ATMS#setLockscreenShown instead, which already does the display
iteration for us.

This also changes the effect to EFFECT_LIFECYCLE, since
ATMS#setLockscreenShown potentially affects that (it does ensure
visibilty checks).

Test: atest
android.server.wm.multidisplay.MultiDisplayLockedKeyguardTests#testPrivateDisplayHideContentWhenLocked
Bug: 364930619
Flag: com.android.window.flags.ensure_keyguard_does_transition_starting

Change-Id: Ia367607c727c4fc8b9d2b636ecf54e86a84702fa
parent 09e4858b
Loading
Loading
Loading
Loading
+6 −27
Original line number Diff line number Diff line
@@ -30,28 +30,23 @@ import java.util.Objects;
 */
public final class KeyguardState implements Parcelable {

    private final int mDisplayId;

    private final boolean mKeyguardShowing;

    private final boolean mAodShowing;


    private KeyguardState(int displayId, boolean keyguardShowing, boolean aodShowing) {
        mDisplayId = displayId;
    private KeyguardState(boolean keyguardShowing, boolean aodShowing) {
        mKeyguardShowing = keyguardShowing;
        mAodShowing = aodShowing;
    }

    private KeyguardState(Parcel in) {
        mDisplayId = in.readInt();
        mKeyguardShowing = in.readBoolean();
        mAodShowing = in.readBoolean();
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mDisplayId);
        dest.writeBoolean(mKeyguardShowing);
        dest.writeBoolean(mAodShowing);
    }
@@ -70,13 +65,6 @@ public final class KeyguardState implements Parcelable {
                }
            };

    /**
     * Gets the display id of this {@link KeyguardState}.
     */
    public int getDisplayId() {
        return mDisplayId;
    }

    /** Returns the keyguard showing value. */
    public boolean getKeyguardShowing() {
        return mKeyguardShowing;
@@ -89,15 +77,14 @@ public final class KeyguardState implements Parcelable {

    @Override
    public String toString() {
        return "KeyguardState{ displayId=" + mDisplayId
                + ", keyguardShowing=" + mKeyguardShowing
        return "KeyguardState{ keyguardShowing=" + mKeyguardShowing
                + ", aodShowing=" + mAodShowing
                + '}';
    }

    @Override
    public int hashCode() {
        return Objects.hash(mDisplayId, mKeyguardShowing, mAodShowing);
        return Objects.hash(mKeyguardShowing, mAodShowing);
    }

    @Override
@@ -105,8 +92,7 @@ public final class KeyguardState implements Parcelable {
        if (!(obj instanceof KeyguardState other)) {
            return false;
        }
        return mDisplayId == other.mDisplayId
                && mKeyguardShowing == other.mKeyguardShowing
        return mKeyguardShowing == other.mKeyguardShowing
                && mAodShowing == other.mAodShowing;
    }

@@ -117,18 +103,11 @@ public final class KeyguardState implements Parcelable {

    /** Builder to construct the {@link KeyguardState}. */
    public static final class Builder {

        private final int mDisplayId;

        private boolean mKeyguardShowing;

        private boolean mAodShowing;

        /**
         * @param displayId the display of this {@link KeyguardState}.
         */
        public Builder(int displayId) {
            mDisplayId = displayId;
        public Builder() {
        }

        /**
@@ -154,7 +133,7 @@ public final class KeyguardState implements Parcelable {
         */
        @NonNull
        public KeyguardState build() {
            return new KeyguardState(mDisplayId, mKeyguardShowing, mAodShowing);
            return new KeyguardState(mKeyguardShowing, mAodShowing);
        }
    }
}
+0 −8
Original line number Diff line number Diff line
@@ -95,14 +95,6 @@ public class DisplayController {
        return displayManager.getDisplay(displayId);
    }

    /**
     * Get all the displays from DisplayManager.
     */
    public Display[] getDisplays() {
        final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class);
        return displayManager.getDisplays();
    }

    /**
     * Gets the DisplayLayout associated with a display.
     */
+2 −5
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;
import android.view.Display;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.window.IRemoteTransition;
@@ -444,10 +443,8 @@ public class KeyguardTransitionHandler
        @Override
        public void startKeyguardTransition(boolean keyguardShowing, boolean aodShowing) {
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            for (Display display : mDisplayController.getDisplays()) {
                wct.addKeyguardState(new KeyguardState.Builder(display.getDisplayId())
                        .setKeyguardShowing(keyguardShowing).setAodShowing(aodShowing).build());
            }
            wct.addKeyguardState(new KeyguardState.Builder().setKeyguardShowing(keyguardShowing)
                    .setAodShowing(aodShowing).build());
            mMainExecutor.execute(() -> {
                mTransitions.startTransition(keyguardShowing ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
                        wct, KeyguardTransitionHandler.this);
+2 −3
Original line number Diff line number Diff line
@@ -1851,14 +1851,13 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
    }

    private int applyKeyguardState(@NonNull WindowContainerTransaction.HierarchyOp hop) {
        int effects = TRANSACT_EFFECTS_NONE;
        int effects = TRANSACT_EFFECTS_LIFECYCLE;

        final KeyguardState keyguardState = hop.getKeyguardState();
        if (keyguardState != null) {
            int displayId = keyguardState.getDisplayId();
            boolean keyguardShowing = keyguardState.getKeyguardShowing();
            boolean aodShowing = keyguardState.getAodShowing();
            mService.mKeyguardController.setKeyguardShown(displayId, keyguardShowing, aodShowing);
            mService.setLockScreenShown(keyguardShowing, aodShowing);
        }
        return effects;
    }