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 static android.car.feature.Flags.FLAG_ANDROID_VIC_VEHICLE_PROPERTIES; 20 21 import android.annotation.FlaggedApi; 22 import android.annotation.IntDef; 23 import android.annotation.NonNull; 24 import android.annotation.SystemApi; 25 26 import com.android.car.internal.util.ConstantDebugUtils; 27 28 import java.lang.annotation.Retention; 29 import java.lang.annotation.RetentionPolicy; 30 31 /** 32 * Used to enumerate the state of {@link 33 * android.car.VehiclePropertyIds#LOW_SPEED_AUTOMATIC_EMERGENCY_BRAKING_STATE}. 34 * 35 * @hide 36 */ 37 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES) 38 @SystemApi 39 public final class LowSpeedAutomaticEmergencyBrakingState { 40 41 /** 42 * This state is used as an alternative to any {@code LowSpeedAutomaticEmergencyBrakingState} 43 * value that is not defined in the platform. Ideally, implementations of 44 * {@link android.car.VehiclePropertyIds#LOW_SPEED_AUTOMATIC_EMERGENCY_BRAKING_STATE} should not 45 * use this state. The framework can use this field to remain backwards compatible if 46 * {@code LowSpeedAutomaticEmergencyBrakingState} is extended to include additional states. 47 */ 48 public static final int OTHER = 0; 49 /** 50 * Low Speed Automatic Emergency Braking is enabled and monitoring safety, but brakes are not 51 * activated. 52 */ 53 public static final int ENABLED = 1; 54 /** 55 * Low Speed Automatic Emergency Braking is enabled and currently has the brakes applied for the 56 * vehicle. 57 */ 58 public static final int ACTIVATED = 2; 59 /** 60 * Many Low Speed Automatic Emergency Braking implementations allow the driver to override Low 61 * Speed Automatic Emergency Braking. This means that the car has determined it should brake, 62 * but a user decides to take over and do something else. This is often done for safety reasons 63 * and to ensure that the driver can always take control of the vehicle. This state should be 64 * set when the user is actively overriding the low speed automatic emergency braking system. 65 */ 66 public static final int USER_OVERRIDE = 3; 67 LowSpeedAutomaticEmergencyBrakingState()68 private LowSpeedAutomaticEmergencyBrakingState() {} 69 70 /** 71 * Returns a user-friendly representation of {@code LowSpeedAutomaticEmergencyBrakingState}. 72 */ 73 @NonNull toString( @owSpeedAutomaticEmergencyBrakingStateInt int lowSpeedAutomaticEmergencyBrakingState)74 public static String toString( 75 @LowSpeedAutomaticEmergencyBrakingStateInt int lowSpeedAutomaticEmergencyBrakingState) { 76 String lowSpeedAutomaticEmergencyBrakingStateString = ConstantDebugUtils.toName( 77 LowSpeedAutomaticEmergencyBrakingState.class, 78 lowSpeedAutomaticEmergencyBrakingState); 79 return (lowSpeedAutomaticEmergencyBrakingStateString != null) 80 ? lowSpeedAutomaticEmergencyBrakingStateString 81 : "0x" + Integer.toHexString(lowSpeedAutomaticEmergencyBrakingState); 82 } 83 84 /** @hide */ 85 @IntDef({OTHER, ENABLED, ACTIVATED, USER_OVERRIDE}) 86 @Retention(RetentionPolicy.SOURCE) 87 public @interface LowSpeedAutomaticEmergencyBrakingStateInt {} 88 } 89