• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import android.car.annotation.ApiRequirements;
23 
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 
27 /**
28  * Used to enumerate the current state of {@link
29  * android.car.VehiclePropertyIds#LANE_DEPARTURE_WARNING_STATE}.
30  *
31  * <p>This list of states may be extended in future releases to include additional states.
32  * @hide
33  */
34 @SystemApi
35 public final class LaneDepartureWarningState {
36     /**
37      * This state is used as an alternative for any {@code LaneDepartureWarningState} value that
38      * is not defined in the platform. Ideally, implementations of {@link
39      * android.car.VehiclePropertyIds#LANE_DEPARTURE_WARNING_STATE} should not use this state.
40      * The framework can use this field to remain backwards compatible if {@code
41      * LaneDepartureWarningState} is extended to include additional states.
42      */
43     @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0,
44             minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0)
45     public static final int OTHER = 0;
46 
47     /**
48      * LDW is enabled and monitoring, but the vehicle is centered in the lane.
49      */
50     @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0,
51             minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0)
52     public static final int NO_WARNING = 1;
53 
54     /**
55      * LDW is enabled, detects the vehicle is approaching or crossing lane lines on the left side
56      * of the vehicle, and is currently warning the user.
57      */
58     @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0,
59             minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0)
60     public static final int WARNING_LEFT = 2;
61 
62     /**
63      * LDW is enabled, detects the vehicle is approaching or crossing lane lines on the right side
64      * of the vehicle, and is currently warning the user.
65      */
66     @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0,
67             minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0)
68     public static final int WARNING_RIGHT = 3;
69 
LaneDepartureWarningState()70     private LaneDepartureWarningState() {}
71 
72     /**
73      * Returns a user-friendly representation of a {@code LaneDepartureWarningState}.
74      */
75     @NonNull
76     @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0,
77             minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0)
toString( @aneDepartureWarningStateInt int laneDepartureWarningState)78     public static String toString(
79             @LaneDepartureWarningStateInt int laneDepartureWarningState) {
80         switch (laneDepartureWarningState) {
81             case OTHER:
82                 return "OTHER";
83             case NO_WARNING:
84                 return "NO_WARNING";
85             case WARNING_LEFT:
86                 return "WARNING_LEFT";
87             case WARNING_RIGHT:
88                 return "WARNING_RIGHT";
89             default:
90                 return "0x" + Integer.toHexString(laneDepartureWarningState);
91         }
92     }
93 
94     /** @hide */
95     @IntDef({OTHER, NO_WARNING, WARNING_LEFT, WARNING_RIGHT})
96     @Retention(RetentionPolicy.SOURCE)
97     public @interface LaneDepartureWarningStateInt {}
98 }
99 
100