| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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.location; |
| 18 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| 20 | import android.annotation.NonNull; |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | |
| 25 | import java.lang.annotation.Retention; |
| 26 | import java.lang.annotation.RetentionPolicy; |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 27 | import java.util.ArrayList; |
| Yu-Han Yang | 0d08d6d | 2022-11-08 17:38:17 +0000 | [diff] [blame] | 28 | import java.util.Collections; |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 29 | import java.util.List; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 30 | import java.util.Objects; |
| 31 | import java.util.concurrent.Executor; |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 32 | |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 33 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 34 | * GNSS chipset capabilities. |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 35 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 36 | public final class GnssCapabilities implements Parcelable { |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 37 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 38 | // IMPORTANT - must match the Capabilities enum in IGnssCallback.hal |
| 39 | /** @hide */ |
| 40 | public static final int TOP_HAL_CAPABILITY_SCHEDULING = 1; |
| 41 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 42 | public static final int TOP_HAL_CAPABILITY_MSB = 1 << 1; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 43 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 44 | public static final int TOP_HAL_CAPABILITY_MSA = 1 << 2; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 45 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 46 | public static final int TOP_HAL_CAPABILITY_SINGLE_SHOT = 1 << 3; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 47 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 48 | public static final int TOP_HAL_CAPABILITY_ON_DEMAND_TIME = 1 << 4; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 49 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 50 | public static final int TOP_HAL_CAPABILITY_GEOFENCING = 1 << 5; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 51 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 52 | public static final int TOP_HAL_CAPABILITY_MEASUREMENTS = 1 << 6; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 53 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 54 | public static final int TOP_HAL_CAPABILITY_NAV_MESSAGES = 1 << 7; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 55 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 56 | public static final int TOP_HAL_CAPABILITY_LOW_POWER_MODE = 1 << 8; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 57 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 58 | public static final int TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST = 1 << 9; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 59 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 60 | public static final int TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS = 1 << 10; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 61 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 62 | public static final int TOP_HAL_CAPABILITY_ANTENNA_INFO = 1 << 11; |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 63 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 64 | public static final int TOP_HAL_CAPABILITY_CORRELATION_VECTOR = 1 << 12; |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 65 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 66 | public static final int TOP_HAL_CAPABILITY_SATELLITE_PVT = 1 << 13; |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 67 | /** @hide */ |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 68 | public static final int TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING = 1 << 14; |
| 69 | /** @hide */ |
| 70 | public static final int TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE = 1 << 15; |
| Sasha Kuznetsov | a68a7a3 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 71 | |
| Anil Admal | 312fddb | 2019-03-25 12:15:43 -0700 | [diff] [blame] | 72 | /** @hide */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 73 | @IntDef(flag = true, prefix = {"TOP_HAL_CAPABILITY_"}, value = {TOP_HAL_CAPABILITY_SCHEDULING, |
| 74 | TOP_HAL_CAPABILITY_MSB, TOP_HAL_CAPABILITY_MSA, TOP_HAL_CAPABILITY_SINGLE_SHOT, |
| 75 | TOP_HAL_CAPABILITY_ON_DEMAND_TIME, TOP_HAL_CAPABILITY_GEOFENCING, |
| 76 | TOP_HAL_CAPABILITY_MEASUREMENTS, TOP_HAL_CAPABILITY_NAV_MESSAGES, |
| 77 | TOP_HAL_CAPABILITY_LOW_POWER_MODE, TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST, |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 78 | TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS, TOP_HAL_CAPABILITY_ANTENNA_INFO, |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 79 | TOP_HAL_CAPABILITY_CORRELATION_VECTOR, TOP_HAL_CAPABILITY_SATELLITE_PVT, |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 80 | TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING, |
| 81 | TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE}) |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 82 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 83 | @Retention(RetentionPolicy.SOURCE) |
| 84 | public @interface TopHalCapabilityFlags {} |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 85 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 86 | // IMPORTANT - must match the Capabilities enum in IMeasurementCorrectionsCallback.hal |
| 87 | /** @hide */ |
| 88 | public static final int SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_LOS_SATS = 1; |
| 89 | /** @hide */ |
| 90 | public static final int SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_EXCESS_PATH_LENGTH = 2; |
| 91 | /** @hide */ |
| 92 | public static final int SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_REFLECTING_PLANE = 4; |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 93 | |
| Anil Admal | 312fddb | 2019-03-25 12:15:43 -0700 | [diff] [blame] | 94 | /** @hide */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 95 | @IntDef(flag = true, prefix = {"SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_"}, value = { |
| 96 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_LOS_SATS, |
| 97 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_EXCESS_PATH_LENGTH, |
| 98 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_REFLECTING_PLANE}) |
| 99 | @Retention(RetentionPolicy.SOURCE) |
| 100 | public @interface SubHalMeasurementCorrectionsCapabilityFlags {} |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 101 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 102 | // IMPORATANT - must match values in IGnssPowerIndicationCallback.aidl |
| 103 | /** @hide */ |
| 104 | public static final int SUB_HAL_POWER_CAPABILITY_TOTAL = 1; |
| 105 | /** @hide */ |
| 106 | public static final int SUB_HAL_POWER_CAPABILITY_SINGLEBAND_TRACKING = 2; |
| 107 | /** @hide */ |
| 108 | public static final int SUB_HAL_POWER_CAPABILITY_MULTIBAND_TRACKING = 4; |
| 109 | /** @hide */ |
| 110 | public static final int SUB_HAL_POWER_CAPABILITY_SINGLEBAND_ACQUISITION = 8; |
| 111 | /** @hide */ |
| 112 | public static final int SUB_HAL_POWER_CAPABILITY_MULTIBAND_ACQUISITION = 16; |
| 113 | /** @hide */ |
| 114 | public static final int SUB_HAL_POWER_CAPABILITY_OTHER_MODES = 32; |
| 115 | |
| 116 | /** @hide */ |
| 117 | @IntDef(flag = true, prefix = {"SUB_HAL_POWER_CAPABILITY_"}, value = { |
| 118 | SUB_HAL_POWER_CAPABILITY_TOTAL, SUB_HAL_POWER_CAPABILITY_SINGLEBAND_TRACKING, |
| 119 | SUB_HAL_POWER_CAPABILITY_MULTIBAND_TRACKING, |
| 120 | SUB_HAL_POWER_CAPABILITY_SINGLEBAND_ACQUISITION, |
| 121 | SUB_HAL_POWER_CAPABILITY_MULTIBAND_ACQUISITION, |
| 122 | SUB_HAL_POWER_CAPABILITY_OTHER_MODES}) |
| 123 | @Retention(RetentionPolicy.SOURCE) |
| 124 | public @interface SubHalPowerCapabilityFlags {} |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 125 | |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 126 | /** The capability is unknown to be supported or not. */ |
| 127 | public static final int CAPABILITY_UNKNOWN = 0; |
| 128 | /** The capability is supported. */ |
| 129 | public static final int CAPABILITY_SUPPORTED = 1; |
| 130 | /** The capability is not supported. */ |
| 131 | public static final int CAPABILITY_UNSUPPORTED = 2; |
| 132 | |
| 133 | /** @hide */ |
| 134 | @IntDef(flag = true, prefix = {"CAPABILITY_"}, value = {CAPABILITY_UNKNOWN, |
| 135 | CAPABILITY_SUPPORTED, |
| 136 | CAPABILITY_UNSUPPORTED}) |
| 137 | @Retention(RetentionPolicy.SOURCE) |
| 138 | public @interface CapabilitySupportType {} |
| 139 | |
| 140 | |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 141 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 142 | * Returns an empty GnssCapabilities object. |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 143 | * |
| 144 | * @hide |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 145 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 146 | public static GnssCapabilities empty() { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 147 | return new GnssCapabilities(/*topFlags=*/ 0, /*isAdrCapabilityKnown=*/ false, |
| 148 | /*measurementCorrectionsFlags=*/ 0, /*powerFlags=*/ 0, /*gnssSignalTypes=*/ |
| 149 | Collections.emptyList()); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | private final @TopHalCapabilityFlags int mTopFlags; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 153 | private final boolean mIsAdrCapabilityKnown; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 154 | private final @SubHalMeasurementCorrectionsCapabilityFlags int mMeasurementCorrectionsFlags; |
| 155 | private final @SubHalPowerCapabilityFlags int mPowerFlags; |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 156 | private final @NonNull List<GnssSignalType> mGnssSignalTypes; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 157 | |
| 158 | private GnssCapabilities( |
| 159 | @TopHalCapabilityFlags int topFlags, |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 160 | boolean isAdrCapabilityKnown, |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 161 | @SubHalMeasurementCorrectionsCapabilityFlags int measurementCorrectionsFlags, |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 162 | @SubHalPowerCapabilityFlags int powerFlags, |
| 163 | @NonNull List<GnssSignalType> gnssSignalTypes) { |
| Yu-Han Yang | e75758a | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 164 | Objects.requireNonNull(gnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 165 | mTopFlags = topFlags; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 166 | mIsAdrCapabilityKnown = isAdrCapabilityKnown; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 167 | mMeasurementCorrectionsFlags = measurementCorrectionsFlags; |
| 168 | mPowerFlags = powerFlags; |
| Yu-Han Yang | 0d08d6d | 2022-11-08 17:38:17 +0000 | [diff] [blame] | 169 | mGnssSignalTypes = Collections.unmodifiableList(gnssSignalTypes); |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 173 | * Returns a new GnssCapabilities object with top hal values set from the given flags. |
| Yu-Han Yang | 8318aba | 2020-10-19 12:08:09 -0700 | [diff] [blame] | 174 | * |
| 175 | * @hide |
| Yu-Han Yang | 8318aba | 2020-10-19 12:08:09 -0700 | [diff] [blame] | 176 | */ |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 177 | public GnssCapabilities withTopHalFlags(@TopHalCapabilityFlags int flags, |
| 178 | boolean isAdrCapabilityKnown) { |
| 179 | if (mTopFlags == flags && mIsAdrCapabilityKnown == isAdrCapabilityKnown) { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 180 | return this; |
| 181 | } else { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 182 | return new GnssCapabilities(flags, isAdrCapabilityKnown, |
| 183 | mMeasurementCorrectionsFlags, mPowerFlags, mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 184 | } |
| Yu-Han Yang | 8318aba | 2020-10-19 12:08:09 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 188 | * Returns a new GnssCapabilities object with gnss measurement corrections sub hal values set |
| 189 | * from the given flags. |
| 190 | * |
| 191 | * @hide |
| 192 | */ |
| 193 | public GnssCapabilities withSubHalMeasurementCorrectionsFlags( |
| 194 | @SubHalMeasurementCorrectionsCapabilityFlags int flags) { |
| 195 | if (mMeasurementCorrectionsFlags == flags) { |
| 196 | return this; |
| 197 | } else { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 198 | return new GnssCapabilities(mTopFlags, mIsAdrCapabilityKnown, flags, mPowerFlags, |
| Yu-Han Yang | 0d08d6d | 2022-11-08 17:38:17 +0000 | [diff] [blame] | 199 | mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Returns a new GnssCapabilities object with gnss measurement corrections sub hal values set |
| 205 | * from the given flags. |
| 206 | * |
| 207 | * @hide |
| 208 | */ |
| 209 | public GnssCapabilities withSubHalPowerFlags(@SubHalPowerCapabilityFlags int flags) { |
| 210 | if (mPowerFlags == flags) { |
| 211 | return this; |
| 212 | } else { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 213 | return new GnssCapabilities(mTopFlags, mIsAdrCapabilityKnown, |
| 214 | mMeasurementCorrectionsFlags, flags, mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | |
| 218 | /** |
| Yu-Han Yang | e75758a | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 219 | * Returns a new GnssCapabilities object with a list of GnssSignalType. |
| 220 | * |
| 221 | * @hide |
| 222 | */ |
| 223 | public GnssCapabilities withSignalTypes(@NonNull List<GnssSignalType> gnssSignalTypes) { |
| 224 | Objects.requireNonNull(gnssSignalTypes); |
| 225 | if (mGnssSignalTypes.equals(gnssSignalTypes)) { |
| 226 | return this; |
| 227 | } else { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 228 | return new GnssCapabilities(mTopFlags, mIsAdrCapabilityKnown, |
| 229 | mMeasurementCorrectionsFlags, mPowerFlags, new ArrayList<>(gnssSignalTypes)); |
| Yu-Han Yang | e75758a | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 234 | * Returns {@code true} if GNSS chipset supports scheduling, {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 235 | */ |
| 236 | public boolean hasScheduling() { |
| 237 | return (mTopFlags & TOP_HAL_CAPABILITY_SCHEDULING) != 0; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Returns {@code true} if GNSS chipset supports Mobile Station Based assistance, {@code false} |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 242 | * otherwise. |
| 243 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 244 | public boolean hasMsb() { |
| 245 | return (mTopFlags & TOP_HAL_CAPABILITY_MSB) != 0; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Returns {@code true} if GNSS chipset supports Mobile Station Assisted assitance, |
| 250 | * {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 251 | */ |
| 252 | public boolean hasMsa() { |
| 253 | return (mTopFlags & TOP_HAL_CAPABILITY_MSA) != 0; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Returns {@code true} if GNSS chipset supports single shot locating, {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 258 | */ |
| Yu-Han Yang | ac91396 | 2022-10-25 16:49:17 +0000 | [diff] [blame] | 259 | public boolean hasSingleShotFix() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 260 | return (mTopFlags & TOP_HAL_CAPABILITY_SINGLE_SHOT) != 0; |
| 261 | } |
| 262 | |
| 263 | /** |
| Neil Fuller | 8ad07e2 | 2022-12-13 14:49:06 +0000 | [diff] [blame] | 264 | * Returns {@code true} if GNSS chipset requests periodic time signal injection from the |
| 265 | * platform in addition to on-demand and occasional time updates, {@code false} otherwise. |
| 266 | * |
| 267 | * <p><em>Note: The naming of this capability and the behavior it controls differ substantially. |
| 268 | * This is the result of a historic implementation bug, b/73893222.</em> |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 269 | */ |
| 270 | public boolean hasOnDemandTime() { |
| 271 | return (mTopFlags & TOP_HAL_CAPABILITY_ON_DEMAND_TIME) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Returns {@code true} if GNSS chipset supports geofencing, {@code false} otherwise. |
| 276 | */ |
| 277 | public boolean hasGeofencing() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 278 | return (mTopFlags & TOP_HAL_CAPABILITY_GEOFENCING) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /** |
| 282 | * Returns {@code true} if GNSS chipset supports measurements, {@code false} otherwise. |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 283 | * |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 284 | * @see LocationManager#registerGnssMeasurementsCallback(Executor, GnssMeasurementsEvent.Callback) |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 285 | */ |
| 286 | public boolean hasMeasurements() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 287 | return (mTopFlags & TOP_HAL_CAPABILITY_MEASUREMENTS) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Returns {@code true} if GNSS chipset supports navigation messages, {@code false} otherwise. |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 292 | * |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 293 | * @deprecated Use {@link #hasNavigationMessages()} instead. |
| 294 | * |
| 295 | * @hide |
| 296 | */ |
| 297 | @Deprecated |
| 298 | @SystemApi |
| 299 | public boolean hasNavMessages() { |
| 300 | return hasNavigationMessages(); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Returns {@code true} if GNSS chipset supports navigation messages, {@code false} otherwise. |
| 305 | * |
| 306 | * @see LocationManager#registerGnssNavigationMessageCallback(Executor, GnssNavigationMessage.Callback) |
| 307 | */ |
| 308 | public boolean hasNavigationMessages() { |
| 309 | return (mTopFlags & TOP_HAL_CAPABILITY_NAV_MESSAGES) != 0; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Returns {@code true} if GNSS chipset supports low power mode, {@code false} otherwise. |
| 314 | * |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 315 | * <p>The low power mode is defined in GNSS HAL. When the low power mode is active, the GNSS |
| 316 | * hardware must make strong tradeoffs to substantially restrict power use. |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 317 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 318 | public boolean hasLowPowerMode() { |
| 319 | return (mTopFlags & TOP_HAL_CAPABILITY_LOW_POWER_MODE) != 0; |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * Returns {@code true} if GNSS chipset supports satellite blocklists, {@code false} otherwise. |
| 324 | * |
| 325 | * @deprecated Use {@link #hasSatelliteBlocklist} instead. |
| 326 | * |
| 327 | * @hide |
| 328 | */ |
| 329 | @SystemApi |
| 330 | @Deprecated |
| 331 | public boolean hasSatelliteBlacklist() { |
| 332 | return (mTopFlags & TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST) != 0; |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Returns {@code true} if GNSS chipset supports satellite blocklists, {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 337 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 338 | public boolean hasSatelliteBlocklist() { |
| 339 | return (mTopFlags & TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /** |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 343 | * Returns {@code true} if GNSS chipset supports satellite PVT, {@code false} otherwise. |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 344 | */ |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 345 | public boolean hasSatellitePvt() { |
| 346 | return (mTopFlags & TOP_HAL_CAPABILITY_SATELLITE_PVT) != 0; |
| 347 | } |
| 348 | |
| 349 | /** |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 350 | * Returns {@code true} if GNSS chipset supports measurement corrections, {@code false} |
| 351 | * otherwise. |
| 352 | */ |
| 353 | public boolean hasMeasurementCorrections() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 354 | return (mTopFlags & TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS) != 0; |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Returns {@code true} if GNSS chipset supports antenna info, {@code false} otherwise. |
| 359 | * |
| 360 | * @deprecated Use {@link #hasAntennaInfo()} instead. |
| 361 | */ |
| 362 | @Deprecated |
| 363 | public boolean hasGnssAntennaInfo() { |
| 364 | return hasAntennaInfo(); |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Returns {@code true} if GNSS chipset supports antenna info, {@code false} otherwise. |
| 369 | * |
| 370 | * @see LocationManager#registerAntennaInfoListener(Executor, GnssAntennaInfo.Listener) |
| 371 | */ |
| 372 | public boolean hasAntennaInfo() { |
| 373 | return (mTopFlags & TOP_HAL_CAPABILITY_ANTENNA_INFO) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /** |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 377 | * Returns {@code true} if GNSS chipset supports correlation vectors as part of measurements |
| 378 | * outputs, {@code false} otherwise. |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 379 | */ |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 380 | public boolean hasMeasurementCorrelationVectors() { |
| 381 | return (mTopFlags & TOP_HAL_CAPABILITY_CORRELATION_VECTOR) != 0; |
| 382 | } |
| 383 | |
| 384 | /** |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 385 | * Returns {@code true} if GNSS chipset will benefit from measurement corrections for driving |
| 386 | * use case if provided, {@code false} otherwise. |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 387 | */ |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 388 | public boolean hasMeasurementCorrectionsForDriving() { |
| 389 | return (mTopFlags & TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING) != 0; |
| 390 | } |
| 391 | |
| 392 | /** |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 393 | * Returns {@link #CAPABILITY_SUPPORTED} if GNSS chipset supports accumulated delta |
| 394 | * range, {@link #CAPABILITY_UNSUPPORTED} if GNSS chipset does not support accumulated |
| 395 | * delta range, and {@link #CAPABILITY_UNKNOWN} if it is unknown, which means GNSS |
| 396 | * chipset may or may not support accumulated delta range. |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 397 | * |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 398 | * <p>The accumulated delta range information can be queried in |
| 399 | * {@link android.location.GnssMeasurement#getAccumulatedDeltaRangeState()}, |
| 400 | * {@link android.location.GnssMeasurement#getAccumulatedDeltaRangeMeters()}, and |
| 401 | * {@link android.location.GnssMeasurement#getAccumulatedDeltaRangeUncertaintyMeters()}. |
| 402 | */ |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 403 | public @CapabilitySupportType int hasAccumulatedDeltaRange() { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 404 | if (!mIsAdrCapabilityKnown) { |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 405 | return CAPABILITY_UNKNOWN; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 406 | } |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 407 | if ((mTopFlags & TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE) != 0) { |
| 408 | return CAPABILITY_SUPPORTED; |
| 409 | } else { |
| 410 | return CAPABILITY_UNSUPPORTED; |
| 411 | } |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | /** |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 415 | * Returns {@code true} if GNSS chipset supports line-of-sight satellite identification |
| 416 | * measurement corrections, {@code false} otherwise. |
| 417 | */ |
| 418 | public boolean hasMeasurementCorrectionsLosSats() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 419 | return (mMeasurementCorrectionsFlags & SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_LOS_SATS) |
| 420 | != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /** |
| 424 | * Returns {@code true} if GNSS chipset supports per satellite excess-path-length measurement |
| 425 | * corrections, {@code false} otherwise. |
| 426 | */ |
| 427 | public boolean hasMeasurementCorrectionsExcessPathLength() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 428 | return (mMeasurementCorrectionsFlags |
| 429 | & SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_EXCESS_PATH_LENGTH) != 0; |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 433 | * Returns {@code true} if GNSS chipset supports reflecting plane measurement corrections, |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 434 | * {@code false} otherwise. |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 435 | * |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 436 | * @deprecated Use {@link #hasMeasurementCorrectionsReflectingPlane()} instead. |
| 437 | * |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 438 | * @hide |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 439 | */ |
| Sasha Kuznetsov | 213bb70 | 2020-02-14 16:14:39 -0800 | [diff] [blame] | 440 | @SystemApi |
| Anil Admal | 3ba0fa9 | 2019-04-19 17:43:00 -0700 | [diff] [blame] | 441 | public boolean hasMeasurementCorrectionsReflectingPane() { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 442 | return hasMeasurementCorrectionsReflectingPlane(); |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| Sasha Kuznetsov | a68a7a3 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 445 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 446 | * Returns {@code true} if GNSS chipset supports reflecting plane measurement corrections, |
| 447 | * {@code false} otherwise. |
| Sasha Kuznetsov | a68a7a3 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 448 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 449 | public boolean hasMeasurementCorrectionsReflectingPlane() { |
| 450 | return (mMeasurementCorrectionsFlags |
| 451 | & SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_REFLECTING_PLANE) != 0; |
| Sasha Kuznetsov | a68a7a3 | 2020-02-11 06:00:10 +0000 | [diff] [blame] | 452 | } |
| 453 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 454 | /** |
| 455 | * Returns {@code true} if GNSS chipset supports measuring power totals, {@code false} |
| 456 | * otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 457 | */ |
| 458 | public boolean hasPowerTotal() { |
| 459 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_TOTAL) != 0; |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Returns {@code true} if GNSS chipset supports measuring single-band tracking power, |
| 464 | * {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 465 | */ |
| 466 | public boolean hasPowerSinglebandTracking() { |
| 467 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_SINGLEBAND_TRACKING) != 0; |
| 468 | } |
| 469 | |
| 470 | /** |
| 471 | * Returns {@code true} if GNSS chipset supports measuring multi-band tracking power, |
| 472 | * {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 473 | */ |
| 474 | public boolean hasPowerMultibandTracking() { |
| 475 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_MULTIBAND_TRACKING) != 0; |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | * Returns {@code true} if GNSS chipset supports measuring single-band acquisition power, |
| 480 | * {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 481 | */ |
| 482 | public boolean hasPowerSinglebandAcquisition() { |
| 483 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_SINGLEBAND_ACQUISITION) != 0; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Returns {@code true} if GNSS chipset supports measuring multi-band acquisition power, |
| 488 | * {@code false} otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 489 | */ |
| 490 | public boolean hasPowerMultibandAcquisition() { |
| 491 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_MULTIBAND_ACQUISITION) != 0; |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Returns {@code true} if GNSS chipset supports measuring OEM defined mode power, {@code false} |
| 496 | * otherwise. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 497 | */ |
| 498 | public boolean hasPowerOtherModes() { |
| 499 | return (mPowerFlags & SUB_HAL_POWER_CAPABILITY_OTHER_MODES) != 0; |
| 500 | } |
| 501 | |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 502 | /** |
| 503 | * Returns the list of {@link GnssSignalType}s that the GNSS chipset supports. |
| 504 | */ |
| 505 | @NonNull |
| 506 | public List<GnssSignalType> getGnssSignalTypes() { |
| 507 | return mGnssSignalTypes; |
| 508 | } |
| 509 | |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 510 | @Override |
| 511 | public boolean equals(Object o) { |
| 512 | if (this == o) { |
| 513 | return true; |
| 514 | } |
| 515 | if (!(o instanceof GnssCapabilities)) { |
| 516 | return false; |
| 517 | } |
| 518 | |
| 519 | GnssCapabilities that = (GnssCapabilities) o; |
| 520 | return mTopFlags == that.mTopFlags |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 521 | && mIsAdrCapabilityKnown == that.mIsAdrCapabilityKnown |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 522 | && mMeasurementCorrectionsFlags == that.mMeasurementCorrectionsFlags |
| Yu-Han Yang | e75758a | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 523 | && mPowerFlags == that.mPowerFlags |
| 524 | && mGnssSignalTypes.equals(that.mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | @Override |
| 528 | public int hashCode() { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 529 | return Objects.hash(mTopFlags, mIsAdrCapabilityKnown, mMeasurementCorrectionsFlags, |
| 530 | mPowerFlags, mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | public static final @NonNull Creator<GnssCapabilities> CREATOR = |
| 534 | new Creator<GnssCapabilities>() { |
| 535 | @Override |
| 536 | public GnssCapabilities createFromParcel(Parcel in) { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 537 | return new GnssCapabilities(in.readInt(), in.readBoolean(), in.readInt(), |
| 538 | in.readInt(), in.createTypedArrayList(GnssSignalType.CREATOR)); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | @Override |
| 542 | public GnssCapabilities[] newArray(int size) { |
| 543 | return new GnssCapabilities[size]; |
| 544 | } |
| 545 | }; |
| 546 | |
| 547 | @Override |
| 548 | public int describeContents() { |
| 549 | return 0; |
| 550 | } |
| 551 | |
| 552 | @Override |
| 553 | public void writeToParcel(@NonNull Parcel parcel, int flags) { |
| 554 | parcel.writeInt(mTopFlags); |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 555 | parcel.writeBoolean(mIsAdrCapabilityKnown); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 556 | parcel.writeInt(mMeasurementCorrectionsFlags); |
| 557 | parcel.writeInt(mPowerFlags); |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 558 | parcel.writeTypedList(mGnssSignalTypes); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | @Override |
| 562 | public String toString() { |
| 563 | StringBuilder builder = new StringBuilder(); |
| 564 | builder.append("["); |
| 565 | if (hasScheduling()) { |
| 566 | builder.append("SCHEDULING "); |
| 567 | } |
| 568 | if (hasMsb()) { |
| 569 | builder.append("MSB "); |
| 570 | } |
| 571 | if (hasMsa()) { |
| 572 | builder.append("MSA "); |
| 573 | } |
| Yu-Han Yang | ac91396 | 2022-10-25 16:49:17 +0000 | [diff] [blame] | 574 | if (hasSingleShotFix()) { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 575 | builder.append("SINGLE_SHOT "); |
| 576 | } |
| 577 | if (hasOnDemandTime()) { |
| 578 | builder.append("ON_DEMAND_TIME "); |
| 579 | } |
| 580 | if (hasGeofencing()) { |
| 581 | builder.append("GEOFENCING "); |
| 582 | } |
| 583 | if (hasMeasurementCorrections()) { |
| 584 | builder.append("MEASUREMENTS "); |
| 585 | } |
| 586 | if (hasNavigationMessages()) { |
| 587 | builder.append("NAVIGATION_MESSAGES "); |
| 588 | } |
| 589 | if (hasLowPowerMode()) { |
| 590 | builder.append("LOW_POWER_MODE "); |
| 591 | } |
| 592 | if (hasSatelliteBlocklist()) { |
| 593 | builder.append("SATELLITE_BLOCKLIST "); |
| 594 | } |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 595 | if (hasSatellitePvt()) { |
| 596 | builder.append("SATELLITE_PVT "); |
| 597 | } |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 598 | if (hasMeasurementCorrections()) { |
| 599 | builder.append("MEASUREMENT_CORRECTIONS "); |
| 600 | } |
| 601 | if (hasAntennaInfo()) { |
| 602 | builder.append("ANTENNA_INFO "); |
| 603 | } |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 604 | if (hasMeasurementCorrelationVectors()) { |
| 605 | builder.append("MEASUREMENT_CORRELATION_VECTORS "); |
| 606 | } |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 607 | if (hasMeasurementCorrectionsForDriving()) { |
| 608 | builder.append("MEASUREMENT_CORRECTIONS_FOR_DRIVING "); |
| 609 | } |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 610 | if (hasAccumulatedDeltaRange() == CAPABILITY_SUPPORTED) { |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 611 | builder.append("ACCUMULATED_DELTA_RANGE "); |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 612 | } else if (hasAccumulatedDeltaRange() == CAPABILITY_UNKNOWN) { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 613 | builder.append("ACCUMULATED_DELTA_RANGE(unknown) "); |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 614 | } |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 615 | if (hasMeasurementCorrectionsLosSats()) { |
| 616 | builder.append("LOS_SATS "); |
| 617 | } |
| 618 | if (hasMeasurementCorrectionsExcessPathLength()) { |
| 619 | builder.append("EXCESS_PATH_LENGTH "); |
| 620 | } |
| 621 | if (hasMeasurementCorrectionsReflectingPlane()) { |
| 622 | builder.append("REFLECTING_PLANE "); |
| 623 | } |
| 624 | if (hasPowerTotal()) { |
| 625 | builder.append("TOTAL_POWER "); |
| 626 | } |
| 627 | if (hasPowerSinglebandTracking()) { |
| 628 | builder.append("SINGLEBAND_TRACKING_POWER "); |
| 629 | } |
| 630 | if (hasPowerMultibandTracking()) { |
| 631 | builder.append("MULTIBAND_TRACKING_POWER "); |
| 632 | } |
| 633 | if (hasPowerSinglebandAcquisition()) { |
| 634 | builder.append("SINGLEBAND_ACQUISITION_POWER "); |
| 635 | } |
| 636 | if (hasPowerMultibandAcquisition()) { |
| 637 | builder.append("MULTIBAND_ACQUISITION_POWER "); |
| 638 | } |
| 639 | if (hasPowerOtherModes()) { |
| 640 | builder.append("OTHER_MODES_POWER "); |
| 641 | } |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 642 | if (!mGnssSignalTypes.isEmpty()) { |
| 643 | builder.append("signalTypes=").append(mGnssSignalTypes).append(" "); |
| 644 | } |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 645 | if (builder.length() > 1) { |
| 646 | builder.setLength(builder.length() - 1); |
| 647 | } else { |
| 648 | builder.append("NONE"); |
| 649 | } |
| 650 | builder.append("]"); |
| 651 | return builder.toString(); |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Builder for GnssCapabilities. |
| 656 | */ |
| 657 | public static final class Builder { |
| 658 | |
| 659 | private @TopHalCapabilityFlags int mTopFlags; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 660 | private boolean mIsAdrCapabilityKnown; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 661 | private @SubHalMeasurementCorrectionsCapabilityFlags int mMeasurementCorrectionsFlags; |
| 662 | private @SubHalPowerCapabilityFlags int mPowerFlags; |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 663 | private @NonNull List<GnssSignalType> mGnssSignalTypes; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 664 | |
| 665 | public Builder() { |
| 666 | mTopFlags = 0; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 667 | mIsAdrCapabilityKnown = false; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 668 | mMeasurementCorrectionsFlags = 0; |
| 669 | mPowerFlags = 0; |
| Yu-Han Yang | 0d08d6d | 2022-11-08 17:38:17 +0000 | [diff] [blame] | 670 | mGnssSignalTypes = Collections.emptyList(); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | public Builder(@NonNull GnssCapabilities capabilities) { |
| 674 | mTopFlags = capabilities.mTopFlags; |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 675 | mIsAdrCapabilityKnown = capabilities.mIsAdrCapabilityKnown; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 676 | mMeasurementCorrectionsFlags = capabilities.mMeasurementCorrectionsFlags; |
| 677 | mPowerFlags = capabilities.mPowerFlags; |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 678 | mGnssSignalTypes = capabilities.mGnssSignalTypes; |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /** |
| 682 | * Sets scheduling capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 683 | */ |
| 684 | public @NonNull Builder setHasScheduling(boolean capable) { |
| 685 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_SCHEDULING, capable); |
| 686 | return this; |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Sets Mobile Station Based capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 691 | */ |
| 692 | public @NonNull Builder setHasMsb(boolean capable) { |
| 693 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_MSB, capable); |
| 694 | return this; |
| 695 | } |
| 696 | |
| 697 | /** |
| 698 | * Sets Mobile Station Assisted capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 699 | */ |
| 700 | public @NonNull Builder setHasMsa(boolean capable) { |
| 701 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_MSA, capable); |
| 702 | return this; |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * Sets single shot locating capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 707 | */ |
| Yu-Han Yang | ac91396 | 2022-10-25 16:49:17 +0000 | [diff] [blame] | 708 | public @NonNull Builder setHasSingleShotFix(boolean capable) { |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 709 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_SINGLE_SHOT, capable); |
| 710 | return this; |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Sets on demand time capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 715 | */ |
| 716 | public @NonNull Builder setHasOnDemandTime(boolean capable) { |
| 717 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_ON_DEMAND_TIME, capable); |
| 718 | return this; |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Sets geofencing capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 723 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 724 | public @NonNull Builder setHasGeofencing(boolean capable) { |
| 725 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_GEOFENCING, capable); |
| 726 | return this; |
| 727 | } |
| 728 | |
| 729 | /** |
| 730 | * Sets measurements capability. |
| 731 | */ |
| 732 | public @NonNull Builder setHasMeasurements(boolean capable) { |
| 733 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_MEASUREMENTS, capable); |
| 734 | return this; |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * Sets navigation messages capability. |
| 739 | */ |
| 740 | public @NonNull Builder setHasNavigationMessages(boolean capable) { |
| 741 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_NAV_MESSAGES, capable); |
| 742 | return this; |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * Sets low power mode capability. |
| 747 | * |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 748 | * <p>The low power mode is defined in GNSS HAL. When the low power mode is active, the GNSS |
| 749 | * hardware must make strong tradeoffs to substantially restrict power use. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 750 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 751 | public @NonNull Builder setHasLowPowerMode(boolean capable) { |
| 752 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_LOW_POWER_MODE, capable); |
| 753 | return this; |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * Sets satellite blocklist capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 758 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 759 | public @NonNull Builder setHasSatelliteBlocklist(boolean capable) { |
| 760 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST, capable); |
| 761 | return this; |
| 762 | } |
| 763 | |
| 764 | /** |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 765 | * Sets satellite PVT capability. |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 766 | */ |
| Joe Huang | e256219 | 2020-12-19 21:04:23 +0800 | [diff] [blame] | 767 | public @NonNull Builder setHasSatellitePvt(boolean capable) { |
| 768 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_SATELLITE_PVT, capable); |
| 769 | return this; |
| 770 | } |
| 771 | |
| 772 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 773 | * Sets measurement corrections capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 774 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 775 | public @NonNull Builder setHasMeasurementCorrections(boolean capable) { |
| 776 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS, capable); |
| 777 | return this; |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Sets antenna info capability. |
| 782 | */ |
| 783 | public @NonNull Builder setHasAntennaInfo(boolean capable) { |
| 784 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_ANTENNA_INFO, capable); |
| 785 | return this; |
| 786 | } |
| 787 | |
| 788 | /** |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 789 | * Sets correlation vector capability. |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 790 | */ |
| Shinru Han | daffd22 | 2020-12-21 21:11:33 +0800 | [diff] [blame] | 791 | public @NonNull Builder setHasMeasurementCorrelationVectors(boolean capable) { |
| 792 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_CORRELATION_VECTOR, capable); |
| 793 | return this; |
| 794 | } |
| 795 | |
| 796 | /** |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 797 | * Sets measurement corrections for driving capability. |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 798 | */ |
| Shinru Han | 2bd6304 | 2021-03-16 17:37:16 +0800 | [diff] [blame] | 799 | public @NonNull Builder setHasMeasurementCorrectionsForDriving(boolean capable) { |
| 800 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING, |
| 801 | capable); |
| 802 | return this; |
| 803 | } |
| 804 | |
| 805 | /** |
| Yu-Han Yang | 40076ac | 2022-11-22 22:09:06 +0000 | [diff] [blame] | 806 | * Sets accumulated delta range capability. |
| 807 | */ |
| Yu-Han Yang | e5aef39 | 2023-03-01 22:38:35 +0000 | [diff] [blame] | 808 | public @NonNull Builder setHasAccumulatedDeltaRange(@CapabilitySupportType int capable) { |
| 809 | if (capable == CAPABILITY_UNKNOWN) { |
| 810 | mIsAdrCapabilityKnown = false; |
| 811 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE, false); |
| 812 | } else if (capable == CAPABILITY_SUPPORTED) { |
| 813 | mIsAdrCapabilityKnown = true; |
| 814 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE, true); |
| 815 | } else if (capable == CAPABILITY_UNSUPPORTED) { |
| 816 | mIsAdrCapabilityKnown = true; |
| 817 | mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_ACCUMULATED_DELTA_RANGE, false); |
| 818 | } |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 819 | return this; |
| 820 | } |
| 821 | |
| 822 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 823 | * Sets measurement corrections line-of-sight satellites capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 824 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 825 | public @NonNull Builder setHasMeasurementCorrectionsLosSats(boolean capable) { |
| 826 | mMeasurementCorrectionsFlags = setFlag(mMeasurementCorrectionsFlags, |
| 827 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_LOS_SATS, capable); |
| 828 | return this; |
| 829 | } |
| 830 | |
| 831 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 832 | * Sets measurement corrections excess path length capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 833 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 834 | public @NonNull Builder setHasMeasurementCorrectionsExcessPathLength(boolean capable) { |
| 835 | mMeasurementCorrectionsFlags = setFlag(mMeasurementCorrectionsFlags, |
| 836 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_EXCESS_PATH_LENGTH, capable); |
| 837 | return this; |
| 838 | } |
| 839 | |
| 840 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 841 | * Sets measurement corrections reflecting plane capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 842 | */ |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 843 | public @NonNull Builder setHasMeasurementCorrectionsReflectingPlane(boolean capable) { |
| 844 | mMeasurementCorrectionsFlags = setFlag(mMeasurementCorrectionsFlags, |
| 845 | SUB_HAL_MEASUREMENT_CORRECTIONS_CAPABILITY_REFLECTING_PLANE, capable); |
| 846 | return this; |
| 847 | } |
| 848 | |
| 849 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 850 | * Sets power totals capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 851 | */ |
| 852 | public @NonNull Builder setHasPowerTotal(boolean capable) { |
| 853 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_TOTAL, capable); |
| 854 | return this; |
| 855 | } |
| 856 | |
| 857 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 858 | * Sets power single-band tracking capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 859 | */ |
| 860 | public @NonNull Builder setHasPowerSinglebandTracking(boolean capable) { |
| 861 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_SINGLEBAND_TRACKING, |
| 862 | capable); |
| 863 | return this; |
| 864 | } |
| 865 | |
| 866 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 867 | * Sets power multi-band tracking capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 868 | */ |
| 869 | public @NonNull Builder setHasPowerMultibandTracking(boolean capable) { |
| 870 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_MULTIBAND_TRACKING, |
| 871 | capable); |
| 872 | return this; |
| 873 | } |
| 874 | |
| 875 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 876 | * Sets power single-band acquisition capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 877 | */ |
| 878 | public @NonNull Builder setHasPowerSinglebandAcquisition(boolean capable) { |
| 879 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_SINGLEBAND_ACQUISITION, |
| 880 | capable); |
| 881 | return this; |
| 882 | } |
| 883 | |
| 884 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 885 | * Sets power multi-band acquisition capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 886 | */ |
| 887 | public @NonNull Builder setHasPowerMultibandAcquisition(boolean capable) { |
| 888 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_MULTIBAND_ACQUISITION, |
| 889 | capable); |
| 890 | return this; |
| 891 | } |
| 892 | |
| 893 | /** |
| Yu-Han Yang | 7756059 | 2022-10-11 03:49:32 +0000 | [diff] [blame] | 894 | * Sets OEM-defined power modes capability. |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 895 | */ |
| 896 | public @NonNull Builder setHasPowerOtherModes(boolean capable) { |
| 897 | mPowerFlags = setFlag(mPowerFlags, SUB_HAL_POWER_CAPABILITY_OTHER_MODES, capable); |
| 898 | return this; |
| 899 | } |
| 900 | |
| 901 | /** |
| Yu-Han Yang | d4dea7d | 2022-10-28 21:13:25 +0000 | [diff] [blame] | 902 | * Sets a list of {@link GnssSignalType}. |
| 903 | */ |
| 904 | public @NonNull Builder setGnssSignalTypes(@NonNull List<GnssSignalType> gnssSignalTypes) { |
| 905 | mGnssSignalTypes = gnssSignalTypes; |
| 906 | return this; |
| 907 | } |
| 908 | |
| 909 | /** |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 910 | * Builds a new GnssCapabilities. |
| 911 | */ |
| 912 | public @NonNull GnssCapabilities build() { |
| Yu-Han Yang | 17d08b8 | 2022-12-22 22:26:25 +0000 | [diff] [blame] | 913 | return new GnssCapabilities(mTopFlags, mIsAdrCapabilityKnown, |
| 914 | mMeasurementCorrectionsFlags, mPowerFlags, new ArrayList<>(mGnssSignalTypes)); |
| Soonil Nagarkar | a8e676b | 2020-12-08 18:47:08 -0800 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | private static int setFlag(int value, int flag, boolean set) { |
| 918 | if (set) { |
| 919 | return value | flag; |
| 920 | } else { |
| 921 | return value & ~flag; |
| 922 | } |
| 923 | } |
| Anil Admal | 9934978 | 2019-03-19 18:58:42 -0700 | [diff] [blame] | 924 | } |
| 925 | } |