• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.systemui.statusbar.policy;
18 
19 import android.app.IActivityTaskManager;
20 
21 import com.android.systemui.Dumpable;
22 import com.android.systemui.statusbar.StatusBarState;
23 import com.android.systemui.statusbar.policy.KeyguardStateController.Callback;
24 
25 import java.io.PrintWriter;
26 
27 /**
28  * Source of truth for keyguard state: If locked, occluded, has password, trusted etc.
29  *
30  * @deprecated this class is not supported when KEYGUARD_WM_STATE_REFACTOR is enabled.
31  * Use {@link com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor}
32  * or {@link com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor} instead.
33  */
34 @Deprecated
35 public interface KeyguardStateController extends CallbackController<Callback>, Dumpable {
36 
37     /**
38      * If the device is locked or unlocked.
39      */
isUnlocked()40     default boolean isUnlocked() {
41         return !isShowing() || canDismissLockScreen();
42     }
43 
44     /**
45      * If the keyguard is visible. This is unrelated to being locked or not.
46      */
isVisible()47     default boolean isVisible() {
48         return isShowing() && !isOccluded();
49     }
50 
dump(PrintWriter pw, String[] args)51     default void dump(PrintWriter pw, String[] args) { }
52 
53     /**
54      * If the keyguard is showing. This includes when it's occluded by an activity, and when
55      * the device is asleep or in always on mode, except when the screen timed out and the user
56      * can unlock by quickly pressing power.
57      *
58      * This is unrelated to being locked or not.
59      *
60      * @see #isUnlocked()
61      * @see #canDismissLockScreen()
62      */
isShowing()63     boolean isShowing();
64 
65     /**
66      * Whether the bouncer (PIN/password entry) is currently visible.
67      */
isPrimaryBouncerShowing()68     boolean isPrimaryBouncerShowing();
69 
70     /**
71      * If swiping up will unlock without asking for a password.
72      * @see #isUnlocked()
73      */
canDismissLockScreen()74     boolean canDismissLockScreen();
75 
76     /**
77      * Whether the keyguard is allowed to rotate, or needs to be locked to the default orientation.
78      */
isKeyguardScreenRotationAllowed()79     boolean isKeyguardScreenRotationAllowed();
80 
81     /**
82      * If the device has PIN/pattern/password or a lock screen at all.
83      */
isMethodSecure()84     boolean isMethodSecure();
85 
86     /**
87      * When there's an {@link android.app.Activity} on top of the keyguard, where
88      * {@link android.app.Activity#setShowWhenLocked(boolean)} is true.
89      */
isOccluded()90     boolean isOccluded();
91 
92     /**
93      * If a {@link android.service.trust.TrustAgentService} is keeping the device unlocked.
94      * {@link #canDismissLockScreen()} is better source of truth that also considers this state.
95      */
isTrusted()96     boolean isTrusted();
97 
98     /**
99      * If the keyguard dismissal animation is running.
100      * @see #isKeyguardGoingAway()
101      */
isKeyguardFadingAway()102     boolean isKeyguardFadingAway();
103 
104     /**
105      * When the keyguard challenge was successfully solved, and {@link android.app.ActivityManager}
106      * is launching the activity that will be revealed.
107      *
108      * This also includes the animation of the keyguard being dismissed, meaning that this will
109      * return {@code true} whenever {@link #isKeyguardFadingAway()} also returns {@code true}.
110      */
isKeyguardGoingAway()111     boolean isKeyguardGoingAway();
112 
113     /**
114      * Whether we're currently animating between the keyguard and the app/launcher surface behind
115      * it, or will be shortly (which happens if we started a fling to dismiss the keyguard).
116      * @see {@link KeyguardViewMediator#isAnimatingBetweenKeyguardAndSurfaceBehind()}
117      */
isAnimatingBetweenKeyguardAndSurfaceBehind()118     default boolean isAnimatingBetweenKeyguardAndSurfaceBehind() {
119         return false;
120     };
121 
122     /**
123      * @return a shortened fading away duration similar to
124      * {{@link #getKeyguardFadingAwayDuration()}} which may only span half of the duration, unless
125      * we're bypassing
126      */
getShortenedFadingAwayDuration()127     default long getShortenedFadingAwayDuration() {
128         return getKeyguardFadingAwayDuration() / 2;
129     }
130 
131     /**
132      * Notifies that the Keyguard is fading away with the specified timings.
133      * @param delay the precalculated animation delay in milliseconds
134      * @param fadeoutDuration the duration of the exit animation, in milliseconds
135      */
notifyKeyguardFadingAway(long delay, long fadeoutDuratio)136     default void notifyKeyguardFadingAway(long delay, long fadeoutDuratio) {
137     }
138 
139     /**
140      * If there are faces enrolled and user enabled face auth on keyguard.
141      */
isFaceEnrolledAndEnabled()142     default boolean isFaceEnrolledAndEnabled() {
143         return false;
144     }
145 
146     /**
147      * If the animation that morphs a notification into an app window is playing.
148      */
isLaunchTransitionFadingAway()149     boolean isLaunchTransitionFadingAway();
150 
151     /**
152      * How long the keyguard dismissal animation should take when unlocking.
153      */
getKeyguardFadingAwayDuration()154     long getKeyguardFadingAwayDuration();
155 
156     /**
157      * Delay for {@link #getKeyguardFadingAwayDuration()}.
158      */
getKeyguardFadingAwayDelay()159     long getKeyguardFadingAwayDelay();
160 
161     /**
162      * Delay when going from {@link StatusBarState#KEYGUARD} to {@link StatusBarState#SHADE} or
163      * {@link StatusBarState#SHADE_LOCKED}.
164      */
calculateGoingToFullShadeDelay()165     long calculateGoingToFullShadeDelay();
166 
167     /**
168      * How much (from 0f to 1f) the keyguard is dismissed, either via a swipe gesture or an
169      * animation.
170      */
getDismissAmount()171     float getDismissAmount();
172 
173     /**
174      * Whether the keyguard is being dismissed due to direct user input, rather than a canned
175      * animation.
176      */
isDismissingFromSwipe()177     boolean isDismissingFromSwipe();
178 
179     /**
180      * Whether a fling animation is currently playing on the keyguard, either to dismiss it or to
181      * cancel dismissing it.
182      */
isFlingingToDismissKeyguard()183     boolean isFlingingToDismissKeyguard();
184 
185     /**
186      * Whether a fling animation is currently playing on the keyguard, either to dismiss it or to
187      * cancel dismissing it, and that animation started during a swipe gesture. Fling animations
188      * can also be started without a swipe (e.g. activity launch from lock screen notification), so
189      * this is a way to tell them apart for animation purposes.
190      */
isFlingingToDismissKeyguardDuringSwipeGesture()191     boolean isFlingingToDismissKeyguardDuringSwipeGesture();
192 
193     /**
194      * Whether a fling animation is currently playing on the keyguard to cancel dismissing it, after
195      * the user released their finger during a swipe gesture.
196      */
isSnappingKeyguardBackAfterSwipe()197     boolean isSnappingKeyguardBackAfterSwipe();
198 
199     /** **/
setLaunchTransitionFadingAway(boolean b)200     default void setLaunchTransitionFadingAway(boolean b) {}
201     /** **/
notifyKeyguardGoingAway(boolean b)202     default void notifyKeyguardGoingAway(boolean b) {}
203     /** **/
notifyKeyguardDoneFading()204     default void notifyKeyguardDoneFading() {}
205     /** **/
notifyKeyguardState(boolean showing, boolean occluded)206     default void notifyKeyguardState(boolean showing, boolean occluded) {}
207     /** **/
notifyPrimaryBouncerShowing(boolean showing)208     default void notifyPrimaryBouncerShowing(boolean showing) {}
209 
210     /**
211      * Updates the keyguard state to reflect that it's in the process of being dismissed, either by
212      * a swipe gesture on the lock screen or by a canned animation.
213      *
214      * @param dismissAmount 0f means we're not dismissed at all, 1f means we have been completely
215      *                      swiped away.
216      * @param dismissingFromTouch True if this change was caused by direct user interaction, false
217      *                            if it's due to an animation.
218      */
notifyKeyguardDismissAmountChanged( float dismissAmount, boolean dismissingFromTouch)219     default void notifyKeyguardDismissAmountChanged(
220             float dismissAmount, boolean dismissingFromTouch) {}
221 
222     /**
223      * Updates the keyguard state to reflect that a dismiss fling gesture has started.
224      *
225      * @param dismiss Whether we're flinging to dismiss (upward) or to cancel a dismiss gesture.
226      */
notifyPanelFlingStart(boolean dismiss)227     void notifyPanelFlingStart(boolean dismiss);
228 
229     /** Updates the keyguard state to reflect that a dismiss fling gesture has ended. */
notifyPanelFlingEnd()230     void notifyPanelFlingEnd();
231 
232     /**
233      * Callback for authentication events.
234      */
235     interface Callback {
236         /**
237          * Called when the locked state of the device changes. The lock screen might still be
238          * showing on some cases, like when a {@link android.service.trust.TrustAgentService} is
239          * active, or face auth was triggered but the user didn't swipe up to dismiss the lock
240          * screen yet.
241          */
onUnlockedChanged()242         default void onUnlockedChanged() {}
243 
244         /**
245          * If the lock screen is active or not. This is different from being locked, since the lock
246          * screen can be visible but unlocked by {@link android.service.trust.TrustAgentService} or
247          * face unlock.
248          *
249          * @see #isShowing()
250          */
onKeyguardShowingChanged()251         default void onKeyguardShowingChanged() {}
252 
253         /**
254          * Called when the bouncer (PIN/password entry) is shown or hidden.
255          */
onPrimaryBouncerShowingChanged()256         default void onPrimaryBouncerShowingChanged() {}
257 
258         /**
259          * Triggered when the device was just unlocked and the lock screen is being dismissed.
260          */
onKeyguardFadingAwayChanged()261         default void onKeyguardFadingAwayChanged() {}
262 
263         /**
264          * We've called {@link IActivityTaskManager#keyguardGoingAway}, which initiates the unlock
265          * sequence.
266          */
onKeyguardGoingAwayChanged()267         default void onKeyguardGoingAwayChanged() {}
268 
269         /**
270          * Triggered when the keyguard dismiss amount has changed, via either a swipe gesture or an
271          * animation.
272          */
onKeyguardDismissAmountChanged()273         default void onKeyguardDismissAmountChanged() {}
274 
275         /**
276          * Triggered when face auth becomes available or unavailable. Value should be queried with
277          * {@link KeyguardStateController#isFaceEnrolledAndEnabled()}.
278          */
onFaceEnrolledChanged()279         default void onFaceEnrolledChanged() {}
280 
281         /**
282          * Triggered when the notification panel is starting or has finished
283          * fading away on transition to an app.
284          */
onLaunchTransitionFadingAwayChanged()285         default void onLaunchTransitionFadingAwayChanged() {}
286     }
287 }
288