1 /*
2  * Copyright (C) 2023 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.car.user;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.os.Parcelable;
22 import android.os.UserHandle;
23 import android.view.Display;
24 
25 import com.android.car.internal.util.DataClass;
26 import com.android.internal.util.Preconditions;
27 
28 /**
29  * User start request.
30  *
31  * @hide
32  */
33 @DataClass(
34         genParcelable = true,
35         genConstructor = false,
36         genAidl = true)
37 @SystemApi
38 public final class UserStartRequest implements Parcelable {
39 
40     private final @NonNull UserHandle mUserHandle;
41     private final int mDisplayId;
42 
43     /** Builder for {@link UserStartRequest}. */
44     public static final class Builder {
45         private final @NonNull UserHandle mUserHandle;
46         private int mDisplayId = Display.INVALID_DISPLAY;
47 
Builder(@onNull UserHandle userHandle)48         public Builder(@NonNull UserHandle userHandle) {
49             com.android.car.internal.util.AnnotationValidations.validate(
50                     NonNull.class, /* ignored= */ null, userHandle);
51             mUserHandle = userHandle;
52         }
53 
54         /** Set the displayId on which to start the user in background. */
setDisplayId(int displayId)55         public @NonNull Builder setDisplayId(int displayId) {
56             Preconditions.checkArgument(displayId != Display.INVALID_DISPLAY,
57                     "setDisplayId: displayId must be valid");
58 
59             mDisplayId = displayId;
60             return this;
61         }
62 
63         /** Builds and returns a {@link UserStartRequest}. */
build()64         public @NonNull UserStartRequest build() {
65             return new UserStartRequest(this);
66         }
67     }
68 
UserStartRequest(Builder builder)69     private UserStartRequest(Builder builder) {
70         mUserHandle = builder.mUserHandle;
71         mDisplayId = builder.mDisplayId;
72     }
73 
74 
75 
76     // Code below generated by codegen v1.0.23.
77     //
78     // DO NOT MODIFY!
79     // CHECKSTYLE:OFF Generated code
80     //
81     // To regenerate run:
82     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/user/UserStartRequest.java
83     //
84     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
85     //   Settings > Editor > Code Style > Formatter Control
86     //@formatter:off
87 
88 
89     @DataClass.Generated.Member
getUserHandle()90     public @NonNull UserHandle getUserHandle() {
91         return mUserHandle;
92     }
93 
94     @DataClass.Generated.Member
getDisplayId()95     public int getDisplayId() {
96         return mDisplayId;
97     }
98 
99     @Override
100     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)101     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
102         // You can override field parcelling by defining methods like:
103         // void parcelFieldName(Parcel dest, int flags) { ... }
104 
105         dest.writeTypedObject(mUserHandle, flags);
106         dest.writeInt(mDisplayId);
107     }
108 
109     @Override
110     @DataClass.Generated.Member
describeContents()111     public int describeContents() { return 0; }
112 
113     /** @hide */
114     @SuppressWarnings({"unchecked", "RedundantCast"})
115     @DataClass.Generated.Member
UserStartRequest(@onNull android.os.Parcel in)116     /* package-private */ UserStartRequest(@NonNull android.os.Parcel in) {
117         // You can override field unparcelling by defining methods like:
118         // static FieldType unparcelFieldName(Parcel in) { ... }
119 
120         UserHandle userHandle = (UserHandle) in.readTypedObject(UserHandle.CREATOR);
121         int displayId = in.readInt();
122 
123         this.mUserHandle = userHandle;
124         com.android.car.internal.util.AnnotationValidations.validate(
125                 NonNull.class, null, mUserHandle);
126         this.mDisplayId = displayId;
127 
128         // onConstructed(); // You can define this method to get a callback
129     }
130 
131     @DataClass.Generated.Member
132     public static final @NonNull Parcelable.Creator<UserStartRequest> CREATOR
133             = new Parcelable.Creator<UserStartRequest>() {
134         @Override
135         public UserStartRequest[] newArray(int size) {
136             return new UserStartRequest[size];
137         }
138 
139         @Override
140         public UserStartRequest createFromParcel(@NonNull android.os.Parcel in) {
141             return new UserStartRequest(in);
142         }
143     };
144 
145     @DataClass.Generated(
146             time = 1676438036327L,
147             codegenVersion = "1.0.23",
148             sourceFile = "packages/services/Car/car-lib/src/android/car/user/UserStartRequest.java",
149             inputSignatures = "private final @android.annotation.NonNull android.os.UserHandle mUserHandle\nprivate final  int mDisplayId\nclass UserStartRequest extends java.lang.Object implements [android.os.Parcelable]\nprivate final @android.annotation.NonNull android.os.UserHandle mUserHandle\nprivate  int mDisplayId\npublic @android.car.annotation.ApiRequirements @android.annotation.NonNull android.car.user.UserStartRequest.Builder backgroundVisible(int)\npublic @android.car.annotation.ApiRequirements @android.annotation.NonNull android.car.user.UserStartRequest build()\nclass Builder extends java.lang.Object implements []\n@com.android.car.internal.util.DataClass(genParcelable=true, genConstructor=false, genAidl=true)")
150     @Deprecated
__metadata()151     private void __metadata() {}
152 
153 
154     //@formatter:on
155     // End of generated code
156 
157 }
158