jonasoreland / runnerup

A open source run tracker
GNU General Public License v3.0
753 stars 275 forks source link

Compatibility issue when calling method #1119

Closed PSDroid2022 closed 1 year ago

PSDroid2022 commented 2 years ago

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

gerhardol commented 2 years ago

ok

gerhardol commented 1 year ago

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.