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