Snap for 10622798 from c2b7914778 to udc-qpr1-release
Change-Id: I32ed5e39e356c8a2cfd7819174b582b2c4199888
This commit is contained in:
34
res/drawable/action_button_bg.xml
Normal file
34
res/drawable/action_button_bg.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2023 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
|
||||
-->
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item>
|
||||
<inset
|
||||
android:insetLeft="0dp"
|
||||
android:insetTop="8dp"
|
||||
android:insetRight="0dp"
|
||||
android:insetBottom="8dp">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<stroke android:width="1dp"
|
||||
android:color="?androidprv:attr/colorAccentPrimaryVariant"/>
|
||||
</shape>
|
||||
</inset>
|
||||
</item>
|
||||
</ripple>
|
||||
|
||||
32
res/layout/action_button.xml
Normal file
32
res/layout/action_button.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<!--
|
||||
~ Copyright (C) 2023 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
|
||||
-->
|
||||
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:gravity="center_vertical|start"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12sp"
|
||||
android:maxWidth="192dp"
|
||||
android:singleLine="true"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/action_button_bg"
|
||||
android:drawableTint="?android:attr/textColorPrimary"
|
||||
android:drawableTintMode="src_in"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
/>
|
||||
|
||||
@@ -410,6 +410,9 @@
|
||||
<!-- Margin for SD card setup completion Image -->
|
||||
<dimen name="setup_completion_margin_top">88dp</dimen>
|
||||
|
||||
<!-- QR code action button -->
|
||||
<dimen name="action_button_icon_size">18dp</dimen>
|
||||
|
||||
<!-- Biometrics Face enroll education dimensions-->
|
||||
<dimen name="face_enroll_icon_large_width">300dp</dimen>
|
||||
<dimen name="face_enroll_icon_large_height">300dp</dimen>
|
||||
|
||||
@@ -1852,7 +1852,7 @@
|
||||
<!-- Title for the fragment to show that the QR code is for sharing Wi-Fi hotspot network [CHAR LIMIT=50] -->
|
||||
<string name="wifi_dpp_share_hotspot">Share hotspot</string>
|
||||
<!-- Title for Wi-Fi DPP lockscreen title [CHAR LIMIT=50] -->
|
||||
<string name="wifi_dpp_lockscreen_title">Verify that it\u0027s you</string>
|
||||
<string name="wifi_dpp_lockscreen_title">Verify it\u0027s you</string>
|
||||
<!-- Hint for Wi-Fi password [CHAR LIMIT=50] -->
|
||||
<string name="wifi_dpp_wifi_password">Wi\u2011Fi password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
|
||||
<!-- Hint for Wi-Fi hotspot password [CHAR LIMIT=50] -->
|
||||
@@ -3423,16 +3423,16 @@
|
||||
|
||||
<!-- Message to be used to explain the users that they need to enter their pattern to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
<string name="lockpassword_confirm_your_pattern_generic">Use your device pattern to continue</string>
|
||||
<string name="lockpassword_confirm_your_pattern_generic">Draw your pattern to continue</string>
|
||||
<!-- Message to be used to explain the users that they need to enter their PIN to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
<string name="lockpassword_confirm_your_pin_generic">Enter your device PIN to continue</string>
|
||||
<string name="lockpassword_confirm_your_pin_generic">Enter your PIN to continue</string>
|
||||
<!-- Message to be used to explain the users that they need to enter their password to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
<string name="lockpassword_confirm_your_password_generic">Enter your device password to continue</string>
|
||||
<string name="lockpassword_confirm_your_password_generic">Enter your password to continue</string>
|
||||
<!-- Message to be used to explain the users that they need to enter their work pattern to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
<string name="lockpassword_confirm_your_pattern_generic_profile">Use your work pattern to continue</string>
|
||||
<string name="lockpassword_confirm_your_pattern_generic_profile">Draw your work pattern to continue</string>
|
||||
<!-- Message to be used to explain the users that they need to enter their work PIN to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
<string name="lockpassword_confirm_your_pin_generic_profile">Enter your work PIN to continue</string>
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PASSWORD;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
import static android.content.Intent.EXTRA_USER_ID;
|
||||
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
|
||||
@@ -782,6 +785,47 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return lpu.getCredentialTypeForUser(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the confirmation credential string of the given user id.
|
||||
*/
|
||||
@Nullable public static String getConfirmCredentialStringForUser(@NonNull Context context,
|
||||
int userId, @LockPatternUtils.CredentialType int credentialType) {
|
||||
final int effectiveUserId = UserManager.get(context).getCredentialOwnerProfile(userId);
|
||||
final boolean isEffectiveUserManagedProfile = UserManager.get(context)
|
||||
.isManagedProfile(effectiveUserId);
|
||||
final DevicePolicyManager devicePolicyManager = context
|
||||
.getSystemService(DevicePolicyManager.class);
|
||||
switch (credentialType) {
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PIN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return devicePolicyManager.getResources().getString(WORK_PROFILE_CONFIRM_PIN,
|
||||
() -> context.getString(
|
||||
R.string.lockpassword_confirm_your_pin_generic_profile));
|
||||
}
|
||||
|
||||
return context.getString(R.string.lockpassword_confirm_your_pin_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return devicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PATTERN,
|
||||
() -> context.getString(
|
||||
R.string.lockpassword_confirm_your_pattern_generic_profile));
|
||||
}
|
||||
|
||||
return context.getString(R.string.lockpassword_confirm_your_pattern_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return devicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PASSWORD,
|
||||
() -> context.getString(
|
||||
R.string.lockpassword_confirm_your_password_generic_profile));
|
||||
}
|
||||
|
||||
return context.getString(R.string.lockpassword_confirm_your_password_generic);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final StringBuilder sBuilder = new StringBuilder(50);
|
||||
private static final java.util.Formatter sFormatter = new java.util.Formatter(
|
||||
sBuilder, Locale.getDefault());
|
||||
|
||||
@@ -20,9 +20,6 @@ package com.android.settings.password;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PASSWORD_HEADER;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PATTERN_HEADER;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PIN_HEADER;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PASSWORD;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -211,7 +208,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||
}
|
||||
if (mDetails == null) {
|
||||
promptInfo.setDeviceCredentialSubtitle(
|
||||
getDetailsFromCredentialType(credentialType, isEffectiveUserManagedProfile));
|
||||
Utils.getConfirmCredentialStringForUser(this, mUserId, credentialType));
|
||||
}
|
||||
|
||||
boolean launchedBiometric = false;
|
||||
@@ -342,39 +339,6 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
|
||||
boolean isEffectiveUserManagedProfile) {
|
||||
switch (credentialType) {
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PIN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(WORK_PROFILE_CONFIRM_PIN,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_pin_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_pin_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PATTERN,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_pattern_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_pattern_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PASSWORD,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_password_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_password_generic);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
@@ -223,11 +223,9 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
|
||||
|
||||
private Button createActionButton(Drawable icon, CharSequence title, View.OnClickListener r) {
|
||||
final Button b = (Button) LayoutInflater.from(getContext()).inflate(
|
||||
com.android.internal.R.layout.chooser_action_button, null);
|
||||
R.layout.action_button, null);
|
||||
if (icon != null) {
|
||||
final int size = getResources()
|
||||
.getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.chooser_action_button_icon_size);
|
||||
final int size = getResources().getDimensionPixelSize(R.dimen.action_button_icon_size);
|
||||
icon.setBounds(0, 0, size, size);
|
||||
b.setCompoundDrawablesRelative(icon, null, null, null);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.UserHandle;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
@@ -391,11 +393,19 @@ public class WifiDppUtils {
|
||||
}
|
||||
};
|
||||
|
||||
final int userId = UserHandle.myUserId();
|
||||
|
||||
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
|
||||
.setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
|
||||
.setTitle(context.getText(R.string.wifi_dpp_lockscreen_title))
|
||||
.setUseDefaultSubtitle();
|
||||
|
||||
if (keyguardManager.isDeviceSecure()) {
|
||||
builder.setDeviceCredentialAllowed(true);
|
||||
builder.setTextForDeviceCredential(
|
||||
null /* title */,
|
||||
Utils.getConfirmCredentialStringForUser(
|
||||
context, userId, Utils.getCredentialType(context, userId)),
|
||||
null /* description */);
|
||||
}
|
||||
|
||||
final BiometricPrompt bp = builder.build();
|
||||
|
||||
@@ -16,9 +16,15 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PASSWORD;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -31,6 +37,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.DevicePolicyResourcesManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -60,6 +67,7 @@ import android.widget.TextView;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -94,6 +102,8 @@ public class UtilsTest {
|
||||
@Mock
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private DevicePolicyResourcesManager mDevicePolicyResourcesManager;
|
||||
@Mock
|
||||
private UserManager mMockUserManager;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@@ -348,4 +358,103 @@ public class UtilsTest {
|
||||
SecurityException.class,
|
||||
() -> Utils.checkUserOwnsFrpCredential(mContext, 123));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_Pin_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(false /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mContext.getString(R.string.lockpassword_confirm_your_pin_generic))
|
||||
.thenReturn("PIN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PIN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("PIN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_Pattern_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(false /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mContext.getString(R.string.lockpassword_confirm_your_pattern_generic))
|
||||
.thenReturn("PATTERN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PATTERN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("PATTERN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_Password_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(false /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mContext.getString(R.string.lockpassword_confirm_your_password_generic))
|
||||
.thenReturn("PASSWORD");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PASSWORD);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("PASSWORD");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPin_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PIN), any()))
|
||||
.thenReturn("WORK PIN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PIN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PIN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPattern_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PATTERN), any()))
|
||||
.thenReturn("WORK PATTERN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PATTERN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PATTERN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPassword_shouldReturnCorrectString() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PASSWORD), any()))
|
||||
.thenReturn("WORK PASSWORD");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PASSWORD);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PASSWORD");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_credentialTypeNone_shouldReturnNull() {
|
||||
setUpForConfirmCredentialString(false /* isEffectiveUserManagedProfile */);
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_NONE);
|
||||
|
||||
assertNull(confirmCredentialString);
|
||||
}
|
||||
|
||||
private void setUpForConfirmCredentialString(boolean isEffectiveUserManagedProfile) {
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mMockUserManager);
|
||||
when(mMockUserManager.getCredentialOwnerProfile(USER_ID)).thenReturn(USER_ID);
|
||||
when(mMockUserManager.isManagedProfile(USER_ID)).thenReturn(isEffectiveUserManagedProfile);
|
||||
when(mContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDevicePolicyManager);
|
||||
when(mDevicePolicyManager.getResources()).thenReturn(mDevicePolicyResourcesManager);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user