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