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.safeparcel.AbstractSafeParcelable; 22 import android.app.appsearch.safeparcel.SafeParcelable; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 import android.os.UserHandle; 26 27 import java.util.Objects; 28 29 /** 30 * Encapsulates a request to make a binder call to insert documents into the index. 31 * 32 * @hide 33 */ 34 @SafeParcelable.Class(creator = "PutDocumentsAidlRequestCreator") 35 public class PutDocumentsAidlRequest extends AbstractSafeParcelable { 36 @NonNull 37 public static final Parcelable.Creator<PutDocumentsAidlRequest> CREATOR = 38 new PutDocumentsAidlRequestCreator(); 39 40 @NonNull 41 @Field(id = 1, getter = "getCallerAttributionSource") 42 private final AppSearchAttributionSource mCallerAttributionSource; 43 44 @NonNull 45 @Field(id = 2, getter = "getDatabaseName") 46 private final String mDatabaseName; 47 48 @NonNull 49 @Field(id = 3, getter = "getDocumentsParcel") 50 private final DocumentsParcel mDocumentsParcel; 51 52 @NonNull 53 @Field(id = 4, getter = "getUserHandle") 54 private final UserHandle mUserHandle; 55 56 @Field(id = 5, getter = "getBinderCallStartTimeMillis") 57 @ElapsedRealtimeLong 58 private final long mBinderCallStartTimeMillis; 59 60 /** 61 * Inserts documents into the index. 62 * 63 * @param callerAttributionSource The permission identity of the package that owns this 64 * document. 65 * @param databaseName The name of the database where this document lives. 66 * @param documentsParcel The Parcelable object contains a list of GenericDocument. 67 * @param userHandle The Handle of the calling user. 68 * @param binderCallStartTimeMillis The start timestamp of binder call in Millis. 69 */ 70 @Constructor PutDocumentsAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull String databaseName, @Param(id = 3) @NonNull DocumentsParcel documentsParcel, @Param(id = 4) @NonNull UserHandle userHandle, @Param(id = 5) @ElapsedRealtimeLong long binderCallStartTimeMillis)71 public PutDocumentsAidlRequest( 72 @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource, 73 @Param(id = 2) @NonNull String databaseName, 74 @Param(id = 3) @NonNull DocumentsParcel documentsParcel, 75 @Param(id = 4) @NonNull UserHandle userHandle, 76 @Param(id = 5) @ElapsedRealtimeLong long binderCallStartTimeMillis) { 77 mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource); 78 mDatabaseName = Objects.requireNonNull(databaseName); 79 mDocumentsParcel = Objects.requireNonNull(documentsParcel); 80 mUserHandle = Objects.requireNonNull(userHandle); 81 mBinderCallStartTimeMillis = binderCallStartTimeMillis; 82 } 83 84 @NonNull getCallerAttributionSource()85 public AppSearchAttributionSource getCallerAttributionSource() { 86 return mCallerAttributionSource; 87 } 88 89 @NonNull getDatabaseName()90 public String getDatabaseName() { 91 return mDatabaseName; 92 } 93 94 @NonNull getDocumentsParcel()95 public DocumentsParcel getDocumentsParcel() { 96 return mDocumentsParcel; 97 } 98 99 @NonNull getUserHandle()100 public UserHandle getUserHandle() { 101 return mUserHandle; 102 } 103 104 @ElapsedRealtimeLong getBinderCallStartTimeMillis()105 public long getBinderCallStartTimeMillis() { 106 return mBinderCallStartTimeMillis; 107 } 108 109 @Override writeToParcel(@onNull Parcel dest, int flags)110 public void writeToParcel(@NonNull Parcel dest, int flags) { 111 PutDocumentsAidlRequestCreator.writeToParcel(this, dest, flags); 112 } 113 } 114