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