am 2a46722f: Merge "Feature request: Increasing advertise data size on non-connectable adv. When the advertisement is non-connectable, give back the bytes to the advertiser where the adv flags would have been. This increases the non-connectable advertisement\'s adverti

* commit '2a46722f96480aed028785e955cbb8cb506df0b2':
  Feature request: Increasing advertise data size on non-connectable adv. When the advertisement is non-connectable, give back the bytes to the advertiser where the adv flags would have been. This increases the non-connectable advertisement's advertise data from 24 to 27 bytes.
This commit is contained in:
Tom Turney
2014-11-15 03:07:29 +00:00
committed by Android Git Automerger

View File

@@ -117,8 +117,9 @@ public final class BluetoothLeAdvertiser {
AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED); AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED);
return; return;
} }
if (totalBytes(advertiseData) > MAX_ADVERTISING_DATA_BYTES || boolean isConnectable = settings.isConnectable();
totalBytes(scanResponse) > MAX_ADVERTISING_DATA_BYTES) { if (totalBytes(advertiseData, isConnectable) > MAX_ADVERTISING_DATA_BYTES ||
totalBytes(scanResponse, isConnectable) > MAX_ADVERTISING_DATA_BYTES) {
postStartFailure(callback, AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE); postStartFailure(callback, AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE);
return; return;
} }
@@ -171,9 +172,10 @@ public final class BluetoothLeAdvertiser {
} }
// Compute the size of the advertise data. // Compute the size of the advertise data.
private int totalBytes(AdvertiseData data) { private int totalBytes(AdvertiseData data, boolean isConnectable) {
if (data == null) return 0; if (data == null) return 0;
int size = FLAGS_FIELD_BYTES; // flags field is always set. // Flags field is omitted if the advertising is not connectable.
int size = isConnectable ? FLAGS_FIELD_BYTES : 0;
if (data.getServiceUuids() != null) { if (data.getServiceUuids() != null) {
int num16BitUuids = 0; int num16BitUuids = 0;
int num32BitUuids = 0; int num32BitUuids = 0;