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

Commit 168ad524 authored by yaoliang1's avatar yaoliang1
Browse files

BtHelper: handle BT crash



Wrapped the calls to the BT proxies with try/catch as the notification that a profile disconnected can happen while the proxy is used

Bug:351925855
Test: BT crash case in bug

Change-Id: Ied1c5e064c25153c263869c61125a227f9c4a2b8
Signed-off-by: default avataryaoliang1 <yaoliang1@xiaomi.com>
parent 40d5af2f
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -436,8 +436,13 @@ public class BtHelper {
        if (mBluetoothHeadset == null || mBluetoothHeadsetDevice == null) {
            return false;
        }
        try {
            return mBluetoothHeadset.getAudioState(mBluetoothHeadsetDevice)
                    == BluetoothHeadset.STATE_AUDIO_CONNECTED;
        } catch (Exception e) {
            Log.e(TAG, "Exception while getting audio state of " + mBluetoothHeadsetDevice, e);
        }
        return false;
    }

    // @GuardedBy("mDeviceBroker.mSetModeLock")
@@ -1051,6 +1056,7 @@ public class BtHelper {
    }

    private void checkScoAudioState() {
        try {
            if (mBluetoothHeadset != null
                    && mBluetoothHeadsetDevice != null
                    && mScoAudioState == SCO_STATE_INACTIVE
@@ -1058,6 +1064,9 @@ public class BtHelper {
                    != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
                mScoAudioState = SCO_STATE_ACTIVE_EXTERNAL;
            }
        } catch (Exception e) {
            Log.e(TAG, "Exception while getting audio state of " + mBluetoothHeadsetDevice, e);
        }
    }

    private boolean getBluetoothHeadset() {