Merge "Start keyguard docs" into sc-v2-dev am: af41f0dccc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15949908

Change-Id: I15fdbd56c51963e87956e13a0e1925dd6012f8ff
This commit is contained in:
TreeHugger Robot
2021-10-07 14:45:48 +00:00
committed by Automerger Merge Worker
11 changed files with 74 additions and 32 deletions

View File

@@ -0,0 +1,12 @@
# Keyguard (aka Lockscreen)
Keyguard is responsible for:
1. Handling authentication to allow the user to unlock the device, via biometrics or [KeyguardBouncer][1]
2. Displaying informational content such as the time, notifications, and smartspace
3. Always-on Display (AOD)
Keyguard is the first screen available when turning on the device, as long as the user has not specified a security method of NONE.
[1]: /frameworks/base/packages/SystemUI/docs/keyguard/bouncer.md

View File

@@ -0,0 +1,18 @@
# Bouncer
[KeyguardBouncer][1] is the component responsible for displaying the security method set by the user (password, PIN, pattern) as well as SIM-related security methods, allowing the user to unlock the device or SIM.
## Components
The bouncer contains a hierarchy of controllers/views to render the user's security method and to manage the authentication attempts.
1. [KeyguardBouncer][1] - Entrypoint for managing the bouncer visibility.
1. [KeyguardHostViewController][2] - Intercepts media keys. Can most likely be merged with the next item.
1. [KeyguardSecurityContainerController][3] - Manages unlock attempt responses, one-handed use
1. [KeyguardSecurityViewFlipperController][4] - Based upon the [KeyguardSecurityModel#SecurityMode][5], will instantiate the required view and controller. PIN, Pattern, etc.
[1]: /frameworks/base/packages/SystemUI/com/android/systemui/statusbar/phone/KeyguardBouncer
[2]: /frameworks/base/packages/SystemUI/com/android/keyguard/KeyguardHostViewController
[3]: /frameworks/base/packages/SystemUI/com/android/keyguard/KeyguardSecurityContainerController
[4]: /frameworks/base/packages/SystemUI/com/android/keyguard/KeyguardSecurityViewFlipperController
[5]: /frameworks/base/packages/SystemUI/com/android/keyguard/KeyguardSecurityModel

View File

@@ -97,7 +97,7 @@
android:singleLine="true" android:singleLine="true"
android:ellipsize="marquee" android:ellipsize="marquee"
android:focusable="true" /> android:focusable="true" />
<FrameLayout android:id="@+id/keyboard_bouncer_container" <FrameLayout android:id="@+id/keyguard_bouncer_container"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_weight="1" /> android:layout_weight="1" />

View File

@@ -18,7 +18,6 @@ package com.android.keyguard;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewRootImpl; import android.view.ViewRootImpl;
import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -186,14 +185,12 @@ public interface KeyguardViewController {
/** /**
* Registers the StatusBar to which this Keyguard View is mounted. * Registers the StatusBar to which this Keyguard View is mounted.
* @param statusBar * @param statusBar
* @param container
* @param notificationPanelViewController * @param notificationPanelViewController
* @param biometricUnlockController * @param biometricUnlockController
* @param notificationContainer * @param notificationContainer
* @param bypassController * @param bypassController
*/ */
void registerStatusBar(StatusBar statusBar, void registerStatusBar(StatusBar statusBar,
ViewGroup container,
NotificationPanelViewController notificationPanelViewController, NotificationPanelViewController notificationPanelViewController,
BiometricUnlockController biometricUnlockController, BiometricUnlockController biometricUnlockController,
View notificationContainer, View notificationContainer,

View File

@@ -77,7 +77,6 @@ import android.view.IRemoteAnimationRunner;
import android.view.RemoteAnimationTarget; import android.view.RemoteAnimationTarget;
import android.view.SyncRtSurfaceTransactionApplier; import android.view.SyncRtSurfaceTransactionApplier;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerPolicyConstants; import android.view.WindowManagerPolicyConstants;
import android.view.animation.Animation; import android.view.animation.Animation;
@@ -2623,7 +2622,6 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
* Registers the StatusBar to which the Keyguard View is mounted. * Registers the StatusBar to which the Keyguard View is mounted.
* *
* @param statusBar * @param statusBar
* @param container
* @param panelView * @param panelView
* @param biometricUnlockController * @param biometricUnlockController
* @param notificationContainer * @param notificationContainer
@@ -2631,10 +2629,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
* @return the View Controller for the Keyguard View this class is mediating. * @return the View Controller for the Keyguard View this class is mediating.
*/ */
public KeyguardViewController registerStatusBar(StatusBar statusBar, public KeyguardViewController registerStatusBar(StatusBar statusBar,
ViewGroup container, NotificationPanelViewController panelView, NotificationPanelViewController panelView,
BiometricUnlockController biometricUnlockController, BiometricUnlockController biometricUnlockController,
View notificationContainer, KeyguardBypassController bypassController) { View notificationContainer, KeyguardBypassController bypassController) {
mKeyguardViewControllerLazy.get().registerStatusBar(statusBar, container, panelView, mKeyguardViewControllerLazy.get().registerStatusBar(statusBar, panelView,
biometricUnlockController, notificationContainer, bypassController); biometricUnlockController, notificationContainer, bypassController);
return mKeyguardViewControllerLazy.get(); return mKeyguardViewControllerLazy.get();
} }

View File

@@ -126,6 +126,19 @@ public class KeyguardBouncer {
mExpansionCallbacks.add(expansionCallback); mExpansionCallbacks.add(expansionCallback);
} }
/**
* Enable/disable only the back button
*/
public void setBackButtonEnabled(boolean enabled) {
int vis = mContainer.getSystemUiVisibility();
if (enabled) {
vis &= ~View.STATUS_BAR_DISABLE_BACK;
} else {
vis |= View.STATUS_BAR_DISABLE_BACK;
}
mContainer.setSystemUiVisibility(vis);
}
public void show(boolean resetSecuritySelection) { public void show(boolean resetSecuritySelection) {
show(resetSecuritySelection, true /* scrimmed */); show(resetSecuritySelection, true /* scrimmed */);
} }

View File

@@ -171,6 +171,13 @@ public class NotificationShadeWindowViewController {
mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container); mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container);
} }
/**
* @return Location where to place the KeyguardBouncer
*/
public ViewGroup getBouncerContainer() {
return mView.findViewById(R.id.keyguard_bouncer_container);
}
/** Inflates the {@link R.layout#status_bar_expanded} layout and sets it up. */ /** Inflates the {@link R.layout#status_bar_expanded} layout and sets it up. */
public void setupExpandedStatusBar() { public void setupExpandedStatusBar() {
mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller); mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller);

