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.NonNull; 20 import android.app.appsearch.safeparcel.AbstractSafeParcelable; 21 import android.app.appsearch.safeparcel.SafeParcelable; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 import android.os.UserHandle; 25 26 import java.util.Objects; 27 28 /** 29 * Encapsulates a request to make a binder call to retrieve all namespaces in given database. 30 * 31 * @hide 32 */ 33 @SafeParcelable.Class(creator = "GetNamespacesAidlRequestCreator") 34 public class GetNamespacesAidlRequest extends AbstractSafeParcelable { 35 @NonNull 36 public static final Parcelable.Creator<GetNamespacesAidlRequest> CREATOR = 37 new GetNamespacesAidlRequestCreator(); 38 39 @NonNull 40 @Field(id = 1, getter = "getCallerAttributionSource") 41 private final AppSearchAttributionSource mCallerAttributionSource; 42 43 @NonNull 44 @Field(id = 2, getter = "getDatabaseName") 45 private final String mDatabaseName; 46 47 @NonNull 48 @Field(id = 3, getter = "getUserHandle") 49 private final UserHandle mUserHandle; 50 51 @Field(id = 4, getter = "getBinderCallStartTimeMillis") 52 private final long mBinderCallStartTimeMillis; 53 54 /** 55 * Retrieves the set of all namespaces in the current database with at least one document. 56 * 57 * @param callerAttributionSource The permission identity of the package that owns the schema. 58 * @param databaseName The name of the database to retrieve. 59 * @param userHandle Handle of the calling user 60 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 61 */ 62 @Constructor GetNamespacesAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull String databaseName, @Param(id = 3) @NonNull UserHandle userHandle, @Param(id = 4) long binderCallStartTimeMillis)63 public GetNamespacesAidlRequest( 64 @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource, 65 @Param(id = 2) @NonNull String databaseName, 66 @Param(id = 3) @NonNull UserHandle userHandle, 67 @Param(id = 4) long binderCallStartTimeMillis) { 68 mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource); 69 mDatabaseName = Objects.requireNonNull(databaseName); 70 mUserHandle = Objects.requireNonNull(userHandle); 71 mBinderCallStartTimeMillis = binderCallStartTimeMillis; 72 } 73 74 @NonNull getCallerAttributionSource()75 public AppSearchAttributionSource getCallerAttributionSource() { 76 return mCallerAttributionSource; 77 } 78 79 @NonNull getDatabaseName()80 public String getDatabaseName() { 81 return mDatabaseName; 82 } 83 84 @NonNull getUserHandle()85 public UserHandle getUserHandle() { 86 return mUserHandle; 87 } 88 getBinderCallStartTimeMillis()89 public long getBinderCallStartTimeMillis() { 90 return mBinderCallStartTimeMillis; 91 } 92 93 @Override writeToParcel(@onNull Parcel dest, int flags)94 public void writeToParcel(@NonNull Parcel dest, int flags) { 95 GetNamespacesAidlRequestCreator.writeToParcel(this, dest, flags); 96 } 97 } 98