Merge "[Catalyst] Update RangeValue usages to IntRangeValuePreference" into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fd6ac4b..2c62ebd 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5307,6 +5307,23 @@
android:value="true" />
</activity>
+ <activity
+ android:name="Settings$DoubleTapPowerSettingsActivity"
+ android:label="@string/double_tap_power_title"
+ android:exported="true"
+ android:enabled="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.action.DOUBLE_TAP_POWER_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.gestures.DoubleTapPowerSettings"/>
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_system"/>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
<receiver android:name=".safetycenter.SafetySourceBroadcastReceiver"
android:exported="true">
<intent-filter>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1a9e0a8..3950a01 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -531,6 +531,7 @@
<string name="title_change_system_locale_region">Change region to %s ?</string>
<!-- Message for asking to change system locale region or not. [CHAR LIMIT=50]-->
<string name="body_change_system_locale_region">Your device will keep %s as a system language</string>
+ <string name="top_intro_numbering_system_title">The digits used will be dependent on the numbering system</string>
<!-- Regional Preferences begin -->
<!-- The title of the menu entry of regional preferences. [CHAR LIMIT=50] -->
@@ -911,6 +912,10 @@
<string name="security_settings_face_enroll_improve_face_alert_body_fingerprint">Delete your current face model to set up Face Unlock again.\n\nYour face model will be permanently and securely deleted.\n\nAfter deletion, you will need your fingerprint, PIN, pattern, or password to unlock your phone or for authentication in apps.</string>
<!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_use_face_category">Use Face Unlock for</string>
+ <!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
+ <string name="security_settings_face_settings_face_category">Face</string>
+ <!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
+ <string name="security_settings_face_settings_use_face_to_category">Use Face to</string>
<!-- Title for a category shown for the face settings page, followed by items that the user can toggle on/off to require/disable. [CHAR LIMIT=50] -->
<string name="security_settings_face_settings_preferences_category">When using Face Unlock</string>
<!-- Text shown on a toggle which disables/enables face unlock, depending if the user's eyes are open. [CHAR LIMIT=30] -->
@@ -942,6 +947,10 @@
<!-- Note: Update FingerprintEnrollParentalConsent.CONSENT_STRING_RESOURCES when any _consent_ strings are added or removed. -->
<!-- Title shown for choose lock options [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint">Fingerprint</string>
+ <!-- Title shown for a category shown for fingerprint settings page. [CHAR LIMIT=22] -->
+ <string name="security_settings_fingerprint_title">Fingerprints</string>
+ <!-- Fingerprint category title - fingerprint options for unlocking the device. [CHAR LIMIT=60] -->
+ <string name="security_settings_category_use_fingerprint">Use fingerprint to</string>
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_preference_title">Fingerprint</string>
<!-- Title for a category shown for the fingerprint settings page, followed by items that the user can toggle on/off to require/disable. [CHAR LIMIT=50] -->
@@ -4775,6 +4784,10 @@
<string name="trackpad_pointer_speed">Cursor speed</string>
<!-- Title text for 'Three finger tap' touchpad preference. This preference allows the user to select an action that will trigger when they tap three fingers on a touchpad. [CHAR LIMIT=60] -->
<string name="three_finger_tap_preference_title">Customise 3-finger tap</string>
+ <!-- Title for the 'Touchpad acceleration' preference switch, which dynamically adjusts cursor movement based on speed. [CHAR LIMIT=60] -->
+ <string name="touchpad_acceleration_title">Touchpad acceleration</string>
+ <!-- Summary text for the 'Touchpad acceleration' preference switch indicating to users that when this switch is enabled, faster movements with your fingers will move the cursor farther. [CHAR LIMIT=NONE] -->
+ <string name="touchpad_acceleration_summary">Faster movements on your touchpad will move the cursor farther</string>
<!-- Title text for mouse pointer color. [CHAR LIMIT=35] -->
<string name="pointer_fill_style">Pointer color</string>
<!-- Content description for black pointer fill style. [CHAR LIMIT=60] -->
@@ -11369,7 +11382,7 @@
<string name="legacy_navigation_summary">Go back, Home, and switch apps with buttons at the bottom of your screen.</string>
<!-- Accessibility string for gesture nav tutorial button [CHAR_LIMIT=NONE] -->
- <string name="nav_tutorial_button_description">Start gesture navigation tutorial, button. Double tap to activate.</string>
+ <string name="nav_tutorial_button_description">Start gesture navigation tutorial.</string>
<!-- Search keywords for System Navigation settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_system_navigation">system navigation, 2 button navigation, 3 button navigation, gesture navigation, swipe</string>
@@ -13127,10 +13140,6 @@
<string name="media_controls_lockscreen_title">Show media on lock screen</string>
<!-- Description of toggle to enable or disable the media resumption on lockscreen [CHAR LIMIT=NONE]-->
<string name="media_controls_lockscreen_description">To quickly resume playback, media player stays open on lock screen</string>
- <!-- Title of toggle to enable or disable media recommendations in quick settings [CHAR LIMIT=NONE] -->
- <string name="media_controls_recommendations_title">Show Assistant media recommendations</string>
- <!-- Description of toggle to enable or disable media recommendations based on user's activity [CHAR LIMIT=NONE] -->
- <string name="media_controls_recommendations_description">Based on your activity</string>
<!-- Subtext for media settings when the player will be hidden [CHAR LIMIT=50] -->
<string name="media_controls_hide_player">Hide player</string>
<!-- Subtext for media settings when the player will be shown [CHAR LIMIT=50] -->
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 3baf439..c7e2967 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -34,7 +34,7 @@
settings:userRestriction="no_config_brightness"/>
<com.android.settingslib.PrimarySwitchPreference
- android:key="screen_brightness_mode"
+ android:key="@string/preference_key_auto_brightness"
android:title="@string/auto_brightness_title"
android:fragment="com.android.settings.display.AutoBrightnessSettings"
settings:useAdminDisabledSummary="true"
diff --git a/res/xml/media_controls_settings.xml b/res/xml/media_controls_settings.xml
index 96a2ee4..ad5ceb2 100644
--- a/res/xml/media_controls_settings.xml
+++ b/res/xml/media_controls_settings.xml
@@ -33,10 +33,4 @@
android:summary="@string/media_controls_lockscreen_description"
app:controller="com.android.settings.sound.MediaControlsLockScreenPreferenceController" />
- <SwitchPreferenceCompat
- android:key="media_controls_recommendations"
- android:title="@string/media_controls_recommendations_title"
- android:summary="@string/media_controls_recommendations_description"
- app:controller="com.android.settings.sound.MediaControlsRecommendationController" />
-
</PreferenceScreen>
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index fd3498e..e32148c 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -20,6 +20,24 @@
android:title="@string/security_settings_face_preference_title">
<PreferenceCategory
+ android:key="biometric_settings_use_face_to"
+ android:title="@string/security_settings_face_settings_use_face_to_category"
+ settings:isPreferenceVisible="false">
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="biometric_settings_face_keyguard"
+ android:title="@string/biometric_settings_use_biometric_unlock_phone"
+ settings:keywords="@string/keywords_biometric_unlock"
+ settings:controller="com.android.settings.biometrics.face.FaceSettingsKeyguardUnlockPreferenceController"/>
+
+ <SwitchPreferenceCompat
+ android:key="biometric_settings_face_app"
+ android:title="@string/biometric_settings_use_biometric_for_apps"
+ settings:keywords="@string/keywords_biometric_unlock"
+ settings:controller="com.android.settings.biometrics.face.FaceSettingsAppsPreferenceController"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="security_settings_face_unlock_category"
android:title="@string/security_settings_face_settings_use_face_category"
settings:controller="com.android.settings.biometrics.face.FaceUnlockCategoryPreferenceController">
diff --git a/res/xml/security_settings_fingerprint.xml b/res/xml/security_settings_fingerprint.xml
index 331549c..701d493 100644
--- a/res/xml/security_settings_fingerprint.xml
+++ b/res/xml/security_settings_fingerprint.xml
@@ -20,6 +20,24 @@
android:title="@string/security_settings_fingerprint_preference_title">
<PreferenceCategory
+ android:key="biometric_settings_use_fingerprint_to"
+ android:title="@string/security_settings_category_use_fingerprint"
+ settings:isPreferenceVisible="false">
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="biometric_settings_fingerprint_keyguard"
+ android:title="@string/biometric_settings_use_biometric_unlock_phone"
+ settings:keywords="@string/keywords_biometric_unlock"
+ settings:controller="com.android.settings.biometrics.fingerprint.FingerprintSettingsKeyguardUnlockPreferenceController"/>
+
+ <SwitchPreferenceCompat
+ android:key="biometric_settings_fingerprint_app"
+ android:title="@string/biometric_settings_use_biometric_for_apps"
+ settings:keywords="@string/keywords_biometric_unlock"
+ settings:controller="com.android.settings.biometrics.fingerprint.FingerprintSettingsAppsPreferenceController"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="security_settings_fingerprints_enrolled"
settings:controller="com.android.settings.biometrics.fingerprint.FingerprintsEnrolledCategoryPreferenceController">
</PreferenceCategory>
diff --git a/res/xml/system_language_picker.xml b/res/xml/system_language_picker.xml
index 5262392..3d8e9d9 100644
--- a/res/xml/system_language_picker.xml
+++ b/res/xml/system_language_picker.xml
@@ -22,8 +22,7 @@
<com.android.settingslib.widget.TopIntroPreference
android:key="top_intro_region"
- android:title="@string/top_intro_region_title"
- settings:isPreferenceVisible="false"/>
+ android:title="@string/top_intro_region_title"/>
<PreferenceCategory
android:key="system_language_suggested_category"
diff --git a/res/xml/touchpad_settings.xml b/res/xml/touchpad_settings.xml
index 7d4b4bf..7369d48 100644
--- a/res/xml/touchpad_settings.xml
+++ b/res/xml/touchpad_settings.xml
@@ -54,6 +54,13 @@
settings:controller="com.android.settings.inputmethod.TouchpadThreeFingerTapPreferenceController"
android:order="37"/>
+ <SwitchPreferenceCompat
+ android:key="touchpad_acceleration"
+ android:title="@string/touchpad_acceleration_title"
+ android:summary="@string/touchpad_acceleration_summary"
+ settings:controller="com.android.settings.inputmethod.TouchpadAccelerationPreferenceController"
+ android:order="38"/>
+
<com.android.settings.widget.SeekBarPreference
android:key="touchpad_pointer_speed"
android:title="@string/trackpad_pointer_speed"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 91494af..ee866ba 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -518,6 +518,11 @@
*/
public static class OneHandedSettingsActivity extends SettingsActivity { /* empty */ }
+ /**
+ * Activity for Double Tap Power Settings
+ */
+ public static class DoubleTapPowerSettingsActivity extends SettingsActivity { /* empty */ }
+
public static class PreviouslyConnectedDeviceActivity extends SettingsActivity { /* empty */ }
public static class ScreenTimeoutActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
index 7b3a724..9fe4794 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
@@ -29,6 +29,7 @@
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import com.android.settings.R;
import com.android.settings.biometrics.BiometricEnrollBase;
@@ -76,6 +77,12 @@
if (mActiveUnlockStatusUtils.isAvailable()) {
updateUiForActiveUnlock();
}
+ if (Flags.biometricsOnboardingEducation()) {
+ final PreferenceCategory category = findPreference(KEY_USE_BIOMETRIC_PREFERENCE);
+ if (category != null) {
+ category.setVisible(false);
+ }
+ }
}
private void updateUiForActiveUnlock() {
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 5a3949b..26b5c37 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -47,6 +47,7 @@
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.biometrics.IdentityCheckBiometricErrorDialog;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.flags.Flags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
@@ -76,6 +77,8 @@
"security_settings_face_delete_faces_container";
private static final String PREF_KEY_ENROLL_FACE_UNLOCK =
"security_settings_face_enroll_faces_container";
+ private static final String PREF_KEY_USE_FACE_TO_CATEGORY =
+ "biometric_settings_use_face_to";
public static final String SECURITY_SETTINGS_FACE_MANAGE_CATEGORY =
"security_settings_face_manage_category";
@@ -238,6 +241,12 @@
if (savedInstanceState != null) {
mToken = savedInstanceState.getByteArray(KEY_TOKEN);
}
+
+ if (Flags.biometricsOnboardingEducation()) {
+ final PreferenceCategory category =
+ findPreference(PREF_KEY_USE_FACE_TO_CATEGORY);
+ category.setVisible(true);
+ }
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceController.java
new file mode 100644
index 0000000..f859060
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2025 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.biometrics.face;
+
+import static android.provider.Settings.Secure.FACE_APP_ENABLED;
+
+import android.content.Context;
+import android.hardware.face.FaceManager;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.Utils;
+import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
+
+public class FaceSettingsAppsPreferenceController extends
+ FaceSettingsPreferenceController {
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ private static final int DEFAULT = ON;
+
+ private FaceManager mFaceManager;
+
+ public FaceSettingsAppsPreferenceController(@NonNull Context context, @NonNull String key) {
+ super(context, key);
+ mFaceManager = Utils.getFaceManagerOrNull(context);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getIntForUser(mContext.getContentResolver(), FACE_APP_ENABLED,
+ DEFAULT, getUserId()) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(), FACE_APP_ENABLED,
+ isChecked ? ON : OFF, getUserId());
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final ActiveUnlockStatusUtils activeUnlockStatusUtils =
+ new ActiveUnlockStatusUtils(mContext);
+ if (!Utils.hasFaceHardware(mContext)
+ && !activeUnlockStatusUtils.isAvailable()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ if (mFaceManager == null) {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+ // This preference will be available only if the user has registered face.
+ final boolean hasFaceEnrolledUser = mFaceManager.hasEnrolledTemplates(getUserId());
+ if (hasFaceEnrolledUser) {
+ return AVAILABLE;
+ } else {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+ }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceController.java
new file mode 100644
index 0000000..e6298c0
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceController.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2025 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.biometrics.face;
+
+import static android.provider.Settings.Secure.FACE_KEYGUARD_ENABLED;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.Utils;
+import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
+
+public class FaceSettingsKeyguardUnlockPreferenceController extends
+ FaceSettingsPreferenceController {
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ private static final int DEFAULT = ON;
+
+ public FaceSettingsKeyguardUnlockPreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ FACE_KEYGUARD_ENABLED, DEFAULT, getUserId()) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ FACE_KEYGUARD_ENABLED, isChecked ? ON : OFF, getUserId());
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final ActiveUnlockStatusUtils activeUnlockStatusUtils =
+ new ActiveUnlockStatusUtils(mContext);
+ if (activeUnlockStatusUtils.isAvailable()) {
+ return getAvailabilityFromRestrictingAdmin();
+ }
+ if (!Utils.hasFaceHardware(mContext)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return getAvailabilityFromRestrictingAdmin();
+ }
+
+ private int getAvailabilityFromRestrictingAdmin() {
+ return getRestrictingAdmin() != null ? DISABLED_FOR_USER : AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index e50b0e5..e618ae3 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -273,6 +273,8 @@
"security_settings_fingerprint_footer";
private static final String KEY_BIOMETRICS_AUTHENTICATION_REQUESTED =
"biometrics_authentication_requested";
+ private static final String KEY_BIOMETRICS_USE_FINGERPRINT_TO_CATEGORY =
+ "biometric_settings_use_fingerprint_to";
private static final int MSG_REFRESH_FINGERPRINT_TEMPLATES = 1000;
private static final int MSG_FINGER_AUTH_SUCCESS = 1001;
@@ -656,6 +658,9 @@
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen root = getPreferenceScreen();
addFingerprintPreferences(root);
+ if (Flags.biometricsOnboardingEducation()) {
+ setupUseFingerprintToPreferences();
+ }
setPreferenceScreen(root);
return root;
}
@@ -685,6 +690,10 @@
if (mFingerprintsEnrolledCategory != null) {
mFingerprintsEnrolledCategory.removeAll();
}
+ if (Flags.biometricsOnboardingEducation()) {
+ mFingerprintsEnrolledCategory.setTitle(root.getContext().getString(
+ R.string.security_settings_fingerprint_title));
+ }
String keyToReturn = mIsExpressiveThemeStyle
? KEY_FINGERPRINT_ADD_EXPRESSIVE : KEY_FINGERPRINT_ADD;
@@ -815,6 +824,26 @@
});
}
+ private void setupUseFingerprintToPreferences() {
+ final PreferenceCategory category =
+ findPreference(KEY_BIOMETRICS_USE_FINGERPRINT_TO_CATEGORY);
+ category.setVisible(true);
+
+ // Setup use fingerprint to unlock preference
+ final FingerprintSettingsKeyguardUnlockPreferenceController fpUnlockController =
+ use(FingerprintSettingsKeyguardUnlockPreferenceController.class);
+ fpUnlockController.setUserId(mUserId);
+ findPreference(fpUnlockController.getPreferenceKey())
+ .setOnPreferenceChangeListener(fpUnlockController);
+
+ // Setup use fingerprint to verify it's you in apps preference
+ final FingerprintSettingsAppsPreferenceController fingerprintAppController =
+ use(FingerprintSettingsAppsPreferenceController.class);
+ fingerprintAppController.setUserId(mUserId);
+ findPreference(fingerprintAppController.getPreferenceKey())
+ .setOnPreferenceChangeListener(fingerprintAppController);
+ }
+
private void updatePreferencesAfterFingerprintRemoved() {
updateAddPreference();
if (isSfps() || (screenOffUnlockUdfps() && isUltrasnoicUdfps())) {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceController.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceController.java
new file mode 100644
index 0000000..2cd92fc
--- /dev/null
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceController.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2025 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.biometrics.fingerprint;
+
+import static android.provider.Settings.Secure.FINGERPRINT_APP_ENABLED;
+
+import android.content.Context;
+import android.hardware.fingerprint.FingerprintManager;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.Utils;
+import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
+
+public class FingerprintSettingsAppsPreferenceController
+ extends FingerprintSettingsPreferenceController {
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ private static final int DEFAULT = ON;
+
+ private FingerprintManager mFingerprintManager;
+
+ public FingerprintSettingsAppsPreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getIntForUser(mContext.getContentResolver(), FINGERPRINT_APP_ENABLED,
+ DEFAULT, getUserId()) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(), FINGERPRINT_APP_ENABLED,
+ isChecked ? ON : OFF, getUserId());
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final ActiveUnlockStatusUtils activeUnlockStatusUtils =
+ new ActiveUnlockStatusUtils(mContext);
+ if (!Utils.hasFingerprintHardware(mContext)
+ && !activeUnlockStatusUtils.isAvailable()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ if (mFingerprintManager == null) {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+ // This preference will be available only if the user has registered fingerprint.
+ final boolean hasFingerprintEnrolledUser =
+ mFingerprintManager.hasEnrolledTemplates(getUserId());
+ if (hasFingerprintEnrolledUser) {
+ return AVAILABLE;
+ } else {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+ }
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceController.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceController.java
new file mode 100644
index 0000000..55c75ab
--- /dev/null
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2025 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.biometrics.fingerprint;
+
+import static android.provider.Settings.Secure.FINGERPRINT_KEYGUARD_ENABLED;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.Utils;
+import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
+
+public class FingerprintSettingsKeyguardUnlockPreferenceController
+ extends FingerprintSettingsPreferenceController {
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ private static final int DEFAULT = ON;
+
+ public FingerprintSettingsKeyguardUnlockPreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ FINGERPRINT_KEYGUARD_ENABLED, DEFAULT, getUserId()) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ FINGERPRINT_KEYGUARD_ENABLED, isChecked ? ON : OFF, getUserId());
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final ActiveUnlockStatusUtils activeUnlockStatusUtils =
+ new ActiveUnlockStatusUtils(mContext);
+ if (activeUnlockStatusUtils.isAvailable()) {
+ return getAvailabilityFromRestrictingAdmin();
+ }
+ if (!Utils.hasFingerprintHardware(mContext)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return getAvailabilityFromRestrictingAdmin();
+ }
+
+ private int getAvailabilityFromRestrictingAdmin() {
+ return getRestrictingAdmin() != null ? DISABLED_FOR_USER : AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java b/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java
new file mode 100644
index 0000000..59e37c5
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2025 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.connecteddevice.audiosharing;
+
+import android.content.Context;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.bluetooth.BluetoothDeviceUpdater;
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settingslib.bluetooth.BluetoothUtils;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.flags.Flags;
+
+/** Maintain and update connected temporary bond bluetooth devices */
+public class TemporaryBondDeviceGroupUpdater extends BluetoothDeviceUpdater {
+ private static final String TAG = "TemporaryBondDeviceGroupUpdater";
+ private static final String PREF_KEY_PREFIX = "temp_bond_bt_";
+
+ public TemporaryBondDeviceGroupUpdater(
+ @NonNull Context context,
+ @NonNull DevicePreferenceCallback devicePreferenceCallback,
+ int metricsCategory) {
+ super(context, devicePreferenceCallback, metricsCategory);
+ }
+
+ @Override
+ public boolean isFilterMatched(@NonNull CachedBluetoothDevice cachedDevice) {
+ // Only connected temporary bond device should be shown in this section when Audio
+ // sharing UI is available.
+ boolean isFilterMatched = Flags.enableTemporaryBondDevicesUi()
+ && BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())
+ && isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)
+ && BluetoothUtils.isAudioSharingUIAvailable(mContext);
+ Log.d(
+ TAG,
+ "isFilterMatched() device : "
+ + cachedDevice.getName()
+ + ", isFilterMatched : "
+ + isFilterMatched);
+ return isFilterMatched;
+ }
+
+ @Override
+ protected String getPreferenceKeyPrefix() {
+ return PREF_KEY_PREFIX;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
+ super.update(cachedBluetoothDevice);
+ Log.d(TAG, "Map : " + mPreferenceMap);
+ }
+}
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreference.kt b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreference.kt
index 2d2fe2b..3cc608b 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreference.kt
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreference.kt
@@ -25,15 +25,13 @@
import com.android.settings.PreferenceRestrictionMixin
import com.android.settings.R
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController.isAodSuppressedByBedtime
+import com.android.settingslib.datastore.AbstractKeyedDataObservable
import com.android.settingslib.datastore.HandlerExecutor
import com.android.settingslib.datastore.KeyValueStore
-import com.android.settingslib.datastore.KeyedObservableDelegate
import com.android.settingslib.datastore.KeyedObserver
import com.android.settingslib.datastore.SettingsSecureStore
import com.android.settingslib.datastore.SettingsStore
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
-import com.android.settingslib.metadata.PreferenceLifecycleContext
-import com.android.settingslib.metadata.PreferenceLifecycleProvider
import com.android.settingslib.metadata.PreferenceSummaryProvider
import com.android.settingslib.metadata.ReadWritePermit
import com.android.settingslib.metadata.SensitivityLevel
@@ -44,11 +42,8 @@
SwitchPreference(KEY, R.string.doze_always_on_title, R.string.doze_always_on_summary),
PreferenceAvailabilityProvider,
PreferenceSummaryProvider,
- PreferenceLifecycleProvider,
PreferenceRestrictionMixin {
- private var keyMappingObserver: KeyedObserver<String>? = null
-
override val keywords: Int
get() = R.string.keywords_always_show_time_info
@@ -88,24 +83,17 @@
override val sensitivityLevel
get() = SensitivityLevel.NO_SENSITIVITY
- override fun onCreate(context: PreferenceLifecycleContext) {
- val storage = SettingsSecureStore.get(context)
- keyMappingObserver =
- KeyedObserver<String> { _, reason -> storage.notifyChange(KEY, reason) }
- .also { storage.addObserver(DOZE_ALWAYS_ON, it, HandlerExecutor.main) }
- }
-
- override fun onDestroy(context: PreferenceLifecycleContext) {
- keyMappingObserver?.let {
- SettingsSecureStore.get(context).removeObserver(DOZE_ALWAYS_ON, it)
- }
- }
-
+ /**
+ * Datastore of the preference.
+ *
+ * The preference key and underlying storage key are the different, leverage
+ * [AbstractKeyedDataObservable] to redirect data change event.
+ */
@Suppress("UNCHECKED_CAST")
class Storage(
private val context: Context,
private val settingsStore: SettingsStore = SettingsSecureStore.get(context),
- ) : KeyedObservableDelegate<String>(settingsStore), KeyValueStore {
+ ) : AbstractKeyedDataObservable<String>(), KeyedObserver<String>, KeyValueStore {
override fun contains(key: String) = settingsStore.contains(DOZE_ALWAYS_ON)
@@ -118,6 +106,20 @@
override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) =
settingsStore.setValue(DOZE_ALWAYS_ON, valueType, value)
+
+ override fun onFirstObserverAdded() {
+ // observe the underlying storage key
+ settingsStore.addObserver(DOZE_ALWAYS_ON, this, HandlerExecutor.main)
+ }
+
+ override fun onKeyChanged(key: String, reason: Int) {
+ // forward data change to preference hierarchy key
+ notifyChange(KEY, reason)
+ }
+
+ override fun onLastObserverRemoved() {
+ settingsStore.removeObserver(DOZE_ALWAYS_ON, this)
+ }
}
companion object {
diff --git a/src/com/android/settings/display/AutoBrightnessScreen.kt b/src/com/android/settings/display/AutoBrightnessScreen.kt
index c425888..b594b55 100644
--- a/src/com/android/settings/display/AutoBrightnessScreen.kt
+++ b/src/com/android/settings/display/AutoBrightnessScreen.kt
@@ -17,7 +17,7 @@
import android.content.Context
import android.os.UserManager
-import android.provider.Settings
+import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE
import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL
import androidx.preference.Preference
@@ -26,8 +26,10 @@
import com.android.settings.R
import com.android.settings.flags.Flags
import com.android.settingslib.PrimarySwitchPreferenceBinding
+import com.android.settingslib.datastore.AbstractKeyedDataObservable
+import com.android.settingslib.datastore.HandlerExecutor
import com.android.settingslib.datastore.KeyValueStore
-import com.android.settingslib.datastore.KeyedObservableDelegate
+import com.android.settingslib.datastore.KeyedObserver
import com.android.settingslib.datastore.SettingsStore
import com.android.settingslib.datastore.SettingsSystemStore
import com.android.settingslib.metadata.BooleanValuePreference
@@ -106,18 +108,32 @@
*/
@Suppress("UNCHECKED_CAST")
private class AutoBrightnessDataStore(private val settingsStore: SettingsStore) :
- KeyedObservableDelegate<String>(settingsStore), KeyValueStore {
+ AbstractKeyedDataObservable<String>(), KeyedObserver<String>, KeyValueStore {
- override fun contains(key: String) = settingsStore.contains(key)
+ override fun contains(key: String) = settingsStore.contains(SCREEN_BRIGHTNESS_MODE)
override fun <T : Any> getDefaultValue(key: String, valueType: Class<T>) =
DEFAULT_VALUE.toBoolean() as T
override fun <T : Any> getValue(key: String, valueType: Class<T>) =
- (settingsStore.getInt(key) ?: DEFAULT_VALUE).toBoolean() as T
+ (settingsStore.getInt(SCREEN_BRIGHTNESS_MODE) ?: DEFAULT_VALUE).toBoolean() as T
override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) =
- settingsStore.setInt(key, (value as? Boolean)?.toBrightnessMode())
+ settingsStore.setInt(SCREEN_BRIGHTNESS_MODE, (value as? Boolean)?.toBrightnessMode())
+
+ override fun onFirstObserverAdded() {
+ // observe the underlying storage key
+ settingsStore.addObserver(SCREEN_BRIGHTNESS_MODE, this, HandlerExecutor.main)
+ }
+
+ override fun onKeyChanged(key: String, reason: Int) {
+ // forward data change to preference hierarchy key
+ notifyChange(KEY, reason)
+ }
+
+ override fun onLastObserverRemoved() {
+ settingsStore.removeObserver(SCREEN_BRIGHTNESS_MODE, this)
+ }
/** Converts brightness mode integer to boolean. */
private fun Int.toBoolean() = this == SCREEN_BRIGHTNESS_MODE_AUTOMATIC
@@ -128,7 +144,7 @@
}
companion object {
- const val KEY = Settings.System.SCREEN_BRIGHTNESS_MODE
+ const val KEY = "auto_brightness_entry"
private const val DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL
}
}
diff --git a/src/com/android/settings/inputmethod/TouchpadAccelerationPreferenceController.java b/src/com/android/settings/inputmethod/TouchpadAccelerationPreferenceController.java
new file mode 100644
index 0000000..ad8c2ce
--- /dev/null
+++ b/src/com/android/settings/inputmethod/TouchpadAccelerationPreferenceController.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2025 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.inputmethod;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class TouchpadAccelerationPreferenceController extends TogglePreferenceController {
+
+ public TouchpadAccelerationPreferenceController(@NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return InputSettings.isTouchpadAccelerationEnabled(mContext);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ InputSettings.setTouchpadAccelerationEnabled(mContext, isChecked);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!InputSettings.isPointerAccelerationFeatureFlagEnabled()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return InputPeripheralsSettingsUtils.isTouchpad() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_system;
+ }
+}
diff --git a/src/com/android/settings/localepicker/LocalePickerBaseListPreferenceController.java b/src/com/android/settings/localepicker/LocalePickerBaseListPreferenceController.java
index 471ca35..913793d 100644
--- a/src/com/android/settings/localepicker/LocalePickerBaseListPreferenceController.java
+++ b/src/com/android/settings/localepicker/LocalePickerBaseListPreferenceController.java
@@ -19,6 +19,7 @@
import static com.android.settings.localepicker.LocaleListEditor.EXTRA_RESULT_LOCALE;
import static com.android.settings.localepicker.RegionAndNumberingSystemPickerFragment.EXTRA_IS_NUMBERING_SYSTEM;
+import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.LocaleList;
@@ -178,7 +179,9 @@
pref.setTitle(localeName);
pref.setKey(locale.toString());
pref.setOnPreferenceClickListener(clickedPref -> {
+ // TODO: b/390347399 - Should pop up a dialog when changes the region.
switchFragment(locale);
+ ((Activity) mContext).finish();
return true;
});
mPreferences.put(locale.getId(), pref);
diff --git a/src/com/android/settings/localepicker/RegionAndNumberingSystemPickerFragment.java b/src/com/android/settings/localepicker/RegionAndNumberingSystemPickerFragment.java
index 293c1ee..091e55b 100644
--- a/src/com/android/settings/localepicker/RegionAndNumberingSystemPickerFragment.java
+++ b/src/com/android/settings/localepicker/RegionAndNumberingSystemPickerFragment.java
@@ -116,8 +116,8 @@
}
TopIntroPreference topIntroPreference = findPreference(KEY_TOP_INTRO_PREFERENCE);
- if (topIntroPreference != null) {
- topIntroPreference.setVisible(!mIsNumberingMode);
+ if (topIntroPreference != null && mIsNumberingMode) {
+ topIntroPreference.setTitle(R.string.top_intro_numbering_system_title);
}
if (mSystemLocaleAllListPreferenceController != null) {
diff --git a/src/com/android/settings/localepicker/SystemLocalePickerFragment.java b/src/com/android/settings/localepicker/SystemLocalePickerFragment.java
index 183990b..f9e211b 100644
--- a/src/com/android/settings/localepicker/SystemLocalePickerFragment.java
+++ b/src/com/android/settings/localepicker/SystemLocalePickerFragment.java
@@ -47,6 +47,7 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.widget.TopIntroPreference;
import com.google.android.material.appbar.AppBarLayout;
@@ -71,14 +72,13 @@
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list";
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST =
"system_locale_suggested_list";
+ private static final String KEY_TOP_INTRO_PREFERENCE = "top_intro_region";
@Nullable
private SearchView mSearchView = null;
@Nullable
private SearchFilter mSearchFilter = null;
@Nullable
- private Set<LocaleStore.LocaleInfo> mLocaleList;
- @Nullable
private List<LocaleStore.LocaleInfo> mLocaleOptions;
@Nullable
private List<LocaleStore.LocaleInfo> mOriginalLocaleInfos;
@@ -106,8 +106,15 @@
}
SystemLocaleCollector systemLocaleCollector = new SystemLocaleCollector(getContext(), null);
- mLocaleList = systemLocaleCollector.getSupportedLocaleList(null, false, false);
- mLocaleOptions = new ArrayList<>(mLocaleList.size());
+ Set<LocaleStore.LocaleInfo> localeList = systemLocaleCollector.getSupportedLocaleList(null,
+ false, false);
+ mLocaleOptions = new ArrayList<>(localeList.size());
+
+ TopIntroPreference topIntroPreference = findPreference(KEY_TOP_INTRO_PREFERENCE);
+ if (topIntroPreference != null) {
+ topIntroPreference.setVisible(false);
+ }
+
}
@Override
@@ -175,7 +182,7 @@
FilterResults results = new FilterResults();
if (mOriginalLocaleInfos == null) {
- mOriginalLocaleInfos = new ArrayList<>(mLocaleList);
+ mOriginalLocaleInfos = new ArrayList<>(mLocaleOptions);
}
if (TextUtils.isEmpty(prefix)) {
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 9680d5a..a30c38b 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -348,9 +348,9 @@
*/
enum RightButtonMode {
Continue(R.string.next_label, true),
- ContinueDisabled(R.string.next_label, false),
+ ContinueDisabled(R.string.next_label, true),
Confirm(R.string.lockpattern_confirm_button_text, true),
- ConfirmDisabled(R.string.lockpattern_confirm_button_text, false),
+ ConfirmDisabled(R.string.lockpattern_confirm_button_text, true),
Ok(android.R.string.ok, true);
/**
@@ -563,6 +563,7 @@
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
mLockPatternView.setFadePattern(false);
+ mLockPatternView.setClickable(false);
mFooterText = (TextView) view.findViewById(R.id.footerText);
diff --git a/src/com/android/settings/sound/MediaControlsRecommendationController.java b/src/com/android/settings/sound/MediaControlsRecommendationController.java
deleted file mode 100644
index 842a141..0000000
--- a/src/com/android/settings/sound/MediaControlsRecommendationController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.sound;
-
-import static android.provider.Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settings.R;
-import com.android.settings.core.TogglePreferenceController;
-
-/**
- * Toggle for media controls recommendation setting
- */
-public class MediaControlsRecommendationController extends TogglePreferenceController {
-
- public MediaControlsRecommendationController(Context context, String key) {
- super(context, key);
- }
-
- @Override
- public boolean isChecked() {
- int val = Settings.Secure.getInt(mContext.getContentResolver(),
- MEDIA_CONTROLS_RECOMMENDATION, 1);
- return val == 1;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- int val = isChecked ? 1 : 0;
- return Settings.Secure.putInt(mContext.getContentResolver(),
- MEDIA_CONTROLS_RECOMMENDATION, val);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return AVAILABLE;
- }
-
- @Override
- public int getSliceHighlightMenuRes() {
- return R.string.menu_key_sound;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsFragmentTest.java
index a570baa..02825d2 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsFragmentTest.java
@@ -385,6 +385,19 @@
@Test
@EnableFlags(com.android.settings.flags.Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
+ public void testUseFingerprintToPreference_isShown() {
+ doReturn(List.of()).when(mFingerprintManager).getEnrolledFingerprints(anyInt());
+ setUpFragment(false, PRIMARY_USER_ID, TYPE_UDFPS_OPTICAL, 5);
+
+ shadowOf(Looper.getMainLooper()).idle();
+
+ final Preference preference =
+ mFragment.findPreference("biometric_settings_use_fingerprint_to");
+ assertThat(preference.isVisible()).isTrue();
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.flags.Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
public void testCheckEnrolledHide_nonUdfps() {
final Fingerprint fingerprint = new Fingerprint("Test", 0, 0);
doReturn(List.of(fingerprint)).when(mFingerprintManager).getEnrolledFingerprints(anyInt());
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java
new file mode 100644
index 0000000..0b34c10
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2025 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.connecteddevice.audiosharing;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothStatusCodes;
+import android.content.Context;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.bluetooth.Utils;
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
+import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.flags.Flags;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/** Tests for {@link TemporaryBondDeviceGroupUpdater}. */
+@RunWith(RobolectricTestRunner.class)
+@Config(
+ shadows = {
+ ShadowBluetoothAdapter.class,
+ ShadowBluetoothUtils.class
+ })
+public class TemporaryBondDeviceGroupUpdaterTest {
+ private static final String TAG = "TemporaryBondDeviceGroupUpdater";
+ private static final String PREF_KEY_PREFIX = "temp_bond_bt_";
+ private static final String TEMP_BOND_METADATA =
+ "<TEMP_BOND_TYPE>le_audio_sharing</TEMP_BOND_TYPE>";
+ private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
+
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
+ @Mock
+ private DevicePreferenceCallback mDevicePreferenceCallback;
+ @Mock
+ private CachedBluetoothDevice mCachedBluetoothDevice;
+ @Mock
+ private BluetoothDevice mBluetoothDevice;
+ @Mock
+ private LocalBluetoothManager mLocalBtManager;
+ @Mock
+ private CachedBluetoothDeviceManager mCachedDeviceManager;
+
+ private TemporaryBondDeviceGroupUpdater mDeviceUpdater;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(
+ BluetoothAdapter.getDefaultAdapter());
+ shadowBluetoothAdapter.setEnabled(true);
+ shadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
+ BluetoothStatusCodes.FEATURE_SUPPORTED);
+ shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
+ BluetoothStatusCodes.FEATURE_SUPPORTED);
+ Context context = ApplicationProvider.getApplicationContext();
+ ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager;
+ mLocalBtManager = Utils.getLocalBtManager(context);
+ when(mLocalBtManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
+ when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+ Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
+ cachedDevices.add(mCachedBluetoothDevice);
+ when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(cachedDevices);
+ mDeviceUpdater =
+ spy(
+ new TemporaryBondDeviceGroupUpdater(
+ context, mDevicePreferenceCallback, /* metricsCategory= */ 0));
+ mDeviceUpdater.setPrefContext(context);
+ }
+
+ @After
+ public void tearDown() {
+ ShadowBluetoothUtils.reset();
+ }
+
+ @Test
+ @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
+ Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
+ public void isFilterMatched_isTemporaryBondDevice_returnsTrue() {
+ when(mBluetoothDevice.isConnected()).thenReturn(true);
+ when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+ when(mBluetoothDevice.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS))
+ .thenReturn(TEMP_BOND_METADATA.getBytes());
+
+ assertThat(mDeviceUpdater.isFilterMatched(mCachedBluetoothDevice)).isTrue();
+ }
+
+ @Test
+ public void getLogTag_returnsCorrectTag() {
+ assertThat(mDeviceUpdater.getLogTag()).isEqualTo(TAG);
+ }
+
+ @Test
+ public void getPreferenceKey_returnsCorrectKey() {
+ assertThat(mDeviceUpdater.getPreferenceKeyPrefix()).isEqualTo(PREF_KEY_PREFIX);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessScreenTest.kt b/tests/robotests/src/com/android/settings/display/AutoBrightnessScreenTest.kt
index ab2d9bd..5da5c2a 100644
--- a/tests/robotests/src/com/android/settings/display/AutoBrightnessScreenTest.kt
+++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessScreenTest.kt
@@ -128,7 +128,11 @@
}
private fun setScreenBrightnessMode(value: Int) =
- Settings.System.putInt(context.contentResolver, AutoBrightnessScreen.KEY, value)
+ Settings.System.putInt(
+ context.contentResolver,
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ value,
+ )
private fun getResId() =
when {
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
index be3b63b..1d42495 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
@@ -287,7 +287,6 @@
final FooterButton nextButton = footerBarMixin.getPrimaryButton();
assertThat(nextButton.getVisibility()).isEqualTo(View.VISIBLE);
- assertThat(nextButton.isEnabled()).isFalse();
enterPattern();
@@ -333,7 +332,6 @@
mContext.getString(R.string.lockpattern_need_to_unlock_wrong));
assertThat(nextButton.getText().toString()).isEqualTo(
mContext.getString(R.string.lockpattern_confirm_button_text));
- assertThat(nextButton.isEnabled()).isFalse();
}
@Test
diff --git a/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceControllerTest.java
new file mode 100644
index 0000000..bf96cac
--- /dev/null
+++ b/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsAppsPreferenceControllerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 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.biometrics.face;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FaceSettingsAppsPreferenceControllerTest {
+ private Context mContext;
+ private FaceSettingsAppsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new FaceSettingsAppsPreferenceController(
+ mContext, "biometric_settings_face_app");
+ }
+
+ @Test
+ public void isSliceable_returnFalse() {
+ assertThat(mController.isSliceable()).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceControllerTest.java b/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceControllerTest.java
new file mode 100644
index 0000000..4eb7d3e
--- /dev/null
+++ b/tests/unit/src/com/android/settings/biometrics/face/FaceSettingsKeyguardUnlockPreferenceControllerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 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.biometrics.face;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FaceSettingsKeyguardUnlockPreferenceControllerTest {
+ private Context mContext;
+ private FaceSettingsKeyguardUnlockPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new FaceSettingsKeyguardUnlockPreferenceController(
+ mContext, "biometric_settings_face_keyguard");
+ }
+
+ @Test
+ public void isSliceable_returnFalse() {
+ assertThat(mController.isSliceable()).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceControllerTest.java
new file mode 100644
index 0000000..4aa21b8
--- /dev/null
+++ b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsAppsPreferenceControllerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 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.biometrics.fingerprint;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FingerprintSettingsAppsPreferenceControllerTest {
+ private Context mContext;
+ private FingerprintSettingsAppsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new FingerprintSettingsAppsPreferenceController(
+ mContext, "biometric_settings_fingerprint_app");
+ }
+
+ @Test
+ public void isSliceable_returnFalse() {
+ assertThat(mController.isSliceable()).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceControllerTest.java b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceControllerTest.java
new file mode 100644
index 0000000..13a58b1
--- /dev/null
+++ b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintSettingsKeyguardUnlockPreferenceControllerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 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.biometrics.fingerprint;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FingerprintSettingsKeyguardUnlockPreferenceControllerTest {
+ private Context mContext;
+ private FingerprintSettingsKeyguardUnlockPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new FingerprintSettingsKeyguardUnlockPreferenceController(
+ mContext, "biometric_settings_fingerprint_keyguard");
+ }
+
+ @Test
+ public void isSliceable_returnFalse() {
+ assertThat(mController.isSliceable()).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java b/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
index bdeede8..ba82e19 100644
--- a/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
@@ -34,8 +34,8 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,6 +51,7 @@
@Mock LockPatternUtils mLockPatternUtils;
private Preference mPreference;
+ private PrivateSpaceMaintainer mPrivateSpaceMaintainer;
private FaceFingerprintUnlockController mFaceFingerprintUnlockController;
/** Required setup before a test. */
@@ -68,12 +69,26 @@
.thenReturn(mLockPatternUtils);
doReturn(true).when(mLockPatternUtils).isSecure(anyInt());
+
+ mPrivateSpaceMaintainer = PrivateSpaceMaintainer.getInstance(mContext);
+ assertThat(mPrivateSpaceMaintainer.createPrivateSpace()).isTrue();
+ assertThat(mPrivateSpaceMaintainer.doesPrivateSpaceExist()).isTrue();
+
mFaceFingerprintUnlockController =
new FaceFingerprintUnlockController(mContext, mLifecycle);
}
+ @After
+ public void tearDown() {
+ // Ensure PSMaintainer is able to remove PS.
+ mSetFlagsRule.enableFlags(
+ android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assertThat(mPrivateSpaceMaintainer.deletePrivateSpace())
+ .isEqualTo(PrivateSpaceMaintainer.ErrorDeletingPrivateSpace.DELETE_PS_ERROR_NONE);
+ }
+
/** Tests that the controller is always available. */
- @Ignore("b/323652985")
@Test
public void getAvailabilityStatus_whenFlagsEnabled_returnsAvailable() {
mSetFlagsRule.enableFlags(
@@ -134,7 +149,6 @@
}
/** Tests that preference is enabled and summary is not same as device lock. */
- @Ignore("b/323652985")
@Test
public void getSummary_whenSeparateProfileLock() {
doReturn(true).when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
diff --git a/tests/unit/src/com/android/settings/sound/MediaControlsRecommendationControllerTest.java b/tests/unit/src/com/android/settings/sound/MediaControlsRecommendationControllerTest.java
deleted file mode 100644
index 68170b2..0000000
--- a/tests/unit/src/com/android/settings/sound/MediaControlsRecommendationControllerTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2020 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.sound;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.spy;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class MediaControlsRecommendationControllerTest {
-
- private static final String KEY = "media_controls_recommendations";
-
- private Context mContext;
- private int mOriginalRecommendation;
- private ContentResolver mContentResolver;
- private MediaControlsRecommendationController mController;
-
- @Before
- public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
- mContentResolver = mContext.getContentResolver();
- mOriginalRecommendation = Settings.Secure.getInt(mContentResolver,
- Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION, 1);
- mController = new MediaControlsRecommendationController(mContext, KEY);
- }
-
- @After
- public void tearDown() {
- Settings.Secure.putInt(mContentResolver, Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION,
- mOriginalRecommendation);
- }
-
- @Test
- public void getAvailability_returnAvailable() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void setChecked_enable_shouldTurnOn() {
- Settings.Secure.putInt(mContentResolver, Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION, 1);
-
- assertThat(mController.isChecked()).isTrue();
-
- mController.setChecked(false);
-
- assertThat(Settings.Secure.getInt(mContentResolver,
- Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION, -1)).isEqualTo(0);
- }
-
- @Test
- public void setChecked_disable_shouldTurnOff() {
- Settings.Secure.putInt(mContentResolver, Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION, 0);
-
- assertThat(mController.isChecked()).isFalse();
-
- mController.setChecked(true);
-
- assertThat(Settings.Secure.getInt(mContentResolver,
- Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION, -1)).isEqualTo(1);
- }
-}