blob: 611827d73d4b580f825bc2cf0bbb15009d4f032b [file] [log] [blame]
Keun-young Park0eb8d262016-02-11 17:06:59 -08001/*
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 */
Keun-young Parke54ac272016-02-16 19:02:18 -080016package android.car;
17
Kai48106a92018-12-18 13:26:19 -080018import android.annotation.IntDef;
Keun-young Park0eb8d262016-02-11 17:06:59 -080019
Kai48106a92018-12-18 13:26:19 -080020import java.lang.annotation.Retention;
21import java.lang.annotation.RetentionPolicy;
22
Keun-young Park0eb8d262016-02-11 17:06:59 -080023/**
Kai18beeee2020-04-07 17:11:04 -070024 * 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>
Keun-young Park0eb8d262016-02-11 17:06:59 -080035 */
Kai18beeee2020-04-07 17:11:04 -070036
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.
Kai92c8d882018-04-06 12:35:31 -070039public final class VehicleAreaSeat {
Kai48106a92018-12-18 13:26:19 -080040 /** List of vehicle's seats. */
41 public static final int SEAT_UNKNOWN = 0;
42 /** Row 1 left side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070043 public static final int SEAT_ROW_1_LEFT = 0x0001;
Kai48106a92018-12-18 13:26:19 -080044 /** Row 1 center seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070045 public static final int SEAT_ROW_1_CENTER = 0x0002;
Kai48106a92018-12-18 13:26:19 -080046 /** Row 1 right side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070047 public static final int SEAT_ROW_1_RIGHT = 0x0004;
Kai48106a92018-12-18 13:26:19 -080048 /** Row 2 left side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070049 public static final int SEAT_ROW_2_LEFT = 0x0010;
Kai48106a92018-12-18 13:26:19 -080050 /** Row 2 center seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070051 public static final int SEAT_ROW_2_CENTER = 0x0020;
Kai48106a92018-12-18 13:26:19 -080052 /** Row 2 right side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070053 public static final int SEAT_ROW_2_RIGHT = 0x0040;
Kai48106a92018-12-18 13:26:19 -080054 /** Row 3 left side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070055 public static final int SEAT_ROW_3_LEFT = 0x0100;
Kai48106a92018-12-18 13:26:19 -080056 /** Row 3 center seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070057 public static final int SEAT_ROW_3_CENTER = 0x0200;
Kai48106a92018-12-18 13:26:19 -080058 /** Row 3 right side seat*/
Steve Paik8968e1d2016-10-06 20:29:37 -070059 public static final int SEAT_ROW_3_RIGHT = 0x0400;
Keun-young Parkcd68cc72016-09-14 11:06:56 -070060
Kai48106a92018-12-18 13:26:19 -080061 /** @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 {}
Kai92c8d882018-04-06 12:35:31 -070077 private VehicleAreaSeat() {}
Kai48106a92018-12-18 13:26:19 -080078
Keun young Parkbb877e22019-08-02 10:38:01 -070079 /** @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
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
Keun-young Park0eb8d262016-02-11 17:06:59 -0800106}