Bouncer updates

Part one of many, to add a multi-user switcher to the bouncer for
supported displays.

This CL:

1. Removes a config that was not-needed, in favor of the
can_use_one_handed_bouncer resource.
2. Adds a new boolean resource to determine when to use the new
bouncer layout with user switcher

Test: atest KeyguardHostViewControllerTest
KeyguardSecurityContainerControllerTest
Bug: 206825213

Change-Id: I18e5e8ef68a57c5c633664062bb2f4fd5d7b778f
This commit is contained in:
Matt Pietal
2021-11-23 08:08:52 -05:00
parent b8f3f9d239
commit 5f2121d729
12 changed files with 40 additions and 90 deletions

View File

@@ -51,10 +51,5 @@
<!-- If true, show multiuser switcher by default unless the user specifically disables it. -->
<bool name="config_showUserSwitcherByDefault">true</bool>
<!-- Enable dynamic keyguard positioning for large-width screens. This will cause the keyguard
to be aligned to one side of the screen when in landscape mode. -->
<bool name="config_enableDynamicKeyguardPositioning">true</bool>
</resources>

View File

@@ -5087,10 +5087,6 @@
<!-- Whether to select voice/data/sms preference without user confirmation -->
<bool name="config_voice_data_sms_auto_fallback">false</bool>
<!-- Whether to enable dynamic keyguard positioning for wide screen devices (e.g. only using
half of the screen, to be accessible using only one hand). -->
<bool name="config_enableDynamicKeyguardPositioning">false</bool>
<!-- Whether to allow the caching of the SIM PIN for verification after unattended reboot -->
<bool name="config_allow_pin_storage_for_unattended_reboot">true</bool>

View File

@@ -4326,8 +4326,6 @@
<java-symbol type="bool" name="config_voice_data_sms_auto_fallback" />
<java-symbol type="bool" name="config_enableDynamicKeyguardPositioning" />
<java-symbol type="attr" name="colorAccentPrimary" />
<java-symbol type="attr" name="colorAccentSecondary" />
<java-symbol type="attr" name="colorAccentTertiary" />

View File

