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 static android.car.feature.Flags.FLAG_ANDROID_VIC_VEHICLE_PROPERTIES;
20 
21 import android.annotation.FlaggedApi;
22 import android.annotation.IntDef;
23 import android.annotation.NonNull;
24 import android.annotation.SystemApi;
25 
26 import com.android.car.internal.util.ConstantDebugUtils;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * Used to enumerate the various impact sensor locations on the car.
33  *
34  * @hide
35  */
36 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES)
37 @SystemApi
38 public final class ImpactSensorLocation {
39     /**
40      * Other impact sensor location. Ideally this should never be used.
41      */
42     public static final int OTHER = 0x01;
43     /**
44      * Frontal impact sensor. Used for the sensor that detects head-on impact.
45      */
46     public static final int FRONT = 0x02;
47     /**
48      * Front-left door side impact sensor. Used for the sensor that detects collisions from the
49      * side, in particular on the front-left door.
50      */
51     public static final int FRONT_LEFT_DOOR_SIDE = 0x04;
52     /**
53      * Front-right door side impact sensor. Used for the sensor that detects collisions from the
54      * side, in particular on the front-right door.
55      */
56     public static final int FRONT_RIGHT_DOOR_SIDE = 0x08;
57     /**
58      * Rear-left door side impact sensor. Used for the sensor that detects collisions from the
59      * side, in particular on the rear-left door.
60      */
61     public static final int REAR_LEFT_DOOR_SIDE = 0x10;
62     /**
63      * Rear-right door side impact sensor. Used for the sensor that detects collisions from the
64      * side, in particular on the rear-right door.
65      */
66     public static final int REAR_RIGHT_DOOR_SIDE = 0x20;
67     /**
68      * Rear impact sensor. Used for the sensor that detects collisions from the rear.
69      */
70     public static final int REAR = 0x40;
71 
ImpactSensorLocation()72     private ImpactSensorLocation() {}
73 
74     /**
75      * Returns a user-friendly representation of {@code ImpactSensorLocation}.
76      */
77     @NonNull
toString(@mpactSensorLocationInt int impactSensorLocation)78     public static String toString(@ImpactSensorLocationInt int impactSensorLocation) {
79         String impactSensorLocationString = ConstantDebugUtils.toName(
80                 ImpactSensorLocation.class, impactSensorLocation);
81         return (impactSensorLocationString != null)
82                 ? impactSensorLocationString
83                 : "0x" + Integer.toHexString(impactSensorLocation);
84     }
85 
86     /** @hide */
87     @IntDef({OTHER, FRONT, FRONT_LEFT_DOOR_SIDE, FRONT_RIGHT_DOOR_SIDE, REAR_LEFT_DOOR_SIDE,
88             REAR_RIGHT_DOOR_SIDE, REAR})
89     @Retention(RetentionPolicy.SOURCE)
90     public @interface ImpactSensorLocationInt {}
91 }
92