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 by {@link android.car.VehiclePropertyIds#CRUISE_CONTROL_COMMAND} to enumerate commands. 28 * 29 * <p>This enum could be extended in future releases to include additional feature states. 30 * @hide 31 */ 32 @SystemApi 33 public class CruiseControlCommand { 34 /** 35 * Activate cruise control, which means CC takes control of maintaining the vehicle's target 36 * speed without the driver having to keep their foot on the accelerator. The target speed for 37 * CC is generally set to the vehicle's speed at the time of activation. 38 */ 39 public static final int ACTIVATE = 1; 40 /** 41 * Suspend cruise control, but still keep it enabled. Once CC is activated again, the 42 * target speed should resume to the previous setting. 43 */ 44 public static final int SUSPEND = 2; 45 /** 46 * Increase the target speed when CC is activated. The increment value should be decided by the 47 * OEM. The updated value can be read from {@link 48 * android.car.VehiclePropertyIds#CRUISE_CONTROL_TARGET_SPEED}. 49 */ 50 public static final int INCREASE_TARGET_SPEED = 3; 51 /** 52 * Decrease the target speed when CC is activated. The decrement value should be decided by the 53 * OEM. The updated value can be read from {@link 54 * android.car.VehiclePropertyIds#CRUISE_CONTROL_TARGET_SPEED}. 55 */ 56 public static final int DECREASE_TARGET_SPEED = 4; 57 /** 58 * Increase the target time gap or distance from the vehicle ahead when adaptive/predictive CC 59 * is activated. The increment value should be decided by the OEM. The updated value can be read 60 * from {@link android.car.VehiclePropertyIds#ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP}. Writing 61 * this command to a standard CC vehicle should throw a {@link PropertyNotAvailableException}. 62 */ 63 public static final int INCREASE_TARGET_TIME_GAP = 5; 64 /** 65 * Decrease the target time gap or distance from the vehicle ahead when adaptive/predictive CC 66 * is activated. The decrement value should be decided by the 0EM. The updated value can be read 67 * from {@link android.car.VehiclePropertyIds#ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP}. Writing 68 * this command to a standard CC vehicle should throw a {@link PropertyNotAvailableException}. 69 */ 70 public static final int DECREASE_TARGET_TIME_GAP = 6; 71 72 CruiseControlCommand()73 private CruiseControlCommand() {} 74 75 /** 76 * Returns a user-friendly representation of a {@code CruiseControlCommand}. 77 */ 78 @NonNull toString( @ruiseControlCommand.CruiseControlCommandInt int cruiseControlCommand)79 public static String toString( 80 @CruiseControlCommand.CruiseControlCommandInt int cruiseControlCommand) { 81 switch (cruiseControlCommand) { 82 case ACTIVATE: 83 return "ACTIVATE"; 84 case SUSPEND: 85 return "SUSPEND"; 86 case INCREASE_TARGET_SPEED: 87 return "INCREASE_TARGET_SPEED"; 88 case DECREASE_TARGET_SPEED: 89 return "DECREASE_TARGET_SPEED"; 90 case INCREASE_TARGET_TIME_GAP: 91 return "INCREASE_TARGET_TIME_GAP"; 92 case DECREASE_TARGET_TIME_GAP: 93 return "DECREASE_TARGET_TIME_GAP"; 94 default: 95 return "0x" + Integer.toHexString(cruiseControlCommand); 96 } 97 } 98 99 /** @hide */ 100 @IntDef({ACTIVATE, SUSPEND, INCREASE_TARGET_SPEED, DECREASE_TARGET_SPEED, 101 INCREASE_TARGET_TIME_GAP, DECREASE_TARGET_TIME_GAP}) 102 @Retention(RetentionPolicy.SOURCE) 103 public @interface CruiseControlCommandInt {} 104 } 105