Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Misuse of mBluetoothAdapter.isMultipleAdvertisementSupported() #67

Open
farmazon3000 opened this issue Jul 12, 2016 · 10 comments
Open

Misuse of mBluetoothAdapter.isMultipleAdvertisementSupported() #67

farmazon3000 opened this issue Jul 12, 2016 · 10 comments

Comments

@farmazon3000
Copy link

farmazon3000 commented Jul 12, 2016

In https://github.com/WebBluetoothCG/ble-test-peripheral-android/blob/master/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java there is:

if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) {
  Toast.makeText(this, R.string.bluetoothAdvertisingNotSupported, Toast.LENGTH_LONG).show();
  Log.e(TAG, "Advertising not supported");
}

And this is misuse of isMultipleAdvertisementSupported, check this AltBeacon/android-beacon-library#266:

It is important to understand that just because isMultipleAdvertisementSupported() returns false does not mean that the device cannot advertise at all -- it means either that it cannot advertise at all OR that it can only transmit one advertisement at a time. Many Motorola devices (Moto X, Moto G) behave this way. The way you are supposed to check if advertising is supported at all is to get an instance of BluetoothLEAdvertiser. If the call to get an instance fails, then it is not supported.

@g-ortuno
Copy link
Contributor

I'm wary of adding code to support one specific vendor. The Android documentation explicitly states that isMultipleAdvertisementSupported() should be used to check for advertising support.

@farmazon3000
Copy link
Author

The Android documentation explicitly states that isMultipleAdvertisementSupported() should be used to check for advertising support

Does it? No it does not.

What it does says is https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#isMultipleAdvertisementSupported()
Return true if the multi advertisement is supported by the chipset

@g-ortuno
Copy link
Contributor

Should have included a citation in my original response. It is under getBluetoothLeAdvertiser:

Use isMultipleAdvertisementSupported() to check whether LE Advertising is supported on this device before calling this method.

@phstudy
Copy link

phstudy commented Sep 11, 2017

@g-ortuno I think @farmazon3000 is right.
Just checking the response of getBluetoothLeAdvertiser() is null or not, it can determine whether
the device supports LE advertising. The comment of getBluetoothLeAdvertiser() is not accurate, you can check the source code of the method. I think the correct comment should be Use isMultipleAdvertisementSupported() to check whether LE *multiple* Advertising is supported on this device before calling this method.

BluetoothAdapter.java in ASOP master

BluetoothAdapter.java in ASOP 7.1_r9

@scheib
Copy link
Contributor

scheib commented Sep 11, 2017

Ok. For BLE Test Peripheral, is this check causing you to not be able to use the tool?

@phstudy
Copy link

phstudy commented Sep 11, 2017

@scheib Yes. If I can not pass the checking, BLE Test Peripheral will show LE Advertising is not available. Please pair with a device to be discoverable..

@AlejandroHCruz
Copy link

Hi, any conclusion on this subject?

@nowavewater
Copy link

Actually, it's not required to support multiple advertisement for Android device to act as peripheral role. Check the official example.

I have a device which returns false with isMultipleAdvertisementSupported(), it works just with the official example.

@g-ortuno
Copy link
Contributor

g-ortuno commented Jul 3, 2018

I'm convinced. Feel free to send a CL to change this.

@abdoutech93
Copy link

Actually, it's not required to support multiple advertisement for Android device to act as peripheral role. Check the official example.

I have a device which returns false with isMultipleAdvertisementSupported(), it works just with the official example.

THANKS A LOT, you made my day

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants