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

Commit 6f7a9736 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Check if BT is disabled or not when sending audio state.

When BT is turning off we need to send the audio state intent.
We were not doing this since the state was turning off.

The check was added to prevent misuse of public APIs, since
these functions are used internally, its not a problem.

Change-Id: I9834cbff741722bf99c2875fa65c0617b7b4807b
parent 14faa3bd
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -603,7 +603,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
     */
    public boolean setAudioState(BluetoothDevice device, int state) {
        if (DBG) log("setAudioState");
        if (mService != null && isEnabled()) {
        if (mService != null && !isDisabled()) {
            try {
                return mService.setAudioState(device, state);
            } catch (RemoteException e) {Log.e(TAG, e.toString());}
@@ -622,7 +622,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
     */
    public int getAudioState(BluetoothDevice device) {
        if (DBG) log("getAudioState");
        if (mService != null && isEnabled()) {
        if (mService != null && !isDisabled()) {
            try {
                return mService.getAudioState(device);
            } catch (RemoteException e) {Log.e(TAG, e.toString());}
@@ -705,6 +705,11 @@ public final class BluetoothHeadset implements BluetoothProfile {
       return false;
    }

    private boolean isDisabled() {
       if (mAdapter.getState() == BluetoothAdapter.STATE_OFF) return true;
       return false;
    }

    private boolean isValidDevice(BluetoothDevice device) {
       if (device == null) return false;