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 driver state of {@link
28  * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_DRIVER_STATE}.
29  *
30  * <p>This enum could be extended in future releases to include additional feature states.
31  * @hide
32  */
33 @SystemApi
34 public class HandsOnDetectionDriverState {
35     /**
36      * This state is used as an alternative for any {@code HandsOnDetectionDriverState} value that
37      * is not defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_DRIVER_STATE} should not use this state.
39      * The framework can use this field to remain backwards compatible if {@code
40      * HandsOnDetectionDriverState} is extended to include additional states.
41      */
42     public static final int OTHER = 0;
43     /**
44      * The system detects that the driver has their hands on the steering wheel.
45      */
46     public static final int HANDS_ON = 1;
47     /**
48      * The system detects that the driver has their hands off the steering wheel.
49      */
50     public static final int HANDS_OFF = 2;
51 
HandsOnDetectionDriverState()52     private HandsOnDetectionDriverState() {}
53 
54     /**
55      * Returns a user-friendly representation of a {@code HandsOnDetectionDriverState}.
56      */
57     @NonNull
toString( @andsOnDetectionDriverStateInt int handsOnDetectionDriverState)58     public static String toString(
59             @HandsOnDetectionDriverStateInt int handsOnDetectionDriverState) {
60         switch (handsOnDetectionDriverState) {
61             case OTHER:
62                 return "OTHER";
63             case HANDS_ON:
64                 return "HANDS_ON";
65             case HANDS_OFF:
66                 return "HANDS_OFF";
67             default:
68                 return "0x" + Integer.toHexString(handsOnDetectionDriverState);
69         }
70     }
71 
72     /** @hide */
73     @IntDef({OTHER, HANDS_ON, HANDS_OFF})
74     @Retention(RetentionPolicy.SOURCE)
75     public @interface HandsOnDetectionDriverStateInt {}
76 }
77