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

Commit 64a7ccc1 authored by Chalard Jean's avatar Chalard Jean Committed by android-build-merger
Browse files

Merge changes Id598ae1d,I475bd011

am: 1ad99fb0

Change-Id: Ic02f8d900b6b430dc1a8bbfdc03297ad52157390
parents ba81211c 1ad99fb0
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ import android.net.IIpMemoryStore;
import android.net.ipmemorystore.Blob;
import android.net.ipmemorystore.IOnBlobRetrievedListener;
import android.net.ipmemorystore.IOnL2KeyResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrieved;
import android.net.ipmemorystore.IOnSameNetworkResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrievedListener;
import android.net.ipmemorystore.IOnSameL3NetworkResponseListener;
import android.net.ipmemorystore.IOnStatusListener;
import android.net.ipmemorystore.NetworkAttributes;
import android.net.ipmemorystore.NetworkAttributesParcelable;
@@ -297,16 +297,16 @@ public class IpMemoryStoreService extends IIpMemoryStore.Stub {
     */
    @Override
    public void isSameNetwork(@Nullable final String l2Key1, @Nullable final String l2Key2,
            @Nullable final IOnSameNetworkResponseListener listener) {
            @Nullable final IOnSameL3NetworkResponseListener listener) {
        if (null == listener) return;
        mExecutor.execute(() -> {
            try {
                if (null == l2Key1 || null == l2Key2) {
                    listener.onSameNetworkResponse(makeStatus(ERROR_ILLEGAL_ARGUMENT), null);
                    listener.onSameL3NetworkResponse(makeStatus(ERROR_ILLEGAL_ARGUMENT), null);
                    return;
                }
                if (null == mDb) {
                    listener.onSameNetworkResponse(makeStatus(ERROR_ILLEGAL_ARGUMENT), null);
                    listener.onSameL3NetworkResponse(makeStatus(ERROR_ILLEGAL_ARGUMENT), null);
                    return;
                }
                try {
@@ -315,16 +315,16 @@ public class IpMemoryStoreService extends IIpMemoryStore.Stub {
                    final NetworkAttributes attr2 =
                            IpMemoryStoreDatabase.retrieveNetworkAttributes(mDb, l2Key2);
                    if (null == attr1 || null == attr2) {
                        listener.onSameNetworkResponse(makeStatus(SUCCESS),
                        listener.onSameL3NetworkResponse(makeStatus(SUCCESS),
                                new SameL3NetworkResponse(l2Key1, l2Key2,
                                        -1f /* never connected */).toParcelable());
                        return;
                    }
                    final float confidence = attr1.getNetworkGroupSamenessConfidence(attr2);
                    listener.onSameNetworkResponse(makeStatus(SUCCESS),
                    listener.onSameL3NetworkResponse(makeStatus(SUCCESS),
                            new SameL3NetworkResponse(l2Key1, l2Key2, confidence).toParcelable());
                } catch (Exception e) {
                    listener.onSameNetworkResponse(makeStatus(ERROR_GENERIC), null);
                    listener.onSameL3NetworkResponse(makeStatus(ERROR_GENERIC), null);
                }
            } catch (final RemoteException e) {
                // Client at the other end died
@@ -343,7 +343,7 @@ public class IpMemoryStoreService extends IIpMemoryStore.Stub {
     */
    @Override
    public void retrieveNetworkAttributes(@Nullable final String l2Key,
            @Nullable final IOnNetworkAttributesRetrieved listener) {
            @Nullable final IOnNetworkAttributesRetrievedListener listener) {
        if (null == listener) return;
        mExecutor.execute(() -> {
            try {
+11 −11
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ import android.content.Context;
import android.net.ipmemorystore.Blob;
import android.net.ipmemorystore.IOnBlobRetrievedListener;
import android.net.ipmemorystore.IOnL2KeyResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrieved;
import android.net.ipmemorystore.IOnSameNetworkResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrievedListener;
import android.net.ipmemorystore.IOnSameL3NetworkResponseListener;
import android.net.ipmemorystore.IOnStatusListener;
import android.net.ipmemorystore.NetworkAttributes;
import android.net.ipmemorystore.NetworkAttributesParcelable;
@@ -163,9 +163,9 @@ public class IpMemoryStoreServiceTest {
    private interface OnNetworkAttributesRetrievedListener  {
        void onNetworkAttributesRetrieved(Status status, String l2Key, NetworkAttributes attr);
    }
    private IOnNetworkAttributesRetrieved onNetworkAttributesRetrieved(
    private IOnNetworkAttributesRetrievedListener onNetworkAttributesRetrieved(
            final OnNetworkAttributesRetrievedListener functor) {
        return new IOnNetworkAttributesRetrieved() {
        return new IOnNetworkAttributesRetrievedListener() {
            @Override
            public void onNetworkAttributesRetrieved(final StatusParcelable status,
                    final String l2Key, final NetworkAttributesParcelable attributes)
@@ -182,17 +182,17 @@ public class IpMemoryStoreServiceTest {
    }

    /** Helper method to make an IOnSameNetworkResponseListener */
    private interface OnSameNetworkResponseListener {
        void onSameNetworkResponse(Status status, SameL3NetworkResponse answer);
    private interface OnSameL3NetworkResponseListener {
        void onSameL3NetworkResponse(Status status, SameL3NetworkResponse answer);
    }
    private IOnSameNetworkResponseListener onSameResponse(
            final OnSameNetworkResponseListener functor) {
        return new IOnSameNetworkResponseListener() {
    private IOnSameL3NetworkResponseListener onSameResponse(
            final OnSameL3NetworkResponseListener functor) {
        return new IOnSameL3NetworkResponseListener() {
            @Override
            public void onSameNetworkResponse(final StatusParcelable status,
            public void onSameL3NetworkResponse(final StatusParcelable status,
                    final SameL3NetworkResponseParcelable sameL3Network)
                    throws RemoteException {
                functor.onSameNetworkResponse(new Status(status),
                functor.onSameL3NetworkResponse(new Status(status),
                        null == sameL3Network ? null : new SameL3NetworkResponse(sameL3Network));
            }

+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ java_library_static {
    srcs: ["java/**/*.java"],
    static_libs: [
        "dnsresolver_aidl_interface-java",
        "ipmemorystore-client",
        "netd_aidl_interface-java",
        "networkstack-aidl-interfaces-java",
    ]
+4 −4
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ import android.net.ipmemorystore.Blob;
import android.net.ipmemorystore.NetworkAttributesParcelable;
import android.net.ipmemorystore.IOnBlobRetrievedListener;
import android.net.ipmemorystore.IOnL2KeyResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrieved;
import android.net.ipmemorystore.IOnSameNetworkResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrievedListener;
import android.net.ipmemorystore.IOnSameL3NetworkResponseListener;
import android.net.ipmemorystore.IOnStatusListener;

/** {@hide} */
@@ -84,7 +84,7 @@ oneway interface IIpMemoryStore {
     * @param listener The listener that will be invoked to return the answer.
     * @return (through the listener) A SameL3NetworkResponse containing the answer and confidence.
     */
    void isSameNetwork(String l2Key1, String l2Key2, IOnSameNetworkResponseListener listener);
    void isSameNetwork(String l2Key1, String l2Key2, IOnSameL3NetworkResponseListener listener);

    /**
     * Retrieve the network attributes for a key.
@@ -95,7 +95,7 @@ oneway interface IIpMemoryStore {
     * @return (through the listener) The network attributes and the L2 key associated with
     *         the query.
     */
    void retrieveNetworkAttributes(String l2Key, IOnNetworkAttributesRetrieved listener);
    void retrieveNetworkAttributes(String l2Key, IOnNetworkAttributesRetrievedListener listener);

    /**
     * Retrieve previously stored private data.
+29 −30
Original line number Diff line number Diff line
@@ -20,14 +20,13 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.net.ipmemorystore.Blob;
import android.net.ipmemorystore.IOnBlobRetrievedListener;
import android.net.ipmemorystore.IOnL2KeyResponseListener;
import android.net.ipmemorystore.IOnNetworkAttributesRetrieved;
import android.net.ipmemorystore.IOnSameNetworkResponseListener;
import android.net.ipmemorystore.IOnStatusListener;
import android.net.ipmemorystore.NetworkAttributes;
import android.net.ipmemorystore.OnBlobRetrievedListener;
import android.net.ipmemorystore.OnL2KeyResponseListener;
import android.net.ipmemorystore.OnNetworkAttributesRetrievedListener;
import android.net.ipmemorystore.OnSameL3NetworkResponseListener;
import android.net.ipmemorystore.OnStatusListener;
import android.net.ipmemorystore.Status;
import android.net.ipmemorystore.StatusParcelable;
import android.os.RemoteException;
import android.util.Log;

@@ -50,12 +49,6 @@ public abstract class IpMemoryStoreClient {
    @NonNull
    protected abstract IIpMemoryStore getService() throws InterruptedException, ExecutionException;

    protected StatusParcelable internalErrorStatus() {
        final StatusParcelable error = new StatusParcelable();
        error.resultCode = Status.ERROR_UNKNOWN;
        return error;
    }

    /**
     * Store network attributes for a given L2 key.
     * If L2Key is null, choose automatically from the attributes ; passing null is equivalent to
@@ -74,12 +67,13 @@ public abstract class IpMemoryStoreClient {
     */
    public void storeNetworkAttributes(@NonNull final String l2Key,
            @NonNull final NetworkAttributes attributes,
            @Nullable final IOnStatusListener listener) {
            @Nullable final OnStatusListener listener) {
        try {
            try {
                getService().storeNetworkAttributes(l2Key, attributes.toParcelable(), listener);
                getService().storeNetworkAttributes(l2Key, attributes.toParcelable(),
                        OnStatusListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onComplete(internalErrorStatus());
                listener.onComplete(new Status(Status.ERROR_UNKNOWN));
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error storing network attributes", e);
@@ -99,12 +93,13 @@ public abstract class IpMemoryStoreClient {
     */
    public void storeBlob(@NonNull final String l2Key, @NonNull final String clientId,
            @NonNull final String name, @NonNull final Blob data,
            @Nullable final IOnStatusListener listener) {
            @Nullable final OnStatusListener listener) {
        try {
            try {
                getService().storeBlob(l2Key, clientId, name, data, listener);
                getService().storeBlob(l2Key, clientId, name, data,
                        OnStatusListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onComplete(internalErrorStatus());
                listener.onComplete(new Status(Status.ERROR_UNKNOWN));
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error storing blob", e);
@@ -126,12 +121,13 @@ public abstract class IpMemoryStoreClient {
     * Through the listener, returns the L2 key if one matched, or null.
     */
    public void findL2Key(@NonNull final NetworkAttributes attributes,
            @NonNull final IOnL2KeyResponseListener listener) {
            @NonNull final OnL2KeyResponseListener listener) {
        try {
            try {
                getService().findL2Key(attributes.toParcelable(), listener);
                getService().findL2Key(attributes.toParcelable(),
                        OnL2KeyResponseListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onL2KeyResponse(internalErrorStatus(), null);
                listener.onL2KeyResponse(new Status(Status.ERROR_UNKNOWN), null);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error finding L2 Key", e);
@@ -148,12 +144,13 @@ public abstract class IpMemoryStoreClient {
     * Through the listener, a SameL3NetworkResponse containing the answer and confidence.
     */
    public void isSameNetwork(@NonNull final String l2Key1, @NonNull final String l2Key2,
            @NonNull final IOnSameNetworkResponseListener listener) {
            @NonNull final OnSameL3NetworkResponseListener listener) {
        try {
            try {
                getService().isSameNetwork(l2Key1, l2Key2, listener);
                getService().isSameNetwork(l2Key1, l2Key2,
                        OnSameL3NetworkResponseListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onSameNetworkResponse(internalErrorStatus(), null);
                listener.onSameL3NetworkResponse(new Status(Status.ERROR_UNKNOWN), null);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error checking for network sameness", e);
@@ -170,12 +167,13 @@ public abstract class IpMemoryStoreClient {
     *         the query.
     */
    public void retrieveNetworkAttributes(@NonNull final String l2Key,
            @NonNull final IOnNetworkAttributesRetrieved listener) {
            @NonNull final OnNetworkAttributesRetrievedListener listener) {
        try {
            try {
                getService().retrieveNetworkAttributes(l2Key, listener);
                getService().retrieveNetworkAttributes(l2Key,
                        OnNetworkAttributesRetrievedListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onNetworkAttributesRetrieved(internalErrorStatus(), null, null);
                listener.onNetworkAttributesRetrieved(new Status(Status.ERROR_UNKNOWN), null, null);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error retrieving network attributes", e);
@@ -194,12 +192,13 @@ public abstract class IpMemoryStoreClient {
     *         and the name of the data associated with the query.
     */
    public void retrieveBlob(@NonNull final String l2Key, @NonNull final String clientId,
            @NonNull final String name, @NonNull final IOnBlobRetrievedListener listener) {
            @NonNull final String name, @NonNull final OnBlobRetrievedListener listener) {
        try {
            try {
                getService().retrieveBlob(l2Key, clientId, name, listener);
                getService().retrieveBlob(l2Key, clientId, name,
                        OnBlobRetrievedListener.toAIDL(listener));
            } catch (InterruptedException | ExecutionException m) {
                listener.onBlobRetrieved(internalErrorStatus(), null, null, null);
                listener.onBlobRetrieved(new Status(Status.ERROR_UNKNOWN), null, null, null);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error retrieving blob", e);
Loading