mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Merge "Fix crash if AM returns empty task list" into tm-dev am: aca91898a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18379858 Change-Id: Ia13c75dadf005fcb70aac793c643cdc3b0718ace Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACT
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
@@ -183,30 +184,31 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
*/
|
||||
public static class CachedTaskInfo {
|
||||
|
||||
@Nullable
|
||||
private final RunningTaskInfo mTopTask;
|
||||
private final List<RunningTaskInfo> mAllCachedTasks;
|
||||
|
||||
CachedTaskInfo(List<RunningTaskInfo> allCachedTasks) {
|
||||
mAllCachedTasks = allCachedTasks;
|
||||
mTopTask = allCachedTasks.get(0);
|
||||
mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0);
|
||||
}
|
||||
|
||||
public int getTaskId() {
|
||||
return mTopTask.taskId;
|
||||
return mTopTask == null ? -1 : mTopTask.taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the root of the task chooser activity
|
||||
*/
|
||||
public boolean isRootChooseActivity() {
|
||||
return ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction());
|
||||
return mTopTask != null && ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given task holds an Assistant activity that is excluded from recents
|
||||
*/
|
||||
public boolean isExcludedAssistant() {
|
||||
return mTopTask.configuration.windowConfiguration
|
||||
return mTopTask != null && mTopTask.configuration.windowConfiguration
|
||||
.getActivityType() == ACTIVITY_TYPE_ASSISTANT
|
||||
&& (mTopTask.baseIntent.getFlags() & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
|
||||
}
|
||||
@@ -215,7 +217,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
* Returns true if this represents the HOME task
|
||||
*/
|
||||
public boolean isHomeTask() {
|
||||
return mTopTask.configuration.windowConfiguration
|
||||
return mTopTask != null && mTopTask.configuration.windowConfiguration
|
||||
.getActivityType() == ACTIVITY_TYPE_HOME;
|
||||
}
|
||||
|
||||
@@ -224,7 +226,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
* is loaded by the model
|
||||
*/
|
||||
public Task[] getPlaceholderTasks() {
|
||||
return new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
|
||||
return mTopTask == null ? new Task[0]
|
||||
: new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,6 +235,9 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
* placeholder until the true object is loaded by the model
|
||||
*/
|
||||
public Task[] getPlaceholderTasks(int[] taskIds) {
|
||||
if (mTopTask == null) {
|
||||
return new Task[0];
|
||||
}
|
||||
Task[] result = new Task[taskIds.length];
|
||||
for (int i = 0; i < taskIds.length; i++) {
|
||||
final int index = i;
|
||||
|
||||
@@ -56,6 +56,7 @@ import java.util.ArrayList;
|
||||
public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsState>
|
||||
implements StateListener<RecentsState> {
|
||||
|
||||
@Nullable
|
||||
private Task mHomeTask;
|
||||
|
||||
public FallbackRecentsView(Context context, AttributeSet attrs) {
|
||||
@@ -89,7 +90,7 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsSta
|
||||
RotationTouchHelper rotationTouchHelper) {
|
||||
// TODO(b/195607777) General fallback love, but this might be correct
|
||||
// Home task should be defined as the front-most task info I think?
|
||||
mHomeTask = homeTask[0];
|
||||
mHomeTask = homeTask.length > 0 ? homeTask[0] : null;
|
||||
onGestureAnimationStart(homeTask, rotationTouchHelper);
|
||||
}
|
||||
|
||||
|
||||
@@ -2257,6 +2257,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
* is called. Also scrolls the view to this task.
|
||||
*/
|
||||
private void showCurrentTask(Task[] runningTasks) {
|
||||
if (runningTasks.length == 0) {
|
||||
return;
|
||||
}
|
||||
int runningTaskViewId = -1;
|
||||
boolean needGroupTaskView = runningTasks.length > 1;
|
||||
if (shouldAddStubTaskView(runningTasks)) {
|
||||
|
||||
Reference in New Issue
Block a user