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.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores information about a particular TaskFragment.
|
* Stores information about a particular TaskFragment.
|
||||||
* @hide
|
* @hide
|
||||||
@@ -50,9 +53,16 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
/** Whether this TaskFragment is visible on the window hierarchy. */
|
/** Whether this TaskFragment is visible on the window hierarchy. */
|
||||||
private final boolean mIsVisible;
|
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(
|
public TaskFragmentInfo(
|
||||||
@NonNull IBinder fragmentToken, @NonNull WindowContainerToken token,
|
@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) {
|
if (fragmentToken == null) {
|
||||||
throw new IllegalArgumentException("Invalid TaskFragmentInfo.");
|
throw new IllegalArgumentException("Invalid TaskFragmentInfo.");
|
||||||
}
|
}
|
||||||
@@ -61,6 +71,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
mConfiguration.setTo(configuration);
|
mConfiguration.setTo(configuration);
|
||||||
mIsEmpty = isEmpty;
|
mIsEmpty = isEmpty;
|
||||||
mIsVisible = isVisible;
|
mIsVisible = isVisible;
|
||||||
|
mActivities.addAll(activities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinder getFragmentToken() {
|
public IBinder getFragmentToken() {
|
||||||
@@ -83,6 +94,10 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
return mIsVisible;
|
return mIsVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IBinder> getActivities() {
|
||||||
|
return mActivities;
|
||||||
|
}
|
||||||
|
|
||||||
@WindowingMode
|
@WindowingMode
|
||||||
public int getWindowingMode() {
|
public int getWindowingMode() {
|
||||||
return mConfiguration.windowConfiguration.getWindowingMode();
|
return mConfiguration.windowConfiguration.getWindowingMode();
|
||||||
@@ -101,7 +116,8 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
&& mToken.equals(that.mToken)
|
&& mToken.equals(that.mToken)
|
||||||
&& mIsEmpty == that.mIsEmpty
|
&& mIsEmpty == that.mIsEmpty
|
||||||
&& mIsVisible == that.mIsVisible
|
&& mIsVisible == that.mIsVisible
|
||||||
&& getWindowingMode() == that.getWindowingMode();
|
&& getWindowingMode() == that.getWindowingMode()
|
||||||
|
&& mActivities.equals(that.mActivities);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskFragmentInfo(Parcel in) {
|
private TaskFragmentInfo(Parcel in) {
|
||||||
@@ -110,6 +126,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
mConfiguration.readFromParcel(in);
|
mConfiguration.readFromParcel(in);
|
||||||
mIsEmpty = in.readBoolean();
|
mIsEmpty = in.readBoolean();
|
||||||
mIsVisible = in.readBoolean();
|
mIsVisible = in.readBoolean();
|
||||||
|
in.readBinderList(mActivities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,6 +136,7 @@ public final class TaskFragmentInfo implements Parcelable {
|
|||||||
mConfiguration.writeToParcel(dest, flags);
|
mConfiguration.writeToParcel(dest, flags);
|
||||||
dest.writeBoolean(mIsEmpty);
|
dest.writeBoolean(mIsEmpty);
|
||||||
dest.writeBoolean(mIsVisible);
|
dest.writeBoolean(mIsVisible);
|
||||||
|
dest.writeBinderList(mActivities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
@@ -205,6 +205,13 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private IBinder mFragmentToken;
|
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 mTmpInsets = new Rect();
|
||||||
private final Rect mTmpBounds = new Rect();
|
private final Rect mTmpBounds = new Rect();
|
||||||
private final Rect mTmpFullBounds = new Rect();
|
private final Rect mTmpFullBounds = new Rect();
|
||||||
@@ -271,8 +278,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
taskFragment.mAdjacentTaskFragment = this;
|
taskFragment.mAdjacentTaskFragment = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTaskFragmentOrganizer(ITaskFragmentOrganizer organizer) {
|
void setTaskFragmentOrganizer(ITaskFragmentOrganizer organizer, int pid) {
|
||||||
mTaskFragmentOrganizer = organizer;
|
mTaskFragmentOrganizer = organizer;
|
||||||
|
mTaskFragmentOrganizerPid = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskFragment getAdjacentTaskFragment() {
|
TaskFragment getAdjacentTaskFragment() {
|
||||||
@@ -1991,12 +1999,23 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
* called from {@link Task}.
|
* called from {@link Task}.
|
||||||
*/
|
*/
|
||||||
TaskFragmentInfo getTaskFragmentInfo() {
|
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(
|
return new TaskFragmentInfo(
|
||||||
mFragmentToken,
|
mFragmentToken,
|
||||||
mRemoteToken.toWindowContainerToken(),
|
mRemoteToken.toWindowContainerToken(),
|
||||||
getConfiguration(),
|
getConfiguration(),
|
||||||
getChildCount() == 0,
|
getChildCount() == 0,
|
||||||
isVisible());
|
isVisible(),
|
||||||
|
childActivities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -924,7 +924,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
ownerActivity.getTask().addChild(taskFragment, POSITION_TOP);
|
ownerActivity.getTask().addChild(taskFragment, POSITION_TOP);
|
||||||
taskFragment.setWindowingMode(creationParams.getWindowingMode());
|
taskFragment.setWindowingMode(creationParams.getWindowingMode());
|
||||||
taskFragment.setBounds(creationParams.getInitialBounds());
|
taskFragment.setBounds(creationParams.getInitialBounds());
|
||||||
taskFragment.setTaskFragmentOrganizer(creationParams.getOrganizer());
|
taskFragment.setTaskFragmentOrganizer(
|
||||||
|
creationParams.getOrganizer(), ownerActivity.getPid());
|
||||||
mLaunchTaskFragments.put(creationParams.getFragmentToken(), taskFragment);
|
mLaunchTaskFragments.put(creationParams.getFragmentToken(), taskFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user