Merge "Fix Settings crash"

This commit is contained in:
TreeHugger Robot
2019-09-27 16:05:32 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 3 deletions

View File

@@ -865,6 +865,10 @@ public class ApplicationsState {
void handleRebuildList() {
AppFilter filter;
Comparator<AppEntry> comparator;
if (!mResumed) {
return;
}
synchronized (mRebuildSync) {
if (!mRebuildRequested) {
return;
@@ -1069,8 +1073,8 @@ public class ApplicationsState {
}
}
if (rebuildingSessions != null) {
for (int i = 0; i < rebuildingSessions.size(); i++) {
rebuildingSessions.get(i).handleRebuildList();
for (Session session : rebuildingSessions) {
session.handleRebuildList();
}
}

View File

@@ -269,7 +269,7 @@ public class ApplicationsStateRoboTest {
}
@Test
public void testDefaultSessionLoadsAll() {
public void testDefaultSession_isResumed_LoadsAll() {
mSession.onResume();
addApp(HOME_PACKAGE_NAME, 1);
@@ -295,6 +295,19 @@ public class ApplicationsStateRoboTest {
assertThat(launchableEntry.launcherEntryEnabled).isTrue();
}
@Test
public void testDefaultSession_isPaused_NotLoadsAll() {
mSession.onResume();
addApp(HOME_PACKAGE_NAME, 1);
addApp(LAUNCHABLE_PACKAGE_NAME, 2);
mSession.mResumed = false;
mSession.rebuild(ApplicationsState.FILTER_EVERYTHING, ApplicationsState.SIZE_COMPARATOR);
processAllMessages();
verify(mCallbacks, never()).onRebuildComplete(mAppEntriesCaptor.capture());
}
@Test
public void testCustomSessionLoadsIconsOnly() {
mSession.setSessionFlags(ApplicationsState.FLAG_SESSION_REQUEST_ICONS);