diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 97da52be5a4c3..96823e17809b2 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -818,42 +818,18 @@ public final class HdmiControlService extends SystemService { getVendorId(), displayName); } - @ServiceThreadOnly - void sendMhlSubcommand(int portId, HdmiMhlSubcommand command) { - assertRunOnServiceThread(); - sendMhlSubcommand(portId, command, null); - } - - @ServiceThreadOnly - void sendMhlSubcommand(int portId, HdmiMhlSubcommand command, SendMessageCallback callback) { - assertRunOnServiceThread(); - mMhlController.sendSubcommand(portId, command, callback); - } - - @ServiceThreadOnly - boolean handleMhlSubcommand(int portId, HdmiMhlSubcommand message) { - assertRunOnServiceThread(); - - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); - if (device != null) { - return device.handleSubcommand(message); - } - Slog.w(TAG, "No mhl device exists[portId:" + portId + ", message:" + message); - return false; - } - @ServiceThreadOnly void handleMhlHotplugEvent(int portId, boolean connected) { assertRunOnServiceThread(); if (connected) { - HdmiMhlLocalDevice newDevice = new HdmiMhlLocalDevice(this, portId); - HdmiMhlLocalDevice oldDevice = mMhlController.addLocalDevice(newDevice); + HdmiMhlLocalDeviceStub newDevice = new HdmiMhlLocalDeviceStub(this, portId); + HdmiMhlLocalDeviceStub oldDevice = mMhlController.addLocalDevice(newDevice); if (oldDevice != null) { oldDevice.onDeviceRemoved(); Slog.i(TAG, "Old device of port " + portId + " is removed"); } } else { - HdmiMhlLocalDevice device = mMhlController.removeLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.removeLocalDevice(portId); if (device != null) { device.onDeviceRemoved(); // There is no explicit event for device removal. @@ -873,7 +849,7 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly void handleMhlBusModeChanged(int portId, int busmode) { assertRunOnServiceThread(); - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId); if (device != null) { device.setBusMode(busmode); } else { @@ -885,7 +861,7 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly void handleMhlBusOvercurrent(int portId, boolean on) { assertRunOnServiceThread(); - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId); if (device != null) { device.onBusOvercurrentDetected(on); } else { @@ -896,7 +872,7 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly void handleMhlDeviceStatusChanged(int portId, int adopterId, int deviceId) { assertRunOnServiceThread(); - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId); // Hotplug event should already have been called before device status change event. if (device != null) { @@ -913,9 +889,9 @@ public final class HdmiControlService extends SystemService { private void updateSafeMhlInput() { assertRunOnServiceThread(); List inputs = Collections.emptyList(); - SparseArray devices = mMhlController.getAllLocalDevices(); + SparseArray devices = mMhlController.getAllLocalDevices(); for (int i = 0; i < devices.size(); ++i) { - HdmiMhlLocalDevice device = devices.valueAt(i); + HdmiMhlLocalDeviceStub device = devices.valueAt(i); HdmiDeviceInfo info = device.getInfo(); if (info != null) { if (inputs.isEmpty()) { @@ -1077,7 +1053,7 @@ public final class HdmiControlService extends SystemService { invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); return; } - HdmiMhlLocalDevice device = mMhlController.getLocalDeviceById(deviceId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDeviceById(deviceId); if (device != null) { if (device.getPortId() == tv.getActivePortId()) { invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS); @@ -1122,7 +1098,7 @@ public final class HdmiControlService extends SystemService { runOnServiceThread(new Runnable() { @Override public void run() { - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(mActivePortId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(mActivePortId); if (device != null) { device.sendKeyEvent(keyCode, isPressed); return; @@ -1434,7 +1410,7 @@ public final class HdmiControlService extends SystemService { Slog.w(TAG, "Hdmi control is disabled."); return ; } - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId); if (device == null) { Slog.w(TAG, "Invalid port id:" + portId); return; @@ -2025,7 +2001,7 @@ public final class HdmiControlService extends SystemService { // the last port to go back to when turnoff command is received. Note that the last port // may not be the MHL-enabled one. In this case the device info to be passed to // input change listener should be the one describing the corresponding HDMI port. - HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); + HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId); HdmiDeviceInfo info = (device != null && device.getInfo() != null) ? device.getInfo() : mPortDeviceMap.get(portId); diff --git a/services/core/java/com/android/server/hdmi/HdmiMhlControllerStub.java b/services/core/java/com/android/server/hdmi/HdmiMhlControllerStub.java index afe6e3c5f09f6..708aee6b4c840 100644 --- a/services/core/java/com/android/server/hdmi/HdmiMhlControllerStub.java +++ b/services/core/java/com/android/server/hdmi/HdmiMhlControllerStub.java @@ -29,7 +29,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; */ final class HdmiMhlControllerStub { - private static final SparseArray mLocalDevices = new SparseArray<>(); + private static final SparseArray mLocalDevices = new SparseArray<>(); private static final HdmiPortInfo[] EMPTY_PORT_INFO = new HdmiPortInfo[0]; private static final int INVALID_MHL_VERSION = 0; private static final int NO_SUPPORTED_FEATURES = 0; @@ -53,59 +53,48 @@ final class HdmiMhlControllerStub { } /** - * Return {@link HdmiMhlLocalDevice} matched with the given port id. + * Return {@link HdmiMhlLocalDeviceStub} matched with the given port id. * * @return null if has no matched port id */ - HdmiMhlLocalDevice getLocalDevice(int portId) { + HdmiMhlLocalDeviceStub getLocalDevice(int portId) { return null; } /** - * Return {@link HdmiMhlLocalDevice} matched with the given device id. + * Return {@link HdmiMhlLocalDeviceStub} matched with the given device id. * * @return null if has no matched id */ - HdmiMhlLocalDevice getLocalDeviceById(int deviceId) { + HdmiMhlLocalDeviceStub getLocalDeviceById(int deviceId) { return null; } - SparseArray getAllLocalDevices() { + SparseArray getAllLocalDevices() { return mLocalDevices; } /** - * Remove a {@link HdmiMhlLocalDevice} matched with the given port id. + * Remove a {@link HdmiMhlLocalDeviceStub} matched with the given port id. * - * @return removed {@link HdmiMhlLocalDevice}. Return null if no matched port id. + * @return removed {@link HdmiMhlLocalDeviceStub}. Return null if no matched port id. */ - HdmiMhlLocalDevice removeLocalDevice(int portId) { + HdmiMhlLocalDeviceStub removeLocalDevice(int portId) { return null; } /** - * Add a new {@link HdmiMhlLocalDevice}. + * Add a new {@link HdmiMhlLocalDeviceStub}. * - * @return old {@link HdmiMhlLocalDevice} having same port id + * @return old {@link HdmiMhlLocalDeviceStub} having same port id */ - HdmiMhlLocalDevice addLocalDevice(HdmiMhlLocalDevice device) { + HdmiMhlLocalDeviceStub addLocalDevice(HdmiMhlLocalDeviceStub device) { return null; } void clearAllLocalDevices() { } - /** - * Send MHL MSC-Subcommand to the device connected to the given port. - */ - void sendSubcommand(int portId, HdmiMhlSubcommand command) { - } - - void sendSubcommand(final int portId, final HdmiMhlSubcommand command, - SendMessageCallback callback) { - } - - void sendVendorCommand(int portId, int offset, int length, byte[] data) { } diff --git a/services/core/java/com/android/server/hdmi/HdmiMhlLocalDeviceStub.java b/services/core/java/com/android/server/hdmi/HdmiMhlLocalDeviceStub.java new file mode 100644 index 0000000000000..53a7c5c2e5dc0 --- /dev/null +++ b/services/core/java/com/android/server/hdmi/HdmiMhlLocalDeviceStub.java @@ -0,0 +1,46 @@ +package com.android.server.hdmi; + +import android.hardware.hdmi.HdmiDeviceInfo; +import android.hardware.hdmi.IHdmiControlCallback; + +/** + * Stub class that models a logical mhl device hosted in this system. + */ +final class HdmiMhlLocalDeviceStub { + + private static final HdmiDeviceInfo INFO = new HdmiDeviceInfo( + Constants.INVALID_PHYSICAL_ADDRESS, Constants.INVALID_PORT_ID, -1, -1); + private final HdmiControlService mService; + private final int mPortId; + + protected HdmiMhlLocalDeviceStub(HdmiControlService service, int portId) { + mService = service; + mPortId = portId; + } + + void onDeviceRemoved() { + } + + HdmiDeviceInfo getInfo() { + return INFO; + } + + void setBusMode(int cbusmode) { + } + + void onBusOvercurrentDetected(boolean on) { + } + + void setDeviceStatusChange(int adopterId, int deviceId) { + } + + int getPortId() { + return mPortId; + } + + void turnOn(IHdmiControlCallback callback) { + } + + void sendKeyEvent(int keycode, boolean isPressed) { + } +}