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

Commit ae928a0f authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I3446249f,I4ec5133f,If2494dc9,I1d7c0651,Ie8d824e5 into main am:...

Merge changes I3446249f,I4ec5133f,If2494dc9,I1d7c0651,Ie8d824e5 into main am: 3d65588f am: ba26daa7

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3206193



Change-Id: I87ee8b900c90ea83b47fb1b3a71ca5fc452183af
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 810a97f5 ba26daa7
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1714,6 +1714,10 @@ public class AudioDeviceBroker {
        sendIILMsg(MSG_IIL_BTLEAUDIO_TIMEOUT, SENDMSG_QUEUE, device, codec, address, delayMs);
    }

    /*package*/ void setHearingAidTimeout(String address, int delayMs) {
        sendLMsg(MSG_IL_BT_HEARING_AID_TIMEOUT, SENDMSG_QUEUE, address, delayMs);
    }

    /*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) {
        synchronized (mDeviceStateLock) {
            mBtHelper.setAvrcpAbsoluteVolumeSupported(supported);
@@ -1959,6 +1963,13 @@ public class AudioDeviceBroker {
                                (String) msg.obj, msg.arg1, msg.arg2);
                    }
                    break;
                case MSG_IL_BT_HEARING_AID_TIMEOUT:
                    // msg.obj  == address of Hearing Aid device
                    synchronized (mDeviceStateLock) {
                        mDeviceInventory.onMakeHearingAidDeviceUnavailableNow(
                                (String) msg.obj);
                    }
                    break;
                case MSG_L_BLUETOOTH_DEVICE_CONFIG_CHANGE: {
                    final BtDeviceInfo btInfo = (BtDeviceInfo) msg.obj;
                    final Pair<Integer, Boolean> codecAndChanged = mBtHelper.getCodecWithFallback(
@@ -2234,6 +2245,7 @@ public class AudioDeviceBroker {
    private static final int MSG_L_SYNCHRONIZE_ADI_DEVICES_IN_INVENTORY = 58;
    private static final int MSG_IL_UPDATED_ADI_DEVICE_STATE = 59;
    private static final int MSG_L_SET_FORCE_BT_A2DP_USE_NO_MUTE = 60;
    private static final int MSG_IL_BT_HEARING_AID_TIMEOUT = 61;

    private static boolean isMessageHandledUnderWakelock(int msgId) {
        switch(msgId) {
@@ -2246,6 +2258,7 @@ public class AudioDeviceBroker {
            case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT:
            case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT:
            case MSG_CHECK_MUTE_MUSIC:
            case MSG_IL_BT_HEARING_AID_TIMEOUT:
                return true;
            default:
                return false;
@@ -2330,6 +2343,7 @@ public class AudioDeviceBroker {
                case MSG_IL_BTA2DP_TIMEOUT:
                case MSG_IIL_BTLEAUDIO_TIMEOUT:
                case MSG_L_BLUETOOTH_DEVICE_CONFIG_CHANGE:
                case MSG_IL_BT_HEARING_AID_TIMEOUT:
                    if (sLastDeviceConnectMsgTime >= time) {
                        // add a little delay to make sure messages are ordered as expected
                        time = sLastDeviceConnectMsgTime + 30;
+16 −4
Original line number Diff line number Diff line
@@ -1050,6 +1050,11 @@ public class AudioDeviceInventory {
        }
    }

    /*package*/ void onMakeHearingAidDeviceUnavailableNow(String address) {
        synchronized (mDevicesLock) {
            makeHearingAidDeviceUnavailable(address);
        }
    }

    /**
     * Goes over all connected LE Audio devices in the provided group ID and
@@ -1902,12 +1907,10 @@ public class AudioDeviceInventory {
                    .set(MediaMetrics.Property.EVENT, "disconnectHearingAid")
                    .record();
            if (toRemove.size() > 0) {
                /*final int delay = */
                checkSendBecomingNoisyIntentInt(DEVICE_OUT_HEARING_AID,
                final int delay = checkSendBecomingNoisyIntentInt(DEVICE_OUT_HEARING_AID,
                        AudioService.CONNECTION_STATE_DISCONNECTED, AudioSystem.DEVICE_NONE);
                toRemove.stream().forEach(deviceAddress ->
                        // TODO delay not used?
                        makeHearingAidDeviceUnavailable(deviceAddress /*, delay*/)
                        makeHearingAidDeviceUnavailableLater(deviceAddress, delay)
                );
            }
        }
@@ -2498,6 +2501,15 @@ public class AudioDeviceInventory {
        mDeviceBroker.postCheckCommunicationDeviceRemoval(ada);
    }

    @GuardedBy("mDevicesLock")
    private void makeHearingAidDeviceUnavailableLater(
            String address, int delayMs) {
        // the device will be made unavailable later, so consider it disconnected right away
        mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(DEVICE_OUT_HEARING_AID, address));
        // send the delayed message to make the device unavailable later
        mDeviceBroker.setHearingAidTimeout(address, delayMs);
    }

    /**
     * Returns whether a device of type DEVICE_OUT_HEARING_AID is connected.
     * Visibility by APM plays no role