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#CRUISE_CONTROL_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 CruiseControlState { 35 /** 36 * This state is used as an alternative for any {@code CruiseControlState} value that is not 37 * defined in the platform. Ideally, implementations of {@link 38 * android.car.VehiclePropertyIds#CRUISE_CONTROL_STATE} should not use this state. The framework 39 * can use this field to remain backwards compatible if {@code CruiseControlState} is extended 40 * to include additional states. 41 */ 42 public static final int OTHER = 0; 43 /** 44 * CC is enabled, but the ADAS system is not actively controlling the vehicle's speed. 45 */ 46 public static final int ENABLED = 1; 47 /** 48 * CC is enabled and activated, so the ADAS system is actively controlling the vehicle's speed. 49 */ 50 public static final int ACTIVATED = 2; 51 /** 52 * Most CC implementations allow the driver to override CC. This means that the car has 53 * determined it should maintain a certain speed and/or maintain a certain distance from a 54 * leading vehicle, but the driver decides to take over and do something else. This is often 55 * done for safety reasons and to ensure that the driver can always take control of the vehicle. 56 * This state will be set when the user is actively overriding the CC system. 57 */ 58 public static final int USER_OVERRIDE = 3; 59 /** 60 * Suspended state indicates CC is enabled and was activated, but now is suspended. This could 61 * be caused by the user tapping the brakes while CC is {@link #ACTIVATED} or the user using the 62 * {@link android.car.VehiclePropertyIds#CRUISE_CONTROL_COMMAND} to suspend CC. Once CC is 63 * suspended, the CC system gives control of the vehicle back to the driver, but saves the 64 * target speed and/or target time gap settings in case CC is resumed. This state can also be 65 * used when adaptive/predictive CC slows to a stop and needs a user signal to start again. 66 */ 67 public static final int SUSPENDED = 4; 68 /** 69 * When CC is in the {@link #ACTIVATED} state but may potentially need to deactivate because of 70 * external conditions (e.g. roads curvature is too extreme, the driver does not have their 71 * hands on the steering wheel for a long period of time, or the driver is not paying 72 * attention), then the ADAS system will notify the driver of a potential need to deactivate and 73 * give control back to the driver. 74 */ 75 public static final int FORCED_DEACTIVATION_WARNING = 5; 76 CruiseControlState()77 private CruiseControlState() {} 78 79 /** 80 * Returns a user-friendly representation of a {@code CruiseControlState}. 81 */ 82 @NonNull toString( @ruiseControlState.CruiseControlStateInt int cruiseControlState)83 public static String toString( 84 @CruiseControlState.CruiseControlStateInt int cruiseControlState) { 85 switch (cruiseControlState) { 86 case OTHER: 87 return "OTHER"; 88 case ENABLED: 89 return "ENABLED"; 90 case ACTIVATED: 91 return "ACTIVATED"; 92 case USER_OVERRIDE: 93 return "USER_OVERRIDE"; 94 case SUSPENDED: 95 return "SUSPENDED"; 96 case FORCED_DEACTIVATION_WARNING: 97 return "FORCED_DEACTIVATION_WARNING"; 98 default: 99 return "0x" + Integer.toHexString(cruiseControlState); 100 } 101 } 102 103 /** @hide */ 104 @IntDef({OTHER, ENABLED, ACTIVATED, USER_OVERRIDE, SUSPENDED, FORCED_DEACTIVATION_WARNING}) 105 @Retention(RetentionPolicy.SOURCE) 106 public @interface CruiseControlStateInt {} 107 } 108