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 android.car.hardware.property;
18 
19 import static android.car.feature.Flags.FLAG_ANDROID_VIC_VEHICLE_PROPERTIES;
20 
21 import android.annotation.FlaggedApi;
22 import android.annotation.IntDef;
23 import android.annotation.NonNull;
24 import android.annotation.SystemApi;
25 
26 import com.android.car.internal.util.ConstantDebugUtils;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * Used to enumerate the state of {@link
33  * android.car.VehiclePropertyIds#ELECTRONIC_STABILITY_CONTROL_STATE}
34  *
35  * @hide
36  */
37 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES)
38 @SystemApi
39 public final class ElectronicStabilityControlState {
40 
41     /**
42      * This state is used as an alternative to any {@code ElectronicStabilityControlState} value
43      * that is not defined in the platform. Ideally, implementations of {@link
44      * android.car.VehiclePropertyIds#ELECTRONIC_STABILITY_CONTROL_STATE} should not use this state.
45      * The framework can use this field to remain backwards compatible if {@code
46      * ElectronicStabilityControlState} is extended to include additional states.
47      */
48     public static final int OTHER = 0;
49     /**
50      * ESC is enabled and monitoring safety, but is not actively controlling the tires to prevent
51      * the car from skidding.
52      */
53     public static final int ENABLED = 1;
54     /**
55      * ESC is enabled and is actively controlling the tires to prevent the car from skidding.
56      */
57     public static final int ACTIVATED = 2;
58 
ElectronicStabilityControlState()59     private ElectronicStabilityControlState() {}
60 
61     /**
62      * Returns a user-friendly representation of {@code ElectronicStabilityControlState}.
63      */
64     @NonNull
toString( @lectronicStabilityControlStateInt int electronicStabilityControlState)65     public static String toString(
66             @ElectronicStabilityControlStateInt int electronicStabilityControlState) {
67         String electronicStabilityControlStateString = ConstantDebugUtils.toName(
68                 ElectronicStabilityControlState.class, electronicStabilityControlState);
69         return (electronicStabilityControlStateString != null)
70                 ? electronicStabilityControlStateString
71                 : "0x" + Integer.toHexString(electronicStabilityControlState);
72     }
73 
74     /** @hide */
75     @IntDef({OTHER, ENABLED, ACTIVATED})
76     @Retention(RetentionPolicy.SOURCE)
77     public @interface ElectronicStabilityControlStateInt {}
78 }
79