• 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.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 get the schema for a given database.
31  *
32  * @hide
33  */
34 @SafeParcelable.Class(creator = "GetSchemaAidlRequestCreator")
35 public class GetSchemaAidlRequest extends AbstractSafeParcelable {
36     @NonNull
37     public static final Parcelable.Creator<GetSchemaAidlRequest> CREATOR =
38             new GetSchemaAidlRequestCreator();
39 
40     @NonNull
41     @Field(id = 1, getter = "getCallerAttributionSource")
42     private final AppSearchAttributionSource mCallerAttributionSource;
43 
44     @NonNull
45     @Field(id = 2, getter = "getTargetPackageName")
46     private final String mTargetPackageName;
47 
48     @NonNull
49     @Field(id = 3, getter = "getDatabaseName")
50     private final String mDatabaseName;
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     @Field(id = 6, getter = "isForEnterprise")
61     private final boolean mIsForEnterprise;
62 
63     /**
64      * Retrieves the AppSearch schema for this database.
65      *
66      * @param callerAttributionSource The permission identity of the package making this call.
67      * @param targetPackageName The name of the package that owns the schema.
68      * @param databaseName The name of the database to retrieve.
69      * @param userHandle Handle of the calling user
70      * @param binderCallStartTimeMillis start timestamp of binder call in Millis
71      */
72     @Constructor
GetSchemaAidlRequest( @aramid = 1) @onNull AppSearchAttributionSource callerAttributionSource, @Param(id = 2) @NonNull String targetPackageName, @Param(id = 3) @NonNull String databaseName, @Param(id = 4) @NonNull UserHandle userHandle, @Param(id = 5) @ElapsedRealtimeLong long binderCallStartTimeMillis, @Param(id = 6) boolean isForEnterprise)73     public GetSchemaAidlRequest(
74             @Param(id = 1) @NonNull AppSearchAttributionSource callerAttributionSource,
75             @Param(id = 2) @NonNull String targetPackageName,
76             @Param(id = 3) @NonNull String databaseName,
77             @Param(id = 4) @NonNull UserHandle userHandle,
78             @Param(id = 5) @ElapsedRealtimeLong long binderCallStartTimeMillis,
79             @Param(id = 6) boolean isForEnterprise) {
80         mCallerAttributionSource = Objects.requireNonNull(callerAttributionSource);
81         mTargetPackageName = Objects.requireNonNull(targetPackageName);
82         mDatabaseName = Objects.requireNonNull(databaseName);
83         mUserHandle = Objects.requireNonNull(userHandle);
84         mBinderCallStartTimeMillis = binderCallStartTimeMillis;
85         mIsForEnterprise = isForEnterprise;
86     }
87 
88     @NonNull
getCallerAttributionSource()89     public AppSearchAttributionSource getCallerAttributionSource() {
90         return mCallerAttributionSource;
91     }
92 
93     @NonNull
getTargetPackageName()94     public String getTargetPackageName() {
95         return mTargetPackageName;
96     }
97 
98     @NonNull
getDatabaseName()99     public String getDatabaseName() {
100         return mDatabaseName;
101     }
102 
103     @NonNull
getUserHandle()104     public UserHandle getUserHandle() {
105         return mUserHandle;
106     }
107 
108     @ElapsedRealtimeLong
getBinderCallStartTimeMillis()109     public long getBinderCallStartTimeMillis() {
110         return mBinderCallStartTimeMillis;
111     }
112 
isForEnterprise()113     public boolean isForEnterprise() {
114         return mIsForEnterprise;
115     }
116 
117     @Override
writeToParcel(@onNull Parcel dest, int flags)118     public void writeToParcel(@NonNull Parcel dest, int flags) {
119         GetSchemaAidlRequestCreator.writeToParcel(this, dest, flags);
120     }
121 }
122