Merge "Adding method to check if a task is running in home stack" into qt-r1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
22110bae84
@@ -20,6 +20,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.TaskDescription;
|
||||
import android.app.TaskInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
@@ -75,7 +76,7 @@ public class Task {
|
||||
|
||||
private int mHashCode;
|
||||
|
||||
public TaskKey(ActivityManager.RecentTaskInfo t) {
|
||||
public TaskKey(TaskInfo t) {
|
||||
ComponentName sourceComponent = t.origActivity != null
|
||||
// Activity alias if there is one
|
||||
? t.origActivity
|
||||
@@ -226,6 +227,17 @@ public class Task {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a task object from the provided task info
|
||||
*/
|
||||
public static Task from(TaskKey taskKey, TaskInfo taskInfo, boolean isLocked) {
|
||||
ActivityManager.TaskDescription td = taskInfo.taskDescription;
|
||||
return new Task(taskKey,
|
||||
td != null ? td.getPrimaryColor() : 0,
|
||||
td != null ? td.getBackgroundColor() : 0,
|
||||
taskInfo.supportsSplitScreenMultiWindow, isLocked, td, taskInfo.topActivity);
|
||||
}
|
||||
|
||||
public Task(TaskKey key) {
|
||||
this.key = key;
|
||||
this.taskDescription = new TaskDescription();
|
||||
|
||||
@@ -30,10 +30,12 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||
import android.annotation.NonNull;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RecentTaskInfo;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.IAssistDataReceiver;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.app.WindowConfiguration.ActivityType;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -500,4 +502,12 @@ public class ActivityManagerWrapper {
|
||||
PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT)
|
||||
|| freeformDevOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the running task represents the home task
|
||||
*/
|
||||
public static boolean isHomeTask(RunningTaskInfo info) {
|
||||
return info.configuration.windowConfiguration.getActivityType()
|
||||
== WindowConfiguration.ACTIVITY_TYPE_HOME;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user