Merge "[Audiosharing] Update audio sharing section title in call" into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c01d162..6408ab1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1074,28 +1074,6 @@
</activity>
<activity
- android:name=".Settings$LanguageAndInputSettingsActivity"
- android:label="@string/language_settings"
- android:exported="true"
- android:icon="@drawable/ic_settings_language">
- <intent-filter>
- <action android:name="android.settings.LANGUAGE_SETTINGS"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.VOICE_LAUNCH"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.language.LanguageAndInputSettings"/>
- <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>
-
- <activity
android:name=".Settings$LanguageSettingsActivity"
android:label="@string/languages_settings"
android:exported="true"
@@ -1225,9 +1203,9 @@
android:label="@string/language_input_gesture_title"
android:clearTaskOnLaunch="true"
android:exported="true"
- android:targetActivity="Settings$LanguageAndInputSettingsActivity">
+ android:targetActivity="Settings$LanguageSettingsActivity">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.language.LanguageAndInputSettings" />
+ android:value="com.android.settings.language.LanguageSettings" />
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
android:value="@string/menu_key_system"/>
</activity-alias>
diff --git a/res/layout/dialog_a11y_bounce_key.xml b/res/layout/dialog_a11y_bounce_key.xml
new file mode 100644
index 0000000..7e23692
--- /dev/null
+++ b/res/layout/dialog_a11y_bounce_key.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/bounce_key_dialog_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:textSize="20sp"
+ android:gravity="center_horizontal"
+ android:text="@string/bounce_keys_dialog_title"
+ android:textColor="?android:attr/textColorPrimary"
+ android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
+ />
+
+ <TextView
+ android:id="@+id/bounce_key_dialog_subtitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="26dp"
+ android:layout_marginTop="8dp"
+ android:textSize="16sp"
+ android:gravity="center"
+ android:text="@string/bounce_keys_dialog_subtitle"
+ android:textColor="?android:attr/textColorSecondary"
+ />
+
+ <RadioGroup
+ android:id="@+id/bounce_key_value_group"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="20dp"
+ android:layout_marginTop="16dp">
+
+ <RadioButton
+ android:id="@+id/bounce_key_value_200"
+ android:text="@string/bounce_keys_dialog_option_200"
+ android:paddingStart="12dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:background="@null"/>
+ <RadioButton
+ android:id="@+id/bounce_key_value_400"
+ android:text="@string/bounce_keys_dialog_option_400"
+ android:paddingStart="12dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginTop="16dp"
+ android:background="@null"/>
+ <RadioButton
+ android:id="@+id/bounce_key_value_600"
+ android:text="@string/bounce_keys_dialog_option_600"
+ android:paddingStart="12dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginTop="16dp"
+ android:background="@null"/>
+ </RadioGroup>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7ff00ce..5326fa5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4520,11 +4520,21 @@
<!-- Title for the 'Bounce keys' preference switch. [CHAR LIMIT=35] -->
<string name="bounce_keys">Bounce keys</string>
<!-- Summary text for the 'Bounce keys' preference sub-screen. [CHAR LIMIT=300] -->
- <string name="bounce_keys_summary">The keyboard ignores quickly repeated presses of the same key within <xliff:g id="bounce_keys_threshold" example="500">%1$d</xliff:g> ms</string>
+ <string name="bounce_keys_summary">The keyboard ignores quickly repeated presses of the same key </string>
+ <!-- Title for the 'Bounce keys' threshold dialog. [CHAR LIMIT=35] -->
+ <string name="bounce_keys_dialog_title">Bounce key threshold</string>
+ <!-- Subtitle for the 'Bounce keys' threshold dialog. [CHAR LIMIT=300] -->
+ <string name="bounce_keys_dialog_subtitle">Choose the duration of time your keyboard ignores repeated key presses</string>
+ <!-- Option title for the 'Bounce keys' threshold dialog for 200 millisecond. [CHAR LIMIT=35] -->
+ <string name="bounce_keys_dialog_option_200">0.2s</string>
+ <!-- Option title for the 'Bounce keys' threshold dialog for 400 millisecond. [CHAR LIMIT=35] -->
+ <string name="bounce_keys_dialog_option_400">0.4s</string>
+ <!-- Option title for the 'Bounce keys' threshold dialog for 600 millisecond. [CHAR LIMIT=35] -->
+ <string name="bounce_keys_dialog_option_600">0.6s</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=300] -->
- <string name="slow_keys_summary">Adjusts the time it takes for a key press to activate to <xliff:g id="slow_keys_threshold" example="500">%1$d</xliff:g> ms</string>
+ <string name="slow_keys_summary">Adjusts the time it takes for a key press to activate</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=300] -->
@@ -4532,7 +4542,7 @@
<!-- Title for a toggle switch for 'mouse' keys, an accessibility setting that allows the mouse pointer to be controlled using certain keys on a physical keyboard if keyboard is connected. [CHAR LIMIT=35] -->
<string name="mouse_keys">Mouse keys</string>
<!-- Summary text for the accessibility setting 'Mouse keys' preference sub-screen. [CHAR LIMIT=100] -->
- <string name="mouse_keys_summary">Use the physical keyboard to control the mouse.</string>
+ <string name="mouse_keys_summary">Use your keyboard to control the pointer</string>
<!-- Title for the button to trigger the 'keyboard shortcuts helper' dialog. [CHAR LIMIT=35] -->
<string name="keyboard_shortcuts_helper">Keyboard shortcuts</string>
<!-- Summary text for the 'keyboard shortcuts helper' dialog. [CHAR LIMIT=100] -->
diff --git a/res/xml/app_channels_bypassing_dnd_settings.xml b/res/xml/app_channels_bypassing_dnd_settings.xml
index 4f6291d..433d26d 100644
--- a/res/xml/app_channels_bypassing_dnd_settings.xml
+++ b/res/xml/app_channels_bypassing_dnd_settings.xml
@@ -16,7 +16,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/zen_mode_settings_title">
+ android:title="@string/zen_mode_apps_title">
<com.android.settingslib.widget.LayoutPreference
android:key="pref_app_header"
android:layout="@layout/settings_entity_header" />
@@ -26,4 +26,4 @@
android:title="@string/zen_mode_bypassing_app_channels_header">
<!-- add app channel toggles here -->
</PreferenceCategory>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/physical_keyboard_a11y_settings.xml b/res/xml/physical_keyboard_a11y_settings.xml
index eb787d0..62479f9 100644
--- a/res/xml/physical_keyboard_a11y_settings.xml
+++ b/res/xml/physical_keyboard_a11y_settings.xml
@@ -32,9 +32,10 @@
android:defaultValue="false"
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilityStickyKeysController"/>
- <SwitchPreferenceCompat
+ <com.android.settingslib.PrimarySwitchPreference
android:key="accessibility_bounce_keys"
android:title="@string/bounce_keys"
+ android:summary="@string/bounce_keys_summary"
android:defaultValue="false"
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilityBounceKeysController"/>
@@ -42,6 +43,7 @@
android:key="accessibility_slow_keys"
android:title="@string/slow_keys"
android:defaultValue="false"
+ android:summary="@string/slow_keys_summary"
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilitySlowKeysController" />
<SwitchPreferenceCompat
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 7678338..f7110b4 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -95,7 +95,6 @@
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
- public static class LanguageAndInputSettingsActivity extends SettingsActivity { /* empty */ }
public static class LanguageSettingsActivity extends SettingsActivity { /* empty */ }
/** Activity for the regional preferences settings. */
public static class RegionalPreferencesActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
index 80d1ce0..91e65b1 100644
--- a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
@@ -67,7 +67,7 @@
initLaunchPreference();
final View view = super.onCreateView(inflater, container, savedInstanceState);
- removePreference(KEY_USE_SERVICE_PREFERENCE);
+ removePreference(getUseServicePreferenceKey());
return view;
}
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index ccba9e7f..24aae3f 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -33,6 +33,8 @@
import android.view.View;
import android.view.ViewGroup;
+import androidx.annotation.VisibleForTesting;
+
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -52,7 +54,10 @@
private static final String TAG = "ToggleColorInversionPreferenceFragment";
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
- private static final String KEY_SHORTCUT_PREFERENCE = "color_inversion_shortcut_key";
+ @VisibleForTesting
+ static final String KEY_SHORTCUT_PREFERENCE = "color_inversion_shortcut_key";
+ @VisibleForTesting
+ static final String KEY_SWITCH_PREFERENCE = "color_inversion_switch_preference_key";
@Override
protected void registerKeysToObserverCallback(
@@ -73,9 +78,9 @@
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
- .authority(getPrefContext().getPackageName())
- .appendPath(String.valueOf(R.raw.a11y_color_inversion_banner))
- .build();
+ .authority(getPrefContext().getPackageName())
+ .appendPath(String.valueOf(R.raw.a11y_color_inversion_banner))
+ .build();
final View view = super.onCreateView(inflater, container, savedInstanceState);
updateFooterPreference();
return view;
@@ -132,6 +137,11 @@
}
@Override
+ protected String getUseServicePreferenceKey() {
+ return KEY_SWITCH_PREFERENCE;
+ }
+
+ @Override
protected CharSequence getShortcutTitle() {
return getText(R.string.accessibility_display_inversion_shortcut_title);
}
@@ -165,7 +175,7 @@
@Override
int getUserShortcutTypes() {
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
- mComponentName);
+ mComponentName);
}
@Override
@@ -176,8 +186,8 @@
@Override
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
- ? R.string.accessibility_color_inversion_qs_tooltip_content
- : R.string.accessibility_color_inversion_auto_added_qs_tooltip_content);
+ ? R.string.accessibility_color_inversion_qs_tooltip_content
+ : R.string.accessibility_color_inversion_auto_added_qs_tooltip_content);
}
@Override
@@ -194,12 +204,22 @@
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
- final List<SearchIndexableRaw> rawData = new ArrayList<>();
+ final List<SearchIndexableRaw> rawData =
+ super.getRawDataToIndex(context, enabled);
+
SearchIndexableRaw raw = new SearchIndexableRaw(context);
raw.key = KEY_SHORTCUT_PREFERENCE;
raw.title = context.getString(
- R.string.accessibility_display_inversion_shortcut_title);
+ R.string.accessibility_display_inversion_shortcut_title);
rawData.add(raw);
+
+ if (Flags.fixA11ySettingsSearch()) {
+ SearchIndexableRaw mainPreferenceRaw = new SearchIndexableRaw(context);
+ mainPreferenceRaw.key = KEY_SWITCH_PREFERENCE;
+ mainPreferenceRaw.title = context.getString(
+ R.string.accessibility_display_inversion_switch_title);
+ rawData.add(mainPreferenceRaw);
+ }
return rawData;
}
};
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 86ddd71..d2fc6cc 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -106,7 +106,7 @@
final List<String> lists = new ArrayList<>();
lists.add(KEY_TOP_INTRO_PREFERENCE);
lists.add(KEY_PREVIEW);
- lists.add(KEY_USE_SERVICE_PREFERENCE);
+ lists.add(getUseServicePreferenceKey());
// Putting saturation level close to the preview so users can see what is changing.
lists.add(KEY_SATURATION);
lists.add(KEY_DEUTERANOMALY);
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 6649cf4..a9f422e 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -83,7 +83,6 @@
public static final String KEY_GENERAL_CATEGORY = "general_categories";
public static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
protected static final String KEY_TOP_INTRO_PREFERENCE = "top_intro";
- protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description";
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
protected static final String KEY_SAVED_QS_TOOLTIP_TYPE = "qs_tooltip_type";
@@ -325,6 +324,10 @@
switchPreference.setTitle(title);
}
+ protected String getUseServicePreferenceKey() {
+ return "use_service";
+ }
+
protected CharSequence getShortcutTitle() {
return getString(R.string.accessibility_shortcut_title, mPackageName);
}
@@ -411,7 +414,7 @@
final List<String> lists = new ArrayList<>();
lists.add(KEY_TOP_INTRO_PREFERENCE);
lists.add(KEY_ANIMATED_IMAGE);
- lists.add(KEY_USE_SERVICE_PREFERENCE);
+ lists.add(getUseServicePreferenceKey());
lists.add(KEY_GENERAL_CATEGORY);
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
return lists;
@@ -476,7 +479,7 @@
private void initToggleServiceSwitchPreference() {
mToggleServiceSwitchPreference = new SettingsMainSwitchPreference(getPrefContext());
- mToggleServiceSwitchPreference.setKey(KEY_USE_SERVICE_PREFERENCE);
+ mToggleServiceSwitchPreference.setKey(getUseServicePreferenceKey());
if (getArguments().containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
final boolean enabled = getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED);
mToggleServiceSwitchPreference.setChecked(enabled);
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index bc14288..ee49450 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -54,7 +54,6 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat;
-import androidx.preference.TwoStatePreference;
import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
@@ -64,7 +63,11 @@
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.Indexable;
+import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.widget.IllustrationPreference;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -73,16 +76,20 @@
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
+import java.util.stream.Stream;
/**
* Fragment that shows the actual UI for providing basic magnification accessibility service setup
* and does not have toggle bar to turn on service to use.
*/
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class ToggleScreenMagnificationPreferenceFragment extends
ToggleFeaturePreferenceFragment implements
MagnificationModePreferenceController.DialogHelper {
private static final String TAG = "ToggleScreenMagnificationPreferenceFragment";
+ @VisibleForTesting
+ static final String KEY_MAGNIFICATION_SHORTCUT_PREFERENCE = "magnification_shortcut_preference";
private static final char COMPONENT_NAME_SEPARATOR = ':';
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
@@ -181,38 +188,29 @@
}
}
+ private static boolean isWindowMagnificationSupported(Context context) {
+ return context.getResources().getBoolean(
+ com.android.internal.R.bool.config_magnification_area)
+ && context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WINDOW_MAGNIFICATION);
+ }
+
@Override
protected void initSettingsPreference() {
// If the device doesn't support window magnification feature, it should hide the
// settings preference.
- final boolean supportWindowMagnification =
- getContext().getResources().getBoolean(
- com.android.internal.R.bool.config_magnification_area)
- && getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WINDOW_MAGNIFICATION);
- if (!supportWindowMagnification) {
+ if (!isWindowMagnificationSupported(getContext())) {
return;
}
- mSettingsPreference = new Preference(getPrefContext());
- mSettingsPreference.setTitle(R.string.accessibility_magnification_mode_title);
- mSettingsPreference.setKey(MagnificationModePreferenceController.PREF_KEY);
- mSettingsPreference.setPersistent(false);
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
- generalCategory.addPreference(mSettingsPreference);
-
- final MagnificationModePreferenceController magnificationModePreferenceController =
- new MagnificationModePreferenceController(getContext(),
- MagnificationModePreferenceController.PREF_KEY);
- magnificationModePreferenceController.setDialogHelper(this);
- getSettingsLifecycle().addObserver(magnificationModePreferenceController);
- magnificationModePreferenceController.displayPreference(getPreferenceScreen());
- addPreferenceController(magnificationModePreferenceController);
-
+ // LINT.IfChange(:preference_list)
+ addMagnificationModeSetting(generalCategory);
addFollowTypingSetting(generalCategory);
addOneFingerPanningSetting(generalCategory);
addAlwaysOnSetting(generalCategory);
addJoystickSetting(generalCategory);
+ // LINT.ThenChange(:search_data)
}
@Override
@@ -233,22 +231,44 @@
&& !Flags.enableMagnificationOneFingerPanningGesture()) {
String summary = MessageFormat.format(
context.getString(R.string.accessibility_screen_magnification_summary),
- new Object[]{1, 2, 3, 4, 5});
+ new Object[]{1, 2, 3, 4, 5});
arguments.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, summary);
}
super.onProcessArguments(arguments);
}
+ private static Preference createMagnificationModePreference(Context context) {
+ final Preference pref = new Preference(context);
+ pref.setTitle(R.string.accessibility_magnification_mode_title);
+ pref.setKey(MagnificationModePreferenceController.PREF_KEY);
+ pref.setPersistent(false);
+ return pref;
+ }
+
+ private void addMagnificationModeSetting(PreferenceCategory generalCategory) {
+ mSettingsPreference = createMagnificationModePreference(getPrefContext());
+ generalCategory.addPreference(mSettingsPreference);
+
+ final MagnificationModePreferenceController magnificationModePreferenceController =
+ new MagnificationModePreferenceController(getContext(),
+ MagnificationModePreferenceController.PREF_KEY);
+ magnificationModePreferenceController.setDialogHelper(this);
+ getSettingsLifecycle().addObserver(magnificationModePreferenceController);
+ magnificationModePreferenceController.displayPreference(getPreferenceScreen());
+ addPreferenceController(magnificationModePreferenceController);
+ }
+
+ private static Preference createFollowTypingPreference(Context context) {
+ final Preference pref = new SwitchPreferenceCompat(context);
+ pref.setTitle(R.string.accessibility_screen_magnification_follow_typing_title);
+ pref.setSummary(R.string.accessibility_screen_magnification_follow_typing_summary);
+ pref.setKey(MagnificationFollowTypingPreferenceController.PREF_KEY);
+ return pref;
+ }
+
private void addFollowTypingSetting(PreferenceCategory generalCategory) {
- var followingTypingSwitchPreference = new SwitchPreferenceCompat(getPrefContext());
- followingTypingSwitchPreference.setTitle(
- R.string.accessibility_screen_magnification_follow_typing_title);
- followingTypingSwitchPreference.setSummary(
- R.string.accessibility_screen_magnification_follow_typing_summary);
- followingTypingSwitchPreference.setKey(
- MagnificationFollowTypingPreferenceController.PREF_KEY);
- generalCategory.addPreference(followingTypingSwitchPreference);
+ generalCategory.addPreference(createFollowTypingPreference(getPrefContext()));
var followTypingPreferenceController = new MagnificationFollowTypingPreferenceController(
getContext(), MagnificationFollowTypingPreferenceController.PREF_KEY);
@@ -257,8 +277,8 @@
addPreferenceController(followTypingPreferenceController);
}
- private boolean isAlwaysOnSettingEnabled() {
- final boolean defaultValue = getContext().getResources().getBoolean(
+ private static boolean isAlwaysOnSupported(Context context) {
+ final boolean defaultValue = context.getResources().getBoolean(
com.android.internal.R.bool.config_magnification_always_on_enabled);
return DeviceConfig.getBoolean(
@@ -268,19 +288,21 @@
);
}
+ private static Preference createAlwaysOnPreference(Context context) {
+ final Preference pref = new SwitchPreferenceCompat(context);
+ pref.setTitle(R.string.accessibility_screen_magnification_always_on_title);
+ pref.setSummary(R.string.accessibility_screen_magnification_always_on_summary);
+ pref.setKey(MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ return pref;
+ }
+
private void addAlwaysOnSetting(PreferenceCategory generalCategory) {
- if (!isAlwaysOnSettingEnabled()) {
+ if (!isAlwaysOnSupported(getContext())) {
return;
}
- var alwaysOnPreference = new SwitchPreferenceCompat(getPrefContext());
- alwaysOnPreference.setTitle(
- R.string.accessibility_screen_magnification_always_on_title);
- alwaysOnPreference.setSummary(
- R.string.accessibility_screen_magnification_always_on_summary);
- alwaysOnPreference.setKey(
- MagnificationAlwaysOnPreferenceController.PREF_KEY);
- generalCategory.addPreference(alwaysOnPreference);
+ final Preference pref = createAlwaysOnPreference(getPrefContext());
+ generalCategory.addPreference(pref);
var alwaysOnPreferenceController = new MagnificationAlwaysOnPreferenceController(
getContext(), MagnificationAlwaysOnPreferenceController.PREF_KEY);
@@ -290,17 +312,24 @@
addPreferenceController(alwaysOnPreferenceController);
}
+ private static Preference createOneFingerPanningPreference(Context context) {
+ final Preference pref = new SwitchPreferenceCompat(context);
+ pref.setTitle(R.string.accessibility_magnification_one_finger_panning_title);
+ pref.setKey(MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ return pref;
+ }
+
+ private static boolean isOneFingerPanningSupported() {
+ return Flags.enableMagnificationOneFingerPanningGesture();
+ }
+
private void addOneFingerPanningSetting(PreferenceCategory generalCategory) {
- if (!Flags.enableMagnificationOneFingerPanningGesture()) {
+ if (!isOneFingerPanningSupported()) {
return;
}
- var oneFingerPanningPreference = new SwitchPreferenceCompat(getPrefContext());
- oneFingerPanningPreference.setTitle(
- R.string.accessibility_magnification_one_finger_panning_title);
- oneFingerPanningPreference.setKey(
- MagnificationOneFingerPanningPreferenceController.PREF_KEY);
- generalCategory.addPreference(oneFingerPanningPreference);
+ final Preference pref = createOneFingerPanningPreference(getPrefContext());
+ generalCategory.addPreference(pref);
mOneFingerPanningPreferenceController =
new MagnificationOneFingerPanningPreferenceController(getContext());
@@ -310,23 +339,28 @@
addPreferenceController(mOneFingerPanningPreferenceController);
}
- private void addJoystickSetting(PreferenceCategory generalCategory) {
- if (!DeviceConfig.getBoolean(
+ private static Preference createJoystickPreference(Context context) {
+ final Preference pref = new SwitchPreferenceCompat(context);
+ pref.setTitle(R.string.accessibility_screen_magnification_joystick_title);
+ pref.setSummary(R.string.accessibility_screen_magnification_joystick_summary);
+ pref.setKey(MagnificationJoystickPreferenceController.PREF_KEY);
+ return pref;
+ }
+
+ private static boolean isJoystickSupported() {
+ return DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_WINDOW_MANAGER,
"MagnificationJoystick__enable_magnification_joystick",
- false
- )) {
+ false);
+ }
+
+ private void addJoystickSetting(PreferenceCategory generalCategory) {
+ if (!isJoystickSupported()) {
return;
}
- TwoStatePreference joystickPreference = new SwitchPreferenceCompat(getPrefContext());
- joystickPreference.setTitle(
- R.string.accessibility_screen_magnification_joystick_title);
- joystickPreference.setSummary(
- R.string.accessibility_screen_magnification_joystick_summary);
- joystickPreference.setKey(
- MagnificationJoystickPreferenceController.PREF_KEY);
- generalCategory.addPreference(joystickPreference);
+ final Preference pref = createJoystickPreference(getPrefContext());
+ generalCategory.addPreference(pref);
MagnificationJoystickPreferenceController joystickPreferenceController =
new MagnificationJoystickPreferenceController(
@@ -354,9 +388,9 @@
super.registerKeysToObserverCallback(contentObserver);
var keysToObserve = List.of(
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED,
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED,
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED,
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED,
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED
);
contentObserver.registerKeysToObserverCallback(keysToObserve,
key -> updatePreferencesState());
@@ -409,7 +443,7 @@
return getShortcutSummaryList(context,
PreferredShortcuts.retrieveUserShortcutType(context,
- MAGNIFICATION_CONTROLLER_NAME));
+ MAGNIFICATION_CONTROLLER_NAME));
}
@Override
@@ -518,6 +552,11 @@
}
@Override
+ protected String getShortcutPreferenceKey() {
+ return KEY_MAGNIFICATION_SHORTCUT_PREFERENCE;
+ }
+
+ @Override
protected CharSequence getShortcutTitle() {
return getText(R.string.accessibility_screen_magnification_shortcut_title);
}
@@ -777,8 +816,8 @@
final int userShortcutType = getUserShortcutTypeFromSettings(context);
final CharSequence featureState =
(userShortcutType != DEFAULT)
- ? context.getText(R.string.accessibility_summary_shortcut_enabled)
- : context.getText(R.string.generic_accessibility_feature_shortcut_off);
+ ? context.getText(R.string.accessibility_summary_shortcut_enabled)
+ : context.getText(R.string.generic_accessibility_feature_shortcut_off);
final CharSequence featureSummary = context.getText(R.string.magnification_feature_summary);
return context.getString(
com.android.settingslib.R.string.preference_summary_default_combination,
@@ -790,4 +829,81 @@
return PreferredShortcuts.retrieveUserShortcutType(
getPrefContext(), MAGNIFICATION_CONTROLLER_NAME);
}
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ // LINT.IfChange(:search_data)
+ @Override
+ public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+ boolean enabled) {
+ final List<SearchIndexableRaw> rawData =
+ super.getRawDataToIndex(context, enabled);
+
+ if (!com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
+ return rawData;
+ }
+
+ rawData.add(createShortcutPreferenceSearchData(context));
+ Stream.of(
+ createMagnificationModePreference(context),
+ createFollowTypingPreference(context),
+ createOneFingerPanningPreference(context),
+ createAlwaysOnPreference(context),
+ createJoystickPreference(context)
+ )
+ .forEach(pref ->
+ rawData.add(createPreferenceSearchData(context, pref)));
+ return rawData;
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> niks = super.getNonIndexableKeys(context);
+
+ if (!com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
+ return niks;
+ }
+
+ if (!isWindowMagnificationSupported(context)) {
+ niks.add(MagnificationModePreferenceController.PREF_KEY);
+ niks.add(MagnificationFollowTypingPreferenceController.PREF_KEY);
+ niks.add(MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ niks.add(MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ niks.add(MagnificationJoystickPreferenceController.PREF_KEY);
+ } else {
+ if (!isAlwaysOnSupported(context)
+ // This preference's title "Keep on while switching apps" does not
+ // mention magnification so it may confuse users who search a term
+ // like "Keep on".
+ // So we hide it if the user has no magnification shortcut enabled.
+ || getUserShortcutTypeFromSettings(context) == DEFAULT) {
+ niks.add(MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ }
+ if (!isOneFingerPanningSupported()) {
+ niks.add(MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ }
+ if (!isJoystickSupported()) {
+ niks.add(MagnificationJoystickPreferenceController.PREF_KEY);
+ }
+ }
+ return niks;
+ }
+ // LINT.ThenChange(:preference_list)
+
+ private SearchIndexableRaw createPreferenceSearchData(
+ Context context, Preference pref) {
+ final SearchIndexableRaw raw = new SearchIndexableRaw(context);
+ raw.key = pref.getKey();
+ raw.title = pref.getTitle().toString();
+ return raw;
+ }
+
+ private SearchIndexableRaw createShortcutPreferenceSearchData(Context context) {
+ final SearchIndexableRaw raw = new SearchIndexableRaw(context);
+ raw.key = KEY_MAGNIFICATION_SHORTCUT_PREFERENCE;
+ raw.title = context.getString(
+ R.string.accessibility_screen_magnification_shortcut_title);
+ return raw;
+ }
+ };
}
diff --git a/src/com/android/settings/bluetooth/ui/model/DeviceSettingPreferenceModel.kt b/src/com/android/settings/bluetooth/ui/model/DeviceSettingPreferenceModel.kt
index b16bff1..ba6d1a6 100644
--- a/src/com/android/settings/bluetooth/ui/model/DeviceSettingPreferenceModel.kt
+++ b/src/com/android/settings/bluetooth/ui/model/DeviceSettingPreferenceModel.kt
@@ -18,6 +18,7 @@
import android.content.Intent
import com.android.settingslib.bluetooth.devicesettings.DeviceSettingId
+import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingActionModel
import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingIcon
import com.android.settingslib.bluetooth.devicesettings.shared.model.ToggleModel
@@ -32,7 +33,7 @@
val title: String,
val summary: String? = null,
val icon: DeviceSettingIcon? = null,
- val intent: Intent? = null,
+ val action: DeviceSettingActionModel? = null,
) : DeviceSettingPreferenceModel
/** Models a switch preference. */
@@ -43,7 +44,7 @@
val icon: DeviceSettingIcon? = null,
val checked: Boolean,
val onCheckedChange: ((Boolean) -> Unit),
- val intent: Intent? = null,
+ val action: DeviceSettingActionModel? = null,
) : DeviceSettingPreferenceModel
/** Models a multi-toggle preference. */
diff --git a/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt b/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt
index ecd700b..5418a04 100644
--- a/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt
+++ b/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt
@@ -55,6 +55,7 @@
import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
import com.android.settings.spa.preference.ComposePreference
import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingActionModel
import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingConfigItemModel
import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingIcon
import com.android.settingslib.spa.framework.theme.SettingsDimension
@@ -313,10 +314,10 @@
return { deviceSettingIcon(model.icon) }
}
}
- if (model.intent != null) {
+ if (model.action != null) {
TwoTargetSwitchPreference(
switchPrefModel,
- primaryOnClick = { startActivity(model.intent) },
+ primaryOnClick = { triggerAction(model.action) },
)
} else {
SwitchPreference(switchPrefModel)
@@ -330,7 +331,7 @@
override val title = model.title
override val summary = { model.summary ?: "" }
override val onClick = {
- model.intent?.let { startActivity(it) }
+ model.action?.let { triggerAction(it) }
Unit
}
override val icon: (@Composable () -> Unit)?
@@ -382,9 +383,16 @@
icon?.let { Icon(it, modifier = Modifier.size(SettingsDimension.itemIconSize)) }
}
- private fun startActivity(intent: Intent) {
- intent.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- context.startActivity(intent)
+ private fun triggerAction(action: DeviceSettingActionModel) {
+ when (action) {
+ is DeviceSettingActionModel.IntentAction -> {
+ action.intent.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ context.startActivity(action.intent)
+ }
+ is DeviceSettingActionModel.PendingIntentAction -> {
+ action.pendingIntent.send()
+ }
+ }
}
private fun getPreferenceKey(settingId: Int) = "DEVICE_SETTING_${settingId}"
diff --git a/src/com/android/settings/bluetooth/ui/viewmodel/BluetoothDeviceDetailsViewModel.kt b/src/com/android/settings/bluetooth/ui/viewmodel/BluetoothDeviceDetailsViewModel.kt
index fe66cb5..a9444a5 100644
--- a/src/com/android/settings/bluetooth/ui/viewmodel/BluetoothDeviceDetailsViewModel.kt
+++ b/src/com/android/settings/bluetooth/ui/viewmodel/BluetoothDeviceDetailsViewModel.kt
@@ -101,7 +101,7 @@
DeviceSettingStateModel.ActionSwitchPreferenceState(newState)
)
},
- intent = intent,
+ action = action,
)
} else {
DeviceSettingPreferenceModel.PlainPreference(
@@ -109,7 +109,7 @@
title = title,
summary = summary,
icon = icon,
- intent = intent,
+ action = action,
)
}
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
index 168fce5..468ac3d 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
@@ -31,6 +31,7 @@
import android.os.Looper;
import android.provider.Settings;
import android.util.Log;
+import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -195,40 +196,33 @@
}
updateDeviceItemsInSharingSession();
if (!mDeviceItemsInSharingSession.isEmpty()) {
- int checkedItemIndex = getActiveItemIndex(mDeviceItemsInSharingSession);
+ Pair<Integer, AudioSharingDeviceItem> pair = getActiveItemWithIndex();
AudioSharingCallAudioDialogFragment.show(
mFragment,
mDeviceItemsInSharingSession,
- checkedItemIndex,
+ pair == null ? -1 : pair.first,
(AudioSharingDeviceItem item) -> {
int currentGroupId =
BluetoothUtils.getPrimaryGroupIdForBroadcast(
mContext.getContentResolver());
- if (item.getGroupId() == currentGroupId) {
- Log.d(
- TAG,
- "Skip set fallback active device: unchanged");
+ int clickedGroupId = item.getGroupId();
+ if (clickedGroupId == currentGroupId) {
+ Log.d(TAG, "Skip set call audio device: unchanged");
return;
}
List<BluetoothDevice> devices =
mGroupedConnectedDevices.getOrDefault(
- item.getGroupId(), ImmutableList.of());
+ clickedGroupId, ImmutableList.of());
CachedBluetoothDevice lead =
AudioSharingUtils.getLeadDevice(
mCacheManager, devices);
if (lead != null) {
- Log.d(
- TAG,
- "Set fallback active device: "
- + lead.getDevice()
- .getAnonymizedAddress());
+ String addr = lead.getDevice().getAnonymizedAddress();
+ Log.d(TAG, "Set call audio device: " + addr);
lead.setActive();
logCallAudioDeviceChange(currentGroupId, lead);
} else {
- Log.d(
- TAG,
- "Fail to set fallback active device: no"
- + " lead device");
+ Log.d(TAG, "Skip set call audio device: no lead");
}
});
}
@@ -263,6 +257,18 @@
}
}
+ @Override
+ public void onActiveDeviceChanged(@Nullable CachedBluetoothDevice activeDevice,
+ int bluetoothProfile) {
+ if (activeDevice != null && bluetoothProfile == BluetoothProfile.LE_AUDIO
+ && BluetoothUtils.isBroadcasting(mBtManager)) {
+ Log.d(TAG, "onActiveDeviceChanged: update summary, device = "
+ + activeDevice.getDevice().getAnonymizedAddress()
+ + ", profile = " + bluetoothProfile);
+ updateSummary();
+ }
+ }
+
/**
* Initialize the controller.
*
@@ -348,30 +354,22 @@
*/
private void updateSummary() {
updateDeviceItemsInSharingSession();
- int fallbackActiveGroupId =
- BluetoothUtils.getPrimaryGroupIdForBroadcast(mContext.getContentResolver());
- if (fallbackActiveGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
- for (AudioSharingDeviceItem item : mDeviceItemsInSharingSession) {
- if (item.getGroupId() == fallbackActiveGroupId) {
- Log.d(
- TAG,
- "updatePreference: set summary to fallback group "
- + fallbackActiveGroupId);
- AudioSharingUtils.postOnMainThread(
- mContext,
- () -> {
- if (mPreference != null) {
- mPreference.setSummary(
- mContext.getString(
- R.string.audio_sharing_call_audio_description,
- item.getName()));
- }
- });
- return;
- }
- }
+ Pair<Integer, AudioSharingDeviceItem> pair = getActiveItemWithIndex();
+ if (pair != null) {
+ Log.d(TAG, "updateSummary, group = " + pair.second.getGroupId());
+ AudioSharingUtils.postOnMainThread(
+ mContext,
+ () -> {
+ if (mPreference != null) {
+ mPreference.setSummary(
+ mContext.getString(
+ R.string.audio_sharing_call_audio_description,
+ pair.second.getName()));
+ }
+ });
+ return;
}
- Log.d(TAG, "updatePreference: set empty summary");
+ Log.d(TAG, "updateSummary: set empty");
AudioSharingUtils.postOnMainThread(
mContext,
() -> {
@@ -388,16 +386,26 @@
mBtManager, mGroupedConnectedDevices, /* filterByInSharing= */ true);
}
- private int getActiveItemIndex(List<AudioSharingDeviceItem> deviceItems) {
- int checkedItemIndex = -1;
+ @Nullable
+ private Pair<Integer, AudioSharingDeviceItem> getActiveItemWithIndex() {
+ List<AudioSharingDeviceItem> deviceItems = new ArrayList<>(mDeviceItemsInSharingSession);
int fallbackActiveGroupId =
BluetoothUtils.getPrimaryGroupIdForBroadcast(mContext.getContentResolver());
- for (AudioSharingDeviceItem item : deviceItems) {
- if (item.getGroupId() == fallbackActiveGroupId) {
- return deviceItems.indexOf(item);
+ if (fallbackActiveGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
+ for (AudioSharingDeviceItem item : deviceItems) {
+ if (item.getGroupId() == fallbackActiveGroupId) {
+ Log.d(TAG, "getActiveItemWithIndex, fallback group = " + item.getGroupId());
+ return new Pair<>(deviceItems.indexOf(item), item);
+ }
}
}
- return checkedItemIndex;
+ for (AudioSharingDeviceItem item : deviceItems) {
+ if (item.isActive()) {
+ Log.d(TAG, "getActiveItemWithIndex, active LEA group = " + item.getGroupId());
+ return new Pair<>(deviceItems.indexOf(item), item);
+ }
+ }
+ return null;
}
@VisibleForTesting
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItem.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItem.java
index 5998e30..ca62dc3 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItem.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItem.java
@@ -19,6 +19,8 @@
import android.os.Parcel;
import android.os.Parcelable;
+import androidx.annotation.NonNull;
+
public final class AudioSharingDeviceItem implements Parcelable {
private final String mName;
private final int mGroupId;
@@ -72,4 +74,10 @@
return new AudioSharingDeviceItem[size];
}
};
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "AudioSharingDeviceItem groupId = " + mGroupId + ", isActive = " + mIsActive;
+ }
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 734bddc..3e92d5f 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -437,8 +437,6 @@
Settings.AdaptiveBrightnessActivity.class.getName(),
// Home page > Security & screen lock
Settings.LocationSettingsActivity.class.getName(),
- // Home page > System
- Settings.LanguageAndInputSettingsActivity.class.getName(),
Settings.LanguageSettingsActivity.class.getName(),
Settings.KeyboardSettingsActivity.class.getName(),
Settings.DateTimeSettingsActivity.class.getName(),
diff --git a/src/com/android/settings/development/DesktopModePreferenceController.java b/src/com/android/settings/development/DesktopModePreferenceController.java
index f43e17c..492686e 100644
--- a/src/com/android/settings/development/DesktopModePreferenceController.java
+++ b/src/com/android/settings/development/DesktopModePreferenceController.java
@@ -17,14 +17,14 @@
package com.android.settings.development;
import static android.provider.Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_MODE_FEATURES;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.fromSetting;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_OFF;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_ON;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET;
+import static android.window.DesktopModeFlags.ToggleOverride.fromSetting;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_OFF;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_ON;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET;
import android.content.Context;
import android.provider.Settings;
-import android.window.flags.DesktopModeFlags.ToggleOverride;
+import android.window.DesktopModeFlags.ToggleOverride;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityController.java b/src/com/android/settings/inputmethod/InputSettingPreferenceController.java
similarity index 87%
rename from src/com/android/settings/inputmethod/KeyboardAccessibilityController.java
rename to src/com/android/settings/inputmethod/InputSettingPreferenceController.java
index 25a93b0..6d462c2 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilityController.java
+++ b/src/com/android/settings/inputmethod/InputSettingPreferenceController.java
@@ -35,25 +35,25 @@
import com.android.settings.keyboard.Flags;
/**
- * Abstract class for toggle controllers of Keyboard accessibility related function.
+ * Abstract class for toggle controllers of Keyboard input setting related function.
*/
-public abstract class KeyboardAccessibilityController extends TogglePreferenceController implements
+public abstract class InputSettingPreferenceController extends TogglePreferenceController implements
LifecycleObserver {
private final ContentResolver mContentResolver;
private final ContentObserver mContentObserver = new ContentObserver(new Handler(true)) {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (getSettingUri().equals(uri)) {
- updateKeyboardAccessibilitySettings();
+ onInputSettingUpdated();
}
}
};
- protected abstract void updateKeyboardAccessibilitySettings();
+ protected abstract void onInputSettingUpdated();
protected abstract Uri getSettingUri();
- public KeyboardAccessibilityController(@NonNull Context context,
+ public InputSettingPreferenceController(@NonNull Context context,
@NonNull String preferenceKey) {
super(context, preferenceKey);
mContentResolver = context.getContentResolver();
@@ -94,7 +94,7 @@
false,
mContentObserver,
UserHandle.myUserId());
- updateKeyboardAccessibilitySettings();
+ onInputSettingUpdated();
}
private void unregisterSettingsObserver() {
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysController.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysController.java
index 6dad8c0..559b2e4 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysController.java
+++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysController.java
@@ -20,20 +20,38 @@
import android.hardware.input.InputSettings;
import android.net.Uri;
import android.provider.Settings;
+import android.text.TextUtils;
+import android.widget.RadioGroup;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.LifecycleObserver;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settingslib.PrimarySwitchPreference;
public class KeyboardAccessibilityBounceKeysController extends
- KeyboardAccessibilityController implements
+ InputSettingPreferenceController implements
LifecycleObserver {
public static final int BOUNCE_KEYS_THRESHOLD = 500;
+ private AlertDialog mAlertDialog;
+ @Nullable
+ private PrimarySwitchPreference mPrimaryPreference;
+
public KeyboardAccessibilityBounceKeysController(@NonNull Context context,
@NonNull String key) {
super(context, key);
+ constructDialog(context);
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPrimaryPreference = screen.findPreference(getPreferenceKey());
}
@Override
@@ -44,6 +62,17 @@
}
@Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return false;
+ }
+ if (mAlertDialog != null) {
+ mAlertDialog.show();
+ }
+ return true;
+ }
+
+ @Override
public boolean isChecked() {
return InputSettings.isAccessibilityBounceKeysEnabled(mContext);
}
@@ -55,16 +84,12 @@
return true;
}
- @NonNull
@Override
- public CharSequence getSummary() {
- return mContext.getString(R.string.bounce_keys_summary, BOUNCE_KEYS_THRESHOLD);
- }
-
- @Override
- protected void updateKeyboardAccessibilitySettings() {
- setChecked(
- InputSettings.isAccessibilityBounceKeysEnabled(mContext));
+ protected void onInputSettingUpdated() {
+ if (mPrimaryPreference != null) {
+ mPrimaryPreference.setChecked(
+ InputSettings.isAccessibilityBounceKeysEnabled(mContext));
+ }
}
@Override
@@ -72,4 +97,31 @@
return Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS);
}
+
+ private void constructDialog(Context context) {
+ mAlertDialog = new AlertDialog.Builder(context)
+ .setView(R.layout.dialog_a11y_bounce_key)
+ .setPositiveButton(android.R.string.ok,
+ (dialog, which) -> {
+ RadioGroup radioGroup =
+ mAlertDialog.findViewById(R.id.bounce_key_value_group);
+ int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
+ int threshold = checkedRadioButtonId == R.id.bounce_key_value_600 ? 600
+ : checkedRadioButtonId == R.id.bounce_key_value_400 ? 400
+ : checkedRadioButtonId == R.id.bounce_key_value_200
+ ? 200 : 0;
+ InputSettings.setAccessibilityBounceKeysThreshold(context, threshold);
+ })
+ .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
+ .create();
+ mAlertDialog.setOnShowListener(dialog -> {
+ RadioGroup radioGroup = mAlertDialog.findViewById(R.id.bounce_key_value_group);
+ int bounceKeysThreshold = InputSettings.getAccessibilityBounceKeysThreshold(context);
+ switch (bounceKeysThreshold) {
+ case 600 -> radioGroup.check(R.id.bounce_key_value_600);
+ case 400 -> radioGroup.check(R.id.bounce_key_value_400);
+ default -> radioGroup.check(R.id.bounce_key_value_200);
+ }
+ });
+ }
}
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityMouseKeysController.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityMouseKeysController.java
index 7c7ad37..57ae88a 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilityMouseKeysController.java
+++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityMouseKeysController.java
@@ -23,15 +23,26 @@
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleObserver;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.TwoStatePreference;
public class KeyboardAccessibilityMouseKeysController extends
- KeyboardAccessibilityController implements
+ InputSettingPreferenceController implements
LifecycleObserver {
+
+ private TwoStatePreference mTwoStatePreference;
+
public KeyboardAccessibilityMouseKeysController(@NonNull Context context, @NonNull String key) {
super(context, key);
}
@Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mTwoStatePreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
public boolean isChecked() {
return InputSettings.isAccessibilityMouseKeysEnabled(mContext);
}
@@ -51,9 +62,11 @@
}
@Override
- protected void updateKeyboardAccessibilitySettings() {
- setChecked(
- InputSettings.isAccessibilityMouseKeysEnabled(mContext));
+ protected void onInputSettingUpdated() {
+ if (mTwoStatePreference != null) {
+ mTwoStatePreference.setChecked(
+ InputSettings.isAccessibilityMouseKeysEnabled(mContext));
+ }
}
@Override
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysController.java b/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysController.java
index 5110663..d8602df 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysController.java
+++ b/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysController.java
@@ -23,19 +23,27 @@
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleObserver;
-
-import com.android.settings.R;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.TwoStatePreference;
public class KeyboardAccessibilitySlowKeysController extends
- KeyboardAccessibilityController implements
+ InputSettingPreferenceController implements
LifecycleObserver {
public static final int SLOW_KEYS_THRESHOLD = 500;
+ private TwoStatePreference mTwoStatePreference;
+
public KeyboardAccessibilitySlowKeysController(@NonNull Context context, @NonNull String key) {
super(context, key);
}
@Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mTwoStatePreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
public boolean isChecked() {
return InputSettings.isAccessibilitySlowKeysEnabled(mContext);
}
@@ -54,16 +62,12 @@
: UNSUPPORTED_ON_DEVICE;
}
- @NonNull
@Override
- public CharSequence getSummary() {
- return mContext.getString(R.string.slow_keys_summary, SLOW_KEYS_THRESHOLD);
- }
-
- @Override
- protected void updateKeyboardAccessibilitySettings() {
- setChecked(
- InputSettings.isAccessibilitySlowKeysEnabled(mContext));
+ protected void onInputSettingUpdated() {
+ if (mTwoStatePreference != null) {
+ mTwoStatePreference.setChecked(
+ InputSettings.isAccessibilitySlowKeysEnabled(mContext));
+ }
}
@Override
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityStickyKeysController.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityStickyKeysController.java
index a62d80b..fd2cb2e 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilityStickyKeysController.java
+++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityStickyKeysController.java
@@ -23,16 +23,27 @@
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleObserver;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.TwoStatePreference;
public class KeyboardAccessibilityStickyKeysController extends
- KeyboardAccessibilityController implements
+ InputSettingPreferenceController implements
LifecycleObserver {
+
+ private TwoStatePreference mTwoStatePreference;
+
public KeyboardAccessibilityStickyKeysController(@NonNull Context context,
@NonNull String key) {
super(context, key);
}
@Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mTwoStatePreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
public boolean isChecked() {
return InputSettings.isAccessibilityStickyKeysEnabled(mContext);
}
@@ -52,9 +63,11 @@
}
@Override
- protected void updateKeyboardAccessibilitySettings() {
- setChecked(
- InputSettings.isAccessibilityStickyKeysEnabled(mContext));
+ protected void onInputSettingUpdated() {
+ if (mTwoStatePreference != null) {
+ mTwoStatePreference.setChecked(
+ InputSettings.isAccessibilityStickyKeysEnabled(mContext));
+ }
}
@Override
diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java
index a1f75bc..28df8ed 100644
--- a/src/com/android/settings/nfc/PaymentSettings.java
+++ b/src/com/android/settings/nfc/PaymentSettings.java
@@ -30,6 +30,7 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.internal.hidden_from_bootclasspath.android.permission.flags.Flags;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -120,6 +121,9 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
+ if (Flags.walletRoleEnabled()) {
+ return false;
+ }
final UserManager userManager = context.getSystemService(UserManager.class);
final UserInfo myUserInfo = userManager.getUserInfo(UserHandle.myUserId());
if (myUserInfo.isGuest()) {
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 3188240..0881b29 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1860,6 +1860,10 @@
boolean suppressAllPage) {
final List<String> niks = super.getNonIndexableKeysFromXml(context, xmlResId,
suppressAllPage);
+ if (TextUtils.isEmpty(context.getString(
+ com.android.internal.R.string.config_supervisedUserCreationPackage))) {
+ niks.add(KEY_ADD_SUPERVISED_USER);
+ }
AddUserWhenLockedPreferenceController controller =
new AddUserWhenLockedPreferenceController(
context, KEY_ADD_USER_WHEN_LOCKED);
diff --git a/src/com/android/settings/widget/TintDrawable.java b/src/com/android/settings/widget/TintDrawable.java
index 7b34890..caa683b 100644
--- a/src/com/android/settings/widget/TintDrawable.java
+++ b/src/com/android/settings/widget/TintDrawable.java
@@ -39,7 +39,7 @@
* underlying drawable. This class should only be used in XML.
*
* @attr ref android.R.styleable#DrawableWrapper_drawable
- * @attr ref R.styleable#TintDrawable_tint
+ * @attr ref android.R.styleable#TintDrawable_tint
*/
public class TintDrawable extends DrawableWrapper {
private ColorStateList mTint;
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
index 1a82a25..e971186 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
@@ -18,7 +18,8 @@
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
-import static com.android.settings.accessibility.ToggleColorInversionPreferenceFragment.KEY_USE_SERVICE_PREFERENCE;
+import static com.android.settings.accessibility.ToggleColorInversionPreferenceFragment.KEY_SHORTCUT_PREFERENCE;
+import static com.android.settings.accessibility.ToggleColorInversionPreferenceFragment.KEY_SWITCH_PREFERENCE;
import static com.google.common.truth.Truth.assertThat;
@@ -32,12 +33,12 @@
import android.content.Context;
import android.os.Bundle;
import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.accessibility.Flags;
import android.widget.PopupWindow;
import androidx.fragment.app.FragmentActivity;
@@ -50,6 +51,7 @@
import com.android.settings.testutils.XmlTestUtils;
import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settings.widget.SettingsMainSwitchPreference;
+import com.android.settingslib.search.SearchIndexableRaw;
import org.junit.Before;
import org.junit.Rule;
@@ -63,6 +65,7 @@
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
import java.util.List;
/** Tests for {@link ToggleColorInversionPreferenceFragment} */
@@ -93,10 +96,10 @@
when(mActivity.getContentResolver()).thenReturn(mContext.getContentResolver());
mScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
- when(mScreen.findPreference(KEY_USE_SERVICE_PREFERENCE))
+ when(mScreen.findPreference(mFragment.getUseServicePreferenceKey()))
.thenReturn(mFragment.mToggleServiceSwitchPreference);
doReturn(mScreen).when(mFragment).getPreferenceScreen();
- mSwitchPreference = mScreen.findPreference(KEY_USE_SERVICE_PREFERENCE);
+ mSwitchPreference = mScreen.findPreference(mFragment.getUseServicePreferenceKey());
}
@Test
@@ -137,7 +140,7 @@
}
@Test
- @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
+ @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void onPreferenceToggled_colorCorrectDisabled_shouldReturnTrueAndShowTooltipView() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF);
@@ -199,6 +202,41 @@
assertThat(keys).containsAtLeastElementsIn(niks);
}
+ @Test
+ @DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getRawDataToIndex_flagOff_returnShortcutIndexablePreferences() {
+ List<SearchIndexableRaw> rawData = ToggleColorInversionPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, /* enabled= */ true);
+
+ assertThat(rawData).hasSize(1);
+ assertThat(rawData.get(0).key).isEqualTo(KEY_SHORTCUT_PREFERENCE);
+ assertThat(rawData.get(0).title).isEqualTo(mContext.getString(
+ R.string.accessibility_display_inversion_shortcut_title));
+
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getRawDataToIndex_flagOn_returnAllIndexablePreferences() {
+ String[] expectedKeys = {KEY_SHORTCUT_PREFERENCE, KEY_SWITCH_PREFERENCE};
+ String[] expectedTitles = {
+ mContext.getString(R.string.accessibility_display_inversion_shortcut_title),
+ mContext.getString(R.string.accessibility_display_inversion_switch_title)};
+ List<String> keysResultList = new ArrayList<>();
+ List<String> titlesResultList = new ArrayList<>();
+ List<SearchIndexableRaw> rawData = ToggleColorInversionPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, /* enabled= */ true);
+
+ for (SearchIndexableRaw rawDataItem : rawData) {
+ keysResultList.add(rawDataItem.key);
+ titlesResultList.add(rawDataItem.title);
+ }
+
+ assertThat(rawData).hasSize(2);
+ assertThat(keysResultList).containsExactly(expectedKeys);
+ assertThat(titlesResultList).containsExactly(expectedTitles);
+ }
+
private static PopupWindow getLatestPopupWindow() {
final ShadowApplication shadowApplication =
Shadow.extract(ApplicationProvider.getApplicationContext());
@@ -220,7 +258,7 @@
mComponentName = PLACEHOLDER_COMPONENT_NAME;
final SettingsMainSwitchPreference switchPreference =
new SettingsMainSwitchPreference(context);
- switchPreference.setKey(KEY_USE_SERVICE_PREFERENCE);
+ switchPreference.setKey(getUseServicePreferenceKey());
mToggleServiceSwitchPreference = switchPreference;
setArguments(new Bundle());
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java
index a5bfec2..fd82994 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java
@@ -18,7 +18,6 @@
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
-import static com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.KEY_USE_SERVICE_PREFERENCE;
import static com.google.common.truth.Truth.assertThat;
@@ -189,6 +188,6 @@
private SettingsMainSwitchPreference getMainFeatureToggle(
ToggleDaltonizerPreferenceFragment fragment) {
- return fragment.findPreference(KEY_USE_SERVICE_PREFERENCE);
+ return fragment.findPreference(fragment.getUseServicePreferenceKey());
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index 71855e0..844fabe 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -235,8 +235,7 @@
@Test
@Config(shadows = ShadowFragment.class)
public void onPreferenceToggledOnDisabledService_notShowTooltipView() {
- mFragment.onPreferenceToggled(
- ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ false);
+ mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ false);
assertThat(getLatestPopupWindow()).isNull();
}
@@ -245,8 +244,7 @@
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
@Config(shadows = ShadowFragment.class)
public void onPreferenceToggledOnEnabledService_showTooltipView() {
- mFragment.onPreferenceToggled(
- ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
+ mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
assertThat(getLatestPopupWindow().isShowing()).isTrue();
}
@@ -258,8 +256,7 @@
suwIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
when(mActivity.getIntent()).thenReturn(suwIntent);
- mFragment.onPreferenceToggled(
- ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
+ mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
assertThat(getLatestPopupWindow()).isNull();
}
@@ -268,12 +265,10 @@
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
@Config(shadows = ShadowFragment.class)
public void onPreferenceToggledOnEnabledService_tooltipViewShown_notShowTooltipView() {
- mFragment.onPreferenceToggled(
- ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
+ mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
getLatestPopupWindow().dismiss();
- mFragment.onPreferenceToggled(
- ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
+ mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
assertThat(getLatestPopupWindow().isShowing()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 038672f..87632ae 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -24,6 +24,7 @@
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
+import static com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment.KEY_MAGNIFICATION_SHORTCUT_PREFERENCE;
import static com.google.common.truth.Truth.assertThat;
@@ -70,6 +71,7 @@
import com.android.settings.testutils.shadow.ShadowStorageManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.search.SearchIndexableRaw;
import com.google.common.truth.Correspondence;
@@ -539,7 +541,7 @@
@Test
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
- for (int size : new int[] {FloatingMenuSizePreferenceController.Size.LARGE,
+ for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE,
FloatingMenuSizePreferenceController.Size.SMALL}) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size);
@@ -557,7 +559,7 @@
@Test
public void optInAllValuesToSettings_hardware_sizeValueIsNotChanged() {
- for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
+ for (int size : new int[]{FloatingMenuSizePreferenceController.Size.UNKNOWN,
FloatingMenuSizePreferenceController.Size.LARGE,
FloatingMenuSizePreferenceController.Size.SMALL}) {
Settings.Secure.putInt(mContext.getContentResolver(),
@@ -575,7 +577,7 @@
@Test
public void optInAllValuesToSettings_tripletap_sizeValueIsNotChanged() {
- for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
+ for (int size : new int[]{FloatingMenuSizePreferenceController.Size.UNKNOWN,
FloatingMenuSizePreferenceController.Size.LARGE,
FloatingMenuSizePreferenceController.Size.SMALL}) {
Settings.Secure.putInt(mContext.getContentResolver(),
@@ -1025,6 +1027,107 @@
.isEqualTo(collectionInfo.getImportantForAccessibilityItemCount() + 1);
}
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getRawDataToIndex_returnsAllPreferenceKeys() {
+ List<String> expectedSearchKeys = List.of(
+ KEY_MAGNIFICATION_SHORTCUT_PREFERENCE,
+ MagnificationModePreferenceController.PREF_KEY,
+ MagnificationFollowTypingPreferenceController.PREF_KEY,
+ MagnificationOneFingerPanningPreferenceController.PREF_KEY,
+ MagnificationAlwaysOnPreferenceController.PREF_KEY,
+ MagnificationJoystickPreferenceController.PREF_KEY);
+
+ final List<SearchIndexableRaw> rawData = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
+ final List<String> actualSearchKeys = rawData.stream().map(raw -> raw.key).toList();
+
+ assertThat(actualSearchKeys).containsExactlyElementsIn(expectedSearchKeys);
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void
+ getNonIndexableKeys_windowMagnificationNotSupported_onlyShortcutPreferenceSearchable() {
+ setWindowMagnificationSupported(false, false);
+
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+ final List<SearchIndexableRaw> rawData = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
+ // Expect all search data, except the shortcut preference, to be in NIKs.
+ final List<String> expectedNiks = rawData.stream().map(raw -> raw.key)
+ .filter(key -> !key.equals(KEY_MAGNIFICATION_SHORTCUT_PREFERENCE)).toList();
+
+ // In NonIndexableKeys == not searchable
+ assertThat(niks).containsExactlyElementsIn(expectedNiks);
+ }
+
+ @Test
+ @EnableFlags({
+ com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH,
+ Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE})
+ public void getNonIndexableKeys_hasShortcutAndAllFeaturesEnabled_allItemsSearchable() {
+ setMagnificationTripleTapEnabled(true);
+ setAlwaysOnSupported(true);
+ setJoystickSupported(true);
+
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ // Empty NonIndexableKeys == all indexed items are searchable
+ assertThat(niks).isEmpty();
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getNonIndexableKeys_noShortcut_alwaysOnSupported_notSearchable() {
+ setMagnificationTripleTapEnabled(false);
+ setAlwaysOnSupported(true);
+
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ // In NonIndexableKeys == not searchable
+ assertThat(niks).contains(MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getNonIndexableKeys_hasShortcut_alwaysOnNotSupported_notSearchable() {
+ setMagnificationTripleTapEnabled(true);
+ setAlwaysOnSupported(false);
+
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ // In NonIndexableKeys == not searchable
+ assertThat(niks).contains(MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ @DisableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE)
+ public void getNonIndexableKeys_oneFingerPanningNotSupported_notSearchable() {
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ // In NonIndexableKeys == not searchable
+ assertThat(niks).contains(MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ }
+
+ @Test
+ @EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
+ public void getNonIndexableKeys_joystickNotSupported_notSearchable() {
+ setJoystickSupported(false);
+
+ final List<String> niks = ToggleScreenMagnificationPreferenceFragment
+ .SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ // In NonIndexableKeys == not searchable
+ assertThat(niks).contains(MagnificationJoystickPreferenceController.PREF_KEY);
+ }
+
private void putStringIntoSettings(String key, String componentName) {
Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
index faea3d8..d9054a8 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
@@ -115,7 +115,8 @@
/* pending */ false,
/* timeApprovedMs */ System.currentTimeMillis(),
/* lastTimeConnected */ Long.MAX_VALUE,
- /* systemDataSyncFlags */ -1);
+ /* systemDataSyncFlags */ -1,
+ /* deviceIcon */ null);
mAssociations.add(association);
showScreen(mController);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
index 87ae3d5..a575d5a 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
@@ -176,6 +176,22 @@
bisSyncState.add(1L);
when(mState.getBisSyncState()).thenReturn(bisSyncState);
when(mContext.getContentResolver()).thenReturn(mContentResolver);
+ when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
+ when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
+ when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
+ when(mCachedDevice1.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(false);
+ when(mCachedDevice1.getMemberDevice()).thenReturn(ImmutableSet.of(mCachedDevice2));
+ when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
+ when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
+ when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
+ when(mCachedDevice2.getName()).thenReturn(TEST_DEVICE_NAME1);
+ when(mCachedDevice2.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(false);
+ when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
+ when(mCachedDevice3.getDevice()).thenReturn(mDevice3);
+ when(mCachedDevice3.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
+ when(mCachedDevice3.getName()).thenReturn(TEST_DEVICE_NAME2);
+ when(mCachedDevice3.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(false);
+ when(mCacheManager.findDevice(mDevice3)).thenReturn(mCachedDevice3);
mController = new AudioSharingCallAudioPreferenceController(mContext);
mController.init(null);
mContentObserver = mController.getSettingsObserver();
@@ -323,7 +339,9 @@
when(mBroadcast.isEnabled(any())).thenReturn(true);
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
mController.displayPreference(mScreen);
+ shadowOf(Looper.getMainLooper()).idle();
mPreference.setSummary("test");
+
mController.onProfileConnectionStateChanged(
mCachedDevice1,
BluetoothAdapter.STATE_DISCONNECTED,
@@ -335,14 +353,13 @@
@Test
public void onFallbackDeviceChanged_updateSummary() {
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
when(mBroadcast.isEnabled(any())).thenReturn(true);
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
mController.displayPreference(mScreen);
+ shadowOf(Looper.getMainLooper()).idle();
+ mPreference.setSummary("test");
+
mContentObserver.onChange(true);
shadowOf(Looper.getMainLooper()).idle();
assertThat(mPreference.getSummary().toString())
@@ -352,20 +369,29 @@
}
@Test
- public void displayPreference_showCorrectSummary() {
+ public void onActiveDeviceChanged_updateSummary() {
+ Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ when(mCachedDevice1.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true);
+ when(mBroadcast.isEnabled(any())).thenReturn(true);
+ when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
+ when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
+ mController.displayPreference(mScreen);
+ shadowOf(Looper.getMainLooper()).idle();
+ mPreference.setSummary("test");
+
+ mController.onActiveDeviceChanged(mCachedDevice1, BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
+ assertThat(mPreference.getSummary().toString())
+ .isEqualTo(
+ mContext.getString(
+ R.string.audio_sharing_call_audio_description, TEST_DEVICE_NAME1));
+ }
+
+ @Test
+ public void displayPreference_fallbackDeviceInSharing_showCorrectSummary() {
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
- when(mCachedDevice1.getMemberDevice()).thenReturn(ImmutableSet.of(mCachedDevice2));
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCachedDevice3.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice3.getDevice()).thenReturn(mDevice3);
- when(mCachedDevice3.getName()).thenReturn(TEST_DEVICE_NAME2);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
- when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
- when(mCacheManager.findDevice(mDevice3)).thenReturn(mCachedDevice3);
+ when(mCachedDevice3.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true);
when(mBroadcast.isEnabled(any())).thenReturn(true);
when(mAssistant.getAllConnectedDevices())
.thenReturn(ImmutableList.of(mDevice1, mDevice2, mDevice3));
@@ -379,14 +405,24 @@
}
@Test
- public void displayPreference_noFallbackDeviceInSharing_showEmptySummary() {
+ public void displayPreference_activeDeviceInSharing_showCorrectSummary() {
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
+ when(mCachedDevice1.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true);
when(mBroadcast.isEnabled(any())).thenReturn(true);
- when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
+ when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1, mDevice2));
+ when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
+ mController.displayPreference(mScreen);
+ shadowOf(Looper.getMainLooper()).idle();
+ assertThat(mPreference.getSummary().toString())
+ .isEqualTo(mContext.getString(
+ R.string.audio_sharing_call_audio_description, TEST_DEVICE_NAME1));
+ }
+
+ @Test
+ public void displayPreference_noFallbackDeviceOrActiveInSharing_showEmptySummary() {
+ Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID2);
+ when(mBroadcast.isEnabled(any())).thenReturn(true);
+ when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1, mDevice2));
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
mController.displayPreference(mScreen);
shadowOf(Looper.getMainLooper()).idle();
@@ -394,7 +430,7 @@
}
@Test
- public void displayPreference_noFallbackDevice_showEmptySummary() {
+ public void displayPreference_noFallbackOrActiveDevice_showEmptySummary() {
Settings.Secure.putInt(
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
when(mBroadcast.isEnabled(any())).thenReturn(true);
@@ -412,17 +448,11 @@
ShadowAlertDialogCompat.reset();
}
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice2.getName()).thenReturn(TEST_DEVICE_NAME2);
- when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
- when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
- mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
+ mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(
+ List.of(mDevice1, mDevice2, mDevice3));
when(mBroadcast.isEnabled(any())).thenReturn(true);
- when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1, mDevice2));
+ when(mAssistant.getAllConnectedDevices()).thenReturn(
+ ImmutableList.of(mDevice1, mDevice2, mDevice3));
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
mController.init(mParentFragment);
mController.displayPreference(mScreen);
@@ -449,14 +479,9 @@
@Test
public void logCallAudioDeviceChange_changeCallAudioToEarlierConnectedDevice() {
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
- when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
- mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
- mController.logCallAudioDeviceChange(TEST_DEVICE_GROUP_ID1, mCachedDevice2);
+ mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(
+ List.of(mDevice1, mDevice2, mDevice3));
+ mController.logCallAudioDeviceChange(TEST_DEVICE_GROUP_ID1, mCachedDevice3);
verify(mFeatureFactory.metricsFeatureProvider)
.action(
mContext,
@@ -468,13 +493,8 @@
@Test
public void logCallAudioDeviceChange_changeCallAudioToLaterConnectedDevice() {
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
- when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
- mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
+ mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(
+ List.of(mDevice1, mDevice2, mDevice3));
mController.logCallAudioDeviceChange(TEST_DEVICE_GROUP_ID2, mCachedDevice1);
verify(mFeatureFactory.metricsFeatureProvider)
.action(
@@ -487,14 +507,8 @@
@Test
public void logCallAudioDeviceChange_deviceNotFoundInRecentList_unknownChangeType() {
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice2.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID2);
- when(mCachedDevice2.getDevice()).thenReturn(mDevice2);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
- when(mCacheManager.findDevice(mDevice2)).thenReturn(mCachedDevice2);
- mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1));
- mController.logCallAudioDeviceChange(TEST_DEVICE_GROUP_ID1, mCachedDevice2);
+ mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(List.of(mDevice1, mDevice2));
+ mController.logCallAudioDeviceChange(TEST_DEVICE_GROUP_ID1, mCachedDevice3);
verify(mFeatureFactory.metricsFeatureProvider)
.action(
mContext,
@@ -505,10 +519,6 @@
@Test
public void testBluetoothLeBroadcastAssistantCallbacks_updateSummary() {
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
Settings.Secure.putInt(
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
when(mBroadcast.isEnabled(any())).thenReturn(true);
@@ -532,10 +542,6 @@
@Test
public void testBluetoothLeBroadcastAssistantCallbacks_doNothing() {
- when(mCachedDevice1.getGroupId()).thenReturn(TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.getDevice()).thenReturn(mDevice1);
- when(mCachedDevice1.getName()).thenReturn(TEST_DEVICE_NAME1);
- when(mCacheManager.findDevice(mDevice1)).thenReturn(mCachedDevice1);
Settings.Secure.putInt(
mContentResolver, TEST_SETTINGS_KEY, BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
when(mBroadcast.isEnabled(any())).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItemTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItemTest.java
index b23882d..27bff76 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItemTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceItemTest.java
@@ -78,4 +78,13 @@
assertThat(itemFromParcel.getGroupId()).isEqualTo(TEST_GROUP_ID);
assertThat(itemFromParcel.isActive()).isEqualTo(TEST_IS_ACTIVE);
}
+
+ @Test
+ public void toString_correctValue() {
+ AudioSharingDeviceItem item =
+ new AudioSharingDeviceItem(TEST_NAME, TEST_GROUP_ID, TEST_IS_ACTIVE);
+ assertThat(item.toString()).isEqualTo(
+ "AudioSharingDeviceItem groupId = " + TEST_GROUP_ID + ", isActive = "
+ + TEST_IS_ACTIVE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/development/DesktopModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DesktopModePreferenceControllerTest.java
index 7fe9377..b9f5621 100644
--- a/tests/robotests/src/com/android/settings/development/DesktopModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DesktopModePreferenceControllerTest.java
@@ -17,9 +17,9 @@
package com.android.settings.development;
import static android.provider.Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_MODE_FEATURES;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_ON;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_OFF;
-import static android.window.flags.DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_ON;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_OFF;
+import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET;
import static com.google.common.truth.Truth.assertThat;
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysControllerTest.java
index 8ac5a5d..d16f697 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysControllerTest.java
@@ -18,39 +18,59 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.hardware.input.InputSettings;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
+import android.widget.RadioGroup;
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.keyboard.Flags;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowLooper;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
com.android.settings.testutils.shadow.ShadowFragment.class,
+ ShadowAlertDialogCompat.class,
})
public class KeyboardAccessibilityBounceKeysControllerTest {
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+ private static final String PREFERENCE_KEY = "accessibility_bounce_keys";
+ @Mock
+ private Preference mPreference;
private Context mContext;
private KeyboardAccessibilityBounceKeysController mKeyboardAccessibilityBounceKeysController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
+ mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
mKeyboardAccessibilityBounceKeysController = new KeyboardAccessibilityBounceKeysController(
mContext,
- "accessibility_bounce_keys");
+ PREFERENCE_KEY);
+ when(mPreference.getKey()).thenReturn(PREFERENCE_KEY);
}
@Test
@@ -82,4 +102,28 @@
assertThat(isEnabled).isFalse();
}
+
+ @Test
+ public void handlePreferenceTreeClick_dialogShows() {
+ mKeyboardAccessibilityBounceKeysController.handlePreferenceTreeClick(mPreference);
+
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ assertThat(alertDialog.isShowing()).isTrue();
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_performClickOn200_updatesBounceKeysThreshold() {
+ mKeyboardAccessibilityBounceKeysController.handlePreferenceTreeClick(mPreference);
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ RadioGroup radioGroup = alertDialog.findViewById(R.id.bounce_key_value_group);
+ radioGroup.check(R.id.bounce_key_value_200);
+
+ alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
+ ShadowLooper.idleMainLooper();
+
+ assertThat(alertDialog.isShowing()).isFalse();
+ int threshold = InputSettings.getAccessibilityBounceKeysThreshold(mContext);
+ assertThat(threshold).isEqualTo(200);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
index 458bc93..7380c66 100644
--- a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
@@ -28,6 +28,10 @@
import android.content.pm.UserInfo;
import android.os.UserHandle;
import android.os.UserManager;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
@@ -36,6 +40,7 @@
import com.android.settings.testutils.shadow.ShadowNfcAdapter;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -58,6 +63,9 @@
private Context mContext;
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
@Mock
private PackageManager mPackageManager;
@@ -98,7 +106,19 @@
}
@Test
- public void getNonIndexableKey_primaryUser_returnsTrue() {
+ @RequiresFlagsEnabled(android.permission.flags.Flags.FLAG_WALLET_ROLE_ENABLED)
+ public void getNonIndexableKey_primaryUser_returnsFalse_walletRoleEnabled() {
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
+
+ final List<String> niks =
+ PaymentSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ assertThat(niks).containsAtLeast(FOREGROUND_KEY, PAYMENT_KEY);
+ }
+
+ @Test
+ @RequiresFlagsDisabled(android.permission.flags.Flags.FLAG_WALLET_ROLE_ENABLED)
+ public void getNonIndexableKey_primaryUser_returnsTrue_walletRoleDisabled() {
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
final List<String> niks =
diff --git a/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java b/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
index f8e790f..656fa27 100644
--- a/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/language/LanguagePreferenceControllerTest.java
@@ -16,7 +16,6 @@
package com.android.settings.language;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.content.ComponentName;
@@ -41,10 +40,9 @@
}
@Test
- public void getAvailabilityStatus_featureFlagOff_LanguageAndInputSettingsActivitydisabled() {
+ public void getAvailabilityStatus_featureFlagOff_LanguageSettingsActivitydisabled() {
mController.getAvailabilityStatus();
- assertFalse(isActivityEnable(mContext, Settings.LanguageAndInputSettingsActivity.class));
assertTrue(isActivityEnable(mContext, Settings.LanguageSettingsActivity.class));
}