Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05d0005e authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

LeAudioService: Handle possible IllegalStateException

When starting or stopping scanner, the IllegalStateException can be
throw when Adapter does not exist.

Bug: 284910850
Test: atest BluetoothInstrumentationTests
Tag: #feature
Change-Id: I6a6d08aef2899b2d3e2783b4a3c9a4bcb207c826
parent a908d33c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1715,7 +1715,11 @@ public class LeAudioService extends ProfileService {
            }
        }

        try {
            mAudioServersScanner.stopScan(mScanCallback);
        } catch (IllegalStateException e) {
            Log.e(TAG, "Fail to stop scanner, consider it stopped", e);
        }

        /* Callback is the indicator for scanning being enabled */
        mScanCallback = null;
@@ -1765,7 +1769,12 @@ public class LeAudioService extends ProfileService {
                .setScanMode(ScanSettings.SCAN_MODE_BALANCED)
                .build();

        try {
            mAudioServersScanner.startScan(filterList, settings, mScanCallback);
        } catch (IllegalStateException e) {
            Log.e(TAG, "Fail to start scanner, consider it stopped", e);
            mScanCallback = null;
        }
    }

    // Suppressed since this is part of a local process