1 /* 2 * Copyright (C) 2024 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 specific network event counts. 23 * @hide 24 */ 25 public interface OnNetworkEventCountRetrievedListener { 26 /** 27 * The memory store has come up with the answer to a query that was sent. 28 */ onNetworkEventCountRetrieved(Status status, int[] counts)29 void onNetworkEventCountRetrieved(Status status, int[] counts); 30 31 /** Converts this OnNetworkEventCountRetrievedListener to a parcelable object */ 32 @NonNull toAIDL( @onNull final OnNetworkEventCountRetrievedListener listener)33 static IOnNetworkEventCountRetrievedListener toAIDL( 34 @NonNull final OnNetworkEventCountRetrievedListener listener) { 35 return new IOnNetworkEventCountRetrievedListener.Stub() { 36 @Override 37 public void onNetworkEventCountRetrieved( 38 final StatusParcelable statusParcelable, 39 final int[] counts) { 40 // NonNull, but still don't crash the system server if null 41 if (null != listener) { 42 listener.onNetworkEventCountRetrieved(new Status(statusParcelable), counts); 43 } 44 } 45 46 @Override 47 public int getInterfaceVersion() { 48 return this.VERSION; 49 } 50 51 @Override 52 public String getInterfaceHash() { 53 return this.HASH; 54 } 55 }; 56 } 57 } 58