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 regenerative braking 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_REGENERATIVE_BRAKING_STATE} to query the 31 * vehicle's regenerative braking state. 32 */ 33 public final class EvRegenerativeBrakingState { 34 35 /** 36 * The vehicle's EV regenerative braking 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 regenerative braking is disabled. 44 */ 45 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 46 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 47 public static final int STATE_DISABLED = 1; 48 49 /** 50 * The regenerative braking is partially enabled. 51 */ 52 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 53 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 54 public static final int STATE_PARTIALLY_ENABLED = 2; 55 56 /** 57 * The regenerative braking is fully enabled. 58 */ 59 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 60 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 61 public static final int STATE_FULLY_ENABLED = 3; 62 63 EvRegenerativeBrakingState()64 private EvRegenerativeBrakingState() { 65 } 66 67 /** 68 * Gets a user-friendly representation of an EV regenerative braking state. 69 */ 70 @NonNull 71 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 72 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) toString(@vRegenerativeBrakingStateInt int evRegenerativeBrakingState)73 public static String toString(@EvRegenerativeBrakingStateInt int evRegenerativeBrakingState) { 74 switch (evRegenerativeBrakingState) { 75 case STATE_UNKNOWN: 76 return "STATE_UNKNOWN"; 77 case STATE_DISABLED: 78 return "STATE_DISABLED"; 79 case STATE_PARTIALLY_ENABLED: 80 return "STATE_PARTIALLY_ENABLED"; 81 case STATE_FULLY_ENABLED: 82 return "STATE_FULLY_ENABLED"; 83 default: 84 return "0x" + Integer.toHexString(evRegenerativeBrakingState); 85 } 86 } 87 88 /** @hide */ 89 @IntDef({STATE_UNKNOWN, STATE_DISABLED, STATE_PARTIALLY_ENABLED, STATE_FULLY_ENABLED}) 90 @Retention(RetentionPolicy.SOURCE) 91 public @interface EvRegenerativeBrakingStateInt { 92 } 93 } 94