Merge "Add flag for not breaking word inside email/url" into main
diff --git a/core/java/android/app/servertransaction/ActivityTransactionItem.java b/core/java/android/app/servertransaction/ActivityTransactionItem.java
index 8ef86ee..506a158 100644
--- a/core/java/android/app/servertransaction/ActivityTransactionItem.java
+++ b/core/java/android/app/servertransaction/ActivityTransactionItem.java
@@ -49,30 +49,13 @@
public abstract class ActivityTransactionItem extends ClientTransactionItem {
/** Target client activity. */
- // TODO(b/311089192): Mark this with @NonNull and final.
- private IBinder mActivityToken;
+ @NonNull
+ private final IBinder mActivityToken;
public ActivityTransactionItem(@NonNull IBinder activityToken) {
mActivityToken = requireNonNull(activityToken);
}
- // TODO(b/311089192): Remove this method once no subclasses obtain from the object pool.
- @Deprecated
- ActivityTransactionItem() {
- }
-
- /**
- * Sets the activity token after the instance is obtained from the object pool.
- *
- * @deprecated This method is deprecated. The object pool is no longer used.
- * Instead, directly create a new object with the activity token.
- * TODO(b/311089192): Remove this method once no subclasses obtain from the object pool.
- */
- @Deprecated
- void setActivityToken(@NonNull IBinder activityToken) {
- mActivityToken = requireNonNull(activityToken);
- }
-
@Override
public final void execute(@NonNull ClientTransactionHandler client,
@NonNull PendingTransactionActions pendingActions) {
diff --git a/core/java/android/app/servertransaction/ConfigurationChangeItem.java b/core/java/android/app/servertransaction/ConfigurationChangeItem.java
index 22da706..123d792 100644
--- a/core/java/android/app/servertransaction/ConfigurationChangeItem.java
+++ b/core/java/android/app/servertransaction/ConfigurationChangeItem.java
@@ -16,6 +16,8 @@
package android.app.servertransaction;
+import static java.util.Objects.requireNonNull;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ClientTransactionHandler;
@@ -27,12 +29,20 @@
/**
* App configuration change message.
+ *
* @hide
*/
public class ConfigurationChangeItem extends ClientTransactionItem {
- private Configuration mConfiguration;
- private int mDeviceId;
+ @NonNull
+ private final Configuration mConfiguration;
+
+ private final int mDeviceId;
+
+ public ConfigurationChangeItem(@NonNull Configuration config, int deviceId) {
+ mConfiguration = new Configuration(config);
+ mDeviceId = deviceId;
+ }
@Override
public void preExecute(@NonNull ClientTransactionHandler client) {
@@ -46,55 +56,31 @@
client.handleConfigurationChanged(mConfiguration, mDeviceId);
}
- // ObjectPoolItem implementation
-
- private ConfigurationChangeItem() {}
-
- /** Obtain an instance initialized with provided params. */
- public static ConfigurationChangeItem obtain(@NonNull Configuration config, int deviceId) {
- ConfigurationChangeItem instance = ObjectPool.obtain(ConfigurationChangeItem.class);
- if (instance == null) {
- instance = new ConfigurationChangeItem();
- }
- instance.mConfiguration = new Configuration(config);
- instance.mDeviceId = deviceId;
-
- return instance;
- }
-
- @Override
- public void recycle() {
- mConfiguration = null;
- mDeviceId = 0;
- ObjectPool.recycle(this);
- }
-
-
// Parcelable implementation
- /** Write to Parcel. */
+ /** Writes to Parcel. */
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeTypedObject(mConfiguration, flags);
dest.writeInt(mDeviceId);
}
- /** Read from Parcel. */
+ /** Reads from Parcel. */
private ConfigurationChangeItem(Parcel in) {
- mConfiguration = in.readTypedObject(Configuration.CREATOR);
+ mConfiguration = requireNonNull(in.readTypedObject(Configuration.CREATOR));
mDeviceId = in.readInt();
}
public static final @android.annotation.NonNull Creator<ConfigurationChangeItem> CREATOR =
- new Creator<ConfigurationChangeItem>() {
- public ConfigurationChangeItem createFromParcel(Parcel in) {
- return new ConfigurationChangeItem(in);
- }
+ new Creator<>() {
+ public ConfigurationChangeItem createFromParcel(Parcel in) {
+ return new ConfigurationChangeItem(in);
+ }
- public ConfigurationChangeItem[] newArray(int size) {
- return new ConfigurationChangeItem[size];
- }
- };
+ public ConfigurationChangeItem[] newArray(int size) {
+ return new ConfigurationChangeItem[size];
+ }
+ };
@Override
public boolean equals(@Nullable Object o) {
diff --git a/core/java/android/app/servertransaction/NewIntentItem.java b/core/java/android/app/servertransaction/NewIntentItem.java
index acf2ea4..b5e9d66 100644
--- a/core/java/android/app/servertransaction/NewIntentItem.java
+++ b/core/java/android/app/servertransaction/NewIntentItem.java
@@ -38,13 +38,24 @@
/**
* New intent message.
+ *
* @hide
*/
public class NewIntentItem extends ActivityTransactionItem {
+ // TODO(b/170729553): Mark this with @NonNull and final once @UnsupportedAppUsage removed.
+ // We cannot do it now to avoid app compatibility regression.
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private List<ReferrerIntent> mIntents;
- private boolean mResume;
+
+ private final boolean mResume;
+
+ public NewIntentItem(@NonNull IBinder activityToken,
+ @NonNull List<ReferrerIntent> intents, boolean resume) {
+ super(activityToken);
+ mIntents = new ArrayList<>(intents);
+ mResume = resume;
+ }
@Override
public int getPostExecutionState() {
@@ -59,36 +70,9 @@
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
}
- // ObjectPoolItem implementation
-
- private NewIntentItem() {}
-
- /** Obtain an instance initialized with provided params. */
- @NonNull
- public static NewIntentItem obtain(@NonNull IBinder activityToken,
- @NonNull List<ReferrerIntent> intents, boolean resume) {
- NewIntentItem instance = ObjectPool.obtain(NewIntentItem.class);
- if (instance == null) {
- instance = new NewIntentItem();
- }
- instance.setActivityToken(activityToken);
- instance.mIntents = new ArrayList<>(intents);
- instance.mResume = resume;
-
- return instance;
- }
-
- @Override
- public void recycle() {
- super.recycle();
- mIntents = null;
- mResume = false;
- ObjectPool.recycle(this);
- }
-
// Parcelable implementation
- /** Write to Parcel. */
+ /** Writes to Parcel. */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
@@ -96,10 +80,11 @@
dest.writeTypedList(mIntents, flags);
}
- /** Read from Parcel. */
+ /** Reads from Parcel. */
private NewIntentItem(@NonNull Parcel in) {
super(in);
mResume = in.readBoolean();
+ // TODO(b/170729553): Wrap with requireNonNull once @UnsupportedAppUsage removed.
mIntents = in.createTypedArrayList(ReferrerIntent.CREATOR);
}
diff --git a/core/java/android/app/servertransaction/RefreshCallbackItem.java b/core/java/android/app/servertransaction/RefreshCallbackItem.java
index a3f82e9..57fd97a 100644
--- a/core/java/android/app/servertransaction/RefreshCallbackItem.java
+++ b/core/java/android/app/servertransaction/RefreshCallbackItem.java
@@ -44,7 +44,20 @@
// Whether refresh should happen using the "stopped -> resumed" cycle or
// "paused -> resumed" cycle.
@LifecycleState
- private int mPostExecutionState;
+ private final int mPostExecutionState;
+
+ /**
+ * Creates a new RefreshCallbackItem.
+ *
+ * @param activityToken the target client activity.
+ * @param postExecutionState indicating whether refresh should happen using the
+ * "stopped -> "resumed" cycle or "paused -> resumed" cycle.
+ */
+ public RefreshCallbackItem(
+ @NonNull IBinder activityToken, @LifecycleState int postExecutionState) {
+ super(activityToken);
+ mPostExecutionState = postExecutionState;
+ }
@Override
public void execute(@NonNull ClientTransactionHandler client,
@@ -67,47 +80,21 @@
return false;
}
- // ObjectPoolItem implementation
-
- @Override
- public void recycle() {
- super.recycle();
- ObjectPool.recycle(this);
- }
-
- /**
- * Obtain an instance initialized with provided params.
- * @param postExecutionState indicating whether refresh should happen using the
- * "stopped -> resumed" cycle or "paused -> resumed" cycle.
- */
- @NonNull
- public static RefreshCallbackItem obtain(@NonNull IBinder activityToken,
- @LifecycleState int postExecutionState) {
- if (postExecutionState != ON_STOP && postExecutionState != ON_PAUSE) {
- throw new IllegalArgumentException(
- "Only ON_STOP or ON_PAUSE are allowed as a post execution state for "
- + "RefreshCallbackItem but got " + postExecutionState);
- }
- RefreshCallbackItem instance =
- ObjectPool.obtain(RefreshCallbackItem.class);
- if (instance == null) {
- instance = new RefreshCallbackItem();
- }
- instance.setActivityToken(activityToken);
- instance.mPostExecutionState = postExecutionState;
- return instance;
- }
-
- private RefreshCallbackItem() {}
-
// Parcelable implementation
+ /** Writes to Parcel. */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mPostExecutionState);
}
+ /** Reads from Parcel. */
+ private RefreshCallbackItem(@NonNull Parcel in) {
+ super(in);
+ mPostExecutionState = in.readInt();
+ }
+
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
@@ -134,11 +121,6 @@
+ ",mPostExecutionState=" + mPostExecutionState + "}";
}
- private RefreshCallbackItem(@NonNull Parcel in) {
- super(in);
- mPostExecutionState = in.readInt();
- }
-
public static final @NonNull Creator<RefreshCallbackItem> CREATOR = new Creator<>() {
public RefreshCallbackItem createFromParcel(@NonNull Parcel in) {
diff --git a/core/java/android/app/servertransaction/TopResumedActivityChangeItem.java b/core/java/android/app/servertransaction/TopResumedActivityChangeItem.java
index 23d4505..b5f8345 100644
--- a/core/java/android/app/servertransaction/TopResumedActivityChangeItem.java
+++ b/core/java/android/app/servertransaction/TopResumedActivityChangeItem.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package android.app.servertransaction;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
@@ -28,11 +29,17 @@
/**
* Top resumed activity changed callback.
+ *
* @hide
*/
public class TopResumedActivityChangeItem extends ActivityTransactionItem {
- private boolean mOnTop;
+ private final boolean mOnTop;
+
+ public TopResumedActivityChangeItem(@NonNull IBinder activityToken, boolean onTop) {
+ super(activityToken);
+ mOnTop = onTop;
+ }
@Override
public void execute(@NonNull ClientTransactionHandler client, @NonNull ActivityClientRecord r,
@@ -58,42 +65,16 @@
ActivityClient.getInstance().activityTopResumedStateLost();
}
- // ObjectPoolItem implementation
-
- private TopResumedActivityChangeItem() {}
-
- /** Obtain an instance initialized with provided params. */
- @NonNull
- public static TopResumedActivityChangeItem obtain(@NonNull IBinder activityToken,
- boolean onTop) {
- TopResumedActivityChangeItem instance =
- ObjectPool.obtain(TopResumedActivityChangeItem.class);
- if (instance == null) {
- instance = new TopResumedActivityChangeItem();
- }
- instance.setActivityToken(activityToken);
- instance.mOnTop = onTop;
-
- return instance;
- }
-
- @Override
- public void recycle() {
- super.recycle();
- mOnTop = false;
- 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.writeBoolean(mOnTop);
}
- /** Read from Parcel. */
+ /** Reads from Parcel. */
private TopResumedActivityChangeItem(@NonNull Parcel in) {
super(in);
mOnTop = in.readBoolean();
@@ -131,7 +112,6 @@
@Override
public String toString() {
- return "TopResumedActivityChangeItem{" + super.toString()
- + ",onTop=" + mOnTop + "}";
+ return "TopResumedActivityChangeItem{" + super.toString() + ",onTop=" + mOnTop + "}";
}
}
diff --git a/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java b/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java
index f6a7291..b2e87bd 100644
--- a/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java
+++ b/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java
@@ -30,14 +30,22 @@
/**
* {@link android.window.WindowContext} configuration change message.
+ *
* @hide
*/
public class WindowContextInfoChangeItem extends ClientTransactionItem {
- @Nullable
- private IBinder mClientToken;
- @Nullable
- private WindowContextInfo mInfo;
+ @NonNull
+ private final IBinder mClientToken;
+
+ @NonNull
+ private final WindowContextInfo mInfo;
+
+ public WindowContextInfoChangeItem(
+ @NonNull IBinder clientToken, @NonNull Configuration config, int displayId) {
+ mClientToken = requireNonNull(clientToken);
+ mInfo = new WindowContextInfo(new Configuration(config), displayId);
+ }
@Override
public void execute(@NonNull ClientTransactionHandler client,
@@ -45,31 +53,6 @@
client.handleWindowContextInfoChanged(mClientToken, mInfo);
}
- // ObjectPoolItem implementation
-
- private WindowContextInfoChangeItem() {}
-
- /** Obtains an instance initialized with provided params. */
- public static WindowContextInfoChangeItem obtain(
- @NonNull IBinder clientToken, @NonNull Configuration config, int displayId) {
- WindowContextInfoChangeItem instance =
- ObjectPool.obtain(WindowContextInfoChangeItem.class);
- if (instance == null) {
- instance = new WindowContextInfoChangeItem();
- }
- instance.mClientToken = requireNonNull(clientToken);
- instance.mInfo = new WindowContextInfo(new Configuration(config), displayId);
-
- return instance;
- }
-
- @Override
- public void recycle() {
- mClientToken = null;
- mInfo = null;
- ObjectPool.recycle(this);
- }
-
// Parcelable implementation
/** Writes to Parcel. */
@@ -82,7 +65,7 @@
/** Reads from Parcel. */
private WindowContextInfoChangeItem(@NonNull Parcel in) {
mClientToken = in.readStrongBinder();
- mInfo = in.readTypedObject(WindowContextInfo.CREATOR);
+ mInfo = requireNonNull(in.readTypedObject(WindowContextInfo.CREATOR));
}
public static final @NonNull Creator<WindowContextInfoChangeItem> CREATOR =
diff --git a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
index 8a305f4..24f6cea 100644
--- a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
+++ b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
@@ -254,8 +254,8 @@
try {
// Send process level config change.
ClientTransaction transaction = newTransaction(activityThread);
- transaction.addTransactionItem(ConfigurationChangeItem.obtain(
- newConfig, DEVICE_ID_INVALID));
+ transaction.addTransactionItem(
+ new ConfigurationChangeItem(newConfig, DEVICE_ID_INVALID));
appThread.scheduleTransaction(transaction);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
@@ -474,15 +474,15 @@
activity.mTestLatch = new CountDownLatch(1);
ClientTransaction transaction = newTransaction(activityThread);
- transaction.addTransactionItem(ConfigurationChangeItem.obtain(
- processConfigLandscape, DEVICE_ID_INVALID));
+ transaction.addTransactionItem(
+ new ConfigurationChangeItem(processConfigLandscape, DEVICE_ID_INVALID));
appThread.scheduleTransaction(transaction);
transaction = newTransaction(activityThread);
transaction.addTransactionItem(new ActivityConfigurationChangeItem(
activity.getActivityToken(), activityConfigLandscape, new ActivityWindowInfo()));
- transaction.addTransactionItem(ConfigurationChangeItem.obtain(
- processConfigPortrait, DEVICE_ID_INVALID));
+ transaction.addTransactionItem(
+ new ConfigurationChangeItem(processConfigPortrait, DEVICE_ID_INVALID));
transaction.addTransactionItem(new ActivityConfigurationChangeItem(
activity.getActivityToken(), activityConfigPortrait, new ActivityWindowInfo()));
appThread.scheduleTransaction(transaction);
@@ -1030,8 +1030,7 @@
@NonNull
private static ClientTransaction newNewIntentTransaction(@NonNull Activity activity,
@NonNull List<ReferrerIntent> intents, boolean resume) {
- final NewIntentItem item = NewIntentItem.obtain(activity.getActivityToken(), intents,
- resume);
+ final NewIntentItem item = new NewIntentItem(activity.getActivityToken(), intents, resume);
final ClientTransaction transaction = newTransaction(activity);
transaction.addTransactionItem(item);
diff --git a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionItemTest.java b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionItemTest.java
index 911b759..96d4cf4 100644
--- a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionItemTest.java
+++ b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionItemTest.java
@@ -174,8 +174,8 @@
@Test
public void testWindowContextInfoChangeItem_execute() {
- final WindowContextInfoChangeItem item = WindowContextInfoChangeItem
- .obtain(mWindowClientToken, mConfiguration, DEFAULT_DISPLAY);
+ final WindowContextInfoChangeItem item = new WindowContextInfoChangeItem(mWindowClientToken,
+ mConfiguration, DEFAULT_DISPLAY);
item.execute(mHandler, mPendingActions);
diff --git a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java b/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java
deleted file mode 100644
index d5a7d51..0000000
--- a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.app.servertransaction;
-
-import static android.app.servertransaction.TestUtils.config;
-import static android.app.servertransaction.TestUtils.referrerIntentList;
-
-import static org.junit.Assert.assertNotSame;
-
-import android.annotation.NonNull;
-import android.os.IBinder;
-import android.platform.test.annotations.Presubmit;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-import java.util.function.Supplier;
-
-/**
- * Tests for {@link ObjectPool}.
- *
- * <p>Build/Install/Run:
- * atest FrameworksCoreTests:ObjectPoolTests
- *
- * <p>This test class is a part of Window Manager Service tests and specified in
- * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}.
- */
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-@Presubmit
-public class ObjectPoolTests {
-
- @Rule
- public final MockitoRule mocks = MockitoJUnit.rule();
-
- @Mock
- private IBinder mActivityToken;
-
- // 1. Check if two obtained objects from pool are not the same.
- // 2. Check if the state of the object is cleared after recycling.
- // 3. Check if the same object is obtained from pool after recycling.
-
- @Test
- public void testRecycleConfigurationChangeItem() {
- testRecycle(() -> ConfigurationChangeItem.obtain(config(), 1));
- }
-
- @Test
- public void testRecycleNewIntentItem() {
- testRecycle(() -> NewIntentItem.obtain(mActivityToken, referrerIntentList(), false));
- }
-
- private void testRecycle(@NonNull Supplier<? extends ObjectPoolItem> obtain) {
- // Reuse the same object after recycle.
- final ObjectPoolItem item = obtain.get();
- item.recycle();
- final ObjectPoolItem item2 = obtain.get();
-
- assertNotSame(item, item2); // Different instance.
-
- // Create new object when the pool is empty.
- final ObjectPoolItem item3 = obtain.get();
-
- assertNotSame(item, item3);
- }
-}
diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
index 644e9f4..59d8c8d 100644
--- a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
+++ b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
@@ -74,11 +74,13 @@
@Test
public void testConfigurationChange() {
// Write to parcel
- ConfigurationChangeItem item = ConfigurationChangeItem.obtain(config(), 1 /* deviceId */);
+ final ConfigurationChangeItem item =
+ new ConfigurationChangeItem(config(), 1 /* deviceId */);
writeAndPrepareForReading(item);
// Read from parcel and assert
- ConfigurationChangeItem result = ConfigurationChangeItem.CREATOR.createFromParcel(mParcel);
+ final ConfigurationChangeItem result =
+ ConfigurationChangeItem.CREATOR.createFromParcel(mParcel);
assertEquals(item.hashCode(), result.hashCode());
assertEquals(item, result);
@@ -122,11 +124,12 @@
@Test
public void testNewIntent() {
// Write to parcel
- NewIntentItem item = NewIntentItem.obtain(mActivityToken, referrerIntentList(), false);
+ final NewIntentItem item =
+ new NewIntentItem(mActivityToken, referrerIntentList(), false /* resume */);
writeAndPrepareForReading(item);
// Read from parcel and assert
- NewIntentItem result = NewIntentItem.CREATOR.createFromParcel(mParcel);
+ final NewIntentItem result = NewIntentItem.CREATOR.createFromParcel(mParcel);
assertEquals(item.hashCode(), result.hashCode());
assertEquals(item, result);
@@ -290,8 +293,8 @@
@Test
public void testClientTransaction() {
// Write to parcel
- final NewIntentItem callback1 = NewIntentItem.obtain(
- mActivityToken, new ArrayList<>(), true);
+ final NewIntentItem callback1 =
+ new NewIntentItem(mActivityToken, new ArrayList<>(), true /* resume */);
final ActivityConfigurationChangeItem callback2 = new ActivityConfigurationChangeItem(
mActivityToken, config(), new ActivityWindowInfo());
@@ -305,7 +308,7 @@
writeAndPrepareForReading(transaction);
// Read from parcel and assert
- ClientTransaction result = ClientTransaction.CREATOR.createFromParcel(mParcel);
+ final ClientTransaction result = ClientTransaction.CREATOR.createFromParcel(mParcel);
assertEquals(transaction.hashCode(), result.hashCode());
assertEquals(transaction, result);
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 5764be9..4da7e53 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -1508,8 +1508,9 @@
ProtoLog.v(WM_DEBUG_STATES, "Sending position change to %s, onTop: %b",
this, onTop);
- mAtmService.getLifecycleManager().scheduleTransactionItem(app.getThread(),
- TopResumedActivityChangeItem.obtain(token, onTop));
+ final TopResumedActivityChangeItem item =
+ new TopResumedActivityChangeItem(token, onTop);
+ mAtmService.getLifecycleManager().scheduleTransactionItem(app.getThread(), item);
} catch (RemoteException e) {
// If process died, whatever.
Slog.w(TAG, "Failed to send top-resumed=" + onTop + " to " + this, e);
@@ -5113,8 +5114,9 @@
// Making sure the client state is RESUMED after transaction completed and doing
// so only if activity is currently RESUMED. Otherwise, client may have extra
// life-cycle calls to RESUMED (and PAUSED later).
- mAtmService.getLifecycleManager().scheduleTransactionItem(app.getThread(),
- NewIntentItem.obtain(token, ar, mState == RESUMED));
+ final NewIntentItem item =
+ new NewIntentItem(token, ar, mState == RESUMED /* resume */);
+ mAtmService.getLifecycleManager().scheduleTransactionItem(app.getThread(), item);
unsent = false;
} catch (RemoteException e) {
Slog.w(TAG, "Exception thrown sending new intent to " + this, e);
diff --git a/services/core/java/com/android/server/wm/ActivityRefresher.java b/services/core/java/com/android/server/wm/ActivityRefresher.java
index c02501f..dcc325e 100644
--- a/services/core/java/com/android/server/wm/ActivityRefresher.java
+++ b/services/core/java/com/android/server/wm/ActivityRefresher.java
@@ -84,8 +84,8 @@
ProtoLog.v(WM_DEBUG_STATES,
"Refreshing activity for freeform camera compatibility treatment, "
+ "activityRecord=%s", activity);
- final RefreshCallbackItem refreshCallbackItem = RefreshCallbackItem.obtain(
- activity.token, cycleThroughStop ? ON_STOP : ON_PAUSE);
+ final RefreshCallbackItem refreshCallbackItem =
+ new RefreshCallbackItem(activity.token, cycleThroughStop ? ON_STOP : ON_PAUSE);
final ResumeActivityItem resumeActivityItem = new ResumeActivityItem(
activity.token, /* isForward */ false, /* shouldSendCompatFakeFocus */ false);
try {
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 61f5f52..750394d 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -1616,10 +1616,9 @@
}
if (next.newIntents != null) {
- final NewIntentItem newIntentItem = NewIntentItem.obtain(
- next.token, next.newIntents, true /* resume */);
- mAtmService.getLifecycleManager().scheduleTransactionItem(
- appThread, newIntentItem);
+ final NewIntentItem item =
+ new NewIntentItem(next.token, next.newIntents, true /* resume */);
+ mAtmService.getLifecycleManager().scheduleTransactionItem(appThread, item);
}
// Well the app will no longer be stopped.
diff --git a/services/core/java/com/android/server/wm/WindowContextListenerController.java b/services/core/java/com/android/server/wm/WindowContextListenerController.java
index cd785e5..e98b1a2 100644
--- a/services/core/java/com/android/server/wm/WindowContextListenerController.java
+++ b/services/core/java/com/android/server/wm/WindowContextListenerController.java
@@ -330,8 +330,8 @@
mLastReportedConfig.setTo(config);
mLastReportedDisplay = displayId;
- mWpc.scheduleClientTransactionItem(WindowContextInfoChangeItem.obtain(
- mClientToken, config, displayId));
+ mWpc.scheduleClientTransactionItem(
+ new WindowContextInfoChangeItem(mClientToken, config, displayId));
mHasPendingConfiguration = false;
}
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index 984caf1..2bae0a8 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -437,7 +437,7 @@
final ConfigurationChangeItem configurationChangeItem;
synchronized (mLastReportedConfiguration) {
onConfigurationChangePreScheduled(mLastReportedConfiguration);
- configurationChangeItem = ConfigurationChangeItem.obtain(
+ configurationChangeItem = new ConfigurationChangeItem(
mLastReportedConfiguration, mLastTopActivityDeviceId);
}
// Schedule immediately to make sure the app component (e.g. receiver, service) can get
@@ -1721,8 +1721,8 @@
}
onConfigurationChangePreScheduled(config);
- scheduleClientTransactionItem(thread, ConfigurationChangeItem.obtain(
- config, mLastTopActivityDeviceId));
+ scheduleClientTransactionItem(
+ thread, new ConfigurationChangeItem(config, mLastTopActivityDeviceId));
}
private void onConfigurationChangePreScheduled(@NonNull Configuration config) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRefresherTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRefresherTests.java
index 68ccb31..14fbbe4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRefresherTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRefresherTests.java
@@ -191,8 +191,8 @@
verify(mActivity.mAppCompatController.getAppCompatCameraOverrides(),
times(refreshRequested ? 1 : 0)).setIsRefreshRequested(true);
- final RefreshCallbackItem refreshCallbackItem = RefreshCallbackItem.obtain(mActivity.token,
- cycleThroughStop ? ON_STOP : ON_PAUSE);
+ final RefreshCallbackItem refreshCallbackItem =
+ new RefreshCallbackItem(mActivity.token, cycleThroughStop ? ON_STOP : ON_PAUSE);
final ResumeActivityItem resumeActivityItem = new ResumeActivityItem(mActivity.token,
/* isForward */ false, /* shouldSendCompatFakeFocus */ false);
diff --git a/services/tests/wmtests/src/com/android/server/wm/CameraCompatFreeformPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/CameraCompatFreeformPolicyTests.java
index c43f414..f2592d2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/CameraCompatFreeformPolicyTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/CameraCompatFreeformPolicyTests.java
@@ -307,8 +307,8 @@
verify(mActivity.mAppCompatController.getAppCompatCameraOverrides(),
times(refreshRequested ? 1 : 0)).setIsRefreshRequested(true);
- final RefreshCallbackItem refreshCallbackItem = RefreshCallbackItem.obtain(mActivity.token,
- cycleThroughStop ? ON_STOP : ON_PAUSE);
+ final RefreshCallbackItem refreshCallbackItem =
+ new RefreshCallbackItem(mActivity.token, cycleThroughStop ? ON_STOP : ON_PAUSE);
final ResumeActivityItem resumeActivityItem = new ResumeActivityItem(mActivity.token,
/* isForward */ false, /* shouldSendCompatFakeFocus */ false);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
index 12bc3ed..2dea6ba 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
@@ -613,8 +613,8 @@
verify(mActivity.mAppCompatController.getAppCompatCameraOverrides(),
times(refreshRequested ? 1 : 0)).setIsRefreshRequested(true);
- final RefreshCallbackItem refreshCallbackItem = RefreshCallbackItem.obtain(mActivity.token,
- cycleThroughStop ? ON_STOP : ON_PAUSE);
+ final RefreshCallbackItem refreshCallbackItem =
+ new RefreshCallbackItem(mActivity.token, cycleThroughStop ? ON_STOP : ON_PAUSE);
final ResumeActivityItem resumeActivityItem = new ResumeActivityItem(mActivity.token,
/* isForward */ false, /* shouldSendCompatFakeFocus */ false);