diff options
Diffstat (limited to 'src/com/android/launcher3/icons')
-rw-r--r-- | src/com/android/launcher3/icons/ComponentWithLabel.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher3/icons/IconCache.java | 19 | ||||
-rw-r--r-- | src/com/android/launcher3/icons/LauncherIcons.java | 4 |
3 files changed, 19 insertions, 13 deletions
diff --git a/src/com/android/launcher3/icons/ComponentWithLabel.java b/src/com/android/launcher3/icons/ComponentWithLabel.java index 46b500265..832956d7e 100644 --- a/src/com/android/launcher3/icons/ComponentWithLabel.java +++ b/src/com/android/launcher3/icons/ComponentWithLabel.java @@ -34,9 +34,11 @@ public interface ComponentWithLabel { class ComponentCachingLogic implements CachingLogic<ComponentWithLabel> { private final PackageManager mPackageManager; + private final boolean mAddToMemCache; - public ComponentCachingLogic(Context context) { + public ComponentCachingLogic(Context context, boolean addToMemCache) { mPackageManager = context.getPackageManager(); + mAddToMemCache = addToMemCache; } @Override @@ -60,5 +62,10 @@ public interface ComponentWithLabel { // Do not load icon. target.icon = BitmapInfo.LOW_RES_ICON; } + + @Override + public boolean addToMemCache() { + return mAddToMemCache; + } } } diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index abff237e8..9c462606a 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -16,6 +16,9 @@ package com.android.launcher3.icons; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; +import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; + import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -36,8 +39,6 @@ import com.android.launcher3.IconProvider; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfoWithIcon; import com.android.launcher3.LauncherFiles; -import com.android.launcher3.LauncherModel; -import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.Utilities; import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.compat.LauncherAppsCompat; @@ -60,8 +61,6 @@ public class IconCache extends BaseIconCache { private static final String TAG = "Launcher.IconCache"; - private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor(); - private final CachingLogic<ComponentWithLabel> mComponentWithLabelCachingLogic; private final CachingLogic<LauncherActivityInfo> mLauncherActivityInfoCachingLogic; @@ -73,9 +72,9 @@ public class IconCache extends BaseIconCache { private int mPendingIconRequestCount = 0; public IconCache(Context context, InvariantDeviceProfile inv) { - super(context, LauncherFiles.APP_ICONS_DB, LauncherModel.getWorkerLooper(), + super(context, LauncherFiles.APP_ICONS_DB, MODEL_EXECUTOR.getLooper(), inv.fillResIconDpi, inv.iconBitmapSize, true /* inMemoryCache */); - mComponentWithLabelCachingLogic = new ComponentCachingLogic(context); + mComponentWithLabelCachingLogic = new ComponentCachingLogic(context, false); mLauncherActivityInfoCachingLogic = LauncherActivityCachingLogic.newInstance(context); mLauncherApps = LauncherAppsCompat.getInstance(mContext); mUserManager = UserManagerCompat.getInstance(mContext); @@ -124,7 +123,7 @@ public class IconCache extends BaseIconCache { final ItemInfoWithIcon info) { Preconditions.assertUIThread(); if (mPendingIconRequestCount <= 0) { - LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_FOREGROUND); + MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND); } mPendingIconRequestCount ++; @@ -136,7 +135,7 @@ public class IconCache extends BaseIconCache { } else if (info instanceof PackageItemInfo) { getTitleAndIconForApp((PackageItemInfo) info, false); } - mMainThreadExecutor.execute(() -> { + MAIN_EXECUTOR.execute(() -> { caller.reapplyItemInfo(info); onEnd(); }); @@ -149,7 +148,7 @@ public class IconCache extends BaseIconCache { private void onIconRequestEnd() { mPendingIconRequestCount --; if (mPendingIconRequestCount <= 0) { - LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_BACKGROUND); + MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); } } @@ -195,7 +194,7 @@ public class IconCache extends BaseIconCache { public synchronized String getTitleNoCache(ComponentWithLabel info) { CacheEntry entry = cacheLocked(info.getComponent(), info.getUser(), () -> info, mComponentWithLabelCachingLogic, false /* usePackageIcon */, - true /* useLowResIcon */, false /* addToMemCache */); + true /* useLowResIcon */); return Utilities.trim(entry.title); } diff --git a/src/com/android/launcher3/icons/LauncherIcons.java b/src/com/android/launcher3/icons/LauncherIcons.java index 763240885..adc92c46c 100644 --- a/src/com/android/launcher3/icons/LauncherIcons.java +++ b/src/com/android/launcher3/icons/LauncherIcons.java @@ -24,6 +24,8 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Process; +import androidx.annotation.Nullable; + import com.android.launcher3.AppInfo; import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.InvariantDeviceProfile; @@ -37,8 +39,6 @@ import com.android.launcher3.util.Themes; import java.util.function.Supplier; -import androidx.annotation.Nullable; - /** * Wrapper class to provide access to {@link BaseIconFactory} and also to provide pool of this class * that are threadsafe. |