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

@@ -50,6 +50,7 @@ public class AccessibilityActivityPreference extends RestrictedPreference {
private final AccessibilityShortcutInfo mA11yShortcutInfo;
private final PackageManager mPm;
private final ComponentName mComponentName;
private final CharSequence mLabel;
private final ListenableFuture mExtraArgumentsFuture;
public AccessibilityActivityPreference(Context context, String packageName, int uid,
@@ -58,9 +59,10 @@ public class AccessibilityActivityPreference extends RestrictedPreference {
mPm = context.getPackageManager();
mA11yShortcutInfo = a11yShortcutInfo;
mComponentName = a11yShortcutInfo.getComponentName();
mLabel = a11yShortcutInfo.getActivityInfo().loadLabel(mPm);
// setup basic info for a preference
setKey(mComponentName.flattenToString());
setTitle(a11yShortcutInfo.getActivityInfo().loadLabel(mPm));
setTitle(mLabel);
setSummary(a11yShortcutInfo.loadSummary(mPm));
setFragment(TARGET_FRAGMENT);
setIconSize(ICON_SIZE_MEDIUM);
@@ -92,6 +94,13 @@ public class AccessibilityActivityPreference extends RestrictedPreference {
super.performClick();
}
/**
* Returns the label of the Accessibility Activity
*/
public CharSequence getLabel() {
return mLabel;
}
private Drawable getA11yActivityIcon() {
ActivityInfo activityInfo = mA11yShortcutInfo.getActivityInfo();
Drawable serviceIcon;