Merge changes Id598ae1d,I475bd011
* changes: Fix a possible crash when the listener is null Straighten AIDL interface for the memory store
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.net.ipmemorystore.NetworkAttributesParcelable;
|
||||
import android.net.ipmemorystore.StatusParcelable;
|
||||
|
||||
/** {@hide} */
|
||||
oneway interface IOnNetworkAttributesRetrieved {
|
||||
oneway interface IOnNetworkAttributesRetrievedListener {
|
||||
/**
|
||||
* Network attributes were fetched for the specified L2 key. While the L2 key will never
|
||||
* be null, the attributes may be if no data is stored about this L2 key.
|
||||
@@ -20,10 +20,10 @@ import android.net.ipmemorystore.SameL3NetworkResponseParcelable;
|
||||
import android.net.ipmemorystore.StatusParcelable;
|
||||
|
||||
/** {@hide} */
|
||||
oneway interface IOnSameNetworkResponseListener {
|
||||
oneway interface IOnSameL3NetworkResponseListener {
|
||||
/**
|
||||
* The memory store has come up with the answer to a query that was sent.
|
||||
*/
|
||||
void onSameNetworkResponse(in StatusParcelable status,
|
||||
void onSameL3NetworkResponse(in StatusParcelable status,
|
||||
in SameL3NetworkResponseParcelable response);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.net.ipmemorystore;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* A listener for the IpMemoryStore to return a blob.
|
||||
* @hide
|
||||
*/
|
||||
public interface OnBlobRetrievedListener {
|
||||
/**
|
||||
* The memory store has come up with the answer to a query that was sent.
|
||||
*/
|
||||
void onBlobRetrieved(Status status, String l2Key, String name, Blob blob);
|
||||
|
||||
/** Converts this OnBlobRetrievedListener to a parcelable object */
|
||||
@NonNull
|
||||
static IOnBlobRetrievedListener toAIDL(@NonNull final OnBlobRetrievedListener listener) {
|
||||
return new IOnBlobRetrievedListener.Stub() {
|
||||
@Override
|
||||
public void onBlobRetrieved(final StatusParcelable statusParcelable, final String l2Key,
|
||||
final String name, final Blob blob) {
|
||||
// NonNull, but still don't crash the system server if null
|
||||
if (null != listener) {
|
||||
listener.onBlobRetrieved(new Status(statusParcelable), l2Key, name, blob);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.net.ipmemorystore;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* A listener for the IpMemoryStore to return a L2 key.
|
||||
* @hide
|
||||
*/
|
||||
public interface OnL2KeyResponseListener {
|
||||
/**
|
||||
* The operation has completed with the specified status.
|
||||
*/
|
||||
void onL2KeyResponse(Status status, String l2Key);
|
||||
|
||||
/** Converts this OnL2KeyResponseListener to a parcelable object */
|
||||
@NonNull
|
||||
static IOnL2KeyResponseListener toAIDL(@NonNull final OnL2KeyResponseListener listener) {
|
||||
return new IOnL2KeyResponseListener.Stub() {
|
||||
@Override
|
||||
public void onL2KeyResponse(final StatusParcelable statusParcelable,
|
||||
final String l2Key) {
|
||||
// NonNull, but still don't crash the system server if null
|
||||
if (null != listener) {
|
||||
listener.onL2KeyResponse(new Status(statusParcelable), l2Key);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.net.ipmemorystore;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* A listener for the IpMemoryStore to return network attributes.
|
||||
* @hide
|
||||
*/
|
||||
public interface OnNetworkAttributesRetrievedListener {
|
||||
/**
|
||||
* The memory store has come up with the answer to a query that was sent.
|
||||
*/
|
||||
void onNetworkAttributesRetrieved(Status status, String l2Key, NetworkAttributes attributes);
|
||||
|
||||
/** Converts this OnNetworkAttributesRetrievedListener to a parcelable object */
|
||||
@NonNull
|
||||
static IOnNetworkAttributesRetrievedListener toAIDL(
|
||||
@NonNull final OnNetworkAttributesRetrievedListener listener) {
|
||||
return new IOnNetworkAttributesRetrievedListener.Stub() {
|
||||
@Override
|
||||
public void onNetworkAttributesRetrieved(final StatusParcelable statusParcelable,
|
||||
final String l2Key,
|
||||
final NetworkAttributesParcelable networkAttributesParcelable) {
|
||||
// NonNull, but still don't crash the system server if null
|
||||
if (null != listener) {
|
||||
listener.onNetworkAttributesRetrieved(
|
||||
new Status(statusParcelable), l2Key,
|
||||
new NetworkAttributes(networkAttributesParcelable));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.net.ipmemorystore;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* A listener for the IpMemoryStore to return a response about network sameness.
|
||||
* @hide
|
||||
*/
|
||||
public interface OnSameL3NetworkResponseListener {
|
||||
/**
|
||||
* The memory store has come up with the answer to a query that was sent.
|
||||
*/
|
||||
void onSameL3NetworkResponse(Status status, SameL3NetworkResponse response);
|
||||
|
||||
/** Converts this OnSameL3NetworkResponseListener to a parcelable object */
|
||||
@NonNull
|
||||
static IOnSameL3NetworkResponseListener toAIDL(
|
||||
@NonNull final OnSameL3NetworkResponseListener listener) {
|
||||
return new IOnSameL3NetworkResponseListener.Stub() {
|
||||
@Override
|
||||
public void onSameL3NetworkResponse(final StatusParcelable statusParcelable,
|
||||
final SameL3NetworkResponseParcelable sameL3NetworkResponseParcelable) {
|
||||
// NonNull, but still don't crash the system server if null
|
||||
if (null != listener) {
|
||||
listener.onSameL3NetworkResponse(
|
||||
new Status(statusParcelable),
|
||||
new SameL3NetworkResponse(sameL3NetworkResponseParcelable));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.net.ipmemorystore;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A listener for the IpMemoryStore to return a status to a client.
|
||||
* @hide
|
||||
*/
|
||||
public interface OnStatusListener {
|
||||
/**
|
||||
* The operation has completed with the specified status.
|
||||
*/
|
||||
void onComplete(Status status);
|
||||
|
||||
/** Converts this OnStatusListener to a parcelable object */
|
||||
@NonNull
|
||||
static IOnStatusListener toAIDL(@Nullable final OnStatusListener listener) {
|
||||
return new IOnStatusListener.Stub() {
|
||||
@Override
|
||||
public void onComplete(final StatusParcelable statusParcelable) {
|
||||
if (null != listener) {
|
||||
listener.onComplete(new Status(statusParcelable));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.net.ipmemorystore;
|
||||
package com.android.server.connectivity.ipmemorystore;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user