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

Commit 0fffc5ce authored by Chalard Jean's avatar Chalard Jean Committed by Gerrit Code Review
Browse files

Merge changes Id598ae1d,I475bd011

* changes:
  Fix a possible crash when the listener is null
  Straighten AIDL interface for the memory store
parents 64e5bd77 51903a13
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));
            }