Search in sources :

Example 31 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

the class HdmiControlService method updateSafeMhlInput.

@ServiceThreadOnly
private void updateSafeMhlInput() {
    assertRunOnServiceThread();
    List<HdmiDeviceInfo> inputs = Collections.emptyList();
    SparseArray<HdmiMhlLocalDeviceStub> devices = mMhlController.getAllLocalDevices();
    for (int i = 0; i < devices.size(); ++i) {
        HdmiMhlLocalDeviceStub device = devices.valueAt(i);
        HdmiDeviceInfo info = device.getInfo();
        if (info != null) {
            if (inputs.isEmpty()) {
                inputs = new ArrayList<>();
            }
            inputs.add(device.getInfo());
        }
    }
    synchronized (mLock) {
        mMhlDevices = inputs;
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 32 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

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 33 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

the class HotplugDetectionAction method checkHotplug.

private void checkHotplug(List<Integer> ackedAddress, boolean audioOnly) {
    BitSet currentInfos = infoListToBitSet(tv().getDeviceInfoList(false), audioOnly);
    BitSet polledResult = addressListToBitSet(ackedAddress);
    // At first, check removed devices.
    BitSet removed = complement(currentInfos, polledResult);
    int index = -1;
    while ((index = removed.nextSetBit(index + 1)) != -1) {
        if (index == Constants.ADDR_AUDIO_SYSTEM) {
            HdmiDeviceInfo avr = tv().getAvrDeviceInfo();
            if (avr != null && tv().isConnected(avr.getPortId())) {
                ++mAvrStatusCount;
                Slog.w(TAG, "Ack not returned from AVR. count: " + mAvrStatusCount);
                if (mAvrStatusCount < AVR_COUNT_MAX) {
                    continue;
                }
            }
        }
        Slog.v(TAG, "Remove device by hot-plug detection:" + index);
        removeDevice(index);
    }
    // Reset the counter if the ack is returned from AVR.
    if (!removed.get(Constants.ADDR_AUDIO_SYSTEM)) {
        mAvrStatusCount = 0;
    }
    // Next, check added devices.
    BitSet added = complement(polledResult, currentInfos);
    index = -1;
    while ((index = added.nextSetBit(index + 1)) != -1) {
        Slog.v(TAG, "Add device by hot-plug detection:" + index);
        addDevice(index);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) BitSet(java.util.BitSet)

Example 34 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

the class NewDeviceAction method addDeviceInfo.

private void addDeviceInfo() {
    // The device should be in the device list with default information.
    if (!tv().isInDeviceList(mDeviceLogicalAddress, mDevicePhysicalAddress)) {
        Slog.w(TAG, String.format("Device not found (%02x, %04x)", mDeviceLogicalAddress, mDevicePhysicalAddress));
        return;
    }
    if (mDisplayName == null) {
        mDisplayName = HdmiUtils.getDefaultDeviceName(mDeviceLogicalAddress);
    }
    HdmiDeviceInfo deviceInfo = new HdmiDeviceInfo(mDeviceLogicalAddress, mDevicePhysicalAddress, tv().getPortId(mDevicePhysicalAddress), mDeviceType, mVendorId, mDisplayName);
    tv().addCecDevice(deviceInfo);
    // Consume CEC messages we already got for this newly found device.
    tv().processDelayedMessages(mDeviceLogicalAddress);
    if (HdmiUtils.getTypeFromAddress(mDeviceLogicalAddress) == HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM) {
        tv().onNewAvrAdded(deviceInfo);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo)

Example 35 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

the class PowerStatusMonitorAction method queryPowerStatus.

private void queryPowerStatus() {
    List<HdmiDeviceInfo> deviceInfos = tv().getDeviceInfoList(false);
    resetPowerStatus(deviceInfos);
    for (HdmiDeviceInfo info : deviceInfos) {
        final int logicalAddress = info.getLogicalAddress();
        sendCommand(HdmiCecMessageBuilder.buildGiveDevicePowerStatus(getSourceAddress(), logicalAddress), new SendMessageCallback() {

            @Override
            public void onSendCompleted(int error) {
                // update power status into UNKNOWN.
                if (error != Constants.SEND_RESULT_SUCCESS) {
                    updatePowerStatus(logicalAddress, POWER_STATUS_UNKNOWN, true);
                }
            }
        });
    }
    mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
    // Add both timers, monitoring and timeout.
    addTimer(STATE_WAIT_FOR_NEXT_MONITORING, MONITIROING_INTERNAL_MS);
    addTimer(STATE_WAIT_FOR_REPORT_POWER_STATUS, REPORT_POWER_STATUS_TIMEOUT_MS);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) SendMessageCallback(com.android.server.hdmi.HdmiControlService.SendMessageCallback)

Aggregations

HdmiDeviceInfo (android.hardware.hdmi.HdmiDeviceInfo)172 ServiceThreadOnly (com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)110 ArrayList (java.util.ArrayList)15 TvInputHardwareInfo (android.media.tv.TvInputHardwareInfo)12 HdmiPortInfo (android.hardware.hdmi.HdmiPortInfo)10 SendMessageCallback (com.android.server.hdmi.HdmiControlService.SendMessageCallback)10 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 InputChannel (android.view.InputChannel)5 SomeArgs (com.android.internal.os.SomeArgs)5 DeviceDiscoveryCallback (com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback)5 AllocateAddressCallback (com.android.server.hdmi.HdmiCecController.AllocateAddressCallback)5 ActiveSource (com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 BitSet (java.util.BitSet)5 TvInputInfo (android.media.tv.TvInputInfo)4 Message (android.os.Message)4