• 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 state of {@link
28  * android.car.VehiclePropertyIds#AUTOMATIC_EMERGENCY_BRAKING_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 AutomaticEmergencyBrakingState {
35     /**
36      * This state is used as an alternative for any {@code AutomaticEmergencyBrakingState} value
37      * that is not defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#AUTOMATIC_EMERGENCY_BRAKING_STATE} should not use this state.
39      * The framework can use this field to remain backwards compatible if {@code
40      * AutomaticEmergencyBrakingState} is extended to include additional states.
41      */
42     public static final int OTHER = 0;
43 
44     /**
45      * AEB is enabled and monitoring safety, but brakes are not activated.
46      */
47     public static final int ENABLED = 1;
48 
49     /**
50      * AEB is enabled and currently has the brakes applied for the vehicle.
51      */
52     public static final int ACTIVATED = 2;
53 
54     /**
55      * Many AEB implementations allow the driver to override AEB. This means that the car has
56      * determined it should brake, but a user decides to take over and do something else. This is
57      * often done for safety reasons and to ensure that the driver can always take control of the
58      * vehicle. This state should be set when the user is actively overriding the AEB system.
59      */
60     public static final int USER_OVERRIDE = 3;
61 
AutomaticEmergencyBrakingState()62     private AutomaticEmergencyBrakingState() {}
63 
64     /**
65      * Returns a user-friendly representation of an {@code AutomaticEmergencyBrakingState}.
66      */
67     @NonNull
toString( @utomaticEmergencyBrakingStateInt int automaticEmergencyBrakingState)68     public static String toString(
69             @AutomaticEmergencyBrakingStateInt int automaticEmergencyBrakingState) {
70         switch (automaticEmergencyBrakingState) {
71             case OTHER:
72                 return "OTHER";
73             case ENABLED:
74                 return "ENABLED";
75             case ACTIVATED:
76                 return "ACTIVATED";
77             case USER_OVERRIDE:
78                 return "USER_OVERRIDE";
79             default:
80                 return "0x" + Integer.toHexString(automaticEmergencyBrakingState);
81         }
82     }
83 
84     /** @hide */
85     @IntDef({OTHER, ENABLED, ACTIVATED, USER_OVERRIDE})
86     @Retention(RetentionPolicy.SOURCE)
87     public @interface AutomaticEmergencyBrakingStateInt {}
88 }
89 
90