Search in sources :

Example 11 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method removeCecDevice.

/**
     * Called when a device is removed or removal of device is detected.
     *
     * @param address a logical address of a device to be removed
     */
@ServiceThreadOnly
final void removeCecDevice(int address) {
    assertRunOnServiceThread();
    HdmiDeviceInfo info = removeDeviceInfo(HdmiDeviceInfo.idForCecDevice(address));
    mCecMessageCache.flushMessagesFrom(address);
    invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 12 with ServiceThreadOnly

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

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 13 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method handleReportPhysicalAddress.

@Override
@ServiceThreadOnly
protected boolean handleReportPhysicalAddress(HdmiCecMessage message) {
    assertRunOnServiceThread();
    int path = HdmiUtils.twoBytesToInt(message.getParams());
    int address = message.getSource();
    int type = message.getParams()[2];
    if (updateCecSwitchInfo(address, type, path))
        return true;
    // Ignore if [Device Discovery Action] is going on.
    if (hasAction(DeviceDiscoveryAction.class)) {
        Slog.i(TAG, "Ignored while Device Discovery Action is in progress: " + message);
        return true;
    }
    if (!isInDeviceList(address, path)) {
        handleNewDeviceAtTheTailOfActivePath(path);
    }
    // Add the device ahead with default information to handle <Active Source>
    // promptly, rather than waiting till the new device action is finished.
    HdmiDeviceInfo deviceInfo = new HdmiDeviceInfo(address, path, getPortId(path), type, Constants.UNKNOWN_VENDOR_ID, HdmiUtils.getDefaultDeviceName(address));
    addCecDevice(deviceInfo);
    startNewDeviceAction(ActiveSource.of(address, path), type);
    return true;
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 14 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method isInDeviceList.

/**
     * Whether a device of the specified physical address and logical address exists
     * in a device info list. However, both are minimal condition and it could
     * be different device from the original one.
     *
     * @param logicalAddress logical address of a device to be searched
     * @param physicalAddress physical address of a device to be searched
     * @return true if exist; otherwise false
     */
@ServiceThreadOnly
boolean isInDeviceList(int logicalAddress, int physicalAddress) {
    assertRunOnServiceThread();
    HdmiDeviceInfo device = getCecDeviceInfo(logicalAddress);
    if (device == null) {
        return false;
    }
    return device.getPhysicalAddress() == physicalAddress;
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 15 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method removeCecDevice.

/**
     * Called when a device is removed or removal of device is detected.
     *
     * @param address a logical address of a device to be removed
     */
@ServiceThreadOnly
final void removeCecDevice(int address) {
    assertRunOnServiceThread();
    HdmiDeviceInfo info = removeDeviceInfo(HdmiDeviceInfo.idForCecDevice(address));
    mCecMessageCache.flushMessagesFrom(address);
    invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
}
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