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 import android.annotation.Nullable;
21 
22 /**
23  * A listener for the IpMemoryStore to return a status to a client.
24  * @hide
25  */
26 public interface OnDeleteStatusListener {
27     /**
28      * The operation has completed with the specified status, and deleted the specified
29      * number of records. The operation can fail with a non-zero count of deleted rows as
30      * wipe requests may fail for lack of storage. See the documentation of each deletion
31      * method for details.
32      */
onComplete(Status status, int deletedRecords)33     void onComplete(Status status, int deletedRecords);
34 
35     /** Converts this OnDeleteStatusListener to a parcelable object */
36     @NonNull
toAIDL(@ullable final OnDeleteStatusListener listener)37     static IOnStatusAndCountListener toAIDL(@Nullable final OnDeleteStatusListener listener) {
38         return new IOnStatusAndCountListener.Stub() {
39             @Override
40             public void onComplete(final StatusParcelable statusParcelable, int deletedRecords) {
41                 if (null != listener) {
42                     listener.onComplete(new Status(statusParcelable), deletedRecords);
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