Merge "Include the list of child Activities in TaskFragmentInfo" into sc-v2-dev
This commit is contained in:
@@ -25,6 +25,9 @@ import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Stores information about a particular TaskFragment.
|
||||
* @hide
|
||||
@@ -50,9 +53,16 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
/** Whether this TaskFragment is visible on the window hierarchy. */
|
||||
private final boolean mIsVisible;
|
||||
|
||||
/**
|
||||
* List of Activity tokens that are children of this TaskFragment. It only contains Activities
|
||||
* that belong to the organizer process for security.
|
||||
*/
|
||||
private final List<IBinder> mActivities = new ArrayList<>();
|
||||
|
||||
public TaskFragmentInfo(
|
||||
@NonNull IBinder fragmentToken, @NonNull WindowContainerToken token,
|
||||
@NonNull Configuration configuration, boolean isEmpty, boolean isVisible) {
|
||||
@NonNull Configuration configuration, boolean isEmpty, boolean isVisible,
|
||||
List<IBinder> activities) {
|
||||
if (fragmentToken == null) {
|
||||
throw new IllegalArgumentException("Invalid TaskFragmentInfo.");
|
||||
}
|
||||
@@ -61,6 +71,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
mConfiguration.setTo(configuration);
|
||||
mIsEmpty = isEmpty;
|
||||
mIsVisible = isVisible;
|
||||
mActivities.addAll(activities);
|
||||
}
|
||||
|
||||
public IBinder getFragmentToken() {
|
||||
@@ -83,6 +94,10 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
return mIsVisible;
|
||||
}
|
||||
|
||||
public List<IBinder> getActivities() {
|
||||
return mActivities;
|
||||
}
|
||||
|
||||
@WindowingMode
|
||||
public int getWindowingMode() {
|
||||
return mConfiguration.windowConfiguration.getWindowingMode();
|
||||
@@ -101,7 +116,8 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
&& mToken.equals(that.mToken)
|
||||
&& mIsEmpty == that.mIsEmpty
|
||||
&& mIsVisible == that.mIsVisible
|
||||
&& getWindowingMode() == that.getWindowingMode();
|
||||
&& getWindowingMode() == that.getWindowingMode()
|
||||
&& mActivities.equals(that.mActivities);
|
||||
}
|
||||
|
||||
private TaskFragmentInfo(Parcel in) {
|
||||
@@ -110,6 +126,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
mConfiguration.readFromParcel(in);
|
||||
mIsEmpty = in.readBoolean();
|
||||
mIsVisible = in.readBoolean();
|
||||
in.readBinderList(mActivities);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,6 +136,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
||||
mConfiguration.writeToParcel(dest, flags);
|
||||
dest.writeBoolean(mIsEmpty);
|
||||
dest.writeBoolean(mIsVisible);
|
||||
dest.writeBinderList(mActivities);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -205,6 +205,13 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
@Nullable
|
||||
private IBinder mFragmentToken;
|
||||
|
||||
/**
|
||||
* The PID of the organizer that created this TaskFragment. It should be the same as the PID
|
||||
* of {@link android.window.TaskFragmentCreationParams#getOwnerToken()}.
|
||||
* {@link ActivityRecord#INVALID_PID} if this is not an organizer-created TaskFragment.
|
||||
*/
|
||||
private int mTaskFragmentOrganizerPid = ActivityRecord.INVALID_PID;
|
||||
|
||||
private final Rect mTmpInsets = new Rect();
|
||||
private final Rect mTmpBounds = new Rect();
|
||||
private final Rect mTmpFullBounds = new Rect();
|
||||
@@ -271,8 +278,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
taskFragment.mAdjacentTaskFragment = this;
|
||||
}
|
||||
|
||||
void setTaskFragmentOrganizer(ITaskFragmentOrganizer organizer) {
|
||||
void setTaskFragmentOrganizer(ITaskFragmentOrganizer organizer, int pid) {
|
||||
mTaskFragmentOrganizer = organizer;
|
||||
mTaskFragmentOrganizerPid = pid;
|
||||
}
|
||||
|
||||
TaskFragment getAdjacentTaskFragment() {
|
||||
@@ -1991,12 +1999,23 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
* called from {@link Task}.
|
||||
*/
|
||||
TaskFragmentInfo getTaskFragmentInfo() {
|
||||
List<IBinder> childActivities = new ArrayList<>();
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
WindowContainer wc = getChildAt(i);
|
||||
if (mTaskFragmentOrganizerPid != ActivityRecord.INVALID_PID
|
||||
&& wc.asActivityRecord() != null
|
||||
&& wc.asActivityRecord().getPid() == mTaskFragmentOrganizerPid) {
|
||||
// Only includes Activities that belong to the organizer process for security.
|
||||
childActivities.add(wc.asActivityRecord().appToken);
|
||||
}
|
||||
}
|
||||
return new TaskFragmentInfo(
|
||||
mFragmentToken,
|
||||
mRemoteToken.toWindowContainerToken(),
|
||||
getConfiguration(),
|
||||
getChildCount() == 0,
|
||||
isVisible());
|
||||
isVisible(),
|
||||
childActivities);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -924,7 +924,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
||||
ownerActivity.getTask().addChild(taskFragment, POSITION_TOP);
|
||||
taskFragment.setWindowingMode(creationParams.getWindowingMode());
|
||||
taskFragment.setBounds(creationParams.getInitialBounds());
|
||||
taskFragment.setTaskFragmentOrganizer(creationParams.getOrganizer());
|
||||
taskFragment.setTaskFragmentOrganizer(
|
||||
creationParams.getOrganizer(), ownerActivity.getPid());
|
||||
mLaunchTaskFragments.put(creationParams.getFragmentToken(), taskFragment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user