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

Commit c8a5b790 authored by Fan Zhang's avatar Fan Zhang
Browse files

Refresh dashboard category data when package changes.

Category needs to refresh when package information changes. So
CategoryUpdateTask should not early exit by just checking config
changes.

This is needed to refresh UI when user enables activity such as
developement options.

Also made CategoryManager thread safe because it's called in both UI
thread and asynctasks

Bug: 31781480
Test: manual

Change-Id: Idcdcd39f727aba423350f3874af5612474e24e28
parent f03f8e59
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.util.ArrayMap;
import android.util.Log;
import android.util.Pair;

import com.android.settingslib.applications.InterestingConfigChanges;

import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -33,8 +31,6 @@ public class CategoryManager {

    private static CategoryManager sInstance;

    private final InterestingConfigChanges mInterestingConfigChanges;

    // Tile cache (key: <packageName, activityName>, value: tile)
    private final Map<Pair<String, String>, Tile> mTileByComponentCache;

@@ -51,12 +47,11 @@ public class CategoryManager {
    }

    CategoryManager() {
        mInterestingConfigChanges = new InterestingConfigChanges();
        mTileByComponentCache = new ArrayMap<>();
        mCategoryByKeyMap = new ArrayMap<>();
    }

    public DashboardCategory getTilesByCategory(Context context, String categoryKey) {
    public synchronized DashboardCategory getTilesByCategory(Context context, String categoryKey) {
        tryInitCategories(context);

        final DashboardCategory category = mCategoryByKeyMap.get(categoryKey);
@@ -66,19 +61,17 @@ public class CategoryManager {
        return category;
    }

    public List<DashboardCategory> getCategories(Context context) {
    public synchronized List<DashboardCategory> getCategories(Context context) {
        tryInitCategories(context);
        return mCategories;
    }

    public void reloadAllCategoriesForConfigChange(Context context) {
        if (mInterestingConfigChanges.applyNewConfig(context.getResources())) {
    public synchronized void reloadAllCategories(Context context) {
        mCategories = null;
        tryInitCategories(context);
    }
    }

    public void updateCategoryFromBlacklist(Set<ComponentName> tileBlacklist) {
    public synchronized void updateCategoryFromBlacklist(Set<ComponentName> tileBlacklist) {
        if (mCategories == null) {
            Log.w(TAG, "Category is null, skipping blacklist update");
        }
@@ -93,7 +86,7 @@ public class CategoryManager {
        }
    }

    private void tryInitCategories(Context context) {
    private synchronized void tryInitCategories(Context context) {
        if (mCategories == null) {
            mTileByComponentCache.clear();
            mCategoryByKeyMap.clear();
+1 −1
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ public class SettingsDrawerActivity extends Activity {

        @Override
        protected Void doInBackground(Void... params) {
            mCategoryManager.reloadAllCategoriesForConfigChange(SettingsDrawerActivity.this);
            mCategoryManager.reloadAllCategories(SettingsDrawerActivity.this);
            return null;
        }