Move unused apps count calculation to bg thread

Move the somewhat expensive calculation of the "Unused apps" count to
the background thread

Initially, the "Unused apps" preference is unavailable. When the bg work
finishes and we see we have a non-zero number of unused apps, we display
the preference and update the summary text.

Bug: 187996287
Test: atest HibernatedAppsPreferenceControllerTest
Test: measure latency of displaying preferences w/ custom trace points

Change-Id: Idb0d836fd8f4bcdd2605a7d59703a7ed53bcd6d4
This commit is contained in:
Kevin Han
2021-06-01 18:53:30 -07:00
parent ef963fe079
commit 8df22e7cd9
3 changed files with 116 additions and 11 deletions

View File

@@ -69,6 +69,10 @@ public class AppDashboardFragment extends DashboardFragment {
use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());
mAppsPreferenceController = use(AppsPreferenceController.class);
mAppsPreferenceController.setFragment(this /* fragment */);
final HibernatedAppsPreferenceController hibernatedAppsPreferenceController =
use(HibernatedAppsPreferenceController.class);
getSettingsLifecycle().addObserver(hibernatedAppsPreferenceController);
}
@Override