Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a850d8e7 authored by Eric Lin's avatar Eric Lin
Browse files

Remove WindowContextWindowRmItem pooling (19/n).

Remove the use of ObjectPool in the creation and management of
WindowContextWindowRemovalItem object. Instead of being obtained from
the pool, these objects are now directly instantiated, simplifying their
handling and aligning with the broader removal of the object pooling
mechanism.

Bug: 311089192
Test: atest FrameworksCoreTests:ClientTransactionItemTest
Test: atest FrameworksCoreTests:TransactionExecutorTests
Flag: EXEMPT removing com.android.window.flags.disable_object_pool
Change-Id: Ib12c0bdb66d003dd7faa8dcd2611eefdd2fbd986
parent fc0fb78f
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -22,31 +22,34 @@ import android.app.ClientTransactionHandler;
/**
 * Base interface for individual requests from server to client.
 * Each of them can be prepared before scheduling and, eventually, executed.
 *
 * @hide
 */
public interface BaseClientRequest extends ObjectPoolItem {
public interface BaseClientRequest {

    /**
     * Prepares the client request before scheduling.
     * An example of this might be informing about pending updates for some values.
     *
     * @param client Target client handler.
     * @param client target client handler.
     */
    default void preExecute(@NonNull ClientTransactionHandler client) {
    }

    /**
     * Executes the request.
     * @param client Target client handler.
     * @param pendingActions Container that may have data pending to be used.
     *
     * @param client         target client handler.
     * @param pendingActions container that may have data pending to be used.
     */
    void execute(@NonNull ClientTransactionHandler client,
            @NonNull PendingTransactionActions pendingActions);

    /**
     * Performs all actions that need to happen after execution, e.g. report the result to server.
     * @param client Target client handler.
     * @param pendingActions Container that may have data pending to be used.
     *
     * @param client         target client handler.
     * @param pendingActions container that may have data pending to be used.
     */
    default void postExecute(@NonNull ClientTransactionHandler client,
            @NonNull PendingTransactionActions pendingActions) {
+0 −11
Original line number Diff line number Diff line
@@ -75,17 +75,6 @@ public abstract class ClientTransactionItem implements BaseClientRequest, Parcel
        pw.append(prefix).println(this);
    }

    /**
     * Provides a default empty implementation for progressive cleanup.
     *
     * @deprecated This method is deprecated. The object pool is no longer used, so there's
     * no need to recycle objects.
     * TODO(b/311089192): Remove once ObjectPoolItem inheritance is removed.
     */
    @Override
    @Deprecated
    public void recycle() {}

    // Parcelable

    @Override
+0 −54
Original line number Diff line number Diff line
/*
 * 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;

/**
 * An object pool that can provide reused objects if available.
 *
 * @hide
 * @deprecated This class is deprecated. Directly create new instances of objects instead of
 * obtaining them from this pool.
 * TODO(b/311089192): Clean up usages of the pool.
 */
@Deprecated
class ObjectPool {

    /**
     * Obtain an instance of a specific class from the pool
     *
     * @param ignoredItemClass The class of the object we're looking for.
     * @return An instance or null if there is none.
     * @deprecated This method is deprecated. Directly create new instances of objects instead of
     * obtaining them from this pool.
     */
    @Deprecated
    public static <T extends ObjectPoolItem> T obtain(Class<T> ignoredItemClass) {
        return null;
    }

    /**
     * Recycle the object to the pool. The object should be properly cleared before this.
     *
     * @param ignoredItem The object to recycle.
     * @see ObjectPoolItem#recycle()
     * @deprecated This method is deprecated. The object pool is no longer used, so there's
     * no need to recycle objects.
     */
    @Deprecated
    public static <T extends ObjectPoolItem> void recycle(T ignoredItem) {
    }
}
+0 −37
Original line number Diff line number Diff line
/*
 * 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;

/**
 * Base interface for all lifecycle items that can be put in object pool.
 *
 * @hide
 * @deprecated This interface is deprecated. Objects should no longer be pooled.
 * TODO(b/311089192): Clean up usages of this interface.
 */
@Deprecated
public interface ObjectPoolItem {
    /**
     * Clear the contents of the item and putting it to a pool. The implementation should call
     * {@link ObjectPool#recycle(ObjectPoolItem)} passing itself.
     *
     * @deprecated This method is deprecated. The object pool is no longer used, so there's
     * no need to recycle objects.
     */
    @Deprecated
    void recycle();
}
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import java.util.List;

/**
 * Class that manages transaction execution in the correct order.
 *
 * @hide
 */
public class TransactionExecutor {
Loading