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