• 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.ViewGroup;
22 import android.view.ViewRootImpl;
23 
24 import com.android.systemui.keyguard.DismissCallbackRegistry;
25 import com.android.systemui.keyguard.KeyguardViewMediator;
26 import com.android.systemui.plugins.FalsingManager;
27 import com.android.systemui.statusbar.phone.BiometricUnlockController;
28 import com.android.systemui.statusbar.phone.KeyguardBypassController;
29 import com.android.systemui.statusbar.phone.NotificationPanelViewController;
30 import com.android.systemui.statusbar.phone.StatusBar;
31 
32 /**
33  *  Interface to control Keyguard View. It should be implemented by KeyguardViewManagers, which
34  *  should, in turn, be injected into {@link KeyguardViewMediator}.
35  */
36 public interface KeyguardViewController {
37     /**
38      * Shows Keyguard.
39      * @param options
40      */
show(Bundle options)41     void show(Bundle options);
42 
43     /**
44      * Hides Keyguard with the fade-out animation as configured by the parameters provided.
45      *
46      * @param startTime
47      * @param fadeoutDuration
48      */
hide(long startTime, long fadeoutDuration)49     void hide(long startTime, long fadeoutDuration);
50 
51     /**
52      * Resets the state of Keyguard View.
53      * @param hideBouncerWhenShowing
54      */
reset(boolean hideBouncerWhenShowing)55     void reset(boolean hideBouncerWhenShowing);
56 
57     /**
58      * Called when the device started going to sleep.
59      */
onStartedGoingToSleep()60     default void onStartedGoingToSleep() {};
61 
62     /**
63      * Called when the device has finished going to sleep.
64      */
onFinishedGoingToSleep()65     default void onFinishedGoingToSleep() {};
66 
67     /**
68      * Called when the device started waking up.
69      */
onStartedWakingUp()70     default void onStartedWakingUp() {};
71 
72     /**
73      * Called when the device started turning on.
74      */
onScreenTurningOn()75     default void onScreenTurningOn() {};
76 
77     /**
78      * Called when the device has finished turning on.
79      */
onScreenTurnedOn()80     default void onScreenTurnedOn() {};
81 
82     /**
83      * Sets whether the Keyguard needs input.
84      * @param needsInput
85      */
setNeedsInput(boolean needsInput)86     void setNeedsInput(boolean needsInput);
87 
88     /**
89      * Called when cancel button in bouncer is pressed.
90      */
onCancelClicked()91     void onCancelClicked();
92 
93     /**
94      * Sets whether the keyguard is occluded by another window.
95      *
96      * @param occluded
97      * @param animate
98      */
setOccluded(boolean occluded, boolean animate)99     void setOccluded(boolean occluded, boolean animate);
100 
101     /**
102      * @return Whether the keyguard is showing
103      */
isShowing()104     boolean isShowing();
105 
106     /**
107      * Dismisses the keyguard by going to the next screen or making it gone.
108      */
dismissAndCollapse()109     void dismissAndCollapse();
110 
111     /**
112      * Notifies that Keyguard is just about to go away.
113      */
keyguardGoingAway()114     void keyguardGoingAway();
115 
116     /**
117      * Sets the system state depending on whether the keyguard is going away or not.
118      */
setKeyguardGoingAwayState(boolean isKeyguardGoingAway)119     void setKeyguardGoingAwayState(boolean isKeyguardGoingAway);
120 
121     /**
122      * @return Whether window animation for unlock should be disabled.
123      */
shouldDisableWindowAnimationsForUnlock()124     boolean shouldDisableWindowAnimationsForUnlock();
125 
126     /**
127      * @return Whether the keyguard is going to notification shade.
128      */
isGoingToNotificationShade()129     boolean isGoingToNotificationShade();
130 
131     /**
132      * @return Whether subtle animation should be used for unlocking the device.
133      */
isUnlockWithWallpaper()134     boolean isUnlockWithWallpaper();
135 
136     /**
137      * @return Whether subtle animation should be used for unlocking the device.
138      */
shouldSubtleWindowAnimationsForUnlock()139     boolean shouldSubtleWindowAnimationsForUnlock();
140 
141     /**
142      * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the
143      * security view of the bouncer.
144      *
145      * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
146      *                       no action should be run
147      */
startPreHideAnimation(Runnable finishRunnable)148     void startPreHideAnimation(Runnable finishRunnable);
149 
150     /**
151      * @return the ViewRootImpl of the View where the Keyguard is mounted.
152      */
getViewRootImpl()153     ViewRootImpl getViewRootImpl();
154 
155     /**
156      * Notifies that the user has authenticated by other means than using the bouncer, for example,
157      * fingerprint.
158      */
notifyKeyguardAuthenticated(boolean strongAuth)159     void notifyKeyguardAuthenticated(boolean strongAuth);
160 
161     /**
162      * Shows the Bouncer.
163      *
164      */
showBouncer(boolean scrimmed)165     void showBouncer(boolean scrimmed);
166 
167     /**
168      * Returns {@code true} when the bouncer is currently showing
169      */
isBouncerShowing()170     boolean isBouncerShowing();
171 
172     /**
173      * When bouncer is fully visible or it is showing but animation didn't finish yet.
174      */
bouncerIsOrWillBeShowing()175     boolean bouncerIsOrWillBeShowing();
176 
177     // TODO: Deprecate registerStatusBar in KeyguardViewController interface. It is currently
178     //  only used for testing purposes in StatusBarKeyguardViewManager, and it prevents us from
179     //  achieving complete abstraction away from where the Keyguard View is mounted.
180 
181     /**
182      * Registers the StatusBar to which this Keyguard View is mounted.
183      *
184      * @param statusBar
185      * @param container
186      * @param notificationPanelViewController
187      * @param biometricUnlockController
188      * @param dismissCallbackRegistry
189      * @param lockIconContainer
190      * @param notificationContainer
191      * @param bypassController
192      * @param falsingManager
193      */
registerStatusBar(StatusBar statusBar, ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, View notificationContainer, KeyguardBypassController bypassController, FalsingManager falsingManager)194     void registerStatusBar(StatusBar statusBar,
195             ViewGroup container,
196             NotificationPanelViewController notificationPanelViewController,
197             BiometricUnlockController biometricUnlockController,
198             DismissCallbackRegistry dismissCallbackRegistry,
199             ViewGroup lockIconContainer, View notificationContainer,
200             KeyguardBypassController bypassController, FalsingManager falsingManager);
201 }
202