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