runnerup icon indicating copy to clipboard operation
runnerup copied to clipboard

Compatibility issue when calling method

Open PSDroid2022 opened this issue 3 years ago • 1 comments

We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''org.runnerup.hr.AndroidBLEHRProvider", you invoke the API "<android.bluetooth.BluetoothAdapter: void stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback)>" in "stopScan" method as shown in following. But actually, this API is introduced in API level 18( https://developer.android.google.cn/reference/android/bluetooth/BluetoothAdapter?hl=en#stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback)).

  @Override
    public void stopScan() {
        if (mIsScanning) {
            mIsScanning = false;
            btAdapter.stopLeScan(mLeScanCallback);
        }
    }

So when the app try to invoke this API on devices after API level 16~17, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT >=18)" to fix this potential issue.

Android device

  • Device: [e.g. Emulator]
  • OS: [e.g. API 16~18]
  • Runnerup Version: [2.4.5.0]

PSDroid2022 avatar Aug 27 '22 14:08 PSDroid2022

ok

gerhardol avatar Aug 27 '22 21:08 gerhardol

Sorry for not responding earlier: BLE was added in Android 4.3 (SDK 18), it should not be possible to start scanning with SDK below 18 anyway. There are about 17 users with this versions the last 28 days.

Note that the old BLE API is used that was replaced in Android 5/SDK21. That need to be replaced eventually should drop releases before 5.0 (another 12 user) or even 5.0 too (another 7). Total 3362 users right now.

gerhardol avatar Feb 04 '23 17:02 gerhardol