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 current warning state of {@link
33  * android.car.VehiclePropertyIds#DRIVER_DROWSINESS_ATTENTION_WARNING}.
34  *
35  * <p>This enum could be extended in future releases to include additional feature states.
36  *
37  * @hide
38  */
39 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES)
40 @SystemApi
41 public final class DriverDrowsinessAttentionWarning {
42     /**
43      * This state is used as an alternative for any {@code DriverDrowsinessAttentionWarning} value
44      * that is not defined in the platform. Ideally, implementations of {@link
45      * android.car.VehiclePropertyIds#DRIVER_DROWSINESS_ATTENTION_WARNING} should not use this
46      * state. The framework can use this field to remain backwards compatible if {@code
47      * DriverDrowsinessAttentionWarning} is extended to include additional states.
48      */
49     public static final int OTHER = 0;
50     /**
51      * When the driver drowsiness and attention warning is enabled, and the driver's current
52      * drowsiness and attention level does not warrant the system to send a warning.
53      */
54     public static final int NO_WARNING = 1;
55     /**
56      * When the driver drowsiness and attention warning is enabled, and the system is warning the
57      * driver based on its assessment of the driver's current drowsiness and attention level.
58      */
59     public static final int WARNING = 2;
60 
DriverDrowsinessAttentionWarning()61     private DriverDrowsinessAttentionWarning() {}
62 
63     /**
64      * Returns a user-friendly representation of a {@code DriverDrowsinessAttentionWarning}.
65      */
66     @NonNull
toString( @riverDrowsinessAttentionWarning.DriverDrowsinessAttentionWarningInt int driverDrowsinessAttentionWarning)67     public static String toString(
68             @DriverDrowsinessAttentionWarning.DriverDrowsinessAttentionWarningInt
69             int driverDrowsinessAttentionWarning) {
70         String driverDrowsinessAttentionWarningString = ConstantDebugUtils.toName(
71                 DriverDrowsinessAttentionWarning.class, driverDrowsinessAttentionWarning);
72         return (driverDrowsinessAttentionWarningString != null)
73                 ? driverDrowsinessAttentionWarningString
74                 : "0x" + Integer.toHexString(driverDrowsinessAttentionWarning);
75     }
76 
77     /** @hide */
78     @IntDef({OTHER, NO_WARNING, WARNING})
79     @Retention(RetentionPolicy.SOURCE)
80     public @interface DriverDrowsinessAttentionWarningInt {}
81 }
82