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

Commit 50bb8763 authored by weichinweng's avatar weichinweng Committed by Stanley Tng
Browse files

Hearing Aid Service: Don't sent suppress noisy intent

1) When the active device is change to other device, don't send suppress
noisy intent
2) When the active device is change to null, will check the connection
state, if it is disconnected will sent intent.

Bug: 112279820
Test: Build Pass, BT off/on when play A2DP, Switch active device
Change-Id: I80cbf8180b68c671657fd3b9375ee78ea15b47eb
parent 665205e0
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -618,19 +618,24 @@ public class HearingAidService extends ProfileService {
            if (DBG) {
                Log.d(TAG, "Set Hearing Aid audio to disconnected");
            }
            mAudioManager.setHearingAidDeviceConnectionState(mPreviousAudioDevice,
                    BluetoothProfile.STATE_DISCONNECTED);
            boolean suppressNoisyIntent =
                    (getConnectionState(mPreviousAudioDevice) == BluetoothProfile.STATE_CONNECTED);
            mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                    mPreviousAudioDevice, BluetoothProfile.STATE_DISCONNECTED,
                    suppressNoisyIntent, 0);
            mPreviousAudioDevice = null;
        } else {
            if (DBG) {
                Log.d(TAG, "Set Hearing Aid audio to connected");
            }
            if (mPreviousAudioDevice != null) {
                mAudioManager.setHearingAidDeviceConnectionState(mPreviousAudioDevice,
                        BluetoothProfile.STATE_DISCONNECTED);
                mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                        mPreviousAudioDevice, BluetoothProfile.STATE_DISCONNECTED,
                        true, 0);
            }
            mAudioManager.setHearingAidDeviceConnectionState(device,
                    BluetoothProfile.STATE_CONNECTED);
            mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                    device, BluetoothProfile.STATE_CONNECTED,
                    true, 0);
            mPreviousAudioDevice = device;
        }
    }
+6 −4
Original line number Diff line number Diff line
@@ -498,8 +498,9 @@ public class HearingAidServiceTest {
        Assert.assertTrue(mService.getConnectedDevices().contains(mRightDevice));

        // Verify the audio is routed to Hearing Aid Profile
        verify(mAudioManager).setHearingAidDeviceConnectionState(any(BluetoothDevice.class),
                eq(BluetoothProfile.STATE_CONNECTED));
        verify(mAudioManager).setBluetoothHearingAidDeviceConnectionState(
                any(BluetoothDevice.class), eq(BluetoothProfile.STATE_CONNECTED),
                eq(true), eq(0));

        // Send a disconnect request
        Assert.assertTrue("Disconnect failed", mService.disconnect(mLeftDevice));
@@ -546,8 +547,9 @@ public class HearingAidServiceTest {
        Assert.assertFalse(mService.getConnectedDevices().contains(mRightDevice));

        // Verify the audio is not routed to Hearing Aid Profile
        verify(mAudioManager).setHearingAidDeviceConnectionState(any(BluetoothDevice.class),
                eq(BluetoothProfile.STATE_DISCONNECTED));
        verify(mAudioManager).setBluetoothHearingAidDeviceConnectionState(
                any(BluetoothDevice.class), eq(BluetoothProfile.STATE_DISCONNECTED),
                eq(false), eq(0));
    }

    /**