• 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 package android.app.appfunctions;
17 
18 import static android.app.appfunctions.flags.Flags.FLAG_ENABLE_APP_FUNCTION_MANAGER;
19 
20 import android.annotation.FlaggedApi;
21 import android.annotation.NonNull;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.os.UserHandle;
25 
26 import java.util.Objects;
27 
28 /**
29  * An internal request to execute an app function.
30  *
31  * @hide
32  */
33 @FlaggedApi(FLAG_ENABLE_APP_FUNCTION_MANAGER)
34 public final class ExecuteAppFunctionAidlRequest implements Parcelable {
35 
36     public static final Creator<ExecuteAppFunctionAidlRequest> CREATOR =
37             new Creator<ExecuteAppFunctionAidlRequest>() {
38                 @Override
39                 public ExecuteAppFunctionAidlRequest createFromParcel(Parcel in) {
40                     ExecuteAppFunctionRequest clientRequest =
41                             ExecuteAppFunctionRequest.CREATOR.createFromParcel(in);
42                     UserHandle userHandle = UserHandle.CREATOR.createFromParcel(in);
43                     String callingPackage = in.readString8();
44                     long requestTime = in.readLong();
45                     return new ExecuteAppFunctionAidlRequest(
46                             clientRequest, userHandle, callingPackage, requestTime);
47                 }
48 
49                 @Override
50                 public ExecuteAppFunctionAidlRequest[] newArray(int size) {
51                     return new ExecuteAppFunctionAidlRequest[size];
52                 }
53             };
54 
55     /** The client request to execute an app function. */
56     private final ExecuteAppFunctionRequest mClientRequest;
57 
58     /** The user handle of the user to execute the app function. */
59     private final UserHandle mUserHandle;
60 
61     /** The package name of the app that is requesting to execute the app function. */
62     private final String mCallingPackage;
63 
64     /** The time of calling executeAppFunction(). */
65     private final long mRequestTime;
66 
ExecuteAppFunctionAidlRequest(ExecuteAppFunctionRequest clientRequest, UserHandle userHandle, String callingPackage, long requestTime)67     public ExecuteAppFunctionAidlRequest(ExecuteAppFunctionRequest clientRequest,
68             UserHandle userHandle, String callingPackage, long requestTime) {
69         this.mClientRequest = Objects.requireNonNull(clientRequest);
70         this.mUserHandle = Objects.requireNonNull(userHandle);
71         this.mCallingPackage = Objects.requireNonNull(callingPackage);
72         this.mRequestTime = requestTime;
73     }
74 
75     @Override
describeContents()76     public int describeContents() {
77         return 0;
78     }
79 
80     @Override
writeToParcel(@onNull Parcel dest, int flags)81     public void writeToParcel(@NonNull Parcel dest, int flags) {
82         mClientRequest.writeToParcel(dest, flags);
83         mUserHandle.writeToParcel(dest, flags);
84         dest.writeString8(mCallingPackage);
85         dest.writeLong(mRequestTime);
86     }
87 
88     /** Returns the client request to execute an app function. */
89     @NonNull
getClientRequest()90     public ExecuteAppFunctionRequest getClientRequest() {
91         return mClientRequest;
92     }
93 
94     /** Returns the user handle of the user to execute the app function. */
95     @NonNull
getUserHandle()96     public UserHandle getUserHandle() {
97         return mUserHandle;
98     }
99 
100     /** Returns the package name of the app that is requesting to execute the app function. */
101     @NonNull
getCallingPackage()102     public String getCallingPackage() {
103         return mCallingPackage;
104     }
105 
106     /** Returns the time of calling executeAppFunction(). */
getRequestTime()107     public long getRequestTime() {
108         return mRequestTime;
109     }
110 }
111