Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
Wale Ogunwale | 5950709 | 2018-10-29 09:00:30 -0700 | [diff] [blame] | 17 | package com.android.server.wm; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 18 | |
Riddle Hsu | 2ca561b | 2019-10-08 21:58:58 +0800 | [diff] [blame] | 19 | import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 20 | import static android.view.Display.DEFAULT_DISPLAY; |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 21 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION; |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 22 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION; |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 23 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE; |
| 24 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER; |
| 25 | import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; |
| 26 | import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE; |
| 27 | import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; |
| 28 | import static android.view.WindowManager.TRANSIT_UNSET; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 29 | import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS; |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 30 | import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 31 | import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE; |
| 32 | import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER; |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 33 | |
Evan Rosky | af9f27c | 2020-02-18 18:58:35 +0000 | [diff] [blame] | 34 | import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS; |
| 35 | import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; |
| 36 | import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Wale Ogunwale | f342f06 | 2020-01-27 07:34:13 -0800 | [diff] [blame] | 37 | import static com.android.server.wm.KeyguardControllerProto.AOD_SHOWING; |
| 38 | import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_OCCLUDED_STATES; |
| 39 | import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_SHOWING; |
| 40 | import static com.android.server.wm.KeyguardOccludedProto.DISPLAY_ID; |
| 41 | import static com.android.server.wm.KeyguardOccludedProto.KEYGUARD_OCCLUDED; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 42 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 43 | import android.os.IBinder; |
| 44 | import android.os.RemoteException; |
Wale Ogunwale | dfb7fb2 | 2017-06-23 14:52:40 -0700 | [diff] [blame] | 45 | import android.os.Trace; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 46 | import android.util.Slog; |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 47 | import android.util.SparseArray; |
Steven Timotius | 4346f0a | 2017-09-12 11:07:21 -0700 | [diff] [blame] | 48 | import android.util.proto.ProtoOutputStream; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 49 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 50 | import com.android.internal.policy.IKeyguardDismissCallback; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 51 | import com.android.server.policy.WindowManagerPolicy; |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 52 | import com.android.server.wm.ActivityTaskManagerInternal.SleepToken; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 53 | |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 54 | import java.io.PrintWriter; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Controls Keyguard occluding, dismissing and transitions depending on what kind of activities are |
| 58 | * currently visible. |
| 59 | * <p> |
| 60 | * Note that everything in this class should only be accessed with the AM lock being held. |
| 61 | */ |
| 62 | class KeyguardController { |
| 63 | |
Wale Ogunwale | 9887561 | 2018-10-12 07:53:02 -0700 | [diff] [blame] | 64 | private static final String TAG = TAG_WITH_CLASS_NAME ? "KeyguardController" : TAG_ATM; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 65 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 66 | private final ActivityStackSupervisor mStackSupervisor; |
| 67 | private WindowManagerService mWindowManager; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 68 | private boolean mKeyguardShowing; |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 69 | private boolean mAodShowing; |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 70 | private boolean mKeyguardGoingAway; |
Jorim Jaggi | 0796187 | 2016-11-23 11:28:57 +0100 | [diff] [blame] | 71 | private boolean mDismissalRequested; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 72 | private int mBeforeUnoccludeTransit; |
| 73 | private int mVisibilityTransactionDepth; |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 74 | private final SparseArray<KeyguardDisplayState> mDisplayStates = new SparseArray<>(); |
| 75 | private final ActivityTaskManagerService mService; |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 76 | private RootWindowContainer mRootWindowContainer; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 77 | |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 78 | KeyguardController(ActivityTaskManagerService service, |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 79 | ActivityStackSupervisor stackSupervisor) { |
| 80 | mService = service; |
| 81 | mStackSupervisor = stackSupervisor; |
| 82 | } |
| 83 | |
| 84 | void setWindowManager(WindowManagerService windowManager) { |
| 85 | mWindowManager = windowManager; |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 86 | mRootWindowContainer = mService.mRootWindowContainer; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /** |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 90 | * @return true if either Keyguard or AOD are showing, not going away, and not being occluded |
| 91 | * on the given display, false otherwise. |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 92 | */ |
| 93 | boolean isKeyguardOrAodShowing(int displayId) { |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 94 | return (mKeyguardShowing || mAodShowing) && !mKeyguardGoingAway |
| 95 | && !isDisplayOccluded(displayId); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @return {@code true} for default display when AOD is showing. Otherwise, same as |
| 100 | * {@link #isKeyguardOrAodShowing(int)} |
| 101 | * TODO(b/125198167): Replace isKeyguardOrAodShowing() by this logic. |
| 102 | */ |
| 103 | boolean isKeyguardUnoccludedOrAodShowing(int displayId) { |
| 104 | if (displayId == DEFAULT_DISPLAY && mAodShowing) { |
| 105 | return true; |
| 106 | } |
| 107 | return isKeyguardOrAodShowing(displayId); |
Issei Suzuki | d6eb5a2 | 2019-02-20 23:08:03 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 111 | * @return true if Keyguard is showing, not going away, and not being occluded on the given |
| 112 | * display, false otherwise |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 113 | */ |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 114 | boolean isKeyguardShowing(int displayId) { |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 115 | return mKeyguardShowing && !mKeyguardGoingAway && !isDisplayOccluded(displayId); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @return true if Keyguard is either showing or occluded, but not going away |
| 120 | */ |
| 121 | boolean isKeyguardLocked() { |
| 122 | return mKeyguardShowing && !mKeyguardGoingAway; |
| 123 | } |
| 124 | |
| 125 | /** |
Bryce Lee | 271617a | 2018-03-15 10:39:12 -0700 | [diff] [blame] | 126 | * @return {@code true} if the keyguard is going away, {@code false} otherwise. |
| 127 | */ |
| 128 | boolean isKeyguardGoingAway() { |
| 129 | // Also check keyguard showing in case value is stale. |
| 130 | return mKeyguardGoingAway && mKeyguardShowing; |
| 131 | } |
| 132 | |
| 133 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 134 | * Update the Keyguard showing state. |
| 135 | */ |
wilsonshih | 177261f | 2019-02-22 12:02:18 +0800 | [diff] [blame] | 136 | void setKeyguardShown(boolean keyguardShowing, boolean aodShowing) { |
Adrian Roos | 6ec76b7 | 2018-04-25 14:01:11 +0200 | [diff] [blame] | 137 | // If keyguard is going away, but SystemUI aborted the transition, need to reset state. |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 138 | final boolean keyguardChanged = keyguardShowing != mKeyguardShowing |
| 139 | || mKeyguardGoingAway && keyguardShowing; |
| 140 | final boolean aodChanged = aodShowing != mAodShowing; |
| 141 | if (!keyguardChanged && !aodChanged) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 142 | return; |
| 143 | } |
Jeff Chang | d136e77 | 2019-11-05 20:33:52 +0800 | [diff] [blame] | 144 | EventLogTags.writeWmSetKeyguardShown( |
wilsonshih | 30eca70 | 2019-07-10 09:22:11 +0800 | [diff] [blame] | 145 | keyguardShowing ? 1 : 0, |
| 146 | aodShowing ? 1 : 0, |
| 147 | mKeyguardGoingAway ? 1 : 0, |
| 148 | "setKeyguardShown"); |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 149 | mKeyguardShowing = keyguardShowing; |
| 150 | mAodShowing = aodShowing; |
chaviw | 0e9fb13 | 2018-06-05 16:29:13 -0700 | [diff] [blame] | 151 | mWindowManager.setAodShowing(aodShowing); |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 152 | |
| 153 | if (keyguardChanged) { |
| 154 | // Irrelevant to AOD. |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 155 | dismissDockedStackIfNeeded(); |
Andrii Kulian | 0d595f3 | 2018-02-21 15:47:33 -0800 | [diff] [blame] | 156 | setKeyguardGoingAway(false); |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 157 | if (keyguardShowing) { |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 158 | mDismissalRequested = false; |
| 159 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 160 | } |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 161 | // TODO(b/113840485): Check usage for non-default display |
| 162 | mWindowManager.setKeyguardOrAodShowingOnDefaultDisplay( |
| 163 | isKeyguardOrAodShowing(DEFAULT_DISPLAY)); |
| 164 | |
| 165 | // Update the sleep token first such that ensureActivitiesVisible has correct sleep token |
| 166 | // state when evaluating visibilities. |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 167 | updateKeyguardSleepToken(); |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 168 | mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Called when Keyguard is going away. |
| 173 | * |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 174 | * @param flags See {@link WindowManagerPolicy#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE} |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 175 | * etc. |
| 176 | */ |
| 177 | void keyguardGoingAway(int flags) { |
Wale Ogunwale | dfb7fb2 | 2017-06-23 14:52:40 -0700 | [diff] [blame] | 178 | if (!mKeyguardShowing) { |
| 179 | return; |
| 180 | } |
Riddle Hsu | 2ca561b | 2019-10-08 21:58:58 +0800 | [diff] [blame] | 181 | Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "keyguardGoingAway"); |
Riddle Hsu | a0022cd | 2019-09-09 21:12:41 +0800 | [diff] [blame] | 182 | mService.deferWindowLayout(); |
Wale Ogunwale | dfb7fb2 | 2017-06-23 14:52:40 -0700 | [diff] [blame] | 183 | try { |
| 184 | setKeyguardGoingAway(true); |
Jeff Chang | d136e77 | 2019-11-05 20:33:52 +0800 | [diff] [blame] | 185 | EventLogTags.writeWmSetKeyguardShown( |
wilsonshih | 30eca70 | 2019-07-10 09:22:11 +0800 | [diff] [blame] | 186 | 1 /* keyguardShowing */, |
| 187 | mAodShowing ? 1 : 0, |
| 188 | 1 /* keyguardGoingAway */, |
| 189 | "keyguardGoingAway"); |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 190 | mRootWindowContainer.getDefaultDisplay().mDisplayContent |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 191 | .prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, |
| 192 | false /* alwaysKeepCurrent */, convertTransitFlags(flags), |
| 193 | false /* forceOverride */); |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 194 | updateKeyguardSleepToken(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 195 | |
Wale Ogunwale | dfb7fb2 | 2017-06-23 14:52:40 -0700 | [diff] [blame] | 196 | // Some stack visibility might change (e.g. docked stack) |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 197 | mRootWindowContainer.resumeFocusedStacksTopActivities(); |
| 198 | mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); |
| 199 | mRootWindowContainer.addStartingWindowsForVisibleActivities(); |
Wale Ogunwale | dfb7fb2 | 2017-06-23 14:52:40 -0700 | [diff] [blame] | 200 | mWindowManager.executeAppTransition(); |
| 201 | } finally { |
Riddle Hsu | a0022cd | 2019-09-09 21:12:41 +0800 | [diff] [blame] | 202 | mService.continueWindowLayout(); |
Riddle Hsu | 2ca561b | 2019-10-08 21:58:58 +0800 | [diff] [blame] | 203 | Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 207 | void dismissKeyguard(IBinder token, IKeyguardDismissCallback callback, CharSequence message) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 208 | final ActivityRecord activityRecord = ActivityRecord.forTokenLocked(token); |
| 209 | if (activityRecord == null || !activityRecord.visibleIgnoringKeyguard) { |
| 210 | failCallback(callback); |
| 211 | return; |
| 212 | } |
Jorim Jaggi | d721489 | 2017-07-18 14:05:19 +0200 | [diff] [blame] | 213 | Slog.i(TAG, "Activity requesting to dismiss Keyguard: " + activityRecord); |
chaviw | 59b9885 | 2017-06-13 12:05:44 -0700 | [diff] [blame] | 214 | |
| 215 | // If the client has requested to dismiss the keyguard and the Activity has the flag to |
| 216 | // turn the screen on, wakeup the screen if it's the top Activity. |
| 217 | if (activityRecord.getTurnScreenOnFlag() && activityRecord.isTopRunningActivity()) { |
| 218 | mStackSupervisor.wakeUp("dismissKeyguard"); |
| 219 | } |
| 220 | |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 221 | mWindowManager.dismissKeyguard(callback, message); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Wale Ogunwale | bfa81ad | 2017-05-24 15:14:42 -0700 | [diff] [blame] | 224 | private void setKeyguardGoingAway(boolean keyguardGoingAway) { |
| 225 | mKeyguardGoingAway = keyguardGoingAway; |
| 226 | mWindowManager.setKeyguardGoingAway(keyguardGoingAway); |
| 227 | } |
| 228 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 229 | private void failCallback(IKeyguardDismissCallback callback) { |
| 230 | try { |
| 231 | callback.onDismissError(); |
| 232 | } catch (RemoteException e) { |
| 233 | Slog.w(TAG, "Failed to call callback", e); |
| 234 | } |
| 235 | } |
| 236 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 237 | private int convertTransitFlags(int keyguardGoingAwayFlags) { |
| 238 | int result = 0; |
| 239 | if ((keyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0) { |
| 240 | result |= TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE; |
| 241 | } |
| 242 | if ((keyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0) { |
| 243 | result |= TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION; |
| 244 | } |
| 245 | if ((keyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0) { |
| 246 | result |= TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER; |
| 247 | } |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 248 | if ((keyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS) != 0) { |
| 249 | result |= TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION; |
| 250 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 251 | return result; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Starts a batch of visibility updates. |
| 256 | */ |
| 257 | void beginActivityVisibilityUpdate() { |
| 258 | mVisibilityTransactionDepth++; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Ends a batch of visibility updates. After all batches are done, this method makes sure to |
| 263 | * update lockscreen occluded/dismiss state if needed. |
| 264 | */ |
| 265 | void endActivityVisibilityUpdate() { |
| 266 | mVisibilityTransactionDepth--; |
| 267 | if (mVisibilityTransactionDepth == 0) { |
| 268 | visibilitiesUpdated(); |
| 269 | } |
| 270 | } |
| 271 | |
Jorim Jaggi | e69c931 | 2016-10-31 18:24:38 -0700 | [diff] [blame] | 272 | /** |
| 273 | * @return True if we may show an activity while Keyguard is showing because we are in the |
| 274 | * process of dismissing it anyways, false otherwise. |
| 275 | */ |
Jorim Jaggi | 0796187 | 2016-11-23 11:28:57 +0100 | [diff] [blame] | 276 | boolean canShowActivityWhileKeyguardShowing(ActivityRecord r, boolean dismissKeyguard) { |
| 277 | |
| 278 | // Allow to show it when we are about to dismiss Keyguard. This isn't allowed if r is |
| 279 | // already the dismissing activity, in which case we don't allow it to repeatedly dismiss |
| 280 | // Keyguard. |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 281 | return dismissKeyguard && canDismissKeyguard() && !mAodShowing |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 282 | && (mDismissalRequested |
Arthur Hung | cf58b33 | 2019-04-17 16:07:10 +0800 | [diff] [blame] | 283 | || (r.canShowWhenLocked() |
| 284 | && getDisplay(r.getDisplayId()).mDismissingKeyguardActivity != r)); |
Jorim Jaggi | 0796187 | 2016-11-23 11:28:57 +0100 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /** |
| 288 | * @return True if we may show an activity while Keyguard is occluded, false otherwise. |
| 289 | */ |
| 290 | boolean canShowWhileOccluded(boolean dismissKeyguard, boolean showWhenLocked) { |
Brad Stenning | 2bdc21e | 2019-03-11 14:33:22 -0700 | [diff] [blame] | 291 | return showWhenLocked || dismissKeyguard |
| 292 | && !mWindowManager.isKeyguardSecure(mService.getCurrentUserId()); |
Jorim Jaggi | e69c931 | 2016-10-31 18:24:38 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 295 | private void visibilitiesUpdated() { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 296 | boolean requestDismissKeyguard = false; |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 297 | for (int displayNdx = mRootWindowContainer.getChildCount() - 1; |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 298 | displayNdx >= 0; displayNdx--) { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 299 | final DisplayContent display = mRootWindowContainer.getChildAt(displayNdx); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 300 | final KeyguardDisplayState state = getDisplay(display.mDisplayId); |
| 301 | state.visibilitiesUpdated(this, display); |
| 302 | requestDismissKeyguard |= state.mRequestDismissKeyguard; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 303 | } |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 304 | |
| 305 | // Dismissing Keyguard happens globally using the information from all displays. |
| 306 | if (requestDismissKeyguard) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 307 | handleDismissKeyguard(); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Called when occluded state changed. |
| 313 | */ |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 314 | private void handleOccludedChanged(int displayId) { |
| 315 | // TODO(b/113840485): Handle app transition for individual display, and apply occluded |
| 316 | // state change to secondary displays. |
| 317 | // For now, only default display fully supports occluded change. Other displays only |
| 318 | // updates keygaurd sleep token on that display. |
| 319 | if (displayId != DEFAULT_DISPLAY) { |
| 320 | updateKeyguardSleepToken(displayId); |
| 321 | return; |
| 322 | } |
| 323 | |
Riddle Hsu | 8419e4b | 2019-09-18 23:28:01 +0800 | [diff] [blame] | 324 | mWindowManager.mPolicy.onKeyguardOccludedChangedLw(isDisplayOccluded(DEFAULT_DISPLAY)); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 325 | if (isKeyguardLocked()) { |
Riddle Hsu | a0022cd | 2019-09-09 21:12:41 +0800 | [diff] [blame] | 326 | mService.deferWindowLayout(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 327 | try { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 328 | mRootWindowContainer.getDefaultDisplay().mDisplayContent |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 329 | .prepareAppTransition(resolveOccludeTransit(), |
| 330 | false /* alwaysKeepCurrent */, 0 /* flags */, |
| 331 | true /* forceOverride */); |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 332 | updateKeyguardSleepToken(DEFAULT_DISPLAY); |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 333 | mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 334 | mWindowManager.executeAppTransition(); |
| 335 | } finally { |
Riddle Hsu | a0022cd | 2019-09-09 21:12:41 +0800 | [diff] [blame] | 336 | mService.continueWindowLayout(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | dismissDockedStackIfNeeded(); |
| 340 | } |
| 341 | |
| 342 | /** |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 343 | * Called when somebody wants to dismiss the Keyguard via the flag. |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 344 | */ |
| 345 | private void handleDismissKeyguard() { |
Jorim Jaggi | 0796187 | 2016-11-23 11:28:57 +0100 | [diff] [blame] | 346 | // We only allow dismissing Keyguard via the flag when Keyguard is secure for legacy |
| 347 | // reasons, because that's how apps used to dismiss Keyguard in the secure case. In the |
| 348 | // insecure case, we actually show it on top of the lockscreen. See #canShowWhileOccluded. |
Brad Stenning | 2bdc21e | 2019-03-11 14:33:22 -0700 | [diff] [blame] | 349 | if (!mWindowManager.isKeyguardSecure(mService.getCurrentUserId())) { |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 350 | return; |
| 351 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 352 | |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 353 | mWindowManager.dismissKeyguard(null /* callback */, null /* message */); |
| 354 | mDismissalRequested = true; |
| 355 | |
| 356 | // If we are about to unocclude the Keyguard, but we can dismiss it without security, |
| 357 | // we immediately dismiss the Keyguard so the activity gets shown without a flicker. |
Wale Ogunwale | 3a256e6 | 2018-12-06 14:41:18 -0800 | [diff] [blame] | 358 | final DisplayContent dc = |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 359 | mRootWindowContainer.getDefaultDisplay().mDisplayContent; |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 360 | if (mKeyguardShowing && canDismissKeyguard() |
Wale Ogunwale | 3a256e6 | 2018-12-06 14:41:18 -0800 | [diff] [blame] | 361 | && dc.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE) { |
| 362 | dc.prepareAppTransition(mBeforeUnoccludeTransit, false /* alwaysKeepCurrent */, |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 363 | 0 /* flags */, true /* forceOverride */); |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 364 | mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 365 | mWindowManager.executeAppTransition(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 366 | } |
| 367 | } |
| 368 | |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 369 | private boolean isDisplayOccluded(int displayId) { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 370 | return getDisplay(displayId).mOccluded; |
| 371 | } |
| 372 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 373 | /** |
| 374 | * @return true if Keyguard can be currently dismissed without entering credentials. |
| 375 | */ |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 376 | boolean canDismissKeyguard() { |
Riddle Hsu | 8419e4b | 2019-09-18 23:28:01 +0800 | [diff] [blame] | 377 | return mWindowManager.mPolicy.isKeyguardTrustedLw() |
Brad Stenning | 2bdc21e | 2019-03-11 14:33:22 -0700 | [diff] [blame] | 378 | || !mWindowManager.isKeyguardSecure(mService.getCurrentUserId()); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | private int resolveOccludeTransit() { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 382 | final DisplayContent dc = mRootWindowContainer.getDefaultDisplay().mDisplayContent; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 383 | if (mBeforeUnoccludeTransit != TRANSIT_UNSET |
Wale Ogunwale | 3a256e6 | 2018-12-06 14:41:18 -0800 | [diff] [blame] | 384 | && dc.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 385 | // TODO(b/113840485): Handle app transition for individual display. |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 386 | && isDisplayOccluded(DEFAULT_DISPLAY)) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 387 | |
| 388 | // Reuse old transit in case we are occluding Keyguard again, meaning that we never |
| 389 | // actually occclude/unocclude Keyguard, but just run a normal transition. |
| 390 | return mBeforeUnoccludeTransit; |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 391 | // TODO(b/113840485): Handle app transition for individual display. |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 392 | } else if (!isDisplayOccluded(DEFAULT_DISPLAY)) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 393 | |
| 394 | // Save transit in case we dismiss/occlude Keyguard shortly after. |
Wale Ogunwale | 3a256e6 | 2018-12-06 14:41:18 -0800 | [diff] [blame] | 395 | mBeforeUnoccludeTransit = dc.mAppTransition.getAppTransition(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 396 | return TRANSIT_KEYGUARD_UNOCCLUDE; |
| 397 | } else { |
| 398 | return TRANSIT_KEYGUARD_OCCLUDE; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | private void dismissDockedStackIfNeeded() { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 403 | // TODO(b/113840485): Handle docked stack for individual display. |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 404 | if (mKeyguardShowing && isDisplayOccluded(DEFAULT_DISPLAY)) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 405 | // The lock screen is currently showing, but is occluded by a window that can |
| 406 | // show on top of the lock screen. In this can we want to dismiss the docked |
| 407 | // stack since it will be complicated/risky to try to put the activity on top |
| 408 | // of the lock screen in the right fullscreen configuration. |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 409 | final ActivityStack stack = |
Wale Ogunwale | 734b896 | 2020-01-21 12:17:42 -0800 | [diff] [blame] | 410 | mRootWindowContainer.getDefaultDisplay().getRootSplitScreenPrimaryTask(); |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 411 | if (stack == null) { |
| 412 | return; |
| 413 | } |
Evan Rosky | af9f27c | 2020-02-18 18:58:35 +0000 | [diff] [blame] | 414 | mRootWindowContainer.getDefaultDisplay().onSplitScreenModeDismissed(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 415 | } |
| 416 | } |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 417 | |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 418 | private void updateKeyguardSleepToken() { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 419 | for (int displayNdx = mRootWindowContainer.getChildCount() - 1; |
Wale Ogunwale | d32da47 | 2018-11-16 07:19:28 -0800 | [diff] [blame] | 420 | displayNdx >= 0; displayNdx--) { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 421 | final DisplayContent display = mRootWindowContainer.getChildAt(displayNdx); |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 422 | updateKeyguardSleepToken(display.mDisplayId); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | private void updateKeyguardSleepToken(int displayId) { |
| 427 | final KeyguardDisplayState state = getDisplay(displayId); |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 428 | if (isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken == null) { |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 429 | state.acquiredSleepToken(); |
Issei Suzuki | 16d4de5 | 2019-07-29 13:12:01 +0000 | [diff] [blame] | 430 | } else if (!isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken != null) { |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 431 | state.releaseSleepToken(); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | |
| 435 | private KeyguardDisplayState getDisplay(int displayId) { |
wilsonshih | e7903ea | 2018-09-26 16:17:59 +0800 | [diff] [blame] | 436 | KeyguardDisplayState state = mDisplayStates.get(displayId); |
| 437 | if (state == null) { |
| 438 | state = new KeyguardDisplayState(mService, displayId); |
| 439 | mDisplayStates.append(displayId, state); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 440 | } |
wilsonshih | e7903ea | 2018-09-26 16:17:59 +0800 | [diff] [blame] | 441 | return state; |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | void onDisplayRemoved(int displayId) { |
wilsonshih | e7903ea | 2018-09-26 16:17:59 +0800 | [diff] [blame] | 445 | final KeyguardDisplayState state = mDisplayStates.get(displayId); |
| 446 | if (state != null) { |
| 447 | state.onRemoved(); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 448 | mDisplayStates.remove(displayId); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | /** Represents Keyguard state per individual display. */ |
| 453 | private static class KeyguardDisplayState { |
| 454 | private final int mDisplayId; |
| 455 | private boolean mOccluded; |
| 456 | private ActivityRecord mDismissingKeyguardActivity; |
| 457 | private boolean mRequestDismissKeyguard; |
| 458 | private final ActivityTaskManagerService mService; |
| 459 | private SleepToken mSleepToken; |
| 460 | |
| 461 | KeyguardDisplayState(ActivityTaskManagerService service, int displayId) { |
| 462 | mService = service; |
| 463 | mDisplayId = displayId; |
| 464 | } |
| 465 | |
| 466 | void onRemoved() { |
| 467 | mDismissingKeyguardActivity = null; |
| 468 | releaseSleepToken(); |
| 469 | } |
| 470 | |
| 471 | void acquiredSleepToken() { |
| 472 | if (mSleepToken == null) { |
| 473 | mSleepToken = mService.acquireSleepToken("keyguard", mDisplayId); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void releaseSleepToken() { |
| 478 | if (mSleepToken != null) { |
| 479 | mSleepToken.release(); |
| 480 | mSleepToken = null; |
| 481 | } |
| 482 | } |
| 483 | |
Louis Chang | 677921f | 2019-12-06 16:44:24 +0800 | [diff] [blame] | 484 | void visibilitiesUpdated(KeyguardController controller, DisplayContent display) { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 485 | final boolean lastOccluded = mOccluded; |
| 486 | final ActivityRecord lastDismissActivity = mDismissingKeyguardActivity; |
| 487 | mRequestDismissKeyguard = false; |
| 488 | mOccluded = false; |
| 489 | mDismissingKeyguardActivity = null; |
| 490 | |
wilsonshih | 9a10e9d | 2019-01-11 14:39:27 +0800 | [diff] [blame] | 491 | final ActivityStack stack = getStackForControllingOccluding(display); |
| 492 | if (stack != null) { |
| 493 | final ActivityRecord topDismissing = stack.getTopDismissingKeyguardActivity(); |
| 494 | mOccluded = stack.topActivityOccludesKeyguard() || (topDismissing != null |
Wale Ogunwale | 85fb19a | 2019-12-05 10:41:05 +0900 | [diff] [blame] | 495 | && stack.topRunningActivity() == topDismissing |
wilsonshih | 9a10e9d | 2019-01-11 14:39:27 +0800 | [diff] [blame] | 496 | && controller.canShowWhileOccluded( |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 497 | true /* dismissKeyguard */, |
| 498 | false /* showWhenLocked */)); |
wilsonshih | 9a10e9d | 2019-01-11 14:39:27 +0800 | [diff] [blame] | 499 | if (stack.getTopDismissingKeyguardActivity() != null) { |
| 500 | mDismissingKeyguardActivity = stack.getTopDismissingKeyguardActivity(); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 501 | } |
wilsonshih | 498a4b8 | 2018-12-11 16:10:16 +0800 | [diff] [blame] | 502 | // FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD only apply for secondary display. |
| 503 | if (mDisplayId != DEFAULT_DISPLAY) { |
| 504 | mOccluded |= stack.canShowWithInsecureKeyguard() |
| 505 | && controller.canDismissKeyguard(); |
| 506 | } |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 507 | } |
wilsonshih | 498a4b8 | 2018-12-11 16:10:16 +0800 | [diff] [blame] | 508 | // TODO(b/123372519): isShowingDream can only works on default display. |
| 509 | if (mDisplayId == DEFAULT_DISPLAY) { |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 510 | mOccluded |= mService.mRootWindowContainer.getDefaultDisplay().mDisplayContent |
Riddle Hsu | 8419e4b | 2019-09-18 23:28:01 +0800 | [diff] [blame] | 511 | .getDisplayPolicy().isShowingDreamLw(); |
wilsonshih | 498a4b8 | 2018-12-11 16:10:16 +0800 | [diff] [blame] | 512 | } |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 513 | |
Issei Suzuki | 62356a2 | 2019-04-11 16:46:37 +0200 | [diff] [blame] | 514 | if (lastOccluded != mOccluded) { |
| 515 | controller.handleOccludedChanged(mDisplayId); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 516 | } |
| 517 | if (lastDismissActivity != mDismissingKeyguardActivity && !mOccluded |
| 518 | && mDismissingKeyguardActivity != null |
Brad Stenning | 2bdc21e | 2019-03-11 14:33:22 -0700 | [diff] [blame] | 519 | && controller.mWindowManager.isKeyguardSecure( |
| 520 | controller.mService.getCurrentUserId())) { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 521 | mRequestDismissKeyguard = true; |
| 522 | } |
| 523 | } |
| 524 | |
wilsonshih | 9a10e9d | 2019-01-11 14:39:27 +0800 | [diff] [blame] | 525 | /** |
| 526 | * Gets the stack used to check the occluded state. |
| 527 | * <p> |
| 528 | * Only the top non-pinned activity of the focusable stack on each display can control its |
| 529 | * occlusion state. |
| 530 | */ |
Louis Chang | 677921f | 2019-12-06 16:44:24 +0800 | [diff] [blame] | 531 | private ActivityStack getStackForControllingOccluding(DisplayContent display) { |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 532 | for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) { |
| 533 | final ActivityStack stack = display.getStackAt(stackNdx); |
wilsonshih | 9a10e9d | 2019-01-11 14:39:27 +0800 | [diff] [blame] | 534 | if (stack != null && stack.isFocusableAndVisible() |
| 535 | && !stack.inPinnedWindowingMode()) { |
| 536 | return stack; |
| 537 | } |
| 538 | } |
| 539 | return null; |
| 540 | } |
| 541 | |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 542 | void dumpStatus(PrintWriter pw, String prefix) { |
| 543 | final StringBuilder sb = new StringBuilder(); |
| 544 | sb.append(prefix); |
| 545 | sb.append(" Occluded=").append(mOccluded) |
| 546 | .append(" DismissingKeyguardActivity=") |
| 547 | .append(mDismissingKeyguardActivity) |
| 548 | .append(" at display=") |
| 549 | .append(mDisplayId); |
| 550 | pw.println(sb.toString()); |
| 551 | } |
| 552 | |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 553 | void dumpDebug(ProtoOutputStream proto, long fieldId) { |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 554 | final long token = proto.start(fieldId); |
| 555 | proto.write(DISPLAY_ID, mDisplayId); |
| 556 | proto.write(KEYGUARD_OCCLUDED, mOccluded); |
| 557 | proto.end(token); |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 558 | } |
| 559 | } |
| 560 | |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 561 | void dump(PrintWriter pw, String prefix) { |
| 562 | pw.println(prefix + "KeyguardController:"); |
| 563 | pw.println(prefix + " mKeyguardShowing=" + mKeyguardShowing); |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 564 | pw.println(prefix + " mAodShowing=" + mAodShowing); |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 565 | pw.println(prefix + " mKeyguardGoingAway=" + mKeyguardGoingAway); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 566 | dumpDisplayStates(pw, prefix); |
Jorim Jaggi | 0796187 | 2016-11-23 11:28:57 +0100 | [diff] [blame] | 567 | pw.println(prefix + " mDismissalRequested=" + mDismissalRequested); |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 568 | pw.println(prefix + " mVisibilityTransactionDepth=" + mVisibilityTransactionDepth); |
| 569 | } |
Steven Timotius | 4346f0a | 2017-09-12 11:07:21 -0700 | [diff] [blame] | 570 | |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 571 | void dumpDebug(ProtoOutputStream proto, long fieldId) { |
Steven Timotius | 4346f0a | 2017-09-12 11:07:21 -0700 | [diff] [blame] | 572 | final long token = proto.start(fieldId); |
Issei Suzuki | d6eb5a2 | 2019-02-20 23:08:03 +0100 | [diff] [blame] | 573 | proto.write(AOD_SHOWING, mAodShowing); |
Steven Timotius | 4346f0a | 2017-09-12 11:07:21 -0700 | [diff] [blame] | 574 | proto.write(KEYGUARD_SHOWING, mKeyguardShowing); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 575 | writeDisplayStatesToProto(proto, KEYGUARD_OCCLUDED_STATES); |
Steven Timotius | 4346f0a | 2017-09-12 11:07:21 -0700 | [diff] [blame] | 576 | proto.end(token); |
| 577 | } |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 578 | |
| 579 | private void dumpDisplayStates(PrintWriter pw, String prefix) { |
| 580 | for (int i = 0; i < mDisplayStates.size(); i++) { |
| 581 | mDisplayStates.valueAt(i).dumpStatus(pw, prefix); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | private void writeDisplayStatesToProto(ProtoOutputStream proto, long fieldId) { |
| 586 | for (int i = 0; i < mDisplayStates.size(); i++) { |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 587 | mDisplayStates.valueAt(i).dumpDebug(proto, fieldId); |
wilsonshih | 0299c8a | 2018-08-24 15:52:57 +0800 | [diff] [blame] | 588 | } |
| 589 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 590 | } |