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

Commit f306f85c authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Settings dashboard performance work" into nyc-dev

parents 2d2ec882 b0ae8f82
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -534,6 +534,7 @@ public class ApplicationsState {
        Comparator<AppEntry> mRebuildComparator;
        ArrayList<AppEntry> mRebuildResult;
        ArrayList<AppEntry> mLastAppList;
        boolean mRebuildForeground;

        Session(Callbacks callbacks) {
            mCallbacks = callbacks;
@@ -572,6 +573,11 @@ public class ApplicationsState {

        // Creates a new list of app entries with the given filter and comparator.
        public ArrayList<AppEntry> rebuild(AppFilter filter, Comparator<AppEntry> comparator) {
            return rebuild(filter, comparator, true);
        }

        public ArrayList<AppEntry> rebuild(AppFilter filter, Comparator<AppEntry> comparator,
                boolean foreground) {
            synchronized (mRebuildSync) {
                synchronized (mEntriesMap) {
                    mRebuildingSessions.add(this);
@@ -579,6 +585,7 @@ public class ApplicationsState {
                    mRebuildAsync = false;
                    mRebuildFilter = filter;
                    mRebuildComparator = comparator;
                    mRebuildForeground = foreground;
                    mRebuildResult = null;
                    if (!mBackgroundHandler.hasMessages(BackgroundHandler.MSG_REBUILD_LIST)) {
                        Message msg = mBackgroundHandler.obtainMessage(
@@ -620,9 +627,11 @@ public class ApplicationsState {
                mRebuildRequested = false;
                mRebuildFilter = null;
                mRebuildComparator = null;
            }

                if (mRebuildForeground) {
                    Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
                    mRebuildForeground = false;
                }
            }

            if (filter != null) {
                filter.init();
@@ -640,7 +649,10 @@ public class ApplicationsState {
                if (filter == null || filter.filterApp(entry)) {
                    synchronized (mEntriesMap) {
                        if (DEBUG_LOCKING) Log.v(TAG, "rebuild acquired lock");
                        if (comparator != null) {
                            // Only need the label if we are going to be sorting.
                            entry.ensureLabel(mContext);
                        }
                        if (DEBUG) Log.i(TAG, "Using " + entry.info.packageName + ": " + entry);
                        filteredApps.add(entry);
                        if (DEBUG_LOCKING) Log.v(TAG, "rebuild releasing lock");
@@ -648,7 +660,9 @@ public class ApplicationsState {
                }
            }

            if (comparator != null) {
                Collections.sort(filteredApps, comparator);
            }

            synchronized (mRebuildSync) {
                if (!mRebuildRequested) {
+2 −0
Original line number Diff line number Diff line
@@ -216,6 +216,8 @@ public class SettingsDrawerActivity extends Activity {
        if (sDashboardCategories == null) {
            sTileCache = new HashMap<>();
            sConfigTracker = new InterestingConfigChanges();
            // Apply initial current config.
            sConfigTracker.applyNewConfig(getResources());
            sDashboardCategories = TileUtils.getCategories(this, sTileCache);
        }
        return sDashboardCategories;