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.annotation.SystemApi;
22 
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 
26 /**
27  * Used by {@link android.car.VehiclePropertyIds#EV_STOPPING_MODE} to enumerate the current state of
28  * the stopping mode.
29  *
30  * <p>This list of states may be extended to include more states in the future.
31  * @hide
32  */
33 @SystemApi
34 public final class EvStoppingMode {
35     /**
36      * Other EV stopping mode. Ideally, this should never be used.
37      */
38     public static final int STATE_OTHER = 0;
39 
40     /**
41      * Vehicle slowly moves forward when the brake pedal is released.
42      */
43     public static final int STATE_CREEP = 1;
44 
45     /**
46      * Vehicle rolls freely when the brake pedal is released (similar to neutral gear).
47      */
48     public static final int STATE_ROLL = 2;
49 
50     /**
51      * Vehicle stops and holds its position when the brake pedal is released.
52      */
53     public static final int STATE_HOLD = 3;
54 
EvStoppingMode()55     private EvStoppingMode() {}
56 
57     /**
58      * Returns a user-friendly representation of an EV stopping mode.
59      */
60     @NonNull
toString(@vStoppingModeInt int evStoppingMode)61     public static String toString(@EvStoppingModeInt int evStoppingMode) {
62         switch (evStoppingMode) {
63             case STATE_OTHER:
64                 return "STATE_OTHER";
65             case STATE_CREEP:
66                 return "STATE_CREEP";
67             case STATE_ROLL:
68                 return "STATE_ROLL";
69             case STATE_HOLD:
70                 return "STATE_HOLD";
71             default:
72                 return "0x" + Integer.toHexString(evStoppingMode);
73         }
74     }
75 
76     /** @hide */
77     @IntDef({STATE_OTHER, STATE_CREEP, STATE_ROLL, STATE_HOLD})
78     @Retention(RetentionPolicy.SOURCE)
79     public @interface EvStoppingModeInt {}
80 }
81 
82