Loading services/core/java/com/android/server/hdmi/Constants.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -248,6 +248,11 @@ final class Constants { static final int DISABLED = 0; static final int DISABLED = 0; static final int ENABLED = 1; static final int ENABLED = 1; // Property name for the local device configurations. // TODO(OEM): OEM should provide this property, and the value is the comma separated integer // values which denotes the device type in HDMI Spec 1.4. static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type"; // -------------------------------------------------- // -------------------------------------------------- // MHL sub command message types. // MHL sub command message types. static final int MHL_MSG_MSGE = 0x02; static final int MHL_MSG_MSGE = 0x02; Loading Loading @@ -275,11 +280,6 @@ final class Constants { static final int MHL_CBUS_MODE_ECBUS_S = 2; static final int MHL_CBUS_MODE_ECBUS_S = 2; static final int MHL_CBUS_MODE_ECBUS_D = 3; static final int MHL_CBUS_MODE_ECBUS_D = 3; // Property name for the local device configurations. // TODO(OEM): OEM should provide this property, and the value is the comma separated integer // values which denotes the device type in HDMI Spec 1.4. static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type"; // MHL RCPE messages // MHL RCPE messages static final int MHL_RCPE_NO_ERROR = 0x00; static final int MHL_RCPE_NO_ERROR = 0x00; static final int MHL_RCPE_INEFFECTIVE_KEYCODE = 0x01; static final int MHL_RCPE_INEFFECTIVE_KEYCODE = 0x01; Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +85 −100 Original line number Original line Diff line number Diff line Loading @@ -179,11 +179,6 @@ public final class HdmiControlService extends SystemService { private final ArrayList<VendorCommandListenerRecord> mVendorCommandListenerRecords = private final ArrayList<VendorCommandListenerRecord> mVendorCommandListenerRecords = new ArrayList<>(); new ArrayList<>(); // List of records for MHL Scratchpad command listener to handle the caller killed in action. @GuardedBy("mLock") private final ArrayList<HdmiMhlScratchpadCommandListenerRecord> mScratchpadCommandListenerRecords = new ArrayList<>(); @GuardedBy("mLock") @GuardedBy("mLock") private InputChangeListenerRecord mInputChangeListenerRecord; private InputChangeListenerRecord mInputChangeListenerRecord; Loading @@ -201,13 +196,6 @@ public final class HdmiControlService extends SystemService { @GuardedBy("mLock") @GuardedBy("mLock") private boolean mProhibitMode; private boolean mProhibitMode; // Set to true while the input change by MHL is allowed. @GuardedBy("mLock") private boolean mMhlInputChangeEnabled; @GuardedBy("mLock") private List<HdmiDeviceInfo> mMhlDevices; // List of records for system audio mode change to handle the the caller killed in action. // List of records for system audio mode change to handle the the caller killed in action. private final ArrayList<SystemAudioModeChangeListenerRecord> private final ArrayList<SystemAudioModeChangeListenerRecord> mSystemAudioModeChangeListenerRecords = new ArrayList<>(); mSystemAudioModeChangeListenerRecords = new ArrayList<>(); Loading @@ -223,9 +211,6 @@ public final class HdmiControlService extends SystemService { @Nullable @Nullable private HdmiCecController mCecController; private HdmiCecController mCecController; @Nullable private HdmiMhlController mMhlController; // HDMI port information. Stored in the unmodifiable list to keep the static information // HDMI port information. Stored in the unmodifiable list to keep the static information // from being modified. // from being modified. private List<HdmiPortInfo> mPortInfo; private List<HdmiPortInfo> mPortInfo; Loading Loading @@ -256,8 +241,23 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly @ServiceThreadOnly private int mActivePortId = Constants.INVALID_PORT_ID; private int mActivePortId = Constants.INVALID_PORT_ID; // Last input port before switching to the MHL port by way of incoming request RAP[ContentOn]. // Set to true while the input change by MHL is allowed. // Should switch back to this port when the device sends RAP[ContentOff]. @GuardedBy("mLock") private boolean mMhlInputChangeEnabled; // List of records for MHL Scratchpad command listener to handle the caller killed in action. @GuardedBy("mLock") private final ArrayList<HdmiMhlScratchpadCommandListenerRecord> mScratchpadCommandListenerRecords = new ArrayList<>(); @GuardedBy("mLock") private List<HdmiDeviceInfo> mMhlDevices; @Nullable private HdmiMhlController mMhlController; // Last input port before switching to the MHL port. Should switch back to this port // when the mobile device sends the request one touch play with off. // Gets invalidated if we go to other port/input. // Gets invalidated if we go to other port/input. @ServiceThreadOnly @ServiceThreadOnly private int mLastInputMhl = Constants.INVALID_PORT_ID; private int mLastInputMhl = Constants.INVALID_PORT_ID; Loading Loading @@ -304,16 +304,17 @@ public final class HdmiControlService extends SystemService { } } mMhlController = HdmiMhlController.create(this); mMhlController = HdmiMhlController.create(this); if (mMhlController == null) { if (!mMhlController.isReady()) { Slog.i(TAG, "Device does not support MHL-control."); Slog.i(TAG, "Device does not support MHL-control."); } } initPortInfo(); mMhlDevices = Collections.emptyList(); mMhlDevices = Collections.emptyList(); initPortInfo(); mMessageValidator = new HdmiCecMessageValidator(this); mMessageValidator = new HdmiCecMessageValidator(this); publishBinderService(Context.HDMI_CONTROL_SERVICE, new BinderService()); publishBinderService(Context.HDMI_CONTROL_SERVICE, new BinderService()); // Register broadcast receiver for power state change. // Register broadcast receiver for power state change. if (mCecController != null || mMhlController != null) { if (mCecController != null) { IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_ON); Loading Loading @@ -378,9 +379,7 @@ public final class HdmiControlService extends SystemService { setMhlInputChangeEnabled(enabled); setMhlInputChangeEnabled(enabled); break; break; case Global.MHL_POWER_CHARGE_ENABLED: case Global.MHL_POWER_CHARGE_ENABLED: if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled)); mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled)); } break; break; } } } } Loading Loading @@ -484,10 +483,6 @@ public final class HdmiControlService extends SystemService { mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap); mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap); if (mMhlController == null) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); return; } else { HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos(); HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos(); ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length); ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length); for (HdmiPortInfo info : mhlPortInfo) { for (HdmiPortInfo info : mhlPortInfo) { Loading @@ -496,7 +491,12 @@ public final class HdmiControlService extends SystemService { } } } } // Build HDMI port info list with CEC port info plus MHL supported flag. // Build HDMI port info list with CEC port info plus MHL supported flag. We can just use // cec port info if we do not have have port that supports MHL. if (mhlSupportedPorts.isEmpty()) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); return; } ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length); ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length); for (HdmiPortInfo info : cecPortInfo) { for (HdmiPortInfo info : cecPortInfo) { if (mhlSupportedPorts.contains(info.getId())) { if (mhlSupportedPorts.contains(info.getId())) { Loading @@ -508,7 +508,6 @@ public final class HdmiControlService extends SystemService { } } mPortInfo = Collections.unmodifiableList(result); mPortInfo = Collections.unmodifiableList(result); } } } List<HdmiPortInfo> getPortInfo() { List<HdmiPortInfo> getPortInfo() { return mPortInfo; return mPortInfo; Loading Loading @@ -652,18 +651,6 @@ public final class HdmiControlService extends SystemService { sendCecCommand(command, null); sendCecCommand(command, null); } } @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); } /** /** * Send <Feature Abort> command on the given CEC message if possible. * Send <Feature Abort> command on the given CEC message if possible. * If the aborted message is invalid, then it wont send the message. * If the aborted message is invalid, then it wont send the message. Loading Loading @@ -795,6 +782,18 @@ public final class HdmiControlService extends SystemService { getVendorId(), displayName); 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 @ServiceThreadOnly boolean handleMhlSubcommand(int portId, HdmiMhlSubcommand message) { boolean handleMhlSubcommand(int portId, HdmiMhlSubcommand message) { assertRunOnServiceThread(); assertRunOnServiceThread(); Loading Loading @@ -895,6 +894,19 @@ public final class HdmiControlService extends SystemService { return mMhlDevices; return mMhlDevices; } } private class HdmiMhlScratchpadCommandListenerRecord implements IBinder.DeathRecipient { private final IHdmiMhlScratchpadCommandListener mListener; public HdmiMhlScratchpadCommandListenerRecord(IHdmiMhlScratchpadCommandListener listener) { mListener = listener; } @Override public void binderDied() { mScratchpadCommandListenerRecords.remove(this); } } // Record class that monitors the event of the caller of being killed. Used to clean up // Record class that monitors the event of the caller of being killed. Used to clean up // the listener list and record list accordingly. // the listener list and record list accordingly. private final class HotplugEventListenerRecord implements IBinder.DeathRecipient { private final class HotplugEventListenerRecord implements IBinder.DeathRecipient { Loading Loading @@ -974,19 +986,6 @@ public final class HdmiControlService extends SystemService { } } } } private class HdmiMhlScratchpadCommandListenerRecord implements IBinder.DeathRecipient { private final IHdmiMhlScratchpadCommandListener mListener; public HdmiMhlScratchpadCommandListenerRecord(IHdmiMhlScratchpadCommandListener listener) { mListener = listener; } @Override public void binderDied() { mScratchpadCommandListenerRecords.remove(this); } } private void enforceAccessPermission() { private void enforceAccessPermission() { getContext().enforceCallingOrSelfPermission(PERMISSION, TAG); getContext().enforceCallingOrSelfPermission(PERMISSION, TAG); } } Loading Loading @@ -1039,7 +1038,6 @@ public final class HdmiControlService extends SystemService { invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); return; return; } } if (mMhlController != null) { HdmiMhlLocalDevice device = mMhlController.getLocalDeviceById(deviceId); HdmiMhlLocalDevice device = mMhlController.getLocalDeviceById(deviceId); if (device != null) { if (device != null) { if (device.getPortId() == tv.getActivePortId()) { if (device.getPortId() == tv.getActivePortId()) { Loading @@ -1053,7 +1051,6 @@ public final class HdmiControlService extends SystemService { tv.doManualPortSwitching(device.getInfo().getPortId(), null); tv.doManualPortSwitching(device.getInfo().getPortId(), null); return; return; } } } tv.deviceSelect(deviceId, callback); tv.deviceSelect(deviceId, callback); } } }); }); Loading Loading @@ -1086,13 +1083,11 @@ public final class HdmiControlService extends SystemService { runOnServiceThread(new Runnable() { runOnServiceThread(new Runnable() { @Override @Override public void run() { public void run() { if (mMhlController != null) { HdmiMhlLocalDevice device = mMhlController.getLocalDevice(mActivePortId); HdmiMhlLocalDevice device = mMhlController.getLocalDevice(mActivePortId); if (device != null) { if (device != null) { device.sendKeyEvent(keyCode, isPressed); device.sendKeyEvent(keyCode, isPressed); return; return; } } } if (mCecController != null) { if (mCecController != null) { HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(deviceType); HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(deviceType); if (localDevice == null) { if (localDevice == null) { Loading Loading @@ -1380,10 +1375,6 @@ public final class HdmiControlService extends SystemService { runOnServiceThread(new Runnable() { runOnServiceThread(new Runnable() { @Override @Override public void run() { public void run() { if (mMhlController == null) { Slog.w(TAG, "No Mhl controller available."); return; } if (!isControlEnabled()) { if (!isControlEnabled()) { Slog.w(TAG, "Hdmi control is disabled."); Slog.w(TAG, "Hdmi control is disabled."); return ; return ; Loading Loading @@ -1775,10 +1766,8 @@ public final class HdmiControlService extends SystemService { } } } } if (mMhlController != null) { mMhlController.clearAllLocalDevices(); mMhlController.clearAllLocalDevices(); } } } @ServiceThreadOnly @ServiceThreadOnly private void clearLocalDevices() { private void clearLocalDevices() { Loading Loading @@ -1887,9 +1876,7 @@ public final class HdmiControlService extends SystemService { int value = toInt(enabled); int value = toInt(enabled); mCecController.setOption(OPTION_CEC_ENABLE, value); mCecController.setOption(OPTION_CEC_ENABLE, value); if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_ENABLE, value); mMhlController.setOption(OPTION_MHL_ENABLE, value); } synchronized (mLock) { synchronized (mLock) { mHdmiControlEnabled = enabled; mHdmiControlEnabled = enabled; Loading Loading @@ -1955,7 +1942,7 @@ public final class HdmiControlService extends SystemService { tv().setActivePortId(portId); tv().setActivePortId(portId); // The port is either the MHL-enabled port where the mobile device is connected, or // The port is either the MHL-enabled port where the mobile device is connected, or // the last port to go back to when RAP[ContentOff] is received. Note that the last port // 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 // 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. // input change listener should be the one describing the corresponding HDMI port. HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); Loading @@ -1966,9 +1953,7 @@ public final class HdmiControlService extends SystemService { } } void setMhlInputChangeEnabled(boolean enabled) { void setMhlInputChangeEnabled(boolean enabled) { if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled)); mMhlController.setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled)); } synchronized (mLock) { synchronized (mLock) { mMhlInputChangeEnabled = enabled; mMhlInputChangeEnabled = enabled; Loading Loading
services/core/java/com/android/server/hdmi/Constants.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -248,6 +248,11 @@ final class Constants { static final int DISABLED = 0; static final int DISABLED = 0; static final int ENABLED = 1; static final int ENABLED = 1; // Property name for the local device configurations. // TODO(OEM): OEM should provide this property, and the value is the comma separated integer // values which denotes the device type in HDMI Spec 1.4. static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type"; // -------------------------------------------------- // -------------------------------------------------- // MHL sub command message types. // MHL sub command message types. static final int MHL_MSG_MSGE = 0x02; static final int MHL_MSG_MSGE = 0x02; Loading Loading @@ -275,11 +280,6 @@ final class Constants { static final int MHL_CBUS_MODE_ECBUS_S = 2; static final int MHL_CBUS_MODE_ECBUS_S = 2; static final int MHL_CBUS_MODE_ECBUS_D = 3; static final int MHL_CBUS_MODE_ECBUS_D = 3; // Property name for the local device configurations. // TODO(OEM): OEM should provide this property, and the value is the comma separated integer // values which denotes the device type in HDMI Spec 1.4. static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type"; // MHL RCPE messages // MHL RCPE messages static final int MHL_RCPE_NO_ERROR = 0x00; static final int MHL_RCPE_NO_ERROR = 0x00; static final int MHL_RCPE_INEFFECTIVE_KEYCODE = 0x01; static final int MHL_RCPE_INEFFECTIVE_KEYCODE = 0x01; Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +85 −100 Original line number Original line Diff line number Diff line Loading @@ -179,11 +179,6 @@ public final class HdmiControlService extends SystemService { private final ArrayList<VendorCommandListenerRecord> mVendorCommandListenerRecords = private final ArrayList<VendorCommandListenerRecord> mVendorCommandListenerRecords = new ArrayList<>(); new ArrayList<>(); // List of records for MHL Scratchpad command listener to handle the caller killed in action. @GuardedBy("mLock") private final ArrayList<HdmiMhlScratchpadCommandListenerRecord> mScratchpadCommandListenerRecords = new ArrayList<>(); @GuardedBy("mLock") @GuardedBy("mLock") private InputChangeListenerRecord mInputChangeListenerRecord; private InputChangeListenerRecord mInputChangeListenerRecord; Loading @@ -201,13 +196,6 @@ public final class HdmiControlService extends SystemService { @GuardedBy("mLock") @GuardedBy("mLock") private boolean mProhibitMode; private boolean mProhibitMode; // Set to true while the input change by MHL is allowed. @GuardedBy("mLock") private boolean mMhlInputChangeEnabled; @GuardedBy("mLock") private List<HdmiDeviceInfo> mMhlDevices; // List of records for system audio mode change to handle the the caller killed in action. // List of records for system audio mode change to handle the the caller killed in action. private final ArrayList<SystemAudioModeChangeListenerRecord> private final ArrayList<SystemAudioModeChangeListenerRecord> mSystemAudioModeChangeListenerRecords = new ArrayList<>(); mSystemAudioModeChangeListenerRecords = new ArrayList<>(); Loading @@ -223,9 +211,6 @@ public final class HdmiControlService extends SystemService { @Nullable @Nullable private HdmiCecController mCecController; private HdmiCecController mCecController; @Nullable private HdmiMhlController mMhlController; // HDMI port information. Stored in the unmodifiable list to keep the static information // HDMI port information. Stored in the unmodifiable list to keep the static information // from being modified. // from being modified. private List<HdmiPortInfo> mPortInfo; private List<HdmiPortInfo> mPortInfo; Loading Loading @@ -256,8 +241,23 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly @ServiceThreadOnly private int mActivePortId = Constants.INVALID_PORT_ID; private int mActivePortId = Constants.INVALID_PORT_ID; // Last input port before switching to the MHL port by way of incoming request RAP[ContentOn]. // Set to true while the input change by MHL is allowed. // Should switch back to this port when the device sends RAP[ContentOff]. @GuardedBy("mLock") private boolean mMhlInputChangeEnabled; // List of records for MHL Scratchpad command listener to handle the caller killed in action. @GuardedBy("mLock") private final ArrayList<HdmiMhlScratchpadCommandListenerRecord> mScratchpadCommandListenerRecords = new ArrayList<>(); @GuardedBy("mLock") private List<HdmiDeviceInfo> mMhlDevices; @Nullable private HdmiMhlController mMhlController; // Last input port before switching to the MHL port. Should switch back to this port // when the mobile device sends the request one touch play with off. // Gets invalidated if we go to other port/input. // Gets invalidated if we go to other port/input. @ServiceThreadOnly @ServiceThreadOnly private int mLastInputMhl = Constants.INVALID_PORT_ID; private int mLastInputMhl = Constants.INVALID_PORT_ID; Loading Loading @@ -304,16 +304,17 @@ public final class HdmiControlService extends SystemService { } } mMhlController = HdmiMhlController.create(this); mMhlController = HdmiMhlController.create(this); if (mMhlController == null) { if (!mMhlController.isReady()) { Slog.i(TAG, "Device does not support MHL-control."); Slog.i(TAG, "Device does not support MHL-control."); } } initPortInfo(); mMhlDevices = Collections.emptyList(); mMhlDevices = Collections.emptyList(); initPortInfo(); mMessageValidator = new HdmiCecMessageValidator(this); mMessageValidator = new HdmiCecMessageValidator(this); publishBinderService(Context.HDMI_CONTROL_SERVICE, new BinderService()); publishBinderService(Context.HDMI_CONTROL_SERVICE, new BinderService()); // Register broadcast receiver for power state change. // Register broadcast receiver for power state change. if (mCecController != null || mMhlController != null) { if (mCecController != null) { IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_ON); Loading Loading @@ -378,9 +379,7 @@ public final class HdmiControlService extends SystemService { setMhlInputChangeEnabled(enabled); setMhlInputChangeEnabled(enabled); break; break; case Global.MHL_POWER_CHARGE_ENABLED: case Global.MHL_POWER_CHARGE_ENABLED: if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled)); mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled)); } break; break; } } } } Loading Loading @@ -484,10 +483,6 @@ public final class HdmiControlService extends SystemService { mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap); mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap); mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap); if (mMhlController == null) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); return; } else { HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos(); HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos(); ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length); ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length); for (HdmiPortInfo info : mhlPortInfo) { for (HdmiPortInfo info : mhlPortInfo) { Loading @@ -496,7 +491,12 @@ public final class HdmiControlService extends SystemService { } } } } // Build HDMI port info list with CEC port info plus MHL supported flag. // Build HDMI port info list with CEC port info plus MHL supported flag. We can just use // cec port info if we do not have have port that supports MHL. if (mhlSupportedPorts.isEmpty()) { mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo)); return; } ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length); ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length); for (HdmiPortInfo info : cecPortInfo) { for (HdmiPortInfo info : cecPortInfo) { if (mhlSupportedPorts.contains(info.getId())) { if (mhlSupportedPorts.contains(info.getId())) { Loading @@ -508,7 +508,6 @@ public final class HdmiControlService extends SystemService { } } mPortInfo = Collections.unmodifiableList(result); mPortInfo = Collections.unmodifiableList(result); } } } List<HdmiPortInfo> getPortInfo() { List<HdmiPortInfo> getPortInfo() { return mPortInfo; return mPortInfo; Loading Loading @@ -652,18 +651,6 @@ public final class HdmiControlService extends SystemService { sendCecCommand(command, null); sendCecCommand(command, null); } } @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); } /** /** * Send <Feature Abort> command on the given CEC message if possible. * Send <Feature Abort> command on the given CEC message if possible. * If the aborted message is invalid, then it wont send the message. * If the aborted message is invalid, then it wont send the message. Loading Loading @@ -795,6 +782,18 @@ public final class HdmiControlService extends SystemService { getVendorId(), displayName); 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 @ServiceThreadOnly boolean handleMhlSubcommand(int portId, HdmiMhlSubcommand message) { boolean handleMhlSubcommand(int portId, HdmiMhlSubcommand message) { assertRunOnServiceThread(); assertRunOnServiceThread(); Loading Loading @@ -895,6 +894,19 @@ public final class HdmiControlService extends SystemService { return mMhlDevices; return mMhlDevices; } } private class HdmiMhlScratchpadCommandListenerRecord implements IBinder.DeathRecipient { private final IHdmiMhlScratchpadCommandListener mListener; public HdmiMhlScratchpadCommandListenerRecord(IHdmiMhlScratchpadCommandListener listener) { mListener = listener; } @Override public void binderDied() { mScratchpadCommandListenerRecords.remove(this); } } // Record class that monitors the event of the caller of being killed. Used to clean up // Record class that monitors the event of the caller of being killed. Used to clean up // the listener list and record list accordingly. // the listener list and record list accordingly. private final class HotplugEventListenerRecord implements IBinder.DeathRecipient { private final class HotplugEventListenerRecord implements IBinder.DeathRecipient { Loading Loading @@ -974,19 +986,6 @@ public final class HdmiControlService extends SystemService { } } } } private class HdmiMhlScratchpadCommandListenerRecord implements IBinder.DeathRecipient { private final IHdmiMhlScratchpadCommandListener mListener; public HdmiMhlScratchpadCommandListenerRecord(IHdmiMhlScratchpadCommandListener listener) { mListener = listener; } @Override public void binderDied() { mScratchpadCommandListenerRecords.remove(this); } } private void enforceAccessPermission() { private void enforceAccessPermission() { getContext().enforceCallingOrSelfPermission(PERMISSION, TAG); getContext().enforceCallingOrSelfPermission(PERMISSION, TAG); } } Loading Loading @@ -1039,7 +1038,6 @@ public final class HdmiControlService extends SystemService { invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); return; return; } } if (mMhlController != null) { HdmiMhlLocalDevice device = mMhlController.getLocalDeviceById(deviceId); HdmiMhlLocalDevice device = mMhlController.getLocalDeviceById(deviceId); if (device != null) { if (device != null) { if (device.getPortId() == tv.getActivePortId()) { if (device.getPortId() == tv.getActivePortId()) { Loading @@ -1053,7 +1051,6 @@ public final class HdmiControlService extends SystemService { tv.doManualPortSwitching(device.getInfo().getPortId(), null); tv.doManualPortSwitching(device.getInfo().getPortId(), null); return; return; } } } tv.deviceSelect(deviceId, callback); tv.deviceSelect(deviceId, callback); } } }); }); Loading Loading @@ -1086,13 +1083,11 @@ public final class HdmiControlService extends SystemService { runOnServiceThread(new Runnable() { runOnServiceThread(new Runnable() { @Override @Override public void run() { public void run() { if (mMhlController != null) { HdmiMhlLocalDevice device = mMhlController.getLocalDevice(mActivePortId); HdmiMhlLocalDevice device = mMhlController.getLocalDevice(mActivePortId); if (device != null) { if (device != null) { device.sendKeyEvent(keyCode, isPressed); device.sendKeyEvent(keyCode, isPressed); return; return; } } } if (mCecController != null) { if (mCecController != null) { HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(deviceType); HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(deviceType); if (localDevice == null) { if (localDevice == null) { Loading Loading @@ -1380,10 +1375,6 @@ public final class HdmiControlService extends SystemService { runOnServiceThread(new Runnable() { runOnServiceThread(new Runnable() { @Override @Override public void run() { public void run() { if (mMhlController == null) { Slog.w(TAG, "No Mhl controller available."); return; } if (!isControlEnabled()) { if (!isControlEnabled()) { Slog.w(TAG, "Hdmi control is disabled."); Slog.w(TAG, "Hdmi control is disabled."); return ; return ; Loading Loading @@ -1775,10 +1766,8 @@ public final class HdmiControlService extends SystemService { } } } } if (mMhlController != null) { mMhlController.clearAllLocalDevices(); mMhlController.clearAllLocalDevices(); } } } @ServiceThreadOnly @ServiceThreadOnly private void clearLocalDevices() { private void clearLocalDevices() { Loading Loading @@ -1887,9 +1876,7 @@ public final class HdmiControlService extends SystemService { int value = toInt(enabled); int value = toInt(enabled); mCecController.setOption(OPTION_CEC_ENABLE, value); mCecController.setOption(OPTION_CEC_ENABLE, value); if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_ENABLE, value); mMhlController.setOption(OPTION_MHL_ENABLE, value); } synchronized (mLock) { synchronized (mLock) { mHdmiControlEnabled = enabled; mHdmiControlEnabled = enabled; Loading Loading @@ -1955,7 +1942,7 @@ public final class HdmiControlService extends SystemService { tv().setActivePortId(portId); tv().setActivePortId(portId); // The port is either the MHL-enabled port where the mobile device is connected, or // The port is either the MHL-enabled port where the mobile device is connected, or // the last port to go back to when RAP[ContentOff] is received. Note that the last port // 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 // 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. // input change listener should be the one describing the corresponding HDMI port. HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId); Loading @@ -1966,9 +1953,7 @@ public final class HdmiControlService extends SystemService { } } void setMhlInputChangeEnabled(boolean enabled) { void setMhlInputChangeEnabled(boolean enabled) { if (mMhlController != null) { mMhlController.setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled)); mMhlController.setOption(OPTION_MHL_INPUT_SWITCHING, toInt(enabled)); } synchronized (mLock) { synchronized (mLock) { mMhlInputChangeEnabled = enabled; mMhlInputChangeEnabled = enabled; Loading