Android 当getBluetoothLeAdvertiser返回一个对象时,为什么IsMultiDefenderVertisementSupported()返回false?

Android 当getBluetoothLeAdvertiser返回一个对象时,为什么IsMultiDefenderVertisementSupported()返回false?,android,sony,ibeacon-android,android-ibeacon,android-ble,Android,Sony,Ibeacon Android,Android Ibeacon,Android Ble,我正在尝试在我的设备上使用BLE传输 以下是我使用的代码和输出: // check BLE support Log.i(TAG, "BLE supported: " + getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)); // true // check BLE transmission support final BluetoothManager bluetoothManager =

我正在尝试在我的设备上使用BLE传输

以下是我使用的代码和输出:

// check BLE support
Log.i(TAG, "BLE supported: " + getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)); // true

// check BLE transmission support
final BluetoothManager bluetoothManager =
        (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();

Log.i(TAG, "isMultipleAdvertisementSupported: " + mBluetoothAdapter.isMultipleAdvertisementSupported()); // false
Log.i(TAG, "isOffloadedFilteringSupported: " + mBluetoothAdapter.isOffloadedFilteringSupported()); // false
Log.i(TAG, "isOffloadedScanBatchingSupported: " + mBluetoothAdapter.isOffloadedScanBatchingSupported()); // false

BluetoothLeAdvertiser mBluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
Log.i(TAG, mBluetoothLeAdvertiser.toString()); //android.bluetooth.le.BluetoothLeAdvertiser@1c51f789

// check BLE transmission support
// android-beacon-library, https://github.com/AltBeacon/android-beacon-library
int result = BeaconTransmitter.checkTransmissionSupported(getApplicationContext());
Log.i(TAG, "ABL checkTransmissionSupported: " + result); // 0
我不明白为什么
mBluetoothLeAdvertiser
不是
null
,因为
mBluetoothLeAdvertiser
验证它不是
false

package android.bluetooth;
// ...

public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
    if (getState() != STATE_ON) {
        return null;
    }
    if (!isMultipleAdvertisementSupported()) {
        return null;
    }
    synchronized(mLock) {
        if (sBluetoothLeAdvertiser == null) {
            sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService);
        }
    }
    return sBluetoothLeAdvertiser;
}

// ...

public boolean isMultipleAdvertisementSupported() {
    if (getState() != STATE_ON) return false;
    try {
        return mService.isMultiAdvertisementSupported();
    } catch (RemoteException e) {
        Log.e(TAG, "failed to get isMultipleAdvertisementSupported, error: ", e);
    }
    return false;
}

欢迎来到Android世界,它同时是开源和开源的!您对上述开源
BluetoothLeAdvertiser
代码的分析是正确的。如果该代码正在您的移动设备上运行,您将看不到顶部代码片段中测试显示的输出结论:第二个代码片段中显示的代码不能是设备上的代码。


Android设备原始设备制造商可以自由修改源代码,使其与硬件配合使用。在这种情况下,我知道摩托罗拉在Moto X和Moto G设备的代码中做了同样的事情。这些设备返回一个
BluetoothLeAdvertiser
,尽管
IsMultiConcevertizementSupported()
返回false。摩托罗拉的一位工程师向我解释说,他们之所以改变这一点,是因为他们希望支持广告,尽管他们使用的BLE芯片一次只能支持一个广告。事实上,我已经证实摩托罗拉设备可以做广告,但如果你试图同时做两个广告,它就失败了

谢谢。我在Sony Z3 Compact上进行了测试。由于不支持多个广告,这是否意味着我不能在可扩展外围模式下使用我的设备?还是我能?我需要同时模拟一个~iBeacon的翻译。大卫,你有没有在摩托罗拉设备上用来做广告的示例代码?看起来您的Android Beacon库只能在支持多个广告的情况下进行广告。Android Beacon库中的
BeaconTransmitter
类是我为摩托罗拉使用的。我为使其工作所做的唯一更改是更改验证传输能力的方法,以尝试并构建广告客户实例,而不是依赖
ismultideconvertizementsupported()
。如果可以构造实例,则假定传输能力。非常感谢。我使用Android Studio和gradle,在这种情况下如何修改Android Beacon库的源代码?或者,我应该定义其他版本吗
org.altbeacon:android-beacon库:2.2-beta2
不起作用。该更改是该库的最新版本,因此没有理由重建它。我怀疑Sony Z3 Compact存在一个简单的问题,它允许您获得广告商实例,但无法成功启动广告。你可能没有追索权,但打开一个错误报告与索尼。