From d4927bbaa28adefb2b7fa5d1a9d82552d2898f37 Mon Sep 17 00:00:00 2001 From: Paul Colta Date: Tue, 23 Aug 2022 15:12:27 +0000 Subject: [PATCH] HDMICEC: Remove deferred OneTouchPlayAction This fix a critical bug of playback devices sending an message when they are not the source selected by users, taking over TVs screen. This situation occurs when users are changing input sources quickly, triggering a playback device to wake up from the standby state, starting CEC initialization. When the initialization is complete, the device tries to start an OneTouchPlayAction, which will trigger the message to be broadcasted. The change includes setting mAddressAllocated to true after the onInitializeCecComplete call as opposed to before. This way, a possible created OneTouchPlayAction is not started right away, but deferred. This action is cancelled when preprocessing the buffer messages. Bug: 235434112 Test: make && atest HdmiCecLocalDevicePlaybackTest Change-Id: Ic189ba5ab72b8e8b4f9d957f3367b453e82df8fd --- .../com/android/server/hdmi/HdmiCecLocalDevicePlayback.java | 1 + .../core/java/com/android/server/hdmi/HdmiControlService.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java index ea54b3001163e..e6c2e7cae23e1 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java @@ -544,6 +544,7 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { || message.getOpcode() == Constants.MESSAGE_SET_STREAM_PATH || message.getOpcode() == Constants.MESSAGE_ACTIVE_SOURCE) { removeAction(ActiveSourceAction.class); + removeAction(OneTouchPlayAction.class); return; } } diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index fa8b5c1b80868..3ee35036e9fdc 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -1051,13 +1051,13 @@ public class HdmiControlService extends SystemService { // Address allocation completed for all devices. Notify each device. if (allocatingDevices.size() == ++finished[0]) { - mAddressAllocated = true; if (initiatedBy != INITIATED_BY_HOTPLUG) { // In case of the hotplug we don't call // onInitializeCecComplete() // since we reallocate the logical address only. onInitializeCecComplete(initiatedBy); } + mAddressAllocated = true; notifyAddressAllocated(allocatedDevices, initiatedBy); // Reinvoke the saved display status callback once the local // device is ready.