Merge "Removing TaskFragment token from LaunchActivityItem" into sc-v2-dev am: 5df8cac564

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15937027

Change-Id: I956d0cf59bdd8dcb8a96cd7c6f023ed724575d6b
This commit is contained in:
Louis Chang
2021-10-05 03:05:51 +00:00
committed by Automerger Merge Worker
9 changed files with 13 additions and 59 deletions

View File

@@ -526,9 +526,6 @@ public final class ActivityThread extends ClientTransactionHandler
// A reusable token for other purposes, e.g. content capture, translation. It shouldn't be // A reusable token for other purposes, e.g. content capture, translation. It shouldn't be
// used without security checks // used without security checks
public IBinder shareableActivityToken; public IBinder shareableActivityToken;
// The token of the initial TaskFragment that embedded this activity. Do not rely on it
// after creation because the activity could be reparented.
@Nullable public IBinder mInitialTaskFragmentToken;
int ident; int ident;
@UnsupportedAppUsage @UnsupportedAppUsage
Intent intent; Intent intent;
@@ -622,8 +619,7 @@ public final class ActivityThread extends ClientTransactionHandler
List<ReferrerIntent> pendingNewIntents, ActivityOptions activityOptions, List<ReferrerIntent> pendingNewIntents, ActivityOptions activityOptions,
boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client, boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client,
IBinder assistToken, FixedRotationAdjustments fixedRotationAdjustments, IBinder assistToken, FixedRotationAdjustments fixedRotationAdjustments,
IBinder shareableActivityToken, boolean launchedFromBubble, IBinder shareableActivityToken, boolean launchedFromBubble) {
IBinder initialTaskFragmentToken) {
this.token = token; this.token = token;
this.assistToken = assistToken; this.assistToken = assistToken;
this.shareableActivityToken = shareableActivityToken; this.shareableActivityToken = shareableActivityToken;
@@ -645,7 +641,6 @@ public final class ActivityThread extends ClientTransactionHandler
mActivityOptions = activityOptions; mActivityOptions = activityOptions;
mPendingFixedRotationAdjustments = fixedRotationAdjustments; mPendingFixedRotationAdjustments = fixedRotationAdjustments;
mLaunchedFromBubble = launchedFromBubble; mLaunchedFromBubble = launchedFromBubble;
mInitialTaskFragmentToken = initialTaskFragmentToken;
init(); init();
} }

View File

