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

Commit dd07ae57 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix a possible crash when the listener is null" into qt-dev

parents 0454f3b8 28671455
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -30,13 +30,16 @@ public interface OnBlobRetrievedListener {

    /** Converts this OnBlobRetrievedListener to a parcelable object */
    @NonNull
    static IOnBlobRetrievedListener toAIDL(final OnBlobRetrievedListener listener) {
    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);
                }
            }
        };
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -30,13 +30,16 @@ public interface OnL2KeyResponseListener {

    /** Converts this OnL2KeyResponseListener to a parcelable object */
    @NonNull
    static IOnL2KeyResponseListener toAIDL(final OnL2KeyResponseListener listener) {
    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);
                }
            }
        };
    }
}
+7 −4
Original line number Diff line number Diff line
@@ -31,16 +31,19 @@ public interface OnNetworkAttributesRetrievedListener {
    /** Converts this OnNetworkAttributesRetrievedListener to a parcelable object */
    @NonNull
    static IOnNetworkAttributesRetrievedListener toAIDL(
            final OnNetworkAttributesRetrievedListener listener) {
            @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));
                }
            }
        };
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -30,15 +30,19 @@ public interface OnSameL3NetworkResponseListener {

    /** Converts this OnSameL3NetworkResponseListener to a parcelable object */
    @NonNull
    static IOnSameL3NetworkResponseListener toAIDL(final OnSameL3NetworkResponseListener listener) {
    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));
                }
            }
        };
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net.ipmemorystore;

import android.annotation.NonNull;
import android.annotation.Nullable;

/**
 * A listener for the IpMemoryStore to return a status to a client.
@@ -30,12 +31,14 @@ public interface OnStatusListener {

    /** Converts this OnStatusListener to a parcelable object */
    @NonNull
    static IOnStatusListener toAIDL(final OnStatusListener listener) {
    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));
                }
            }
        };
    }
}