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
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
if (android.view.accessibility.Flags.a11yQsShortcut()) {
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
}
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_STICKY_KEYS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SLOW_KEYS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS);

View File

@@ -31,7 +31,6 @@ import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -114,9 +113,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
if (android.view.accessibility.Flags.a11yQsShortcut()) {
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
}
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
mSettingsContentObserver = new AccessibilitySettingsContentObserver(new Handler());
mSettingsContentObserver.registerKeysToObserverCallback(shortcutFeatureKeys, key -> {
updateShortcutPreferenceData();
@@ -374,38 +371,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
showQuickSettingsTooltipIfNeeded();
}
/**
* @deprecated made obsolete by quick settings rollout.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private void showQuickSettingsTooltipIfNeeded() {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
// Don't show Quick Settings tooltip
return;
}
final ComponentName tileComponentName = getTileComponentName();
if (tileComponentName == null) {
// Returns if no tile service assigned.
return;
}
if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences(
getContext(), tileComponentName)) {
// Returns if quick settings tooltip only show once.
return;
}
final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType);
if (TextUtils.isEmpty(content)) {
// Returns if no content of tile tooltip assigned.
return;
}
final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
? R.drawable.accessibility_qs_tooltip_illustration
: R.drawable.accessibility_auto_added_qs_tooltip_illustration;
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
mTooltipWindow.setup(content, imageResId);
mTooltipWindow.showAtTopCenter(getView());
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
tileComponentName);
mNeedsQSTooltipReshow = false;
}
/**

View File

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

View File

@@ -61,7 +61,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.StringJoiner;
/** Provides utility methods to accessibility settings only. */
public final class AccessibilityUtil {
@@ -203,28 +202,23 @@ public final class AccessibilityUtil {
* @param context The current context.
* @param shortcutTypes A combination of {@link UserShortcutType}.
* @param componentName The component name that need to be opted in Settings.
*
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
static void optInAllValuesToSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutTypes,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
return;
}
if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
optInValueToSettings(context, SOFTWARE, componentName);
}
if (((shortcutTypes & HARDWARE) == HARDWARE)) {
optInValueToSettings(context, HARDWARE, componentName);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutTypes,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
}
@@ -234,38 +228,25 @@ public final class AccessibilityUtil {
* @param context The current context.
* @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be opted in Settings.
*
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
@VisibleForTesting
static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutType,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
return;
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutType,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
final String targetKey = convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
if (hasValueInSettings(context, shortcutType, componentName)) {
return;
}
final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
if (!TextUtils.isEmpty(targetString)) {
joiner.add(targetString);
}
joiner.add(componentName.flattenToString());
Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
}
/**
@@ -275,27 +256,23 @@ public final class AccessibilityUtil {
* @param context The current context.
* @param shortcutTypes A combination of {@link UserShortcutType}.
* @param componentName The component name that need to be opted out from Settings.
*
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
static void optOutAllValuesFromSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutTypes,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
return;
}
if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
optOutValueFromSettings(context, SOFTWARE, componentName);
}
if (((shortcutTypes & HARDWARE) == HARDWARE)) {
optOutValueFromSettings(context, HARDWARE, componentName);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutTypes,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
}
@@ -305,42 +282,25 @@ public final class AccessibilityUtil {
* @param context The current context.
* @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be opted out from Settings.
*
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
@VisibleForTesting
static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutType,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
return;
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutType,
Set.of(componentName.flattenToString()),
UserHandle.myUserId()
);
}
final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
final String targetKey = convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
if (TextUtils.isEmpty(targetString)) {
return;
}
sStringColonSplitter.setString(targetString);
while (sStringColonSplitter.hasNext()) {
final String name = sStringColonSplitter.next();
if (TextUtils.isEmpty(name) || (componentName.flattenToString()).equals(name)) {
continue;
}
joiner.add(name);
}
Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
}
/**
@@ -354,11 +314,6 @@ public final class AccessibilityUtil {
static boolean hasValuesInSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) {
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()) {
if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
}
}
if (!android.provider.Flags.a11yStandaloneGestureEnabled()) {
if ((shortcutType & GESTURE) == GESTURE) {
continue;
@@ -379,15 +334,16 @@ public final class AccessibilityUtil {
* @param shortcutType The preferred shortcut type user selected.
* @param componentName The component name that need to be checked existed in Settings.
* @return {@code true} if componentName existed in Settings.
*
* @deprecated use
* {@link ShortcutUtils#isShortcutContained(Context, int, String)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
@VisibleForTesting
static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
@NonNull ComponentName componentName) {
if (!android.view.accessibility.Flags.a11yQsShortcut()
&& (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
return false;
}
return ShortcutUtils.getShortcutTargetsFromSettings(
context, shortcutType, UserHandle.myUserId()
).contains(componentName.flattenToString());
@@ -405,11 +361,6 @@ public final class AccessibilityUtil {
@NonNull ComponentName componentName) {
int shortcutTypes = DEFAULT;
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()) {
if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
}
}
if (!android.provider.Flags.a11yStandaloneGestureEnabled()) {
if ((shortcutType & GESTURE) == GESTURE) {
continue;
@@ -428,23 +379,15 @@ public final class AccessibilityUtil {
*
* @param shortcutType The shortcut type.
* @return Mapping key in Settings.
*
* @deprecated use
* {@link ShortcutUtils#convertToKey(int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
static String convertKeyFromSettings(@UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
return ShortcutUtils.convertToKey(shortcutType);
}
switch (shortcutType) {
case SOFTWARE:
return Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS;
case HARDWARE:
return Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
case TRIPLETAP:
return Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED;
default:
throw new IllegalArgumentException(
"Unsupported userShortcutType " + shortcutType);
}
return ShortcutUtils.convertToKey(shortcutType);
}
/**
@@ -521,10 +464,6 @@ public final class AccessibilityUtil {
final List<CharSequence> list = new ArrayList<>();
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!android.view.accessibility.Flags.a11yQsShortcut()
&& (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) {
continue;
}
if (!android.provider.Flags.a11yStandaloneGestureEnabled()
&& (shortcutType & GESTURE) == GESTURE) {
continue;

View File

@@ -77,9 +77,7 @@ public class ColorAndMotionFragment extends DashboardFragment {
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
if (android.view.accessibility.Flags.a11yQsShortcut()) {
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
}
mShortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
if (Flags.forceInvertColor()) {
mShortcutFeatureKeys.add(ToggleForceInvertPreferenceController.SETTINGS_KEY);
}

View File

@@ -17,7 +17,6 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import android.content.ComponentName;
@@ -25,7 +24,6 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.view.accessibility.Flags;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -123,11 +121,6 @@ public final class PreferredShortcuts {
@NonNull Context context, @NonNull Set<String> components) {
final Map<Integer, Set<String>> shortcutTypeToTargets = new ArrayMap<>();
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if (!Flags.a11yQsShortcut()
&& shortcutType == QUICK_SETTINGS) {
// Skip saving quick setting as preferred shortcut option when flag is not enabled
continue;
}
shortcutTypeToTargets.put(
shortcutType,
ShortcutUtils.getShortcutTargetsFromSettings(

View File

@@ -16,9 +16,6 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;
import android.content.ComponentName;
import android.content.Context;
import android.database.ContentObserver;
import android.hardware.display.ColorDisplayManager;
@@ -29,12 +26,12 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.server.display.feature.flags.Flags;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -42,7 +39,7 @@ import com.android.settingslib.core.lifecycle.events.OnStop;
/** PreferenceController that shows the Reduce Bright Colors summary */
public class ReduceBrightColorsPreferenceController
extends AccessibilityQuickSettingsPrimarySwitchPreferenceController
extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop {
private ContentObserver mSettingsContentObserver;
private PrimarySwitchPreference mPreference;
@@ -72,7 +69,6 @@ public class ReduceBrightColorsPreferenceController
@Override
public boolean setChecked(boolean isChecked) {
super.setChecked(isChecked);
return mColorDisplayManager.setReduceBrightColorsActivated(isChecked);
}
@@ -125,20 +121,4 @@ public class ReduceBrightColorsPreferenceController
public void onStop() {
mContext.getContentResolver().unregisterContentObserver(mSettingsContentObserver);
}
@Nullable
@Override
protected ComponentName getTileComponentName() {
// TODO: When clean up the feature flag, change the parent class from
// AccessibilityQuickSettingsPrimarySwitchPreferenceController to
// TogglePreferenceController
return android.view.accessibility.Flags.a11yQsShortcut()
? null : REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;
}
@Override
CharSequence getTileTooltipContent() {
return mContext.getText(
R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content);
}
}

View File

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

View File

@@ -167,9 +167,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
if (android.view.accessibility.Flags.a11yQsShortcut()) {
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
}
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
return shortcutFeatureKeys;
}
@@ -750,44 +748,13 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
showQuickSettingsTooltipIfNeeded();
}
/**
* @deprecated made obsolete by quick settings rollout.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private void showQuickSettingsTooltipIfNeeded() {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
// Don't show Quick Settings tooltip
return;
}
final ComponentName tileComponentName = getTileComponentName();
if (tileComponentName == null) {
// Returns if no tile service assigned.
return;
}
Activity activity = getActivity();
if (activity != null && WizardManagerHelper.isAnySetupWizard(activity.getIntent())) {
// Don't show QuickSettingsTooltip in Setup Wizard
return;
}
if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences(
getContext(), tileComponentName)) {
// Returns if quick settings tooltip only show once.
return;
}
final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType);
if (TextUtils.isEmpty(content)) {
// Returns if no content of tile tooltip assigned.
return;
}
final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
? R.drawable.accessibility_qs_tooltip_illustration
: R.drawable.accessibility_auto_added_qs_tooltip_illustration;
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
mTooltipWindow.setup(content, imageResId);
mTooltipWindow.showAtTopCenter(getView());
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
tileComponentName);
mNeedsQSTooltipReshow = false;
}
/** Returns user visible name of the tile by given {@link ComponentName}. */

