• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.Nullable;
20 import android.car.annotation.ApiRequirements;
21 import android.car.annotation.ApiRequirements.CarVersion;
22 import android.car.annotation.ApiRequirements.PlatformVersion;
23 import android.car.hardware.CarPropertyValue;
24 import android.car.hardware.property.CarPropertyManager.GetPropertyRequest;
25 import android.car.hardware.property.CarPropertyManager.SetPropertyRequest;
26 import android.os.Parcelable;
27 
28 import com.android.car.internal.util.DataClass;
29 
30 /**
31  * A request for {@link CarPropertyService.getPropertiesAsync} or
32  * {@link CarPropertyService.setPropertiesAsync}
33  *
34  * @hide
35  */
36 @DataClass(genConstructor = false)
37 public final class AsyncPropertyServiceRequest implements Parcelable {
38     private final int mRequestId;
39     private final int mPropertyId;
40     private final int mAreaId;
41     // The property value to set. Ignored for get request.
42     @Nullable
43     private final CarPropertyValue mCarPropertyValue;
44     // The update rate in HZ for listening to new property update event for async set. Ignored for
45     // get request.
46     private float mUpdateRateHz;
47     // Whether to listen for property update event before calling success callback for async set.
48     // Ignored for get request.
49     private boolean mWaitForPropertyUpdate;
50 
51     /**
52      * Creates an async get request.
53      */
newGetAsyncRequest( GetPropertyRequest getPropertyRequest)54     public static AsyncPropertyServiceRequest newGetAsyncRequest(
55             GetPropertyRequest getPropertyRequest) {
56         return new AsyncPropertyServiceRequest(getPropertyRequest.getRequestId(),
57                 getPropertyRequest.getPropertyId(), getPropertyRequest.getAreaId());
58     }
59 
60     /**
61      * Creates an async set request.
62      */
newSetAsyncRequest( SetPropertyRequest setPropertyRequest)63     public static AsyncPropertyServiceRequest newSetAsyncRequest(
64             SetPropertyRequest setPropertyRequest) {
65         int propertyId = setPropertyRequest.getPropertyId();
66         int areaId = setPropertyRequest.getAreaId();
67         AsyncPropertyServiceRequest request = new AsyncPropertyServiceRequest(
68                 setPropertyRequest.getRequestId(), propertyId, areaId,
69                 new CarPropertyValue(propertyId, areaId, setPropertyRequest.getValue()));
70         request.setUpdateRateHz(setPropertyRequest.getUpdateRateHz());
71         request.setWaitForPropertyUpdate(setPropertyRequest.isWaitForPropertyUpdate());
72         return request;
73     }
74 
75     /**
76      * Creates an async get request, for test only.
77      */
AsyncPropertyServiceRequest(int requestId, int propertyId, int areaId)78     public AsyncPropertyServiceRequest(int requestId, int propertyId, int areaId) {
79         this(requestId, propertyId, areaId, /* carPropertyValue= */ null);
80     }
81 
82     /**
83      * Creates an async set request, for test only.
84      */
AsyncPropertyServiceRequest(int requestId, int propertyId, int areaId, @Nullable CarPropertyValue carPropertyValue)85     public AsyncPropertyServiceRequest(int requestId, int propertyId, int areaId,
86             @Nullable CarPropertyValue carPropertyValue) {
87         mRequestId = requestId;
88         mPropertyId = propertyId;
89         mAreaId = areaId;
90         mCarPropertyValue = carPropertyValue;
91         mWaitForPropertyUpdate = true;
92     }
93 
94     /**
95      * Sets the update rate in HZ for listening to new property update event.
96      */
setUpdateRateHz(float updateRateHz)97     public void setUpdateRateHz(float updateRateHz) {
98         mUpdateRateHz = updateRateHz;
99     }
100 
101     /**
102      * Sets whether to wait for property update before calling async set's success callback.
103      */
setWaitForPropertyUpdate(boolean waitForPropertyUpdate)104     public void setWaitForPropertyUpdate(boolean waitForPropertyUpdate) {
105         mWaitForPropertyUpdate = waitForPropertyUpdate;
106     }
107 
108 
109 
110     // Code below generated by codegen v1.0.23.
111     //
112     // DO NOT MODIFY!
113     // CHECKSTYLE:OFF Generated code
114     //
115     // To regenerate run:
116     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/com/android/car/internal/property/AsyncPropertyServiceRequest.java
117     //
118     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
119     //   Settings > Editor > Code Style > Formatter Control
120     //@formatter:off
121 
122     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
123                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
124     @DataClass.Generated.Member
getRequestId()125     public int getRequestId() {
126         return mRequestId;
127     }
128 
129     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
130                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
131     @DataClass.Generated.Member
getPropertyId()132     public int getPropertyId() {
133         return mPropertyId;
134     }
135 
136     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
137                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
138     @DataClass.Generated.Member
getAreaId()139     public int getAreaId() {
140         return mAreaId;
141     }
142 
143     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
144                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
145     @DataClass.Generated.Member
getCarPropertyValue()146     public @Nullable CarPropertyValue getCarPropertyValue() {
147         return mCarPropertyValue;
148     }
149 
150     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
151                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
152     @DataClass.Generated.Member
getUpdateRateHz()153     public float getUpdateRateHz() {
154         return mUpdateRateHz;
155     }
156 
157     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
158                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
159     @DataClass.Generated.Member
isWaitForPropertyUpdate()160     public boolean isWaitForPropertyUpdate() {
161         return mWaitForPropertyUpdate;
162     }
163 
164     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
165                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
166     @Override
167     @DataClass.Generated.Member
writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)168     public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) {
169         // You can override field parcelling by defining methods like:
170         // void parcelFieldName(Parcel dest, int flags) { ... }
171 
172         byte flg = 0;
173         if (mWaitForPropertyUpdate) flg |= 0x20;
174         if (mCarPropertyValue != null) flg |= 0x8;
175         dest.writeByte(flg);
176         dest.writeInt(mRequestId);
177         dest.writeInt(mPropertyId);
178         dest.writeInt(mAreaId);
179         if (mCarPropertyValue != null) dest.writeTypedObject(mCarPropertyValue, flags);
180         dest.writeFloat(mUpdateRateHz);
181     }
182 
183     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
184                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
185     @Override
186     @DataClass.Generated.Member
describeContents()187     public int describeContents() { return 0; }
188 
189     /** @hide */
190     @SuppressWarnings({"unchecked", "RedundantCast"})
191     @DataClass.Generated.Member
AsyncPropertyServiceRequest(@ndroid.annotation.NonNull android.os.Parcel in)192     /* package-private */ AsyncPropertyServiceRequest(@android.annotation.NonNull android.os.Parcel in) {
193         // You can override field unparcelling by defining methods like:
194         // static FieldType unparcelFieldName(Parcel in) { ... }
195 
196         byte flg = in.readByte();
197         boolean waitForPropertyUpdate = (flg & 0x20) != 0;
198         int requestId = in.readInt();
199         int propertyId = in.readInt();
200         int areaId = in.readInt();
201         CarPropertyValue carPropertyValue = (flg & 0x8) == 0 ? null : (CarPropertyValue) in.readTypedObject(CarPropertyValue.CREATOR);
202         float updateRateHz = in.readFloat();
203 
204         this.mRequestId = requestId;
205         this.mPropertyId = propertyId;
206         this.mAreaId = areaId;
207         this.mCarPropertyValue = carPropertyValue;
208         this.mUpdateRateHz = updateRateHz;
209         this.mWaitForPropertyUpdate = waitForPropertyUpdate;
210 
211         // onConstructed(); // You can define this method to get a callback
212     }
213 
214     @ApiRequirements(minCarVersion = CarVersion.UPSIDE_DOWN_CAKE_0,
215                      minPlatformVersion = PlatformVersion.TIRAMISU_0)
216     @DataClass.Generated.Member
217     public static final @android.annotation.NonNull Parcelable.Creator<AsyncPropertyServiceRequest> CREATOR
218             = new Parcelable.Creator<AsyncPropertyServiceRequest>() {
219         @Override
220         public AsyncPropertyServiceRequest[] newArray(int size) {
221             return new AsyncPropertyServiceRequest[size];
222         }
223 
224         @Override
225         public AsyncPropertyServiceRequest createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
226             return new AsyncPropertyServiceRequest(in);
227         }
228     };
229 
230     @DataClass.Generated(
231             time = 1678739854323L,
232             codegenVersion = "1.0.23",
233             sourceFile = "packages/services/Car/car-lib/src/com/android/car/internal/property/AsyncPropertyServiceRequest.java",
234             inputSignatures = "private final  int mRequestId\nprivate final  int mPropertyId\nprivate final  int mAreaId\nprivate final @android.annotation.Nullable android.car.hardware.CarPropertyValue mCarPropertyValue\nprivate  float mUpdateRateHz\nprivate  boolean mWaitForPropertyUpdate\npublic static  com.android.car.internal.property.AsyncPropertyServiceRequest newGetAsyncRequest(android.car.hardware.Property.GetPropertyRequest)\npublic static  com.android.car.internal.property.AsyncPropertyServiceRequest newSetAsyncRequest(setPropertyRequest)\npublic  void setUpdateRateHz(float)\npublic  void setWaitForPropertyUpdate(boolean)\nclass AsyncPropertyServiceRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genConstructor=false)")
235     @Deprecated
__metadata()236     private void __metadata() {}
237 
238 
239     //@formatter:on
240     // End of generated code
241 
242 }
243