From acccaff128e2103dd2cb0034a8740355778f6c37 Mon Sep 17 00:00:00 2001 From: Riley Jones Date: Thu, 21 Nov 2024 01:03:39 +0000 Subject: [PATCH] Cleaning up quick settings flag in Settings app Removes all instances of a11y_qs_enabled. Any code that would be nontrivial to remove has been deprecated for later cleanup. Test: atest com.android.settings.accessibility Flag: EXEMPT flag cleanup Bug: 367414968 Change-Id: I81f3c9cee377535eaa552a170d58ec1a79d1da65 --- ...ingsPrimarySwitchPreferenceController.java | 149 ------------- .../accessibility/AccessibilitySettings.java | 4 +- ...cessibilityShortcutPreferenceFragment.java | 42 +--- .../AccessibilityShortcutsTutorial.java | 4 - .../accessibility/AccessibilityUtil.java | 199 ++++++------------ .../accessibility/ColorAndMotionFragment.java | 4 +- .../accessibility/PreferredShortcuts.java | 7 - ...educeBrightColorsPreferenceController.java | 24 +-- ...ccessibilityServicePreferenceFragment.java | 14 +- .../ToggleFeaturePreferenceFragment.java | 47 +---- ...ScreenMagnificationPreferenceFragment.java | 169 +++++---------- ...QuickSettingsShortcutOptionController.java | 4 +- .../ShortcutOptionPreferenceController.java | 34 ++- ...areShortcutOptionPreferenceController.java | 25 --- .../TripleTapShortcutOptionController.java | 14 -- ...ngerDoubleTapShortcutOptionController.java | 12 -- .../VolumeKeysShortcutOptionController.java | 14 -- ...PrimarySwitchPreferenceControllerTest.java | 198 ----------------- .../AccessibilitySettingsTest.java | 16 +- ...ibilityShortcutPreferenceFragmentTest.java | 24 --- .../AccessibilityShortcutsTutorialTest.java | 5 - .../accessibility/AccessibilityUtilTest.java | 90 -------- .../CaptioningFontSizeControllerTest.java | 1 - ...brationTogglePreferenceControllerTest.java | 2 +- ...tionIntensityPreferenceControllerTest.java | 4 +- ...brationTogglePreferenceControllerTest.java | 4 +- ...sibilityServicePreferenceFragmentTest.java | 79 ------- ...eColorInversionPreferenceFragmentTest.java | 19 -- ...oggleDaltonizerPreferenceFragmentTest.java | 17 -- .../ToggleFeaturePreferenceFragmentTest.java | 51 ----- ...enMagnificationPreferenceFragmentTest.java | 139 +----------- .../EditShortcutsPreferenceFragmentTest.java | 4 - ...kSettingsShortcutOptionControllerTest.java | 18 -- ...hortcutOptionPreferenceControllerTest.java | 124 ----------- ...TripleTapShortcutOptionControllerTest.java | 31 --- ...DoubleTapShortcutOptionControllerTest.java | 28 --- ...olumeKeysShortcutOptionControllerTest.java | 25 --- .../accessibility/PreferredShortcutsTest.java | 26 --- ...eBrightColorsPreferenceControllerTest.java | 24 --- 39 files changed, 159 insertions(+), 1536 deletions(-) delete mode 100644 src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java delete mode 100644 tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest.java diff --git a/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java deleted file mode 100644 index 8a3f22d807a..00000000000 --- a/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2022 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.accessibility; - -import android.content.ComponentName; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; - -import androidx.annotation.Nullable; -import androidx.preference.PreferenceScreen; - -import com.android.settings.R; -import com.android.settings.core.TogglePreferenceController; -import com.android.settingslib.PrimarySwitchPreference; -import com.android.settingslib.core.lifecycle.LifecycleObserver; -import com.android.settingslib.core.lifecycle.events.OnCreate; -import com.android.settingslib.core.lifecycle.events.OnDestroy; -import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState; - -/** PrimarySwitchPreferenceController that shows quick settings tooltip on first use. */ -public abstract class AccessibilityQuickSettingsPrimarySwitchPreferenceController - extends TogglePreferenceController - implements LifecycleObserver, OnCreate, OnDestroy, OnSaveInstanceState { - private static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow"; - private final Handler mHandler; - private PrimarySwitchPreference mPreference; - private AccessibilityQuickSettingsTooltipWindow mTooltipWindow; - private boolean mNeedsQSTooltipReshow = false; - - /** Returns the accessibility tile component name. */ - @Nullable - abstract ComponentName getTileComponentName(); - - /** Returns the accessibility tile tooltip content. */ - abstract CharSequence getTileTooltipContent(); - - public AccessibilityQuickSettingsPrimarySwitchPreferenceController(Context context, - String preferenceKey) { - super(context, preferenceKey); - mHandler = new Handler(context.getMainLooper()); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - // Restore the tooltip. - if (savedInstanceState != null) { - if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) { - mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW); - } - } - } - - @Override - public void onDestroy() { - mHandler.removeCallbacksAndMessages(null); - final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing(); - if (isTooltipWindowShowing) { - mTooltipWindow.dismiss(); - } - } - - @Override - public void onSaveInstanceState(Bundle outState) { - final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing(); - if (mNeedsQSTooltipReshow || isTooltipWindowShowing) { - outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true); - } - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - mPreference = screen.findPreference(getPreferenceKey()); - if (mNeedsQSTooltipReshow) { - mHandler.post(this::showQuickSettingsTooltipIfNeeded); - } - } - - @Override - public boolean setChecked(boolean isChecked) { - if (isChecked) { - showQuickSettingsTooltipIfNeeded(); - } - return isChecked; - } - - @Override - public boolean isChecked() { - return false; - } - - @Override - public int getAvailabilityStatus() { - return AVAILABLE; - } - - @Override - public int getSliceHighlightMenuRes() { - return R.string.menu_key_accessibility; - } - - private void showQuickSettingsTooltipIfNeeded() { - if (mPreference == null) { - // Returns if no preference found by slice highlight menu. - return; - } - - final ComponentName tileComponentName = getTileComponentName(); - if (tileComponentName == null) { - // Returns if no tile service assigned. - return; - } - - if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences( - mContext, tileComponentName)) { - // Returns if quick settings tooltip only show once. - return; - } - - // TODO (287728819): Move tooltip showing to SystemUI - // Since the lifecycle of controller is independent of that of the preference, doing - // null check on switch is a temporary solution for the case that switch view - // is not ready when we would like to show the tooltip. If the switch is not ready, - // we give up showing the tooltip and also do not reshow it in the future. - if (mPreference.getSwitch() != null) { - mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); - mTooltipWindow.setup(getTileTooltipContent(), - R.drawable.accessibility_auto_added_qs_tooltip_illustration); - mTooltipWindow.showAtTopCenter(mPreference.getSwitch()); - } - AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName); - mNeedsQSTooltipReshow = false; - } -} diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java index 801d3ee223c..62b0f3460f8 100644 --- a/src/com/android/settings/accessibility/AccessibilitySettings.java +++ b/src/com/android/settings/accessibility/AccessibilitySettings.java @@ -180,9 +180,7 @@ public class AccessibilitySettings extends DashboardFragment implements // Observe changes from accessibility selection menu shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); - if (android.view.accessibility.Flags.a11yQsShortcut()) { - shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); - } + shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_STICKY_KEYS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SLOW_KEYS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS); diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java index 91d75f34631..104b35a9fbe 100644 --- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java +++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java @@ -31,7 +31,6 @@ import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; -import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -114,9 +113,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted final List shortcutFeatureKeys = new ArrayList<>(); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); - if (android.view.accessibility.Flags.a11yQsShortcut()) { - shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); - } + shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); mSettingsContentObserver = new AccessibilitySettingsContentObserver(new Handler()); mSettingsContentObserver.registerKeysToObserverCallback(shortcutFeatureKeys, key -> { updateShortcutPreferenceData(); @@ -374,38 +371,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted showQuickSettingsTooltipIfNeeded(); } + /** + * @deprecated made obsolete by quick settings rollout. + * + * (TODO 367414968: finish removal.) + */ + @Deprecated private void showQuickSettingsTooltipIfNeeded() { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - // Don't show Quick Settings tooltip - return; - } - final ComponentName tileComponentName = getTileComponentName(); - if (tileComponentName == null) { - // Returns if no tile service assigned. - return; - } - - if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences( - getContext(), tileComponentName)) { - // Returns if quick settings tooltip only show once. - return; - } - - final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType); - if (TextUtils.isEmpty(content)) { - // Returns if no content of tile tooltip assigned. - return; - } - - final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT - ? R.drawable.accessibility_qs_tooltip_illustration - : R.drawable.accessibility_auto_added_qs_tooltip_illustration; - mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); - mTooltipWindow.setup(content, imageResId); - mTooltipWindow.showAtTopCenter(getView()); - AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(), - tileComponentName); - mNeedsQSTooltipReshow = false; } /** diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java index c613181d489..9386ba0a70b 100644 --- a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java +++ b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java @@ -496,10 +496,6 @@ public final class AccessibilityShortcutsTutorial { if ((shortcutTypes & shortcutType) == 0) { continue; } - if ((shortcutTypes & QUICK_SETTINGS) == QUICK_SETTINGS - && !android.view.accessibility.Flags.a11yQsShortcut()) { - continue; - } tutorialPages.add( createShortcutTutorialPage( context, shortcutType, buttonMode, featureName, inSetupWizard)); diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java index 82d32815bf5..d31720dc302 100644 --- a/src/com/android/settings/accessibility/AccessibilityUtil.java +++ b/src/com/android/settings/accessibility/AccessibilityUtil.java @@ -61,7 +61,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.StringJoiner; /** Provides utility methods to accessibility settings only. */ public final class AccessibilityUtil { @@ -203,28 +202,23 @@ public final class AccessibilityUtil { * @param context The current context. * @param shortcutTypes A combination of {@link UserShortcutType}. * @param componentName The component name that need to be opted in Settings. + * + * @deprecated use + * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead. + * + * (TODO 367414968: finish removal.) */ + @Deprecated static void optInAllValuesToSettings(Context context, int shortcutTypes, @NonNull ComponentName componentName) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ true, - shortcutTypes, - Set.of(componentName.flattenToString()), - UserHandle.myUserId() - ); - } - - return; - } - - if ((shortcutTypes & SOFTWARE) == SOFTWARE) { - optInValueToSettings(context, SOFTWARE, componentName); - } - if (((shortcutTypes & HARDWARE) == HARDWARE)) { - optInValueToSettings(context, HARDWARE, componentName); + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ true, + shortcutTypes, + Set.of(componentName.flattenToString()), + UserHandle.myUserId() + ); } } @@ -234,38 +228,25 @@ public final class AccessibilityUtil { * @param context The current context. * @param shortcutType The preferred shortcut type user selected. * @param componentName The component name that need to be opted in Settings. + * + * @deprecated use + * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead. + * + * (TODO 367414968: finish removal.) */ + @Deprecated @VisibleForTesting static void optInValueToSettings(Context context, @UserShortcutType int shortcutType, @NonNull ComponentName componentName) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ true, - shortcutType, - Set.of(componentName.flattenToString()), - UserHandle.myUserId() - ); - } - return; + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ true, + shortcutType, + Set.of(componentName.flattenToString()), + UserHandle.myUserId() + ); } - - final String targetKey = convertKeyFromSettings(shortcutType); - final String targetString = Settings.Secure.getString(context.getContentResolver(), - targetKey); - - if (hasValueInSettings(context, shortcutType, componentName)) { - return; - } - - final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR)); - if (!TextUtils.isEmpty(targetString)) { - joiner.add(targetString); - } - joiner.add(componentName.flattenToString()); - - Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString()); } /** @@ -275,27 +256,23 @@ public final class AccessibilityUtil { * @param context The current context. * @param shortcutTypes A combination of {@link UserShortcutType}. * @param componentName The component name that need to be opted out from Settings. + * + * @deprecated use + * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead. + * + * (TODO 367414968: finish removal.) */ + @Deprecated static void optOutAllValuesFromSettings(Context context, int shortcutTypes, @NonNull ComponentName componentName) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ false, - shortcutTypes, - Set.of(componentName.flattenToString()), - UserHandle.myUserId() - ); - } - return; - } - - if ((shortcutTypes & SOFTWARE) == SOFTWARE) { - optOutValueFromSettings(context, SOFTWARE, componentName); - } - if (((shortcutTypes & HARDWARE) == HARDWARE)) { - optOutValueFromSettings(context, HARDWARE, componentName); + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ false, + shortcutTypes, + Set.of(componentName.flattenToString()), + UserHandle.myUserId() + ); } } @@ -305,42 +282,25 @@ public final class AccessibilityUtil { * @param context The current context. * @param shortcutType The preferred shortcut type user selected. * @param componentName The component name that need to be opted out from Settings. + * + * @deprecated use + * {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead. + * + * (TODO 367414968: finish removal.) */ + @Deprecated @VisibleForTesting static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType, @NonNull ComponentName componentName) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ false, - shortcutType, - Set.of(componentName.flattenToString()), - UserHandle.myUserId() - ); - } - return; + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ false, + shortcutType, + Set.of(componentName.flattenToString()), + UserHandle.myUserId() + ); } - - final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR)); - final String targetKey = convertKeyFromSettings(shortcutType); - final String targetString = Settings.Secure.getString(context.getContentResolver(), - targetKey); - - if (TextUtils.isEmpty(targetString)) { - return; - } - - sStringColonSplitter.setString(targetString); - while (sStringColonSplitter.hasNext()) { - final String name = sStringColonSplitter.next(); - if (TextUtils.isEmpty(name) || (componentName.flattenToString()).equals(name)) { - continue; - } - joiner.add(name); - } - - Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString()); } /** @@ -354,11 +314,6 @@ public final class AccessibilityUtil { static boolean hasValuesInSettings(Context context, int shortcutTypes, @NonNull ComponentName componentName) { for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { - if (!android.view.accessibility.Flags.a11yQsShortcut()) { - if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { - continue; - } - } if (!android.provider.Flags.a11yStandaloneGestureEnabled()) { if ((shortcutType & GESTURE) == GESTURE) { continue; @@ -379,15 +334,16 @@ public final class AccessibilityUtil { * @param shortcutType The preferred shortcut type user selected. * @param componentName The component name that need to be checked existed in Settings. * @return {@code true} if componentName existed in Settings. + * + * @deprecated use + * {@link ShortcutUtils#isShortcutContained(Context, int, String)} instead. + * + * (TODO 367414968: finish removal.) */ + @Deprecated @VisibleForTesting static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType, @NonNull ComponentName componentName) { - if (!android.view.accessibility.Flags.a11yQsShortcut() - && (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { - return false; - } - return ShortcutUtils.getShortcutTargetsFromSettings( context, shortcutType, UserHandle.myUserId() ).contains(componentName.flattenToString()); @@ -405,11 +361,6 @@ public final class AccessibilityUtil { @NonNull ComponentName componentName) { int shortcutTypes = DEFAULT; for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { - if (!android.view.accessibility.Flags.a11yQsShortcut()) { - if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { - continue; - } - } if (!android.provider.Flags.a11yStandaloneGestureEnabled()) { if ((shortcutType & GESTURE) == GESTURE) { continue; @@ -428,23 +379,15 @@ public final class AccessibilityUtil { * * @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) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - return ShortcutUtils.convertToKey(shortcutType); - } - - switch (shortcutType) { - case SOFTWARE: - return Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS; - case HARDWARE: - return Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE; - case TRIPLETAP: - return Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED; - default: - throw new IllegalArgumentException( - "Unsupported userShortcutType " + shortcutType); - } + return ShortcutUtils.convertToKey(shortcutType); } /** @@ -521,10 +464,6 @@ public final class AccessibilityUtil { final List list = new ArrayList<>(); for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { - if (!android.view.accessibility.Flags.a11yQsShortcut() - && (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { - continue; - } if (!android.provider.Flags.a11yStandaloneGestureEnabled() && (shortcutType & GESTURE) == GESTURE) { continue; diff --git a/src/com/android/settings/accessibility/ColorAndMotionFragment.java b/src/com/android/settings/accessibility/ColorAndMotionFragment.java index 7a7c21dd1af..6e9037fcd59 100644 --- a/src/com/android/settings/accessibility/ColorAndMotionFragment.java +++ b/src/com/android/settings/accessibility/ColorAndMotionFragment.java @@ -77,9 +77,7 @@ public class ColorAndMotionFragment extends DashboardFragment { mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED); mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); - if (android.view.accessibility.Flags.a11yQsShortcut()) { - mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); - } + mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); if (Flags.forceInvertColor()) { mShortcutFeatureKeys.add(ToggleForceInvertPreferenceController.SETTINGS_KEY); } diff --git a/src/com/android/settings/accessibility/PreferredShortcuts.java b/src/com/android/settings/accessibility/PreferredShortcuts.java index 9006609091d..526b1fa8b39 100644 --- a/src/com/android/settings/accessibility/PreferredShortcuts.java +++ b/src/com/android/settings/accessibility/PreferredShortcuts.java @@ -17,7 +17,6 @@ package com.android.settings.accessibility; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT; -import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE; import android.content.ComponentName; @@ -25,7 +24,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.UserHandle; import android.util.ArrayMap; -import android.view.accessibility.Flags; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; @@ -123,11 +121,6 @@ public final class PreferredShortcuts { @NonNull Context context, @NonNull Set components) { final Map> shortcutTypeToTargets = new ArrayMap<>(); 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 - continue; - } shortcutTypeToTargets.put( shortcutType, ShortcutUtils.getShortcutTargetsFromSettings( diff --git a/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java b/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java index e7f59f49974..4e70103cfc7 100644 --- a/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java +++ b/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java @@ -16,9 +16,6 @@ package com.android.settings.accessibility; -import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME; - -import android.content.ComponentName; import android.content.Context; import android.database.ContentObserver; import android.hardware.display.ColorDisplayManager; @@ -29,12 +26,12 @@ import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; -import androidx.annotation.Nullable; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.server.display.feature.flags.Flags; import com.android.settings.R; +import com.android.settings.core.TogglePreferenceController; import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnStart; @@ -42,7 +39,7 @@ import com.android.settingslib.core.lifecycle.events.OnStop; /** PreferenceController that shows the Reduce Bright Colors summary */ public class ReduceBrightColorsPreferenceController - extends AccessibilityQuickSettingsPrimarySwitchPreferenceController + extends TogglePreferenceController implements LifecycleObserver, OnStart, OnStop { private ContentObserver mSettingsContentObserver; private PrimarySwitchPreference mPreference; @@ -72,7 +69,6 @@ public class ReduceBrightColorsPreferenceController @Override public boolean setChecked(boolean isChecked) { - super.setChecked(isChecked); return mColorDisplayManager.setReduceBrightColorsActivated(isChecked); } @@ -125,20 +121,4 @@ public class ReduceBrightColorsPreferenceController public void onStop() { mContext.getContentResolver().unregisterContentObserver(mSettingsContentObserver); } - - @Nullable - @Override - protected ComponentName getTileComponentName() { - // TODO: When clean up the feature flag, change the parent class from - // AccessibilityQuickSettingsPrimarySwitchPreferenceController to - // TogglePreferenceController - return android.view.accessibility.Flags.a11yQsShortcut() - ? null : REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME; - } - - @Override - CharSequence getTileTooltipContent() { - return mContext.getText( - R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content); - } } diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java index e41d857bbdb..5ccea524cd0 100644 --- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java @@ -452,15 +452,11 @@ public class ToggleAccessibilityServicePreferenceFragment extends @Override protected int getDefaultShortcutTypes() { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityServiceInfo info = getAccessibilityServiceInfo(); - boolean isAccessibilityTool = info != null && info.isAccessibilityTool(); - return !isAccessibilityTool || getTileComponentName() == null - ? super.getDefaultShortcutTypes() - : ShortcutConstants.UserShortcutType.QUICK_SETTINGS; - } - - return super.getDefaultShortcutTypes(); + AccessibilityServiceInfo info = getAccessibilityServiceInfo(); + boolean isAccessibilityTool = info != null && info.isAccessibilityTool(); + return !isAccessibilityTool || getTileComponentName() == null + ? super.getDefaultShortcutTypes() + : ShortcutConstants.UserShortcutType.QUICK_SETTINGS; } private void onAllowButtonFromEnableToggleClicked() { diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index a9f422e3749..b7f46025349 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -167,9 +167,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment final List shortcutFeatureKeys = new ArrayList<>(); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); - if (android.view.accessibility.Flags.a11yQsShortcut()) { - shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); - } + shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS); return shortcutFeatureKeys; } @@ -750,44 +748,13 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment showQuickSettingsTooltipIfNeeded(); } + /** + * @deprecated made obsolete by quick settings rollout. + * + * (TODO 367414968: finish removal.) + */ + @Deprecated private void showQuickSettingsTooltipIfNeeded() { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - // Don't show Quick Settings tooltip - return; - } - final ComponentName tileComponentName = getTileComponentName(); - if (tileComponentName == null) { - // Returns if no tile service assigned. - return; - } - - Activity activity = getActivity(); - if (activity != null && WizardManagerHelper.isAnySetupWizard(activity.getIntent())) { - // Don't show QuickSettingsTooltip in Setup Wizard - return; - } - - if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences( - getContext(), tileComponentName)) { - // Returns if quick settings tooltip only show once. - return; - } - - final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType); - if (TextUtils.isEmpty(content)) { - // Returns if no content of tile tooltip assigned. - return; - } - - final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT - ? R.drawable.accessibility_qs_tooltip_illustration - : R.drawable.accessibility_auto_added_qs_tooltip_illustration; - mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); - mTooltipWindow.setup(content, imageResId); - mTooltipWindow.showAtTopCenter(getView()); - AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(), - tileComponentName); - mNeedsQSTooltipReshow = false; } /** Returns user visible name of the tile by given {@link ComponentName}. */ diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java index 68089d50d7e..f2254609ade 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -56,6 +56,7 @@ 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; @@ -74,7 +75,6 @@ import com.google.android.setupcompat.util.WizardManagerHelper; import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.StringJoiner; import java.util.stream.Stream; /** @@ -203,13 +203,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends } final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY); - // LINT.IfChange(:preference_list) + // LINT.IfChange(preference_list) addMagnificationModeSetting(generalCategory); addFollowTypingSetting(generalCategory); addOneFingerPanningSetting(generalCategory); addAlwaysOnSetting(generalCategory); addJoystickSetting(generalCategory); - // LINT.ThenChange(:search_data) + // LINT.ThenChange(search_data) } @Override @@ -588,70 +588,29 @@ public class ToggleScreenMagnificationPreferenceFragment extends optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP); } } - if (android.view.accessibility.Flags.a11yQsShortcut()) { - if (((shortcutTypes & QUICK_SETTINGS) - == QUICK_SETTINGS)) { - optInMagnificationValueToSettings(context, QUICK_SETTINGS); - } + 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) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ true, - shortcutType, - Set.of(MAGNIFICATION_CONTROLLER_NAME), - UserHandle.myUserId() - ); - } - return; - } - - if (shortcutType == TRIPLETAP) { - Settings.Secure.putInt(context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON); - return; - } - - if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) { - if (shortcutType == TWOFINGER_DOUBLETAP) { - Settings.Secure.putInt( - context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, - ON); - return; - } - } - - if (hasMagnificationValueInSettings(context, shortcutType)) { - return; - } - - final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType); - final String targetString = Settings.Secure.getString(context.getContentResolver(), - targetKey); - final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR)); - - if (!TextUtils.isEmpty(targetString)) { - joiner.add(targetString); - } - joiner.add(MAGNIFICATION_CONTROLLER_NAME); - - Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString()); - // The size setting defaults to unknown. If the user has ever manually changed the size - // before, we do not automatically change it. - if (shortcutType == SOFTWARE - && Settings.Secure.getInt(context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.UNKNOWN) - == FloatingMenuSizePreferenceController.Size.UNKNOWN) { - Settings.Secure.putInt(context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.LARGE); + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ true, + shortcutType, + Set.of(MAGNIFICATION_CONTROLLER_NAME), + UserHandle.myUserId() + ); } } @@ -676,65 +635,30 @@ public class ToggleScreenMagnificationPreferenceFragment extends optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP); } } - if (android.view.accessibility.Flags.a11yQsShortcut()) { - if (((shortcutTypes & QUICK_SETTINGS) + if (((shortcutTypes & QUICK_SETTINGS) == QUICK_SETTINGS)) { - optOutMagnificationValueFromSettings(context, 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) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets( - /* enable= */ false, - shortcutType, - Set.of(MAGNIFICATION_CONTROLLER_NAME), - UserHandle.myUserId() - ); - } - return; + AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets( + /* enable= */ false, + shortcutType, + Set.of(MAGNIFICATION_CONTROLLER_NAME), + UserHandle.myUserId() + ); } - - if (shortcutType == TRIPLETAP) { - Settings.Secure.putInt(context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF); - return; - } - - if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) { - if (shortcutType == TWOFINGER_DOUBLETAP) { - Settings.Secure.putInt( - context.getContentResolver(), - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, - OFF); - return; - } - } - - final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType); - final String targetString = Settings.Secure.getString(context.getContentResolver(), - targetKey); - - if (TextUtils.isEmpty(targetString)) { - return; - } - - final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR)); - - sStringColonSplitter.setString(targetString); - while (sStringColonSplitter.hasNext()) { - final String name = sStringColonSplitter.next(); - if (TextUtils.isEmpty(name) || MAGNIFICATION_CONTROLLER_NAME.equals(name)) { - continue; - } - joiner.add(name); - } - - Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString()); } @VisibleForTesting @@ -788,15 +712,16 @@ public class ToggleScreenMagnificationPreferenceFragment extends 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 ((shortcutType & (TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE | TRIPLETAP)) - == shortcutType - && !android.view.accessibility.Flags.a11yQsShortcut()) { - // These shortcuts will throw if we try to look up their settings without the flag. - continue; - } if (hasMagnificationValueInSettings(context, shortcutType)) { shortcutTypes |= shortcutType; } @@ -831,7 +756,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { - // LINT.IfChange(:search_data) + // LINT.IfChange(search_data) @Override public List getRawDataToIndex(Context context, boolean enabled) { @@ -887,7 +812,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends } return niks; } - // LINT.ThenChange(:preference_list) + // LINT.ThenChange(preference_list) private SearchIndexableRaw createPreferenceSearchData( Context context, Preference pref) { diff --git a/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionController.java b/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionController.java index eeecd1f3050..892ae1ef30d 100644 --- a/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionController.java +++ b/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionController.java @@ -25,7 +25,6 @@ import android.os.UserHandle; import android.service.quicksettings.TileService; import android.util.ArraySet; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.annotation.NonNull; import androidx.preference.Preference; @@ -82,8 +81,7 @@ public class QuickSettingsShortcutOptionController extends ShortcutOptionPrefere @Override protected boolean isShortcutAvailable() { - return Flags.a11yQsShortcut() - && TileService.isQuickSettingsSupported() + return TileService.isQuickSettingsSupported() && allTargetsHasQsTile() && allTargetsHasValidQsTileUseCase(); } diff --git a/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java b/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java index defb256c8f5..afb5acf272c 100644 --- a/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java +++ b/src/com/android/settings/accessibility/shortcuts/ShortcutOptionPreferenceController.java @@ -19,7 +19,6 @@ package com.android.settings.accessibility.shortcuts; import android.content.Context; import android.os.UserHandle; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.annotation.NonNull; import androidx.preference.Preference; @@ -111,36 +110,27 @@ public abstract class ShortcutOptionPreferenceController extends BasePreferenceC return !targets.isEmpty() && targets.containsAll(getShortcutTargets()); } + /** * 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 shortcutTargets = getShortcutTargets(); @ShortcutConstants.UserShortcutType int shortcutType = getShortcutType(); - if (Flags.a11yQsShortcut()) { - AccessibilityManager a11yManager = mContext.getSystemService( - AccessibilityManager.class); - if (a11yManager != null) { - a11yManager.enableShortcutsForTargets(enable, shortcutType, shortcutTargets, - UserHandle.myUserId()); - } - return; + AccessibilityManager a11yManager = mContext.getSystemService( + AccessibilityManager.class); + if (a11yManager != null) { + a11yManager.enableShortcutsForTargets(enable, shortcutType, shortcutTargets, + UserHandle.myUserId()); } - - if (enable) { - for (String target : shortcutTargets) { - ShortcutUtils.optInValueToSettings(mContext, shortcutType, target); - } - } else { - for (String target : shortcutTargets) { - ShortcutUtils.optOutValueFromSettings(mContext, shortcutType, target); - } - } - ShortcutUtils.updateInvisibleToggleAccessibilityServiceEnableState( - mContext, shortcutTargets, UserHandle.myUserId()); } - /** * Returns true when the user can associate a shortcut to the targets */ diff --git a/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceController.java b/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceController.java index 861bebd83ef..3f35d1cf4b8 100644 --- a/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceController.java +++ b/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceController.java @@ -19,14 +19,11 @@ package com.android.settings.accessibility.shortcuts; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; import android.content.Context; -import android.provider.Settings; import android.view.View; -import android.view.accessibility.Flags; import com.android.internal.accessibility.common.ShortcutConstants; import com.android.settings.R; import com.android.settings.accessibility.AccessibilityButtonFragment; -import com.android.settings.accessibility.FloatingMenuSizePreferenceController; import com.android.settings.core.SubSettingLauncher; import com.android.settings.utils.AnnotationSpan; @@ -62,26 +59,4 @@ public abstract class SoftwareShortcutOptionPreferenceController R.string.accessibility_shortcut_edit_dialog_summary_software_floating), linkInfo); } - - @Override - protected void enableShortcutForTargets(boolean enable) { - super.enableShortcutForTargets(enable); - if (Flags.a11yQsShortcut()) { - return; - } - - if (enable) { - // Update the A11y FAB size to large when the Magnification shortcut is enabled - // and the user hasn't changed the floating button size - if (isMagnificationInTargets() - && Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.UNKNOWN) - == FloatingMenuSizePreferenceController.Size.UNKNOWN) { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.LARGE); - } - } - } } diff --git a/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionController.java b/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionController.java index bdec9a6f290..3f0d80a5966 100644 --- a/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionController.java +++ b/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionController.java @@ -20,7 +20,6 @@ import static com.android.internal.accessibility.AccessibilityShortcutController import android.content.Context; import android.provider.Settings; -import android.view.accessibility.Flags; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; @@ -99,17 +98,4 @@ public class TripleTapShortcutOptionController extends ShortcutOptionPreferenceC Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON; } - - @Override - protected void enableShortcutForTargets(boolean enable) { - if (Flags.a11yQsShortcut()) { - super.enableShortcutForTargets(enable); - return; - } - - Settings.Secure.putInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, - enable ? AccessibilityUtil.State.ON : AccessibilityUtil.State.OFF); - } } diff --git a/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionController.java b/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionController.java index 26e8386efbc..c88a1ccb1a2 100644 --- a/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionController.java +++ b/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionController.java @@ -86,16 +86,4 @@ public class TwoFingerDoubleTapShortcutOptionController Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON; } - - @Override - protected void enableShortcutForTargets(boolean enable) { - if (android.view.accessibility.Flags.a11yQsShortcut()) { - super.enableShortcutForTargets(enable); - return; - } - Settings.Secure.putInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, - enable ? AccessibilityUtil.State.ON : AccessibilityUtil.State.OFF); - } } diff --git a/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionController.java b/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionController.java index f3da35b66da..eb7b82d389f 100644 --- a/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionController.java +++ b/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionController.java @@ -17,14 +17,12 @@ package com.android.settings.accessibility.shortcuts; import android.content.Context; -import android.view.accessibility.Flags; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.internal.accessibility.common.ShortcutConstants; import com.android.settings.R; -import com.android.settings.accessibility.AccessibilityUtil; /** * A controller handles displaying the volume keys shortcut option preference and @@ -61,16 +59,4 @@ public class VolumeKeysShortcutOptionController extends ShortcutOptionPreference protected boolean isShortcutAvailable() { return true; } - - @Override - protected void enableShortcutForTargets(boolean enable) { - super.enableShortcutForTargets(enable); - if (Flags.a11yQsShortcut()) { - return; - } - - if (enable) { - AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(mContext); - } - } } diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest.java deleted file mode 100644 index 08cbaae4efc..00000000000 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2022 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.accessibility; - -import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW; - -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; - -import android.content.ComponentName; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.widget.LinearLayout; -import android.widget.PopupWindow; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.preference.PreferenceViewHolder; -import androidx.test.core.app.ApplicationProvider; - -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.testutils.shadow.ShadowFragment; -import com.android.settingslib.PrimarySwitchPreference; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadow.api.Shadow; -import org.robolectric.shadows.ShadowApplication; -import org.robolectric.shadows.ShadowLooper; - -/** - * Tests for {@link AccessibilityQuickSettingsPrimarySwitchPreferenceController}. - */ -@RunWith(RobolectricTestRunner.class) -public class AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest { - - private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example"; - private static final String PLACEHOLDER_TILE_CLASS_NAME = - PLACEHOLDER_PACKAGE_NAME + "tile.placeholder"; - private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName( - PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME); - private static final CharSequence PLACEHOLDER_TILE_CONTENT = - PLACEHOLDER_TILE_CLASS_NAME + ".tile.content"; - private static final String TEST_KEY = "test_pref_key"; - private static final String TEST_TITLE = "test_title"; - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule(); - - @Spy - private final Context mContext = ApplicationProvider.getApplicationContext(); - - private TestAccessibilityQuickSettingsPrimarySwitchPreferenceController mController; - private PrimarySwitchPreference mPreference; - private TestFragment mFragment; - private PreferenceScreen mScreen; - private PreferenceViewHolder mHolder; - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private PreferenceManager mPreferenceManager; - - private static PopupWindow getLatestPopupWindow() { - final ShadowApplication shadowApplication = - Shadow.extract(ApplicationProvider.getApplicationContext()); - return shadowApplication.getLatestPopupWindow(); - } - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - - mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat); - mFragment = spy(new TestFragment()); - when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager); - when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext); - when(mFragment.getContext()).thenReturn(mContext); - mScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null)); - when(mScreen.getPreferenceManager()).thenReturn(mPreferenceManager); - doReturn(mScreen).when(mFragment).getPreferenceScreen(); - - mPreference = new PrimarySwitchPreference(mContext); - mPreference.setKey(TEST_KEY); - mPreference.setTitle(TEST_TITLE); - LayoutInflater inflater = LayoutInflater.from(mContext); - mHolder = PreferenceViewHolder.createInstanceForTests(inflater.inflate( - com.android.settingslib.widget.preference.twotarget.R.layout.preference_two_target, null)); - LinearLayout mWidgetView = mHolder.itemView.findViewById(android.R.id.widget_frame); - inflater.inflate(R.layout.preference_widget_primary_switch, mWidgetView, true); - mPreference.onBindViewHolder(mHolder); - - mController = new TestAccessibilityQuickSettingsPrimarySwitchPreferenceController(mContext, - TEST_KEY); - when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); - } - - @Test - public void setChecked_showTooltipView() { - mController.displayPreference(mScreen); - - mController.setChecked(true); - - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - - @Test - public void setChecked_notCallDisplayPreference_notShowTooltipView() { - // Simulates the slice highlight menu that does not call {@link #displayPreference} before - // {@link #setChecked} called. - mController.setChecked(true); - - assertThat(getLatestPopupWindow()).isNull(); - } - - @Test - public void setChecked_tooltipViewShown_notShowTooltipView() { - mController.displayPreference(mScreen); - mController.setChecked(true); - getLatestPopupWindow().dismiss(); - mController.setChecked(false); - - mController.setChecked(true); - - assertThat(getLatestPopupWindow().isShowing()).isFalse(); - } - - @Test - @Config(shadows = ShadowFragment.class) - public void restoreValueFromSavedInstanceState_showTooltipView() { - final Bundle savedInstanceState = new Bundle(); - savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true); - mController.onCreate(savedInstanceState); - - mController.displayPreference(mScreen); - ShadowLooper.idleMainLooper(); - - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - - public static class TestAccessibilityQuickSettingsPrimarySwitchPreferenceController - extends AccessibilityQuickSettingsPrimarySwitchPreferenceController { - - public TestAccessibilityQuickSettingsPrimarySwitchPreferenceController(Context context, - String preferenceKey) { - super(context, preferenceKey); - } - - @Override - ComponentName getTileComponentName() { - return PLACEHOLDER_TILE_COMPONENT_NAME; - } - - @Override - CharSequence getTileTooltipContent() { - return PLACEHOLDER_TILE_CONTENT; - } - } - - private static class TestFragment extends SettingsPreferenceFragment { - - @Override - protected boolean shouldSkipForInitialSUW() { - return false; - } - - @Override - public int getMetricsCategory() { - return 0; - } - } -} diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java index 36578a90e25..939b2e4b800 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java @@ -376,21 +376,7 @@ public class AccessibilitySettingsTest { } @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onCreate_flagDisabled_haveRegisterToSpecificUrisAndActions() { - setupFragment(); - - assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, - AccessibilitySettingsContentObserver.class).isTrue(); - assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, - AccessibilitySettingsContentObserver.class).isTrue(); - assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_QS_TARGETS, - AccessibilitySettingsContentObserver.class).isFalse(); - } - - @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onCreate_flagEnabled_haveRegisterToSpecificUrisAndActions() { + public void onCreate_haveRegisterToSpecificUrisAndActions() { setupFragment(); assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java index 9d18c44e392..ca18e269a50 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java @@ -19,7 +19,6 @@ package com.android.settings.accessibility; 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.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW; import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType; import static com.google.common.truth.Truth.assertThat; @@ -38,14 +37,11 @@ import android.content.Context; import android.content.Intent; import android.icu.text.CaseMap; import android.os.Bundle; -import android.platform.test.annotations.DisableFlags; -import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.Flags; import android.widget.PopupWindow; import androidx.annotation.Nullable; @@ -156,25 +152,6 @@ public class AccessibilityShortcutPreferenceFragmentTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - @Config(shadows = ShadowFragment.class) - public void restoreValueFromSavedInstanceState_showTooltipView() { - mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat); - mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT); - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - - final Bundle savedInstanceState = new Bundle(); - savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true); - mFragment.onAttach(mContext); - mFragment.onCreate(savedInstanceState); - mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY); - mFragment.onViewCreated(mFragment.getView(), savedInstanceState); - - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) @Config(shadows = ShadowFragment.class) public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() { mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT); @@ -219,7 +196,6 @@ public class AccessibilityShortcutPreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { final PreferredShortcut userPreferredShortcut = new PreferredShortcut( PLACEHOLDER_COMPONENT_NAME.flattenToString(), diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java index cd8743d595b..779866229ce 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java @@ -133,7 +133,6 @@ public final class AccessibilityShortcutsTutorialTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void createTutorialPages_turnOnQuickSettingShortcut_hasOnePage() { mShortcutTypes |= QUICK_SETTINGS; @@ -260,7 +259,6 @@ public final class AccessibilityShortcutsTutorialTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOn_verifyText() { mShortcutTypes |= QUICK_SETTINGS; setTouchExplorationEnabled(true); @@ -292,7 +290,6 @@ public final class AccessibilityShortcutsTutorialTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOn_verifyText() { mShortcutTypes |= QUICK_SETTINGS; setTouchExplorationEnabled(true); @@ -318,7 +315,6 @@ public final class AccessibilityShortcutsTutorialTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOff_verifyText() { mShortcutTypes |= QUICK_SETTINGS; setTouchExplorationEnabled(false); @@ -349,7 +345,6 @@ public final class AccessibilityShortcutsTutorialTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOff_verifyText() { mShortcutTypes |= QUICK_SETTINGS; setTouchExplorationEnabled(false); diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java index ee3d9360e2c..24db847dffa 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java @@ -46,7 +46,6 @@ import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.test.core.app.ApplicationProvider; @@ -203,7 +202,6 @@ public final class AccessibilityUtilTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getUserShortcutTypeFromSettings_threeShortcutTypesChosen() { setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString()); @@ -220,22 +218,6 @@ public final class AccessibilityUtilTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInAllValuesToSettings_optInValue_haveMatchString() { - clearShortcuts(); - int shortcutTypes = SOFTWARE | HARDWARE; - - AccessibilityUtil.optInAllValuesToSettings(mContext, shortcutTypes, MOCK_COMPONENT_NAME); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - MOCK_COMPONENT_NAME.flattenToString()); - assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo( - MOCK_COMPONENT_NAME.flattenToString()); - - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void optInAllValuesToSettings_optInValue_callsA11yManager() { AccessibilityManager a11yManager = AccessibilityTestUtils.setupMockAccessibilityManager(mContext); @@ -252,20 +234,6 @@ public final class AccessibilityUtilTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInValueToSettings_optInValue_haveMatchString() { - setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); - - AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE, - MOCK_COMPONENT_NAME2); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - MOCK_COMPONENT_NAME.flattenToString() + ":" - + MOCK_COMPONENT_NAME2.flattenToString()); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void optInValueToSettings_optInValue_callsA11yManager() { AccessibilityManager a11yManager = AccessibilityTestUtils.setupMockAccessibilityManager(mContext); @@ -281,37 +249,6 @@ public final class AccessibilityUtilTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInValueToSettings_optInTwoValues_haveMatchString() { - setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); - - AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE, - MOCK_COMPONENT_NAME2); - AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE, - MOCK_COMPONENT_NAME2); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - MOCK_COMPONENT_NAME.flattenToString() + ":" - + MOCK_COMPONENT_NAME2.flattenToString()); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutAllValuesToSettings_optOutValue_emptyString() { - setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); - setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString()); - int shortcutTypes = - SOFTWARE | HARDWARE | TRIPLETAP; - - AccessibilityUtil.optOutAllValuesFromSettings(mContext, shortcutTypes, - MOCK_COMPONENT_NAME); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty(); - assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void optOutAllValuesToSettings_optOutValue_callsA1yManager() { AccessibilityManager a11yManager = AccessibilityTestUtils.setupMockAccessibilityManager(mContext); @@ -331,31 +268,6 @@ public final class AccessibilityUtilTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutValueFromSettings_optOutValue_emptyString() { - setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); - - AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE, - MOCK_COMPONENT_NAME); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty(); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutValueFromSettings_optOutValue_haveMatchString() { - setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString(), - MOCK_COMPONENT_NAME2.flattenToString()); - - AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE, - MOCK_COMPONENT_NAME2); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - MOCK_COMPONENT_NAME.flattenToString()); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void optOutValueFromSettings_optOutValue_callsA11yManager() { AccessibilityManager a11yManager = AccessibilityTestUtils.setupMockAccessibilityManager(mContext); @@ -389,7 +301,6 @@ public final class AccessibilityUtilTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() { assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP)) .isEqualTo( @@ -397,7 +308,6 @@ public final class AccessibilityUtilTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void convertKeyFromSettings_shortcutTypeQuickSettings() { assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS)) .isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS); diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java index b00d8d899f7..c222d3fd66d 100644 --- a/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java @@ -22,7 +22,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.when; - import static org.robolectric.Shadows.shadowOf; import android.content.Context; diff --git a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java index 78f49a66906..76b93b03c94 100644 --- a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java @@ -26,8 +26,8 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.app.settings.SettingsEnums; import android.content.ContentResolver; diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java index 355e8c32041..da8059c25ec 100644 --- a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java @@ -30,10 +30,10 @@ import android.provider.Settings; import androidx.preference.PreferenceScreen; import androidx.test.core.app.ApplicationProvider; -import com.android.settings.core.BasePreferenceController; import com.android.settings.R; -import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor; +import com.android.settings.core.BasePreferenceController; import com.android.settings.testutils.shadow.SettingsShadowResources; +import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor; import com.android.settings.widget.SeekBarPreference; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java index 501bbb0e102..348ac45c5dd 100644 --- a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java @@ -31,9 +31,9 @@ import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import androidx.test.core.app.ApplicationProvider; +import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settings.testutils.shadow.SettingsShadowResources; -import com.android.settings.R; import com.android.settingslib.core.lifecycle.Lifecycle; import org.junit.After; @@ -42,8 +42,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.robolectric.annotation.Config; import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; /** Test for {@link MediaVibrationIntensityPreferenceController}. */ @RunWith(RobolectricTestRunner.class) diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java index 008f542b500..70290af8a61 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java @@ -34,13 +34,8 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Bundle; -import android.platform.test.annotations.DisableFlags; -import android.platform.test.annotations.EnableFlags; -import android.platform.test.flag.junit.SetFlagsRule; -import android.provider.Settings; import android.service.quicksettings.TileService; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; @@ -55,7 +50,6 @@ import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragm import com.android.settings.widget.SettingsMainSwitchPreference; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; @@ -75,8 +69,6 @@ import java.util.Set; @RunWith(RobolectricTestRunner.class) public class ToggleAccessibilityServicePreferenceFragmentTest { - @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); - private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example"; private static final String PLACEHOLDER_PACKAGE_NAME2 = "com.placeholder.example2"; private static final String PLACEHOLDER_SERVICE_CLASS_NAME = "a11yservice1"; @@ -314,30 +306,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void getDefaultShortcutTypes_noAssociatedTile_softwareTypeIsDefault() throws Throwable { - PreferredShortcuts.clearPreferredShortcuts(mContext); - setupAccessibilityServiceInfoForFragment( - /* isAccessibilityTool= */ true, - /* tileService= */ null - /* warningRequired= */); - - assertThat(mFragment.getDefaultShortcutTypes()) - .isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void getDefaultShortcutTypes_hasAssociatedTile_softwareTypeIsDefault() { - PreferredShortcuts.clearPreferredShortcuts(mContext); - when(mFragment.getTileComponentName()).thenReturn(PLACEHOLDER_TILE_COMPONENT_NAME); - - assertThat(mFragment.getDefaultShortcutTypes()) - .isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getDefaultShortcutTypes_isAccessibilityTool_hasAssociatedTile_qsTypeIsDefault() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -351,7 +319,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getDefaultShortcutTypes_isNotAccessibilityTool_hasAssociatedTile_softwareTypeIsDefault() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -365,7 +332,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getDefaultShortcutTypes_isAccessibilityTool_noAssociatedTile_softwareTypeIsDefault() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -379,7 +345,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void getDefaultShortcutTypes_isNotAccessibilityTool_noAssociatedTile_softwareTypeIsDefault() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -393,7 +358,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -413,7 +377,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut() throws Throwable { PreferredShortcuts.clearPreferredShortcuts(mContext); @@ -433,47 +396,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_flagOff_enableSoftwareShortcut() - throws Throwable { - PreferredShortcuts.clearPreferredShortcuts(mContext); - setupAccessibilityServiceInfoForFragment( - /* isAccessibilityTool= */ true, - /* tileService= */ PLACEHOLDER_TILE_COMPONENT_NAME - /* warningRequired= */); - mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null); - - mFragment.mShortcutPreference.setChecked(true); - mFragment.onToggleClicked(mFragment.mShortcutPreference); - - assertThat( - Settings.Secure.getString(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS)) - .contains(mFragment.mComponentName.flattenToString()); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_flagOff_enableSoftwareShortcut() - throws Throwable { - PreferredShortcuts.clearPreferredShortcuts(mContext); - setupAccessibilityServiceInfoForFragment( - /* isAccessibilityTool= */ true, - /* tileService= */ null - /* warningRequired= */); - mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null); - - mFragment.mShortcutPreference.setChecked(true); - mFragment.onToggleClicked(mFragment.mShortcutPreference); - - assertThat( - Settings.Secure.getString(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS)) - .contains(mFragment.mComponentName.flattenToString()); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void toggleShortcutPreference_userPreferVolumeKeysShortcut_noQsTile_enableVolumeKeysShortcut() throws Throwable { setupAccessibilityServiceInfoForFragment( @@ -498,7 +420,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut() throws Throwable { setupAccessibilityServiceInfoForFragment( diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java index e9711864909..cbd449305d4 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragmentTest.java @@ -139,25 +139,6 @@ public class ToggleColorInversionPreferenceFragmentTest { assertThat(getLatestPopupWindow()).isNull(); } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onPreferenceToggled_colorCorrectDisabled_shouldReturnTrueAndShowTooltipView() { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF); - mSwitchPreference.setChecked(false); - mFragment.onAttach(mContext); - mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY); - mFragment.onViewCreated(mFragment.getView(), Bundle.EMPTY); - - mFragment.onPreferenceToggled(mSwitchPreference.getKey(), true); - - final boolean isEnabled = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF) == ON; - assertThat(isEnabled).isTrue(); - assertThat(getLatestPopupWindow()).isNotNull(); - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - @Test public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() { Settings.Secure.putInt(mContext.getContentResolver(), diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java index a33fefbb404..390a8ca6e38 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragmentTest.java @@ -106,23 +106,6 @@ public class ToggleDaltonizerPreferenceFragmentTest { assertThat(getLatestPopupWindow()).isNull(); } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onPreferenceToggled_colorCorrectDisabled_shouldReturnTrueAndShowTooltipView() { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF); - ToggleDaltonizerPreferenceFragment fragment = getFragmentInResumedState(); - SettingsMainSwitchPreference switchPreference = getMainFeatureToggle(fragment); - - fragment.onPreferenceToggled(switchPreference.getKey(), true); - - final boolean isEnabled = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF) == ON; - assertThat(isEnabled).isTrue(); - assertThat(getLatestPopupWindow()).isNotNull(); - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - @Test public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() { Settings.Secure.putInt(mContext.getContentResolver(), diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java index 844fabe2647..87ab52dbab5 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java @@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -38,7 +37,6 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.icu.text.CaseMap; import android.os.Bundle; -import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; @@ -142,7 +140,6 @@ public class ToggleFeaturePreferenceFragmentTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) @Config(shadows = {ShadowFragment.class}) public void onResume_flagEnabled_haveRegisterToSpecificUris() { mFragment.onAttach(mContext); @@ -166,31 +163,6 @@ public class ToggleFeaturePreferenceFragmentTest { any(AccessibilitySettingsContentObserver.class)); } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - @Config(shadows = {ShadowFragment.class}) - public void onResume_flagDisabled_haveRegisterToSpecificUris() { - mFragment.onAttach(mContext); - mFragment.onCreate(Bundle.EMPTY); - - mFragment.onResume(); - - verify(mContentResolver).registerContentObserver( - eq(Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS)), - eq(false), - any(AccessibilitySettingsContentObserver.class)); - verify(mContentResolver).registerContentObserver( - eq(Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE)), - eq(false), - any(AccessibilitySettingsContentObserver.class)); - verify(mContentResolver, never()).registerContentObserver( - eq(Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_QS_TARGETS)), - eq(false), - any(AccessibilitySettingsContentObserver.class)); - } - @Test public void updateShortcutPreferenceData_assignDefaultValueToVariable() { mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME; @@ -240,15 +212,6 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(getLatestPopupWindow()).isNull(); } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - @Config(shadows = ShadowFragment.class) - public void onPreferenceToggledOnEnabledService_showTooltipView() { - mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true); - - assertThat(getLatestPopupWindow().isShowing()).isTrue(); - } - @Test @Config(shadows = ShadowFragment.class) public void onPreferenceToggledOnEnabledService_inSuw_toolTipViewShouldNotShow() { @@ -261,18 +224,6 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(getLatestPopupWindow()).isNull(); } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - @Config(shadows = ShadowFragment.class) - public void onPreferenceToggledOnEnabledService_tooltipViewShown_notShowTooltipView() { - mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true); - getLatestPopupWindow().dismiss(); - - mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true); - - assertThat(getLatestPopupWindow().isShowing()).isFalse(); - } - @Test public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() { mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO; @@ -365,7 +316,6 @@ public class ToggleFeaturePreferenceFragmentTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) @Config(shadows = ShadowFragment.class) public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() { mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT); @@ -374,7 +324,6 @@ public class ToggleFeaturePreferenceFragmentTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { final PreferredShortcut userPreferredShortcut = new PreferredShortcut( PLACEHOLDER_COMPONENT_NAME.flattenToString(), diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java index 87632ae8a64..0b385941997 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java @@ -337,8 +337,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onResume_flagEnabled_haveRegisterToSpecificUris() { + public void onResume_haveRegisterToSpecificUris() { ShadowContentResolver shadowContentResolver = Shadows.shadowOf( mContext.getContentResolver()); Uri[] observedUri = new Uri[]{ @@ -367,38 +366,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { } } - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void onResume_flagDisabled_haveRegisterToSpecificUris() { - ShadowContentResolver shadowContentResolver = Shadows.shadowOf( - mContext.getContentResolver()); - Uri[] observedUri = new Uri[]{ - Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS), - Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE), - Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED), - Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED) - }; - for (Uri uri : observedUri) { - // verify no observer registered before launching the fragment - assertThat(shadowContentResolver.getContentObservers(uri)).isEmpty(); - } - - mFragController.create(R.id.main_content, /* bundle= */ null).start().resume(); - - for (Uri uri : observedUri) { - Collection observers = shadowContentResolver.getContentObservers(uri); - assertThat(observers.size()).isEqualTo(1); - assertThat(observers.stream().findFirst().get()).isInstanceOf( - AccessibilitySettingsContentObserver.class); - } - assertThat(shadowContentResolver.getContentObservers( - Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_QS_TARGETS))).hasSize(0); - } - @Test @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE) public void onResume_oneFingerPanningFlagOn_registerToSpecificUri() { @@ -462,20 +429,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { } @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInAllValuesToSettings_optInValue_haveMatchString() { - int shortcutTypes = SOFTWARE | TRIPLETAP; - - ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext, - shortcutTypes); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - MAGNIFICATION_CONTROLLER_NAME); - assertThat(getMagnificationTripleTapStatus()).isTrue(); - } - - @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void optInAllValuesToSettings_optInValue_callA11yManager() { int shortcutTypes = SOFTWARE | TRIPLETAP | HARDWARE @@ -500,45 +453,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { verifyNoMoreInteractions(mAccessibilityManager); } - @Test - @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE) - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInAllValuesToSettings_twoFingerTripleTap_haveMatchString() { - int shortcutTypes = TWOFINGER_DOUBLETAP; - - ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext, - shortcutTypes); - - assertThat(Settings.Secure.getInt(mContext.getContentResolver(), - TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF)).isEqualTo(ON); - } - - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() { - putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString()); - - ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext, - SOFTWARE); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME); - } - - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optInAllValuesToSettings_software_sizeValueIsNull_putLargeSizeValue() { - ShadowSettings.ShadowSecure.reset(); - - ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext, - SOFTWARE); - - assertThat(Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.UNKNOWN)).isEqualTo( - FloatingMenuSizePreferenceController.Size.LARGE); - } - @Test public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() { for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE, @@ -594,24 +508,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { } @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutAllValuesToSettings_optOutValue_emptyString() { - 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); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty(); - assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty(); - assertThat(getMagnificationTripleTapStatus()).isFalse(); - } - - @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void optOutAllValuesToSettings_optOutValue_callA11yManager() { Set shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME); putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME); @@ -635,38 +531,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { verifyNoMoreInteractions(mAccessibilityManager); } - @Test - @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE) - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutAllValuesToSettings_twoFingerTripleTap_settingsValueIsOff() { - Settings.Secure.putInt(mContext.getContentResolver(), - TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON); - - ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings( - mContext, TWOFINGER_DOUBLETAP); - - assertThat(Settings.Secure.getInt(mContext.getContentResolver(), - TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON)).isEqualTo(OFF); - } - - @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() { - putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, - PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME); - putStringIntoSettings(HARDWARE_SHORTCUT_KEY, - PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME); - int shortcutTypes = SOFTWARE | HARDWARE; - - ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings( - mContext, shortcutTypes); - - assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo( - PLACEHOLDER_COMPONENT_NAME.flattenToString()); - assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo( - PLACEHOLDER_COMPONENT_NAME.flattenToString()); - } - @Test public void updateShortcutPreferenceData_assignDefaultValueToVariable() { mFragController.create(R.id.main_content, /* bundle= */ null).start().resume(); @@ -979,7 +843,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { } @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { final PreferredShortcut userPreferredShortcut = new PreferredShortcut( MAGNIFICATION_CONTROLLER_NAME, diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java index b3270e95c11..dd898e39175 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java @@ -46,7 +46,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.util.Pair; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; @@ -466,7 +465,6 @@ public class EditShortcutsPreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void fragmentResumed_enableTouchExploration_qsShortcutOptionSummaryUpdated() { String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2, R.string.accessibility_shortcut_edit_dialog_summary_quick_settings); @@ -486,7 +484,6 @@ public class EditShortcutsPreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void fragmentPaused_enableTouchExploration_qsShortcutOptionSummaryNotUpdated() { String expectedSummary = StringUtil.getIcuPluralsString(mContext, 1, R.string.accessibility_shortcut_edit_dialog_summary_quick_settings); @@ -644,7 +641,6 @@ public class EditShortcutsPreferenceFragmentTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void onQuickSettingsShortcutSettingChanged_preferredShortcutsUpdated() { final String target = TARGET_FAKE_COMPONENT.flattenToString(); mFragmentScenario = createFragScenario( diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionControllerTest.java index 55fbd8e3249..8f26c99be11 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/QuickSettingsShortcutOptionControllerTest.java @@ -27,11 +27,7 @@ import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; import android.content.Context; 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.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.preference.PreferenceManager; import androidx.preference.PreferenceScreen; @@ -45,7 +41,6 @@ import com.android.settings.testutils.shadow.SettingsShadowResources; import com.android.settingslib.utils.StringUtil; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; @@ -67,8 +62,6 @@ public class QuickSettingsShortcutOptionControllerTest { private static final String TARGET_FLATTEN = TARGET.flattenToString(); private static final ComponentName TARGET_TILE = new ComponentName("FakePackage", "FakeTileClass"); - @Rule - public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private final Context mContext = spy(ApplicationProvider.getApplicationContext()); private QuickSettingsShortcutOptionController mController; @@ -149,13 +142,6 @@ public class QuickSettingsShortcutOptionControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void isShortcutAvailable_a11yQsShortcutFlagDisabled_returnsFalse() { - assertThat(mController.isShortcutAvailable()).isFalse(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void isShortcutAvailable_qsNotSupported_returnsFalse() { SettingsShadowResources.overrideResource( com.android.internal.R.bool.config_quickSettingsSupported, false); @@ -164,7 +150,6 @@ public class QuickSettingsShortcutOptionControllerTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void isShortcutAvailable_qsTileProvided_returnsTrue() { when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId())) .thenReturn(Map.of(TARGET, TARGET_TILE)); @@ -173,7 +158,6 @@ public class QuickSettingsShortcutOptionControllerTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void isShortcutAvailable_qsTileNotProvided_returnsFalse() { when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId())) .thenReturn(Collections.emptyMap()); @@ -182,7 +166,6 @@ public class QuickSettingsShortcutOptionControllerTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void isShortcutAvailable_qsTileProvided_invalidUseCase_returnFalse() { AccessibilityServiceInfo mockStandardA11yService = AccessibilityTestUtils.createAccessibilityServiceInfo( @@ -197,7 +180,6 @@ public class QuickSettingsShortcutOptionControllerTest { } @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void isShortcutAvailable_qsTileProvided_validUseCase_returnTrue() { AccessibilityServiceInfo mockAlwaysOnA11yService = AccessibilityTestUtils.createAccessibilityServiceInfo( diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceControllerTest.java index 1eeb9446c21..74e9870522a 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/SoftwareShortcutOptionPreferenceControllerTest.java @@ -33,14 +33,11 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; 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 android.text.SpannableStringBuilder; import android.view.View; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.fragment.app.FragmentActivity; @@ -50,10 +47,8 @@ import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.SubSettings; import com.android.settings.accessibility.AccessibilityButtonFragment; -import com.android.settings.accessibility.FloatingMenuSizePreferenceController; import com.android.settings.testutils.AccessibilityTestUtils; import com.android.settings.utils.AnnotationSpan; -import com.android.settingslib.accessibility.AccessibilityUtils; import org.junit.Before; import org.junit.Rule; @@ -178,23 +173,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableShortcut_shortcutTurnedOn() { - String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); - mController.setShortcutTargets(Set.of(target)); - assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target - )).isFalse(); - - mController.enableShortcutForTargets(true); - - assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target - )).isTrue(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_enableShortcut_callA11yManager() { String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); mController.setShortcutTargets(Set.of(target)); @@ -214,25 +192,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableShortcut_shortcutTurnedOff() { - String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); - ShortcutUtils.optInValueToSettings( - mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target); - assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target - )).isTrue(); - mController.setShortcutTargets(Set.of(target)); - - mController.enableShortcutForTargets(false); - - assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target - )).isFalse(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_disableShortcut_callA11yManager() { String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); ShortcutUtils.optInValueToSettings( @@ -253,89 +212,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest { verifyNoMoreInteractions(mAccessibilityManager); } - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableShortcutWithMagnification_menuSizeIncreased() { - mController.setShortcutTargets(Set.of(TARGET_MAGNIFICATION)); - - mController.enableShortcutForTargets(true); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.UNKNOWN)) - .isEqualTo(FloatingMenuSizePreferenceController.Size.LARGE); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableShortcutWithMagnification_userConfigureSmallMenuSize_menuSizeNotChanged() { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.SMALL); - mController.setShortcutTargets(Set.of(TARGET_MAGNIFICATION)); - - mController.enableShortcutForTargets(true); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, - FloatingMenuSizePreferenceController.Size.UNKNOWN)) - .isEqualTo(FloatingMenuSizePreferenceController.Size.SMALL); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableAlwaysOnServiceShortcut_turnsOnAlwaysOnService() { - mController.setShortcutTargets( - Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString())); - - mController.enableShortcutForTargets(true); - - assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext)) - .contains(TARGET_ALWAYS_ON_A11Y_SERVICE); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableAlwaysOnServiceShortcut_turnsOffAlwaysOnService() { - mController.setShortcutTargets( - Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString())); - - mController.enableShortcutForTargets(false); - - assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext)) - .doesNotContain(TARGET_ALWAYS_ON_A11Y_SERVICE); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableStandardServiceShortcut_wontTurnOnService() { - mController.setShortcutTargets( - Set.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString())); - - mController.enableShortcutForTargets(true); - - assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext)) - .doesNotContain(TARGET_STANDARD_A11Y_SERVICE); - } - - @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableStandardServiceShortcutWithServiceOn_wontTurnOffService() { - mController.setShortcutTargets( - Set.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString())); - AccessibilityUtils.setAccessibilityServiceState( - mContext, TARGET_STANDARD_A11Y_SERVICE, /* enabled= */ true); - - mController.enableShortcutForTargets(false); - - assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext)) - .contains(TARGET_STANDARD_A11Y_SERVICE); - } - private void assertLaunchSettingsPage(String page) { ContextWrapper applicationContext = (Application) mContext.getApplicationContext(); final Intent intent = Shadows.shadowOf(applicationContext).getNextStartedActivity(); diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionControllerTest.java index 1ffd042b172..6526862634f 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/TripleTapShortcutOptionControllerTest.java @@ -28,12 +28,9 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import android.content.ComponentName; import android.content.Context; 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 android.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.preference.PreferenceManager; import androidx.preference.PreferenceScreen; @@ -182,20 +179,6 @@ public class TripleTapShortcutOptionControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableShortcut_settingUpdated() { - mController.enableShortcutForTargets(true); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, - AccessibilityUtil.State.OFF) - ).isEqualTo(AccessibilityUtil.State.ON); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_enableShortcut_callA11yManager() { mController.enableShortcutForTargets(true); @@ -209,20 +192,6 @@ public class TripleTapShortcutOptionControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableShortcut_settingUpdated() { - mController.enableShortcutForTargets(false); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, - AccessibilityUtil.State.OFF) - ).isEqualTo(AccessibilityUtil.State.OFF); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_disableShortcut_callA11yManager() { mController.enableShortcutForTargets(false); diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionControllerTest.java index dde60e902fa..53048b00775 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/TwoFingerDoubleTapShortcutOptionControllerTest.java @@ -143,20 +143,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest { } @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableShortcut_settingUpdated() { - mController.enableShortcutForTargets(true); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, - AccessibilityUtil.State.OFF) - ).isEqualTo(AccessibilityUtil.State.ON); - } - - @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_enableShortcut_callA11yManager() { mController.enableShortcutForTargets(true); @@ -170,20 +156,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest { } @Test - @DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableShortcut_settingUpdated() { - mController.enableShortcutForTargets(false); - - assertThat( - Settings.Secure.getInt( - mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, - AccessibilityUtil.State.OFF) - ).isEqualTo(AccessibilityUtil.State.OFF); - } - - @Test - @EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_disableShortcut_callA11yManager() { mController.enableShortcutForTargets(false); diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionControllerTest.java index 511503aceba..d9eb995d18e 100644 --- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/VolumeKeysShortcutOptionControllerTest.java @@ -25,11 +25,8 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import android.content.ComponentName; import android.content.Context; 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.view.accessibility.AccessibilityManager; -import android.view.accessibility.Flags; import androidx.preference.PreferenceManager; import androidx.preference.PreferenceScreen; @@ -111,17 +108,6 @@ public class VolumeKeysShortcutOptionControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_enableVolumeKeysShortcut_shortcutSet() { - mController.enableShortcutForTargets(true); - - assertThat( - ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET)).isTrue(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_enableVolumeKeysShortcut_callA11yManager() { mController.enableShortcutForTargets(true); @@ -135,17 +121,6 @@ public class VolumeKeysShortcutOptionControllerTest { } @Test - @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) - public void enableShortcutForTargets_disableVolumeKeysShortcut_shortcutNotSet() { - mController.enableShortcutForTargets(false); - - assertThat( - ShortcutUtils.isComponentIdExistingInSettings( - mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET)).isFalse(); - } - - @Test - @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) public void enableShortcutForTargets_disableVolumeKeysShortcut_callA11yManager() { mController.enableShortcutForTargets(false); diff --git a/tests/unit/src/com/android/settings/accessibility/PreferredShortcutsTest.java b/tests/unit/src/com/android/settings/accessibility/PreferredShortcutsTest.java index d068194cd9c..09c746b732b 100644 --- a/tests/unit/src/com/android/settings/accessibility/PreferredShortcutsTest.java +++ b/tests/unit/src/com/android/settings/accessibility/PreferredShortcutsTest.java @@ -25,12 +25,7 @@ import static com.google.common.truth.Truth.assertThat; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; -import android.platform.test.annotations.RequiresFlagsDisabled; -import android.platform.test.annotations.RequiresFlagsEnabled; -import android.platform.test.flag.junit.CheckFlagsRule; -import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; -import android.view.accessibility.Flags; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -41,7 +36,6 @@ import com.android.internal.accessibility.util.ShortcutUtils; import org.junit.AfterClass; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,8 +55,6 @@ public class PreferredShortcutsTest { CLASS_NAME_2); private static final ContentResolver sContentResolver = ApplicationProvider.getApplicationContext().getContentResolver(); - @Rule - public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); private final Context mContext = ApplicationProvider.getApplicationContext(); @Before @@ -175,7 +167,6 @@ public class PreferredShortcutsTest { } @Test - @RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT) public void updatePreferredShortcutFromSettings_colorInversionWithQsAndSoftwareShortcut_preferredShortcutsMatches() { String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString(); Settings.Secure.putString(sContentResolver, @@ -192,23 +183,6 @@ public class PreferredShortcutsTest { } - @Test - @RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT) - public void updatePreferredShortcutFromSettings_colorInversionWithQsAndHardwareShortcut_qsShortcutNotSaved() { - String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString(); - Settings.Secure.putString(sContentResolver, - Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, target); - Settings.Secure.putString(sContentResolver, - Settings.Secure.ACCESSIBILITY_QS_TARGETS, target); - assertThat(!android.view.accessibility.Flags.a11yQsShortcut()).isTrue(); - - PreferredShortcuts.updatePreferredShortcutsFromSettings(mContext, Set.of(target)); - - int savedPreferredShortcut = PreferredShortcuts.retrieveUserShortcutType( - mContext, target); - assertThat(savedPreferredShortcut).isEqualTo(UserShortcutType.HARDWARE); - } - @Test public void retrieveUserShortcutTypeWithoutDefault_noUserPreferredShortcuts_returnSoftwareShortcut() { String target = COMPONENT_NAME_1.flattenToString(); diff --git a/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java index 7229996b2e3..e1c0277c7e9 100644 --- a/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java @@ -16,8 +16,6 @@ package com.android.settings.accessibility; -import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME; - import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.doReturn; @@ -26,12 +24,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; -import android.platform.test.annotations.RequiresFlagsDisabled; -import android.platform.test.annotations.RequiresFlagsEnabled; -import android.platform.test.flag.junit.CheckFlagsRule; -import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; -import android.view.accessibility.Flags; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -40,7 +33,6 @@ import com.android.internal.R; import org.junit.Before; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,8 +40,6 @@ import org.junit.runner.RunWith; public class ReduceBrightColorsPreferenceControllerTest { private static final String PREF_KEY = "rbc_preference"; - @Rule - public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); private Context mContext; private Resources mResources;; private ReduceBrightColorsPreferenceController mController; @@ -98,20 +88,6 @@ public class ReduceBrightColorsPreferenceControllerTest { assertThat(mController.isAvailable()).isFalse(); } - - @Test - @RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT) - public void getTileComponentName_a11yQsFlagOff_returnComponentName() { - assertThat(mController.getTileComponentName()) - .isEqualTo(REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME); - } - - @Test - @RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT) - public void getTileComponentName_a11yQsFlagOff_returnNull() { - assertThat(mController.getTileComponentName()).isNull(); - } - private int resourceId(String type, String name) { return mContext.getResources().getIdentifier(name, type, mContext.getPackageName()); }