• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 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 package android.app.appsearch;
17 
18 import android.annotation.FlaggedApi;
19 import android.annotation.NonNull;
20 import android.app.appsearch.aidl.AppSearchBatchResultParcelV2;
21 import android.app.appsearch.safeparcel.AbstractSafeParcelable;
22 import android.app.appsearch.safeparcel.SafeParcelable;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 
26 import com.android.appsearch.flags.Flags;
27 
28 import java.util.Objects;
29 
30 /**
31  * Results of {@link AppSearchSession#removeBlob}, containing the outcome of the removal of each
32  * handles.
33  *
34  * <p>This class is used to retrieve the result of a batch removal operation on a collection of blob
35  * handles.
36  */
37 @FlaggedApi(Flags.FLAG_ENABLE_BLOB_STORE)
38 // TODO(b/384721898): Switch to JSpecify annotations
39 @SuppressWarnings({"HiddenSuperclass", "JSpecifyNullness"})
40 @SafeParcelable.Class(creator = "RemoveBlobResponseCreator")
41 public final class RemoveBlobResponse extends AbstractSafeParcelable {
42 
43     public static final @NonNull Parcelable.Creator<RemoveBlobResponse> CREATOR =
44             new RemoveBlobResponseCreator();
45 
46     @Field(id = 1, getter = "getResponseParcel")
47     private final AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> mResultParcel;
48 
49     /** Creates a {@link RemoveBlobResponse} with given {@link AppSearchBatchResult}. */
RemoveBlobResponse(@onNull AppSearchBatchResult<AppSearchBlobHandle, Void> result)50     public RemoveBlobResponse(@NonNull AppSearchBatchResult<AppSearchBlobHandle, Void> result) {
51         this(AppSearchBatchResultParcelV2.fromBlobHandleToVoid(result));
52     }
53 
54     @Constructor
RemoveBlobResponse( @aramid = 1) @onNull AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> resultParcel)55     RemoveBlobResponse(
56             @Param(id = 1) @NonNull
57                     AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> resultParcel) {
58         mResultParcel = Objects.requireNonNull(resultParcel);
59     }
60 
61     /**
62      * Returns the {@link AppSearchBatchResult} object containing the results of the removal
63      * operation for each {@link AppSearchBlobHandle}.
64      *
65      * @return A {@link AppSearchBatchResult} maps {@link AppSearchBlobHandle}s which is a unique
66      *     identifier for a specific blob being removed to the outcome of that commit. If the
67      *     operation was successful, the result for that handle is {@code null}; if there was an
68      *     error, the result contains an {@link AppSearchResult} with details of the failure.
69      */
getResult()70     public @NonNull AppSearchBatchResult<AppSearchBlobHandle, Void> getResult() {
71         return mResultParcel.getResult();
72     }
73 
74     /**
75      * Retrieves the underlying parcel representation of the batch result.
76      *
77      * @hide
78      */
getResponseParcel()79     public @NonNull AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> getResponseParcel() {
80         return mResultParcel;
81     }
82 
83     @Override
writeToParcel(@onNull Parcel dest, int flags)84     public void writeToParcel(@NonNull Parcel dest, int flags) {
85         RemoveBlobResponseCreator.writeToParcel(this, dest, flags);
86     }
87 }
88