@@ -73,7 +73,6 @@ public class LaunchActivityItem extends ClientTransactionItem {
private IBinder mAssistToken; private IBinder mAssistToken;
private IBinder mShareableActivityToken; private IBinder mShareableActivityToken;
private boolean mLaunchedFromBubble; private boolean mLaunchedFromBubble;
private IBinder mTaskFragmentToken;
/** /**
* It is only non-null if the process is the first time to launch activity. It is only an * It is only non-null if the process is the first time to launch activity. It is only an
* optimization for quick look up of the interface so the field is ignored for comparison. * optimization for quick look up of the interface so the field is ignored for comparison.
@@ -87,7 +86,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
mOverrideConfig, mCompatInfo, mReferrer, mVoiceInteractor, mState, mPersistentState, mOverrideConfig, mCompatInfo, mReferrer, mVoiceInteractor, mState, mPersistentState,
mPendingResults, mPendingNewIntents, mActivityOptions, mIsForward, mProfilerInfo, mPendingResults, mPendingNewIntents, mActivityOptions, mIsForward, mProfilerInfo,
client, mAssistToken, mFixedRotationAdjustments, mShareableActivityToken, client, mAssistToken, mFixedRotationAdjustments, mShareableActivityToken,
mLaunchedFromBubble, mTaskFragmentToken); mLaunchedFromBubble);
client.addLaunchingActivity(token, r); client.addLaunchingActivity(token, r);
client.updateProcessState(mProcState, false); client.updateProcessState(mProcState, false);
client.updatePendingConfiguration(mCurConfig); client.updatePendingConfiguration(mCurConfig);
@@ -125,7 +124,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
boolean isForward, ProfilerInfo profilerInfo, IBinder assistToken, boolean isForward, ProfilerInfo profilerInfo, IBinder assistToken,
IActivityClientController activityClientController, IActivityClientController activityClientController,
FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken, FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken,
boolean launchedFromBubble, IBinder taskFragmentToken) { boolean launchedFromBubble) {
LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class); LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class);
if (instance == null) { if (instance == null) {
instance = new LaunchActivityItem(); instance = new LaunchActivityItem();
@@ -134,7 +133,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
voiceInteractor, procState, state, persistentState, pendingResults, voiceInteractor, procState, state, persistentState, pendingResults,
pendingNewIntents, activityOptions, isForward, profilerInfo, assistToken, pendingNewIntents, activityOptions, isForward, profilerInfo, assistToken,
activityClientController, fixedRotationAdjustments, shareableActivityToken, activityClientController, fixedRotationAdjustments, shareableActivityToken,
launchedFromBubble, taskFragmentToken); launchedFromBubble);
return instance; return instance;
} }
@@ -142,7 +141,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
@Override @Override
public void recycle() { public void recycle() {
setValues(this, null, 0, null, null, null, null, null, null, 0, null, null, null, null, setValues(this, null, 0, null, null, null, null, null, null, 0, null, null, null, null,
null, false, null, null, null, null, null, false, null); null, false, null, null, null, null, null, false);
ObjectPool.recycle(this); ObjectPool.recycle(this);
} }
@@ -173,7 +172,6 @@ public class LaunchActivityItem extends ClientTransactionItem {
dest.writeTypedObject(mFixedRotationAdjustments, flags); dest.writeTypedObject(mFixedRotationAdjustments, flags);
dest.writeStrongBinder(mShareableActivityToken); dest.writeStrongBinder(mShareableActivityToken);
dest.writeBoolean(mLaunchedFromBubble); dest.writeBoolean(mLaunchedFromBubble);
dest.writeStrongBinder(mTaskFragmentToken);
} }
/** Read from Parcel. */ /** Read from Parcel. */
@@ -192,8 +190,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
in.readStrongBinder(), in.readStrongBinder(),
IActivityClientController.Stub.asInterface(in.readStrongBinder()), IActivityClientController.Stub.asInterface(in.readStrongBinder()),
in.readTypedObject(FixedRotationAdjustments.CREATOR), in.readStrongBinder(), in.readTypedObject(FixedRotationAdjustments.CREATOR), in.readStrongBinder(),
in.readBoolean(), in.readBoolean());
in.readStrongBinder());
} }
public static final @NonNull Creator<LaunchActivityItem> CREATOR = public static final @NonNull Creator<LaunchActivityItem> CREATOR =
@@ -232,8 +229,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
&& Objects.equals(mProfilerInfo, other.mProfilerInfo) && Objects.equals(mProfilerInfo, other.mProfilerInfo)
&& Objects.equals(mAssistToken, other.mAssistToken) && Objects.equals(mAssistToken, other.mAssistToken)
&& Objects.equals(mFixedRotationAdjustments, other.mFixedRotationAdjustments) && Objects.equals(mFixedRotationAdjustments, other.mFixedRotationAdjustments)
&& Objects.equals(mShareableActivityToken, other.mShareableActivityToken) && Objects.equals(mShareableActivityToken, other.mShareableActivityToken);
&& Objects.equals(mTaskFragmentToken, other.mTaskFragmentToken);
} }
@Override @Override
@@ -256,7 +252,6 @@ public class LaunchActivityItem extends ClientTransactionItem {
result = 31 * result + Objects.hashCode(mAssistToken); result = 31 * result + Objects.hashCode(mAssistToken);
result = 31 * result + Objects.hashCode(mFixedRotationAdjustments); result = 31 * result + Objects.hashCode(mFixedRotationAdjustments);
result = 31 * result + Objects.hashCode(mShareableActivityToken); result = 31 * result + Objects.hashCode(mShareableActivityToken);
result = 31 * result + Objects.hashCode(mTaskFragmentToken);
return result; return result;
} }
@@ -306,7 +301,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
ActivityOptions activityOptions, boolean isForward, ProfilerInfo profilerInfo, ActivityOptions activityOptions, boolean isForward, ProfilerInfo profilerInfo,
IBinder assistToken, IActivityClientController activityClientController, IBinder assistToken, IActivityClientController activityClientController,
FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken, FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken,
boolean launchedFromBubble, IBinder taskFragmentToken) { boolean launchedFromBubble) {
instance.mIntent = intent; instance.mIntent = intent;
instance.mIdent = ident; instance.mIdent = ident;
instance.mInfo = info; instance.mInfo = info;
@@ -328,6 +323,5 @@ public class LaunchActivityItem extends ClientTransactionItem {
instance.mFixedRotationAdjustments = fixedRotationAdjustments; instance.mFixedRotationAdjustments = fixedRotationAdjustments;
instance.mShareableActivityToken = shareableActivityToken; instance.mShareableActivityToken = shareableActivityToken;
instance.mLaunchedFromBubble = launchedFromBubble; instance.mLaunchedFromBubble = launchedFromBubble;
instance.mTaskFragmentToken = taskFragmentToken;
} }
} }