View File

@@ -1553,6 +1553,9 @@ public class StatusBar extends SystemUI implements
time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why); time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why);
mWakeUpComingFromTouch = true; mWakeUpComingFromTouch = true;
where.getLocationInWindow(mTmpInt2); where.getLocationInWindow(mTmpInt2);
// NOTE, the incoming view can sometimes be the entire container... unsure if
// this location is valuable enough
mWakeUpTouchLocation = new PointF(mTmpInt2[0] + where.getWidth() / 2, mWakeUpTouchLocation = new PointF(mTmpInt2[0] + where.getWidth() / 2,
mTmpInt2[1] + where.getHeight() / 2); mTmpInt2[1] + where.getHeight() / 2);
mFalsingCollector.onScreenOnFromTouch(); mFalsingCollector.onScreenOnFromTouch();
@@ -1646,7 +1649,7 @@ public class StatusBar extends SystemUI implements
} }
}); });
mStatusBarKeyguardViewManager.registerStatusBar( mStatusBarKeyguardViewManager.registerStatusBar(
/* statusBar= */ this, getBouncerContainer(), /* statusBar= */ this,
mNotificationPanelViewController, mBiometricUnlockController, mNotificationPanelViewController, mBiometricUnlockController,
mStackScroller, mKeyguardBypassController); mStackScroller, mKeyguardBypassController);
mKeyguardIndicationController mKeyguardIndicationController
@@ -1681,8 +1684,8 @@ public class StatusBar extends SystemUI implements
return mNotificationPanelViewController; return mNotificationPanelViewController;
} }
protected ViewGroup getBouncerContainer() { public ViewGroup getBouncerContainer() {
return mNotificationShadeWindowView.findViewById(R.id.keyboard_bouncer_container); return mNotificationShadeWindowViewController.getBouncerContainer();
} }
public int getStatusBarHeight() { public int getStatusBarHeight() {

View File

@@ -120,7 +120,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override @Override
public void onFullyShown() { public void onFullyShown() {
updateStates(); updateStates();
mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mContainer, "BOUNCER_VISIBLE"); mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(),
mStatusBar.getBouncerContainer(), "BOUNCER_VISIBLE");
} }
@Override @Override
@@ -174,7 +175,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private NotificationPanelViewController mNotificationPanelViewController; private NotificationPanelViewController mNotificationPanelViewController;
private BiometricUnlockController mBiometricUnlockController; private BiometricUnlockController mBiometricUnlockController;
private ViewGroup mContainer;
private View mNotificationContainer; private View mNotificationContainer;
protected KeyguardBouncer mBouncer; protected KeyguardBouncer mBouncer;
@@ -270,14 +270,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override @Override
public void registerStatusBar(StatusBar statusBar, public void registerStatusBar(StatusBar statusBar,
ViewGroup container,
NotificationPanelViewController notificationPanelViewController, NotificationPanelViewController notificationPanelViewController,
BiometricUnlockController biometricUnlockController, BiometricUnlockController biometricUnlockController,
View notificationContainer, View notificationContainer,
KeyguardBypassController bypassController) { KeyguardBypassController bypassController) {
mStatusBar = statusBar; mStatusBar = statusBar;
mContainer = container;
mBiometricUnlockController = biometricUnlockController; mBiometricUnlockController = biometricUnlockController;
ViewGroup container = mStatusBar.getBouncerContainer();
mBouncer = mKeyguardBouncerFactory.create(container, mExpansionCallback); mBouncer = mKeyguardBouncerFactory.create(container, mExpansionCallback);
mNotificationPanelViewController = notificationPanelViewController; mNotificationPanelViewController = notificationPanelViewController;
notificationPanelViewController.addExpansionListener(this); notificationPanelViewController.addExpansionListener(this);
@@ -356,7 +356,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} else if (mPulsing && expansion == KeyguardBouncer.EXPANSION_VISIBLE) { } else if (mPulsing && expansion == KeyguardBouncer.EXPANSION_VISIBLE) {
// Panel expanded while pulsing but didn't translate the bouncer (because we are // Panel expanded while pulsing but didn't translate the bouncer (because we are
// unlocked.) Let's simply wake-up to dismiss the lock screen. // unlocked.) Let's simply wake-up to dismiss the lock screen.
mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mContainer, "BOUNCER_VISIBLE"); mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mStatusBar.getBouncerContainer(),
"BOUNCER_VISIBLE");
} }
} }
@@ -833,7 +834,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
public void onKeyguardFadedAway() { public void onKeyguardFadedAway() {
mContainer.postDelayed(() -> mNotificationShadeWindowController mNotificationContainer.postDelayed(() -> mNotificationShadeWindowController
.setKeyguardFadingAway(false), 100); .setKeyguardFadingAway(false), 100);
ViewGroupFadeHelper.reset(mNotificationPanelViewController.getView()); ViewGroupFadeHelper.reset(mNotificationPanelViewController.getView());
mStatusBar.finishKeyguardFadingAway(); mStatusBar.finishKeyguardFadingAway();
@@ -958,10 +959,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}; };
protected void updateStates() { protected void updateStates() {
if (mContainer == null ) {
return;
}
int vis = mContainer.getSystemUiVisibility();
boolean showing = mShowing; boolean showing = mShowing;
boolean occluded = mOccluded; boolean occluded = mOccluded;
boolean bouncerShowing = mBouncer.isShowing(); boolean bouncerShowing = mBouncer.isShowing();
@@ -973,9 +970,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
(mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive) (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive)
|| mFirstUpdate) { || mFirstUpdate) {
if (bouncerDismissible || !showing || remoteInputActive) { if (bouncerDismissible || !showing || remoteInputActive) {
mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); mBouncer.setBackButtonEnabled(true);
} else { } else {
mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); mBouncer.setBackButtonEnabled(false);
} }
} }
@@ -1042,11 +1039,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
if (delay == 0) { if (delay == 0) {
mMakeNavigationBarVisibleRunnable.run(); mMakeNavigationBarVisibleRunnable.run();
} else { } else {
mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable, mNotificationContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable,
delay); delay);
} }
} else { } else {
mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable); mNotificationContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
mStatusBar.getNotificationShadeWindowView().getWindowInsetsController() mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
.hide(navigationBars()); .hide(navigationBars());
} }
@@ -1371,4 +1368,4 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
void requestUdfps(boolean requestUdfps, int color); void requestUdfps(boolean requestUdfps, int color);
} }
} }