View File

@@ -56,6 +56,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat;
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags;
import com.android.settings.DialogCreatable;
@@ -74,7 +75,6 @@ import com.google.android.setupcompat.util.WizardManagerHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Stream;
/**
@@ -203,13 +203,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
// LINT.IfChange(:preference_list)
// LINT.IfChange(preference_list)
addMagnificationModeSetting(generalCategory);
addFollowTypingSetting(generalCategory);
addOneFingerPanningSetting(generalCategory);
addAlwaysOnSetting(generalCategory);
addJoystickSetting(generalCategory);
// LINT.ThenChange(:search_data)
// LINT.ThenChange(search_data)
}
@Override
@@ -588,70 +588,29 @@ public class ToggleScreenMagnificationPreferenceFragment extends
optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP);
}
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
if (((shortcutTypes & QUICK_SETTINGS)
== QUICK_SETTINGS)) {
optInMagnificationValueToSettings(context, QUICK_SETTINGS);
}
if (((shortcutTypes & QUICK_SETTINGS)
== QUICK_SETTINGS)) {
optInMagnificationValueToSettings(context, QUICK_SETTINGS);
}
}
/**
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private static void optInMagnificationValueToSettings(
Context context, @UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutType,
Set.of(MAGNIFICATION_CONTROLLER_NAME),
UserHandle.myUserId()
);
}
return;
}
if (shortcutType == TRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (shortcutType == TWOFINGER_DOUBLETAP) {
Settings.Secure.putInt(
context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
ON);
return;
}
}
if (hasMagnificationValueInSettings(context, shortcutType)) {
return;
}
final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
if (!TextUtils.isEmpty(targetString)) {
joiner.add(targetString);
}
joiner.add(MAGNIFICATION_CONTROLLER_NAME);
Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
// The size setting defaults to unknown. If the user has ever manually changed the size
// before, we do not automatically change it.
if (shortcutType == SOFTWARE
&& Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
FloatingMenuSizePreferenceController.Size.UNKNOWN)
== FloatingMenuSizePreferenceController.Size.UNKNOWN) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
FloatingMenuSizePreferenceController.Size.LARGE);
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ true,
shortcutType,
Set.of(MAGNIFICATION_CONTROLLER_NAME),
UserHandle.myUserId()
);
}
}
@@ -676,65 +635,30 @@ public class ToggleScreenMagnificationPreferenceFragment extends
optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP);
}
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
if (((shortcutTypes & QUICK_SETTINGS)
if (((shortcutTypes & QUICK_SETTINGS)
== QUICK_SETTINGS)) {
optOutMagnificationValueFromSettings(context, QUICK_SETTINGS);
}
optOutMagnificationValueFromSettings(context, QUICK_SETTINGS);
}
}
/**
* @deprecated use
* {@link AccessibilityManager#enableShortcutsForTargets(boolean, int, Set, int)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private static void optOutMagnificationValueFromSettings(Context context,
@UserShortcutType int shortcutType) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutType,
Set.of(MAGNIFICATION_CONTROLLER_NAME),
UserHandle.myUserId()
);
}
return;
AccessibilityManager a11yManager = context.getSystemService(AccessibilityManager.class);
if (a11yManager != null) {
a11yManager.enableShortcutsForTargets(
/* enable= */ false,
shortcutType,
Set.of(MAGNIFICATION_CONTROLLER_NAME),
UserHandle.myUserId()
);
}
if (shortcutType == TRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (shortcutType == TWOFINGER_DOUBLETAP) {
Settings.Secure.putInt(
context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
OFF);
return;
}
}
final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
if (TextUtils.isEmpty(targetString)) {
return;
}
final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
sStringColonSplitter.setString(targetString);
while (sStringColonSplitter.hasNext()) {
final String name = sStringColonSplitter.next();
if (TextUtils.isEmpty(name) || MAGNIFICATION_CONTROLLER_NAME.equals(name)) {
continue;
}
joiner.add(name);
}
Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
}
@VisibleForTesting
@@ -788,15 +712,16 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return false;
}
/**
* @deprecated use
* {@link ShortcutUtils#getEnabledShortcutTypes(Context, String)} instead.
*
* (TODO 367414968: finish removal.)
*/
@Deprecated
private static int getUserShortcutTypeFromSettings(Context context) {
int shortcutTypes = DEFAULT;
for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) {
if ((shortcutType & (TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE | TRIPLETAP))
== shortcutType
&& !android.view.accessibility.Flags.a11yQsShortcut()) {
// These shortcuts will throw if we try to look up their settings without the flag.
continue;
}
if (hasMagnificationValueInSettings(context, shortcutType)) {
shortcutTypes |= shortcutType;
}
@@ -831,7 +756,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
// LINT.IfChange(:search_data)
// LINT.IfChange(search_data)
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
@@ -887,7 +812,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
return niks;
}
// LINT.ThenChange(:preference_list)
// LINT.ThenChange(preference_list)
private SearchIndexableRaw createPreferenceSearchData(
Context context, Preference pref) {

View File

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

View File

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

View File

@@ -19,14 +19,11 @@ package com.android.settings.accessibility.shortcuts;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
import android.content.Context;
import android.provider.Settings;
import android.view.View;
import android.view.accessibility.Flags;
import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityButtonFragment;
import com.android.settings.accessibility.FloatingMenuSizePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.utils.AnnotationSpan;
@@ -62,26 +59,4 @@ public abstract class SoftwareShortcutOptionPreferenceController
R.string.accessibility_shortcut_edit_dialog_summary_software_floating),
linkInfo);
}
@Override
protected void enableShortcutForTargets(boolean enable) {
super.enableShortcutForTargets(enable);
if (Flags.a11yQsShortcut()) {
return;
}
if (enable) {
// Update the A11y FAB size to large when the Magnification shortcut is enabled
// and the user hasn't changed the floating button size
if (isMagnificationInTargets()
&& Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
FloatingMenuSizePreferenceController.Size.UNKNOWN)
== FloatingMenuSizePreferenceController.Size.UNKNOWN) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
FloatingMenuSizePreferenceController.Size.LARGE);
}
}
}
}

View File

@@ -20,7 +20,6 @@ import static com.android.internal.accessibility.AccessibilityShortcutController
import android.content.Context;
import android.provider.Settings;
import android.view.accessibility.Flags;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -99,17 +98,4 @@ public class TripleTapShortcutOptionController extends ShortcutOptionPreferenceC
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON;
}
@Override
protected void enableShortcutForTargets(boolean enable) {
if (Flags.a11yQsShortcut()) {
super.enableShortcutForTargets(enable);
return;
}
Settings.Secure.putInt(
mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
enable ? AccessibilityUtil.State.ON : AccessibilityUtil.State.OFF);
}
}

View File

@@ -86,16 +86,4 @@ public class TwoFingerDoubleTapShortcutOptionController
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
AccessibilityUtil.State.OFF) == AccessibilityUtil.State.ON;
}
@Override
protected void enableShortcutForTargets(boolean enable) {
if (android.view.accessibility.Flags.a11yQsShortcut()) {
super.enableShortcutForTargets(enable);
return;
}
Settings.Secure.putInt(
mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
enable ? AccessibilityUtil.State.ON : AccessibilityUtil.State.OFF);
}
}

View File

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