View File

@@ -157,7 +157,7 @@ public class ObjectPoolTests {
.setPendingResults(resultInfoList()).setPendingNewIntents(referrerIntentList()) .setPendingResults(resultInfoList()).setPendingNewIntents(referrerIntentList())
.setIsForward(true).setAssistToken(assistToken) .setIsForward(true).setAssistToken(assistToken)
.setShareableActivityToken(shareableActivityToken) .setShareableActivityToken(shareableActivityToken)
.setTaskFragmentToken(new Binder()).build(); .build();
LaunchActivityItem emptyItem = new LaunchActivityItemBuilder().build(); LaunchActivityItem emptyItem = new LaunchActivityItemBuilder().build();
LaunchActivityItem item = itemSupplier.get(); LaunchActivityItem item = itemSupplier.get();

View File

@@ -112,7 +112,6 @@ class TestUtils {
private IBinder mShareableActivityToken; private IBinder mShareableActivityToken;
private FixedRotationAdjustments mFixedRotationAdjustments; private FixedRotationAdjustments mFixedRotationAdjustments;
private boolean mLaunchedFromBubble; private boolean mLaunchedFromBubble;
private IBinder mTaskFragmentToken;
LaunchActivityItemBuilder setIntent(Intent intent) { LaunchActivityItemBuilder setIntent(Intent intent) {
mIntent = intent; mIntent = intent;
@@ -214,18 +213,13 @@ class TestUtils {
return this; return this;
} }
LaunchActivityItemBuilder setTaskFragmentToken(IBinder taskFragmentToken) {
mTaskFragmentToken = taskFragmentToken;
return this;
}
LaunchActivityItem build() { LaunchActivityItem build() {
return LaunchActivityItem.obtain(mIntent, mIdent, mInfo, return LaunchActivityItem.obtain(mIntent, mIdent, mInfo,
mCurConfig, mOverrideConfig, mCompatInfo, mReferrer, mVoiceInteractor, mCurConfig, mOverrideConfig, mCompatInfo, mReferrer, mVoiceInteractor,
mProcState, mState, mPersistentState, mPendingResults, mPendingNewIntents, mProcState, mState, mPersistentState, mPendingResults, mPendingNewIntents,
mActivityOptions, mIsForward, mProfilerInfo, mAssistToken, mActivityOptions, mIsForward, mProfilerInfo, mAssistToken,
null /* activityClientController */, mFixedRotationAdjustments, null /* activityClientController */, mFixedRotationAdjustments,
mShareableActivityToken, mLaunchedFromBubble, mTaskFragmentToken); mShareableActivityToken, mLaunchedFromBubble);
} }
} }
} }

View File

@@ -209,7 +209,6 @@ public class TransactionParcelTests {
.setPendingNewIntents(referrerIntentList()).setIsForward(true) .setPendingNewIntents(referrerIntentList()).setIsForward(true)
.setAssistToken(new Binder()).setFixedRotationAdjustments(fixedRotationAdjustments) .setAssistToken(new Binder()).setFixedRotationAdjustments(fixedRotationAdjustments)
.setShareableActivityToken(new Binder()) .setShareableActivityToken(new Binder())
.setTaskFragmentToken(new Binder())
.build(); .build();
writeAndPrepareForReading(item); writeAndPrepareForReading(item);

View File

@@ -299,7 +299,7 @@ public class ActivityThreadClientTest {
null /* activityOptions */, true /* isForward */, null /* profilerInfo */, null /* activityOptions */, true /* isForward */, null /* profilerInfo */,
mThread /* client */, null /* asssitToken */, mThread /* client */, null /* asssitToken */,
null /* fixedRotationAdjustments */, null /* shareableActivityToken */, null /* fixedRotationAdjustments */, null /* shareableActivityToken */,
false /* launchedFromBubble */, null /* taskfragmentToken */); false /* launchedFromBubble */);
} }
@Override @Override

