1 /* 2 * Copyright (C) 2021 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; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** 26 * Possible states of a vehicle's ignition. 27 * 28 * <p>Applications can use {@link android.car.hardware.property.CarPropertyManager#getProperty(int, 29 * int)} with {@link android.car.VehiclePropertyIds#IGNITION_STATE} to query the vehicle's ignition 30 * state. 31 */ 32 public final class VehicleIgnitionState { 33 34 /** 35 * The vehicle's ignition state is undefined. 36 */ 37 public static final int UNDEFINED = 0; 38 39 /** 40 * Steering wheel is locked. If car can be in {@code LOCK} and {@code OFF} state at the same 41 * time than HAL must report {@code LOCK} state. 42 */ 43 public static final int LOCK = 1; 44 45 /** 46 * Steering wheel is not locked, engine and all accessories are off. If car can be in {@code 47 * LOCK} and {@code OFF} state at the same time than HAL must report {@code LOCK} state. 48 * 49 * <p>If {@link android.car.VehiclePropertyIds#IGNITION_STATE} is implemented on a BEV, then 50 * this state communicates the BEV's High Voltage battery is disconnected and thus the vehicle 51 * is OFF. 52 */ 53 public static final int OFF = 2; 54 55 /** 56 * Typically in this state accessories become available (e.g. radio). Instrument cluster and 57 * engine are turned off 58 */ 59 public static final int ACC = 3; 60 61 /** 62 * Ignition is in state on. Accessories and instrument cluster available, engine might be 63 * running or ready to be started. 64 * 65 * <p>If {@link android.car.VehiclePropertyIds#IGNITION_STATE} is implemented on a BEV, then 66 * this state communicates the BEV's High Voltage battery is connected and thus the vehicle is 67 * ON. 68 */ 69 public static final int ON = 4; 70 71 /** Typically in this state engine is starting (cranking). */ 72 public static final int START = 5; 73 VehicleIgnitionState()74 private VehicleIgnitionState() { 75 } 76 77 /** 78 * Gets a user-friendly representation of an ignition state. 79 */ 80 @NonNull toString(@ehicleIgnitionState.Enum int ignitionState)81 public static String toString(@VehicleIgnitionState.Enum int ignitionState) { 82 switch (ignitionState) { 83 case UNDEFINED: 84 return "UNDEFINED"; 85 case LOCK: 86 return "LOCK"; 87 case OFF: 88 return "OFF"; 89 case ACC: 90 return "ACC"; 91 case ON: 92 return "ON"; 93 case START: 94 return "START"; 95 default: 96 return "0x" + Integer.toHexString(ignitionState); 97 } 98 } 99 100 /** @hide */ 101 @IntDef({ 102 UNDEFINED, 103 LOCK, 104 OFF, 105 ACC, 106 ON, 107 START, 108 }) 109 @Retention(RetentionPolicy.SOURCE) 110 public @interface Enum { 111 } 112 } 113