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