• 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.NotificationPanelViewController;
27 import com.android.systemui.shade.ShadeExpansionStateManager;
28 import com.android.systemui.statusbar.phone.BiometricUnlockController;
29 import com.android.systemui.statusbar.phone.CentralSurfaces;
30 import com.android.systemui.statusbar.phone.KeyguardBypassController;
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 when true, hides the primary and alternate bouncers if showing.
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      * Sets whether the Keyguard needs input.
74      * @param needsInput
75      */
setNeedsInput(boolean needsInput)76     void setNeedsInput(boolean needsInput);
77 
78     /**
79      * Called when cancel button in bouncer is pressed.
80      */
onCancelClicked()81     void onCancelClicked();
82 
83     /**
84      * Sets whether the keyguard is occluded by another window.
85      *
86      * @param occluded
87      * @param animate
88      */
setOccluded(boolean occluded, boolean animate)89     void setOccluded(boolean occluded, boolean animate);
90 
91     /**
92      * Dismisses the keyguard by going to the next screen or making it gone.
93      */
dismissAndCollapse()94     void dismissAndCollapse();
95 
96     /**
97      * Notifies that Keyguard is just about to go away.
98      */
keyguardGoingAway()99     void keyguardGoingAway();
100 
101     /**
102      * Sets the system state depending on whether the keyguard is going away or not.
103      */
setKeyguardGoingAwayState(boolean isKeyguardGoingAway)104     void setKeyguardGoingAwayState(boolean isKeyguardGoingAway);
105 
106     /**
107      * @return Whether window animation for unlock should be disabled.
108      */
shouldDisableWindowAnimationsForUnlock()109     boolean shouldDisableWindowAnimationsForUnlock();
110 
111     /**
112      * @return Whether the keyguard is going to notification shade.
113      */
isGoingToNotificationShade()114     boolean isGoingToNotificationShade();
115 
116     /**
117      * @return Whether subtle animation should be used for unlocking the device.
118      */
isUnlockWithWallpaper()119     boolean isUnlockWithWallpaper();
120 
121     /**
122      * @return Whether subtle animation should be used for unlocking the device.
123      */
shouldSubtleWindowAnimationsForUnlock()124     boolean shouldSubtleWindowAnimationsForUnlock();
125 
126     /**
127      * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the
128      * security view of the bouncer.
129      *
130      * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
131      *                       no action should be run
132      */
startPreHideAnimation(Runnable finishRunnable)133     void startPreHideAnimation(Runnable finishRunnable);
134 
135     /**
136      * Blocks the current touch gesture from affecting the expansion amount of the notification
137      * panel. This is used after a completed unlock gesture to ignore further dragging before an
138      * ACTION_UP.
139      */
blockPanelExpansionFromCurrentTouch()140     void blockPanelExpansionFromCurrentTouch();
141 
142     /**
143      * @return the ViewRootImpl of the View where the Keyguard is mounted.
144      */
getViewRootImpl()145     ViewRootImpl getViewRootImpl();
146 
147     /**
148      * Notifies that the user has authenticated by other means than using the bouncer, for example,
149      * fingerprint.
150      */
notifyKeyguardAuthenticated(boolean strongAuth)151     void notifyKeyguardAuthenticated(boolean strongAuth);
152 
153     /**
154      * Shows the primary bouncer.
155      */
showPrimaryBouncer(boolean scrimmed)156     void showPrimaryBouncer(boolean scrimmed);
157 
158     /**
159      * When the primary bouncer is fully visible or is showing but animation didn't finish yet.
160      */
primaryBouncerIsOrWillBeShowing()161     boolean primaryBouncerIsOrWillBeShowing();
162 
163     /**
164      * Returns {@code true} when the primary bouncer or alternate bouncer is currently showing
165      */
isBouncerShowing()166     boolean isBouncerShowing();
167 
168     /**
169      * Stop showing the alternate bouncer, if showing.
170      */
hideAlternateBouncer(boolean updateScrim)171     void hideAlternateBouncer(boolean updateScrim);
172 
173     // TODO: Deprecate registerStatusBar in KeyguardViewController interface. It is currently
174     //  only used for testing purposes in StatusBarKeyguardViewManager, and it prevents us from
175     //  achieving complete abstraction away from where the Keyguard View is mounted.
176 
177     /**
178      * Registers the CentralSurfaces to which this Keyguard View is mounted.
179      */
registerCentralSurfaces(CentralSurfaces centralSurfaces, NotificationPanelViewController notificationPanelViewController, @Nullable ShadeExpansionStateManager shadeExpansionStateManager, BiometricUnlockController biometricUnlockController, View notificationContainer, KeyguardBypassController bypassController)180     void registerCentralSurfaces(CentralSurfaces centralSurfaces,
181             NotificationPanelViewController notificationPanelViewController,
182             @Nullable ShadeExpansionStateManager shadeExpansionStateManager,
183             BiometricUnlockController biometricUnlockController,
184             View notificationContainer,
185             KeyguardBypassController bypassController);
186 }
187