ActiveSourceHandlerpublic final class ActiveSourceHandler extends Object Handles CEC command <Active Source>.
Used by feature actions that need to handle the command in their flow. Only for TV
local device. |
Fields Summary |
---|
private static final String | TAG | private final HdmiCecLocalDeviceTv | mSource | private final HdmiControlService | mService | private final android.hardware.hdmi.IHdmiControlCallback | mCallback |
Methods Summary |
---|
static com.android.server.hdmi.ActiveSourceHandler | create(HdmiCecLocalDeviceTv source, android.hardware.hdmi.IHdmiControlCallback callback)
if (source == null) {
Slog.e(TAG, "Wrong arguments");
return null;
}
return new ActiveSourceHandler(source, callback);
| private final int | getSourceAddress()
return mSource.getDeviceInfo().getLogicalAddress();
| private void | invokeCallback(int result)
if (mCallback == null) {
return;
}
try {
mCallback.onComplete(result);
} catch (RemoteException e) {
Slog.e(TAG, "Callback failed:" + e);
}
| void | process(com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource newActive, int deviceType)Handles the incoming active source command.
// Seq #17
HdmiCecLocalDeviceTv tv = mSource;
HdmiDeviceInfo device = mService.getDeviceInfo(newActive.logicalAddress);
if (device == null) {
tv.startNewDeviceAction(newActive, deviceType);
}
if (!tv.isProhibitMode()) {
tv.updateActiveSource(newActive);
boolean notifyInputChange = (mCallback == null);
tv.updateActiveInput(newActive.physicalAddress, notifyInputChange);
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
} else {
// TV is in a mode that should keep its current source/input from
// being changed for its operation. Reclaim the active source
// or switch the port back to the one used for the current mode.
ActiveSource current = tv.getActiveSource();
if (current.logicalAddress == getSourceAddress()) {
HdmiCecMessage activeSourceCommand = HdmiCecMessageBuilder.buildActiveSource(
current.logicalAddress, current.physicalAddress);
mService.sendCecCommand(activeSourceCommand);
tv.updateActiveSource(current);
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
} else {
tv.startRoutingControl(newActive.physicalAddress, current.physicalAddress, true,
mCallback);
}
}
|
|