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 state of {@link
33  * android.car.VehiclePropertyIds#DRIVER_DISTRACTION_STATE}.
34  *
35  * <p>This list of states may be extended in future releases to include additional states.
36  *
37  * @hide
38  */
39 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES)
40 @SystemApi
41 public final class DriverDistractionState {
42     /**
43      * This state is used as an alternative for any {@code DriverDistractionState} value
44      * that is not defined in the platform. Ideally, implementations of {@link
45      * android.car.VehiclePropertyIds#DRIVER_DISTRACTION_STATE} should not use this state.
46      * The framework can use this field to remain backwards compatible if {@code
47      * DriverDistractionState} is extended to include additional states.
48      */
49     public static final int OTHER = 0;
50 
51     /**
52      * The system detects that the driver is attentive / not distracted.
53      */
54     public static final int NOT_DISTRACTED = 1;
55 
56     /**
57      * The system detects that the driver is distracted, which can be anything that
58      * reduces the driver's foucs on the primary task of driving/controlling the
59      * vehicle.
60      */
61     public static final int DISTRACTED = 2;
62 
DriverDistractionState()63     private DriverDistractionState() {}
64 
65     /**
66      * Returns a user-friendly representation of a {@code DriverDistractionState}.
67      */
68     @NonNull
toString( @riverDistractionStateInt int driverDistractionState)69     public static String toString(
70             @DriverDistractionStateInt int driverDistractionState) {
71         String driverDistractionStateString = ConstantDebugUtils.toName(
72                 DriverDistractionState.class, driverDistractionState);
73         return (driverDistractionStateString != null)
74                 ? driverDistractionStateString
75                 : "0x" + Integer.toHexString(driverDistractionState);
76     }
77 
78     /** @hide */
79     @IntDef({
80         OTHER,
81         NOT_DISTRACTED,
82         DISTRACTED})
83     @Retention(RetentionPolicy.SOURCE)
84     public @interface DriverDistractionStateInt {}
85 }
86