blob: e39b198ae38476d4658cc379c21a23f099488309 [file] [log] [blame]
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -08001/*
2 * Copyright (C) 2017 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
17package android.bluetooth.le;
18
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -070019import android.bluetooth.BluetoothAdapter;
Jakub Pawlowski9e377192017-04-12 08:51:22 -070020import android.bluetooth.BluetoothDevice;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -080021import android.os.Parcel;
22import android.os.Parcelable;
23
24/**
25 * The {@link AdvertisingSetParameters} provide a way to adjust advertising
26 * preferences for each
27 * Bluetooth LE advertising set. Use {@link AdvertisingSetParameters.Builder} to
28 * create an
29 * instance of this class.
30 */
31public final class AdvertisingSetParameters implements Parcelable {
32
33 /**
Jack Hea355e5e2017-08-22 16:06:54 -070034 * Advertise on low frequency, around every 1000ms. This is the default and
35 * preferred advertising mode as it consumes the least power.
36 */
Jakub Pawlowski6b1f3952017-05-09 14:28:21 -070037 public static final int INTERVAL_HIGH = 1600;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -080038
39 /**
40 * Advertise on medium frequency, around every 250ms. This is balanced
41 * between advertising frequency and power consumption.
42 */
43 public static final int INTERVAL_MEDIUM = 400;
44
45 /**
46 * Perform high frequency, low latency advertising, around every 100ms. This
47 * has the highest power consumption and should not be used for continuous
48 * background advertising.
49 */
Jakub Pawlowski6b1f3952017-05-09 14:28:21 -070050 public static final int INTERVAL_LOW = 160;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -080051
52 /**
53 * Minimum value for advertising interval.
54 */
55 public static final int INTERVAL_MIN = 160;
56
57 /**
58 * Maximum value for advertising interval.
59 */
60 public static final int INTERVAL_MAX = 16777215;
61
62 /**
63 * Advertise using the lowest transmission (TX) power level. Low transmission
64 * power can be used to restrict the visibility range of advertising packets.
65 */
66 public static final int TX_POWER_ULTRA_LOW = -21;
67
68 /**
69 * Advertise using low TX power level.
70 */
71 public static final int TX_POWER_LOW = -15;
72
73 /**
74 * Advertise using medium TX power level.
75 */
76 public static final int TX_POWER_MEDIUM = -7;
77
78 /**
79 * Advertise using high TX power level. This corresponds to largest visibility
80 * range of the advertising packet.
81 */
82 public static final int TX_POWER_HIGH = 1;
83
84 /**
85 * Minimum value for TX power.
86 */
87 public static final int TX_POWER_MIN = -127;
88
89 /**
90 * Maximum value for TX power.
91 */
92 public static final int TX_POWER_MAX = 1;
93
94 /**
95 * The maximum limited advertisement duration as specified by the Bluetooth
96 * SIG
97 */
98 private static final int LIMITED_ADVERTISING_MAX_MILLIS = 180 * 1000;
99
Jack He2992cd02017-08-22 21:21:23 -0700100 private final boolean mIsLegacy;
101 private final boolean mIsAnonymous;
102 private final boolean mIncludeTxPower;
103 private final int mPrimaryPhy;
104 private final int mSecondaryPhy;
105 private final boolean mConnectable;
106 private final boolean mScannable;
107 private final int mInterval;
108 private final int mTxPowerLevel;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800109
Jakub Pawlowskid12b5682017-03-20 15:57:46 -0700110 private AdvertisingSetParameters(boolean connectable, boolean scannable, boolean isLegacy,
Jack Hea355e5e2017-08-22 16:06:54 -0700111 boolean isAnonymous, boolean includeTxPower,
112 int primaryPhy, int secondaryPhy,
113 int interval, int txPowerLevel) {
Jack He2992cd02017-08-22 21:21:23 -0700114 mConnectable = connectable;
115 mScannable = scannable;
116 mIsLegacy = isLegacy;
117 mIsAnonymous = isAnonymous;
118 mIncludeTxPower = includeTxPower;
119 mPrimaryPhy = primaryPhy;
120 mSecondaryPhy = secondaryPhy;
121 mInterval = interval;
122 mTxPowerLevel = txPowerLevel;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800123 }
124
125 private AdvertisingSetParameters(Parcel in) {
Jack He2992cd02017-08-22 21:21:23 -0700126 mConnectable = in.readInt() != 0;
127 mScannable = in.readInt() != 0;
128 mIsLegacy = in.readInt() != 0;
129 mIsAnonymous = in.readInt() != 0;
130 mIncludeTxPower = in.readInt() != 0;
131 mPrimaryPhy = in.readInt();
132 mSecondaryPhy = in.readInt();
133 mInterval = in.readInt();
134 mTxPowerLevel = in.readInt();
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800135 }
136
137 /**
138 * Returns whether the advertisement will be connectable.
139 */
Jack Hea355e5e2017-08-22 16:06:54 -0700140 public boolean isConnectable() {
Jack He2992cd02017-08-22 21:21:23 -0700141 return mConnectable;
Jack Hea355e5e2017-08-22 16:06:54 -0700142 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800143
144 /**
Jakub Pawlowskid12b5682017-03-20 15:57:46 -0700145 * Returns whether the advertisement will be scannable.
146 */
Jack Hea355e5e2017-08-22 16:06:54 -0700147 public boolean isScannable() {
Jack He2992cd02017-08-22 21:21:23 -0700148 return mScannable;
Jack Hea355e5e2017-08-22 16:06:54 -0700149 }
Jakub Pawlowskid12b5682017-03-20 15:57:46 -0700150
151 /**
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800152 * Returns whether the legacy advertisement will be used.
153 */
Jack Hea355e5e2017-08-22 16:06:54 -0700154 public boolean isLegacy() {
Jack He2992cd02017-08-22 21:21:23 -0700155 return mIsLegacy;
Jack Hea355e5e2017-08-22 16:06:54 -0700156 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800157
158 /**
159 * Returns whether the advertisement will be anonymous.
160 */
Jack Hea355e5e2017-08-22 16:06:54 -0700161 public boolean isAnonymous() {
Jack He2992cd02017-08-22 21:21:23 -0700162 return mIsAnonymous;
Jack Hea355e5e2017-08-22 16:06:54 -0700163 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800164
165 /**
166 * Returns whether the TX Power will be included.
167 */
Jack Hea355e5e2017-08-22 16:06:54 -0700168 public boolean includeTxPower() {
Jack He2992cd02017-08-22 21:21:23 -0700169 return mIncludeTxPower;
Jack Hea355e5e2017-08-22 16:06:54 -0700170 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800171
172 /**
173 * Returns the primary advertising phy.
174 */
Jack Hea355e5e2017-08-22 16:06:54 -0700175 public int getPrimaryPhy() {
Jack He2992cd02017-08-22 21:21:23 -0700176 return mPrimaryPhy;
Jack Hea355e5e2017-08-22 16:06:54 -0700177 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800178
179 /**
180 * Returns the secondary advertising phy.
181 */
Jack Hea355e5e2017-08-22 16:06:54 -0700182 public int getSecondaryPhy() {
Jack He2992cd02017-08-22 21:21:23 -0700183 return mSecondaryPhy;
Jack Hea355e5e2017-08-22 16:06:54 -0700184 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800185
186 /**
187 * Returns the advertising interval.
188 */
Jack Hea355e5e2017-08-22 16:06:54 -0700189 public int getInterval() {
Jack He2992cd02017-08-22 21:21:23 -0700190 return mInterval;
Jack Hea355e5e2017-08-22 16:06:54 -0700191 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800192
193 /**
194 * Returns the TX power level for advertising.
195 */
Jack Hea355e5e2017-08-22 16:06:54 -0700196 public int getTxPowerLevel() {
Jack He2992cd02017-08-22 21:21:23 -0700197 return mTxPowerLevel;
Jack Hea355e5e2017-08-22 16:06:54 -0700198 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800199
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800200 @Override
201 public String toString() {
Jack He2992cd02017-08-22 21:21:23 -0700202 return "AdvertisingSetParameters [connectable=" + mConnectable
203 + ", isLegacy=" + mIsLegacy
204 + ", isAnonymous=" + mIsAnonymous
205 + ", includeTxPower=" + mIncludeTxPower
206 + ", primaryPhy=" + mPrimaryPhy
207 + ", secondaryPhy=" + mSecondaryPhy
208 + ", interval=" + mInterval
209 + ", txPowerLevel=" + mTxPowerLevel + "]";
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800210 }
211
212 @Override
213 public int describeContents() {
Jack Hea355e5e2017-08-22 16:06:54 -0700214 return 0;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800215 }
216
217 @Override
218 public void writeToParcel(Parcel dest, int flags) {
Jack He2992cd02017-08-22 21:21:23 -0700219 dest.writeInt(mConnectable ? 1 : 0);
220 dest.writeInt(mScannable ? 1 : 0);
221 dest.writeInt(mIsLegacy ? 1 : 0);
222 dest.writeInt(mIsAnonymous ? 1 : 0);
223 dest.writeInt(mIncludeTxPower ? 1 : 0);
224 dest.writeInt(mPrimaryPhy);
225 dest.writeInt(mSecondaryPhy);
226 dest.writeInt(mInterval);
227 dest.writeInt(mTxPowerLevel);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800228 }
229
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700230 public static final @android.annotation.NonNull Parcelable.Creator<AdvertisingSetParameters> CREATOR =
Jack Hea355e5e2017-08-22 16:06:54 -0700231 new Creator<AdvertisingSetParameters>() {
232 @Override
233 public AdvertisingSetParameters[] newArray(int size) {
234 return new AdvertisingSetParameters[size];
235 }
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800236
Jack Hea355e5e2017-08-22 16:06:54 -0700237 @Override
238 public AdvertisingSetParameters createFromParcel(Parcel in) {
239 return new AdvertisingSetParameters(in);
240 }
241 };
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800242
243 /**
244 * Builder class for {@link AdvertisingSetParameters}.
245 */
246 public static final class Builder {
Jack He2992cd02017-08-22 21:21:23 -0700247 private boolean mConnectable = false;
248 private boolean mScannable = false;
249 private boolean mIsLegacy = false;
250 private boolean mIsAnonymous = false;
251 private boolean mIncludeTxPower = false;
252 private int mPrimaryPhy = BluetoothDevice.PHY_LE_1M;
253 private int mSecondaryPhy = BluetoothDevice.PHY_LE_1M;
254 private int mInterval = INTERVAL_LOW;
255 private int mTxPowerLevel = TX_POWER_MEDIUM;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800256
257 /**
258 * Set whether the advertisement type should be connectable or
259 * non-connectable.
Jakub Pawlowski010cc952017-04-06 07:22:57 -0700260 * Legacy advertisements can be both connectable and scannable. Non-legacy
Jakub Pawlowskie7f89b02017-03-22 22:53:18 -0700261 * advertisements can be only scannable or only connectable.
Jack Hea355e5e2017-08-22 16:06:54 -0700262 *
263 * @param connectable Controls whether the advertisement type will be connectable (true) or
264 * non-connectable (false).
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800265 */
266 public Builder setConnectable(boolean connectable) {
Jack He2992cd02017-08-22 21:21:23 -0700267 mConnectable = connectable;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800268 return this;
269 }
270
271 /**
Jakub Pawlowskie7f89b02017-03-22 22:53:18 -0700272 * Set whether the advertisement type should be scannable.
Jakub Pawlowski010cc952017-04-06 07:22:57 -0700273 * Legacy advertisements can be both connectable and scannable. Non-legacy
Jakub Pawlowskie7f89b02017-03-22 22:53:18 -0700274 * advertisements can be only scannable or only connectable.
Jack Hea355e5e2017-08-22 16:06:54 -0700275 *
276 * @param scannable Controls whether the advertisement type will be scannable (true) or
277 * non-scannable (false).
Jakub Pawlowskid12b5682017-03-20 15:57:46 -0700278 */
279 public Builder setScannable(boolean scannable) {
Jack He2992cd02017-08-22 21:21:23 -0700280 mScannable = scannable;
Jakub Pawlowskid12b5682017-03-20 15:57:46 -0700281 return this;
282 }
283
284 /**
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800285 * When set to true, advertising set will advertise 4.x Spec compliant
286 * advertisements.
287 *
Jakub Pawlowski08ed9242017-03-22 22:44:09 -0700288 * @param isLegacy whether legacy advertising mode should be used.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800289 */
290 public Builder setLegacyMode(boolean isLegacy) {
Jack He2992cd02017-08-22 21:21:23 -0700291 mIsLegacy = isLegacy;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800292 return this;
293 }
294
295 /**
Jakub Pawlowski08ed9242017-03-22 22:44:09 -0700296 * Set whether advertiser address should be ommited from all packets. If this
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800297 * mode is used, periodic advertising can't be enabled for this set.
298 *
299 * This is used only if legacy mode is not used.
300 *
Jakub Pawlowski08ed9242017-03-22 22:44:09 -0700301 * @param isAnonymous whether anonymous advertising should be used.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800302 */
Jakub Pawlowskibc2991e2017-03-10 16:07:59 -0800303 public Builder setAnonymous(boolean isAnonymous) {
Jack He2992cd02017-08-22 21:21:23 -0700304 mIsAnonymous = isAnonymous;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800305 return this;
306 }
307
308 /**
Jakub Pawlowski08ed9242017-03-22 22:44:09 -0700309 * Set whether TX power should be included in the extended header.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800310 *
311 * This is used only if legacy mode is not used.
312 *
Jack Hea355e5e2017-08-22 16:06:54 -0700313 * @param includeTxPower whether TX power should be included in extended header
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800314 */
315 public Builder setIncludeTxPower(boolean includeTxPower) {
Jack He2992cd02017-08-22 21:21:23 -0700316 mIncludeTxPower = includeTxPower;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800317 return this;
318 }
319
320 /**
321 * Set the primary physical channel used for this advertising set.
322 *
323 * This is used only if legacy mode is not used.
324 *
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700325 * Use {@link BluetoothAdapter#isLeCodedPhySupported} to determine if LE Coded PHY is
326 * supported on this device.
Jack Hea355e5e2017-08-22 16:06:54 -0700327 *
328 * @param primaryPhy Primary advertising physical channel, can only be {@link
329 * BluetoothDevice#PHY_LE_1M} or {@link BluetoothDevice#PHY_LE_CODED}.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800330 * @throws IllegalArgumentException If the primaryPhy is invalid.
331 */
332 public Builder setPrimaryPhy(int primaryPhy) {
Jack He2992cd02017-08-22 21:21:23 -0700333 if (primaryPhy != BluetoothDevice.PHY_LE_1M
334 && primaryPhy != BluetoothDevice.PHY_LE_CODED) {
Jack Hea355e5e2017-08-22 16:06:54 -0700335 throw new IllegalArgumentException("bad primaryPhy " + primaryPhy);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800336 }
Jack He2992cd02017-08-22 21:21:23 -0700337 mPrimaryPhy = primaryPhy;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800338 return this;
339 }
340
341 /**
342 * Set the secondary physical channel used for this advertising set.
343 *
344 * This is used only if legacy mode is not used.
345 *
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700346 * Use {@link BluetoothAdapter#isLeCodedPhySupported} and
347 * {@link BluetoothAdapter#isLe2MPhySupported} to determine if LE Coded PHY or 2M PHY is
348 * supported on this device.
349 *
Jack Hea355e5e2017-08-22 16:06:54 -0700350 * @param secondaryPhy Secondary advertising physical channel, can only be one of {@link
351 * BluetoothDevice#PHY_LE_1M}, {@link BluetoothDevice#PHY_LE_2M} or {@link
352 * BluetoothDevice#PHY_LE_CODED}.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800353 * @throws IllegalArgumentException If the secondaryPhy is invalid.
354 */
355 public Builder setSecondaryPhy(int secondaryPhy) {
Jack He2992cd02017-08-22 21:21:23 -0700356 if (secondaryPhy != BluetoothDevice.PHY_LE_1M
357 && secondaryPhy != BluetoothDevice.PHY_LE_2M
358 && secondaryPhy != BluetoothDevice.PHY_LE_CODED) {
Jack Hea355e5e2017-08-22 16:06:54 -0700359 throw new IllegalArgumentException("bad secondaryPhy " + secondaryPhy);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800360 }
Jack He2992cd02017-08-22 21:21:23 -0700361 mSecondaryPhy = secondaryPhy;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800362 return this;
363 }
364
365 /**
366 * Set advertising interval.
367 *
Jack Hea355e5e2017-08-22 16:06:54 -0700368 * @param interval Bluetooth LE Advertising interval, in 0.625ms unit. Valid range is from
369 * 160 (100ms) to 16777215 (10,485.759375 s). Recommended values are: {@link
370 * AdvertisingSetParameters#INTERVAL_LOW}, {@link AdvertisingSetParameters#INTERVAL_MEDIUM},
371 * or {@link AdvertisingSetParameters#INTERVAL_HIGH}.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800372 * @throws IllegalArgumentException If the interval is invalid.
373 */
374 public Builder setInterval(int interval) {
375 if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) {
Jack Hea355e5e2017-08-22 16:06:54 -0700376 throw new IllegalArgumentException("unknown interval " + interval);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800377 }
Jack He2992cd02017-08-22 21:21:23 -0700378 mInterval = interval;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800379 return this;
380 }
381
382 /**
383 * Set the transmission power level for the advertising.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800384 *
Jack Hea355e5e2017-08-22 16:06:54 -0700385 * @param txPowerLevel Transmission power of Bluetooth LE Advertising, in dBm. The valid
386 * range is [-127, 1] Recommended values are:
387 * {@link AdvertisingSetParameters#TX_POWER_ULTRA_LOW},
388 * {@link AdvertisingSetParameters#TX_POWER_LOW},
389 * {@link AdvertisingSetParameters#TX_POWER_MEDIUM},
390 * or {@link AdvertisingSetParameters#TX_POWER_HIGH}.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800391 * @throws IllegalArgumentException If the {@code txPowerLevel} is invalid.
392 */
393 public Builder setTxPowerLevel(int txPowerLevel) {
394 if (txPowerLevel < TX_POWER_MIN || txPowerLevel > TX_POWER_MAX) {
Jack He2992cd02017-08-22 21:21:23 -0700395 throw new IllegalArgumentException("unknown txPowerLevel " + txPowerLevel);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800396 }
Jack He2992cd02017-08-22 21:21:23 -0700397 mTxPowerLevel = txPowerLevel;
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800398 return this;
399 }
400
401 /**
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800402 * Build the {@link AdvertisingSetParameters} object.
Jack Hea355e5e2017-08-22 16:06:54 -0700403 *
Jakub Pawlowski9d4abb52017-04-28 04:11:26 -0700404 * @throws IllegalStateException if invalid combination of parameters is used.
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800405 */
406 public AdvertisingSetParameters build() {
Jack He2992cd02017-08-22 21:21:23 -0700407 if (mIsLegacy) {
408 if (mIsAnonymous) {
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700409 throw new IllegalArgumentException("Legacy advertising can't be anonymous");
410 }
411
Jack He2992cd02017-08-22 21:21:23 -0700412 if (mConnectable && !mScannable) {
Jakub Pawlowski9d4abb52017-04-28 04:11:26 -0700413 throw new IllegalStateException(
Jack Hea355e5e2017-08-22 16:06:54 -0700414 "Legacy advertisement can't be connectable and non-scannable");
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700415 }
416
Jack He2992cd02017-08-22 21:21:23 -0700417 if (mIncludeTxPower) {
Jakub Pawlowski9d4abb52017-04-28 04:11:26 -0700418 throw new IllegalStateException(
Jack Hea355e5e2017-08-22 16:06:54 -0700419 "Legacy advertising can't include TX power level in header");
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700420 }
421 } else {
Jack He2992cd02017-08-22 21:21:23 -0700422 if (mConnectable && mScannable) {
Jakub Pawlowski9d4abb52017-04-28 04:11:26 -0700423 throw new IllegalStateException(
Jack Hea355e5e2017-08-22 16:06:54 -0700424 "Advertising can't be both connectable and scannable");
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700425 }
426
Jack He2992cd02017-08-22 21:21:23 -0700427 if (mIsAnonymous && mConnectable) {
Jakub Pawlowski9d4abb52017-04-28 04:11:26 -0700428 throw new IllegalStateException(
Jack Hea355e5e2017-08-22 16:06:54 -0700429 "Advertising can't be both connectable and anonymous");
Jakub Pawlowskif4ed33f2017-03-30 11:19:24 -0700430 }
431 }
432
Jack He2992cd02017-08-22 21:21:23 -0700433 return new AdvertisingSetParameters(mConnectable, mScannable, mIsLegacy, mIsAnonymous,
434 mIncludeTxPower, mPrimaryPhy, mSecondaryPhy, mInterval, mTxPowerLevel);
Jakub Pawlowskia9d1a322017-01-10 06:15:54 -0800435 }
436 }
Jack He2992cd02017-08-22 21:21:23 -0700437}