1 /*
2  * Copyright (C) 2023 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 to enumerate the current position of {@link
28  * android.car.VehiclePropertyIds#WINDSHIELD_WIPERS_SWITCH}.
29  *
30  * <p>This list of enum values may be extended in future releases to include additional values.
31  * @hide
32  */
33 @SystemApi
34 public final class WindshieldWipersSwitch {
35     /**
36      * This value is used as an alternative for any {@code WindshieldWipersSwitch} value that is not
37      * defined in the platform. Ideally, implementations of {@link
38      * android.car.VehiclePropertyIds#WINDSHIELD_WIPERS_SWITCH} should not use this value. The
39      * framework can use this field to remain backwards compatible if {@code WindshieldWipersSwitch}
40      * is extended to include additional values.
41      */
42     public static final int OTHER = 0;
43 
44     /**
45      * The windshield wipers switch is set to the off position.
46      */
47     public static final int OFF = 1;
48 
49     /**
50      * {@code MIST} mode performs a single wipe, and then returns to the {@link #OFF} position.
51      */
52     public static final int MIST = 2;
53 
54     /**
55      * {@code INTERMITTENT_LEVEL_*} modes performs intermittent wiping. As the level increases, the
56      * intermittent time period decreases.
57      */
58     public static final int INTERMITTENT_LEVEL_1 = 3;
59 
60     /**
61      * See {@link #INTERMITTENT_LEVEL_1}.
62      */
63     public static final int INTERMITTENT_LEVEL_2 = 4;
64 
65     /**
66      * See {@link #INTERMITTENT_LEVEL_1}.
67      */
68     public static final int INTERMITTENT_LEVEL_3 = 5;
69 
70     /**
71      * See {@link #INTERMITTENT_LEVEL_1}.
72      */
73     public static final int INTERMITTENT_LEVEL_4 = 6;
74 
75     /**
76      * See {@link #INTERMITTENT_LEVEL_1}.
77      */
78     public static final int INTERMITTENT_LEVEL_5 = 7;
79 
80     /**
81      * {@code CONTINUOUS_LEVEL_*} modes performs continuous wiping. As the level increases the speed
82      * of the wiping increases as well.
83      */
84     public static final int CONTINUOUS_LEVEL_1 = 8;
85 
86     /**
87      * See {@link #CONTINUOUS_LEVEL_1}.
88      */
89     public static final int CONTINUOUS_LEVEL_2 = 9;
90 
91     /**
92      * See {@link #CONTINUOUS_LEVEL_1}.
93      */
94     public static final int CONTINUOUS_LEVEL_3 = 10;
95 
96     /**
97      * See {@link #CONTINUOUS_LEVEL_1}.
98      */
99     public static final int CONTINUOUS_LEVEL_4 = 11;
100 
101     /**
102      * See {@link #CONTINUOUS_LEVEL_1}.
103      */
104     public static final int CONTINUOUS_LEVEL_5 = 12;
105 
106     /**
107      * {@code AUTO} allows the vehicle to decide the required wiping level based on the exterior
108      * weather conditions.
109      */
110     public static final int AUTO = 13;
111 
112     /**
113      * Windshield wipers are set to the service mode.
114      */
115     public static final int SERVICE = 14;
116 
WindshieldWipersSwitch()117     private WindshieldWipersSwitch() {}
118 
119     /**
120      * Returns a user-friendly representation of a {@code WindshieldWipersSwitch}.
121      */
122     @NonNull
toString( @indshieldWipersSwitchInt int windshieldWipersSwitch)123     public static String toString(
124             @WindshieldWipersSwitchInt int windshieldWipersSwitch) {
125         switch (windshieldWipersSwitch) {
126             case OTHER:
127                 return "OTHER";
128             case OFF:
129                 return "OFF";
130             case MIST:
131                 return "MIST";
132             case INTERMITTENT_LEVEL_1:
133                 return "INTERMITTENT_LEVEL_1";
134             case INTERMITTENT_LEVEL_2:
135                 return "INTERMITTENT_LEVEL_2";
136             case INTERMITTENT_LEVEL_3:
137                 return "INTERMITTENT_LEVEL_3";
138             case INTERMITTENT_LEVEL_4:
139                 return "INTERMITTENT_LEVEL_4";
140             case INTERMITTENT_LEVEL_5:
141                 return "INTERMITTENT_LEVEL_5";
142             case CONTINUOUS_LEVEL_1:
143                 return "CONTINUOUS_LEVEL_1";
144             case CONTINUOUS_LEVEL_2:
145                 return "CONTINUOUS_LEVEL_2";
146             case CONTINUOUS_LEVEL_3:
147                 return "CONTINUOUS_LEVEL_3";
148             case CONTINUOUS_LEVEL_4:
149                 return "CONTINUOUS_LEVEL_4";
150             case CONTINUOUS_LEVEL_5:
151                 return "CONTINUOUS_LEVEL_5";
152             case AUTO:
153                 return "AUTO";
154             case SERVICE:
155                 return "SERVICE";
156             default:
157                 return "0x" + Integer.toHexString(windshieldWipersSwitch);
158         }
159     }
160 
161     /** @hide */
162     @IntDef({
163             OTHER,
164             OFF,
165             MIST,
166             INTERMITTENT_LEVEL_1,
167             INTERMITTENT_LEVEL_2,
168             INTERMITTENT_LEVEL_3,
169             INTERMITTENT_LEVEL_4,
170             INTERMITTENT_LEVEL_5,
171             CONTINUOUS_LEVEL_1,
172             CONTINUOUS_LEVEL_2,
173             CONTINUOUS_LEVEL_3,
174             CONTINUOUS_LEVEL_4,
175             CONTINUOUS_LEVEL_5,
176             AUTO,
177             SERVICE
178     })
179     @Retention(RetentionPolicy.SOURCE)
180     public @interface WindshieldWipersSwitchInt {}
181 }
182