summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shubang Lu <shubang@google.com> 2019-02-04 18:47:15 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-04 18:47:15 +0000
commitedbfd1be7255e434c5a085a36e0932ab58a6cc57 (patch)
tree21e525eaf73df302f79b3c25c2fba089c8516b41
parent83a07847cb8afd531ed8c24fb59f76cc36ae3e8d (diff)
parent10a9124ab97c1b643edb5079b784b0db01a3eb69 (diff)
Merge "Add callback to sendCecCommand in SendKeyEventAction when handling volume key forwarding."
-rw-r--r--services/core/java/com/android/server/hdmi/SendKeyAction.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/hdmi/SendKeyAction.java b/services/core/java/com/android/server/hdmi/SendKeyAction.java
index 40d2583691c6..5ad7fab888fd 100644
--- a/services/core/java/com/android/server/hdmi/SendKeyAction.java
+++ b/services/core/java/com/android/server/hdmi/SendKeyAction.java
@@ -17,8 +17,10 @@ package com.android.server.hdmi;
import static com.android.server.hdmi.HdmiConfig.IRT_MS;
+import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.util.Slog;
import android.view.KeyEvent;
+import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
/**
* Feature action that transmits remote control key command (User Control Press/
@@ -146,8 +148,26 @@ final class SendKeyAction extends HdmiCecFeatureAction {
if (cecKeycodeAndParams == null) {
return;
}
- sendCommand(HdmiCecMessageBuilder.buildUserControlPressed(getSourceAddress(),
- mTargetAddress, cecKeycodeAndParams));
+ // Devices that are not directly connected with audio system device can't detect if the
+ // audio system device is still plugged in. Framework checks if the volume key forwarding is
+ // successful or not every time to make sure the System Audio Mode status is still updated.
+ if (mTargetAddress == Constants.ADDR_AUDIO_SYSTEM
+ && localDevice().mAddress != Constants.ADDR_TV) {
+ sendCommand(HdmiCecMessageBuilder.buildUserControlPressed(getSourceAddress(),
+ mTargetAddress, cecKeycodeAndParams), new SendMessageCallback() {
+ @Override
+ public void onSendCompleted(int error) {
+ if (error != SendMessageResult.SUCCESS) {
+ HdmiLogger.debug(
+ "AVR did not respond to <User Control Pressed>");
+ localDevice().mService.setSystemAudioActivated(false);
+ }
+ }
+ });
+ } else {
+ sendCommand(HdmiCecMessageBuilder.buildUserControlPressed(getSourceAddress(),
+ mTargetAddress, cecKeycodeAndParams));
+ }
}
private void sendKeyUp() {