View File

@@ -16,15 +16,12 @@
package com.android.systemui.statusbar.phone; package com.android.systemui.statusbar.phone;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
@@ -119,7 +116,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
any(ViewGroup.class), any(ViewGroup.class),
any(KeyguardBouncer.BouncerExpansionCallback.class))) any(KeyguardBouncer.BouncerExpansionCallback.class)))
.thenReturn(mBouncer); .thenReturn(mBouncer);
when(mStatusBar.getBouncerContainer()).thenReturn(mContainer);
when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
mWakefulnessLifecycle = new WakefulnessLifecycle( mWakefulnessLifecycle = new WakefulnessLifecycle(
getContext(), getContext(),
@@ -143,7 +140,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mUnlockedScreenOffAnimationController, mUnlockedScreenOffAnimationController,
mKeyguardMessageAreaFactory, mKeyguardMessageAreaFactory,
mShadeController); mShadeController);
mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer, mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar,
mNotificationPanelView, mBiometrucUnlockController, mNotificationPanelView, mBiometrucUnlockController,
mNotificationContainer, mBypassController); mNotificationContainer, mBypassController);
mStatusBarKeyguardViewManager.show(null); mStatusBarKeyguardViewManager.show(null);

View File

@@ -459,7 +459,7 @@ public class StatusBarTest extends SysuiTestCase {
mock(DumpManager.class), mock(DumpManager.class),
mActivityLaunchAnimator, mActivityLaunchAnimator,
mDialogLaunchAnimator); mDialogLaunchAnimator);
when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class), when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class),
any(NotificationPanelViewController.class), any(BiometricUnlockController.class), any(NotificationPanelViewController.class), any(BiometricUnlockController.class),
any(ViewGroup.class), any(KeyguardBypassController.class))) any(ViewGroup.class), any(KeyguardBypassController.class)))
.thenReturn(mStatusBarKeyguardViewManager); .thenReturn(mStatusBarKeyguardViewManager);