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

Commit 850d90b4 authored by PK Guo's avatar PK Guo Committed by Mikhail Naganov
Browse files

audio: fix SAD and SAM inconsistent after audioserver crash

When restoring setting after audioserver crash
1. The setHdmiSystemAudioSupported doesn't setForceUse with SAM
because the setting value is equal to mHdmiSystemAudioSupported.
2. The SAD is stored in the AudioDescriptor, but AudioDescriptor
isn't pass to native layer.

Adjust logic to ensure that SAM and AudioDescriptor can set to
native layer when restoring setting after the crash.

Flag: EXEMPT bugfix
Bug: 412816152
Test: manual
(cherry picked from https://android-review.googlesource.com/q/commit:c8c71a45626b84c079b877e656a228f12de491d7)
Change-Id: Idb16a66f087d8558d7bd26048f1d7284acfb5dd8
parent ccd028ea
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -904,9 +904,14 @@ public class AudioDeviceInventory {
                }
                // device disconnected: call setDeviceConnectionState(AVAILABLE)
                res = mAudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(
                            di.mDeviceType,
                            AudioSystem.isInputDevice(di.mDeviceType)
                                ? AudioDeviceAttributes.ROLE_INPUT
                                : AudioDeviceAttributes.ROLE_OUTPUT,
                            AudioDeviceInfo.convertInternalDeviceToDeviceType(di.mDeviceType),
                            di.mDeviceAddress,
                            di.mDeviceName),
                            di.mDeviceName,
                            di.mAudioProfiles,
                            di.mAudioDescriptors),
                        AudioSystem.DEVICE_STATE_AVAILABLE,
                        di.mDeviceCodecFormat, false /*deviceSwitch*/);
                if (res == AudioSystem.AUDIO_STATUS_SERVER_DIED) {
+6 −2
Original line number Diff line number Diff line
@@ -2244,7 +2244,7 @@ public class AudioService extends IAudioService.Stub
        }
        synchronized (mHdmiClientLock) {
            if (mHdmiManager != null && mHdmiTvClient != null) {
                setHdmiSystemAudioSupported(mHdmiSystemAudioSupported);
                setHdmiSystemAudioSupported(mHdmiSystemAudioSupported, true);
            }
        }
@@ -13272,6 +13272,10 @@ public class AudioService extends IAudioService.Stub
    @Override
    public int setHdmiSystemAudioSupported(boolean on) {
        return setHdmiSystemAudioSupported(on, false);
    }
    private int setHdmiSystemAudioSupported(boolean on, boolean force) {
        int device = AudioSystem.DEVICE_NONE;
        synchronized (mHdmiClientLock) {
            if (mHdmiManager != null) {
@@ -13280,7 +13284,7 @@ public class AudioService extends IAudioService.Stub
                            + "system audio mode.");
                    return device;
                }
                if (mHdmiSystemAudioSupported != on) {
                if (force || mHdmiSystemAudioSupported != on) {
                    mHdmiSystemAudioSupported = on;
                    final int config = on ? AudioSystem.FORCE_HDMI_SYSTEM_AUDIO_ENFORCED :
                        AudioSystem.FORCE_NONE;