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
This commit is contained in:
Riley Jones
2024-11-21 01:03:39 +00:00
parent e39b2c18d8
commit acccaff128
39 changed files with 159 additions and 1536 deletions

View File

@@ -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;
}
}

View File

@@ -180,9 +180,7 @@ public class AccessibilitySettings extends DashboardFragment implements
// Observe changes from accessibility selection menu // Observe changes from accessibility selection menu
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); 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_STICKY_KEYS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SLOW_KEYS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SLOW_KEYS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS);

View File

@@ -31,7 +31,6 @@ import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -114,9 +113,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
final List<String> shortcutFeatureKeys = new ArrayList<>(); final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); 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 = new AccessibilitySettingsContentObserver(new Handler());
mSettingsContentObserver.registerKeysToObserverCallback(shortcutFeatureKeys, key -> { mSettingsContentObserver.registerKeysToObserverCallback(shortcutFeatureKeys, key -> {
updateShortcutPreferenceData(); updateShortcutPreferenceData();
@@ -374,38 +371,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
showQuickSettingsTooltipIfNeeded(); showQuickSettingsTooltipIfNeeded();
} }
/**
* @deprecated made obsolete by quick settings rollout.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private void showQuickSettingsTooltipIfNeeded() { 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;
} }
/** /**

View File

@@ -496,10 +496,6 @@ public final class AccessibilityShortcutsTutorial {
if ((shortcutTypes & shortcutType) == 0) { if ((shortcutTypes & shortcutType) == 0) {
continue; continue;
} }
if ((shortcutTypes & QUICK_SETTINGS) == QUICK_SETTINGS
&& !android.view.accessibility.Flags.a11yQsShortcut()) {
continue;
}
tutorialPages.add( tutorialPages.add(
createShortcutTutorialPage( createShortcutTutorialPage(
context, shortcutType, buttonMode, featureName, inSetupWizard)); context, shortcutType, buttonMode, featureName, inSetupWizard));

View File

@@ -61,7 +61,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.StringJoiner;
/** Provides utility methods to accessibility settings only. */ /** Provides utility methods to accessibility settings only. */
public final class AccessibilityUtil { public final class AccessibilityUtil {
@@ -203,28 +202,23 @@ public final class AccessibilityUtil {
* @param context The current context. * @param context The current context.
* @param shortcutTypes A combination of {@link UserShortcutType}. * @param shortcutTypes A combination of {@link UserShortcutType}.
* @param componentName The component name that need to be opted in Settings. * @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, static void optInAllValuesToSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ true,
/* enable= */ true, shortcutTypes,
shortcutTypes, Set.of(componentName.flattenToString()),
Set.of(componentName.flattenToString()), UserHandle.myUserId()
UserHandle.myUserId() );
);
}
return;
}
if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
optInValueToSettings(context, SOFTWARE, componentName);
}
if (((shortcutTypes & HARDWARE) == HARDWARE)) {
optInValueToSettings(context, HARDWARE, componentName);
} }
} }
@@ -234,38 +228,25 @@ public final class AccessibilityUtil {
* @param context The current context. * @param context The current context.
* @param shortcutType The preferred shortcut type user selected. * @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be opted in Settings. * @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 @VisibleForTesting
static void optInValueToSettings(Context context, @UserShortcutType int shortcutType, static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ true,
/* enable= */ true, shortcutType,
shortcutType, Set.of(componentName.flattenToString()),
Set.of(componentName.flattenToString()), UserHandle.myUserId()
UserHandle.myUserId() );
);
}
return;
} }
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 context The current context.
* @param shortcutTypes A combination of {@link UserShortcutType}. * @param shortcutTypes A combination of {@link UserShortcutType}.
* @param componentName The component name that need to be opted out from Settings. * @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, static void optOutAllValuesFromSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ false,
/* enable= */ false, shortcutTypes,
shortcutTypes, Set.of(componentName.flattenToString()),
Set.of(componentName.flattenToString()), UserHandle.myUserId()
UserHandle.myUserId() );
);
}
return;
}
if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
optOutValueFromSettings(context, SOFTWARE, componentName);
}
if (((shortcutTypes & HARDWARE) == HARDWARE)) {
optOutValueFromSettings(context, HARDWARE, componentName);
} }
} }
@@ -305,42 +282,25 @@ public final class AccessibilityUtil {
* @param context The current context. * @param context The current context.
* @param shortcutType The preferred shortcut type user selected. * @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be opted out from Settings. * @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 @VisibleForTesting
static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType, static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ false,
/* enable= */ false, shortcutType,
shortcutType, Set.of(componentName.flattenToString()),
Set.of(componentName.flattenToString()), UserHandle.myUserId()
UserHandle.myUserId() );
);
}
return;
} }
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, static boolean hasValuesInSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { 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 (!android.provider.Flags.a11yStandaloneGestureEnabled()) {
if ((shortcutType & GESTURE) == GESTURE) { if ((shortcutType & GESTURE) == GESTURE) {
continue; continue;
@@ -379,15 +334,16 @@ public final class AccessibilityUtil {
* @param shortcutType The preferred shortcut type user selected. * @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be checked existed in Settings. * @param componentName The component name that need to be checked existed in Settings.
* @return {@code true} if componentName 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 @VisibleForTesting
static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType, static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
if (!android.view.accessibility.Flags.a11yQsShortcut()
&& (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
return false;
}
return ShortcutUtils.getShortcutTargetsFromSettings( return ShortcutUtils.getShortcutTargetsFromSettings(
context, shortcutType, UserHandle.myUserId() context, shortcutType, UserHandle.myUserId()
).contains(componentName.flattenToString()); ).contains(componentName.flattenToString());
@@ -405,11 +361,6 @@ public final class AccessibilityUtil {
@NonNull ComponentName componentName) { @NonNull ComponentName componentName) {
int shortcutTypes = DEFAULT; int shortcutTypes = DEFAULT;
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { 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 (!android.provider.Flags.a11yStandaloneGestureEnabled()) {
if ((shortcutType & GESTURE) == GESTURE) { if ((shortcutType & GESTURE) == GESTURE) {
continue; continue;
@@ -428,23 +379,15 @@ public final class AccessibilityUtil {
* *
* @param shortcutType The shortcut type. * @param shortcutType The shortcut type.
* @return Mapping key in Settings. * @return Mapping key in Settings.
*
* @deprecated use
* {@link ShortcutUtils#convertToKey(int)} instead.
*
* (TODO 367414968: finish removal.)
*/ */
@Deprecated
static String convertKeyFromSettings(@UserShortcutType int shortcutType) { static String convertKeyFromSettings(@UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { return ShortcutUtils.convertToKey(shortcutType);
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);
}
} }
/** /**
@@ -521,10 +464,6 @@ public final class AccessibilityUtil {
final List<CharSequence> list = new ArrayList<>(); final List<CharSequence> list = new ArrayList<>();
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { 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() if (!android.provider.Flags.a11yStandaloneGestureEnabled()
&& (shortcutType & GESTURE) == GESTURE) { && (shortcutType & GESTURE) == GESTURE) {
continue; continue;

View File

@@ -77,9 +77,7 @@ public class ColorAndMotionFragment extends DashboardFragment {
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED); mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); 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()) { if (Flags.forceInvertColor()) {
mShortcutFeatureKeys.add(ToggleForceInvertPreferenceController.SETTINGS_KEY); mShortcutFeatureKeys.add(ToggleForceInvertPreferenceController.SETTINGS_KEY);
} }

View File

@@ -17,7 +17,6 @@
package com.android.settings.accessibility; package com.android.settings.accessibility;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT; 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 static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import android.content.ComponentName; import android.content.ComponentName;
@@ -25,7 +24,6 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.view.accessibility.Flags;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -123,11 +121,6 @@ public final class PreferredShortcuts {
@NonNull Context context, @NonNull Set<String> components) { @NonNull Context context, @NonNull Set<String> components) {
final Map<Integer, Set<String>> shortcutTypeToTargets = new ArrayMap<>(); final Map<Integer, Set<String>> shortcutTypeToTargets = new ArrayMap<>();
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { 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( shortcutTypeToTargets.put(
shortcutType, shortcutType,
ShortcutUtils.getShortcutTargetsFromSettings( ShortcutUtils.getShortcutTargetsFromSettings(

View File

@@ -16,9 +16,6 @@
package com.android.settings.accessibility; 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.content.Context;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.hardware.display.ColorDisplayManager; import android.hardware.display.ColorDisplayManager;
@@ -29,12 +26,12 @@ import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.server.display.feature.flags.Flags; import com.android.server.display.feature.flags.Flags;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; 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 */ /** PreferenceController that shows the Reduce Bright Colors summary */
public class ReduceBrightColorsPreferenceController public class ReduceBrightColorsPreferenceController
extends AccessibilityQuickSettingsPrimarySwitchPreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop { implements LifecycleObserver, OnStart, OnStop {
private ContentObserver mSettingsContentObserver; private ContentObserver mSettingsContentObserver;
private PrimarySwitchPreference mPreference; private PrimarySwitchPreference mPreference;
@@ -72,7 +69,6 @@ public class ReduceBrightColorsPreferenceController
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
super.setChecked(isChecked);
return mColorDisplayManager.setReduceBrightColorsActivated(isChecked); return mColorDisplayManager.setReduceBrightColorsActivated(isChecked);
} }
@@ -125,20 +121,4 @@ public class ReduceBrightColorsPreferenceController
public void onStop() { public void onStop() {
mContext.getContentResolver().unregisterContentObserver(mSettingsContentObserver); 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);
}
} }

View File

@@ -452,15 +452,11 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override @Override
protected int getDefaultShortcutTypes() { protected int getDefaultShortcutTypes() {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityServiceInfo info = getAccessibilityServiceInfo();
AccessibilityServiceInfo info = getAccessibilityServiceInfo(); boolean isAccessibilityTool = info != null && info.isAccessibilityTool();
boolean isAccessibilityTool = info != null && info.isAccessibilityTool(); return !isAccessibilityTool || getTileComponentName() == null
return !isAccessibilityTool || getTileComponentName() == null ? super.getDefaultShortcutTypes()
? super.getDefaultShortcutTypes() : ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
: ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
}
return super.getDefaultShortcutTypes();
} }
private void onAllowButtonFromEnableToggleClicked() { private void onAllowButtonFromEnableToggleClicked() {

View File

@@ -167,9 +167,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
final List<String> shortcutFeatureKeys = new ArrayList<>(); final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE); 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; return shortcutFeatureKeys;
} }
@@ -750,44 +748,13 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
showQuickSettingsTooltipIfNeeded(); showQuickSettingsTooltipIfNeeded();
} }
/**
* @deprecated made obsolete by quick settings rollout.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private void showQuickSettingsTooltipIfNeeded() { 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}. */ /** Returns user visible name of the tile by given {@link ComponentName}. */

View File

@@ -56,6 +56,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat; import androidx.preference.SwitchPreferenceCompat;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags; import com.android.server.accessibility.Flags;
import com.android.settings.DialogCreatable; import com.android.settings.DialogCreatable;
@@ -74,7 +75,6 @@ import com.google.android.setupcompat.util.WizardManagerHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
@@ -203,13 +203,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
} }
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY); final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
// LINT.IfChange(:preference_list) // LINT.IfChange(preference_list)
addMagnificationModeSetting(generalCategory); addMagnificationModeSetting(generalCategory);
addFollowTypingSetting(generalCategory); addFollowTypingSetting(generalCategory);
addOneFingerPanningSetting(generalCategory); addOneFingerPanningSetting(generalCategory);
addAlwaysOnSetting(generalCategory); addAlwaysOnSetting(generalCategory);
addJoystickSetting(generalCategory); addJoystickSetting(generalCategory);
// LINT.ThenChange(:search_data) // LINT.ThenChange(search_data)
} }
@Override @Override
@@ -588,70 +588,29 @@ public class ToggleScreenMagnificationPreferenceFragment extends
optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP); optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP);
} }
} }
if (android.view.accessibility.Flags.a11yQsShortcut()) { if (((shortcutTypes & QUICK_SETTINGS)
if (((shortcutTypes & QUICK_SETTINGS) == QUICK_SETTINGS)) {
== QUICK_SETTINGS)) { optInMagnificationValueToSettings(context, 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( private static void optInMagnificationValueToSettings(
Context context, @UserShortcutType int shortcutType) { Context context, @UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ true,
/* enable= */ true, shortcutType,
shortcutType, Set.of(MAGNIFICATION_CONTROLLER_NAME),
Set.of(MAGNIFICATION_CONTROLLER_NAME), UserHandle.myUserId()
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);
} }
} }
@@ -676,65 +635,30 @@ public class ToggleScreenMagnificationPreferenceFragment extends
optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP); optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP);
} }
} }
if (android.view.accessibility.Flags.a11yQsShortcut()) { if (((shortcutTypes & QUICK_SETTINGS)
if (((shortcutTypes & QUICK_SETTINGS)
== 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, private static void optOutMagnificationValueFromSettings(Context context,
@UserShortcutType int shortcutType) { @UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(
a11yManager.enableShortcutsForTargets( /* enable= */ false,
/* enable= */ false, shortcutType,
shortcutType, Set.of(MAGNIFICATION_CONTROLLER_NAME),
Set.of(MAGNIFICATION_CONTROLLER_NAME), UserHandle.myUserId()
UserHandle.myUserId() );
);
}
return;
} }
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 @VisibleForTesting
@@ -788,15 +712,16 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return false; return false;
} }
/**
* @deprecated use
* {@link ShortcutUtils#getEnabledShortcutTypes(Context, String)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private static int getUserShortcutTypeFromSettings(Context context) { private static int getUserShortcutTypeFromSettings(Context context) {
int shortcutTypes = DEFAULT; int shortcutTypes = DEFAULT;
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { 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)) { if (hasMagnificationValueInSettings(context, shortcutType)) {
shortcutTypes |= shortcutType; shortcutTypes |= shortcutType;
} }
@@ -831,7 +756,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() { new BaseSearchIndexProvider() {
// LINT.IfChange(:search_data) // LINT.IfChange(search_data)
@Override @Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context, public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) { boolean enabled) {
@@ -887,7 +812,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
} }
return niks; return niks;
} }
// LINT.ThenChange(:preference_list) // LINT.ThenChange(preference_list)
private SearchIndexableRaw createPreferenceSearchData( private SearchIndexableRaw createPreferenceSearchData(
Context context, Preference pref) { Context context, Preference pref) {

View File

@@ -25,7 +25,6 @@ import android.os.UserHandle;
import android.service.quicksettings.TileService; import android.service.quicksettings.TileService;
import android.util.ArraySet; import android.util.ArraySet;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.Preference; import androidx.preference.Preference;
@@ -82,8 +81,7 @@ public class QuickSettingsShortcutOptionController extends ShortcutOptionPrefere
@Override @Override
protected boolean isShortcutAvailable() { protected boolean isShortcutAvailable() {
return Flags.a11yQsShortcut() return TileService.isQuickSettingsSupported()
&& TileService.isQuickSettingsSupported()
&& allTargetsHasQsTile() && allTargetsHasQsTile()
&& allTargetsHasValidQsTileUseCase(); && allTargetsHasValidQsTileUseCase();
} }

View File

@@ -19,7 +19,6 @@ package com.android.settings.accessibility.shortcuts;
import android.content.Context; import android.content.Context;
import android.os.UserHandle; import android.os.UserHandle;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.Preference; import androidx.preference.Preference;
@@ -111,36 +110,27 @@ public abstract class ShortcutOptionPreferenceController extends BasePreferenceC
return !targets.isEmpty() && targets.containsAll(getShortcutTargets()); return !targets.isEmpty() && targets.containsAll(getShortcutTargets());
} }
/** /**
* Enable or disable the shortcut for the given accessibility features. * 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) { protected void enableShortcutForTargets(boolean enable) {
Set<String> shortcutTargets = getShortcutTargets(); Set<String> shortcutTargets = getShortcutTargets();
@ShortcutConstants.UserShortcutType int shortcutType = getShortcutType(); @ShortcutConstants.UserShortcutType int shortcutType = getShortcutType();
if (Flags.a11yQsShortcut()) { AccessibilityManager a11yManager = mContext.getSystemService(
AccessibilityManager a11yManager = mContext.getSystemService( AccessibilityManager.class);
AccessibilityManager.class); if (a11yManager != null) {
if (a11yManager != null) { a11yManager.enableShortcutsForTargets(enable, shortcutType, shortcutTargets,
a11yManager.enableShortcutsForTargets(enable, shortcutType, shortcutTargets, UserHandle.myUserId());
UserHandle.myUserId());
}
return;
} }
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 * Returns true when the user can associate a shortcut to the targets
*/ */

View File

@@ -19,14 +19,11 @@ package com.android.settings.accessibility.shortcuts;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
import android.content.Context; import android.content.Context;
import android.provider.Settings;
import android.view.View; import android.view.View;
import android.view.accessibility.Flags;
import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityButtonFragment; import com.android.settings.accessibility.AccessibilityButtonFragment;
import com.android.settings.accessibility.FloatingMenuSizePreferenceController;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.utils.AnnotationSpan; import com.android.settings.utils.AnnotationSpan;
@@ -62,26 +59,4 @@ public abstract class SoftwareShortcutOptionPreferenceController
R.string.accessibility_shortcut_edit_dialog_summary_software_floating), R.string.accessibility_shortcut_edit_dialog_summary_software_floating),
linkInfo); 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);
}
}
}
} }

