Loading quickstep/src/com/android/quickstep/RecentTasksList.java +12 −4 Original line number Diff line number Diff line Loading @@ -300,8 +300,12 @@ public class RecentTasksList { @VisibleForTesting TaskLoadResult loadTasksInBackground(int numTasks, int requestId, boolean loadKeysOnly) { int currentUserId = Process.myUserHandle().getIdentifier(); ArrayList<GroupedRecentTaskInfo> rawTasks = mSysUiProxy.getRecentTasks(numTasks, currentUserId); ArrayList<GroupedRecentTaskInfo> rawTasks; try { rawTasks = mSysUiProxy.getRecentTasks(numTasks, currentUserId); } catch (SystemUiProxy.GetRecentTasksException e) { return INVALID_RESULT; } // The raw tasks are given in most-recent to least-recent order, we need to reverse it Collections.reverse(rawTasks); Loading Loading @@ -416,8 +420,12 @@ public class RecentTasksList { } writer.println(prefix + " ]"); int currentUserId = Process.myUserHandle().getIdentifier(); ArrayList<GroupedRecentTaskInfo> rawTasks = mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); ArrayList<GroupedRecentTaskInfo> rawTasks; try { rawTasks = mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); } catch (SystemUiProxy.GetRecentTasksException e) { rawTasks = new ArrayList<>(); } writer.println(prefix + " rawTasks=["); for (GroupedRecentTaskInfo task : rawTasks) { TaskInfo taskInfo1 = task.getTaskInfo1(); Loading quickstep/src/com/android/quickstep/SystemUiProxy.java +21 −5 Original line number Diff line number Diff line Loading @@ -1394,10 +1394,26 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } } public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) { public static class GetRecentTasksException extends Exception { public GetRecentTasksException(String message) { super(message); } public GetRecentTasksException(String message, Throwable cause) { super(message, cause); } } /** * Retrieves a list of Recent tasks from ActivityManager. * @throws GetRecentTasksException if IRecentTasks is not initialized, or when we get * RemoteException from server side */ public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) throws GetRecentTasksException { if (mRecentTasks == null) { Log.w(TAG, "getRecentTasks() failed due to null mRecentTasks"); return new ArrayList<>(); Log.e(TAG, "getRecentTasks() failed due to null mRecentTasks"); throw new GetRecentTasksException("null mRecentTasks"); } try { final GroupedRecentTaskInfo[] rawTasks = mRecentTasks.getRecentTasks(numTasks, Loading @@ -1407,8 +1423,8 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } return new ArrayList<>(Arrays.asList(rawTasks)); } catch (RemoteException e) { Log.w(TAG, "Failed call getRecentTasks", e); return new ArrayList<>(); Log.e(TAG, "Failed call getRecentTasks", e); throw new GetRecentTasksException("Failed call getRecentTasks", e); } } Loading quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +20 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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())) Loading @@ -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); Loading @@ -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 */), Loading @@ -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 */), Loading Loading
quickstep/src/com/android/quickstep/RecentTasksList.java +12 −4 Original line number Diff line number Diff line Loading @@ -300,8 +300,12 @@ public class RecentTasksList { @VisibleForTesting TaskLoadResult loadTasksInBackground(int numTasks, int requestId, boolean loadKeysOnly) { int currentUserId = Process.myUserHandle().getIdentifier(); ArrayList<GroupedRecentTaskInfo> rawTasks = mSysUiProxy.getRecentTasks(numTasks, currentUserId); ArrayList<GroupedRecentTaskInfo> rawTasks; try { rawTasks = mSysUiProxy.getRecentTasks(numTasks, currentUserId); } catch (SystemUiProxy.GetRecentTasksException e) { return INVALID_RESULT; } // The raw tasks are given in most-recent to least-recent order, we need to reverse it Collections.reverse(rawTasks); Loading Loading @@ -416,8 +420,12 @@ public class RecentTasksList { } writer.println(prefix + " ]"); int currentUserId = Process.myUserHandle().getIdentifier(); ArrayList<GroupedRecentTaskInfo> rawTasks = mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); ArrayList<GroupedRecentTaskInfo> rawTasks; try { rawTasks = mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); } catch (SystemUiProxy.GetRecentTasksException e) { rawTasks = new ArrayList<>(); } writer.println(prefix + " rawTasks=["); for (GroupedRecentTaskInfo task : rawTasks) { TaskInfo taskInfo1 = task.getTaskInfo1(); Loading
quickstep/src/com/android/quickstep/SystemUiProxy.java +21 −5 Original line number Diff line number Diff line Loading @@ -1394,10 +1394,26 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } } public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) { public static class GetRecentTasksException extends Exception { public GetRecentTasksException(String message) { super(message); } public GetRecentTasksException(String message, Throwable cause) { super(message, cause); } } /** * Retrieves a list of Recent tasks from ActivityManager. * @throws GetRecentTasksException if IRecentTasks is not initialized, or when we get * RemoteException from server side */ public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) throws GetRecentTasksException { if (mRecentTasks == null) { Log.w(TAG, "getRecentTasks() failed due to null mRecentTasks"); return new ArrayList<>(); Log.e(TAG, "getRecentTasks() failed due to null mRecentTasks"); throw new GetRecentTasksException("null mRecentTasks"); } try { final GroupedRecentTaskInfo[] rawTasks = mRecentTasks.getRecentTasks(numTasks, Loading @@ -1407,8 +1423,8 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } return new ArrayList<>(Arrays.asList(rawTasks)); } catch (RemoteException e) { Log.w(TAG, "Failed call getRecentTasks", e); return new ArrayList<>(); Log.e(TAG, "Failed call getRecentTasks", e); throw new GetRecentTasksException("Failed call getRecentTasks", e); } } Loading
quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +20 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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())) Loading @@ -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); Loading @@ -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 */), Loading @@ -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 */), Loading