Settings dashboard performance work
- Don't block main thread with rebuild work - Don't run rebuild as foreground priority - Don't use comparator on apps/notifications summaries, we don't care about order - Simplify dashboard item layout Change-Id: I33bdd06a234ea308b44b45cac5ed1e9eac1c7d43 Fixes: 26541310
This commit is contained in:
@@ -33,20 +33,9 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_weight="1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -58,15 +47,9 @@
|
||||
<TextView android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:textAppearance="@style/TextAppearance.Small"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -23,10 +23,7 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.icu.text.AlphabeticIndex;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.*;
|
||||
import android.preference.PreferenceFrameLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
@@ -1225,6 +1222,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
// TODO: Can probably hack together with less than full app state.
|
||||
private final ApplicationsState mAppState;
|
||||
private final ApplicationsState.Session mSession;
|
||||
private final Handler mHandler;
|
||||
|
||||
private SummaryProvider(Context context, SummaryLoader loader) {
|
||||
mContext = context;
|
||||
@@ -1232,6 +1230,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
mAppState =
|
||||
ApplicationsState.getInstance((Application) context.getApplicationContext());
|
||||
mSession = mAppState.newSession(this);
|
||||
mHandler = new Handler(mAppState.getBackgroundLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1248,6 +1247,16 @@ public class ManageApplications extends InstrumentedFragment
|
||||
mLoader.setSummary(this, mContext.getString(R.string.apps_summary, apps.size()));
|
||||
}
|
||||
|
||||
private void postRebuild() {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSummary(mSession.rebuild(ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||
null, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebuildComplete(ArrayList<AppEntry> apps) {
|
||||
updateSummary(apps);
|
||||
@@ -1255,20 +1264,17 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
@Override
|
||||
public void onPackageListChanged() {
|
||||
updateSummary(mSession.rebuild(ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||
ApplicationsState.ALPHA_COMPARATOR));
|
||||
postRebuild();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLauncherInfoChanged() {
|
||||
updateSummary(mSession.rebuild(ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||
ApplicationsState.ALPHA_COMPARATOR));
|
||||
postRebuild();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadEntriesCompleted() {
|
||||
updateSummary(mSession.rebuild(ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||
ApplicationsState.ALPHA_COMPARATOR));
|
||||
postRebuild();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,6 +17,7 @@ package com.android.settings.applications;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppStateBaseBridge.Callback;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
@@ -44,6 +45,7 @@ public class NotificationApps extends ManageApplications {
|
||||
private final ApplicationsState.Session mSession;
|
||||
private final NotificationBackend mNotifBackend;
|
||||
private final AppStateNotificationBridge mExtraInfoBridge;
|
||||
private final Handler mHandler;
|
||||
|
||||
private SummaryProvider(Context context, SummaryLoader loader) {
|
||||
mContext = context;
|
||||
@@ -54,6 +56,7 @@ public class NotificationApps extends ManageApplications {
|
||||
mNotifBackend = new NotificationBackend();
|
||||
mExtraInfoBridge = new AppStateNotificationBridge(mContext,
|
||||
mAppState, this, mNotifBackend);
|
||||
mHandler = new Handler(mAppState.getBackgroundLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,9 +87,14 @@ public class NotificationApps extends ManageApplications {
|
||||
|
||||
@Override
|
||||
public void onExtraInfoUpdated() {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSummary(mSession.rebuild(
|
||||
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED,
|
||||
ApplicationsState.ALPHA_COMPARATOR));
|
||||
null, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user