View File

@@ -20,7 +20,6 @@ import static com.android.internal.accessibility.AccessibilityShortcutController
import android.content.Context; import android.content.Context;
import android.provider.Settings; import android.provider.Settings;
import android.view.accessibility.Flags;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -99,17 +98,4 @@ public class TripleTapShortcutOptionController extends ShortcutOptionPreferenceC
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON; 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);
}
} }

View File

@@ -86,16 +86,4 @@ public class TwoFingerDoubleTapShortcutOptionController
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED, Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON; 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);
}
} }

View File

@@ -17,14 +17,12 @@
package com.android.settings.accessibility.shortcuts; package com.android.settings.accessibility.shortcuts;
import android.content.Context; import android.content.Context;
import android.view.accessibility.Flags;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil;
/** /**
* A controller handles displaying the volume keys shortcut option preference and * A controller handles displaying the volume keys shortcut option preference and
@@ -61,16 +59,4 @@ public class VolumeKeysShortcutOptionController extends ShortcutOptionPreference
protected boolean isShortcutAvailable() { protected boolean isShortcutAvailable() {
return true; return true;
} }
@Override
protected void enableShortcutForTargets(boolean enable) {
super.enableShortcutForTargets(enable);
if (Flags.a11yQsShortcut()) {
return;
}
if (enable) {
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(mContext);
}
}
} }

View File

@@ -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;
}
}
}

View File

@@ -376,21 +376,7 @@ public class AccessibilitySettingsTest {
} }
@Test @Test
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void onCreate_haveRegisterToSpecificUrisAndActions() {
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() {
setupFragment(); setupFragment();
assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS,

View File

@@ -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.HARDWARE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType; import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -38,14 +37,11 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.icu.text.CaseMap; import android.icu.text.CaseMap;
import android.os.Bundle; 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.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.Flags;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -156,25 +152,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
} }
@Test @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) @Config(shadows = ShadowFragment.class)
public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() { public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() {
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT); mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
@@ -219,7 +196,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut( final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
PLACEHOLDER_COMPONENT_NAME.flattenToString(), PLACEHOLDER_COMPONENT_NAME.flattenToString(),

View File

@@ -133,7 +133,6 @@ public final class AccessibilityShortcutsTutorialTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createTutorialPages_turnOnQuickSettingShortcut_hasOnePage() { public void createTutorialPages_turnOnQuickSettingShortcut_hasOnePage() {
mShortcutTypes |= QUICK_SETTINGS; mShortcutTypes |= QUICK_SETTINGS;
@@ -260,7 +259,6 @@ public final class AccessibilityShortcutsTutorialTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOn_verifyText() { public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOn_verifyText() {
mShortcutTypes |= QUICK_SETTINGS; mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(true); setTouchExplorationEnabled(true);
@@ -292,7 +290,6 @@ public final class AccessibilityShortcutsTutorialTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOn_verifyText() { public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOn_verifyText() {
mShortcutTypes |= QUICK_SETTINGS; mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(true); setTouchExplorationEnabled(true);
@@ -318,7 +315,6 @@ public final class AccessibilityShortcutsTutorialTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOff_verifyText() { public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOff_verifyText() {
mShortcutTypes |= QUICK_SETTINGS; mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(false); setTouchExplorationEnabled(false);
@@ -349,7 +345,6 @@ public final class AccessibilityShortcutsTutorialTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOff_verifyText() { public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOff_verifyText() {
mShortcutTypes |= QUICK_SETTINGS; mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(false); setTouchExplorationEnabled(false);

View File

@@ -46,7 +46,6 @@ import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
@@ -203,7 +202,6 @@ public final class AccessibilityUtilTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getUserShortcutTypeFromSettings_threeShortcutTypesChosen() { public void getUserShortcutTypeFromSettings_threeShortcutTypesChosen() {
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString()); setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString()); setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
@@ -220,22 +218,6 @@ public final class AccessibilityUtilTest {
} }
@Test @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() { public void optInAllValuesToSettings_optInValue_callsA11yManager() {
AccessibilityManager a11yManager = AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext); AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
@@ -252,20 +234,6 @@ public final class AccessibilityUtilTest {
} }
@Test @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() { public void optInValueToSettings_optInValue_callsA11yManager() {
AccessibilityManager a11yManager = AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext); AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
@@ -281,37 +249,6 @@ public final class AccessibilityUtilTest {
} }
@Test @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() { public void optOutAllValuesToSettings_optOutValue_callsA1yManager() {
AccessibilityManager a11yManager = AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext); AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
@@ -331,31 +268,6 @@ public final class AccessibilityUtilTest {
} }
@Test @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() { public void optOutValueFromSettings_optOutValue_callsA11yManager() {
AccessibilityManager a11yManager = AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext); AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
@@ -389,7 +301,6 @@ public final class AccessibilityUtilTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() { public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() {
assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP)) assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP))
.isEqualTo( .isEqualTo(
@@ -397,7 +308,6 @@ public final class AccessibilityUtilTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void convertKeyFromSettings_shortcutTypeQuickSettings() { public void convertKeyFromSettings_shortcutTypeQuickSettings() {
assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS)) assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS))
.isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS); .isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS);

View File

@@ -22,7 +22,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf; import static org.robolectric.Shadows.shadowOf;
import android.content.Context; import android.content.Context;

View File

@@ -26,8 +26,8 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.ContentResolver; import android.content.ContentResolver;

View File

@@ -30,10 +30,10 @@ import android.provider.Settings;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.R; 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.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
import com.android.settings.widget.SeekBarPreference; import com.android.settings.widget.SeekBarPreference;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;

View File

@@ -31,9 +31,9 @@ import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.shadow.SettingsShadowResources; import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.After; import org.junit.After;
@@ -42,8 +42,8 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Test for {@link MediaVibrationIntensityPreferenceController}. */ /** Test for {@link MediaVibrationIntensityPreferenceController}. */
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)

