Merge "Sound screen migration" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 97a7e23..a11acb0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4543,6 +4543,14 @@
<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 your keyboard to control the pointer</string>
+ <!-- Title for the 'Mouse reverse scrolling' preference switch, which reverses the direction of mouse scroll wheels so that moving the wheel up scrolls the content down. [CHAR LIMIT=60] -->
+ <string name="mouse_reverse_vertical_scrolling">Mouse reverse scrolling</string>
+ <!-- Summary text for the 'Mouse reverse scrolling' preference switch indicating to users that when the setting is enabled that scrolling up with their mouse wheel will move the page content down. [CHAR LIMIT=NONE] -->
+ <string name="mouse_reverse_vertical_scrolling_summary">Scroll up to move the page down</string>
+ <!-- Title for the 'Swap buttons' preference switch, which swaps the left and right buttons of connected mice so that right click will be the primary action button and left clicking will be the secondary action, for example showing the context menu. [CHAR LIMIT=60] -->
+ <string name="mouse_swap_primary_button">Swap left and right buttons</string>
+ <!-- Summary text for the 'Swap buttons' preference switch indicating to users that when this switch is enabled, their left click will behave as though it is the right click (secondary action) and that the right click will be the primary action. [CHAR LIMIT=NONE] -->
+ <string name="mouse_swap_primary_button_summary">Use the left mouse button as your right</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] -->
@@ -5639,7 +5647,7 @@
<!-- Title for the preference to change video caption locale. [CHAR LIMIT=35] -->
<string name="captioning_locale">Language</string>
<!-- Title for the preference to change video caption text size. [CHAR LIMIT=35] -->
- <string name="captioning_text_size">Text size</string>
+ <string name="captioning_text_size">Caption size</string>
<!-- Title for the preference category containing video caption property presets. [CHAR LIMIT=35] -->
<string name="captioning_preset">Caption style</string>
<!-- Title for the preference catgeory containing custom video caption properties. [CHAR LIMIT=35] -->
diff --git a/res/xml/accessibility_edit_shortcuts.xml b/res/xml/accessibility_edit_shortcuts.xml
index bb55527..77c09da 100644
--- a/res/xml/accessibility_edit_shortcuts.xml
+++ b/res/xml/accessibility_edit_shortcuts.xml
@@ -90,11 +90,5 @@
settings:allowDividerAbove="false"
settings:allowDividerBelow="false"
settings:controller="com.android.settings.accessibility.shortcuts.TripleTapShortcutOptionController" />
- <!--
- LINT.ThenChange(
- /src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java:shortcut_type_ui_order,
- /src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java:shortcut_type_ui_order,
- /src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java:shortcut_type_ui_order
- )
- -->
+ <!-- LINT.ThenChange(/src/com/android/settings/accessibility/AccessibilityUtil.java:shortcut_type_ui_order) -->
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml
index 7e94944..2f7c7fc 100644
--- a/res/xml/trackpad_settings.xml
+++ b/res/xml/trackpad_settings.xml
@@ -62,6 +62,20 @@
android:selectable="false"
settings:controller="com.android.settings.inputmethod.TrackpadPointerSpeedPreferenceController"/>
+ <SwitchPreferenceCompat
+ android:key="mouse_reverse_vertical_scrolling"
+ android:title="@string/mouse_reverse_vertical_scrolling"
+ android:summary="@string/mouse_reverse_vertical_scrolling_summary"
+ settings:controller="com.android.settings.inputmethod.MouseReverseVerticalScrollingPreferenceController"
+ android:order="45"/>
+
+ <SwitchPreferenceCompat
+ android:key="mouse_swap_primary_button"
+ android:title="@string/mouse_swap_primary_button"
+ android:summary="@string/mouse_swap_primary_button_summary"
+ settings:controller="com.android.settings.inputmethod.MouseSwapPrimaryButtonPreferenceController"
+ android:order="47"/>
+
<Preference
android:fragment="com.android.settings.inputmethod.PointerTouchpadFragment"
android:key="pointer_and_touchpad"
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
index de3cb8a..c613181 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
@@ -64,7 +64,6 @@
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
-import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.settings.R;
@@ -490,11 +489,10 @@
static List<TutorialPage> createShortcutTutorialPages(
@NonNull Context context, int shortcutTypes, @NonNull CharSequence featureName,
boolean inSetupWizard) {
- // LINT.IfChange(shortcut_type_ui_order)
final List<TutorialPage> tutorialPages = new ArrayList<>();
int buttonMode = ShortcutUtils.getButtonMode(context, context.getUserId());
- for (int shortcutType: ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType: AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if ((shortcutTypes & shortcutType) == 0) {
continue;
}
@@ -506,7 +504,6 @@
createShortcutTutorialPage(
context, shortcutType, buttonMode, featureName, inSetupWizard));
}
- // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order)
return tutorialPages;
}
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index 5e178db..82d3281 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -50,7 +50,6 @@
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
-import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.settings.R;
@@ -66,6 +65,16 @@
/** Provides utility methods to accessibility settings only. */
public final class AccessibilityUtil {
+ // LINT.IfChange(shortcut_type_ui_order)
+ static final int[] SHORTCUTS_ORDER_IN_UI = {
+ QUICK_SETTINGS,
+ SOFTWARE, // FAB displays before gesture. Navbar displays without gesture.
+ GESTURE,
+ HARDWARE,
+ TWOFINGER_DOUBLETAP,
+ TRIPLETAP
+ };
+ // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order)
private AccessibilityUtil(){}
@@ -344,7 +353,7 @@
*/
static boolean hasValuesInSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) {
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()) {
if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
@@ -395,7 +404,7 @@
static int getUserShortcutTypesFromSettings(Context context,
@NonNull ComponentName componentName) {
int shortcutTypes = DEFAULT;
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()) {
if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
@@ -511,8 +520,7 @@
public static CharSequence getShortcutSummaryList(Context context, int shortcutTypes) {
final List<CharSequence> list = new ArrayList<>();
- // LINT.IfChange(shortcut_type_ui_order)
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()
&& (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
@@ -548,7 +556,6 @@
list.sort(CharSequence::compare);
return CaseMap.toTitle().wholeString().noLowercase().apply(Locale.getDefault(), /* iter= */
null, LocaleUtils.getConcatenatedString(list));
- // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order)
}
@VisibleForTesting
diff --git a/src/com/android/settings/accessibility/AutoclickUtils.java b/src/com/android/settings/accessibility/AutoclickUtils.java
index 89f2ceb..eec89d6 100644
--- a/src/com/android/settings/accessibility/AutoclickUtils.java
+++ b/src/com/android/settings/accessibility/AutoclickUtils.java
@@ -16,18 +16,11 @@
package com.android.settings.accessibility;
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import android.annotation.IntDef;
-import android.annotation.PluralsRes;
import android.annotation.StringRes;
import android.content.Context;
-import android.content.res.Resources;
-import com.android.settings.R;
import com.android.settingslib.utils.StringUtil;
-import java.lang.annotation.Retention;
import java.util.HashMap;
import java.util.Map;
@@ -52,16 +45,6 @@
*/
static final int AUTOCLICK_DELAY_STEP = 100;
- @Retention(SOURCE)
- @IntDef({
- Quantity.ONE,
- Quantity.FEW
- })
- private @interface Quantity {
- int ONE = 1;
- int FEW = 3;
- }
-
/**
* Gets string that should be used for provided autoclick delay.
*
@@ -73,13 +56,12 @@
*/
public static CharSequence getAutoclickDelaySummary(Context context,
@StringRes int id, int delayMillis) {
- final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.FEW;
final float delaySecond = (float) delayMillis / 1000;
// Only show integer when delay time is 1.
final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
Map<String, Object> arguments = new HashMap<>();
- arguments.put("count", quantity);
+ arguments.put("count", delaySecond);
arguments.put("time", String.format(decimalFormat, delaySecond));
return StringUtil.getIcuPluralsString(context, arguments, id);
}
diff --git a/src/com/android/settings/accessibility/PreferredShortcuts.java b/src/com/android/settings/accessibility/PreferredShortcuts.java
index c3e64ab..9006609 100644
--- a/src/com/android/settings/accessibility/PreferredShortcuts.java
+++ b/src/com/android/settings/accessibility/PreferredShortcuts.java
@@ -30,7 +30,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
-import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
@@ -123,7 +122,7 @@
public static void updatePreferredShortcutsFromSettings(
@NonNull Context context, @NonNull Set<String> components) {
final Map<Integer, Set<String>> shortcutTypeToTargets = new ArrayMap<>();
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!Flags.a11yQsShortcut()
&& shortcutType == QUICK_SETTINGS) {
// Skip saving quick setting as preferred shortcut option when flag is not enabled
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index ee49450..68089d5 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -55,7 +55,6 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat;
-import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags;
@@ -740,7 +739,7 @@
@VisibleForTesting
static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) {
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if ((shortcutTypes & shortcutType) == 0) {
continue;
}
@@ -791,7 +790,7 @@
private static int getUserShortcutTypeFromSettings(Context context) {
int shortcutTypes = DEFAULT;
- for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if ((shortcutType & (TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE | TRIPLETAP))
== shortcutType
&& !android.view.accessibility.Flags.a11yQsShortcut()) {
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
index 468ac3d..11a337f 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
@@ -219,7 +219,7 @@
if (lead != null) {
String addr = lead.getDevice().getAnonymizedAddress();
Log.d(TAG, "Set call audio device: " + addr);
- lead.setActive();
+ AudioSharingUtils.setPrimary(mContext, lead);
logCallAudioDeviceChange(currentGroupId, lead);
} else {
Log.d(TAG, "Skip set call audio device: no lead");
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceController.java
index db2c7b2..47623e4 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceController.java
@@ -390,7 +390,7 @@
Log.d(TAG, "onDeviceClick, set active in call mode");
CachedBluetoothDevice cachedDevice =
((BluetoothDevicePreference) preference).getBluetoothDevice();
- cachedDevice.setActive();
+ AudioSharingUtils.setPrimary(mContext, cachedDevice);
}
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_AUDIO_SHARING_DEVICE_CLICK,
isCallMode);
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandler.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandler.java
index 396144a..0c34487 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandler.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandler.java
@@ -192,7 +192,7 @@
// If this method is called with user triggered, e.g. manual click on the
// "Connected devices" page, we need call setActive for the device, since user
// intend to switch active device for the call.
- cachedDevice.setActive();
+ AudioSharingUtils.setPrimary(mContext, cachedDevice);
}
return;
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingUtils.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingUtils.java
index a662809..592c8eb 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingUtils.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingUtils.java
@@ -21,6 +21,7 @@
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_PAGE_ID;
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_SOURCE_PAGE_ID;
import static com.android.settings.connecteddevice.audiosharing.AudioSharingUtils.MetricKey.METRIC_KEY_USER_TRIGGERED;
+import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID;
import static java.util.stream.Collectors.toList;
@@ -28,6 +29,7 @@
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeBroadcastMetadata;
import android.content.Context;
+import android.provider.Settings;
import android.util.Log;
import android.util.Pair;
import android.widget.Toast;
@@ -44,6 +46,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.bluetooth.VolumeControlProfile;
+import com.android.settingslib.flags.Flags;
import java.util.ArrayList;
import java.util.Comparator;
@@ -344,6 +347,27 @@
return vc != null && vc.isProfileReady();
}
+ /** Set {@link CachedBluetoothDevice} as primary device for call audio */
+ public static void setPrimary(@NonNull Context context,
+ @Nullable CachedBluetoothDevice cachedDevice) {
+ if (cachedDevice == null) return;
+ cachedDevice.setActive();
+ if (Flags.audioSharingHysteresisModeFix()) {
+ int groupId = BluetoothUtils.getGroupId(cachedDevice);
+ // TODO: use real key name in SettingsProvider
+ int userPreferredId = Settings.Secure.getInt(
+ context.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ if (groupId != userPreferredId) {
+ Settings.Secure.putInt(
+ context.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ groupId);
+ }
+ }
+ }
+
/**
* Build audio sharing dialog log event data
*
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index 6df100c..421963e 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -84,7 +84,7 @@
for (int simSlotNumber = 0; simSlotNumber < mPreferenceList.size(); simSlotNumber++) {
final Preference simStatusPreference = mPreferenceList.get(simSlotNumber);
simStatusPreference.setTitle(getPreferenceTitle(simSlotNumber));
- simStatusPreference.setSummary(getPhoneNumber(simSlotNumber));
+ setPhoneNumber(simSlotNumber);
}
}
@@ -93,24 +93,15 @@
return true;
}
- private CharSequence getFirstPhoneNumber() {
- final List<SubscriptionInfo> subscriptionInfoList =
- mSubscriptionManager.getActiveSubscriptionInfoList();
- if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
- return mContext.getText(R.string.device_info_default);
- }
-
- // For now, We only return first result for slice view.
- return getFormattedPhoneNumber(subscriptionInfoList.get(0));
- }
-
- private CharSequence getPhoneNumber(int simSlot) {
+ private void setPhoneNumber(int simSlot) {
+ final Preference simStatusPreference = mPreferenceList.get(simSlot);
final SubscriptionInfo subscriptionInfo = getSubscriptionInfo(simSlot);
+ simStatusPreference.setEnabled(subscriptionInfo != null);
if (subscriptionInfo == null) {
- return mContext.getText(R.string.device_info_default);
+ simStatusPreference.setSummary(mContext.getString(R.string.device_info_not_available));
+ } else {
+ simStatusPreference.setSummary(getFormattedPhoneNumber(subscriptionInfo));
}
-
- return getFormattedPhoneNumber(subscriptionInfo);
}
private CharSequence getPreferenceTitle(int simSlot) {
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 99441b0..87e5560 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -251,6 +251,8 @@
Bundle savedInstanceState) {
RecyclerView recyclerView = super.onCreateRecyclerView(inflater, parent,
savedInstanceState);
+ recyclerView.setVerticalScrollBarEnabled(false);
+ recyclerView.setHorizontalScrollBarEnabled(false);
recyclerView.setPadding(mPaddingHorizontal, 0, mPaddingHorizontal, 0);
return recyclerView;
}
diff --git a/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceController.java b/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceController.java
new file mode 100644
index 0000000..977e906
--- /dev/null
+++ b/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceController.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class MouseReverseVerticalScrollingPreferenceController extends TogglePreferenceController {
+
+ public MouseReverseVerticalScrollingPreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return InputSettings.isMouseReverseVerticalScrollingEnabled(mContext);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ InputSettings.setMouseReverseVerticalScrolling(mContext, isChecked);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!InputSettings.isMouseReverseVerticalScrollingFeatureFlagEnabled()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_system;
+ }
+}
diff --git a/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceController.java b/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceController.java
new file mode 100644
index 0000000..88199d8
--- /dev/null
+++ b/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceController.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.inputmethod;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class MouseSwapPrimaryButtonPreferenceController extends TogglePreferenceController {
+
+ public MouseSwapPrimaryButtonPreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return InputSettings.isMouseSwapPrimaryButtonEnabled(mContext);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ InputSettings.setMouseSwapPrimaryButton(mContext, isChecked);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!InputSettings.isMouseSwapPrimaryButtonFeatureFlagEnabled()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_system;
+ }
+}
diff --git a/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt b/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt
index 2c0955b..b94f52c 100644
--- a/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt
+++ b/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt
@@ -38,9 +38,17 @@
finish()
}
- private fun isValidCall() =
- PasswordUtils.getCallingAppPackageName(activityToken) ==
+ private fun isValidCall(): Boolean {
+ val callingAppPackageName = PasswordUtils.getCallingAppPackageName(activityToken)
+ if (callingAppPackageName == packageName) {
+ // SettingsIntelligence sometimes starts SearchResultTrampoline first, in this case,
+ // SearchResultTrampoline checks if the call is valid, then SearchResultTrampoline will
+ // start this activity, allow this use case.
+ return true
+ }
+ return callingAppPackageName ==
featureFactory.searchFeatureProvider.getSettingsIntelligencePkgName(this)
+ }
companion object {
@VisibleForTesting
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java
index 61bc8aa..0bc0b94 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java
@@ -18,6 +18,7 @@
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID;
import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.EXTRA_BLUETOOTH_DEVICE;
import static com.google.common.truth.Truth.assertThat;
@@ -37,6 +38,7 @@
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeBroadcastAssistant;
import android.bluetooth.BluetoothLeBroadcastMetadata;
@@ -50,6 +52,7 @@
import android.os.Bundle;
import android.os.Looper;
import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
import android.util.Pair;
import androidx.annotation.NonNull;
@@ -587,6 +590,10 @@
@Test
public void testInCallState_showCallStateTitleAndSetActiveOnDeviceClick() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
+ mSetFlagsRule.disableFlags(Flags.FLAG_AUDIO_SHARING_HYSTERESIS_MODE_FIX);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
mController.displayPreference(mScreen);
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
@@ -599,6 +606,32 @@
BluetoothDevicePreference preference = createBluetoothDevicePreference();
mController.onDeviceClick(preference);
verify(mCachedDevice).setActive();
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID)).isEqualTo(
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ }
+
+ @Test
+ public void testInCallState_enableHysteresisFix_setAndSaveActiveOnDeviceClick() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
+ mSetFlagsRule.enableFlags(Flags.FLAG_AUDIO_SHARING_HYSTERESIS_MODE_FIX);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ mController.displayPreference(mScreen);
+
+ mAudioManager.setMode(AudioManager.MODE_IN_CALL);
+ mController.onAudioModeChanged();
+ shadowOf(Looper.getMainLooper()).idle();
+
+ BluetoothDevicePreference preference = createBluetoothDevicePreference();
+ when(mCachedDevice.getGroupId()).thenReturn(1);
+ mController.onDeviceClick(preference);
+ verify(mCachedDevice).setActive();
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID)).isEqualTo(1);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java
index ad6dd7f..c96a086 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java
@@ -16,6 +16,8 @@
package com.android.settings.connecteddevice.audiosharing;
+import static com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast.BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -32,6 +34,7 @@
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeBroadcast;
import android.bluetooth.BluetoothLeBroadcastMetadata;
@@ -43,6 +46,7 @@
import android.os.Bundle;
import android.os.Looper;
import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
import android.util.Pair;
import androidx.fragment.app.DialogFragment;
@@ -193,6 +197,10 @@
@Test
public void handleUserTriggeredDeviceConnected_inCall_setActive() {
+ mSetFlagsRule.disableFlags(Flags.FLAG_AUDIO_SHARING_HYSTERESIS_MODE_FIX);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL);
setUpBroadcast(true);
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
@@ -201,6 +209,29 @@
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
shadowOf(Looper.getMainLooper()).idle();
verify(mCachedDevice1).setActive();
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID)).isEqualTo(
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ }
+
+ @Test
+ public void handleUserTriggeredDeviceConnected_inCall_enableHysteresisFix_setAndSaveActive() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_AUDIO_SHARING_HYSTERESIS_MODE_FIX);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL);
+ setUpBroadcast(true);
+ ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
+ when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
+ when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
+ mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
+ shadowOf(Looper.getMainLooper()).idle();
+ verify(mCachedDevice1).setActive();
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ BLUETOOTH_LE_BROADCAST_PRIMARY_DEVICE_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID)).isEqualTo(1);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceControllerTest.java
new file mode 100644
index 0000000..a962b1a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.inputmethod;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+import android.os.UserHandle;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.hardware.input.Flags;
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/** Tests for {@link MouseReverseVerticalScrollingPreferenceController} */
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {
+ com.android.settings.testutils.shadow.ShadowSystemSettings.class,
+})
+public class MouseReverseVerticalScrollingPreferenceControllerTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
+ private static final String PREFERENCE_KEY = "mouse_reverse_vertical_scrolling";
+ private static final String SETTING_KEY = Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING;
+
+ private Context mContext;
+ private MouseReverseVerticalScrollingPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new MouseReverseVerticalScrollingPreferenceController(
+ mContext, PREFERENCE_KEY);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void getAvailabilityStatus_expected() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void getAvailabilityStatus_flagIsDisabled_notSupport() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void setChecked_true_shouldReturn1() {
+ mController.setChecked(true);
+
+ boolean isEnabled = InputSettings.isMouseReverseVerticalScrollingEnabled(mContext);
+ assertThat(isEnabled).isTrue();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void setChecked_false_shouldReturn0() {
+ mController.setChecked(false);
+
+ boolean isEnabled = InputSettings.isMouseReverseVerticalScrollingEnabled(mContext);
+ assertThat(isEnabled).isFalse();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void isChecked_providerPutInt1_returnTrue() {
+ Settings.System.putIntForUser(
+ mContext.getContentResolver(),
+ SETTING_KEY,
+ 1,
+ UserHandle.USER_CURRENT);
+
+ boolean result = mController.isChecked();
+
+ assertThat(result).isTrue();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_REVERSE_VERTICAL_SCROLLING)
+ public void isChecked_providerPutInt0_returnFalse() {
+ Settings.System.putIntForUser(
+ mContext.getContentResolver(),
+ SETTING_KEY,
+ 0,
+ UserHandle.USER_CURRENT);
+
+ boolean result = mController.isChecked();
+
+ assertThat(result).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceControllerTest.java
new file mode 100644
index 0000000..fe401f2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.inputmethod;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+import android.os.UserHandle;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.hardware.input.Flags;
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/** Tests for {@link MouseReverseVerticalScrollingPreferenceController} */
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {
+ com.android.settings.testutils.shadow.ShadowSystemSettings.class,
+})
+public class MouseSwapPrimaryButtonPreferenceControllerTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
+ private static final String PREFERENCE_KEY = "mouse_swap_primary_button";
+ private static final String SETTING_KEY = Settings.System.MOUSE_SWAP_PRIMARY_BUTTON;
+
+ private Context mContext;
+ private MouseSwapPrimaryButtonPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new MouseSwapPrimaryButtonPreferenceController(
+ mContext, PREFERENCE_KEY);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void getAvailabilityStatus_expected() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void getAvailabilityStatus_flagIsDisabled_notSupport() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void setChecked_true_shouldReturn1() {
+ mController.setChecked(true);
+
+ boolean isEnabled = InputSettings.isMouseSwapPrimaryButtonEnabled(mContext);
+ assertThat(isEnabled).isTrue();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void setChecked_false_shouldReturn0() {
+ mController.setChecked(false);
+
+ boolean isEnabled = InputSettings.isMouseSwapPrimaryButtonEnabled(mContext);
+ assertThat(isEnabled).isFalse();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void isChecked_providerPutInt1_returnTrue() {
+ Settings.System.putIntForUser(
+ mContext.getContentResolver(),
+ SETTING_KEY,
+ 1,
+ UserHandle.USER_CURRENT);
+
+ boolean result = mController.isChecked();
+
+ assertThat(result).isTrue();
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_MOUSE_SWAP_PRIMARY_BUTTON)
+ public void isChecked_providerPutInt0_returnFalse() {
+ Settings.System.putIntForUser(
+ mContext.getContentResolver(),
+ SETTING_KEY,
+ 0,
+ UserHandle.USER_CURRENT);
+
+ boolean result = mController.isChecked();
+
+ assertThat(result).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 9a5399c..05e2f24 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -37,6 +37,7 @@
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settings.R;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.Before;
@@ -135,25 +136,23 @@
}
@Test
- public void getSummary_cannotGetActiveSubscriptionInfo_shouldShowUnknown() {
+ public void getSummary_cannotGetActiveSubscriptionInfo_shouldShowNotAvailable() {
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
mController.displayPreference(mScreen);
mController.updateState(mPreference);
- verify(mPreference).setSummary(ResourcesUtils.getResourcesString(
- mContext, "device_info_default"));
+ verify(mPreference).setSummary(mContext.getString(R.string.device_info_not_available));
}
@Test
- public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() {
+ public void getSummary_getEmptySubscriptionInfo_shouldShowNotAvailable() {
List<SubscriptionInfo> infos = new ArrayList<>();
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(infos);
mController.displayPreference(mScreen);
mController.updateState(mPreference);
- verify(mPreference).setSummary(ResourcesUtils.getResourcesString(
- mContext, "device_info_default"));
+ verify(mPreference).setSummary(mContext.getString(R.string.device_info_not_available));
}
}