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

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

CEC: Prevent premature standby process completion

Handles the situation where standby is prematurely completed
by handleTerminateArc initiated in HdmiCecLocalDeviceTv.disableDevice().
Power status is now checked to stop the flow before removing
RequestArcTerminateAction which can call mPendingActionClearedCallback.

Also Make sure mPendingActionClearedCallback is set to null at the beginning
so that disable callback is not invoked unintentionally in
HdmiCecLocalDevice.checkIfPendingActionsCleared() which is supposed to work
at standby process only. It is now invoked by handleDisableDeviceTimeout
to make sure standby process is completed with PendingActionClearedCallback
at HdmiControlService.onStandby().

Bug: 20159835, Bug: 19930352
Change-Id: Iac29dfb6acff76182ff4e9563edc611406c23f3c
parent 341cba2a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ abstract class HdmiCecLocalDevice {
    void init() {
        assertRunOnServiceThread();
        mPreferredAddress = getPreferredAddress();
        mPendingActionClearedCallback = null;
    }

    /**
@@ -837,16 +838,16 @@ abstract class HdmiCecLocalDevice {
     *
     * @param initiatedByCec true if this sequence is initiated
     *        by the reception the CEC messages like <Standby>
     * @param origialCallback callback interface to get notified when all pending actions are
     * @param originalCallback callback interface to get notified when all pending actions are
     *        cleared
     */
    protected void disableDevice(boolean initiatedByCec,
            final PendingActionClearedCallback origialCallback) {
            final PendingActionClearedCallback originalCallback) {
        mPendingActionClearedCallback = new PendingActionClearedCallback() {
            @Override
            public void onCleared(HdmiCecLocalDevice device) {
                mHandler.removeMessages(MSG_DISABLE_DEVICE_TIMEOUT);
                origialCallback.onCleared(device);
                originalCallback.onCleared(device);
            }
        };
        mHandler.sendMessageDelayed(Message.obtain(mHandler, MSG_DISABLE_DEVICE_TIMEOUT),
@@ -865,6 +866,9 @@ abstract class HdmiCecLocalDevice {
            action.finish(false);
            iter.remove();
        }
        if (mPendingActionClearedCallback != null) {
            mPendingActionClearedCallback.onCleared(this);
        }
    }

    /**
+7 −5
Original line number Diff line number Diff line
@@ -1109,11 +1109,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    @ServiceThreadOnly
    protected boolean handleTerminateArc(HdmiCecMessage message) {
        assertRunOnServiceThread();
        // In cast of termination, do not check ARC configuration in that AVR device
        // might be removed already.

        // In case where <Terminate Arc> is started by <Request ARC Termination>
        // need to clean up RequestArcInitiationAction.
        if (mService .isPowerStandbyOrTransient()) {
            setArcStatus(false);
            return true;
        }
        // Do not check ARC configuration since the AVR might have been already removed.
        // Clean up RequestArcTerminationAction in case <Terminate Arc> was started by
        // <Request ARC Termination>.
        removeAction(RequestArcTerminationAction.class);
        SetArcTransmissionStateAction action = new SetArcTransmissionStateAction(this,
                message.getSource(), false);