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