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.SearchSpec; 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.Objects; 29 30 /** 31 * Encapsulates a request to make a binder call to remove documents by query. 32 * 33 * @hide 34 */ 35 @SafeParcelable.Class(creator = "RemoveByQueryAidlRequestCreator") 36 public class RemoveByQueryAidlRequest extends AbstractSafeParcelable { 37 @NonNull 38 public static final Parcelable.Creator<RemoveByQueryAidlRequest> CREATOR = 39 new RemoveByQueryAidlRequestCreator(); 40 41 @NonNull 42 @Field(id = 1, getter = "getCallerAttributionSource") 43 private final AppSearchAttributionSource mCallerAttributionSource; 44 45 @NonNull 46 @Field(id = 2, getter = "getDatabaseName") 47 private final String mDatabaseName; 48 49 @NonNull 50 @Field(id = 3, getter = "getQueryExpression") 51 private final String mQueryExpression; 52 53 @NonNull 54 @Field(id = 4, getter = "getSearchSpec") 55 private final SearchSpec mSearchSpec; 56 57 @NonNull 58 @Field(id = 5, getter = "getUserHandle") 59 private final UserHandle mUserHandle; 60 61 @Field(id = 6, getter = "getBinderCallStartTimeMillis") 62 @ElapsedRealtimeLong 63 private final long mBinderCallStartTimeMillis; 64 65 /** 66 * Removes documents by given query. 67 * 68 * @param callerAttributionSource The permission identity of the package to query over. 69 * @param databaseName The databaseName this query for. 70 * @param queryExpression String to search for 71 * @param searchSpec SearchSpec 72 * @param userHandle Handle of the calling user 73 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 74 */ 75 @Constructor RemoveByQueryAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull String databaseName, @Param(id = 3) @NonNull String queryExpression, @Param(id = 4) @NonNull SearchSpec searchSpec, @Param(id = 5) @NonNull UserHandle userHandle, @Param(id = 6) @ElapsedRealtimeLong long binderCallStartTimeMillis)76 public RemoveByQueryAidlRequest( 77 @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource, 78 @Param(id = 2) @NonNull String databaseName, 79 @Param(id = 3) @NonNull String queryExpression, 80 @Param(id = 4) @NonNull SearchSpec searchSpec, 81 @Param(id = 5) @NonNull UserHandle userHandle, 82 @Param(id = 6) @ElapsedRealtimeLong long binderCallStartTimeMillis) { 83 mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource); 84 mDatabaseName = Objects.requireNonNull(databaseName); 85 mQueryExpression = Objects.requireNonNull(queryExpression); 86 mSearchSpec = Objects.requireNonNull(searchSpec); 87 mUserHandle = Objects.requireNonNull(userHandle); 88 mBinderCallStartTimeMillis = binderCallStartTimeMillis; 89 } 90 91 @NonNull getCallerAttributionSource()92 public AppSearchAttributionSource getCallerAttributionSource() { 93 return mCallerAttributionSource; 94 } 95 96 @NonNull getDatabaseName()97 public String getDatabaseName() { 98 return mDatabaseName; 99 } 100 101 @NonNull getQueryExpression()102 public String getQueryExpression() { 103 return mQueryExpression; 104 } 105 106 @NonNull getSearchSpec()107 public SearchSpec getSearchSpec() { 108 return mSearchSpec; 109 } 110 111 @NonNull getUserHandle()112 public UserHandle getUserHandle() { 113 return mUserHandle; 114 } 115 116 @ElapsedRealtimeLong getBinderCallStartTimeMillis()117 public long getBinderCallStartTimeMillis() { 118 return mBinderCallStartTimeMillis; 119 } 120 121 @Override writeToParcel(@onNull Parcel dest, int flags)122 public void writeToParcel(@NonNull Parcel dest, int flags) { 123 RemoveByQueryAidlRequestCreator.writeToParcel(this, dest, flags); 124 } 125 } 126