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 L2 key. 23 * @hide 24 */ 25 public interface OnL2KeyResponseListener { 26 /** 27 * The operation has completed with the specified status. 28 */ onL2KeyResponse(Status status, String l2Key)29 void onL2KeyResponse(Status status, String l2Key); 30 31 /** Converts this OnL2KeyResponseListener to a parcelable object */ 32 @NonNull toAIDL(@onNull final OnL2KeyResponseListener listener)33 static IOnL2KeyResponseListener toAIDL(@NonNull final OnL2KeyResponseListener listener) { 34 return new IOnL2KeyResponseListener.Stub() { 35 @Override 36 public void onL2KeyResponse(final StatusParcelable statusParcelable, 37 final String l2Key) { 38 // NonNull, but still don't crash the system server if null 39 if (null != listener) { 40 listener.onL2KeyResponse(new Status(statusParcelable), l2Key); 41 } 42 } 43 44 @Override 45 public int getInterfaceVersion() { 46 return this.VERSION; 47 } 48 49 @Override 50 public String getInterfaceHash() { 51 return this.HASH; 52 } 53 }; 54 } 55 } 56