Handling configuration changes at runtime instead of killing the process

Change-Id: I0c7f7e58ddb690f371c257b6142a4e918e9acb7f
This commit is contained in:
Sunny Goyal committed 2018-10-19 12:52:17 -07:00
1 parent 6e11a2d9f2
commit 87dc48b7bf
7 files changed
+168 -48

No files matched your search

@@ -90,11 +90,11 @@ public class BaseIconCache {
private final HashMap<ComponentKey, CacheEntry> mCache =
new HashMap<>(INITIAL_ICON_CACHE_CAPACITY);
private final InstantAppResolver mInstantAppResolver;
final int mIconDpi;
final IconDB mIconDb;
final Handler mWorkerHandler;
int mIconDpi;
IconDB mIconDb;
private final BitmapFactory.Options mDecodeOptions;
public BaseIconCache(Context context, int iconDpi, int iconPixelSize) {
@@ -103,8 +103,6 @@ public class BaseIconCache {
mUserManager = UserManagerCompat.getInstance(mContext);
mLauncherApps = LauncherAppsCompat.getInstance(mContext);
mInstantAppResolver = InstantAppResolver.newInstance(mContext);
mIconDpi = iconDpi;
mIconDb = new IconDB(context, iconPixelSize);
mIconProvider = IconProvider.newInstance(context);
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
@@ -115,6 +113,22 @@ public class BaseIconCache {
} else {
mDecodeOptions = null;
}
mIconDpi = iconDpi;
mIconDb = new IconDB(context, iconPixelSize);
}
public void updateIconParams(int iconDpi, int iconPixelSize) {
mWorkerHandler.post(() -> updateIconParamsBg(iconDpi, iconPixelSize));
}
private synchronized void updateIconParamsBg(int iconDpi, int iconPixelSize) {
mIconDpi = iconDpi;
mDefaultIcons.clear();
mIconDb.close();
mIconDb = new IconDB(mContext, iconPixelSize);
mCache.clear();
}
private Drawable getFullResDefaultActivityIcon() {