• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 
26 /**
27  * Used to enumerate the current warning state of {@link
28  * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_WARNING}.
29  *
30  * <p>This enum could be extended in future releases to include additional feature states.
31  * @hide
32  */
33 @SystemApi
34 public class HandsOnDetectionWarning {
35     /**
36      * This state is used as an alternative for any {@code HandsOnDetectionWarning} value that is
37      * not defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_WARNING} should not use this state. The
39      * framework can use this field to remain backwards compatible if {@code
40      * HandsOnDetectionWarning} is extended to include additional states.
41      */
42     public static final int OTHER = 0;
43     /**
44      * HOD is enabled and the driver's current safety does not warrant sending a warning. This state
45      * is independent of whether the driver actually has their hands on or off the wheel.
46      */
47     public static final int NO_WARNING = 1;
48     /**
49      * HOD is enabled and the driver's hands have been off the wheel for too long a duration, and
50      * the vehicle is sending a warning to the driver as a consequence of this.
51      */
52     public static final int WARNING = 2;
53 
HandsOnDetectionWarning()54     private HandsOnDetectionWarning() {}
55 
56     /**
57      * Returns a user-friendly representation of a {@code HandsOnDetectionWarning}.
58      */
59     @NonNull
toString( @andsOnDetectionWarning.HandsOnDetectionWarningInt int handsOnDetectionWarning)60     public static String toString(
61             @HandsOnDetectionWarning.HandsOnDetectionWarningInt int handsOnDetectionWarning) {
62         switch (handsOnDetectionWarning) {
63             case OTHER:
64                 return "OTHER";
65             case NO_WARNING:
66                 return "NO_WARNING";
67             case WARNING:
68                 return "WARNING";
69             default:
70                 return "0x" + Integer.toHexString(handsOnDetectionWarning);
71         }
72     }
73 
74     /** @hide */
75     @IntDef({OTHER, NO_WARNING, WARNING})
76     @Retention(RetentionPolicy.SOURCE)
77     public @interface HandsOnDetectionWarningInt {}
78 }
79