Search in sources :

Example 51 with ServiceThreadOnly

use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method onAddressAllocated.

@Override
@ServiceThreadOnly
protected void onAddressAllocated(int logicalAddress, int reason) {
    assertRunOnServiceThread();
    List<HdmiPortInfo> ports = mService.getPortInfo();
    for (HdmiPortInfo port : ports) {
        mArcFeatureEnabled.put(port.getId(), port.isArcSupported());
    }
    mService.registerTvInputCallback(mTvInputCallback);
    mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(mAddress, mService.getPhysicalAddress(), mDeviceType));
    mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(mAddress, mService.getVendorId()));
    // TV is a CEC switch too.
    mCecSwitches.add(mService.getPhysicalAddress());
    mTvInputs.clear();
    mSkipRoutingControl = (reason == HdmiControlService.INITIATED_BY_WAKE_UP_MESSAGE);
    launchRoutingControl(reason != HdmiControlService.INITIATED_BY_ENABLE_CEC && reason != HdmiControlService.INITIATED_BY_BOOT_UP);
    mLocalDeviceAddresses = initLocalDeviceAddresses();
    resetSelectRequestBuffer();
    launchDeviceDiscovery();
}
Also used : HdmiPortInfo(android.hardware.hdmi.HdmiPortInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 52 with ServiceThreadOnly

use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method deviceSelect.

/**
     * Performs the action 'device select', or 'one touch play' initiated by TV.
     *
     * @param id id of HDMI device to select
     * @param callback callback object to report the result with
     */
@ServiceThreadOnly
void deviceSelect(int id, IHdmiControlCallback callback) {
    assertRunOnServiceThread();
    HdmiDeviceInfo targetDevice = mDeviceInfos.get(id);
    if (targetDevice == null) {
        invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE);
        return;
    }
    int targetAddress = targetDevice.getLogicalAddress();
    ActiveSource active = getActiveSource();
    if (targetDevice.getDevicePowerStatus() == HdmiControlManager.POWER_STATUS_ON && active.isValid() && targetAddress == active.logicalAddress) {
        invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS);
        return;
    }
    if (targetAddress == Constants.ADDR_INTERNAL) {
        handleSelectInternalSource();
        // Switching to internal source is always successful even when CEC control is disabled.
        setActiveSource(targetAddress, mService.getPhysicalAddress());
        setActivePath(mService.getPhysicalAddress());
        invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS);
        return;
    }
    if (!mService.isControlEnabled()) {
        setActiveSource(targetDevice);
        invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
        return;
    }
    removeAction(DeviceSelectAction.class);
    addAndStartAction(new DeviceSelectAction(this, targetDevice, callback));
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 53 with ServiceThreadOnly

use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method launchDeviceDiscovery.

@ServiceThreadOnly
private void launchDeviceDiscovery() {
    assertRunOnServiceThread();
    clearDeviceInfoList();
    DeviceDiscoveryAction action = new DeviceDiscoveryAction(this, new DeviceDiscoveryCallback() {

        @Override
        public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos) {
            for (HdmiDeviceInfo info : deviceInfos) {
                addCecDevice(info);
            }
            // we should put device info of local device manually here
            for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
                addCecDevice(device.getDeviceInfo());
            }
            mSelectRequestBuffer.process();
            resetSelectRequestBuffer();
            addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
            addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
            // If there is AVR, initiate System Audio Auto initiation action,
            // which turns on and off system audio according to last system
            // audio setting.
            HdmiDeviceInfo avr = getAvrDeviceInfo();
            if (avr != null) {
                onNewAvrAdded(avr);
            } else {
                setSystemAudioMode(false, true);
            }
        }
    });
    addAndStartAction(action);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) DeviceDiscoveryCallback(com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 54 with ServiceThreadOnly

use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method changeSystemAudioMode.

@ServiceThreadOnly
// Seq #32
void changeSystemAudioMode(boolean enabled, IHdmiControlCallback callback) {
    assertRunOnServiceThread();
    if (!mService.isControlEnabled() || hasAction(DeviceDiscoveryAction.class)) {
        setSystemAudioMode(false, true);
        invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
        return;
    }
    HdmiDeviceInfo avr = getAvrDeviceInfo();
    if (avr == null) {
        setSystemAudioMode(false, true);
        invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE);
        return;
    }
    addAndStartAction(new SystemAudioActionFromTv(this, avr.getLogicalAddress(), enabled, callback));
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 55 with ServiceThreadOnly

use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method setAudioReturnChannel.

/**
     * Switch hardware ARC circuit in the system.
     */
@ServiceThreadOnly
void setAudioReturnChannel(boolean enabled) {
    assertRunOnServiceThread();
    HdmiDeviceInfo avr = getAvrDeviceInfo();
    if (avr != null) {
        mService.setAudioReturnChannel(avr.getPortId(), enabled);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Aggregations

ServiceThreadOnly (com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)135 HdmiDeviceInfo (android.hardware.hdmi.HdmiDeviceInfo)110 HdmiPortInfo (android.hardware.hdmi.HdmiPortInfo)15 PendingActionClearedCallback (com.android.server.hdmi.HdmiCecLocalDevice.PendingActionClearedCallback)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)10 ArrayList (java.util.ArrayList)10 Intent (android.content.Intent)5 IHdmiControlCallback (android.hardware.hdmi.IHdmiControlCallback)5 RemoteException (android.os.RemoteException)5 ArraySet (android.util.ArraySet)5 SparseArray (android.util.SparseArray)5 SparseIntArray (android.util.SparseIntArray)5 LocaleInfo (com.android.internal.app.LocalePicker.LocaleInfo)5 DeviceDiscoveryCallback (com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback)5 AllocateAddressCallback (com.android.server.hdmi.HdmiCecController.AllocateAddressCallback)5 Locale (java.util.Locale)5