FileDocCategorySizeDatePackage
ActiveSourceHandler.javaAPI DocAndroid 5.1 API3912Thu Mar 12 22:22:42 GMT 2015com.android.server.hdmi

ActiveSourceHandler

public 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
Constructors Summary
private ActiveSourceHandler(HdmiCecLocalDeviceTv source, android.hardware.hdmi.IHdmiControlCallback callback)

        mSource = source;
        mService = mSource.getService();
        mCallback = callback;
    
Methods Summary
static com.android.server.hdmi.ActiveSourceHandlercreate(HdmiCecLocalDeviceTv source, android.hardware.hdmi.IHdmiControlCallback callback)


          
        if (source == null) {
            Slog.e(TAG, "Wrong arguments");
            return null;
        }
        return new ActiveSourceHandler(source, callback);
    
private final intgetSourceAddress()

        return mSource.getDeviceInfo().getLogicalAddress();
    
private voidinvokeCallback(int result)

        if (mCallback == null) {
            return;
        }
        try {
            mCallback.onComplete(result);
        } catch (RemoteException e) {
            Slog.e(TAG, "Callback failed:" + e);
        }
    
voidprocess(com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource newActive, int deviceType)
Handles the incoming active source command.

param
newActive new active source information
param
deviceType device type of the new active source

        // 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);
            }
        }