View File

@@ -172,7 +172,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
void handleActivityCreated(@NonNull Activity launchedActivity) { void handleActivityCreated(@NonNull Activity launchedActivity) {
final List<EmbeddingRule> splitRules = getSplitRules(); final List<EmbeddingRule> splitRules = getSplitRules();
final TaskFragmentContainer currentContainer = getContainerWithActivity( final TaskFragmentContainer currentContainer = getContainerWithActivity(
launchedActivity.getActivityToken(), launchedActivity); launchedActivity.getActivityToken());
// Check if the activity is configured to always be expanded. // Check if the activity is configured to always be expanded.
if (shouldExpand(launchedActivity, null, splitRules)) { if (shouldExpand(launchedActivity, null, splitRules)) {
@@ -262,29 +262,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
*/ */
@Nullable @Nullable
TaskFragmentContainer getContainerWithActivity(@NonNull IBinder activityToken) { TaskFragmentContainer getContainerWithActivity(@NonNull IBinder activityToken) {
return getContainerWithActivity(activityToken, null /* activityToAdd */);
}
/**
* This method can only be called from {@link #onActivityCreated(Activity)}, use
* {@link #getContainerWithActivity(IBinder) } otherwise.
*
* Returns a container that this activity is registered with. The activity could be created
* before the container appeared, adding the activity to the container if so.
*/
@Nullable
private TaskFragmentContainer getContainerWithActivity(@NonNull IBinder activityToken,
Activity activityToAdd) {
final IBinder taskFragmentToken = ActivityThread.currentActivityThread().getActivityClient(
activityToken).mInitialTaskFragmentToken;
for (TaskFragmentContainer container : mContainers) { for (TaskFragmentContainer container : mContainers) {
if (container.hasActivity(activityToken)) { if (container.hasActivity(activityToken)) {
return container; return container;
} else if (container.getTaskFragmentToken().equals(taskFragmentToken)) {
if (activityToAdd != null) {
container.addPendingAppearedActivity(activityToAdd);
}
return container;
} }
} }

View File

@@ -853,10 +853,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
proc.getThread(), r.appToken); proc.getThread(), r.appToken);
final boolean isTransitionForward = r.isTransitionForward(); final boolean isTransitionForward = r.isTransitionForward();
IBinder fragmentToken = null;
if (r.getTaskFragment().getTaskFragmentOrganizerPid() == r.getPid()) {
fragmentToken = r.getTaskFragment().getFragmentToken();
}
clientTransaction.addCallback(LaunchActivityItem.obtain(new Intent(r.intent), clientTransaction.addCallback(LaunchActivityItem.obtain(new Intent(r.intent),
System.identityHashCode(r), r.info, System.identityHashCode(r), r.info,
// TODO: Have this take the merged configuration instead of separate global // TODO: Have this take the merged configuration instead of separate global
@@ -868,7 +864,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
results, newIntents, r.takeOptions(), isTransitionForward, results, newIntents, r.takeOptions(), isTransitionForward,
proc.createProfilerInfoIfNeeded(), r.assistToken, activityClientController, proc.createProfilerInfoIfNeeded(), r.assistToken, activityClientController,
r.createFixedRotationAdjustmentsIfNeeded(), r.shareableActivityToken, r.createFixedRotationAdjustmentsIfNeeded(), r.shareableActivityToken,
r.getLaunchedFromBubble(), fragmentToken)); r.getLaunchedFromBubble()));
// Set desired final state. // Set desired final state.
final ActivityLifecycleItem lifecycleItem; final ActivityLifecycleItem lifecycleItem;

View File

@@ -2151,10 +2151,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
} }
} }
int getTaskFragmentOrganizerPid() {
return mTaskFragmentOrganizerPid;
}
/** /**
* Returns a {@link TaskFragmentInfo} with information from this TaskFragment. Should not be * Returns a {@link TaskFragmentInfo} with information from this TaskFragment. Should not be
* called from {@link Task}. * called from {@link Task}.