1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.ipmemorystore;
18 
19 import android.annotation.NonNull;
20 
21 /**
22  * A listener for the IpMemoryStore to return a blob.
23  * @hide
24  */
25 public interface OnBlobRetrievedListener {
26     /**
27      * The memory store has come up with the answer to a query that was sent.
28      */
onBlobRetrieved(Status status, String l2Key, String name, Blob blob)29     void onBlobRetrieved(Status status, String l2Key, String name, Blob blob);
30 
31     /** Converts this OnBlobRetrievedListener to a parcelable object */
32     @NonNull
toAIDL(@onNull final OnBlobRetrievedListener listener)33     static IOnBlobRetrievedListener toAIDL(@NonNull final OnBlobRetrievedListener listener) {
34         return new IOnBlobRetrievedListener.Stub() {
35             @Override
36             public void onBlobRetrieved(final StatusParcelable statusParcelable, final String l2Key,
37                     final String name, final Blob blob) {
38                 // NonNull, but still don't crash the system server if null
39                 if (null != listener) {
40                     listener.onBlobRetrieved(new Status(statusParcelable), l2Key, name, blob);
41                 }
42             }
43 
44             @Override
45             public int getInterfaceVersion() {
46                 return this.VERSION;
47             }
48         };
49     }
50 }
51