Replace usage of hidden API getLeState by isLeEnabled

Tag: #feature
Bug: 200202780
Test: build
Change-Id: If682deb4e2d8bc32bc74fa7a61f5e660c84918fa
This commit is contained in:
Etienne Ruffieux
2022-02-01 13:31:21 +00:00
parent d7a62ace0f
commit 88e3cd602e

View File

@@ -21,8 +21,6 @@ import static android.bluetooth.BluetoothAdapter.ACTION_BLE_STATE_CHANGED;
import static android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED;
import static android.bluetooth.BluetoothAdapter.EXTRA_PREVIOUS_STATE;
import static android.bluetooth.BluetoothAdapter.EXTRA_STATE;
import static android.bluetooth.BluetoothAdapter.STATE_BLE_ON;
import static android.bluetooth.BluetoothAdapter.STATE_ON;
import static android.bluetooth.BluetoothAdapter.nameForState;
import static android.bluetooth.le.ScanCallback.SCAN_FAILED_ALREADY_STARTED;
import static android.bluetooth.le.ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED;
@@ -156,7 +154,7 @@ class BleCompanionDeviceScanner implements AssociationStore.OnChangeListener {
private void checkBleState() {
enforceInitialized();
final boolean bleAvailable = isBleAvailable();
final boolean bleAvailable = mBtAdapter.isLeEnabled();
if (DEBUG) {
Log.i(TAG, "checkBleState() bleAvailable=" + bleAvailable);
}
@@ -183,16 +181,6 @@ class BleCompanionDeviceScanner implements AssociationStore.OnChangeListener {
}
}
/**
* A duplicate of {@code BluetoothAdapter.getLeAccess()} method which has the package-private
* access level, so it's not accessible from here.
*/
private boolean isBleAvailable() {
final int state = mBtAdapter.getLeState();
if (DEBUG) Log.d(TAG, "getLeAccess() state=" + nameForBtState(state));
return state == STATE_ON || state == STATE_BLE_ON;
}
@MainThread
private void startScan() {
enforceInitialized();