• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.appsearch.aidl;
18 
19 import android.annotation.ElapsedRealtimeLong;
20 import android.annotation.NonNull;
21 import android.app.appsearch.AppSearchBlobHandle;
22 import android.app.appsearch.safeparcel.AbstractSafeParcelable;
23 import android.app.appsearch.safeparcel.SafeParcelable;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26 import android.os.UserHandle;
27 
28 import java.util.Collections;
29 import java.util.List;
30 import java.util.Objects;
31 
32 /**
33  * Encapsulates a request to make a binder call to remove a batch of blob to AppSearch
34  *
35  * @hide
36  */
37 @SafeParcelable.Class(creator = "RemoveBlobAidlRequestCreator")
38 public final class RemoveBlobAidlRequest extends AbstractSafeParcelable {
39     @NonNull
40     public static final Parcelable.Creator<RemoveBlobAidlRequest> CREATOR =
41             new RemoveBlobAidlRequestCreator();
42 
43     @NonNull
44     @Field(id = 1, getter = "getCallerAttributionSource")
45     private final AppSearchAttributionSource mCallerAttributionSource;
46 
47     @NonNull
48     @Field(id = 2, getter = "getCallingDatabaseName")
49     private final String mCallingDatabaseName;
50 
51     @NonNull
52     @Field(id = 3, getter = "getBlobHandles")
53     private final List<AppSearchBlobHandle> mBlobHandles;
54 
55     @NonNull
56     @Field(id = 4, getter = "getUserHandle")
57     private final UserHandle mUserHandle;
58 
59     @Field(id = 5, getter = "getBinderCallStartTimeMillis")
60     private final long mBinderCallStartTimeMillis;
61 
62     /**
63      * Commit a batch of blob to AppSearch
64      *
65      * @param callerAttributionSource The permission identity of the package that is getting this
66      *     document.
67      * @param callingDatabaseName The database name of these blob stored in.
68      * @param blobHandles The blobs to remove
69      * @param userHandle Handle of the calling user.
70      * @param binderCallStartTimeMillis start timestamp of binder call in Millis.
71      */
72     @Constructor
RemoveBlobAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull String callingDatabaseName, @Param(id = 3) @NonNull List<AppSearchBlobHandle> blobHandles, @Param(id = 4) @NonNull UserHandle userHandle, @Param(id = 5) long binderCallStartTimeMillis)73     public RemoveBlobAidlRequest(
74             @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource,
75             @Param(id = 2) @NonNull String callingDatabaseName,
76             @Param(id = 3) @NonNull List<AppSearchBlobHandle> blobHandles,
77             @Param(id = 4) @NonNull UserHandle userHandle,
78             @Param(id = 5) long binderCallStartTimeMillis) {
79         mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource);
80         mCallingDatabaseName = Objects.requireNonNull(callingDatabaseName);
81         mBlobHandles = Objects.requireNonNull(blobHandles);
82         mUserHandle = Objects.requireNonNull(userHandle);
83         mBinderCallStartTimeMillis = binderCallStartTimeMillis;
84     }
85 
86     @NonNull
getCallerAttributionSource()87     public AppSearchAttributionSource getCallerAttributionSource() {
88         return mCallerAttributionSource;
89     }
90 
91     @NonNull
getCallingDatabaseName()92     public String getCallingDatabaseName() {
93         return mCallingDatabaseName;
94     }
95 
96     /** Gets the {@code list} of {@link AppSearchBlobHandle} to remove blobs from AppSearch. */
97     @NonNull
getBlobHandles()98     public List<AppSearchBlobHandle> getBlobHandles() {
99         return Collections.unmodifiableList(mBlobHandles);
100     }
101 
102     @NonNull
getUserHandle()103     public UserHandle getUserHandle() {
104         return mUserHandle;
105     }
106 
107     @ElapsedRealtimeLong
getBinderCallStartTimeMillis()108     public long getBinderCallStartTimeMillis() {
109         return mBinderCallStartTimeMillis;
110     }
111 
112     @Override
writeToParcel(@onNull Parcel dest, int flags)113     public void writeToParcel(@NonNull Parcel dest, int flags) {
114         RemoveBlobAidlRequestCreator.writeToParcel(this, dest, flags);
115     }
116 }
117