View File

@@ -34,13 +34,8 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo;
import android.os.Bundle; 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.service.quicksettings.TileService;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@@ -55,7 +50,6 @@ import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragm
import com.android.settings.widget.SettingsMainSwitchPreference; import com.android.settings.widget.SettingsMainSwitchPreference;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Answers; import org.mockito.Answers;
@@ -75,8 +69,6 @@ import java.util.Set;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class ToggleAccessibilityServicePreferenceFragmentTest { 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_NAME = "com.placeholder.example";
private static final String PLACEHOLDER_PACKAGE_NAME2 = "com.placeholder.example2"; private static final String PLACEHOLDER_PACKAGE_NAME2 = "com.placeholder.example2";
private static final String PLACEHOLDER_SERVICE_CLASS_NAME = "a11yservice1"; private static final String PLACEHOLDER_SERVICE_CLASS_NAME = "a11yservice1";
@@ -314,30 +306,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @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() public void getDefaultShortcutTypes_isAccessibilityTool_hasAssociatedTile_qsTypeIsDefault()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -351,7 +319,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getDefaultShortcutTypes_isNotAccessibilityTool_hasAssociatedTile_softwareTypeIsDefault() public void getDefaultShortcutTypes_isNotAccessibilityTool_hasAssociatedTile_softwareTypeIsDefault()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -365,7 +332,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getDefaultShortcutTypes_isAccessibilityTool_noAssociatedTile_softwareTypeIsDefault() public void getDefaultShortcutTypes_isAccessibilityTool_noAssociatedTile_softwareTypeIsDefault()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -379,7 +345,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getDefaultShortcutTypes_isNotAccessibilityTool_noAssociatedTile_softwareTypeIsDefault() public void getDefaultShortcutTypes_isNotAccessibilityTool_noAssociatedTile_softwareTypeIsDefault()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -393,7 +358,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -413,7 +377,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -433,47 +396,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @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() public void toggleShortcutPreference_userPreferVolumeKeysShortcut_noQsTile_enableVolumeKeysShortcut()
throws Throwable { throws Throwable {
setupAccessibilityServiceInfoForFragment( setupAccessibilityServiceInfoForFragment(
@@ -498,7 +420,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut() public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut()
throws Throwable { throws Throwable {
setupAccessibilityServiceInfoForFragment( setupAccessibilityServiceInfoForFragment(

View File

@@ -139,25 +139,6 @@ public class ToggleColorInversionPreferenceFragmentTest {
assertThat(getLatestPopupWindow()).isNull(); 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 @Test
public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() { public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),

View File

@@ -106,23 +106,6 @@ public class ToggleDaltonizerPreferenceFragmentTest {
assertThat(getLatestPopupWindow()).isNull(); 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 @Test
public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() { public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),

View File

@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -38,7 +37,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.icu.text.CaseMap; import android.icu.text.CaseMap;
import android.os.Bundle; import android.os.Bundle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
@@ -142,7 +140,6 @@ public class ToggleFeaturePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
@Config(shadows = {ShadowFragment.class}) @Config(shadows = {ShadowFragment.class})
public void onResume_flagEnabled_haveRegisterToSpecificUris() { public void onResume_flagEnabled_haveRegisterToSpecificUris() {
mFragment.onAttach(mContext); mFragment.onAttach(mContext);
@@ -166,31 +163,6 @@ public class ToggleFeaturePreferenceFragmentTest {
any(AccessibilitySettingsContentObserver.class)); 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 @Test
public void updateShortcutPreferenceData_assignDefaultValueToVariable() { public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME; mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
@@ -240,15 +212,6 @@ public class ToggleFeaturePreferenceFragmentTest {
assertThat(getLatestPopupWindow()).isNull(); 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 @Test
@Config(shadows = ShadowFragment.class) @Config(shadows = ShadowFragment.class)
public void onPreferenceToggledOnEnabledService_inSuw_toolTipViewShouldNotShow() { public void onPreferenceToggledOnEnabledService_inSuw_toolTipViewShouldNotShow() {
@@ -261,18 +224,6 @@ public class ToggleFeaturePreferenceFragmentTest {
assertThat(getLatestPopupWindow()).isNull(); 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 @Test
public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() { public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() {
mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO; mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO;
@@ -365,7 +316,6 @@ public class ToggleFeaturePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
@Config(shadows = ShadowFragment.class) @Config(shadows = ShadowFragment.class)
public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() { public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() {
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT); mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
@@ -374,7 +324,6 @@ public class ToggleFeaturePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut( final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
PLACEHOLDER_COMPONENT_NAME.flattenToString(), PLACEHOLDER_COMPONENT_NAME.flattenToString(),

View File

@@ -337,8 +337,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT) public void onResume_haveRegisterToSpecificUris() {
public void onResume_flagEnabled_haveRegisterToSpecificUris() {
ShadowContentResolver shadowContentResolver = Shadows.shadowOf( ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
mContext.getContentResolver()); mContext.getContentResolver());
Uri[] observedUri = new Uri[]{ 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<ContentObserver> 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 @Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE) @EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE)
public void onResume_oneFingerPanningFlagOn_registerToSpecificUri() { public void onResume_oneFingerPanningFlagOn_registerToSpecificUri() {
@@ -462,20 +429,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
} }
@Test @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() { public void optInAllValuesToSettings_optInValue_callA11yManager() {
int shortcutTypes = int shortcutTypes =
SOFTWARE | TRIPLETAP | HARDWARE SOFTWARE | TRIPLETAP | HARDWARE
@@ -500,45 +453,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
verifyNoMoreInteractions(mAccessibilityManager); 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 @Test
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() { public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE, for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE,
@@ -594,24 +508,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
} }
@Test @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() { public void optOutAllValuesToSettings_optOutValue_callA11yManager() {
Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME); Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME);
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME); putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
@@ -635,38 +531,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
verifyNoMoreInteractions(mAccessibilityManager); 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 @Test
public void updateShortcutPreferenceData_assignDefaultValueToVariable() { public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume(); mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
@@ -979,7 +843,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() { public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut( final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME, MAGNIFICATION_CONTROLLER_NAME,

View File

@@ -46,7 +46,6 @@ import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
import android.util.Pair; import android.util.Pair;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@@ -466,7 +465,6 @@ public class EditShortcutsPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void fragmentResumed_enableTouchExploration_qsShortcutOptionSummaryUpdated() { public void fragmentResumed_enableTouchExploration_qsShortcutOptionSummaryUpdated() {
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2, String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2,
R.string.accessibility_shortcut_edit_dialog_summary_quick_settings); R.string.accessibility_shortcut_edit_dialog_summary_quick_settings);
@@ -486,7 +484,6 @@ public class EditShortcutsPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void fragmentPaused_enableTouchExploration_qsShortcutOptionSummaryNotUpdated() { public void fragmentPaused_enableTouchExploration_qsShortcutOptionSummaryNotUpdated() {
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 1, String expectedSummary = StringUtil.getIcuPluralsString(mContext, 1,
R.string.accessibility_shortcut_edit_dialog_summary_quick_settings); R.string.accessibility_shortcut_edit_dialog_summary_quick_settings);
@@ -644,7 +641,6 @@ public class EditShortcutsPreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void onQuickSettingsShortcutSettingChanged_preferredShortcutsUpdated() { public void onQuickSettingsShortcutSettingChanged_preferredShortcutsUpdated() {
final String target = TARGET_FAKE_COMPONENT.flattenToString(); final String target = TARGET_FAKE_COMPONENT.flattenToString();
mFragmentScenario = createFragScenario( mFragmentScenario = createFragScenario(

View File

@@ -27,11 +27,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.UserHandle; 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.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -45,7 +41,6 @@ import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.utils.StringUtil; import com.android.settingslib.utils.StringUtil;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
@@ -67,8 +62,6 @@ public class QuickSettingsShortcutOptionControllerTest {
private static final String TARGET_FLATTEN = TARGET.flattenToString(); private static final String TARGET_FLATTEN = TARGET.flattenToString();
private static final ComponentName TARGET_TILE = private static final ComponentName TARGET_TILE =
new ComponentName("FakePackage", "FakeTileClass"); new ComponentName("FakePackage", "FakeTileClass");
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private final Context mContext = spy(ApplicationProvider.getApplicationContext()); private final Context mContext = spy(ApplicationProvider.getApplicationContext());
private QuickSettingsShortcutOptionController mController; private QuickSettingsShortcutOptionController mController;
@@ -149,13 +142,6 @@ public class QuickSettingsShortcutOptionControllerTest {
} }
@Test @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() { public void isShortcutAvailable_qsNotSupported_returnsFalse() {
SettingsShadowResources.overrideResource( SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_quickSettingsSupported, false); com.android.internal.R.bool.config_quickSettingsSupported, false);
@@ -164,7 +150,6 @@ public class QuickSettingsShortcutOptionControllerTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void isShortcutAvailable_qsTileProvided_returnsTrue() { public void isShortcutAvailable_qsTileProvided_returnsTrue() {
when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId())) when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId()))
.thenReturn(Map.of(TARGET, TARGET_TILE)); .thenReturn(Map.of(TARGET, TARGET_TILE));
@@ -173,7 +158,6 @@ public class QuickSettingsShortcutOptionControllerTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void isShortcutAvailable_qsTileNotProvided_returnsFalse() { public void isShortcutAvailable_qsTileNotProvided_returnsFalse() {
when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId())) when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId()))
.thenReturn(Collections.emptyMap()); .thenReturn(Collections.emptyMap());
@@ -182,7 +166,6 @@ public class QuickSettingsShortcutOptionControllerTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void isShortcutAvailable_qsTileProvided_invalidUseCase_returnFalse() { public void isShortcutAvailable_qsTileProvided_invalidUseCase_returnFalse() {
AccessibilityServiceInfo mockStandardA11yService = AccessibilityServiceInfo mockStandardA11yService =
AccessibilityTestUtils.createAccessibilityServiceInfo( AccessibilityTestUtils.createAccessibilityServiceInfo(
@@ -197,7 +180,6 @@ public class QuickSettingsShortcutOptionControllerTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void isShortcutAvailable_qsTileProvided_validUseCase_returnTrue() { public void isShortcutAvailable_qsTileProvided_validUseCase_returnTrue() {
AccessibilityServiceInfo mockAlwaysOnA11yService = AccessibilityServiceInfo mockAlwaysOnA11yService =
AccessibilityTestUtils.createAccessibilityServiceInfo( AccessibilityTestUtils.createAccessibilityServiceInfo(

View File

@@ -33,14 +33,11 @@ import android.content.Context;
import android.content.ContextWrapper; import android.content.ContextWrapper;
import android.content.Intent; import android.content.Intent;
import android.os.UserHandle; 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.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.view.View; import android.view.View;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@@ -50,10 +47,8 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings; import com.android.settings.SubSettings;
import com.android.settings.accessibility.AccessibilityButtonFragment; import com.android.settings.accessibility.AccessibilityButtonFragment;
import com.android.settings.accessibility.FloatingMenuSizePreferenceController;
import com.android.settings.testutils.AccessibilityTestUtils; import com.android.settings.testutils.AccessibilityTestUtils;
import com.android.settings.utils.AnnotationSpan; import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.accessibility.AccessibilityUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@@ -178,23 +173,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_enableShortcut_callA11yManager() {
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
mController.setShortcutTargets(Set.of(target)); mController.setShortcutTargets(Set.of(target));
@@ -214,25 +192,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_disableShortcut_callA11yManager() {
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
ShortcutUtils.optInValueToSettings( ShortcutUtils.optInValueToSettings(
@@ -253,89 +212,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
verifyNoMoreInteractions(mAccessibilityManager); 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) { private void assertLaunchSettingsPage(String page) {
ContextWrapper applicationContext = (Application) mContext.getApplicationContext(); ContextWrapper applicationContext = (Application) mContext.getApplicationContext();
final Intent intent = Shadows.shadowOf(applicationContext).getNextStartedActivity(); final Intent intent = Shadows.shadowOf(applicationContext).getNextStartedActivity();

View File

@@ -28,12 +28,9 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.UserHandle; 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.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings; import android.provider.Settings;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -182,20 +179,6 @@ public class TripleTapShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_enableShortcut_callA11yManager() {
mController.enableShortcutForTargets(true); mController.enableShortcutForTargets(true);
@@ -209,20 +192,6 @@ public class TripleTapShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_disableShortcut_callA11yManager() {
mController.enableShortcutForTargets(false); mController.enableShortcutForTargets(false);

View File

@@ -143,20 +143,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_enableShortcut_callA11yManager() {
mController.enableShortcutForTargets(true); mController.enableShortcutForTargets(true);
@@ -170,20 +156,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_disableShortcut_callA11yManager() {
mController.enableShortcutForTargets(false); mController.enableShortcutForTargets(false);

View File

@@ -25,11 +25,8 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.UserHandle; 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.platform.test.flag.junit.SetFlagsRule;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -111,17 +108,6 @@ public class VolumeKeysShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_enableVolumeKeysShortcut_callA11yManager() {
mController.enableShortcutForTargets(true); mController.enableShortcutForTargets(true);
@@ -135,17 +121,6 @@ public class VolumeKeysShortcutOptionControllerTest {
} }
@Test @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() { public void enableShortcutForTargets_disableVolumeKeysShortcut_callA11yManager() {
mController.enableShortcutForTargets(false); mController.enableShortcutForTargets(false);

View File

@@ -25,12 +25,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; 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.provider.Settings;
import android.view.accessibility.Flags;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; 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.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -61,8 +55,6 @@ public class PreferredShortcutsTest {
CLASS_NAME_2); CLASS_NAME_2);
private static final ContentResolver sContentResolver = private static final ContentResolver sContentResolver =
ApplicationProvider.getApplicationContext().getContentResolver(); ApplicationProvider.getApplicationContext().getContentResolver();
@Rule
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private final Context mContext = ApplicationProvider.getApplicationContext(); private final Context mContext = ApplicationProvider.getApplicationContext();
@Before @Before
@@ -175,7 +167,6 @@ public class PreferredShortcutsTest {
} }
@Test @Test
@RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void updatePreferredShortcutFromSettings_colorInversionWithQsAndSoftwareShortcut_preferredShortcutsMatches() { public void updatePreferredShortcutFromSettings_colorInversionWithQsAndSoftwareShortcut_preferredShortcutsMatches() {
String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString(); String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString();
Settings.Secure.putString(sContentResolver, 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 @Test
public void retrieveUserShortcutTypeWithoutDefault_noUserPreferredShortcuts_returnSoftwareShortcut() { public void retrieveUserShortcutTypeWithoutDefault_noUserPreferredShortcuts_returnSoftwareShortcut() {
String target = COMPONENT_NAME_1.flattenToString(); String target = COMPONENT_NAME_1.flattenToString();

View File

@@ -16,8 +16,6 @@
package com.android.settings.accessibility; 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 com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
@@ -26,12 +24,7 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; 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.provider.Settings;
import android.view.accessibility.Flags;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -40,7 +33,6 @@ import com.android.internal.R;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -48,8 +40,6 @@ import org.junit.runner.RunWith;
public class ReduceBrightColorsPreferenceControllerTest { public class ReduceBrightColorsPreferenceControllerTest {
private static final String PREF_KEY = "rbc_preference"; private static final String PREF_KEY = "rbc_preference";
@Rule
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private Context mContext; private Context mContext;
private Resources mResources;; private Resources mResources;;
private ReduceBrightColorsPreferenceController mController; private ReduceBrightColorsPreferenceController mController;
@@ -98,20 +88,6 @@ public class ReduceBrightColorsPreferenceControllerTest {
assertThat(mController.isAvailable()).isFalse(); 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) { private int resourceId(String type, String name) {
return mContext.getResources().getIdentifier(name, type, mContext.getPackageName()); return mContext.getResources().getIdentifier(name, type, mContext.getPackageName());
} }