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

Commit fea5eae1 authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Refresh dashboard category data when package changes."

parents e05040d5 c8a5b790
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;
        }