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

Commit fa05d720 authored by Soonil Nagarkar's avatar Soonil Nagarkar Committed by Android (Google) Code Review
Browse files

Merge "Adopt new ListenerTransport framework"

parents fe77e7b0 7f78f206
Loading
Loading
Loading
Loading
+13 −26
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.internal.util.Preconditions;

import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.function.Consumer;

/**
@@ -58,36 +57,24 @@ public class ListenerTransport<TListener> {
    }

    /**
     * Executes the given operation for the listener. {@link #onOperationFinished(Consumer)} will
     * always be invoked at some time after this method, regardless of if the listener invocation
     * happens or if the operation fails in some way.
     * Executes the given operation for the listener.
     */
    public final void execute(@NonNull Consumer<TListener> operation) {
        Objects.requireNonNull(operation);
        try {

        if (mListener == null) {
            return;
        }

        mExecutor.execute(() -> {
                try {
            TListener listener = mListener;
            if (listener == null) {
                return;
            }

            operation.accept(listener);
                } finally {
                    onOperationFinished(operation);
                }
        });
        } catch (RejectedExecutionException e) {
            onOperationFinished(operation);
    }
    }

    /**
     * Invoked when an operation is finished. This method will always be called once for every call
     * to {@link #execute(Consumer)}, regardless of whether the operation encountered any
     * error or failed to execute in any way. May run on any thread.
     */
    protected void onOperationFinished(@NonNull Consumer<TListener> operation) {}

    @Override
    public final boolean equals(Object obj) {
+3 −3
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public abstract class ListenerTransportManager<TTransport extends ListenerTransp
     * replace the old transport with the new transport server side. If no transport exists with
     * that key, it will be added server side via {@link #registerWithServer(ListenerTransport)}.
     */
    public void registerListener(@NonNull Object key, @NonNull TTransport transport) {
    protected void registerListener(@NonNull Object key, @NonNull TTransport transport) {
        Objects.requireNonNull(key);
        Objects.requireNonNull(transport);

@@ -104,7 +104,7 @@ public abstract class ListenerTransportManager<TTransport extends ListenerTransp
     * Removes the transport with the given key, and makes a call to remove the transport server
     * side via {@link #unregisterWithServer(ListenerTransport)}.
     */
    public void unregisterListener(@NonNull Object key) {
    protected void unregisterListener(@NonNull Object key) {
        Objects.requireNonNull(key);

        synchronized (mTransports) {
@@ -128,7 +128,7 @@ public abstract class ListenerTransportManager<TTransport extends ListenerTransp
     * intended use is for when the transport is already removed server side and only client side
     * cleanup is necessary.
     */
    public void removeTransport(@NonNull Object key, @NonNull ListenerTransport<?> transport) {
    protected void removeTransport(@NonNull Object key, @NonNull ListenerTransport<?> transport) {
        Objects.requireNonNull(key);
        Objects.requireNonNull(transport);

+2 −2
Original line number Diff line number Diff line
@@ -72,8 +72,8 @@ public abstract class ListenerTransportMultiplexer<TRequest, TListener> {

    /**
     * Invoked when the server already has a request registered, and it is being replaced with a new
     * request. The default implementation unregisters first, then registers the new request, but
     * this may be overridden by subclasses in order to reregister more efficiently.
     * request. The default implementation simply registers the new request, trusting the server to
     * overwrite the old request.
     */
    protected void reregisterWithServer(TRequest oldMergedRequest, TRequest mergedRequest)
            throws RemoteException {
+5 −3
Original line number Diff line number Diff line
@@ -50,9 +50,11 @@ interface ILocationManager
            in ICancellationSignal cancellationSignal, in ILocationListener listener,
            String packageName, String attributionTag, String listenerId);

    void requestLocationUpdates(in LocationRequest request, in ILocationListener listener,
            in PendingIntent intent, String packageName, String attributionTag, String listenerId);
    void removeUpdates(in ILocationListener listener, in PendingIntent intent);
    void registerLocationListener(in LocationRequest request, in ILocationListener listener, String packageName, String attributionTag, String listenerId);
    void unregisterLocationListener(in ILocationListener listener);

    void registerLocationPendingIntent(in LocationRequest request, in PendingIntent intent, String packageName, String attributionTag);
    void unregisterLocationPendingIntent(in PendingIntent intent);

    void requestGeofence(in Geofence geofence, in PendingIntent intent, String packageName, String attributionTag);
    void removeGeofence(in PendingIntent intent);
+120 −270

File changed.

Preview size limit exceeded, changes collapsed.

Loading