• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.car.internal.property;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.car.hardware.CarPropertyValue;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import com.android.car.internal.util.AnnotationValidations;
26 import com.android.car.internal.util.DataClass;
27 
28 /**
29  * A request for {@link com.android.car.CarPropertyService#getPropertiesAsync}
30  */
31 @DataClass(genConstructor = false)
32 public final class GetSetValueResult implements Parcelable {
33     private final int mRequestId;
34     // Result for async getProperty, ignored for setProperty.
35     @Nullable
36     private final CarPropertyValue mCarPropertyValue;
37     // Only useful for setProperty, ignored for getProperty.
38     private final long mUpdateTimestampNanos;
39     @NonNull
40     private final CarPropertyErrorCodes mCarPropertyErrorCodes;
41 
GetSetValueResult(int requestId, @Nullable CarPropertyValue carPropertyValue, @NonNull CarPropertyErrorCodes carPropertyErrorCodes, long updateTimestampNanos)42     private GetSetValueResult(int requestId, @Nullable CarPropertyValue carPropertyValue,
43             @NonNull CarPropertyErrorCodes carPropertyErrorCodes, long updateTimestampNanos) {
44         mRequestId = requestId;
45         mCarPropertyValue = carPropertyValue;
46         mUpdateTimestampNanos = updateTimestampNanos;
47         mCarPropertyErrorCodes = carPropertyErrorCodes;
48     }
49 
50     /**
51      * Creates an async get property result.
52      */
newGetValueResult(int requestId, CarPropertyValue carPropertyValue)53     public static GetSetValueResult newGetValueResult(int requestId,
54             CarPropertyValue carPropertyValue) {
55         CarPropertyErrorCodes carPropertyErrorCodes = CarPropertyErrorCodes.STATUS_OK_NO_ERROR;
56         return new GetSetValueResult(requestId, carPropertyValue,
57                 carPropertyErrorCodes, /* updateTimestampNanos= */ 0);
58     }
59 
60     /**
61      * Creates an async error property result.
62      */
newErrorResult(int requestId, @NonNull CarPropertyErrorCodes carPropertyErrorCodes)63     public static GetSetValueResult newErrorResult(int requestId,
64             @NonNull CarPropertyErrorCodes carPropertyErrorCodes) {
65         return new GetSetValueResult(requestId, /* carPropertyValue= */ null,
66                 carPropertyErrorCodes, /* updateTimestampNanos= */ 0);
67     }
68 
69     /**
70      * Creates an async set property result.
71      */
newSetValueResult(int requestId, long updateTimestampNanos)72     public static GetSetValueResult newSetValueResult(int requestId,
73             long updateTimestampNanos) {
74         CarPropertyErrorCodes carPropertyErrorCodes = CarPropertyErrorCodes.STATUS_OK_NO_ERROR;
75         return new GetSetValueResult(requestId, /* carPropertyValue= */ null,
76                 carPropertyErrorCodes, updateTimestampNanos);
77     }
78 
79     /**
80      * Creates an async error set property result.
81      */
newErrorSetValueResult(int requestId, @NonNull CarPropertyErrorCodes carPropertyErrorCodes)82     public static GetSetValueResult newErrorSetValueResult(int requestId,
83             @NonNull CarPropertyErrorCodes carPropertyErrorCodes) {
84         return new GetSetValueResult(requestId, /* carPropertyValue= */ null,
85                 carPropertyErrorCodes, /* updateTimestampNanos= */ 0);
86     }
87 
88 
89 
90     // Code below generated by codegen v1.0.23.
91     //
92     // DO NOT MODIFY!
93     // CHECKSTYLE:OFF Generated code
94     //
95     // To regenerate run:
96     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/com/android/car/internal/property/GetSetValueResult.java
97     //
98     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
99     //   Settings > Editor > Code Style > Formatter Control
100     //@formatter:off
101 
102 
103     @DataClass.Generated.Member
getRequestId()104     public int getRequestId() {
105         return mRequestId;
106     }
107 
108     @DataClass.Generated.Member
getCarPropertyValue()109     public @Nullable CarPropertyValue getCarPropertyValue() {
110         return mCarPropertyValue;
111     }
112 
113     @DataClass.Generated.Member
getUpdateTimestampNanos()114     public long getUpdateTimestampNanos() {
115         return mUpdateTimestampNanos;
116     }
117 
118     @DataClass.Generated.Member
getCarPropertyErrorCodes()119     public @NonNull CarPropertyErrorCodes getCarPropertyErrorCodes() {
120         return mCarPropertyErrorCodes;
121     }
122 
123     @Override
124     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)125     public void writeToParcel(@NonNull Parcel dest, int flags) {
126         // You can override field parcelling by defining methods like:
127         // void parcelFieldName(Parcel dest, int flags) { ... }
128 
129         byte flg = 0;
130         if (mCarPropertyValue != null) flg |= 0x2;
131         dest.writeByte(flg);
132         dest.writeInt(mRequestId);
133         if (mCarPropertyValue != null) dest.writeTypedObject(mCarPropertyValue, flags);
134         dest.writeLong(mUpdateTimestampNanos);
135         dest.writeTypedObject(mCarPropertyErrorCodes, flags);
136     }
137 
138     @Override
139     @DataClass.Generated.Member
describeContents()140     public int describeContents() { return 0; }
141 
142     @SuppressWarnings({"unchecked", "RedundantCast"})
143     @DataClass.Generated.Member
GetSetValueResult(@onNull Parcel in)144     /* package-private */ GetSetValueResult(@NonNull Parcel in) {
145         // You can override field unparcelling by defining methods like:
146         // static FieldType unparcelFieldName(Parcel in) { ... }
147 
148         byte flg = in.readByte();
149         int requestId = in.readInt();
150         CarPropertyValue carPropertyValue = (flg & 0x2) == 0 ? null : (CarPropertyValue) in.readTypedObject(CarPropertyValue.CREATOR);
151         long updateTimestampNanos = in.readLong();
152         CarPropertyErrorCodes carPropertyErrorCodes = (CarPropertyErrorCodes) in.readTypedObject(CarPropertyErrorCodes.CREATOR);
153 
154         this.mRequestId = requestId;
155         this.mCarPropertyValue = carPropertyValue;
156         this.mUpdateTimestampNanos = updateTimestampNanos;
157         this.mCarPropertyErrorCodes = carPropertyErrorCodes;
158         AnnotationValidations.validate(
159                 NonNull.class, null, mCarPropertyErrorCodes);
160 
161         // onConstructed(); // You can define this method to get a callback
162     }
163 
164     @DataClass.Generated.Member
165     public static final @NonNull Parcelable.Creator<GetSetValueResult> CREATOR
166             = new Parcelable.Creator<GetSetValueResult>() {
167         @Override
168         public GetSetValueResult[] newArray(int size) {
169             return new GetSetValueResult[size];
170         }
171 
172         @Override
173         public GetSetValueResult createFromParcel(@NonNull Parcel in) {
174             return new GetSetValueResult(in);
175         }
176     };
177 
178     @DataClass.Generated(
179             time = 1707958964110L,
180             codegenVersion = "1.0.23",
181             sourceFile = "packages/services/Car/car-lib/src/com/android/car/internal/property/GetSetValueResult.java",
182             inputSignatures = "private final  int mRequestId\nprivate final @android.annotation.Nullable android.car.hardware.CarPropertyValue mCarPropertyValue\nprivate final  long mUpdateTimestampNanos\nprivate final @android.annotation.NonNull com.android.car.internal.property.CarPropertyErrorCodes mCarPropertyErrorCodes\npublic static  com.android.car.internal.property.GetSetValueResult newGetValueResult(int,android.car.hardware.CarPropertyValue)\npublic static  com.android.car.internal.property.GetSetValueResult newErrorResult(int,com.android.car.internal.property.CarPropertyErrorCodes)\npublic static  com.android.car.internal.property.GetSetValueResult newSetValueResult(int,long)\npublic static  com.android.car.internal.property.GetSetValueResult newErrorSetValueResult(int,com.android.car.internal.property.CarPropertyErrorCodes)\nclass GetSetValueResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genConstructor=false)")
183     @Deprecated
__metadata()184     private void __metadata() {}
185 
186 
187     //@formatter:on
188     // End of generated code
189 
190 }
191