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 state of {@link
28  * android.car.VehiclePropertyIds#EMERGENCY_LANE_KEEP_ASSIST_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 EmergencyLaneKeepAssistState {
35     /**
36      * This state is used as an alternative for any {@code EmergencyLaneKeepAssistState} value that
37      * is not defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#EMERGENCY_LANE_KEEP_ASSIST_STATE} should not use this state.
39      * The framework can use this field to remain backwards compatible if {@code
40      * EmergencyLaneKeepAssistState} is extended to include additional states.
41      */
42     public static final int OTHER = 0;
43     /**
44      * ELKA is enabled and monitoring safety, but no safety event is detected and steering assist is
45      * not activated.
46      */
47     public static final int ENABLED = 1;
48     /**
49      * ELKA is enabled and a safety event is detected. Vehicle is sending out a warning to the
50      * driver indicating that there is a dangerous maneuver on the left side of the vehicle.
51      */
52     public static final int WARNING_LEFT = 2;
53     /**
54      * ELKA is enabled and a safety event is detected. Vehicle is sending out a warning to the
55      * driver indicating that there is a dangerous maneuver on the right side of the vehicle.
56      */
57     public static final int WARNING_RIGHT = 3;
58     /**
59      * ELKA is enabled and currently has steering assist applied to the vehicle. Steering assist
60      * nudges the vehicle towards the left, which generally means the steering wheel turns counter
61      * clockwise. This is usually in response to the driver making an unsafe right lane change.
62      */
63     public static final int ACTIVATED_STEER_LEFT = 4;
64     /**
65      * ELKA is enabled and currently has steering assist applied to the vehicle. Steering assist
66      * nudges the vehicle towards the right, which generally means the steering wheel turns
67      * clockwise. This is usually in response to the driver making an unsafe left lane change.
68      */
69     public static final int ACTIVATED_STEER_RIGHT = 5;
70     /**
71      * Many safety feature implementations allow the driver to override said feature. This means
72      * that the car has determined it should take some action, but a user decides to take over and
73      * do something else. This is often done for safety reasons and to ensure that the driver can
74      * always take control of the vehicle. This state should be set when the user is currently
75      * overriding ELKA.
76      */
77     public static final int USER_OVERRIDE = 6;
78 
EmergencyLaneKeepAssistState()79     private EmergencyLaneKeepAssistState() {}
80 
81     /**
82      * Returns a user-friendly representation of an {@code EmergencyLaneKeepAssistState}.
83      */
84     @NonNull
toString( @mergencyLaneKeepAssistStateInt int emergencyLaneKeepAssistState)85     public static String toString(
86             @EmergencyLaneKeepAssistStateInt int emergencyLaneKeepAssistState) {
87         switch (emergencyLaneKeepAssistState) {
88             case OTHER:
89                 return "OTHER";
90             case ENABLED:
91                 return "ENABLED";
92             case WARNING_LEFT:
93                 return "WARNING_LEFT";
94             case WARNING_RIGHT:
95                 return "WARNING_RIGHT";
96             case ACTIVATED_STEER_LEFT:
97                 return "ACTIVATED_STEER_LEFT";
98             case ACTIVATED_STEER_RIGHT:
99                 return "ACTIVATED_STEER_RIGHT";
100             case USER_OVERRIDE:
101                 return "USER_OVERRIDE";
102             default:
103                 return "0x" + Integer.toHexString(emergencyLaneKeepAssistState);
104         }
105     }
106 
107     /** @hide */
108     @IntDef({OTHER, ENABLED, WARNING_LEFT, WARNING_RIGHT, ACTIVATED_STEER_LEFT,
109             ACTIVATED_STEER_RIGHT, USER_OVERRIDE})
110     @Retention(RetentionPolicy.SOURCE)
111     public @interface EmergencyLaneKeepAssistStateInt {}
112 }
113