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_KEEP_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 LaneKeepAssistState { 35 /** 36 * This state is used as an alternative for any {@code LaneKeepAssistState} value that is not 37 * defined in the platform. Ideally, implementations of {@link 38 * android.car.VehiclePropertyIds#LANE_KEEP_ASSIST_STATE} should not use this state. The 39 * framework can use this field to remain backwards compatible if {@code LaneKeepAssistState} 40 * is extended to include additional states. 41 */ 42 public static final int OTHER = 0; 43 44 /** 45 * LKA is enabled and monitoring, but steering assist is not activated. 46 */ 47 public static final int ENABLED = 1; 48 49 /** 50 * LKA is enabled and currently has steering assist applied for the vehicle. Steering assist is 51 * steering toward the left direction, which generally means the steering wheel turns counter 52 * clockwise. This is usually in response to the vehicle drifting to the right. Once steering 53 * assist is completed, LKA must return to the {@link #ENABLED} state. 54 */ 55 public static final int ACTIVATED_STEER_LEFT = 2; 56 57 /** 58 * LKA is enabled and currently has steering assist applied for the vehicle. Steering assist is 59 * steering toward the right direction, which generally means the steering wheel turns 60 * clockwise. This is usually in response to the vehicle drifting to the left. Once steering 61 * assist is completed, LKA must return to the {@link #ENABLED} state. 62 */ 63 public static final int ACTIVATED_STEER_RIGHT = 3; 64 65 /** 66 * Many LKA implementations allow the driver to override LKA. This means that the car has 67 * determined it should take some action, but a user decides to take over and do something else. 68 * This is often done for safety reasons and to ensure that the driver can always take control 69 * of the vehicle. This state should be set when the user is actively overriding the LKA system. 70 */ 71 public static final int USER_OVERRIDE = 4; 72 LaneKeepAssistState()73 private LaneKeepAssistState() {} 74 75 /** 76 * Returns a user-friendly representation of a {@code LaneKeepAssistState}. 77 */ 78 @NonNull toString( @aneKeepAssistStateInt int laneKeepAssistState)79 public static String toString( 80 @LaneKeepAssistStateInt int laneKeepAssistState) { 81 switch (laneKeepAssistState) { 82 case OTHER: 83 return "OTHER"; 84 case ENABLED: 85 return "ENABLED"; 86 case ACTIVATED_STEER_LEFT: 87 return "ACTIVATED_STEER_LEFT"; 88 case ACTIVATED_STEER_RIGHT: 89 return "ACTIVATED_STEER_RIGHT"; 90 case USER_OVERRIDE: 91 return "USER_OVERRIDE"; 92 default: 93 return "0x" + Integer.toHexString(laneKeepAssistState); 94 } 95 } 96 97 /** @hide */ 98 @IntDef({OTHER, ENABLED, ACTIVATED_STEER_LEFT, ACTIVATED_STEER_RIGHT, USER_OVERRIDE}) 99 @Retention(RetentionPolicy.SOURCE) 100 public @interface LaneKeepAssistStateInt {} 101 } 102 103