Improve the speed of AccessibilitySettings#containsTargetNameInList to

help reduce the a11y settings' cold start latency.

Bug: 327052480
Flag: EXEMPT bugfix low risk
Test: atest com.android.settings.accessibility
Test: manual (a11y settings page still shows up with correct content)
Change-Id: Ib9980756d88a218ebb10f17d6a3b0d9a406a0ddd
This commit is contained in:
Chun-Ku Lin
2024-06-07 00:11:23 +00:00
parent b2f88a16c9
commit 7e03bf65c7
4 changed files with 34 additions and 25 deletions

View File

@@ -101,13 +101,14 @@ public class RestrictedPreferenceHelper {
}
/**
* Creates the list of {@link RestrictedPreference} with the installedShortcuts arguments.
* Creates the list of {@link AccessibilityActivityPreference} with the installedShortcuts
* arguments.
*
* @param installedShortcuts The list of {@link AccessibilityShortcutInfo}s of the
* installed accessibility shortcuts
* @return The list of {@link RestrictedPreference}
* @return The list of {@link AccessibilityActivityPreference}
*/
public List<RestrictedPreference> createAccessibilityActivityPreferenceList(
public List<AccessibilityActivityPreference> createAccessibilityActivityPreferenceList(
List<AccessibilityShortcutInfo> installedShortcuts) {
final Set<ComponentName> enabledServices =
AccessibilityUtils.getEnabledServicesFromSettings(mContext);
@@ -115,7 +116,7 @@ public class RestrictedPreferenceHelper {
UserHandle.myUserId());
final int installedShortcutsSize = installedShortcuts.size();
final List<RestrictedPreference> preferenceList = new ArrayList<>(
final List<AccessibilityActivityPreference> preferenceList = new ArrayList<>(
installedShortcutsSize);
for (int i = 0; i < installedShortcutsSize; ++i) {
@@ -124,7 +125,7 @@ public class RestrictedPreferenceHelper {
final ComponentName componentName = info.getComponentName();
final boolean serviceEnabled = enabledServices.contains(componentName);
RestrictedPreference preference = new AccessibilityActivityPreference(
AccessibilityActivityPreference preference = new AccessibilityActivityPreference(
mContext, componentName.getPackageName(), activityInfo.applicationInfo.uid,
info);
setRestrictedPreferenceEnabled(preference, permittedServices, serviceEnabled);