Make QS shortcut type as default preferred shortcut for A11yService that

associate with a TileService

Bug: 322712028
Test: manual (Turn on the shortcut for the first time for various
feature with or without tile. Verify only the A11yService with tile
would show QS as the shortcut when directly turn on the main shortcut
toggle)
Test: atest com.android.settings.accessibility

Flag: aconfig android.view.accessibility.a11y_qs_shortcut
Change-Id: I569b417639d2db8b7eddd818a2b9037ed4be2509
This commit is contained in:
Chun-Ku Lin
2024-03-16 01:13:16 +00:00
parent 71ebe0f959
commit 5cdf972b50
5 changed files with 231 additions and 32 deletions

View File

@@ -54,6 +54,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
@@ -661,7 +662,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
int value = restoreOnConfigChangedValue();
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = PreferredShortcuts.retrieveUserShortcutType(
getPrefContext(), mComponentName.flattenToString());
getPrefContext(), mComponentName.flattenToString(), getDefaultShortcutTypes());
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
: UserShortcutType.EMPTY;
}
@@ -710,8 +711,8 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
return context.getText(R.string.accessibility_shortcut_state_off);
}
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(context,
mComponentName.flattenToString());
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(
context, mComponentName.flattenToString(), getDefaultShortcutTypes());
final List<CharSequence> list = new ArrayList<>();
if (android.view.accessibility.Flags.a11yQsShortcut()) {
@@ -811,7 +812,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
}
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(getPrefContext(),
mComponentName.flattenToString());
mComponentName.flattenToString(), getDefaultShortcutTypes());
mShortcutPreference.setChecked(
AccessibilityUtil.hasValuesInSettings(getPrefContext(), shortcutTypes,
mComponentName));
@@ -829,7 +830,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
}
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(getPrefContext(),
mComponentName.flattenToString());
mComponentName.flattenToString(), getDefaultShortcutTypes());
if (preference.isChecked()) {
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes,
mComponentName);
@@ -977,4 +978,13 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
boolean isAnySetupWizard() {
return WizardManagerHelper.isAnySetupWizard(getIntent());
}
/**
* Returns the default preferred shortcut types when the user doesn't have a preferred shortcut
* types
*/
@ShortcutConstants.UserShortcutType
protected int getDefaultShortcutTypes() {
return ShortcutConstants.UserShortcutType.SOFTWARE;
}
}