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

HdmiCecLocalDevicePlayback

public final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice
Represent a logical device of type Playback residing in Android system.

Fields Summary
private static final String
TAG
private boolean
mIsActiveSource
private android.os.PowerManager.WakeLock
mWakeLock
Constructors Summary
HdmiCecLocalDevicePlayback(HdmiControlService service)


      
        super(service, HdmiDeviceInfo.DEVICE_PLAYBACK);
    
Methods Summary
protected booleancanGoToStandby()

        return !getWakeLock().isHeld();
    
protected voiddisableDevice(boolean initiatedByCec, PendingActionClearedCallback callback)

        super.disableDevice(initiatedByCec, callback);

        assertRunOnServiceThread();
        if (!initiatedByCec && mIsActiveSource) {
            mService.sendCecCommand(HdmiCecMessageBuilder.buildInactiveSource(
                    mAddress, mService.getPhysicalAddress()));
        }
        setActiveSource(false);
        checkIfPendingActionsCleared();
    
protected voiddump(com.android.internal.util.IndentingPrintWriter pw)

        super.dump(pw);
        pw.println("mIsActiveSource: " + mIsActiveSource);
    
protected intgetPreferredAddress()

        assertRunOnServiceThread();
        return SystemProperties.getInt(Constants.PROPERTY_PREFERRED_ADDRESS_PLAYBACK,
                Constants.ADDR_UNREGISTERED);
    
private android.os.PowerManager.WakeLockgetWakeLock()

        assertRunOnServiceThread();
        if (mWakeLock == null) {
            mWakeLock = mService.getPowerManager().newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
            mWakeLock.setReferenceCounted(false);
        }
        return mWakeLock;
    
protected booleanhandleActiveSource(HdmiCecMessage message)

        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        mayResetActiveSource(physicalAddress);
        return true;  // Broadcast message.
    
protected booleanhandleRequestActiveSource(HdmiCecMessage message)

        assertRunOnServiceThread();
        maySendActiveSource(message.getSource());
        return true;  // Broadcast message.
    
protected booleanhandleRoutingChange(HdmiCecMessage message)

        assertRunOnServiceThread();
        int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2);
        maySetActiveSource(newPath);
        return true;  // Broadcast message.
    
protected booleanhandleRoutingInformation(HdmiCecMessage message)

        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        maySetActiveSource(physicalAddress);
        return true;  // Broadcast message.
    
protected booleanhandleSetStreamPath(HdmiCecMessage message)

        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        maySetActiveSource(physicalAddress);
        maySendActiveSource(message.getSource());
        wakeUpIfActiveSource();
        return true;  // Broadcast message.
    
private voidinvokeCallback(android.hardware.hdmi.IHdmiControlCallback callback, int result)

        assertRunOnServiceThread();
        try {
            callback.onComplete(result);
        } catch (RemoteException e) {
            Slog.e(TAG, "Invoking callback failed:" + e);
        }
    
private voidmayResetActiveSource(int physicalAddress)

        if (physicalAddress != mService.getPhysicalAddress()) {
            setActiveSource(false);
        }
    
private voidmaySendActiveSource(int dest)

        if (mIsActiveSource) {
            mService.sendCecCommand(HdmiCecMessageBuilder.buildActiveSource(
                    mAddress, mService.getPhysicalAddress()));
            // Always reports menu-status active to receive RCP.
            mService.sendCecCommand(HdmiCecMessageBuilder.buildReportMenuStatus(
                    mAddress, dest, Constants.MENU_STATE_ACTIVATED));
        }
    
private voidmaySetActiveSource(int physicalAddress)

        setActiveSource(physicalAddress == mService.getPhysicalAddress());
    
protected voidonAddressAllocated(int logicalAddress, int reason)

        assertRunOnServiceThread();
        mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                mAddress, mService.getPhysicalAddress(), mDeviceType));
        mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
                mAddress, mService.getVendorId()));
        startQueuedActions();
    
voidonHotplug(int portId, boolean connected)

        assertRunOnServiceThread();
        mCecMessageCache.flushAll();
        // We'll not clear mIsActiveSource on the hotplug event to pass CETC 11.2.2-2 ~ 3.
        if (connected && mService.isPowerStandbyOrTransient()) {
            mService.wakeUp();
        }
        if (!connected) {
            getWakeLock().release();
        }
    
voidoneTouchPlay(android.hardware.hdmi.IHdmiControlCallback callback)

        assertRunOnServiceThread();
        if (hasAction(OneTouchPlayAction.class)) {
            Slog.w(TAG, "oneTouchPlay already in progress");
            invokeCallback(callback, HdmiControlManager.RESULT_ALREADY_IN_PROGRESS);
            return;
        }

        // TODO: Consider the case of multiple TV sets. For now we always direct the command
        //       to the primary one.
        OneTouchPlayAction action = OneTouchPlayAction.create(this, Constants.ADDR_TV,
                callback);
        if (action == null) {
            Slog.w(TAG, "Cannot initiate oneTouchPlay");
            invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
            return;
        }
        addAndStartAction(action);
    
voidqueryDisplayStatus(android.hardware.hdmi.IHdmiControlCallback callback)

        assertRunOnServiceThread();
        if (hasAction(DevicePowerStatusAction.class)) {
            Slog.w(TAG, "queryDisplayStatus already in progress");
            invokeCallback(callback, HdmiControlManager.RESULT_ALREADY_IN_PROGRESS);
            return;
        }
        DevicePowerStatusAction action = DevicePowerStatusAction.create(this,
                Constants.ADDR_TV, callback);
        if (action == null) {
            Slog.w(TAG, "Cannot initiate queryDisplayStatus");
            invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
            return;
        }
        addAndStartAction(action);
    
voidsetActiveSource(boolean on)

        assertRunOnServiceThread();
        mIsActiveSource = on;
        if (on) {
            getWakeLock().acquire();
            HdmiLogger.debug("active source: %b. Wake lock acquired", mIsActiveSource);
        } else {
            getWakeLock().release();
            HdmiLogger.debug("Wake lock released");
        }
    
protected voidsetPreferredAddress(int addr)

        assertRunOnServiceThread();
        SystemProperties.set(Constants.PROPERTY_PREFERRED_ADDRESS_PLAYBACK,
                String.valueOf(addr));
    
private voidwakeUpIfActiveSource()

        if (mIsActiveSource && mService.isPowerStandbyOrTransient()) {
            mService.wakeUp();
        }