Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +31 −2 Original line number Diff line number Diff line Loading @@ -888,13 +888,42 @@ abstract class HdmiCecLocalDevice { } /** * Send a key event to other device. * Send a key event to other CEC device. The logical address of target device will be given by * {@link #findKeyReceiverAddress}. * * @param keyCode key code defined in {@link android.view.KeyEvent} * @param isPressed {@code true} for key down event * @see #findKeyReceiverAddress() */ @ServiceThreadOnly protected void sendKeyEvent(int keyCode, boolean isPressed) { Slog.w(TAG, "sendKeyEvent not implemented"); assertRunOnServiceThread(); if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) { Slog.w(TAG, "Unsupported key: " + keyCode); return; } List<SendKeyAction> action = getActions(SendKeyAction.class); int logicalAddress = findKeyReceiverAddress(); if (logicalAddress == Constants.ADDR_INVALID || logicalAddress == mAddress) { // Don't send key event to invalid device or itself. Slog.w(TAG, "Discard key event: " + keyCode + ", pressed:" + isPressed + ", receiverAddr=" + logicalAddress); } else if (!action.isEmpty()) { action.get(0).processKeyEvent(keyCode, isPressed); } else if (isPressed) { addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode)); } } /** * Returns the logical address of the device which will receive key events via * {@link #sendKeyEvent}. * * @see #sendKeyEvent(int, boolean) */ protected int findKeyReceiverAddress() { Slog.w(TAG, "findKeyReceiverAddress is not implemented"); return Constants.ADDR_INVALID; } void sendUserControlPressedAndReleased(int targetAddress, int cecKeycode) { Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +5 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,11 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { } } @Override protected int findKeyReceiverAddress() { return Constants.ADDR_TV; } @Override @ServiceThreadOnly protected void sendStandby(int deviceId) { Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +1 −33 Original line number Diff line number Diff line Loading @@ -432,40 +432,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { return mService.getPowerStatus(); } /** * Sends key to a target CEC device. * * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}. * @param isPressed true if this is key press event */ @Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode, boolean isPressed) { assertRunOnServiceThread(); if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) { Slog.w(TAG, "Unsupported key: " + keyCode); return; } List<SendKeyAction> action = getActions(SendKeyAction.class); int logicalAddress = findKeyReceiverAddress(); if (logicalAddress == mAddress) { Slog.w(TAG, "Discard key event to itself :" + keyCode + " pressed:" + isPressed); return; } if (!action.isEmpty()) { action.get(0).processKeyEvent(keyCode, isPressed); } else { if (isPressed) { if (logicalAddress != Constants.ADDR_INVALID) { addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode)); return; } } Slog.w(TAG, "Discard key event: " + keyCode + " pressed:" + isPressed); } } private int findKeyReceiverAddress() { protected int findKeyReceiverAddress() { if (getActiveSource().isValid()) { return getActiveSource().logicalAddress; } Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +31 −2 Original line number Diff line number Diff line Loading @@ -888,13 +888,42 @@ abstract class HdmiCecLocalDevice { } /** * Send a key event to other device. * Send a key event to other CEC device. The logical address of target device will be given by * {@link #findKeyReceiverAddress}. * * @param keyCode key code defined in {@link android.view.KeyEvent} * @param isPressed {@code true} for key down event * @see #findKeyReceiverAddress() */ @ServiceThreadOnly protected void sendKeyEvent(int keyCode, boolean isPressed) { Slog.w(TAG, "sendKeyEvent not implemented"); assertRunOnServiceThread(); if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) { Slog.w(TAG, "Unsupported key: " + keyCode); return; } List<SendKeyAction> action = getActions(SendKeyAction.class); int logicalAddress = findKeyReceiverAddress(); if (logicalAddress == Constants.ADDR_INVALID || logicalAddress == mAddress) { // Don't send key event to invalid device or itself. Slog.w(TAG, "Discard key event: " + keyCode + ", pressed:" + isPressed + ", receiverAddr=" + logicalAddress); } else if (!action.isEmpty()) { action.get(0).processKeyEvent(keyCode, isPressed); } else if (isPressed) { addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode)); } } /** * Returns the logical address of the device which will receive key events via * {@link #sendKeyEvent}. * * @see #sendKeyEvent(int, boolean) */ protected int findKeyReceiverAddress() { Slog.w(TAG, "findKeyReceiverAddress is not implemented"); return Constants.ADDR_INVALID; } void sendUserControlPressedAndReleased(int targetAddress, int cecKeycode) { Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +5 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,11 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { } } @Override protected int findKeyReceiverAddress() { return Constants.ADDR_TV; } @Override @ServiceThreadOnly protected void sendStandby(int deviceId) { Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +1 −33 Original line number Diff line number Diff line Loading @@ -432,40 +432,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { return mService.getPowerStatus(); } /** * Sends key to a target CEC device. * * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}. * @param isPressed true if this is key press event */ @Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode, boolean isPressed) { assertRunOnServiceThread(); if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) { Slog.w(TAG, "Unsupported key: " + keyCode); return; } List<SendKeyAction> action = getActions(SendKeyAction.class); int logicalAddress = findKeyReceiverAddress(); if (logicalAddress == mAddress) { Slog.w(TAG, "Discard key event to itself :" + keyCode + " pressed:" + isPressed); return; } if (!action.isEmpty()) { action.get(0).processKeyEvent(keyCode, isPressed); } else { if (isPressed) { if (logicalAddress != Constants.ADDR_INVALID) { addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode)); return; } } Slog.w(TAG, "Discard key event: " + keyCode + " pressed:" + isPressed); } } private int findKeyReceiverAddress() { protected int findKeyReceiverAddress() { if (getActiveSource().isValid()) { return getActiveSource().logicalAddress; } Loading