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 package android.car.hardware.property;
17 
18 import android.annotation.IntDef;
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 
25 /**
26  * Used by Lights state vehicle properties to enumerate the current state of the lights.
27  * Use {@link android.car.hardware.property.CarPropertyManager#getProperty(int, int)} and {@link
28  * android.car.hardware.property.CarPropertyManager#setProperty(Class, int, int, java.lang.Object)}
29  * to set and get related vehicle properties.
30  * @hide
31  */
32 @SystemApi
33 public final class VehicleLightState {
34 
35     /**
36      * Off light state.
37      */
38     public static final int STATE_OFF = 0;
39 
40     /**
41      * On light state.
42      */
43     public static final int STATE_ON = 1;
44 
45     /**
46      * Light state is in daytime running mode. Most cars automatically control daytime running mode,
47      * but some cars allow the users to activate them manually.
48      */
49     public static final int STATE_DAYTIME_RUNNING = 2;
50 
VehicleLightState()51     private VehicleLightState() {}
52 
53     /**
54      * Gets a user-friendly representation of a vehicle light state.
55      */
56     @NonNull
toString(@ehicleLightStateInt int vehicleLightState)57     public static String toString(@VehicleLightStateInt int vehicleLightState) {
58         switch (vehicleLightState) {
59             case STATE_OFF:
60                 return "STATE_OFF";
61             case STATE_ON:
62                 return "STATE_ON";
63             case STATE_DAYTIME_RUNNING:
64                 return "STATE_DAYTIME_RUNNING";
65             default:
66                 return "0x" + Integer.toHexString(vehicleLightState);
67         }
68     }
69 
70     /** @hide */
71     @IntDef({STATE_OFF, STATE_ON, STATE_DAYTIME_RUNNING})
72     @Retention(RetentionPolicy.SOURCE)
73     public @interface VehicleLightStateInt {}
74 }
75