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 create and initialize AppSearchImpl for the 31 * calling application. 32 * 33 * @hide 34 */ 35 @SafeParcelable.Class(creator = "InitializeAidlRequestCreator") 36 public class InitializeAidlRequest extends AbstractSafeParcelable { 37 @NonNull 38 public static final Parcelable.Creator<InitializeAidlRequest> CREATOR = 39 new InitializeAidlRequestCreator(); 40 41 @NonNull 42 @SafeParcelable.Field(id = 1, getter = "getCallerAttributionSource") 43 private final AppSearchAttributionSource mCallerAttributionSource; 44 45 @NonNull 46 @Field(id = 2, getter = "getUserHandle") 47 private final UserHandle mUserHandle; 48 49 @Field(id = 3, getter = "getBinderCallStartTimeMillis") 50 @ElapsedRealtimeLong 51 private final long mBinderCallStartTimeMillis; 52 53 /** 54 * Creates and initializes AppSearchImpl for the calling app. 55 * 56 * @param callerAttributionSource The permission identity of the package to initialize for. 57 * @param userHandle Handle of the calling user 58 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 59 */ 60 @Constructor InitializeAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull UserHandle userHandle, @Param(id = 3) @ElapsedRealtimeLong long binderCallStartTimeMillis)61 public InitializeAidlRequest( 62 @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource, 63 @Param(id = 2) @NonNull UserHandle userHandle, 64 @Param(id = 3) @ElapsedRealtimeLong long binderCallStartTimeMillis) { 65 mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource); 66 mUserHandle = Objects.requireNonNull(userHandle); 67 mBinderCallStartTimeMillis = binderCallStartTimeMillis; 68 } 69 70 @NonNull getCallerAttributionSource()71 public AppSearchAttributionSource getCallerAttributionSource() { 72 return mCallerAttributionSource; 73 } 74 75 @NonNull getUserHandle()76 public UserHandle getUserHandle() { 77 return mUserHandle; 78 } 79 80 @ElapsedRealtimeLong getBinderCallStartTimeMillis()81 public long getBinderCallStartTimeMillis() { 82 return mBinderCallStartTimeMillis; 83 } 84 85 @Override writeToParcel(@onNull Parcel dest, int flags)86 public void writeToParcel(@NonNull Parcel dest, int flags) { 87 InitializeAidlRequestCreator.writeToParcel(this, dest, flags); 88 } 89 } 90