Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92dec234 authored by Clark Scheff's avatar Clark Scheff Committed by Gerrit Code Review
Browse files

Revert "Themes: Build icon cache when applying icons"

This reverts commit 7bb802a4.

This is not thread safe.  It is possible for an icon to be in the
middle of being composed when another process requests it.  That
process would not be able to load the image.  In Trebuchet, the
icon would be displayed as the standard "android" icon since it
would not be able to load the icon.

Change-Id: Id9bc38296cc02c376f9ea66565babc00e8dbf634
parent 4d5c8cb6
Loading
Loading
Loading
Loading
+2 −23
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -122,9 +121,8 @@ public class ThemeService extends IThemeService.Stub {
    private class ThemeWorkerHandler extends Handler {
        private static final int MESSAGE_CHANGE_THEME = 1;
        private static final int MESSAGE_APPLY_DEFAULT_THEME = 2;
        private static final int MESSAGE_BUILD_ICON_CACHE = 3;
        private static final int MESSAGE_QUEUE_THEME_FOR_PROCESSING = 4;
        private static final int MESSAGE_DEQUEUE_AND_PROCESS_THEME = 5;
        private static final int MESSAGE_QUEUE_THEME_FOR_PROCESSING = 3;
        private static final int MESSAGE_DEQUEUE_AND_PROCESS_THEME = 4;

        public ThemeWorkerHandler(Looper looper) {
            super(looper);
@@ -140,9 +138,6 @@ public class ThemeService extends IThemeService.Stub {
                case MESSAGE_APPLY_DEFAULT_THEME:
                    doApplyDefaultTheme();
                    break;
                case MESSAGE_BUILD_ICON_CACHE:
                    doBuildIconCache();
                    break;
                case MESSAGE_QUEUE_THEME_FOR_PROCESSING:
                    String pkgName = (String) msg.obj;
                    synchronized (mThemesToProcessQueue) {
@@ -351,7 +346,6 @@ public class ThemeService extends IThemeService.Stub {
                mPM.updateIconMaps(null);
            } else {
                mPM.updateIconMaps(pkgName);
                mHandler.sendEmptyMessage(ThemeWorkerHandler.MESSAGE_BUILD_ICON_CACHE);
            }
        } catch (Exception e) {
            Log.w(TAG, "Changing icons failed", e);
@@ -1059,21 +1053,6 @@ public class ThemeService extends IThemeService.Stub {
        }
    };

    private void doBuildIconCache() {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> infos = mPM.queryIntentActivities(mainIntent, 0);
        for(ResolveInfo info : infos) {
            try {
                mPM.getActivityIcon(
                        new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
            } catch (Exception e) {
                Log.w(TAG, "Unable to fetch icon for " + info, e);
            }
        }
    }

    private void processInstalledThemes() {
        final String defaultTheme = ThemeUtils.getDefaultThemePackageName(mContext);
        Message msg;