Merge "Cleanup of deprecated A11y settings functions" into main
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index 04c4702..f3e5e62 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -219,22 +219,6 @@
}
/**
- * Converts {@link UserShortcutType} to key in Settings.
- *
- * @param shortcutType The shortcut type.
- * @return Mapping key in Settings.
- *
- * @deprecated use
- * {@link ShortcutUtils#convertToKey(int)} instead.
- *
- * (TODO 367414968: finish removal.)
- */
- @Deprecated
- static String convertKeyFromSettings(@UserShortcutType int shortcutType) {
- return ShortcutUtils.convertToKey(shortcutType);
- }
-
- /**
* Gets the width of the screen.
*
* @param context the current context.
diff --git a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
index f729cc7..013fdee 100644
--- a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
@@ -41,7 +41,6 @@
import androidx.preference.Preference;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import java.util.ArrayList;
import java.util.List;
@@ -117,24 +116,6 @@
}
@Override
- CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- final ComponentName componentName = getTileComponentName();
- if (componentName == null) {
- return null;
- }
-
- final CharSequence tileName = loadTileLabel(getPrefContext(), componentName);
- if (tileName == null) {
- return null;
- }
-
- final int titleResId = type == QuickSettingsTooltipType.GUIDE_TO_EDIT
- ? R.string.accessibility_service_qs_tooltip_content
- : R.string.accessibility_service_auto_added_qs_tooltip_content;
- return getString(titleResId, tileName);
- }
-
- @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Do not call super. We don't want to see the "Help & feedback" option on this page so as
// not to confuse users who think they might be able to send feedback about a specific
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index a2a8cf3..06bcdb7 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -48,7 +48,6 @@
import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settingslib.accessibility.AccessibilityUtils;
@@ -246,24 +245,6 @@
}
@Override
- CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- final ComponentName componentName = getTileComponentName();
- if (componentName == null) {
- return null;
- }
-
- final CharSequence tileName = loadTileLabel(getPrefContext(), componentName);
- if (tileName == null) {
- return null;
- }
-
- final int titleResId = type == QuickSettingsTooltipType.GUIDE_TO_EDIT
- ? R.string.accessibility_service_qs_tooltip_content
- : R.string.accessibility_service_auto_added_qs_tooltip_content;
- return getString(titleResId, tileName);
- }
-
- @Override
protected void updateSwitchBarToggleSwitch() {
final boolean checked = isAccessibilityServiceEnabled();
if (mToggleServiceSwitchPreference.isChecked() == checked) {
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index b779f9d..b8f31b1 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -36,7 +36,6 @@
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.search.SearchIndexable;
@@ -180,13 +179,6 @@
}
@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);
- }
-
- @Override
protected void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
if (mToggleServiceSwitchPreference.isChecked() == checked) {
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index fe51e69..42906c1 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -35,7 +35,6 @@
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.search.SearchIndexable;
@@ -195,13 +194,6 @@
}
@Override
- CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
- ? R.string.accessibility_color_correction_qs_tooltip_content
- : R.string.accessibility_color_correction_auto_added_qs_tooltip_content);
- }
-
- @Override
protected void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
if (mToggleServiceSwitchPreference.isChecked() == checked) {
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 91f8c4f..7c34283 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -59,7 +59,6 @@
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.flags.Flags;
@@ -274,14 +273,6 @@
/** Returns the accessibility tile component name. */
abstract ComponentName getTileComponentName();
- /** Returns the accessibility tile component name.
- *
- * @deprecated unused, as this class no longer displays tile tooltips.
- *
- * (TODO 367414968: finish removal.)*/
- @Deprecated
- abstract CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type);
-
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
final CharSequence title =
getString(R.string.accessibility_service_primary_switch_title, mFeatureName);
diff --git a/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
index ff14021..dc63828 100644
--- a/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
@@ -37,7 +37,6 @@
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SeekBarPreference;
import com.android.settings.widget.SettingsMainSwitchPreference;
@@ -182,13 +181,6 @@
}
@Override
- CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
- ? R.string.accessibility_reduce_bright_colors_qs_tooltip_content
- : R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content);
- }
-
- @Override
protected void updateSwitchBarToggleSwitch() {
final boolean checked = mColorDisplayManager.isReduceBrightColorsActivated();
mRbcIntensityPreferenceController.updateState(getPreferenceScreen()
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 0d0c7fa..5ecdf67 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -19,12 +19,6 @@
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import static com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
@@ -39,7 +33,6 @@
import android.icu.text.MessageFormat;
import android.net.Uri;
import android.os.Bundle;
-import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
@@ -55,13 +48,11 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat;
-import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags;
import com.android.settings.DialogCreatable;
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;
@@ -498,7 +489,8 @@
@Override
int getUserShortcutTypes() {
- return getUserShortcutTypeFromSettings(getPrefContext());
+ return ShortcutUtils.getEnabledShortcutTypes(
+ getPrefContext(), MAGNIFICATION_CONTROLLER_NAME);
}
@Override
@@ -507,11 +499,6 @@
}
@Override
- CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- return null;
- }
-
- @Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
if (enabled && TextUtils.equals(
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
@@ -529,11 +516,12 @@
@Override
public void onToggleClicked(ShortcutPreference preference) {
final int shortcutTypes = getUserPreferredShortcutTypes();
+ getPrefContext().getSystemService(AccessibilityManager.class).enableShortcutsForTargets(
+ preference.isChecked(), shortcutTypes,
+ Set.of(MAGNIFICATION_CONTROLLER_NAME), getPrefContext().getUserId()
+ );
if (preference.isChecked()) {
- optInAllMagnificationValuesToSettings(getPrefContext(), shortcutTypes);
showDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
- } else {
- optOutAllMagnificationValuesFromSettings(getPrefContext(), shortcutTypes);
}
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
}
@@ -550,7 +538,8 @@
@Override
protected void updateShortcutPreferenceData() {
- final int shortcutTypes = getUserShortcutTypeFromSettings(getPrefContext());
+ final int shortcutTypes = ShortcutUtils.getEnabledShortcutTypes(
+ getPrefContext(), MAGNIFICATION_CONTROLLER_NAME);
if (shortcutTypes != DEFAULT) {
final PreferredShortcut shortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME, shortcutTypes);
@@ -583,174 +572,10 @@
@Override
protected void updateShortcutPreference() {
- final int shortcutTypes = getUserPreferredShortcutTypes();
- mShortcutPreference.setChecked(
- hasMagnificationValuesInSettings(getPrefContext(), shortcutTypes));
+ mShortcutPreference.setChecked(getUserShortcutTypes() != DEFAULT);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
}
- @VisibleForTesting
- static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
- if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
- optInMagnificationValueToSettings(context, SOFTWARE);
- }
- if (((shortcutTypes & HARDWARE) == HARDWARE)) {
- optInMagnificationValueToSettings(context, HARDWARE);
- }
- if (((shortcutTypes & TRIPLETAP) == TRIPLETAP)) {
- optInMagnificationValueToSettings(context, TRIPLETAP);
- }
- if (((shortcutTypes & GESTURE) == GESTURE)) {
- optInMagnificationValueToSettings(context, GESTURE);
- }
- if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (((shortcutTypes & TWOFINGER_DOUBLETAP)
- == TWOFINGER_DOUBLETAP)) {
- optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP);
- }
- }
- if (((shortcutTypes & QUICK_SETTINGS)
- == QUICK_SETTINGS)) {
- optInMagnificationValueToSettings(context, QUICK_SETTINGS);
- }
- }
-
- /**
- * @deprecated use
- * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
- *
- * (TODO 367414968: finish removal.)
- */
- @Deprecated
- private static void optInMagnificationValueToSettings(
- Context context, @UserShortcutType int shortcutType) {
- AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
- if (a11yManager != null) {
- a11yManager.enableShortcutsForTargets(
- /* enable= */ true,
- shortcutType,
- Set.of(MAGNIFICATION_CONTROLLER_NAME),
- UserHandle.myUserId()
- );
- }
- }
-
- @VisibleForTesting
- static void optOutAllMagnificationValuesFromSettings(Context context,
- int shortcutTypes) {
- if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
- optOutMagnificationValueFromSettings(context, SOFTWARE);
- }
- if (((shortcutTypes & HARDWARE) == HARDWARE)) {
- optOutMagnificationValueFromSettings(context, HARDWARE);
- }
- if (((shortcutTypes & TRIPLETAP) == TRIPLETAP)) {
- optOutMagnificationValueFromSettings(context, TRIPLETAP);
- }
- if (((shortcutTypes & GESTURE) == GESTURE)) {
- optOutMagnificationValueFromSettings(context, GESTURE);
- }
- if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (((shortcutTypes & TWOFINGER_DOUBLETAP)
- == TWOFINGER_DOUBLETAP)) {
- optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP);
- }
- }
- if (((shortcutTypes & QUICK_SETTINGS)
- == QUICK_SETTINGS)) {
- optOutMagnificationValueFromSettings(context, QUICK_SETTINGS);
- }
- }
-
- /**
- * @deprecated use
- * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
- *
- * (TODO 367414968: finish removal.)
- */
- @Deprecated
- private static void optOutMagnificationValueFromSettings(Context context,
- @UserShortcutType int shortcutType) {
- AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
- if (a11yManager != null) {
- a11yManager.enableShortcutsForTargets(
- /* enable= */ false,
- shortcutType,
- Set.of(MAGNIFICATION_CONTROLLER_NAME),
- UserHandle.myUserId()
- );
- }
- }
-
- @VisibleForTesting
- static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) {
- for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
- if ((shortcutTypes & shortcutType) == 0) {
- continue;
- }
- if (((shortcutType & TWOFINGER_DOUBLETAP)
- == TWOFINGER_DOUBLETAP)
- && !Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- continue;
- }
- if (hasMagnificationValueInSettings(context, shortcutType)) {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean hasMagnificationValueInSettings(Context context,
- @UserShortcutType int shortcutType) {
- if (shortcutType == TRIPLETAP) {
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF) == ON;
- }
- if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (shortcutType == TWOFINGER_DOUBLETAP) {
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
- OFF) == ON;
- }
- }
-
- final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
- final String targetString = Settings.Secure.getString(context.getContentResolver(),
- targetKey);
-
- if (TextUtils.isEmpty(targetString)) {
- return false;
- }
-
- sStringColonSplitter.setString(targetString);
- while (sStringColonSplitter.hasNext()) {
- final String name = sStringColonSplitter.next();
- if (MAGNIFICATION_CONTROLLER_NAME.equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @deprecated use
- * {@link ShortcutUtils#getEnabledShortcutTypes(Context, String)} instead.
- *
- * (TODO 367414968: finish removal.)
- */
- @Deprecated
- private static int getUserShortcutTypeFromSettings(Context context) {
- int shortcutTypes = DEFAULT;
- for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
- if (hasMagnificationValueInSettings(context, shortcutType)) {
- shortcutTypes |= shortcutType;
- }
- }
-
- return shortcutTypes;
- }
-
/**
* Gets the service summary of magnification.
*
@@ -758,7 +583,8 @@
*/
public static CharSequence getServiceSummary(Context context) {
// Get the user shortcut type from settings provider.
- final int userShortcutType = getUserShortcutTypeFromSettings(context);
+ final int userShortcutType = ShortcutUtils.getEnabledShortcutTypes(
+ context, MAGNIFICATION_CONTROLLER_NAME);
final CharSequence featureState =
(userShortcutType != DEFAULT)
? context.getText(R.string.accessibility_summary_shortcut_enabled)
@@ -822,7 +648,8 @@
// 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) {
+ || ShortcutUtils.getEnabledShortcutTypes(
+ context, MAGNIFICATION_CONTROLLER_NAME) == DEFAULT) {
niks.add(MagnificationAlwaysOnPreferenceController.PREF_KEY);
}
if (!isOneFingerPanningSupported()) {
diff --git a/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java b/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java
index afb5acf..70e8141 100644
--- a/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java
+++ b/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java
@@ -113,13 +113,7 @@
/**
* Enable or disable the shortcut for the given accessibility features.
- *
- * @deprecated use
- * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
- *
- * (TODO 367414968: finish removal.)
*/
- @Deprecated
protected void enableShortcutForTargets(boolean enable) {
Set<String> shortcutTargets = getShortcutTargets();
@ShortcutConstants.UserShortcutType int shortcutType = getShortcutType();
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
index c93ee1e..4e8c592 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
@@ -21,16 +21,8 @@
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
-
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName;
import android.content.Context;
@@ -61,7 +53,6 @@
private static final String SECURE_TEST_KEY = "secure_test_key";
private static final String MOCK_PACKAGE_NAME = "com.mock.example";
private static final String MOCK_CLASS_NAME = MOCK_PACKAGE_NAME + ".mock_a11y_service";
- private static final String MOCK_CLASS_NAME2 = MOCK_PACKAGE_NAME + ".mock_a11y_service2";
private static final ComponentName MOCK_COMPONENT_NAME = new ComponentName(MOCK_PACKAGE_NAME,
MOCK_CLASS_NAME);
@Rule
@@ -71,7 +62,7 @@
@Before
public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
+ mContext = ApplicationProvider.getApplicationContext();
}
@Test
@@ -149,37 +140,6 @@
}
@Test
- public void convertKeyFromSettings_shortcutTypeSoftware() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(SOFTWARE))
- .isEqualTo(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
- }
-
- @Test
- public void convertKeyFromSettings_shortcutTypeHardware() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(HARDWARE))
- .isEqualTo(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
- }
-
- @Test
- public void convertKeyFromSettings_shortcutTypeTripleTap() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(TRIPLETAP))
- .isEqualTo(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
- }
-
- @Test
- public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP))
- .isEqualTo(
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED);
- }
-
- @Test
- public void convertKeyFromSettings_shortcutTypeQuickSettings() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS))
- .isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
- }
-
- @Test
@EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void getSoftwareShortcutSummary_returnsSoftwareSummary() {
assertThat(AccessibilityUtil.getSoftwareShortcutSummary(mContext)).isEqualTo(
diff --git a/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java
index 8d5724b..da8fd7e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java
@@ -16,8 +16,6 @@
package com.android.settings.accessibility;
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -34,11 +32,7 @@
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
-import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
-
import org.junit.Before;
-import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
@@ -83,72 +77,6 @@
doReturn(mScreen).when(mFragment).getPreferenceScreen();
}
- @Test
- public void getTileTooltipContent_noTileServiceAssigned_returnNull() {
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
-
- assertThat(tileTooltipContent).isNull();
- }
-
- @Test
- public void getTileTooltipContent_hasOneTileService_guideToEdit_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(R.string.accessibility_service_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasOneTileService_guideToDirectUse_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(
- R.string.accessibility_service_auto_added_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasTwoTileServices_guideToEdit_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
- PLACEHOLDER_TILE_NAME2);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(R.string.accessibility_service_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasTwoTileServices_guideToDirectUse_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
- PLACEHOLDER_TILE_NAME2);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(
- R.string.accessibility_service_auto_added_qs_tooltip_content, tileName));
- }
-
private void setupTileService(String packageName, String name, String tileName) {
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
final ResolveInfo info = new ResolveInfo();
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java
index 70290af..db5aec5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java
@@ -43,9 +43,7 @@
import androidx.test.core.app.ApplicationProvider;
import com.android.internal.accessibility.common.ShortcutConstants;
-import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.widget.SettingsMainSwitchPreference;
@@ -112,72 +110,6 @@
}
@Test
- public void getTileTooltipContent_noTileServiceAssigned_returnNull() {
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
-
- assertThat(tileTooltipContent).isNull();
- }
-
- @Test
- public void getTileTooltipContent_hasOneTileService_guideToEdit_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(R.string.accessibility_service_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasOneTileService_guideToDirectUse_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(
- R.string.accessibility_service_auto_added_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasTwoTileServices_guideToEdit_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
- PLACEHOLDER_TILE_NAME2);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(R.string.accessibility_service_qs_tooltip_content, tileName));
- }
-
- @Test
- public void getTileTooltipContent_hasTwoTileServices_guideToDirectUse_haveMatchString() {
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
- PLACEHOLDER_TILE_NAME);
- setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
- PLACEHOLDER_TILE_NAME2);
-
- final CharSequence tileTooltipContent =
- mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
- final CharSequence tileName =
- mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
- assertThat(tileTooltipContent.toString()).isEqualTo(
- mContext.getString(
- R.string.accessibility_service_auto_added_qs_tooltip_content, tileName));
- }
-
- @Test
public void getAccessibilityServiceInfo() throws Throwable {
final AccessibilityServiceInfo info1 = getFakeAccessibilityServiceInfo(
PLACEHOLDER_PACKAGE_NAME,
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
index cbd4493..ff73e7f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java
@@ -47,7 +47,6 @@
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.testutils.XmlTestUtils;
import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settings.widget.SettingsMainSwitchPreference;
@@ -266,11 +265,6 @@
}
@Override
- protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- return PLACEHOLDER_TILE_TOOLTIP_CONTENT;
- }
-
- @Override
public View getView() {
return mock(View.class);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index ad5b1b5..8f9d2e1 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -53,7 +53,6 @@
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.flags.Flags;
import com.android.settings.testutils.shadow.ShadowAccessibilityManager;
import com.android.settings.testutils.shadow.ShadowFragment;
@@ -379,11 +378,6 @@
}
@Override
- protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
- return PLACEHOLDER_TILE_TOOLTIP_CONTENT;
- }
-
- @Override
public int getPreferenceScreenResId() {
return R.xml.placeholder_prefs;
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 863452f..ae059dd 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -35,7 +35,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums;
@@ -47,7 +46,6 @@
import android.icu.text.CaseMap;
import android.net.Uri;
import android.os.Bundle;
-import android.os.UserHandle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
@@ -66,7 +64,7 @@
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.testutils.AccessibilityTestUtils;
+import com.android.settings.testutils.shadow.ShadowAccessibilityManager;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowStorageManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
@@ -83,6 +81,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowContentResolver;
import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.shadows.ShadowSettings;
@@ -92,7 +91,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Locale;
-import java.util.Set;
/** Tests for {@link ToggleScreenMagnificationPreferenceFragment}. */
@RunWith(RobolectricTestRunner.class)
@@ -101,6 +99,7 @@
ShadowStorageManager.class,
ShadowSettings.ShadowSecure.class,
ShadowDeviceConfig.class,
+ ShadowAccessibilityManager.class,
})
public class ToggleScreenMagnificationPreferenceFragmentTest {
@@ -137,15 +136,15 @@
private FragmentController<ToggleScreenMagnificationPreferenceFragment> mFragController;
private Context mContext;
- private AccessibilityManager mAccessibilityManager;
private Resources mSpyResources;
private ShadowPackageManager mShadowPackageManager;
+ private ShadowAccessibilityManager mShadowAccessibilityManager;
@Before
public void setUpTestFragment() {
-
mContext = spy(ApplicationProvider.getApplicationContext());
- mAccessibilityManager = AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
+ mShadowAccessibilityManager = Shadow.extract(
+ mContext.getSystemService(AccessibilityManager.class));
// Set up the fragment that support window magnification feature
mSpyResources = spy(mContext.getResources());
@@ -421,137 +420,6 @@
}
@Test
- public void hasValueInSettings_putValue_hasValue() {
- setMagnificationTripleTapEnabled(/* enabled= */ true);
-
- assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, TRIPLETAP)).isTrue();
- }
-
- @Test
- @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
- public void hasMagnificationValuesInSettings_twoFingerTripleTapIsOn_isTrue() {
- Settings.Secure.putInt(
- mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
-
- assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, TWOFINGER_DOUBLETAP)).isTrue();
- }
-
- @Test
- @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
- public void hasMagnificationValuesInSettings_twoFingerTripleTapIsOff_isFalse() {
- Settings.Secure.putInt(
- mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF);
-
- assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, TWOFINGER_DOUBLETAP)).isFalse();
- }
-
- @Test
- public void optInAllValuesToSettings_optInValue_callA11yManager() {
- int shortcutTypes =
- SOFTWARE | TRIPLETAP | HARDWARE
- | QUICK_SETTINGS;
- Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME);
-
- ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
- shortcutTypes);
-
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, SOFTWARE,
- shortcutTargets, UserHandle.myUserId());
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, HARDWARE,
- shortcutTargets, UserHandle.myUserId());
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, QUICK_SETTINGS,
- shortcutTargets, UserHandle.myUserId());
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, TRIPLETAP,
- shortcutTargets, UserHandle.myUserId());
- verifyNoMoreInteractions(mAccessibilityManager);
- }
-
- @Test
- public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
- for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE,
- FloatingMenuSizePreferenceController.Size.SMALL}) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size);
-
- ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
- mContext,
- SOFTWARE);
-
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
- FloatingMenuSizePreferenceController.Size.UNKNOWN)).isEqualTo(
- size);
- }
- }
-
- @Test
- public void optInAllValuesToSettings_hardware_sizeValueIsNotChanged() {
- for (int size : new int[]{FloatingMenuSizePreferenceController.Size.UNKNOWN,
- FloatingMenuSizePreferenceController.Size.LARGE,
- FloatingMenuSizePreferenceController.Size.SMALL}) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size);
-
- ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
- mContext,
- HARDWARE);
-
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
- size);
- }
- }
-
- @Test
- public void optInAllValuesToSettings_tripletap_sizeValueIsNotChanged() {
- for (int size : new int[]{FloatingMenuSizePreferenceController.Size.UNKNOWN,
- FloatingMenuSizePreferenceController.Size.LARGE,
- FloatingMenuSizePreferenceController.Size.SMALL}) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size);
-
- ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
- mContext,
- TRIPLETAP);
-
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
- size);
- }
- }
-
- @Test
- public void optOutAllValuesToSettings_optOutValue_callA11yManager() {
- Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME);
- putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
- putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
- setMagnificationTripleTapEnabled(/* enabled= */ true);
- int shortcutTypes =
- SOFTWARE | HARDWARE | TRIPLETAP;
-
- ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
- mContext, shortcutTypes);
-
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, SOFTWARE,
- shortcutTargets, UserHandle.myUserId());
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, HARDWARE,
- shortcutTargets, UserHandle.myUserId());
- verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, TRIPLETAP,
- shortcutTargets, UserHandle.myUserId());
- verifyNoMoreInteractions(mAccessibilityManager);
- }
-
- @Test
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
@@ -565,8 +433,8 @@
@Test
public void updateShortcutPreferenceData_hasValueInSettings_assignToVariable() {
- putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
- setMagnificationTripleTapEnabled(/* enabled= */ true);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP | SOFTWARE, List.of(MAGNIFICATION_CONTROLLER_NAME));
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
mFragController.get().updateShortcutPreferenceData();
@@ -593,8 +461,8 @@
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void updateShortcutPreferenceData_hasTwoFingerTripleTapInSettings_assignToVariable() {
- Settings.Secure.putInt(
- mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TWOFINGER_DOUBLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
mFragController.get().updateShortcutPreferenceData();
@@ -802,7 +670,8 @@
@Test
public void getSummary_magnificationEnabled_returnShortcutOnWithSummary() {
- setMagnificationTripleTapEnabled(true);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
assertThat(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
@@ -816,7 +685,8 @@
@Test
public void getSummary_magnificationDisabled_returnShortcutOffWithSummary() {
- setMagnificationTripleTapEnabled(false);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP, List.of());
assertThat(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
@@ -832,8 +702,8 @@
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void getSummary_magnificationGestureEnabled_returnShortcutOnWithSummary() {
- Settings.Secure.putInt(
- mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TWOFINGER_DOUBLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
assertThat(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
@@ -848,8 +718,8 @@
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void getSummary_magnificationGestureDisabled_returnShortcutOffWithSummary() {
- Settings.Secure.putInt(
- mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP | TWOFINGER_DOUBLETAP, List.of());
assertThat(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
@@ -977,7 +847,8 @@
Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE,
Flags.FLAG_ENABLE_LOW_VISION_HATS})
public void getNonIndexableKeys_hasShortcutAndAllFeaturesEnabled_allItemsSearchable() {
- setMagnificationTripleTapEnabled(true);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
setAlwaysOnSupported(true);
setJoystickSupported(true);
@@ -991,7 +862,8 @@
@Test
@EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
public void getNonIndexableKeys_noShortcut_alwaysOnSupported_notSearchable() {
- setMagnificationTripleTapEnabled(false);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP, List.of());
setAlwaysOnSupported(true);
final List<String> niks = ToggleScreenMagnificationPreferenceFragment
@@ -1004,7 +876,8 @@
@Test
@EnableFlags(com.android.settings.accessibility.Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
public void getNonIndexableKeys_hasShortcut_alwaysOnNotSupported_notSearchable() {
- setMagnificationTripleTapEnabled(true);
+ mShadowAccessibilityManager.setAccessibilityShortcutTargets(
+ TRIPLETAP, List.of(MAGNIFICATION_CONTROLLER_NAME));
setAlwaysOnSupported(false);
final List<String> niks = ToggleScreenMagnificationPreferenceFragment
@@ -1056,11 +929,6 @@
PreferredShortcuts.saveUserShortcutType(context, shortcut);
}
- private void setMagnificationTripleTapEnabled(boolean enabled) {
- Settings.Secure.putInt(mContext.getContentResolver(), TRIPLETAP_SHORTCUT_KEY,
- enabled ? ON : OFF);
- }
-
private void setKeyMagnificationMode(@MagnificationMode int mode) {
MagnificationCapabilities.setCapabilities(mContext, mode);
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java
index 2741212..4de7339 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java
@@ -26,6 +26,7 @@
import android.util.ArrayMap;
import android.view.accessibility.AccessibilityManager;
+import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import org.robolectric.annotation.Implementation;
@@ -96,8 +97,11 @@
/**
* Used by tests to easily write directly to a shortcut targets value
*/
- public void setAccessibilityShortcutTargets(
- @UserShortcutType int shortcutType, List<String> targets) {
- mShortcutTargets.put(shortcutType, targets);
+ public void setAccessibilityShortcutTargets(int shortcutTypes, List<String> targets) {
+ for (int type : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ if ((type & shortcutTypes) == type) {
+ mShortcutTargets.put(type, List.copyOf(targets));
+ }
+ }
}
}