From 5e8e8ebc1920b14ce06351a0c73ddeae131316dd Mon Sep 17 00:00:00 2001 From: ykhung Date: Thu, 2 Feb 2023 09:40:10 +0800 Subject: [PATCH] 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 --- .../settingslib/applications/ApplicationsState.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java index 21e7d816d7273..48d449dd7daa6 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java @@ -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() {