Add a static method on the ApplicationsState to enable app icon cache

This will be used by the EBS (Flipendo) process to enable the app icon cache mechanism to improve the resume latency without loading the icon from the PackageManager again

Bug: 232360114
Test: presubmit and local verification on the EBS page
Change-Id: I6694e3792f6be09620b102789b77816b0c40a4a3
This commit is contained in:
ykhung
2023-02-02 09:40:10 +08:00
committed by YK Hung
parent 58af2f2549
commit 5e8e8ebc19

View File

@@ -101,6 +101,9 @@ public class ApplicationsState {
@VisibleForTesting
static ApplicationsState sInstance;
// Whether the app icon cache mechanism is enabled or not.
private static boolean sAppIconCacheEnabled = false;
public static ApplicationsState getInstance(Application app) {
return getInstance(app, AppGlobals.getPackageManager());
}
@@ -115,6 +118,11 @@ public class ApplicationsState {
}
}
/** Set whether the app icon cache mechanism is enabled or not. */
public static void setAppIconCacheEnabled(boolean enabled) {
sAppIconCacheEnabled = enabled;
}
final Context mContext;
final PackageManager mPm;
final IPackageManager mIpm;
@@ -776,7 +784,8 @@ public class ApplicationsState {
}
private static boolean isAppIconCacheEnabled(Context context) {
return SETTING_PKG.equals(context.getPackageName());
return SETTING_PKG.equals(context.getPackageName())
|| sAppIconCacheEnabled;
}
void rebuildActiveSessions() {