1 /* 2 * Copyright (C) 2022 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 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** 26 * Possible EV charge states of a vehicle. 27 * 28 * <p>Applications can use {@link android.car.hardware.property.CarPropertyManager#getProperty(int, 29 * int)} with {@link android.car.VehiclePropertyIds#EV_CHARGE_STATE} to query the vehicle's ignition 30 * charge state. 31 */ 32 public final class EvChargeState { 33 34 /** 35 * The vehicle's EV charge state is unknown. 36 */ 37 public static final int STATE_UNKNOWN = 0; 38 39 /** 40 * The vehicle is charging. 41 */ 42 public static final int STATE_CHARGING = 1; 43 44 /** 45 * The vehicle is fully charged. 46 */ 47 public static final int STATE_FULLY_CHARGED = 2; 48 49 /** 50 * The vehicle is not charging. 51 */ 52 public static final int STATE_NOT_CHARGING = 3; 53 54 /** 55 * The vehicle is not charging due to an error. 56 */ 57 public static final int STATE_ERROR = 4; 58 59 EvChargeState()60 private EvChargeState() { 61 } 62 63 /** 64 * Gets a user-friendly representation of an EV charge state. 65 */ 66 @NonNull toString(@vChargeStateInt int evChargeState)67 public static String toString(@EvChargeStateInt int evChargeState) { 68 switch (evChargeState) { 69 case STATE_UNKNOWN: 70 return "STATE_UNKNOWN"; 71 case STATE_CHARGING: 72 return "STATE_CHARGING"; 73 case STATE_FULLY_CHARGED: 74 return "STATE_FULLY_CHARGED"; 75 case STATE_NOT_CHARGING: 76 return "STATE_NOT_CHARGING"; 77 case STATE_ERROR: 78 return "STATE_ERROR"; 79 default: 80 return "0x" + Integer.toHexString(evChargeState); 81 } 82 } 83 84 /** @hide */ 85 @IntDef({STATE_UNKNOWN, STATE_CHARGING, STATE_FULLY_CHARGED, STATE_NOT_CHARGING, STATE_ERROR}) 86 @Retention(RetentionPolicy.SOURCE) 87 public @interface EvChargeStateInt { 88 } 89 } 90