1 /*
2  * Copyright (C) 2018 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  * Possible vehicle light switch states.
28  *
29  * <p>Applications can use {@link
30  * android.car.hardware.property.CarPropertyManager#getProperty(int, int)} and {@link
31  * android.car.hardware.property.CarPropertyManager#setProperty(Class, int, int, java.lang.Object)}
32  * to get and set the vehicle's light switch.
33  *
34  * @hide
35  */
36 @SystemApi
37 public final class VehicleLightSwitch {
38 
39     /**
40      * Off light switch state.
41      */
42     public static final int STATE_OFF = 0;
43 
44     /**
45      * On light switch state.
46      */
47     public static final int STATE_ON = 1;
48 
49     /**
50      * Daytime running light switch state. Most cars automatically control daytime running mode, but
51      * some cars allow the users to activate them manually.
52      */
53     public static final int STATE_DAYTIME_RUNNING = 2;
54 
55     /**
56      * Automatic light switch state. Allows the ECU to set the lights automatically.
57      */
58     public static final int STATE_AUTOMATIC = 0x100;
59 
VehicleLightSwitch()60     private VehicleLightSwitch() {
61     }
62 
63     /**
64      * Gets a user-friendly representation of a vehicle light switch.
65      */
66     @NonNull
toString(@ehicleLightSwitchInt int vehicleLightSwitch)67     public static String toString(@VehicleLightSwitchInt int vehicleLightSwitch) {
68         switch (vehicleLightSwitch) {
69             case STATE_OFF:
70                 return "STATE_OFF";
71             case STATE_ON:
72                 return "STATE_ON";
73             case STATE_DAYTIME_RUNNING:
74                 return "STATE_DAYTIME_RUNNING";
75             case STATE_AUTOMATIC:
76                 return "STATE_AUTOMATIC";
77             default:
78                 return "0x" + Integer.toHexString(vehicleLightSwitch);
79         }
80     }
81 
82     /** @hide */
83     @IntDef({STATE_OFF, STATE_ON, STATE_DAYTIME_RUNNING, STATE_AUTOMATIC})
84     @Retention(RetentionPolicy.SOURCE)
85     public @interface VehicleLightSwitchInt {
86     }
87 }
88