Includes AccessibilityMenu-in-System in interaction controls category.
The Menu APK will be included by default on devices. However, in order to ensure Menu appears in the interaction controls category an OEM would need to update their config_preinstalled_interaction_control_services array. This change ensures Menu is in the correct category without any OEM action required. Bug: 261252772 Test: atest AccessibilitySettingsTest Change-Id: I9b3d6dddf2691d9489ef847e400eb776aca96e56
This commit is contained in:
@@ -64,8 +64,9 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
private static final String CATEGORY_CAPTIONS = "captions_category";
|
||||
private static final String CATEGORY_AUDIO = "audio_category";
|
||||
private static final String CATEGORY_DISPLAY = "display_category";
|
||||
private static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
|
||||
private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
|
||||
@VisibleForTesting
|
||||
static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
|
||||
|
||||
private static final String[] CATEGORIES = new String[]{
|
||||
CATEGORY_SCREEN_READER, CATEGORY_CAPTIONS, CATEGORY_AUDIO, CATEGORY_DISPLAY,
|
||||
@@ -144,7 +145,8 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
|
||||
private final Map<String, PreferenceCategory> mCategoryToPrefCategoryMap =
|
||||
new ArrayMap<>();
|
||||
private final Map<Preference, PreferenceCategory> mServicePreferenceToPreferenceCategoryMap =
|
||||
@VisibleForTesting
|
||||
final Map<Preference, PreferenceCategory> mServicePreferenceToPreferenceCategoryMap =
|
||||
new ArrayMap<>();
|
||||
private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
|
||||
new ArrayMap<>();
|
||||
@@ -352,6 +354,12 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL,
|
||||
R.array.config_preinstalled_interaction_control_services);
|
||||
|
||||
// ACCESSIBILITY_MENU_IN_SYSTEM is a default pre-bundled interaction control service.
|
||||
// If the device opts out of including this service then this is a no-op.
|
||||
mPreBundledServiceComponentToCategoryMap.put(
|
||||
AccessibilityManager.ACCESSIBILITY_MENU_IN_SYSTEM,
|
||||
mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL));
|
||||
|
||||
final List<RestrictedPreference> preferenceList = getInstalledAccessibilityList(
|
||||
getPrefContext());
|
||||
|
||||
|
@@ -328,13 +328,43 @@ public class AccessibilitySettingsTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowFragment.class, ShadowUserManager.class})
|
||||
public void testAccessibilityMenuInSystem_IncludedInInteractionControl() {
|
||||
mShadowAccessibilityManager.setInstalledAccessibilityServiceList(
|
||||
List.of(getMockAccessibilityServiceInfo(
|
||||
AccessibilityManager.ACCESSIBILITY_MENU_IN_SYSTEM)));
|
||||
setupFragment();
|
||||
|
||||
final RestrictedPreference pref = mFragment.getPreferenceScreen().findPreference(
|
||||
AccessibilityManager.ACCESSIBILITY_MENU_IN_SYSTEM.flattenToString());
|
||||
final String prefCategory = mFragment.mServicePreferenceToPreferenceCategoryMap.get(
|
||||
pref).getKey();
|
||||
assertThat(prefCategory).isEqualTo(AccessibilitySettings.CATEGORY_INTERACTION_CONTROL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowFragment.class, ShadowUserManager.class})
|
||||
public void testAccessibilityMenuInSystem_NoPrefWhenNotInstalled() {
|
||||
mShadowAccessibilityManager.setInstalledAccessibilityServiceList(List.of());
|
||||
setupFragment();
|
||||
|
||||
final RestrictedPreference pref = mFragment.getPreferenceScreen().findPreference(
|
||||
AccessibilityManager.ACCESSIBILITY_MENU_IN_SYSTEM.flattenToString());
|
||||
assertThat(pref).isNull();
|
||||
}
|
||||
|
||||
private AccessibilityServiceInfo getMockAccessibilityServiceInfo(String packageName,
|
||||
String className) {
|
||||
return getMockAccessibilityServiceInfo(new ComponentName(packageName, className));
|
||||
}
|
||||
|
||||
private AccessibilityServiceInfo getMockAccessibilityServiceInfo(ComponentName componentName) {
|
||||
final ApplicationInfo applicationInfo = new ApplicationInfo();
|
||||
final ServiceInfo serviceInfo = new ServiceInfo();
|
||||
applicationInfo.packageName = packageName;
|
||||
serviceInfo.packageName = packageName;
|
||||
serviceInfo.name = className;
|
||||
applicationInfo.packageName = componentName.getPackageName();
|
||||
serviceInfo.packageName = componentName.getPackageName();
|
||||
serviceInfo.name = componentName.getClassName();
|
||||
serviceInfo.applicationInfo = applicationInfo;
|
||||
|
||||
final ResolveInfo resolveInfo = new ResolveInfo();
|
||||
@@ -342,7 +372,7 @@ public class AccessibilitySettingsTest {
|
||||
try {
|
||||
final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo,
|
||||
mContext);
|
||||
info.setComponentName(new ComponentName(packageName, className));
|
||||
info.setComponentName(componentName);
|
||||
return info;
|
||||
} catch (XmlPullParserException | IOException e) {
|
||||
// Do nothing
|
||||
|
Reference in New Issue
Block a user