Search in sources :

Example 86 with ServiceThreadOnly

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

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

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

the class HdmiCecLocalDeviceTv method updateActiveInput.

@ServiceThreadOnly
void updateActiveInput(int path, boolean notifyInputChange) {
    assertRunOnServiceThread();
    // Seq #15
    setActivePath(path);
    // Show OSD port change banner
    if (notifyInputChange) {
        ActiveSource activeSource = getActiveSource();
        HdmiDeviceInfo info = getCecDeviceInfo(activeSource.logicalAddress);
        if (info == null) {
            info = mService.getDeviceInfoByPort(getActivePortId());
            if (info == null) {
                // No CEC/MHL device is present at the port. Attempt to switch to
                // the hardware port itself for non-CEC devices that may be connected.
                info = new HdmiDeviceInfo(path, getActivePortId());
            }
        }
        mService.invokeInputChangeListener(info);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 88 with ServiceThreadOnly

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

the class HdmiControlService method changeInputForMhl.

/**
     * Performs input change, routing control for MHL device.
     *
     * @param portId MHL port, or the last port to go back to if {@code contentOn} is false
     * @param contentOn {@code true} if RAP data is content on; otherwise false
     */
@ServiceThreadOnly
void changeInputForMhl(int portId, boolean contentOn) {
    assertRunOnServiceThread();
    if (tv() == null)
        return;
    final int lastInput = contentOn ? tv().getActivePortId() : Constants.INVALID_PORT_ID;
    if (portId != Constants.INVALID_PORT_ID) {
        tv().doManualPortSwitching(portId, new IHdmiControlCallback.Stub() {

            @Override
            public void onComplete(int result) throws RemoteException {
                // Keep the last input to switch back later when RAP[ContentOff] is received.
                // This effectively sets the port to invalid one if the switching is for
                // RAP[ContentOff].
                setLastInputForMhl(lastInput);
            }
        });
    }
    // MHL device is always directly connected to the port. Update the active port ID to avoid
    // unnecessary post-routing control task.
    tv().setActivePortId(portId);
    // The port is either the MHL-enabled port where the mobile device is connected, or
    // the last port to go back to when turnoff command is received. Note that the last port
    // may not be the MHL-enabled one. In this case the device info to be passed to
    // input change listener should be the one describing the corresponding HDMI port.
    HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId);
    HdmiDeviceInfo info = (device != null) ? device.getInfo() : mPortDeviceMap.get(portId, HdmiDeviceInfo.INACTIVE_DEVICE);
    invokeInputChangeListener(info);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) IHdmiControlCallback(android.hardware.hdmi.IHdmiControlCallback) RemoteException(android.os.RemoteException) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 89 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method addDeviceInfo.

/**
     * Add a new {@link HdmiDeviceInfo}. It returns old device info which has the same
     * logical address as new device info's.
     *
     * <p>Declared as package-private. accessed by {@link HdmiControlService} only.
     *
     * @param deviceInfo a new {@link HdmiDeviceInfo} to be added.
     * @return {@code null} if it is new device. Otherwise, returns old {@HdmiDeviceInfo}
     *         that has the same logical address as new one has.
     */
@ServiceThreadOnly
private HdmiDeviceInfo addDeviceInfo(HdmiDeviceInfo deviceInfo) {
    assertRunOnServiceThread();
    HdmiDeviceInfo oldDeviceInfo = getCecDeviceInfo(deviceInfo.getLogicalAddress());
    if (oldDeviceInfo != null) {
        removeDeviceInfo(deviceInfo.getId());
    }
    mDeviceInfos.append(deviceInfo.getId(), deviceInfo);
    updateSafeDeviceInfoList();
    return oldDeviceInfo;
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 90 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method clearDeviceInfoList.

// Clear all device info.
@ServiceThreadOnly
private void clearDeviceInfoList() {
    assertRunOnServiceThread();
    for (HdmiDeviceInfo info : mSafeExternalInputs) {
        invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
    }
    mDeviceInfos.clear();
    updateSafeDeviceInfoList();
}
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