/* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.car.internal.property; import android.annotation.NonNull; import android.annotation.Nullable; import android.car.hardware.CarPropertyValue; import android.os.Parcel; import android.os.Parcelable; import com.android.car.internal.util.AnnotationValidations; import com.android.car.internal.util.DataClass; /** * A request for {@link com.android.car.CarPropertyService#getPropertiesAsync} * * @hide */ @DataClass(genConstructor = false) public final class GetSetValueResult implements Parcelable { private final int mRequestId; // Result for async getProperty, ignored for setProperty. @Nullable private final CarPropertyValue mCarPropertyValue; // Only useful for setProperty, ignored for getProperty. private final long mUpdateTimestampNanos; @NonNull private final CarPropertyErrorCodes mCarPropertyErrorCodes; private GetSetValueResult(int requestId, @Nullable CarPropertyValue carPropertyValue, @NonNull CarPropertyErrorCodes carPropertyErrorCodes, long updateTimestampNanos) { mRequestId = requestId; mCarPropertyValue = carPropertyValue; mUpdateTimestampNanos = updateTimestampNanos; mCarPropertyErrorCodes = carPropertyErrorCodes; } /** * Creates an async get property result. */ public static GetSetValueResult newGetValueResult(int requestId, CarPropertyValue carPropertyValue) { CarPropertyErrorCodes carPropertyErrorCodes = CarPropertyErrorCodes.STATUS_OK_NO_ERROR; return new GetSetValueResult(requestId, carPropertyValue, carPropertyErrorCodes, /* updateTimestampNanos= */ 0); } /** * Creates an async error property result. */ public static GetSetValueResult newErrorResult(int requestId, @NonNull CarPropertyErrorCodes carPropertyErrorCodes) { return new GetSetValueResult(requestId, /* carPropertyValue= */ null, carPropertyErrorCodes, /* updateTimestampNanos= */ 0); } /** * Creates an async set property result. */ public static GetSetValueResult newSetValueResult(int requestId, long updateTimestampNanos) { CarPropertyErrorCodes carPropertyErrorCodes = CarPropertyErrorCodes.STATUS_OK_NO_ERROR; return new GetSetValueResult(requestId, /* carPropertyValue= */ null, carPropertyErrorCodes, updateTimestampNanos); } /** * Creates an async error set property result. */ public static GetSetValueResult newErrorSetValueResult(int requestId, @NonNull CarPropertyErrorCodes carPropertyErrorCodes) { return new GetSetValueResult(requestId, /* carPropertyValue= */ null, carPropertyErrorCodes, /* updateTimestampNanos= */ 0); } // Code below generated by codegen v1.0.23. // // DO NOT MODIFY! // CHECKSTYLE:OFF Generated code // // To regenerate run: // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/com/android/car/internal/property/GetSetValueResult.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control //@formatter:off @DataClass.Generated.Member public int getRequestId() { return mRequestId; } @DataClass.Generated.Member public @Nullable CarPropertyValue getCarPropertyValue() { return mCarPropertyValue; } @DataClass.Generated.Member public long getUpdateTimestampNanos() { return mUpdateTimestampNanos; } @DataClass.Generated.Member public @NonNull CarPropertyErrorCodes getCarPropertyErrorCodes() { return mCarPropertyErrorCodes; } @Override @DataClass.Generated.Member public void writeToParcel(@NonNull Parcel dest, int flags) { // You can override field parcelling by defining methods like: // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; if (mCarPropertyValue != null) flg |= 0x2; dest.writeByte(flg); dest.writeInt(mRequestId); if (mCarPropertyValue != null) dest.writeTypedObject(mCarPropertyValue, flags); dest.writeLong(mUpdateTimestampNanos); dest.writeTypedObject(mCarPropertyErrorCodes, flags); } @Override @DataClass.Generated.Member public int describeContents() { return 0; } /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @DataClass.Generated.Member /* package-private */ GetSetValueResult(@NonNull Parcel in) { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } byte flg = in.readByte(); int requestId = in.readInt(); CarPropertyValue carPropertyValue = (flg & 0x2) == 0 ? null : (CarPropertyValue) in.readTypedObject(CarPropertyValue.CREATOR); long updateTimestampNanos = in.readLong(); CarPropertyErrorCodes carPropertyErrorCodes = (CarPropertyErrorCodes) in.readTypedObject(CarPropertyErrorCodes.CREATOR); this.mRequestId = requestId; this.mCarPropertyValue = carPropertyValue; this.mUpdateTimestampNanos = updateTimestampNanos; this.mCarPropertyErrorCodes = carPropertyErrorCodes; AnnotationValidations.validate( NonNull.class, null, mCarPropertyErrorCodes); // onConstructed(); // You can define this method to get a callback } @DataClass.Generated.Member public static final @NonNull Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public GetSetValueResult[] newArray(int size) { return new GetSetValueResult[size]; } @Override public GetSetValueResult createFromParcel(@NonNull Parcel in) { return new GetSetValueResult(in); } }; @DataClass.Generated( time = 1707958964110L, codegenVersion = "1.0.23", sourceFile = "packages/services/Car/car-lib/src/com/android/car/internal/property/GetSetValueResult.java", 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)") @Deprecated private void __metadata() {} //@formatter:on // End of generated code }