• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.keyguard;
18 
19 import android.os.Bundle;
20 import android.view.View;
21 import android.view.ViewRootImpl;
22 
23 import androidx.annotation.Nullable;
24 
25 import com.android.systemui.keyguard.KeyguardViewMediator;
26 import com.android.systemui.shade.ShadeExpansionStateManager;
27 import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor;
28 import com.android.systemui.statusbar.phone.BiometricUnlockController;
29 import com.android.systemui.statusbar.phone.CentralSurfaces;
30 
31 /**
32  *  Interface to control Keyguard View. It should be implemented by KeyguardViewManagers, which
33  *  should, in turn, be injected into {@link KeyguardViewMediator}.
34  */
35 public interface KeyguardViewController {
36     /**
37      * Shows Keyguard.
38      * @param options
39      */
show(Bundle options)40     void show(Bundle options);
41 
42     /**
43      * Hides Keyguard with the fade-out animation as configured by the parameters provided.
44      *
45      * @param startTime
46      * @param fadeoutDuration
47      */
hide(long startTime, long fadeoutDuration)48     void hide(long startTime, long fadeoutDuration);
49 
50     /**
51      * Resets the state of Keyguard View.
52      * @param hideBouncerWhenShowing when true, hides the primary and alternate bouncers if showing.
53      */
reset(boolean hideBouncerWhenShowing)54     void reset(boolean hideBouncerWhenShowing);
55 
56     /**
57      * Called when the device started going to sleep.
58      */
onStartedGoingToSleep()59     default void onStartedGoingToSleep() {};
60 
61     /**
62      * Called when the device has finished going to sleep.
63      */
onFinishedGoingToSleep()64     default void onFinishedGoingToSleep() {};
65 
66     /**
67      * Called when the device started waking up.
68      */
onStartedWakingUp()69     default void onStartedWakingUp() {};
70 
71     /**
72      * Sets whether the Keyguard needs input.
73      * @param needsInput
74      */
setNeedsInput(boolean needsInput)75     void setNeedsInput(boolean needsInput);
76 
77     /**
78      * Called when cancel button in bouncer is pressed.
79      */
onCancelClicked()80     void onCancelClicked();
81 
82     /**
83      * Sets whether the keyguard is occluded by another window.
84      *
85      * @param occluded
86      * @param animate
87      */
setOccluded(boolean occluded, boolean animate)88     void setOccluded(boolean occluded, boolean animate);
89 
90     /**
91      * Dismisses the keyguard by going to the next screen or making it gone.
92      */
dismissAndCollapse()93     void dismissAndCollapse();
94 
95     /**
96      * Notifies that Keyguard is just about to go away.
97      */
keyguardGoingAway()98     void keyguardGoingAway();
99 
100     /**
101      * Sets the system state depending on whether the keyguard is going away or not.
102      */
setKeyguardGoingAwayState(boolean isKeyguardGoingAway)103     void setKeyguardGoingAwayState(boolean isKeyguardGoingAway);
104 
105     /**
106      * @return Whether window animation for unlock should be disabled.
107      */
shouldDisableWindowAnimationsForUnlock()108     boolean shouldDisableWindowAnimationsForUnlock();
109 
110     /**
111      * @return Whether the keyguard is going to notification shade.
112      */
isGoingToNotificationShade()113     boolean isGoingToNotificationShade();
114 
115     /**
116      * @return Whether subtle animation should be used for unlocking the device.
117      */
isUnlockWithWallpaper()118     boolean isUnlockWithWallpaper();
119 
120     /**
121      * @return Whether the bouncer over dream is showing. Note that the bouncer over dream is
122      * handled independently of the rest of the notification panel. As a result, setting this state
123      * via {@link CentralSurfaces#setBouncerShowing(boolean)} leads to unintended side effects from
124      * states modified behind the dream.
125      */
isBouncerShowingOverDream()126     boolean isBouncerShowingOverDream();
127 
128     /**
129      * @return Whether subtle animation should be used for unlocking the device.
130      */
shouldSubtleWindowAnimationsForUnlock()131     boolean shouldSubtleWindowAnimationsForUnlock();
132 
133     /**
134      * Starts the animation before we dismiss Keyguard, i.e. a disappearing animation on the
135      * security view of the bouncer.
136      *
137      * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
138      *                       no action should be run
139      */
startPreHideAnimation(Runnable finishRunnable)140     void startPreHideAnimation(Runnable finishRunnable);
141 
142     /**
143      * Blocks the current touch gesture from affecting the expansion amount of the notification
144      * panel. This is used after a completed unlock gesture to ignore further dragging before an
145      * ACTION_UP.
146      */
blockPanelExpansionFromCurrentTouch()147     void blockPanelExpansionFromCurrentTouch();
148 
149     /**
150      * @return the ViewRootImpl of the View where the Keyguard is mounted.
151      */
getViewRootImpl()152     ViewRootImpl getViewRootImpl();
153 
154     /**
155      * Notifies that the user has authenticated by other means than using the bouncer, for example,
156      * fingerprint.
157      */
notifyKeyguardAuthenticated(boolean strongAuth)158     void notifyKeyguardAuthenticated(boolean strongAuth);
159 
160     /**
161      * Shows the primary bouncer.
162      */
showPrimaryBouncer(boolean scrimmed)163     void showPrimaryBouncer(boolean scrimmed);
164 
165     /**
166      * When the primary bouncer is fully visible or is showing but animation didn't finish yet.
167      */
primaryBouncerIsOrWillBeShowing()168     boolean primaryBouncerIsOrWillBeShowing();
169 
170     /**
171      * Returns {@code true} when the primary bouncer or alternate bouncer is currently showing
172      */
isBouncerShowing()173     boolean isBouncerShowing();
174 
175     /**
176      * Stop showing the alternate bouncer, if showing.
177      */
hideAlternateBouncer(boolean updateScrim)178     void hideAlternateBouncer(boolean updateScrim);
179 
180     // TODO: Deprecate registerStatusBar in KeyguardViewController interface. It is currently
181     //  only used for testing purposes in StatusBarKeyguardViewManager, and it prevents us from
182     //  achieving complete abstraction away from where the Keyguard View is mounted.
183 
184     /**
185      * Registers the CentralSurfaces to which this Keyguard View is mounted.
186      */
registerCentralSurfaces(CentralSurfaces centralSurfaces, ShadeLockscreenInteractor shadeLockscreenInteractor, @Nullable ShadeExpansionStateManager shadeExpansionStateManager, BiometricUnlockController biometricUnlockController, View notificationContainer)187     void registerCentralSurfaces(CentralSurfaces centralSurfaces,
188             ShadeLockscreenInteractor shadeLockscreenInteractor,
189             @Nullable ShadeExpansionStateManager shadeExpansionStateManager,
190             BiometricUnlockController biometricUnlockController,
191             View notificationContainer);
192 }
193