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

Commit d99c67e4 authored by Aritra Sen's avatar Aritra Sen
Browse files

Cleanup Silence device manager and move logic to adapter service for active...

Cleanup Silence device manager and move logic to adapter service for active device changes similiar to ActiveDeviceManager.

Tag: #refactor
Bug: 296932947
Test: atest BluetoothInstrumentationTests
Change-Id: If4b3e3bd0bc19c229f3a8643a0cd85c482ce7cce
parent 65db42e1
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1069,7 +1069,6 @@ public class A2dpService extends ProfileService {
        }

        mAdapterService.handleActiveDeviceChange(BluetoothProfile.A2DP, device);
        mAdapterService.getSilenceDeviceManager().a2dpActiveDeviceChanged(device);

        BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_ACTIVE_DEVICE_CHANGED,
                BluetoothProfile.A2DP, mAdapterService.obfuscateAddress(device),
+1 −1
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
     * Called when active state of audio profiles changed
     *
     * @param profile The Bluetooth profile of which active state changed
     * @param device The device currently activated. {@code null} if no A2DP device activated
     * @param device The device currently activated. {@code null} if no device is active
     */
    public void profileActiveDeviceChanged(int profile, BluetoothDevice device) {
        switch (profile) {
+1 −0
Original line number Diff line number Diff line
@@ -6919,6 +6919,7 @@ public class AdapterService extends Service {
    /** Handle Bluetooth app state when active device changes for a given {@code profile}. */
    public void handleActiveDeviceChange(int profile, BluetoothDevice device) {
        mActiveDeviceManager.profileActiveDeviceChanged(profile, device);
        mSilenceDeviceManager.profileActiveDeviceChanged(profile, device);
        mPhonePolicy.profileActiveDeviceChanged(profile, device);
    }

+19 −18
Original line number Diff line number Diff line
@@ -76,6 +76,25 @@ public class SilenceDeviceManager {
    private static final int ENABLE_SILENCE = 0;
    private static final int DISABLE_SILENCE = 1;

    /**
     * Called when active state of audio profiles changed
     *
     * @param profile The Bluetooth profile of which active state changed
     * @param device The device currently activated. {@code null} if no device is active
     */
    public void profileActiveDeviceChanged(int profile, BluetoothDevice device) {
        switch (profile) {
            case BluetoothProfile.A2DP:
                mHandler.obtainMessage(MSG_A2DP_ACTIVE_DEVICE_CHANGED, device).sendToTarget();
                break;
            case BluetoothProfile.HEADSET:
                mHandler.obtainMessage(MSG_HFP_ACTIVE_DEVICE_CHANGED, device).sendToTarget();
                break;
            default:
                break;
        }
    }

    /**
     * Called when A2DP connection state changed by A2dpService
     *
@@ -88,15 +107,6 @@ public class SilenceDeviceManager {
                .sendToTarget();
    }

    /**
     * Called when A2DP active device changed by A2dpService
     *
     * @param device The device currently activated. {@code null} if no A2DP device activated
     */
    public void a2dpActiveDeviceChanged(BluetoothDevice device) {
        mHandler.obtainMessage(MSG_A2DP_ACTIVE_DEVICE_CHANGED, device).sendToTarget();
    }

    /**
     * Called when HFP connection state changed by HeadsetService
     *
@@ -109,15 +119,6 @@ public class SilenceDeviceManager {
                .sendToTarget();
    }

    /**
     * Called when HFP active device is changed by HeadsetService
     *
     * @param device The device currently activated. {@code null} if no HFP device activated
     */
    public void hfpActiveDeviceChanged(BluetoothDevice device) {
        mHandler.obtainMessage(MSG_HFP_ACTIVE_DEVICE_CHANGED, device).sendToTarget();
    }

    class SilenceDeviceManagerHandler extends Handler {
        SilenceDeviceManagerHandler(Looper looper) {
            super(looper);
+0 −1
Original line number Diff line number Diff line
@@ -2136,7 +2136,6 @@ public class HeadsetService extends ProfileService {
        logD("broadcastActiveDevice: " + device);

        mAdapterService.handleActiveDeviceChange(BluetoothProfile.HEADSET, device);
        mAdapterService.getSilenceDeviceManager().hfpActiveDeviceChanged(device);

        BluetoothStatsLog.write(
                BluetoothStatsLog.BLUETOOTH_ACTIVE_DEVICE_CHANGED,
Loading