Merge "Fix a possible crash when the listener is null" into qt-dev
am: dd07ae579c
Change-Id: I325fd3eda6e89228353342f00a49f50b22b17071
This commit is contained in:
@@ -30,12 +30,15 @@ public interface OnBlobRetrievedListener {
|
|||||||
|
|
||||||
/** Converts this OnBlobRetrievedListener to a parcelable object */
|
/** Converts this OnBlobRetrievedListener to a parcelable object */
|
||||||
@NonNull
|
@NonNull
|
||||||
static IOnBlobRetrievedListener toAIDL(final OnBlobRetrievedListener listener) {
|
static IOnBlobRetrievedListener toAIDL(@NonNull final OnBlobRetrievedListener listener) {
|
||||||
return new IOnBlobRetrievedListener.Stub() {
|
return new IOnBlobRetrievedListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onBlobRetrieved(final StatusParcelable statusParcelable, final String l2Key,
|
public void onBlobRetrieved(final StatusParcelable statusParcelable, final String l2Key,
|
||||||
final String name, final Blob blob) {
|
final String name, final Blob blob) {
|
||||||
listener.onBlobRetrieved(new Status(statusParcelable), l2Key, name, blob);
|
// NonNull, but still don't crash the system server if null
|
||||||
|
if (null != listener) {
|
||||||
|
listener.onBlobRetrieved(new Status(statusParcelable), l2Key, name, blob);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ public interface OnL2KeyResponseListener {
|
|||||||
|
|
||||||
/** Converts this OnL2KeyResponseListener to a parcelable object */
|
/** Converts this OnL2KeyResponseListener to a parcelable object */
|
||||||
@NonNull
|
@NonNull
|
||||||
static IOnL2KeyResponseListener toAIDL(final OnL2KeyResponseListener listener) {
|
static IOnL2KeyResponseListener toAIDL(@NonNull final OnL2KeyResponseListener listener) {
|
||||||
return new IOnL2KeyResponseListener.Stub() {
|
return new IOnL2KeyResponseListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onL2KeyResponse(final StatusParcelable statusParcelable,
|
public void onL2KeyResponse(final StatusParcelable statusParcelable,
|
||||||
final String l2Key) {
|
final String l2Key) {
|
||||||
listener.onL2KeyResponse(new Status(statusParcelable), l2Key);
|
// NonNull, but still don't crash the system server if null
|
||||||
|
if (null != listener) {
|
||||||
|
listener.onL2KeyResponse(new Status(statusParcelable), l2Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,15 +31,18 @@ public interface OnNetworkAttributesRetrievedListener {
|
|||||||
/** Converts this OnNetworkAttributesRetrievedListener to a parcelable object */
|
/** Converts this OnNetworkAttributesRetrievedListener to a parcelable object */
|
||||||
@NonNull
|
@NonNull
|
||||||
static IOnNetworkAttributesRetrievedListener toAIDL(
|
static IOnNetworkAttributesRetrievedListener toAIDL(
|
||||||
final OnNetworkAttributesRetrievedListener listener) {
|
@NonNull final OnNetworkAttributesRetrievedListener listener) {
|
||||||
return new IOnNetworkAttributesRetrievedListener.Stub() {
|
return new IOnNetworkAttributesRetrievedListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onNetworkAttributesRetrieved(final StatusParcelable statusParcelable,
|
public void onNetworkAttributesRetrieved(final StatusParcelable statusParcelable,
|
||||||
final String l2Key,
|
final String l2Key,
|
||||||
final NetworkAttributesParcelable networkAttributesParcelable) {
|
final NetworkAttributesParcelable networkAttributesParcelable) {
|
||||||
listener.onNetworkAttributesRetrieved(
|
// NonNull, but still don't crash the system server if null
|
||||||
new Status(statusParcelable), l2Key,
|
if (null != listener) {
|
||||||
new NetworkAttributes(networkAttributesParcelable));
|
listener.onNetworkAttributesRetrieved(
|
||||||
|
new Status(statusParcelable), l2Key,
|
||||||
|
new NetworkAttributes(networkAttributesParcelable));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,18 @@ public interface OnSameL3NetworkResponseListener {
|
|||||||
|
|
||||||
/** Converts this OnSameL3NetworkResponseListener to a parcelable object */
|
/** Converts this OnSameL3NetworkResponseListener to a parcelable object */
|
||||||
@NonNull
|
@NonNull
|
||||||
static IOnSameL3NetworkResponseListener toAIDL(final OnSameL3NetworkResponseListener listener) {
|
static IOnSameL3NetworkResponseListener toAIDL(
|
||||||
|
@NonNull final OnSameL3NetworkResponseListener listener) {
|
||||||
return new IOnSameL3NetworkResponseListener.Stub() {
|
return new IOnSameL3NetworkResponseListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onSameL3NetworkResponse(final StatusParcelable statusParcelable,
|
public void onSameL3NetworkResponse(final StatusParcelable statusParcelable,
|
||||||
final SameL3NetworkResponseParcelable sameL3NetworkResponseParcelable) {
|
final SameL3NetworkResponseParcelable sameL3NetworkResponseParcelable) {
|
||||||
listener.onSameL3NetworkResponse(
|
// NonNull, but still don't crash the system server if null
|
||||||
new Status(statusParcelable),
|
if (null != listener) {
|
||||||
new SameL3NetworkResponse(sameL3NetworkResponseParcelable));
|
listener.onSameL3NetworkResponse(
|
||||||
|
new Status(statusParcelable),
|
||||||
|
new SameL3NetworkResponse(sameL3NetworkResponseParcelable));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package android.net.ipmemorystore;
|
package android.net.ipmemorystore;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A listener for the IpMemoryStore to return a status to a client.
|
* A listener for the IpMemoryStore to return a status to a client.
|
||||||
@@ -30,11 +31,13 @@ public interface OnStatusListener {
|
|||||||
|
|
||||||
/** Converts this OnStatusListener to a parcelable object */
|
/** Converts this OnStatusListener to a parcelable object */
|
||||||
@NonNull
|
@NonNull
|
||||||
static IOnStatusListener toAIDL(final OnStatusListener listener) {
|
static IOnStatusListener toAIDL(@Nullable final OnStatusListener listener) {
|
||||||
return new IOnStatusListener.Stub() {
|
return new IOnStatusListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(final StatusParcelable statusParcelable) {
|
public void onComplete(final StatusParcelable statusParcelable) {
|
||||||
listener.onComplete(new Status(statusParcelable));
|
if (null != listener) {
|
||||||
|
listener.onComplete(new Status(statusParcelable));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user