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#LANE_CENTERING_ASSIST_STATE}.
29  *
30  * <p>This list of states may be extended in future releases to include additional states.
31  * @hide
32  */
33 @SystemApi
34 public final class LaneCenteringAssistState {
35     /**
36      * This state is used as an alternative for any {@code LaneCenteringAssistState} value that is
37      * not defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#LANE_CENTERING_ASSIST_STATE} should not use this state. The
39      * framework can use this field to remain backwards compatible if {@code
40      * LaneCenteringAssistState} is extended to include additional states.
41      */
42     public static final int OTHER = 0;
43 
44     /**
45      * LCA is enabled but the ADAS system has not received an activation signal from the driver.
46      * Therefore, LCA is not steering the car and waits for the driver to send an {@link
47      * LaneCenteringAssistCommand#ACTIVATE} command.
48      */
49     public static final int ENABLED = 1;
50 
51     /**
52      * LCA is enabled and the driver has sent an activation command to the LCA system, but the
53      * system has not started actively steering the vehicle. This may happen when LCA needs time to
54      * detect valid lane lines. The activation command can be sent through the {@link
55      * android.car.VehiclePropertyIds#LANE_CENTERING_ASSIST_COMMAND} vehicle property or through a
56      * system external to Android. Once LCA is actively steering the vehicle, the state will be
57      * updated to {@link #ACTIVATED}. If the feature is not able to activate, then the cause can be
58      * communicated through the {@link ErrorState} values and then return to the {@link #ENABLED}
59      * state.
60      */
61     public static final int ACTIVATION_REQUESTED = 2;
62 
63     /**
64      * LCA is enabled and actively steering the car to keep it centered in its lane.
65      */
66     public static final int ACTIVATED = 3;
67 
68     /**
69      * Many LCA implementations allow the driver to override LCA. This means that the car has
70      * determined it should go a certain direction to keep the car centered in the lane, but a user
71      * decides to take over and do something else. This is often done for safety reasons and to
72      * ensure that the driver can always take control of the vehicle. This state should be set when
73      * the user is actively overriding the LCA system.
74      */
75     public static final int USER_OVERRIDE = 4;
76 
77     /**
78      * When LCA is in the {@link #ACTIVATED} state but it will potentially need to deactivate
79      * because of external conditions (e.g. roads curvature is too extreme, the driver does not have
80      * their hands on the steering wheel for a long period of time, or the driver is not paying
81      * attention), then the ADAS system will notify the driver of a potential need to deactivate and
82      * give control back to the driver.
83      */
84     public static final int FORCED_DEACTIVATION_WARNING = 5;
85 
LaneCenteringAssistState()86     private LaneCenteringAssistState() {}
87 
88     /**
89      * Returns a user-friendly representation of a {@code LaneCenteringAssistState}.
90      */
91     @NonNull
toString( @aneCenteringAssistStateInt int laneCenteringAssistState)92     public static String toString(
93             @LaneCenteringAssistStateInt int laneCenteringAssistState) {
94         switch (laneCenteringAssistState) {
95             case OTHER:
96                 return "OTHER";
97             case ENABLED:
98                 return "ENABLED";
99             case ACTIVATION_REQUESTED:
100                 return "ACTIVATION_REQUESTED";
101             case ACTIVATED:
102                 return "ACTIVATED";
103             case USER_OVERRIDE:
104                 return "USER_OVERRIDE";
105             case FORCED_DEACTIVATION_WARNING:
106                 return "FORCED_DEACTIVATION_WARNING";
107             default:
108                 return "0x" + Integer.toHexString(laneCenteringAssistState);
109         }
110     }
111 
112     /** @hide */
113     @IntDef({OTHER, ENABLED, ACTIVATION_REQUESTED, ACTIVATED, USER_OVERRIDE,
114             FORCED_DEACTIVATION_WARNING})
115     @Retention(RetentionPolicy.SOURCE)
116     public @interface LaneCenteringAssistStateInt {}
117 }
118 
119