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

Commit 7b0cf641 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

CEC: Remove system audio on hotplug

System audio was not being immediately removed by polling mechanism
mechanism but was being checked three times in order to avoid accidental
polling failure. This came with a side effect of the system audio
not removed instantly even when the device is physically removed.

This CL relies on hotplug event to tell whether the device removal
should be done right away or has to wait for 3 polling intervals.

Bug: 20133405
Change-Id: I9dbd7a8b9e424d523d0c22e4cac19b341461b71e
parent 07e1967c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -913,6 +913,12 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        }
    }

    @ServiceThreadOnly
    boolean isConnected(int portId) {
        assertRunOnServiceThread();
        return mService.isConnected(portId);
    }

    private void notifyArcStatusToAudioService(boolean enabled) {
        // Note that we don't set any name to ARC.
        mService.getAudioManager().setWiredDeviceConnectionState(
+6 −0
Original line number Diff line number Diff line
@@ -780,6 +780,12 @@ public final class HdmiControlService extends SystemService {
        return false;
    }

    @ServiceThreadOnly
    boolean isConnected(int portId) {
        assertRunOnServiceThread();
        return mCecController.isConnected(portId);
    }

    void runOnServiceThread(Runnable runnable) {
        mHandler.post(runnable);
    }
+7 −4
Original line number Diff line number Diff line
@@ -156,12 +156,15 @@ final class HotplugDetectionAction extends HdmiCecFeatureAction {
        int index = -1;
        while ((index = removed.nextSetBit(index + 1)) != -1) {
            if (index == Constants.ADDR_AUDIO_SYSTEM) {
                HdmiDeviceInfo avr = tv().getAvrDeviceInfo();
                if (avr != null && tv().isConnected(avr.getPortId())) {
                    ++mAvrStatusCount;
                    Slog.w(TAG, "Ack not returned from AVR. count: " + mAvrStatusCount);
                    if (mAvrStatusCount < AVR_COUNT_MAX) {
                        continue;
                    }
                }
            }
            Slog.v(TAG, "Remove device by hot-plug detection:" + index);
            removeDevice(index);
        }