Bouncer User Switcher - Use flags
The user switcher will be enabled per device, mostly for larger form
factors. Add a flag based on a config value, that can be overlayed or
overriden with the flag app. Also correct some layout issues and
positioning for pin/pw/pattern for larger form factors.
Bug: 206825213
Test: atest KeyguardSecurityContainerTest
Change-Id: Ib8c059bd5739162d3ffe7a1c86fcd757e87701bf
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml
index 1e142ea..e64b586 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_host_view.xml
@@ -46,8 +46,6 @@
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="@dimen/keyguard_security_view_top_margin"
- android:paddingStart="@dimen/keyguard_security_view_lateral_margin"
- android:paddingEnd="@dimen/keyguard_security_view_lateral_margin"
android:layout_gravity="center"
android:gravity="center">
</com.android.keyguard.KeyguardSecurityViewFlipper>
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml
index e1550aa..e77e084 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml
@@ -25,6 +25,7 @@
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
androidprv:layout_maxHeight="@dimen/keyguard_security_height"
+ android:layout_gravity="center_horizontal|bottom"
android:gravity="bottom"
>
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pattern_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pattern_view.xml
index f613a19..231ead8 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_pattern_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_pattern_view.xml
@@ -28,6 +28,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
+ android:layout_gravity="center_horizontal|bottom"
android:clipChildren="false"
android:clipToPadding="false">
@@ -65,6 +66,7 @@
android:orientation="vertical"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
+ android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
android:gravity="center_horizontal" />
</com.android.keyguard.KeyguardPatternView>
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
index 94566c7..7ce6f0e 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
@@ -25,6 +25,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
+ android:layout_gravity="center_horizontal|bottom"
android:orientation="vertical"
>
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml
index 3e34e4b..b765f49 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_sim_pin_view.xml
@@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
- android:gravity="center_horizontal">
+ android:layout_gravity="center_horizontal|bottom">
<Space
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml
index d5510e9..917ea6b 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml
@@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
- android:gravity="center_horizontal">
+ android:layout_gravity="center_horizontal|bottom">
<Space
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res-keyguard/values-sw720dp/bools.xml b/packages/SystemUI/res-keyguard/values-sw720dp/bools.xml
deleted file mode 100644
index 54bb1fc..0000000
--- a/packages/SystemUI/res-keyguard/values-sw720dp/bools.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<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">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">true</bool>
-</resources>
diff --git a/packages/SystemUI/res-keyguard/values/config.xml b/packages/SystemUI/res-keyguard/values/config.xml
index 6194aa0..e824443 100644
--- a/packages/SystemUI/res-keyguard/values/config.xml
+++ b/packages/SystemUI/res-keyguard/values/config.xml
@@ -27,6 +27,6 @@
<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>
+ <bool name="config_enableBouncerUserSwitcher">false</bool>
</resources>
diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml
index c8bb8e9..cbf4f83 100644
--- a/packages/SystemUI/res-keyguard/values/dimens.xml
+++ b/packages/SystemUI/res-keyguard/values/dimens.xml
@@ -37,7 +37,6 @@
<!-- Margin around the various security views -->
<dimen name="keyguard_security_view_top_margin">8dp</dimen>
- <dimen name="keyguard_security_view_lateral_margin">20dp</dimen>
<dimen name="keyguard_eca_top_margin">18dp</dimen>
<dimen name="keyguard_eca_bottom_margin">12dp</dimen>
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index b5ea498..3fab724 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -616,9 +616,13 @@
final View view = getChildAt(i);
if (view.getVisibility() != GONE) {
int updatedWidthMeasureSpec = mViewMode.getChildWidthMeasureSpec(widthMeasureSpec);
+ final LayoutParams lp = (LayoutParams) view.getLayoutParams();
+
+ // When using EXACTLY spec, measure will use the layout width if > 0. Set before
+ // measuring the child
+ lp.width = MeasureSpec.getSize(updatedWidthMeasureSpec);
measureChildWithMargins(view, updatedWidthMeasureSpec, 0, heightMeasureSpec, 0);
- final LayoutParams lp = (LayoutParams) view.getLayoutParams();
maxWidth = Math.max(maxWidth,
view.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
maxHeight = Math.max(maxHeight,
@@ -969,7 +973,7 @@
public int getChildWidthMeasureSpec(int parentWidthMeasureSpec) {
return MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(parentWidthMeasureSpec) / 2,
- MeasureSpec.getMode(parentWidthMeasureSpec));
+ MeasureSpec.EXACTLY);
}
@Override
@@ -1026,7 +1030,7 @@
public int getChildWidthMeasureSpec(int parentWidthMeasureSpec) {
return MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(parentWidthMeasureSpec) / 2,
- MeasureSpec.getMode(parentWidthMeasureSpec));
+ MeasureSpec.EXACTLY);
}
private void updateSecurityViewGravity() {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
index 2fb2211..49a8022 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
@@ -51,6 +51,8 @@
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingCollector;
+import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -83,6 +85,7 @@
private final FalsingManager mFalsingManager;
private final UserSwitcherController mUserSwitcherController;
private final GlobalSettings mGlobalSettings;
+ private final FeatureFlags mFeatureFlags;
private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;
@@ -238,6 +241,7 @@
FalsingCollector falsingCollector,
FalsingManager falsingManager,
UserSwitcherController userSwitcherController,
+ FeatureFlags featureFlags,
GlobalSettings globalSettings) {
super(view);
mLockPatternUtils = lockPatternUtils;
@@ -255,6 +259,7 @@
mFalsingCollector = falsingCollector;
mFalsingManager = falsingManager;
mUserSwitcherController = userSwitcherController;
+ mFeatureFlags = featureFlags;
mGlobalSettings = globalSettings;
}
@@ -510,7 +515,7 @@
}
private boolean canDisplayUserSwitcher() {
- return getResources().getBoolean(R.bool.bouncer_display_user_switcher);
+ return mFeatureFlags.isEnabled(Flags.BOUNCER_USER_SWITCHER);
}
private void configureMode() {
@@ -615,6 +620,7 @@
private final FalsingCollector mFalsingCollector;
private final FalsingManager mFalsingManager;
private final GlobalSettings mGlobalSettings;
+ private final FeatureFlags mFeatureFlags;
private final UserSwitcherController mUserSwitcherController;
@Inject
@@ -632,6 +638,7 @@
FalsingCollector falsingCollector,
FalsingManager falsingManager,
UserSwitcherController userSwitcherController,
+ FeatureFlags featureFlags,
GlobalSettings globalSettings) {
mView = view;
mAdminSecondaryLockScreenControllerFactory = adminSecondaryLockScreenControllerFactory;
@@ -645,6 +652,7 @@
mConfigurationController = configurationController;
mFalsingCollector = falsingCollector;
mFalsingManager = falsingManager;
+ mFeatureFlags = featureFlags;
mGlobalSettings = globalSettings;
mUserSwitcherController = userSwitcherController;
}
@@ -656,8 +664,7 @@
mKeyguardUpdateMonitor, mKeyguardSecurityModel, mMetricsLogger, mUiEventLogger,
mKeyguardStateController, securityCallback, mSecurityViewFlipperController,
mConfigurationController, mFalsingCollector, mFalsingManager,
- mUserSwitcherController, mGlobalSettings);
+ mUserSwitcherController, mFeatureFlags, mGlobalSettings);
}
-
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.java b/packages/SystemUI/src/com/android/systemui/flags/Flags.java
index 726f865..6580b18 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.java
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.java
@@ -57,8 +57,10 @@
/***************************************/
// 200 - keyguard/lockscreen
- public static final BooleanFlag KEYGUARD_LAYOUT =
- new BooleanFlag(200, true);
+
+ // ** Flag retired **
+ // public static final BooleanFlag KEYGUARD_LAYOUT =
+ // new BooleanFlag(200, true);
public static final BooleanFlag LOCKSCREEN_ANIMATIONS =
new BooleanFlag(201, true);
@@ -69,6 +71,9 @@
public static final ResourceBooleanFlag CHARGING_RIPPLE =
new ResourceBooleanFlag(203, R.bool.flag_charging_ripple);
+ public static final ResourceBooleanFlag BOUNCER_USER_SWITCHER =
+ new ResourceBooleanFlag(204, R.bool.config_enableBouncerUserSwitcher);
+
/***************************************/
// 300 - power menu
public static final BooleanFlag POWER_MENU_LITE =
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
index c873804..599e547 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
@@ -48,6 +48,7 @@
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingCollector;
+import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -116,6 +117,8 @@
@Mock
private GlobalSettings mGlobalSettings;
@Mock
+ private FeatureFlags mFeatureFlags;
+ @Mock
private UserSwitcherController mUserSwitcherController;
private Configuration mConfiguration;
@@ -151,7 +154,7 @@
mKeyguardUpdateMonitor, mKeyguardSecurityModel, mMetricsLogger, mUiEventLogger,
mKeyguardStateController, mKeyguardSecurityViewFlipperController,
mConfigurationController, mFalsingCollector, mFalsingManager,
- mUserSwitcherController, mGlobalSettings).create(mSecurityCallback);
+ mUserSwitcherController, mFeatureFlags, mGlobalSettings).create(mSecurityCallback);
}
@Test