summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityThread.java2
-rw-r--r--core/java/android/app/servertransaction/ActivityRelaunchItem.java109
-rw-r--r--core/tests/coretests/src/android/app/activity/ActivityThreadTest.java4
-rw-r--r--core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java8
-rw-r--r--core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java6
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java2
6 files changed, 55 insertions, 76 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 75f2c4bfbd93..5c2cc73bf0fa 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -6239,7 +6239,7 @@ public final class ActivityThread extends ClientTransactionHandler
r.createdConfig != null
? r.createdConfig : mConfigurationController.getConfiguration(),
r.overrideConfig);
- final ActivityRelaunchItem activityRelaunchItem = ActivityRelaunchItem.obtain(
+ final ActivityRelaunchItem activityRelaunchItem = new ActivityRelaunchItem(
r.token, null /* pendingResults */, null /* pendingIntents */,
0 /* configChanges */, mergedConfiguration, r.mPreserveWindow,
r.getActivityWindowInfo());
diff --git a/core/java/android/app/servertransaction/ActivityRelaunchItem.java b/core/java/android/app/servertransaction/ActivityRelaunchItem.java
index 45bf235de2cd..cecf7013c79c 100644
--- a/core/java/android/app/servertransaction/ActivityRelaunchItem.java
+++ b/core/java/android/app/servertransaction/ActivityRelaunchItem.java
@@ -18,6 +18,8 @@ package android.app.servertransaction;
import static android.app.ActivityThread.DEBUG_ORDER;
+import static java.util.Objects.requireNonNull;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityThread.ActivityClientRecord;
@@ -39,25 +41,50 @@ import java.util.Objects;
/**
* Activity relaunch callback.
+ *
* @hide
*/
public class ActivityRelaunchItem extends ActivityTransactionItem {
private static final String TAG = "ActivityRelaunchItem";
- private List<ResultInfo> mPendingResults;
- private List<ReferrerIntent> mPendingNewIntents;
- private int mConfigChanges;
- private MergedConfiguration mConfig;
- private boolean mPreserveWindow;
- private ActivityWindowInfo mActivityWindowInfo;
+ @Nullable
+ private final List<ResultInfo> mPendingResults;
+
+ @Nullable
+ private final List<ReferrerIntent> mPendingNewIntents;
+
+ @NonNull
+ private final MergedConfiguration mConfig;
+
+ @NonNull
+ private final ActivityWindowInfo mActivityWindowInfo;
+
+ private final int mConfigChanges;
+ private final boolean mPreserveWindow;
/**
* A record that was properly configured for relaunch. Execution will be cancelled if not
* initialized after {@link #preExecute(ClientTransactionHandler)}.
*/
+ @Nullable
private ActivityClientRecord mActivityClientRecord;
+ public ActivityRelaunchItem(@NonNull IBinder activityToken,
+ @Nullable List<ResultInfo> pendingResults,
+ @Nullable List<ReferrerIntent> pendingNewIntents, int configChanges,
+ @NonNull MergedConfiguration config, boolean preserveWindow,
+ @NonNull ActivityWindowInfo activityWindowInfo) {
+ super(activityToken);
+ mPendingResults = pendingResults != null ? new ArrayList<>(pendingResults) : null;
+ mPendingNewIntents =
+ pendingNewIntents != null ? new ArrayList<>(pendingNewIntents) : null;
+ mConfig = new MergedConfiguration(config);
+ mActivityWindowInfo = new ActivityWindowInfo(activityWindowInfo);
+ mConfigChanges = configChanges;
+ mPreserveWindow = preserveWindow;
+ }
+
@Override
public void preExecute(@NonNull ClientTransactionHandler client) {
// The local config is already scaled so only apply if this item is from server side.
@@ -87,70 +114,29 @@ public class ActivityRelaunchItem extends ActivityTransactionItem {
client.reportRelaunch(r);
}
- // ObjectPoolItem implementation
-
- private ActivityRelaunchItem() {}
-
- /** Obtain an instance initialized with provided params. */
- @NonNull
- public static ActivityRelaunchItem obtain(@NonNull IBinder activityToken,
- @Nullable List<ResultInfo> pendingResults,
- @Nullable List<ReferrerIntent> pendingNewIntents, int configChanges,
- @NonNull MergedConfiguration config, boolean preserveWindow,
- @NonNull ActivityWindowInfo activityWindowInfo) {
- ActivityRelaunchItem instance = ObjectPool.obtain(ActivityRelaunchItem.class);
- if (instance == null) {
- instance = new ActivityRelaunchItem();
- }
- instance.setActivityToken(activityToken);
- instance.mPendingResults = pendingResults != null ? new ArrayList<>(pendingResults) : null;
- instance.mPendingNewIntents =
- pendingNewIntents != null ? new ArrayList<>(pendingNewIntents) : null;
- instance.mConfigChanges = configChanges;
- instance.mConfig = new MergedConfiguration(config);
- instance.mPreserveWindow = preserveWindow;
- instance.mActivityWindowInfo = new ActivityWindowInfo(activityWindowInfo);
-
- return instance;
- }
-
- @Override
- public void recycle() {
- super.recycle();
- mPendingResults = null;
- mPendingNewIntents = null;
- mConfigChanges = 0;
- mConfig = null;
- mPreserveWindow = false;
- mActivityClientRecord = null;
- mActivityWindowInfo = null;
- ObjectPool.recycle(this);
- }
-
-
// Parcelable implementation
- /** Write to Parcel. */
+ /** Writes to Parcel. */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeTypedList(mPendingResults, flags);
dest.writeTypedList(mPendingNewIntents, flags);
- dest.writeInt(mConfigChanges);
dest.writeTypedObject(mConfig, flags);
- dest.writeBoolean(mPreserveWindow);
dest.writeTypedObject(mActivityWindowInfo, flags);
+ dest.writeInt(mConfigChanges);
+ dest.writeBoolean(mPreserveWindow);
}
- /** Read from Parcel. */
+ /** Reads from Parcel. */
private ActivityRelaunchItem(@NonNull Parcel in) {
super(in);
mPendingResults = in.createTypedArrayList(ResultInfo.CREATOR);
mPendingNewIntents = in.createTypedArrayList(ReferrerIntent.CREATOR);
+ mConfig = requireNonNull(in.readTypedObject(MergedConfiguration.CREATOR));
+ mActivityWindowInfo = requireNonNull(in.readTypedObject(ActivityWindowInfo.CREATOR));
mConfigChanges = in.readInt();
- mConfig = in.readTypedObject(MergedConfiguration.CREATOR);
mPreserveWindow = in.readBoolean();
- mActivityWindowInfo = in.readTypedObject(ActivityWindowInfo.CREATOR);
}
public static final @NonNull Creator<ActivityRelaunchItem> CREATOR =
@@ -175,9 +161,10 @@ public class ActivityRelaunchItem extends ActivityTransactionItem {
final ActivityRelaunchItem other = (ActivityRelaunchItem) o;
return Objects.equals(mPendingResults, other.mPendingResults)
&& Objects.equals(mPendingNewIntents, other.mPendingNewIntents)
- && mConfigChanges == other.mConfigChanges && Objects.equals(mConfig, other.mConfig)
- && mPreserveWindow == other.mPreserveWindow
- && Objects.equals(mActivityWindowInfo, other.mActivityWindowInfo);
+ && Objects.equals(mConfig, other.mConfig)
+ && Objects.equals(mActivityWindowInfo, other.mActivityWindowInfo)
+ && mConfigChanges == other.mConfigChanges
+ && mPreserveWindow == other.mPreserveWindow;
}
@Override
@@ -186,10 +173,10 @@ public class ActivityRelaunchItem extends ActivityTransactionItem {
result = 31 * result + super.hashCode();
result = 31 * result + Objects.hashCode(mPendingResults);
result = 31 * result + Objects.hashCode(mPendingNewIntents);
- result = 31 * result + mConfigChanges;
result = 31 * result + Objects.hashCode(mConfig);
- result = 31 * result + (mPreserveWindow ? 1 : 0);
result = 31 * result + Objects.hashCode(mActivityWindowInfo);
+ result = 31 * result + mConfigChanges;
+ result = 31 * result + (mPreserveWindow ? 1 : 0);
return result;
}
@@ -198,9 +185,9 @@ public class ActivityRelaunchItem extends ActivityTransactionItem {
return "ActivityRelaunchItem{" + super.toString()
+ ",pendingResults=" + mPendingResults
+ ",pendingNewIntents=" + mPendingNewIntents
- + ",configChanges=" + mConfigChanges
+ ",config=" + mConfig
- + ",preserveWindow=" + mPreserveWindow
- + ",activityWindowInfo=" + mActivityWindowInfo + "}";
+ + ",activityWindowInfo=" + mActivityWindowInfo
+ + ",configChanges=" + mConfigChanges
+ + ",preserveWindow=" + mPreserveWindow + "}";
}
}
diff --git a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
index c51c3a50db9f..8a305f4e9554 100644
--- a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
+++ b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
@@ -847,7 +847,7 @@ public class ActivityThreadTest {
final ActivityWindowInfo newInfo = new ActivityWindowInfo();
newInfo.set(true /* isEmbedded */, new Rect(0, 0, 1000, 2000),
new Rect(0, 0, 1000, 1000));
- final ActivityRelaunchItem relaunchItem = ActivityRelaunchItem.obtain(
+ final ActivityRelaunchItem relaunchItem = new ActivityRelaunchItem(
activity.getActivityToken(), null, null, 0,
new MergedConfiguration(currentConfig, currentConfig),
false /* preserveWindow */, newInfo);
@@ -978,7 +978,7 @@ public class ActivityThreadTest {
} else {
activityWindowInfo = record.getActivityWindowInfo();
}
- final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(
+ final ClientTransactionItem callbackItem = new ActivityRelaunchItem(
activity.getActivityToken(), null, null, 0,
new MergedConfiguration(currentConfig, currentConfig),
false /* preserveWindow */, activityWindowInfo);
diff --git a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java b/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java
index d389b78da263..a7b0a6c42c54 100644
--- a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java
+++ b/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java
@@ -17,7 +17,6 @@
package android.app.servertransaction;
import static android.app.servertransaction.TestUtils.config;
-import static android.app.servertransaction.TestUtils.mergedConfig;
import static android.app.servertransaction.TestUtils.referrerIntentList;
import static android.app.servertransaction.TestUtils.resultInfoList;
@@ -131,13 +130,6 @@ public class ObjectPoolTests {
}
@Test
- public void testRecycleActivityRelaunchItem() {
- testRecycle(() -> ActivityRelaunchItem.obtain(mActivityToken,
- resultInfoList(), referrerIntentList(), 42, mergedConfig(), true,
- new ActivityWindowInfo()));
- }
-
- @Test
public void testRecycleMoveToDisplayItem() {
testRecycle(() -> MoveToDisplayItem.obtain(mActivityToken, 4, config(),
new ActivityWindowInfo()));
diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
index 1e434bdb6d04..c4abdaa184aa 100644
--- a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
+++ b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
@@ -216,17 +216,17 @@ public class TransactionParcelTests {
@Test
public void testRelaunch() {
// Write to parcel
- Configuration overrideConfig = new Configuration();
+ final Configuration overrideConfig = new Configuration();
overrideConfig.assetsSeq = 5;
final ActivityWindowInfo activityWindowInfo = new ActivityWindowInfo();
activityWindowInfo.set(true /* isEmbedded */, new Rect(0, 0, 500, 1000),
new Rect(0, 0, 500, 500));
- ActivityRelaunchItem item = ActivityRelaunchItem.obtain(mActivityToken, resultInfoList(),
+ final ActivityRelaunchItem item = new ActivityRelaunchItem(mActivityToken, resultInfoList(),
referrerIntentList(), 35, mergedConfig(), true, activityWindowInfo);
writeAndPrepareForReading(item);
// Read from parcel and assert
- ActivityRelaunchItem result = ActivityRelaunchItem.CREATOR.createFromParcel(mParcel);
+ final ActivityRelaunchItem result = ActivityRelaunchItem.CREATOR.createFromParcel(mParcel);
assertEquals(item.hashCode(), result.hashCode());
assertEquals(item, result);
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 072b1c7d14be..2abc37e5135e 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -9991,7 +9991,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
try {
ProtoLog.i(WM_DEBUG_STATES, "Moving to %s Relaunching %s callers=%s" ,
(andResume ? "RESUMED" : "PAUSED"), this, Debug.getCallers(6));
- final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(token,
+ final ClientTransactionItem callbackItem = new ActivityRelaunchItem(token,
pendingResults, pendingNewIntents, configChangeFlags,
new MergedConfiguration(getProcessGlobalConfiguration(),
getMergedOverrideConfiguration()),