Load work apps in RecentAppStatsMixin

This change will show work apps and personal apps together in the
recent apps settings page, sorted by decreasing last usage time.

Test: see both work and personal apps in the recent apps page in the
correct order.
Fix: 146921442

Change-Id: I174a556010529bc39c085cc006722bc2947535bd
This commit is contained in:
Liahav Eitan
2022-05-20 11:53:11 +00:00
parent 7cebb74e17
commit 82e81e23e0
4 changed files with 214 additions and 65 deletions

View File

@@ -70,7 +70,7 @@ public class AppsPreferenceControllerTest {
private PreferenceScreen mScreen;
private AppsPreferenceController mController;
private List<UsageStats> mUsageStats;
private List<RecentAppStatsMixin.UsageStatsWrapper> mUsageStats;
private PreferenceCategory mRecentAppsCategory;
private PreferenceCategory mGeneralCategory;
private Preference mSeeAllPref;
@@ -147,15 +147,15 @@ public class AppsPreferenceControllerTest {
final UsageStats stat3 = new UsageStats();
stat1.mLastTimeUsed = System.currentTimeMillis();
stat1.mPackageName = "pkg.class";
mUsageStats.add(stat1);
mUsageStats.add(statsWrapperOf(stat1));
stat2.mLastTimeUsed = System.currentTimeMillis();
stat2.mPackageName = "pkg.class2";
mUsageStats.add(stat2);
mUsageStats.add(statsWrapperOf(stat2));
stat3.mLastTimeUsed = System.currentTimeMillis();
stat3.mPackageName = "pkg.class3";
mUsageStats.add(stat3);
mUsageStats.add(statsWrapperOf(stat3));
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
.thenReturn(mAppEntry);
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
@@ -164,4 +164,9 @@ public class AppsPreferenceControllerTest {
.thenReturn(mAppEntry);
mAppEntry.info = mApplicationInfo;
}
private static RecentAppStatsMixin.UsageStatsWrapper statsWrapperOf(
UsageStats stats) {
return new RecentAppStatsMixin.UsageStatsWrapper(stats, /* userId= */ 0);
}
}