1. This line returns failed:
mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_BLUETOOTH_LE)
Your device must have the file in file system to support BLUETOOTH,
/etc/handheld_core_hardware.xml
<feature name="android.hardware.bluetooth" />
and have this file to support BLE
/etc/android.hardware.bluetooth_le.xml
<feature name="android.hardware.bluetooth_le" />
Unfortunately, my ASUS Zenfone 5 doesn't have the file android.hardware.bluetooth_le.xml, so the feature is missing.
2. Even I ignore FEATURE_BLUETOOTH_LE, I still don't get BLE functions.
We get BluetoothManager from SystemService.
BluetoothManager bluetoothManager =
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
In BluetoothAdapter.java
IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
we got iGatt == null, which means the BluetoothManager doesn't contain IBluetoothGatt.
In BluetoothManagerService.java
private void bluetoothStateChangeHandler(int prevState, int newState) {
......
if (mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_BLUETOOTH_LE)) {
Intent i = new Intent(IBluetoothGatt.class.getName());
doBind(i, mConnection, Context.BIND_AUTO_CREATE, UserHandle.CURRENT);
}
It doesn't bind to the GattService, so it cannot use Ble functions.
3. Can we use normal BT API to connect BLE device?