summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/window/KeyguardState.aidl22
-rw-r--r--core/java/android/window/KeyguardState.java160
-rw-r--r--core/java/android/window/WindowContainerTransaction.java43
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java16
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitions.java7
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityManagerTest.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java50
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/WindowManagerLockscreenVisibilityManager.kt19
-rw-r--r--services/core/java/com/android/server/wm/KeyguardController.java23
-rw-r--r--services/core/java/com/android/server/wm/WindowOrganizerController.java19
10 files changed, 344 insertions, 18 deletions
diff --git a/core/java/android/window/KeyguardState.aidl b/core/java/android/window/KeyguardState.aidl
new file mode 100644
index 000000000000..9612d9590056
--- /dev/null
+++ b/core/java/android/window/KeyguardState.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.window;
+
+/**
+ * @hide
+ */
+parcelable KeyguardState;
diff --git a/core/java/android/window/KeyguardState.java b/core/java/android/window/KeyguardState.java
new file mode 100644
index 000000000000..6584d30cdaed
--- /dev/null
+++ b/core/java/android/window/KeyguardState.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.window;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Data object of params for Keyguard related {@link WindowContainerTransaction} operation.
+ *
+ * @hide
+ */
+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;
+ 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);
+ }
+
+ @NonNull
+ public static final Creator<KeyguardState> CREATOR =
+ new Creator<KeyguardState>() {
+ @Override
+ public KeyguardState createFromParcel(Parcel in) {
+ return new KeyguardState(in);
+ }
+
+ @Override
+ public KeyguardState[] newArray(int size) {
+ return new KeyguardState[size];
+ }
+ };
+
+ /**
+ * Gets the display id of this {@link KeyguardState}.
+ */
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ /** Returns the keyguard showing value. */
+ public boolean getKeyguardShowing() {
+ return mKeyguardShowing;
+ }
+
+ /** Returns the aod showing value. */
+ public boolean getAodShowing() {
+ return mAodShowing;
+ }
+
+ @Override
+ public String toString() {
+ return "KeyguardState{ displayId=" + mDisplayId
+ + ", keyguardShowing=" + mKeyguardShowing
+ + ", aodShowing=" + mAodShowing
+ + '}';
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mDisplayId, mKeyguardShowing, mAodShowing);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (!(obj instanceof KeyguardState other)) {
+ return false;
+ }
+ return mDisplayId == other.mDisplayId
+ && mKeyguardShowing == other.mKeyguardShowing
+ && mAodShowing == other.mAodShowing;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** 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;
+ }
+
+ /**
+ * Sets the boolean value for this operation.
+ */
+ @NonNull
+ public Builder setKeyguardShowing(boolean keyguardShowing) {
+ mKeyguardShowing = keyguardShowing;
+ return this;
+ }
+
+ /**
+ * Sets the boolean value for this operation.
+ */
+ @NonNull
+ public Builder setAodShowing(boolean aodShowing) {
+ mAodShowing = aodShowing;
+ return this;
+ }
+
+ /**
+ * Constructs the {@link KeyguardState}.
+ */
+ @NonNull
+ public KeyguardState build() {
+ return new KeyguardState(mDisplayId, mKeyguardShowing, mAodShowing);
+ }
+ }
+}
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index 0dc9263e990d..8e495ec1dc40 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -869,6 +869,24 @@ public final class WindowContainerTransaction implements Parcelable {
}
/**
+ * Adds a {@link KeyguardState} to apply to the given displays.
+ *
+ * @hide
+ */
+ @NonNull
+ public WindowContainerTransaction addKeyguardState(
+ @NonNull KeyguardState keyguardState) {
+ Objects.requireNonNull(keyguardState);
+ final HierarchyOp hierarchyOp =
+ new HierarchyOp.Builder(
+ HierarchyOp.HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE)
+ .setKeyguardState(keyguardState)
+ .build();
+ mHierarchyOps.add(hierarchyOp);
+ return this;
+ }
+
+ /**
* Sets/removes the always on top flag for this {@code windowContainer}. See
* {@link com.android.server.wm.ConfigurationContainer#setAlwaysOnTop(boolean)}.
* Please note that this method is only intended to be used for a
@@ -1469,6 +1487,7 @@ public final class WindowContainerTransaction implements Parcelable {
public static final int HIERARCHY_OP_TYPE_SET_IS_TRIMMABLE = 19;
public static final int HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION = 20;
public static final int HIERARCHY_OP_TYPE_SET_EXCLUDE_INSETS_TYPES = 21;
+ public static final int HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE = 22;
// The following key(s) are for use with mLaunchOptions:
// When launching a task (eg. from recents), this is the taskId to be launched.
@@ -1516,6 +1535,9 @@ public final class WindowContainerTransaction implements Parcelable {
private TaskFragmentOperation mTaskFragmentOperation;
@Nullable
+ private KeyguardState mKeyguardState;
+
+ @Nullable
private PendingIntent mPendingIntent;
@Nullable
@@ -1666,6 +1688,7 @@ public final class WindowContainerTransaction implements Parcelable {
mLaunchOptions = copy.mLaunchOptions;
mActivityIntent = copy.mActivityIntent;
mTaskFragmentOperation = copy.mTaskFragmentOperation;
+ mKeyguardState = copy.mKeyguardState;
mPendingIntent = copy.mPendingIntent;
mShortcutInfo = copy.mShortcutInfo;
mAlwaysOnTop = copy.mAlwaysOnTop;
@@ -1689,6 +1712,7 @@ public final class WindowContainerTransaction implements Parcelable {
mLaunchOptions = in.readBundle();
mActivityIntent = in.readTypedObject(Intent.CREATOR);
mTaskFragmentOperation = in.readTypedObject(TaskFragmentOperation.CREATOR);
+ mKeyguardState = in.readTypedObject(KeyguardState.CREATOR);
mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR);
mAlwaysOnTop = in.readBoolean();
@@ -1770,6 +1794,11 @@ public final class WindowContainerTransaction implements Parcelable {
}
@Nullable
+ public KeyguardState getKeyguardState() {
+ return mKeyguardState;
+ }
+
+ @Nullable
public PendingIntent getPendingIntent() {
return mPendingIntent;
}
@@ -1902,6 +1931,9 @@ public final class WindowContainerTransaction implements Parcelable {
.append(" mExcludeInsetsTypes= ")
.append(WindowInsets.Type.toString(mExcludeInsetsTypes));
break;
+ case HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE:
+ sb.append("KeyguardState= ").append(mKeyguardState);
+ break;
case HIERARCHY_OP_TYPE_SET_IS_TRIMMABLE:
sb.append("container= ").append(mContainer)
.append(" isTrimmable= ")
@@ -1932,6 +1964,7 @@ public final class WindowContainerTransaction implements Parcelable {
dest.writeBundle(mLaunchOptions);
dest.writeTypedObject(mActivityIntent, flags);
dest.writeTypedObject(mTaskFragmentOperation, flags);
+ dest.writeTypedObject(mKeyguardState, flags);
dest.writeTypedObject(mPendingIntent, flags);
dest.writeTypedObject(mShortcutInfo, flags);
dest.writeBoolean(mAlwaysOnTop);
@@ -1993,6 +2026,9 @@ public final class WindowContainerTransaction implements Parcelable {
private TaskFragmentOperation mTaskFragmentOperation;
@Nullable
+ private KeyguardState mKeyguardState;
+
+ @Nullable
private PendingIntent mPendingIntent;
@Nullable
@@ -2081,6 +2117,12 @@ public final class WindowContainerTransaction implements Parcelable {
return this;
}
+ Builder setKeyguardState(
+ @Nullable KeyguardState keyguardState) {
+ mKeyguardState = keyguardState;
+ return this;
+ }
+
Builder setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) {
mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch;
return this;
@@ -2130,6 +2172,7 @@ public final class WindowContainerTransaction implements Parcelable {
hierarchyOp.mPendingIntent = mPendingIntent;
hierarchyOp.mAlwaysOnTop = mAlwaysOnTop;
hierarchyOp.mTaskFragmentOperation = mTaskFragmentOperation;
+ hierarchyOp.mKeyguardState = mKeyguardState;
hierarchyOp.mShortcutInfo = mShortcutInfo;
hierarchyOp.mBounds = mBounds;
hierarchyOp.mIncludingParents = mIncludingParents;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
index abec3b9c0c3b..f8d2011d0934 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
@@ -28,6 +28,8 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_OCCLUDING;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_UNOCCLUDING;
import static android.view.WindowManager.TRANSIT_SLEEP;
+import static android.view.WindowManager.TRANSIT_TO_BACK;
+import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
@@ -44,6 +46,7 @@ import android.view.SurfaceControl;
import android.view.WindowManager;
import android.window.IRemoteTransition;
import android.window.IRemoteTransitionFinishedCallback;
+import android.window.KeyguardState;
import android.window.TransitionInfo;
import android.window.TransitionRequestInfo;
import android.window.WindowContainerToken;
@@ -388,5 +391,18 @@ public class KeyguardTransitionHandler
mMainExecutor.execute(() ->
mIsLaunchingActivityOverLockscreen = isLaunchingActivityOverLockscreen);
}
+
+ @Override
+ public void startKeyguardTransition(boolean keyguardShowing, boolean aodShowing) {
+ final WindowContainerTransaction wct = new WindowContainerTransaction();
+ final KeyguardState keyguardState =
+ new KeyguardState.Builder(android.view.Display.DEFAULT_DISPLAY)
+ .setKeyguardShowing(keyguardShowing).setAodShowing(aodShowing).build();
+ wct.addKeyguardState(keyguardState);
+ mMainExecutor.execute(() -> {
+ mTransitions.startTransition(keyguardShowing ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
+ wct, KeyguardTransitionHandler.this);
+ });
+ }
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitions.java
index b7245b91f36c..1d349e6c96e0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitions.java
@@ -44,4 +44,11 @@ public interface KeyguardTransitions {
* Notify whether keyguard has created a remote animation runner for next app launch.
*/
default void setLaunchingActivityOverLockscreen(boolean isLaunchingActivityOverLockscreen) {}
+
+ /**
+ * Notifies Shell to start a keyguard transition directly.
+ * @param keyguardShowing whether keyguard is showing or not.
+ * @param aodShowing whether aod is showing or not.
+ */
+ default void startKeyguardTransition(boolean keyguardShowing, boolean aodShowing) {}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityManagerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityManagerTest.kt
index 43c7ed6a769d..9c58e2b987a1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityManagerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityManagerTest.kt
@@ -25,6 +25,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransition
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
+import com.android.wm.shell.keyguard.KeyguardTransitions
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -46,6 +47,7 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
@Mock private lateinit var keyguardSurfaceBehindAnimator: KeyguardSurfaceBehindParamsApplier
@Mock
private lateinit var keyguardDismissTransitionInteractor: KeyguardDismissTransitionInteractor
+ @Mock private lateinit var keyguardTransitions: KeyguardTransitions
@Before
fun setUp() {
@@ -59,6 +61,7 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
keyguardStateController = keyguardStateController,
keyguardSurfaceBehindAnimator = keyguardSurfaceBehindAnimator,
keyguardDismissTransitionInteractor = keyguardDismissTransitionInteractor,
+ keyguardTransitions = keyguardTransitions,
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 9c7cc81c34aa..2052459692b2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -178,6 +178,7 @@ import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.settings.SystemSettings;
import com.android.systemui.util.time.SystemClock;
import com.android.systemui.wallpapers.data.repository.WallpaperRepository;
+import com.android.window.flags.Flags;
import com.android.wm.shell.keyguard.KeyguardTransitions;
import dagger.Lazy;
@@ -236,6 +237,9 @@ import java.util.function.Consumer;
*/
public class KeyguardViewMediator implements CoreStartable, Dumpable,
StatusBarStateController.StateListener {
+
+ private static final boolean ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS =
+ Flags.ensureKeyguardDoesTransitionStarting();
private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
private static final long KEYGUARD_DONE_PENDING_TIMEOUT_MS = 3000;
@@ -2865,9 +2869,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
return;
}
- try {
- mActivityTaskManagerService.setLockScreenShown(showing, aodShowing);
- } catch (RemoteException ignored) {
+ if (ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS) {
+ mKeyguardTransitions.startKeyguardTransition(showing, aodShowing);
+ } else {
+ try {
+
+ mActivityTaskManagerService.setLockScreenShown(showing, aodShowing);
+ } catch (RemoteException ignored) {
+ }
}
});
}
@@ -2998,18 +3007,23 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
// Handled in WmLockscreenVisibilityManager if flag is enabled.
if (!KeyguardWmStateRefactor.isEnabled()) {
- // Don't actually hide the Keyguard at the moment, wait for window manager
- // until it tells us it's safe to do so with startKeyguardExitAnimation.
- // Posting to mUiOffloadThread to ensure that calls to ActivityTaskManager
- // will be in order.
- final int keyguardFlag = flags;
- mUiBgExecutor.execute(() -> {
- try {
- mActivityTaskManagerService.keyguardGoingAway(keyguardFlag);
- } catch (RemoteException e) {
- Log.e(TAG, "Error while calling WindowManager", e);
- }
- });
+ // Don't actually hide the Keyguard at the moment, wait for window manager
+ // until it tells us it's safe to do so with startKeyguardExitAnimation.
+ // Posting to mUiOffloadThread to ensure that calls to ActivityTaskManager
+ // will be in order.
+ final int keyguardFlag = flags;
+ mUiBgExecutor.execute(() -> {
+ if (ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS) {
+ mKeyguardTransitions.startKeyguardTransition(
+ false /* keyguardShowing */, false /* aodShowing */);
+ return;
+ }
+ try {
+ mActivityTaskManagerService.keyguardGoingAway(keyguardFlag);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while calling WindowManager", e);
+ }
+ });
}
Trace.endSection();
@@ -3464,6 +3478,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
public void showSurfaceBehindKeyguard() {
mSurfaceBehindRemoteAnimationRequested = true;
+ if (ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS) {
+ mKeyguardTransitions.startKeyguardTransition(
+ false /* keyguardShowing */, false /* aodShowing */);
+ return;
+ }
+
try {
int flags = KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS
| KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WindowManagerLockscreenVisibilityManager.kt b/packages/SystemUI/src/com/android/systemui/keyguard/WindowManagerLockscreenVisibilityManager.kt
index e89594e58aa0..032af94e62aa 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/WindowManagerLockscreenVisibilityManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/WindowManagerLockscreenVisibilityManager.kt
@@ -26,6 +26,8 @@ import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransitionInteractor
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier
import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.window.flags.Flags
+import com.android.wm.shell.keyguard.KeyguardTransitions
import java.util.concurrent.Executor
import javax.inject.Inject
@@ -42,6 +44,7 @@ constructor(
private val keyguardStateController: KeyguardStateController,
private val keyguardSurfaceBehindAnimator: KeyguardSurfaceBehindParamsApplier,
private val keyguardDismissTransitionInteractor: KeyguardDismissTransitionInteractor,
+ private val keyguardTransitions: KeyguardTransitions
) {
/**
@@ -97,6 +100,9 @@ constructor(
/** Callback provided by WM to call once we're done with the going away animation. */
private var goingAwayRemoteAnimationFinishedCallback: IRemoteAnimationFinishedCallback? = null
+ private val enableNewKeyguardShellTransitions: Boolean =
+ Flags.ensureKeyguardDoesTransitionStarting()
+
/**
* Set the visibility of the surface behind the keyguard, making the appropriate calls to Window
* Manager to effect the change.
@@ -114,7 +120,14 @@ constructor(
return
}
+
+
if (visible) {
+ if (enableNewKeyguardShellTransitions) {
+ keyguardTransitions.startKeyguardTransition(false /* keyguardShowing */, false /* aodShowing */)
+ isKeyguardGoingAway = true
+ return
+ }
// Make the surface visible behind the keyguard by calling keyguardGoingAway. The
// lockscreen is still showing as well, allowing us to animate unlocked.
Log.d(TAG, "ActivityTaskManagerService#keyguardGoingAway()")
@@ -220,7 +233,11 @@ constructor(
"isLockscreenShowing=$lockscreenShowing, " +
"aodVisible=$aodVisible)."
)
- activityTaskManagerService.setLockScreenShown(lockscreenShowing, aodVisible)
+ if (enableNewKeyguardShellTransitions) {
+ keyguardTransitions.startKeyguardTransition(lockscreenShowing, aodVisible)
+ } else {
+ activityTaskManagerService.setLockScreenShown(lockscreenShowing, aodVisible)
+ }
this.isLockscreenShowing = lockscreenShowing
this.isAodVisible = aodVisible
}
diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java
index 0c489d6207e9..2fde5aaef5d4 100644
--- a/services/core/java/com/android/server/wm/KeyguardController.java
+++ b/services/core/java/com/android/server/wm/KeyguardController.java
@@ -62,6 +62,7 @@ import android.view.WindowManager;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.policy.WindowManagerPolicy;
+import com.android.window.flags.Flags;
import java.io.PrintWriter;
@@ -73,6 +74,9 @@ import java.io.PrintWriter;
*/
class KeyguardController {
+ private static final boolean ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS =
+ Flags.ensureKeyguardDoesTransitionStarting();
+
private static final String TAG = TAG_WITH_CLASS_NAME ? "KeyguardController" : TAG_ATM;
static final String KEYGUARD_SLEEP_TOKEN_TAG = "keyguard";
@@ -201,6 +205,19 @@ class KeyguardController {
setWakeTransitionReady();
return;
}
+
+ if (ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS) {
+ final TransitionController transitionController =
+ mWindowManager.mAtmService.getTransitionController();
+ final Transition transition = transitionController.getCollectingTransition();
+ if (transition != null && displayId == DEFAULT_DISPLAY) {
+ if (!keyguardShowing && state.mKeyguardShowing) {
+ transition.addFlag(TRANSIT_FLAG_KEYGUARD_GOING_AWAY);
+ } else if (keyguardShowing && !state.mKeyguardShowing) {
+ transition.addFlag(TRANSIT_FLAG_KEYGUARD_APPEARING);
+ }
+ }
+ }
// Update the task snapshot if the screen will not be turned off. To make sure that the
// unlocking animation can animate consistent content. The conditions are:
// - Either AOD or keyguard changes to be showing. So if the states change individually,
@@ -231,8 +248,10 @@ class KeyguardController {
|| (keyguardShowing && !Display.isOffState(dc.getDisplayInfo().state))) {
// Keyguard decided to show or stopped going away. Send a transition to animate back
// to the locked state before holding the sleep token again
- dc.requestTransitionAndLegacyPrepare(
- TRANSIT_TO_FRONT, TRANSIT_FLAG_KEYGUARD_APPEARING);
+ if (!ENABLE_NEW_KEYGUARD_SHELL_TRANSITIONS) {
+ dc.requestTransitionAndLegacyPrepare(
+ TRANSIT_TO_FRONT, TRANSIT_FLAG_KEYGUARD_APPEARING);
+ }
dc.mWallpaperController.adjustWallpaperWindows();
dc.executeAppTransition();
}
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index f8d0bc252b0f..2229807f5db1 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -51,6 +51,7 @@ import static android.window.WindowContainerTransaction.Change.CHANGE_FOCUSABLE;
import static android.window.WindowContainerTransaction.Change.CHANGE_FORCE_TRANSLUCENT;
import static android.window.WindowContainerTransaction.Change.CHANGE_HIDDEN;
import static android.window.WindowContainerTransaction.Change.CHANGE_RELATIVE_BOUNDS;
+import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_ADD_INSETS_FRAME_PROVIDER;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_ADD_TASK_FRAGMENT_OPERATION;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT;
@@ -121,6 +122,7 @@ import android.window.ITransitionMetricsReporter;
import android.window.ITransitionPlayer;
import android.window.IWindowContainerTransactionCallback;
import android.window.IWindowOrganizerController;
+import android.window.KeyguardState;
import android.window.RemoteTransition;
import android.window.TaskFragmentAnimationParams;
import android.window.TaskFragmentCreationParams;
@@ -1253,6 +1255,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
caller, errorCallbackToken, organizer);
break;
}
+ case HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE: {
+ effects |= applyKeyguardState(hop);
+ break;
+ }
case HIERARCHY_OP_TYPE_PENDING_INTENT: {
final Bundle launchOpts = hop.getLaunchOptions();
ActivityOptions activityOptions = launchOpts != null
@@ -1788,6 +1794,19 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
return effects;
}
+ private int applyKeyguardState(@NonNull WindowContainerTransaction.HierarchyOp hop) {
+ int effects = TRANSACT_EFFECTS_NONE;
+
+ 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);
+ }
+ return effects;
+ }
+
/**
* Executes the provided {@code runnable} after the {@code transition}. If the
* {@code transition} is {@code null}, the {@code runnable} is executed immediately.