Throw exception from SystemUiProxy.getRecentTasks for invalid result
- The reason Recents is empty after a force-stop is when RecentsTasksList.getTasks is called first time after restart, the result is always invalid but we cached the invalid result with a chagneId(=1). The next time we call getTasks again, we think the cached result is valid, and returend an empty list. - The fix is to mark such result as invalid to avoid caching the wrong result Fix: 353926204 Test: RecentTasksListTest Flag: EXEMPT bugfix Change-Id: If15ab8fd7454db8a08c22b17eaac73f0c78aa75f
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -69,14 +71,14 @@ public class RecentTasksListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRecentTasksChanged_doesNotFetchTasks() {
|
||||
public void onRecentTasksChanged_doesNotFetchTasks() throws Exception {
|
||||
mRecentTasksList.onRecentTasksChanged();
|
||||
verify(mockSystemUiProxy, times(0))
|
||||
.getRecentTasks(anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_onlyKeys_noValidTaskDescription() {
|
||||
public void loadTasksInBackground_onlyKeys_noValidTaskDescription() throws Exception {
|
||||
GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks(
|
||||
new ActivityManager.RecentTaskInfo(), new ActivityManager.RecentTaskInfo(), null);
|
||||
when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
@@ -91,7 +93,19 @@ public class RecentTasksListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_moreThanKeys_hasValidTaskDescription() {
|
||||
public void loadTasksInBackground_GetRecentTasksException() throws Exception {
|
||||
when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenThrow(new SystemUiProxy.GetRecentTasksException("task load failed"));
|
||||
|
||||
RecentTasksList.TaskLoadResult taskList = mRecentTasksList.loadTasksInBackground(
|
||||
Integer.MAX_VALUE, -1, false);
|
||||
|
||||
assertThat(taskList.mRequestId).isEqualTo(-1);
|
||||
assertThat(taskList).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_moreThanKeys_hasValidTaskDescription() throws Exception {
|
||||
String taskDescription = "Wheeee!";
|
||||
ActivityManager.RecentTaskInfo task1 = new ActivityManager.RecentTaskInfo();
|
||||
task1.taskDescription = new ActivityManager.TaskDescription(taskDescription);
|
||||
@@ -111,7 +125,7 @@ public class RecentTasksListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_freeformTask_createsDesktopTask() {
|
||||
public void loadTasksInBackground_freeformTask_createsDesktopTask() throws Exception {
|
||||
ActivityManager.RecentTaskInfo[] tasks = {
|
||||
createRecentTaskInfo(1 /* taskId */),
|
||||
createRecentTaskInfo(4 /* taskId */),
|
||||
@@ -134,7 +148,8 @@ public class RecentTasksListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_freeformTask_onlyMinimizedTasks_doesNotCreateDesktopTask() {
|
||||
public void loadTasksInBackground_freeformTask_onlyMinimizedTasks_doesNotCreateDesktopTask()
|
||||
throws Exception {
|
||||
ActivityManager.RecentTaskInfo[] tasks = {
|
||||
createRecentTaskInfo(1 /* taskId */),
|
||||
createRecentTaskInfo(4 /* taskId */),
|
||||
|
||||
Reference in New Issue
Block a user