Keun-young Park | 0eb8d26 | 2016-02-11 17:06:59 -0800 | [diff] [blame] | 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 | */ |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 16 | package android.car; |
| 17 | |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 18 | import android.annotation.IntDef; |
Keun-young Park | 0eb8d26 | 2016-02-11 17:06:59 -0800 | [diff] [blame] | 19 | |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 20 | import java.lang.annotation.Retention; |
| 21 | import java.lang.annotation.RetentionPolicy; |
| 22 | |
Keun-young Park | 0eb8d26 | 2016-02-11 17:06:59 -0800 | [diff] [blame] | 23 | /** |
Kai | 18beeee | 2020-04-07 17:11:04 -0700 | [diff] [blame^] | 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> |
Keun-young Park | 0eb8d26 | 2016-02-11 17:06:59 -0800 | [diff] [blame] | 35 | */ |
Kai | 18beeee | 2020-04-07 17:11:04 -0700 | [diff] [blame^] | 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. |
Kai | 92c8d88 | 2018-04-06 12:35:31 -0700 | [diff] [blame] | 39 | public final class VehicleAreaSeat { |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 40 | /** List of vehicle's seats. */ |
| 41 | public static final int SEAT_UNKNOWN = 0; |
| 42 | /** Row 1 left side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 43 | public static final int SEAT_ROW_1_LEFT = 0x0001; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 44 | /** Row 1 center seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 45 | public static final int SEAT_ROW_1_CENTER = 0x0002; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 46 | /** Row 1 right side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 47 | public static final int SEAT_ROW_1_RIGHT = 0x0004; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 48 | /** Row 2 left side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 49 | public static final int SEAT_ROW_2_LEFT = 0x0010; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 50 | /** Row 2 center seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 51 | public static final int SEAT_ROW_2_CENTER = 0x0020; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 52 | /** Row 2 right side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 53 | public static final int SEAT_ROW_2_RIGHT = 0x0040; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 54 | /** Row 3 left side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 55 | public static final int SEAT_ROW_3_LEFT = 0x0100; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 56 | /** Row 3 center seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 57 | public static final int SEAT_ROW_3_CENTER = 0x0200; |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 58 | /** Row 3 right side seat*/ |
Steve Paik | 8968e1d | 2016-10-06 20:29:37 -0700 | [diff] [blame] | 59 | public static final int SEAT_ROW_3_RIGHT = 0x0400; |
Keun-young Park | cd68cc7 | 2016-09-14 11:06:56 -0700 | [diff] [blame] | 60 | |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 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 {} |
Kai | 92c8d88 | 2018-04-06 12:35:31 -0700 | [diff] [blame] | 77 | private VehicleAreaSeat() {} |
Kai | 48106a9 | 2018-12-18 13:26:19 -0800 | [diff] [blame] | 78 | |
Keun young Park | bb877e2 | 2019-08-02 10:38:01 -0700 | [diff] [blame] | 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 |
| 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 Park | 0eb8d26 | 2016-02-11 17:06:59 -0800 | [diff] [blame] | 106 | } |