Snap for 11361184 from 317173b7cdd3966362bf3c3e42004ab23ba9e4c1 to 24Q2-release
Change-Id: I3c679f5edf3fd926df7d5b72aa61166e21bee4e6
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d51dfdc..98cb31a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2283,6 +2283,21 @@
android:value="true" />
</activity>
+ <activity
+ android:name="Settings$AccessibilityEditShortcutsActivity"
+ android:label="@string/accessibility_settings"
+ android:exported="true"
+ android:permission="android.permission.MANAGE_ACCESSIBILITY">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment" />
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_accessibility"/>
+ </activity>
+
<activity android:name=".accessibility.AccessibilitySettingsForSetupWizardActivity"
android:icon="@drawable/ic_accessibility_suggestion"
android:label="@string/vision_settings_title"
diff --git a/aconfig/accessibility/accessibility_flags.aconfig b/aconfig/accessibility/accessibility_flags.aconfig
index 1c03a27..ad770fb 100644
--- a/aconfig/accessibility/accessibility_flags.aconfig
+++ b/aconfig/accessibility/accessibility_flags.aconfig
@@ -9,6 +9,19 @@
bug: "300302098"
}
+flag {
+ name: "enable_hearing_aid_preset_control"
+ namespace: "accessibility"
+ description: "Allows users to control hearing aid preset in the Bluetooth device details page."
+ bug: "300015207"
+}
+
+flag {
+ name: "enable_hearing_aid_volume_offset_control"
+ namespace: "accessibility"
+ description: "Allows users to control hearing aid volume offset in the Bluetooth device details page."
+ bug: "301198830"
+}
flag {
name: "remove_qs_tooltip_in_suw"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 01979b2..491d58f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1743,7 +1743,7 @@
<string name="bluetooth_pairing_request">Pair with <xliff:g id="device_name">%1$s</xliff:g>?</string>
<!-- Message when a bluetooth device from a coordinated set is bonding late. [CHAR LIMIT=NONE] -->
- <string name="bluetooth_pairing_group_late_bonding">Add new member to the existing coordinated set</string>
+ <string name="bluetooth_pairing_group_late_bonding">Confirm to add the second piece of your audio device</string>
<!-- Message when bluetooth is informing the user of the pairing key. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_key_msg">Bluetooth pairing code</string>
@@ -1766,7 +1766,7 @@
<string name="bluetooth_enter_passkey_other_device">You may also need to type this passkey on the other device.</string>
<!-- Pairing dialog text to remind user the pairing including all of the devices in a coordinated set. [CHAR LIMIT=NONE] -->
- <string name="bluetooth_paring_group_msg">Confirm to pair with the coordinated set</string>
+ <string name="bluetooth_paring_group_msg">Confirm to pair with the audio device</string>
<!-- Checkbox message in pairing dialogs. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_shares_phonebook">Allow access to your contacts and call history</string>
@@ -4311,6 +4311,10 @@
<string name="bounce_keys">Bounce keys</string>
<!-- Summary text for the 'Bounce keys' preference sub-screen. [CHAR LIMIT=100] -->
<string name="bounce_keys_summary">Enable Bounce keys for physical keyboard accessibility</string>
+ <!-- Title for the 'Slow keys' preference switch. [CHAR LIMIT=35] -->
+ <string name="slow_keys">Slow keys</string>
+ <!-- Summary text for the 'Slow keys' preference sub-screen. [CHAR LIMIT=100] -->
+ <string name="slow_keys_summary">Enable Slow keys for physical keyboard accessibility</string>
<!-- Title for the 'Sticky keys' preference switch. [CHAR LIMIT=35] -->
<string name="sticky_keys">Sticky keys</string>
<!-- Summary text for the 'Sticky keys' preference sub-screen. [CHAR LIMIT=100] -->
diff --git a/res/xml/physical_keyboard_settings.xml b/res/xml/physical_keyboard_settings.xml
index dc424d1..b95f23e 100644
--- a/res/xml/physical_keyboard_settings.xml
+++ b/res/xml/physical_keyboard_settings.xml
@@ -44,16 +44,22 @@
android:title="@string/keyboard_a11y_category">
<SwitchPreference
- android:key="accessibility_bounce_keys"
- android:title="@string/bounce_keys"
- android:summary="@string/bounce_keys_summary"
- android:defaultValue="false" />
-
- <SwitchPreference
android:key="accessibility_sticky_keys"
android:title="@string/sticky_keys"
android:summary="@string/sticky_keys_summary"
android:defaultValue="false" />
+ <SwitchPreference
+ android:key="accessibility_slow_keys"
+ android:title="@string/slow_keys"
+ android:summary="@string/slow_keys_summary"
+ android:defaultValue="false" />
+
+ <SwitchPreference
+ android:key="accessibility_bounce_keys"
+ android:title="@string/bounce_keys"
+ android:summary="@string/bounce_keys_summary"
+ android:defaultValue="false" />
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 2275c6d..63ce331 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -102,6 +102,7 @@
public static class DevelopmentSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityDetailsSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccessibilityEditShortcutsActivity extends SettingsActivity { /* empty */ }
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accessibility/FontSizeData.java b/src/com/android/settings/accessibility/FontSizeData.java
index 1226d25..096710d 100644
--- a/src/com/android/settings/accessibility/FontSizeData.java
+++ b/src/com/android/settings/accessibility/FontSizeData.java
@@ -25,6 +25,7 @@
import android.provider.Settings;
import com.android.settingslib.R;
+import com.android.window.flags.Flags;
import java.util.Arrays;
import java.util.List;
@@ -38,12 +39,11 @@
FontSizeData(Context context) {
super(context);
-
final Resources resources = getContext().getResources();
final ContentResolver resolver = getContext().getContentResolver();
final List<String> strEntryValues =
Arrays.asList(resources.getStringArray(R.array.entryvalues_font_size));
- setDefaultValue(FONT_SCALE_DEF_VALUE);
+ setDefaultValue(getFontScaleDefValue(resolver));
final float currentScale =
Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, getDefaultValue());
setInitialIndex(fontSizeValueToIndex(currentScale, strEntryValues.toArray(new String[0])));
@@ -78,4 +78,10 @@
}
return indices.length - 1;
}
+
+ private float getFontScaleDefValue(ContentResolver resolver) {
+ return Flags.configurableFontScaleDefault() ? Settings.System.getFloat(resolver,
+ Settings.System.DEFAULT_DEVICE_FONT_SCALE, FONT_SCALE_DEF_VALUE)
+ : FONT_SCALE_DEF_VALUE;
+ }
}
diff --git a/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java b/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
index 6666554..7a1dd4b 100644
--- a/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
@@ -270,6 +270,7 @@
}
mShortcutTargets = Set.of(targets);
+ // TODO(318748373): use 'targets' to populate title when no title is given
}
@Override
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 3950031..8fee052 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -34,6 +34,7 @@
import com.android.settings.accessibility.ToggleColorInversionPreferenceFragment;
import com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment;
import com.android.settings.accessibility.ToggleReduceBrightColorsPreferenceFragment;
+import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.accounts.AccountDashboardFragment;
import com.android.settings.accounts.AccountSyncSettings;
import com.android.settings.accounts.ChooseAccountFragment;
@@ -250,6 +251,7 @@
AccessibilityDetailsSettingsFragment.class.getName(),
AccessibilitySettings.class.getName(),
AccessibilitySettingsForSetupWizard.class.getName(),
+ EditShortcutsPreferenceFragment.class.getName(),
TextReadingPreferenceFragment.class.getName(),
TextReadingPreferenceFragmentForSetupWizard.class.getName(),
CaptioningPropertiesFragment.class.getName(),
diff --git a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
index b39d874..69e6c69 100644
--- a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
+++ b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
@@ -52,6 +52,9 @@
@Override
public boolean isAvailable() {
+ // If the build is insecure (any -user build, 'ro.adb.secure=0'), adbd does not
+ // requests/store authorizations. There is no need for a "revoke authorizations"
+ // button.
return AdbProperties.secure().orElse(false);
}
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index 7de505e..b06edb2 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -70,6 +70,7 @@
private static final String KEYBOARD_A11Y_CATEGORY = "keyboard_a11y_category";
private static final String SHOW_VIRTUAL_KEYBOARD_SWITCH = "show_virtual_keyboard_switch";
private static final String ACCESSIBILITY_BOUNCE_KEYS = "accessibility_bounce_keys";
+ private static final String ACCESSIBILITY_SLOW_KEYS = "accessibility_slow_keys";
private static final String ACCESSIBILITY_STICKY_KEYS = "accessibility_sticky_keys";
private static final String KEYBOARD_SHORTCUTS_HELPER = "keyboard_shortcuts_helper";
private static final String MODIFIER_KEYS_SETTINGS = "modifier_keys_settings";
@@ -78,6 +79,8 @@
Secure.SHOW_IME_WITH_HARD_KEYBOARD);
private static final Uri sAccessibilityBounceKeysUri = Secure.getUriFor(
Secure.ACCESSIBILITY_BOUNCE_KEYS);
+ private static final Uri sAccessibilitySlowKeysUri = Secure.getUriFor(
+ Secure.ACCESSIBILITY_SLOW_KEYS);
private static final Uri sAccessibilityStickyKeysUri = Secure.getUriFor(
Secure.ACCESSIBILITY_STICKY_KEYS);
@@ -97,6 +100,8 @@
@Nullable
private TwoStatePreference mAccessibilityBounceKeys = null;
@Nullable
+ private TwoStatePreference mAccessibilitySlowKeys = null;
+ @Nullable
private TwoStatePreference mAccessibilityStickyKeys = null;
@@ -127,6 +132,8 @@
mKeyboardA11yCategory = Objects.requireNonNull(findPreference(KEYBOARD_A11Y_CATEGORY));
mAccessibilityBounceKeys = Objects.requireNonNull(
mKeyboardA11yCategory.findPreference(ACCESSIBILITY_BOUNCE_KEYS));
+ mAccessibilitySlowKeys = Objects.requireNonNull(
+ mKeyboardA11yCategory.findPreference(ACCESSIBILITY_SLOW_KEYS));
mAccessibilityStickyKeys = Objects.requireNonNull(
mKeyboardA11yCategory.findPreference(ACCESSIBILITY_STICKY_KEYS));
@@ -147,6 +154,9 @@
if (!InputSettings.isAccessibilityBounceKeysFeatureEnabled()) {
mKeyboardA11yCategory.removePreference(mAccessibilityBounceKeys);
}
+ if (!InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()) {
+ mKeyboardA11yCategory.removePreference(mAccessibilitySlowKeys);
+ }
if (!InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
mKeyboardA11yCategory.removePreference(mAccessibilityStickyKeys);
}
@@ -196,6 +206,8 @@
mShowVirtualKeyboardSwitchPreferenceChangeListener);
Objects.requireNonNull(mAccessibilityBounceKeys).setOnPreferenceChangeListener(
mAccessibilityBounceKeysSwitchPreferenceChangeListener);
+ Objects.requireNonNull(mAccessibilitySlowKeys).setOnPreferenceChangeListener(
+ mAccessibilitySlowKeysSwitchPreferenceChangeListener);
Objects.requireNonNull(mAccessibilityStickyKeys).setOnPreferenceChangeListener(
mAccessibilityStickyKeysSwitchPreferenceChangeListener);
registerSettingsObserver();
@@ -208,6 +220,7 @@
mIm.unregisterInputDeviceListener(this);
Objects.requireNonNull(mShowVirtualKeyboardSwitch).setOnPreferenceChangeListener(null);
Objects.requireNonNull(mAccessibilityBounceKeys).setOnPreferenceChangeListener(null);
+ Objects.requireNonNull(mAccessibilitySlowKeys).setOnPreferenceChangeListener(null);
Objects.requireNonNull(mAccessibilityStickyKeys).setOnPreferenceChangeListener(null);
unregisterSettingsObserver();
}
@@ -315,10 +328,12 @@
updateShowVirtualKeyboardSwitch();
if (InputSettings.isAccessibilityBounceKeysFeatureEnabled()
- || InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
+ || InputSettings.isAccessibilityStickyKeysFeatureEnabled()
+ || InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()) {
Objects.requireNonNull(mKeyboardA11yCategory).setOrder(2);
preferenceScreen.addPreference(mKeyboardA11yCategory);
updateAccessibilityBounceKeysSwitch();
+ updateAccessibilitySlowKeysSwitch();
updateAccessibilityStickyKeysSwitch();
}
}
@@ -356,6 +371,13 @@
mContentObserver,
UserHandle.myUserId());
}
+ if (InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()) {
+ contentResolver.registerContentObserver(
+ sAccessibilitySlowKeysUri,
+ false,
+ mContentObserver,
+ UserHandle.myUserId());
+ }
if (InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
contentResolver.registerContentObserver(
sAccessibilityStickyKeysUri,
@@ -365,6 +387,7 @@
}
updateShowVirtualKeyboardSwitch();
updateAccessibilityBounceKeysSwitch();
+ updateAccessibilitySlowKeysSwitch();
updateAccessibilityStickyKeysSwitch();
}
@@ -385,6 +408,14 @@
InputSettings.isAccessibilityBounceKeysEnabled(getContext()));
}
+ private void updateAccessibilitySlowKeysSwitch() {
+ if (!InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()) {
+ return;
+ }
+ Objects.requireNonNull(mAccessibilitySlowKeys).setChecked(
+ InputSettings.isAccessibilitySlowKeysEnabled(getContext()));
+ }
+
private void updateAccessibilityStickyKeysSwitch() {
if (!InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
return;
@@ -414,6 +445,13 @@
};
private final OnPreferenceChangeListener
+ mAccessibilitySlowKeysSwitchPreferenceChangeListener = (preference, newValue) -> {
+ InputSettings.setAccessibilitySlowKeysThreshold(getContext(),
+ ((Boolean) newValue) ? 500 : 0);
+ return true;
+ };
+
+ private final OnPreferenceChangeListener
mAccessibilityStickyKeysSwitchPreferenceChangeListener = (preference, newValue) -> {
InputSettings.setAccessibilityStickyKeysEnabled(getContext(), (Boolean) newValue);
return true;
@@ -426,6 +464,8 @@
updateShowVirtualKeyboardSwitch();
} else if (sAccessibilityBounceKeysUri.equals(uri)) {
updateAccessibilityBounceKeysSwitch();
+ } else if (sAccessibilitySlowKeysUri.equals(uri)) {
+ updateAccessibilitySlowKeysSwitch();
} else if (sAccessibilityStickyKeysUri.equals(uri)) {
updateAccessibilityStickyKeysSwitch();
}
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index 99d6492..8690847 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.res.Resources;
import android.icu.text.MessageFormat;
import android.os.Bundle;
import android.os.UserHandle;
@@ -30,6 +31,7 @@
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
@@ -45,7 +47,11 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.widget.FooterPreference;
+
+import java.util.List;
+
/**
* Screen pinning settings.
*/
@@ -174,9 +180,8 @@
}
}
- private int getCurrentSecurityTitle() {
- int quality = mLockPatternUtils.getKeyguardStoredPasswordQuality(
- UserHandle.myUserId());
+ private static int getCurrentSecurityTitle(LockPatternUtils lockPatternUtils) {
+ int quality = lockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId());
switch (quality) {
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
@@ -187,7 +192,7 @@
case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
return R.string.screen_pinning_unlock_password;
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
- if (mLockPatternUtils.isLockPatternEnabled(UserHandle.myUserId())) {
+ if (lockPatternUtils.isLockPatternEnabled(UserHandle.myUserId())) {
return R.string.screen_pinning_unlock_pattern;
}
}
@@ -232,7 +237,7 @@
}
});
mUseScreenLock.setChecked(isScreenLockUsed());
- mUseScreenLock.setTitle(getCurrentSecurityTitle());
+ mUseScreenLock.setTitle(getCurrentSecurityTitle(mLockPatternUtils));
} else {
mFooterPreference.setSummary(getAppPinningContent());
mUseScreenLock.setEnabled(false);
@@ -252,8 +257,30 @@
}
/**
- * For search
+ * For search.
+ *
+ * This page only provides an index for the toggle preference of using screen lock for
+ * unpinning. The preference name will change with various lock configurations. Indexing data
+ * from XML isn't suitable since it uses a static title by default. So, we skip XML indexing
+ * by omitting the XML argument in the constructor and use a dynamic index method instead.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.screen_pinning_settings);
+ new BaseSearchIndexProvider() {
+
+ @NonNull
+ @Override
+ public List<SearchIndexableRaw> getDynamicRawDataToIndex(@NonNull Context context,
+ boolean enabled) {
+ List<SearchIndexableRaw> dynamicRaws =
+ super.getDynamicRawDataToIndex(context, enabled);
+ final SearchIndexableRaw raw = new SearchIndexableRaw(context);
+ final Resources res = context.getResources();
+ final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
+ raw.key = KEY_USE_SCREEN_LOCK;
+ raw.title = res.getString(getCurrentSecurityTitle(lockPatternUtils));
+ raw.screenTitle = res.getString(R.string.screen_pinning_title);
+ dynamicRaws.add(raw);
+ return dynamicRaws;
+ }
+ };
}
diff --git a/tests/robotests/src/com/android/settings/security/ScreenPinningSettingsTest.java b/tests/robotests/src/com/android/settings/security/ScreenPinningSettingsTest.java
new file mode 100644
index 0000000..045ef65
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/ScreenPinningSettingsTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+package com.android.settings.security;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.UserHandle;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
+import com.android.settingslib.search.SearchIndexableRaw;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowLockPatternUtils.class)
+public class ScreenPinningSettingsTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ }
+
+ @After
+ public void tearDown() {
+ ShadowLockPatternUtils.reset();
+ }
+
+ @Test
+ public void getDynamicRawDataToIndex_numericPassword_shouldIndexUnlockPinTitle() {
+ ShadowLockPatternUtils.setKeyguardStoredPasswordQuality(
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+
+ final List<SearchIndexableRaw> indexRaws =
+ ScreenPinningSettings.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(
+ mContext, /* enabled= */ true);
+
+ assertThat(indexRaws.size()).isEqualTo(1);
+ assertThat(indexRaws.get(0).title).isEqualTo(
+ mContext.getString(R.string.screen_pinning_unlock_pin));
+ }
+
+ @Test
+ public void getDynamicRawDataToIndex_alphabeticPassword_shouldIndexUnlockPasswordTitle() {
+ ShadowLockPatternUtils.setKeyguardStoredPasswordQuality(
+ DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC);
+
+ final List<SearchIndexableRaw> indexRaws =
+ ScreenPinningSettings.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(
+ mContext, /* enabled= */ true);
+
+ assertThat(indexRaws.size()).isEqualTo(1);
+ assertThat(indexRaws.get(0).title).isEqualTo(
+ mContext.getString(R.string.screen_pinning_unlock_password));
+ }
+
+ @Test
+ public void getDynamicRawDataToIndex_patternPassword_shouldIndexUnlockPatternTitle() {
+ ShadowLockPatternUtils.setKeyguardStoredPasswordQuality(
+ DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+ ShadowLockPatternUtils.setIsLockPatternEnabled(
+ UserHandle.myUserId(), /* isLockPatternEnabled= */ true);
+
+ final List<SearchIndexableRaw> indexRaws =
+ ScreenPinningSettings.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(
+ mContext, /* enabled= */ true);
+
+ assertThat(indexRaws.size()).isEqualTo(1);
+ assertThat(indexRaws.get(0).title).isEqualTo(
+ mContext.getString(R.string.screen_pinning_unlock_pattern));
+ }
+
+ @Test
+ public void getDynamicRawDataToIndex_nonePassword_shouldIndexUnlockNoneTitle() {
+ ShadowLockPatternUtils.setKeyguardStoredPasswordQuality(
+ DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
+
+ final List<SearchIndexableRaw> indexRaws =
+ ScreenPinningSettings.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(
+ mContext, /* enabled= */ true);
+
+ assertThat(indexRaws.size()).isEqualTo(1);
+ assertThat(indexRaws.get(0).title).isEqualTo(
+ mContext.getString(R.string.screen_pinning_unlock_none));
+ }
+}
diff --git a/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
index 0474f52..efea6fd 100644
--- a/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
+++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
@@ -50,6 +50,7 @@
private static Map<Integer, Boolean> sUserToVisiblePatternEnabledMap = new HashMap<>();
private static Map<Integer, Boolean> sUserToBiometricAllowedMap = new HashMap<>();
private static Map<Integer, Boolean> sUserToLockPatternEnabledMap = new HashMap<>();
+ private static Map<Integer, Integer> sKeyguardStoredPasswordQualityMap = new HashMap<>();
private static boolean sIsUserOwnsFrpCredential;
@@ -66,6 +67,7 @@
sUserToLockPatternEnabledMap.clear();
sDeviceEncryptionEnabled = false;
sIsUserOwnsFrpCredential = false;
+ sKeyguardStoredPasswordQualityMap.clear();
}
@Implementation
@@ -97,7 +99,7 @@
@Implementation
protected int getKeyguardStoredPasswordQuality(int userHandle) {
- return 1;
+ return sKeyguardStoredPasswordQualityMap.getOrDefault(userHandle, /* defaultValue= */ 1);
}
@Implementation
@@ -171,7 +173,7 @@
@Implementation
public boolean isLockPatternEnabled(int userId) {
- return sUserToBiometricAllowedMap.getOrDefault(userId, false);
+ return sUserToLockPatternEnabledMap.getOrDefault(userId, false);
}
public static void setIsLockPatternEnabled(int userId, boolean isLockPatternEnabled) {
@@ -238,4 +240,8 @@
public boolean isSeparateProfileChallengeEnabled(int userHandle) {
return false;
}
+
+ public static void setKeyguardStoredPasswordQuality(int quality) {
+ sKeyguardStoredPasswordQualityMap.put(UserHandle.myUserId(), quality);
+ }
}