diff --git a/aconfig/catalyst/sound_screen.aconfig b/aconfig/catalyst/sound_screen.aconfig
new file mode 100644
index 00000000000..ea5f77131dc
--- /dev/null
+++ b/aconfig/catalyst/sound_screen.aconfig
@@ -0,0 +1,9 @@
+package: "com.android.settings.flags"
+container: "system"
+
+flag {
+ name: "catalyst_sound_screen"
+ namespace: "android_settings"
+ description: "Flag for sound and vibration page"
+ bug: "323791114"
+}
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c6d44c180db..a11acb09586 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4543,6 +4543,14 @@
Mouse keys
Use your keyboard to control the pointer
+
+ Mouse reverse scrolling
+
+ Scroll up to move the page down
+
+ Swap left and right buttons
+
+ Use the left mouse button as your right
Keyboard shortcuts
diff --git a/res/xml/accessibility_color_and_motion.xml b/res/xml/accessibility_color_and_motion.xml
index a500b72d958..6b47a9d62f5 100644
--- a/res/xml/accessibility_color_and_motion.xml
+++ b/res/xml/accessibility_color_and_motion.xml
@@ -39,6 +39,8 @@
settings:keywords="@string/keywords_color_inversion"
settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
+
-
+
\ No newline at end of file
diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml
index 7e9494476fe..2f7c7fcdd4a 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"/>
+
+
+
+
createShortcutTutorialPages(
@NonNull Context context, int shortcutTypes, @NonNull CharSequence featureName,
boolean inSetupWizard) {
- // LINT.IfChange(shortcut_type_ui_order)
final List 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 @@ public final class AccessibilityShortcutsTutorial {
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 5e178db2f89..82d32815bf5 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -50,7 +50,6 @@ import androidx.annotation.NonNull;
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 @@ import java.util.StringJoiner;
/** 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 @@ public final class AccessibilityUtil {
*/
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 @@ public final class AccessibilityUtil {
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 final class AccessibilityUtil {
public static CharSequence getShortcutSummaryList(Context context, int shortcutTypes) {
final List 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 @@ public final class AccessibilityUtil {
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 89f2ceb57f9..eec89d616af 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 @@ public final class AutoclickUtils {
*/
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 final class AutoclickUtils {
*/
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 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 c3e64ab9ab0..9006609091d 100644
--- a/src/com/android/settings/accessibility/PreferredShortcuts.java
+++ b/src/com/android/settings/accessibility/PreferredShortcuts.java
@@ -30,7 +30,6 @@ import android.view.accessibility.Flags;
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 final class PreferredShortcuts {
public static void updatePreferredShortcutsFromSettings(
@NonNull Context context, @NonNull Set components) {
final Map> 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 ee49450f82d..68089d50d7e 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -55,7 +55,6 @@ import androidx.preference.Preference;
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 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@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 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index 6df100ca4ec..421963eb31c 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -84,7 +84,7 @@ public class PhoneNumberPreferenceController extends BasePreferenceController {
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 @@ public class PhoneNumberPreferenceController extends BasePreferenceController {
return true;
}
- private CharSequence getFirstPhoneNumber() {
- final List 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 99441b0cc50..87e5560c959 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -251,6 +251,8 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
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 00000000000..977e906e2a5
--- /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 00000000000..88199d8d64e
--- /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/notification/SoundScreen.kt b/src/com/android/settings/notification/SoundScreen.kt
new file mode 100644
index 00000000000..ecb0c85ed5d
--- /dev/null
+++ b/src/com/android/settings/notification/SoundScreen.kt
@@ -0,0 +1,47 @@
+/*
+ * 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.notification
+
+import android.content.Context
+import androidx.fragment.app.Fragment
+import com.android.settings.R
+import com.android.settings.flags.Flags
+import com.android.settingslib.metadata.ProvidePreferenceScreen
+import com.android.settingslib.metadata.preferenceHierarchy
+import com.android.settingslib.preference.PreferenceScreenCreator
+
+@ProvidePreferenceScreen
+class SoundScreen : PreferenceScreenCreator {
+ override val key: String
+ get() = KEY
+
+ override val title: Int
+ get() = R.string.sound_settings
+
+ override val keywords: Int
+ get() = R.string.keywords_sounds
+
+ override fun isFlagEnabled(context: Context): Boolean = Flags.catalystSoundScreen()
+
+ override fun fragmentClass(): Class? = SoundSettings::class.java
+
+ override fun getPreferenceHierarchy(context: Context) =
+ preferenceHierarchy(this) {}
+
+ companion object {
+ const val KEY = "sound_screen"
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 4575708bbbd..596f19bc62a 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -29,6 +29,8 @@ import android.os.UserHandle;
import android.preference.SeekBarVolumizer;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
@@ -193,21 +195,23 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
@Override
public void onAttach(Context context) {
super.onAttach(context);
- ArrayList volumeControllers = new ArrayList<>();
- volumeControllers.add(use(AlarmVolumePreferenceController.class));
- volumeControllers.add(use(MediaVolumePreferenceController.class));
- volumeControllers.add(use(SeparateRingVolumePreferenceController.class));
- volumeControllers.add(use(NotificationVolumePreferenceController.class));
- volumeControllers.add(use(CallVolumePreferenceController.class));
+ if (!isCatalystEnabled()) {
+ ArrayList volumeControllers = new ArrayList<>();
+ volumeControllers.add(use(AlarmVolumePreferenceController.class));
+ volumeControllers.add(use(MediaVolumePreferenceController.class));
+ volumeControllers.add(use(SeparateRingVolumePreferenceController.class));
+ volumeControllers.add(use(NotificationVolumePreferenceController.class));
+ volumeControllers.add(use(CallVolumePreferenceController.class));
- use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference ->
- onPreferenceDataChanged(listPreference));
- mHfpOutputControllerKey =
- use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey();
+ use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference ->
+ onPreferenceDataChanged(listPreference));
+ mHfpOutputControllerKey =
+ use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey();
- for (VolumeSeekBarPreferenceController controller : volumeControllers) {
- controller.setCallback(mVolumeCallback);
- getSettingsLifecycle().addObserver(controller);
+ for (VolumeSeekBarPreferenceController controller : volumeControllers) {
+ controller.setCallback(mVolumeCallback);
+ getSettingsLifecycle().addObserver(controller);
+ }
}
}
@@ -321,4 +325,9 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
mDialogFragment.onListPreferenceUpdated(preference);
}
}
+
+ @Override
+ public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
+ return SoundScreen.KEY;
+ }
}
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 00000000000..a962b1ade14
--- /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 00000000000..fe401f29c5a
--- /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/robotests/src/com/android/settings/notification/SoundScreenTest.kt b/tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt
new file mode 100644
index 00000000000..83b29d2907f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt
@@ -0,0 +1,53 @@
+/*
+ * 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.notification
+
+import android.content.Context
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.platform.test.flag.junit.SetFlagsRule
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.flags.Flags
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class SoundScreenTest {
+ @get:Rule val setFlagsRule = SetFlagsRule()
+ private val context: Context = ApplicationProvider.getApplicationContext()
+ private val soundScreen = SoundScreen()
+
+ @Test
+ fun key() {
+ assertThat(soundScreen.key).isEqualTo(SoundScreen.KEY)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN)
+ fun isFlagEnabled_returnTrue() {
+ assertThat(soundScreen.isFlagEnabled(context)).isTrue()
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN)
+ fun isFlagEnabled_returnFalse() {
+ assertThat(soundScreen.isFlagEnabled(context)).isFalse()
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 9a5399c5f07..05e2f246dbd 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.preference.PreferenceScreen;
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 @@ public class PhoneNumberPreferenceControllerTest {
}
@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 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));
}
}
diff --git a/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java b/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
index bb2d2ef4674..f0a24844659 100644
--- a/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
+++ b/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
@@ -53,6 +53,8 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
public void setDefaultKey_percentage_shouldSuppressNotification() {
Secure.putInt(
mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1);
+ Secure.putInt(
+ mContext.getContentResolver(), Secure.EXTRA_LOW_POWER_WARNING_ACKNOWLEDGED, 1);
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);