@@ -2,6 +2,13 @@
[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.
## Supported States
1. Phone, portrait mode - The default and typically only way to view the bouncer. Screen cannot rotate.
1. Phone, landscape - Can only get into this state via lockscreen activities. Launch camera, rotate to landscape, tap lock icon is one example.
1. Foldables - Both landscape and portrait are supported. In landscape, the bouncer can appear on either of the hinge and can be dragged to the other side. Also refered to as "OneHandedMode in [KeyguardSecurityContainerController][3]
1. Tablets - The bouncer is supplemented with user icons and a multi-user switcher, when available.
## Components
The bouncer contains a hierarchy of controllers/views to render the user's security method and to manage the authentication attempts.
@@ -11,6 +18,8 @@ The bouncer contains a hierarchy of controllers/views to render the user's secur
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.
Fun fact: Naming comes from the concept of a bouncer at a bar or nightclub, who prevent troublemakers from entering or eject them from the premises.
[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

View File

@@ -16,5 +16,7 @@
-->
<resources>
<!-- Allows PIN/Pattern to be drawn on one side of a display, and for the user to
switch sides -->
<bool name="can_use_one_handed_bouncer">true</bool>
</resources>

View File

@@ -16,5 +16,11 @@
-->
<resources>
<!-- Allows PIN/Pattern to be drawn on one side of a display, and for the user to
switch sides -->
<bool name="can_use_one_handed_bouncer">true</bool>
<!-- Will display the bouncer on one side of the display, and the current user icon and
user switcher on the other side -->
<bool name="bouncer_display_user_switcher">true</bool>
</resources>

View File

@@ -22,5 +22,11 @@
<!-- Allow the menu hard key to be disabled in LockScreen on some devices [DO NOT TRANSLATE] -->
<bool name="config_disableMenuKeyInLockScreen">false</bool>
<!-- Allows PIN/Pattern to be drawn on one side of a display, and for the user to
switch sides -->
<bool name="can_use_one_handed_bouncer">false</bool>
<!-- Will display the bouncer on one side of the display, and the current user icon and
user switcher on the other side -->
<bool name="bouncer_display_user_switcher">false</bool>
</resources>

View File

@@ -479,9 +479,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
Resources resources = mView.getResources();
if (resources.getBoolean(R.bool.can_use_one_handed_bouncer)
&& resources.getBoolean(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning)) {
if (resources.getBoolean(R.bool.can_use_one_handed_bouncer)) {
gravity = resources.getInteger(
R.integer.keyguard_host_view_one_handed_gravity);
} else {

View File

@@ -496,19 +496,22 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
}
private boolean canUseOneHandedBouncer() {
// Is it enabled?
if (!getResources().getBoolean(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning)) {
return false;
}
if (!KeyguardSecurityModel.isSecurityViewOneHanded(mCurrentSecurityMode)) {
if (!isSecurityViewOneHanded(mCurrentSecurityMode)) {
return false;
}
return getResources().getBoolean(R.bool.can_use_one_handed_bouncer);
}
/**
* Returns whether the given security view should be used in a "one handed" way. This can be
* used to change how the security view is drawn (e.g. take up less of the screen, and align to
* one side).
*/
private boolean isSecurityViewOneHanded(SecurityMode securityMode) {
return securityMode == SecurityMode.Pattern || securityMode == SecurityMode.PIN;
}
private void configureOneHandedMode() {
boolean oneHandedMode = canUseOneHandedBouncer();

View File

@@ -94,13 +94,4 @@ public class KeyguardSecurityModel {
throw new IllegalStateException("Unknown security quality:" + security);
}
}
/**
* Returns whether the given security view should be used in a "one handed" way. This can be
* used to change how the security view is drawn (e.g. take up less of the screen, and align to
* one side).
*/
public static boolean isSecurityViewOneHanded(SecurityMode securityMode) {
return securityMode == SecurityMode.Pattern || securityMode == SecurityMode.PIN;
}
}

View File

@@ -80,8 +80,6 @@ public class KeyguardHostViewControllerTest extends SysuiTestCase {
// Explicitly disable one handed keyguard.
mTestableResources.addOverride(
R.bool.can_use_one_handed_bouncer, false);
mTestableResources.addOverride(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning, false);
when(mKeyguardSecurityContainerControllerFactory.create(any(
KeyguardSecurityContainer.SecurityCallback.class)))
@@ -149,8 +147,6 @@ public class KeyguardHostViewControllerTest extends SysuiTestCase {
// Start disabled.
mTestableResources.addOverride(
R.bool.can_use_one_handed_bouncer, false);
mTestableResources.addOverride(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning, false);
mKeyguardHostViewController.init();
assertEquals(
@@ -160,8 +156,6 @@ public class KeyguardHostViewControllerTest extends SysuiTestCase {
// And enable
mTestableResources.addOverride(
R.bool.can_use_one_handed_bouncer, true);
mTestableResources.addOverride(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning, true);
mKeyguardHostViewController.updateResources();
assertEquals(

View File

@@ -251,11 +251,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
}
@Test
public void showSecurityScreen_oneHandedMode_bothFlagsDisabled_noOneHandedMode() {
setUpKeyguardFlags(
/* deviceConfigCanUseOneHandedKeyguard= */false,
/* sysuiResourceCanUseOneHandedKeyguard= */false);
public void showSecurityScreen_oneHandedMode_flagDisabled_noOneHandedMode() {
when(mResources.getBoolean(R.bool.can_use_one_handed_bouncer)).thenReturn(false);
when(mKeyguardSecurityViewFlipperController.getSecurityView(
eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
.thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
@@ -265,39 +262,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
}
@Test
public void showSecurityScreen_oneHandedMode_deviceFlagDisabled_noOneHandedMode() {
setUpKeyguardFlags(
/* deviceConfigCanUseOneHandedKeyguard= */false,
/* sysuiResourceCanUseOneHandedKeyguard= */true);
when(mKeyguardSecurityViewFlipperController.getSecurityView(
eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
.thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Pattern);
verify(mView).setOneHandedMode(false);
}
@Test
public void showSecurityScreen_oneHandedMode_sysUiFlagDisabled_noOneHandedMode() {
setUpKeyguardFlags(
/* deviceConfigCanUseOneHandedKeyguard= */true,
/* sysuiResourceCanUseOneHandedKeyguard= */false);
when(mKeyguardSecurityViewFlipperController.getSecurityView(
eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
.thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Pattern);
verify(mView).setOneHandedMode(false);
}
@Test
public void showSecurityScreen_oneHandedMode_bothFlagsEnabled_oneHandedMode() {
setUpKeyguardFlags(
/* deviceConfigCanUseOneHandedKeyguard= */true,
/* sysuiResourceCanUseOneHandedKeyguard= */true);
public void showSecurityScreen_oneHandedMode_flagEnabled_oneHandedMode() {
when(mResources.getBoolean(R.bool.can_use_one_handed_bouncer)).thenReturn(true);
when(mKeyguardSecurityViewFlipperController.getSecurityView(
eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
.thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
@@ -307,11 +273,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
}
@Test
public void showSecurityScreen_twoHandedMode_bothFlagsEnabled_noOneHandedMode() {
setUpKeyguardFlags(
/* deviceConfigCanUseOneHandedKeyguard= */true,
/* sysuiResourceCanUseOneHandedKeyguard= */true);
public void showSecurityScreen_twoHandedMode_flagEnabled_noOneHandedMode() {
when(mResources.getBoolean(R.bool.can_use_one_handed_bouncer)).thenReturn(true);
when(mKeyguardSecurityViewFlipperController.getSecurityView(
eq(SecurityMode.Password), any(KeyguardSecurityCallback.class)))
.thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
@@ -319,15 +282,4 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Password);
verify(mView).setOneHandedMode(false);
}
private void setUpKeyguardFlags(
boolean deviceConfigCanUseOneHandedKeyguard,
boolean sysuiResourceCanUseOneHandedKeyguard) {
when(mResources.getBoolean(
com.android.internal.R.bool.config_enableDynamicKeyguardPositioning))
.thenReturn(deviceConfigCanUseOneHandedKeyguard);
when(mResources.getBoolean(
R.bool.can_use_one_handed_bouncer))
.thenReturn(sysuiResourceCanUseOneHandedKeyguard);
}
}