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