summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2017-03-17 22:34:24 +0000
committer android-build-merger <android-build-merger@google.com> 2017-03-17 22:34:24 +0000
commit07d79aa3b0556fe79a15b99aee678bb6bce015cc (patch)
treee4c057bc95e40027fde28809124260bdc486ec0f
parent4992b1533e4a779e3ce47daa8f70a721f198113c (diff)
parentd9f2f67a5fc8b26fcfe0bac50ba3d9ecd7bf8b8a (diff)
Merge "Bluetooth 5 move timeout parameter (1/2)"
am: d9f2f67a5f Change-Id: Iee7d485461f5e02ab65ec9f7311e962deb603543
-rw-r--r--api/current.txt6
-rw-r--r--api/system-current.txt6
-rw-r--r--api/test-current.txt6
-rw-r--r--core/java/android/bluetooth/IBluetoothGatt.aidl4
-rw-r--r--core/java/android/bluetooth/le/AdvertisingSet.java4
-rw-r--r--core/java/android/bluetooth/le/AdvertisingSetParameters.java36
-rw-r--r--core/java/android/bluetooth/le/BluetoothLeAdvertiser.java52
7 files changed, 63 insertions, 51 deletions
diff --git a/api/current.txt b/api/current.txt
index 3f4b73d57cc5..b3d9fc119040 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7506,7 +7506,7 @@ package android.bluetooth.le {
}
public final class AdvertisingSet {
- method public void enableAdvertising(boolean);
+ method public void enableAdvertising(boolean, int);
method public void periodicAdvertisingEnable(boolean);
method public void setAdvertisingData(android.bluetooth.le.AdvertiseData);
method public void setAdvertisingParameters(android.bluetooth.le.AdvertisingSetParameters);
@@ -7539,7 +7539,6 @@ package android.bluetooth.le {
method public int getInterval();
method public int getPrimaryPhy();
method public int getSecondaryPhy();
- method public int getTimeout();
method public int getTxPowerLevel();
method public boolean includeTxPower();
method public boolean isAnonymous();
@@ -7573,7 +7572,6 @@ package android.bluetooth.le {
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
- method public android.bluetooth.le.AdvertisingSetParameters.Builder setTimeout(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
}
@@ -7582,6 +7580,8 @@ package android.bluetooth.le {
method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
method public void stopAdvertising(android.bluetooth.le.AdvertiseCallback);
method public void stopAdvertisingSet(android.bluetooth.le.AdvertisingSetCallback);
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 7241e9513f50..55d4f4e25702 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7810,7 +7810,7 @@ package android.bluetooth.le {
}
public final class AdvertisingSet {
- method public void enableAdvertising(boolean);
+ method public void enableAdvertising(boolean, int);
method public void periodicAdvertisingEnable(boolean);
method public void setAdvertisingData(android.bluetooth.le.AdvertiseData);
method public void setAdvertisingParameters(android.bluetooth.le.AdvertisingSetParameters);
@@ -7843,7 +7843,6 @@ package android.bluetooth.le {
method public int getInterval();
method public int getPrimaryPhy();
method public int getSecondaryPhy();
- method public int getTimeout();
method public int getTxPowerLevel();
method public boolean includeTxPower();
method public boolean isAnonymous();
@@ -7877,7 +7876,6 @@ package android.bluetooth.le {
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
- method public android.bluetooth.le.AdvertisingSetParameters.Builder setTimeout(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
}
@@ -7886,6 +7884,8 @@ package android.bluetooth.le {
method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
method public void stopAdvertising(android.bluetooth.le.AdvertiseCallback);
method public void stopAdvertisingSet(android.bluetooth.le.AdvertisingSetCallback);
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 074c078cc4b3..8ac5b123155f 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -7515,7 +7515,7 @@ package android.bluetooth.le {
}
public final class AdvertisingSet {
- method public void enableAdvertising(boolean);
+ method public void enableAdvertising(boolean, int);
method public void periodicAdvertisingEnable(boolean);
method public void setAdvertisingData(android.bluetooth.le.AdvertiseData);
method public void setAdvertisingParameters(android.bluetooth.le.AdvertisingSetParameters);
@@ -7548,7 +7548,6 @@ package android.bluetooth.le {
method public int getInterval();
method public int getPrimaryPhy();
method public int getSecondaryPhy();
- method public int getTimeout();
method public int getTxPowerLevel();
method public boolean includeTxPower();
method public boolean isAnonymous();
@@ -7582,7 +7581,6 @@ package android.bluetooth.le {
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
- method public android.bluetooth.le.AdvertisingSetParameters.Builder setTimeout(int);
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
}
@@ -7591,6 +7589,8 @@ package android.bluetooth.le {
method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback);
method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback);
+ method public void startAdvertisingSet(android.bluetooth.le.AdvertisingSetParameters, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.PeriodicAdvertisingParameters, android.bluetooth.le.AdvertiseData, int, android.bluetooth.le.AdvertisingSetCallback, android.os.Handler);
method public void stopAdvertising(android.bluetooth.le.AdvertiseCallback);
method public void stopAdvertisingSet(android.bluetooth.le.AdvertisingSetCallback);
}
diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl
index 29f29e7dba4e..c281c7f7b0f8 100644
--- a/core/java/android/bluetooth/IBluetoothGatt.aidl
+++ b/core/java/android/bluetooth/IBluetoothGatt.aidl
@@ -52,10 +52,10 @@ interface IBluetoothGatt {
void startAdvertisingSet(in AdvertisingSetParameters parameters, in AdvertiseData advertiseData,
in AdvertiseData scanResponse, in PeriodicAdvertisingParameters periodicParameters,
- in AdvertiseData periodicData, in IAdvertisingSetCallback callback);
+ in AdvertiseData periodicData, in int timeout, in IAdvertisingSetCallback callback);
void stopAdvertisingSet(in IAdvertisingSetCallback callback);
- void enableAdverisingSet(in int advertiserId, in boolean enable);
+ void enableAdverisingSet(in int advertiserId, in boolean enable, in int timeout);
void setAdvertisingData(in int advertiserId, in AdvertiseData data);
void setScanResponseData(in int advertiserId, in AdvertiseData data);
void setAdvertisingParameters(in int advertiserId, in AdvertisingSetParameters parameters);
diff --git a/core/java/android/bluetooth/le/AdvertisingSet.java b/core/java/android/bluetooth/le/AdvertisingSet.java
index 1524022b1f0f..5524a2bdae18 100644
--- a/core/java/android/bluetooth/le/AdvertisingSet.java
+++ b/core/java/android/bluetooth/le/AdvertisingSet.java
@@ -63,9 +63,9 @@ public final class AdvertisingSet {
* Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
*
*/
- public void enableAdvertising(boolean enable) {
+ public void enableAdvertising(boolean enable, int timeout) {
try {
- gatt.enableAdverisingSet(this.advertiserId, enable);
+ gatt.enableAdverisingSet(this.advertiserId, enable, timeout);
} catch (RemoteException e) {
Log.e(TAG, "remote exception - ", e);
}
diff --git a/core/java/android/bluetooth/le/AdvertisingSetParameters.java b/core/java/android/bluetooth/le/AdvertisingSetParameters.java
index 453dd70a589c..59fef8d1d1ea 100644
--- a/core/java/android/bluetooth/le/AdvertisingSetParameters.java
+++ b/core/java/android/bluetooth/le/AdvertisingSetParameters.java
@@ -118,13 +118,11 @@ public final class AdvertisingSetParameters implements Parcelable {
private final boolean connectable;
private final int interval;
private final int txPowerLevel;
- private final int timeoutMillis;
private AdvertisingSetParameters(boolean connectable, boolean isLegacy,
boolean isAnonymous, boolean includeTxPower,
int primaryPhy, int secondaryPhy,
- int interval, int txPowerLevel,
- int timeoutMillis) {
+ int interval, int txPowerLevel) {
this.connectable = connectable;
this.isLegacy = isLegacy;
this.isAnonymous = isAnonymous;
@@ -133,7 +131,6 @@ public final class AdvertisingSetParameters implements Parcelable {
this.secondaryPhy = secondaryPhy;
this.interval = interval;
this.txPowerLevel = txPowerLevel;
- this.timeoutMillis = timeoutMillis;
}
private AdvertisingSetParameters(Parcel in) {
@@ -145,7 +142,6 @@ public final class AdvertisingSetParameters implements Parcelable {
secondaryPhy = in.readInt();
interval = in.readInt();
txPowerLevel = in.readInt();
- timeoutMillis = in.readInt();
}
/**
@@ -188,11 +184,6 @@ public final class AdvertisingSetParameters implements Parcelable {
*/
public int getTxPowerLevel() { return txPowerLevel; }
- /**
- * Returns the advertising time limit in milliseconds.
- */
- public int getTimeout() { return timeoutMillis; }
-
@Override
public String toString() {
return "AdvertisingSetParameters [connectable=" + connectable
@@ -202,8 +193,7 @@ public final class AdvertisingSetParameters implements Parcelable {
+ ", primaryPhy=" + primaryPhy
+ ", secondaryPhy=" + secondaryPhy
+ ", interval=" + interval
- + ", txPowerLevel=" + txPowerLevel
- + ", timeoutMillis=" + timeoutMillis + "]";
+ + ", txPowerLevel=" + txPowerLevel + "]";
}
@Override
@@ -221,7 +211,6 @@ public final class AdvertisingSetParameters implements Parcelable {
dest.writeInt(secondaryPhy);
dest.writeInt(interval);
dest.writeInt(txPowerLevel);
- dest.writeInt(timeoutMillis);
}
public static final Parcelable.Creator<AdvertisingSetParameters> CREATOR =
@@ -250,7 +239,6 @@ public final class AdvertisingSetParameters implements Parcelable {
private int secondaryPhy = PHY_LE_1M;
private int interval = INTERVAL_LOW;
private int txPowerLevel = TX_POWER_MEDIUM;
- private int timeoutMillis = 0;
/**
* Set whether the advertisement type should be connectable or
@@ -380,30 +368,12 @@ public final class AdvertisingSetParameters implements Parcelable {
}
/**
- * Limit advertising to a given amount of time.
- * @param timeoutMillis Advertising time limit. May not exceed 180000
- * milliseconds. A value of 0 will disable the time limit.
- * @throws IllegalArgumentException If the provided timeout is over 180000
- * ms.
- */
- public Builder setTimeout(int timeoutMillis) {
- if (timeoutMillis < 0 || timeoutMillis > LIMITED_ADVERTISING_MAX_MILLIS) {
- throw new IllegalArgumentException("timeoutMillis invalid (must be 0-" +
- LIMITED_ADVERTISING_MAX_MILLIS +
- " milliseconds)");
- }
- this.timeoutMillis = timeoutMillis;
- return this;
- }
-
- /**
* Build the {@link AdvertisingSetParameters} object.
*/
public AdvertisingSetParameters build() {
return new AdvertisingSetParameters(connectable, isLegacy, isAnonymous,
includeTxPower, primaryPhy,
- secondaryPhy, interval, txPowerLevel,
- timeoutMillis);
+ secondaryPhy, interval, txPowerLevel);
}
}
} \ No newline at end of file
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index c9f1d7a32efb..67fd1c86aa3b 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -130,7 +130,6 @@ public final class BluetoothLeAdvertiser {
AdvertisingSetParameters.Builder parameters = new AdvertisingSetParameters.Builder();
parameters.setLegacyMode(true);
parameters.setConnectable(isConnectable);
- parameters.setTimeout(settings.getTimeout());
if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_LOW_POWER) {
parameters.setInterval(1600); // 1s
} else if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_BALANCED) {
@@ -152,7 +151,7 @@ public final class BluetoothLeAdvertiser {
AdvertisingSetCallback wrapped = wrapOldCallback(callback, settings);
mLegacyAdvertisers.put(callback, wrapped);
startAdvertisingSet(parameters.build(), advertiseData, scanResponse, null, null,
- wrapped);
+ settings.getTimeout(), wrapped);
}
}
@@ -216,8 +215,8 @@ public final class BluetoothLeAdvertiser {
AdvertiseData advertiseData, AdvertiseData scanResponse,
PeriodicAdvertisingParameters periodicParameters,
AdvertiseData periodicData, AdvertisingSetCallback callback) {
- startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, callback, new Handler(Looper.getMainLooper()));
+ startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
+ periodicData, 0, callback, new Handler(Looper.getMainLooper()));
}
/**
@@ -237,6 +236,49 @@ public final class BluetoothLeAdvertiser {
PeriodicAdvertisingParameters periodicParameters,
AdvertiseData periodicData, AdvertisingSetCallback callback,
Handler handler) {
+ startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
+ periodicData, 0, callback, handler);
+ }
+
+ /**
+ * Creates a new advertising set. If operation succeed, device will start advertising. This
+ * method returns immediately, the operation status is delivered through
+ * {@code callback.onAdvertisingSetStarted()}.
+ * <p>
+ * @param parameters advertising set parameters.
+ * @param advertiseData Advertisement data to be broadcasted.
+ * @param scanResponse Scan response associated with the advertisement data.
+ * @param periodicData Periodic advertising data.
+ * @param timeoutMillis Advertising time limit. May not exceed 180000
+ * @param callback Callback for advertising set.
+ */
+ public void startAdvertisingSet(AdvertisingSetParameters parameters,
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, int timeoutMillis,
+ AdvertisingSetCallback callback) {
+ startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
+ periodicData, timeoutMillis, callback, new Handler(Looper.getMainLooper()));
+ }
+
+ /**
+ * Creates a new advertising set. If operation succeed, device will start advertising. This
+ * method returns immediately, the operation status is delivered through
+ * {@code callback.onAdvertisingSetStarted()}.
+ * <p>
+ * @param parameters advertising set parameters.
+ * @param advertiseData Advertisement data to be broadcasted.
+ * @param scanResponse Scan response associated with the advertisement data.
+ * @param periodicData Periodic advertising data.
+ * @param timeoutMillis Advertising time limit. May not exceed 180000
+ * @param callback Callback for advertising set.
+ * @param handler thread upon which the callbacks will be invoked.
+ */
+ public void startAdvertisingSet(AdvertisingSetParameters parameters,
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, int timeoutMillis,
+ AdvertisingSetCallback callback, Handler handler) {
BluetoothLeUtils.checkAdapterStateOn(mBluetoothAdapter);
if (callback == null) {
@@ -259,7 +301,7 @@ public final class BluetoothLeAdvertiser {
try {
gatt.startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, wrapped);
+ periodicData, timeoutMillis, wrapped);
} catch (RemoteException e) {
Log.e(TAG, "Failed to start advertising set - ", e);
throw new IllegalStateException("Failed to start advertising set");