• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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;
17 
18 import android.annotation.IntDef;
19 import android.car.annotation.AddedInOrBefore;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /**
25  * Object used to indicate the area value for car properties which have area type
26  * {@link VehicleAreaType#VEHICLE_AREA_TYPE_SEAT}.
27  * <p>
28  * The constants defined by {@link VehicleAreaSeat} indicate the position for area type
29  * {@link VehicleAreaType#VEHICLE_AREA_TYPE_SEAT}. A property can have a single or a combination of
30  * positions. Developers can query the position using
31  * {@link android.car.hardware.property.CarPropertyManager#getAreaId(int, int)}.
32  * </p><p>
33  * Refer to {@link android.car.hardware.CarPropertyConfig#getAreaIds()} for more information about
34  * areaId.
35  * </p>
36  */
37 
38 // This class is only designed to provide constants for VehicleAreaSeat. The constants should
39 // be same as VehicleAreaSeat in /hardware/interfaces/automotive/vehicle/2.0/types.hal.
40 public final class VehicleAreaSeat {
41     /** List of vehicle's seats. */
42     @AddedInOrBefore(majorVersion = 33)
43     public static final int SEAT_UNKNOWN = 0;
44     /** Row 1 left side seat*/
45     @AddedInOrBefore(majorVersion = 33)
46     public static final int SEAT_ROW_1_LEFT = 0x0001;
47     /** Row 1 center seat*/
48     @AddedInOrBefore(majorVersion = 33)
49     public static final int SEAT_ROW_1_CENTER = 0x0002;
50     /** Row 1 right side seat*/
51     @AddedInOrBefore(majorVersion = 33)
52     public static final int SEAT_ROW_1_RIGHT = 0x0004;
53     /** Row 2 left side seat*/
54     @AddedInOrBefore(majorVersion = 33)
55     public static final int SEAT_ROW_2_LEFT = 0x0010;
56     /** Row 2 center seat*/
57     @AddedInOrBefore(majorVersion = 33)
58     public static final int SEAT_ROW_2_CENTER = 0x0020;
59     /** Row 2 right side seat*/
60     @AddedInOrBefore(majorVersion = 33)
61     public static final int SEAT_ROW_2_RIGHT = 0x0040;
62     /** Row 3 left side seat*/
63     @AddedInOrBefore(majorVersion = 33)
64     public static final int SEAT_ROW_3_LEFT = 0x0100;
65     /** Row 3 center seat*/
66     @AddedInOrBefore(majorVersion = 33)
67     public static final int SEAT_ROW_3_CENTER = 0x0200;
68     /** Row 3 right side seat*/
69     @AddedInOrBefore(majorVersion = 33)
70     public static final int SEAT_ROW_3_RIGHT = 0x0400;
71 
72     /** @hide */
73     @IntDef(prefix = {"SEAT_"}, value = {
74         SEAT_UNKNOWN,
75         SEAT_ROW_1_LEFT,
76         SEAT_ROW_1_CENTER,
77         SEAT_ROW_1_RIGHT,
78         SEAT_ROW_2_LEFT,
79         SEAT_ROW_2_CENTER,
80         SEAT_ROW_2_RIGHT,
81         SEAT_ROW_3_LEFT,
82         SEAT_ROW_3_CENTER,
83         SEAT_ROW_3_RIGHT
84     })
85     @Retention(RetentionPolicy.SOURCE)
86 
87     public @interface Enum {}
VehicleAreaSeat()88     private VehicleAreaSeat() {}
89 
90     /** @hide */
91     @AddedInOrBefore(majorVersion = 33)
92     public static final int SIDE_LEFT = -1;
93     /** @hide */
94     @AddedInOrBefore(majorVersion = 33)
95     public static final int SIDE_CENTER = 0;
96     /** @hide */
97     @AddedInOrBefore(majorVersion = 33)
98     public static final int SIDE_RIGHT = 1;
99     /**
100      * Convert row number and side into {@link Enum}.
101      *
102      * @param rowNumber should be 1, 2 or 3
103      * @param side {@link #SIDE_LEFT}. {@link #SIDE_CENTER}, {@link #SIDE_RIGHT}.
104      *
105      * @hide */
106     @Enum
107     @AddedInOrBefore(majorVersion = 33)
fromRowAndSide(int rowNumber, int side)108     public static int fromRowAndSide(int rowNumber, int side) {
109         if (rowNumber < 1 || rowNumber > 3) {
110             return SEAT_UNKNOWN;
111         }
112         if (side < -1 || side > 1) {
113             return SEAT_UNKNOWN;
114         }
115         int seat = 0x1;
116         seat = seat << ((rowNumber - 1) * 4);
117         seat = seat << (side + 1);
118         return seat;
119     }
120 
121 }
122