Search in sources :

Example 71 with HdmiDeviceInfo

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

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)

Example 72 with HdmiDeviceInfo

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

the class HdmiControlService method allocateLogicalAddress.

@ServiceThreadOnly
private void allocateLogicalAddress(final ArrayList<HdmiCecLocalDevice> allocatingDevices, final int initiatedBy) {
    assertRunOnServiceThread();
    mCecController.clearLogicalAddress();
    final ArrayList<HdmiCecLocalDevice> allocatedDevices = new ArrayList<>();
    final int[] finished = new int[1];
    mAddressAllocated = allocatingDevices.isEmpty();
    // For TV device, select request can be invoked while address allocation or device
    // discovery is in progress. Initialize the request here at the start of allocation,
    // and process the collected requests later when the allocation and device discovery
    // is all completed.
    mSelectRequestBuffer.clear();
    for (final HdmiCecLocalDevice localDevice : allocatingDevices) {
        mCecController.allocateLogicalAddress(localDevice.getType(), localDevice.getPreferredAddress(), new AllocateAddressCallback() {

            @Override
            public void onAllocated(int deviceType, int logicalAddress) {
                if (logicalAddress == Constants.ADDR_UNREGISTERED) {
                    Slog.e(TAG, "Failed to allocate address:[device_type:" + deviceType + "]");
                } else {
                    // Set POWER_STATUS_ON to all local devices because they share lifetime
                    // with system.
                    HdmiDeviceInfo deviceInfo = createDeviceInfo(logicalAddress, deviceType, HdmiControlManager.POWER_STATUS_ON);
                    localDevice.setDeviceInfo(deviceInfo);
                    mCecController.addLocalDevice(deviceType, localDevice);
                    mCecController.addLogicalAddress(logicalAddress);
                    allocatedDevices.add(localDevice);
                }
                // Address allocation completed for all devices. Notify each device.
                if (allocatingDevices.size() == ++finished[0]) {
                    mAddressAllocated = true;
                    if (initiatedBy != INITIATED_BY_HOTPLUG) {
                        // In case of the hotplug we don't call onInitializeCecComplete()
                        // since we reallocate the logical address only.
                        onInitializeCecComplete(initiatedBy);
                    }
                    notifyAddressAllocated(allocatedDevices, initiatedBy);
                    mCecMessageBuffer.processMessages();
                }
            }
        });
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ArrayList(java.util.ArrayList) AllocateAddressCallback(com.android.server.hdmi.HdmiCecController.AllocateAddressCallback) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 73 with HdmiDeviceInfo

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

the class HdmiControlService method initPortInfo.

// Initialize HDMI port information. Combine the information from CEC and MHL HAL and
// keep them in one place.
@ServiceThreadOnly
private void initPortInfo() {
    assertRunOnServiceThread();
    HdmiPortInfo[] cecPortInfo = null;
    // each port. Return empty array if CEC HAL didn't provide the info.
    if (mCecController != null) {
        cecPortInfo = mCecController.getPortInfos();
    }
    if (cecPortInfo == null) {
        return;
    }
    SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>();
    SparseIntArray portIdMap = new SparseIntArray();
    SparseArray<HdmiDeviceInfo> portDeviceMap = new SparseArray<>();
    for (HdmiPortInfo info : cecPortInfo) {
        portIdMap.put(info.getAddress(), info.getId());
        portInfoMap.put(info.getId(), info);
        portDeviceMap.put(info.getId(), new HdmiDeviceInfo(info.getAddress(), info.getId()));
    }
    mPortIdMap = new UnmodifiableSparseIntArray(portIdMap);
    mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap);
    mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap);
    HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos();
    ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length);
    for (HdmiPortInfo info : mhlPortInfo) {
        if (info.isMhlSupported()) {
            mhlSupportedPorts.add(info.getId());
        }
    }
    // cec port info if we do not have have port that supports MHL.
    if (mhlSupportedPorts.isEmpty()) {
        mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo));
        return;
    }
    ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length);
    for (HdmiPortInfo info : cecPortInfo) {
        if (mhlSupportedPorts.contains(info.getId())) {
            result.add(new HdmiPortInfo(info.getId(), info.getType(), info.getAddress(), info.isCecSupported(), true, info.isArcSupported()));
        } else {
            result.add(info);
        }
    }
    mPortInfo = Collections.unmodifiableList(result);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ArraySet(android.util.ArraySet) HdmiPortInfo(android.hardware.hdmi.HdmiPortInfo) ArrayList(java.util.ArrayList) SparseArray(android.util.SparseArray) SparseIntArray(android.util.SparseIntArray) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 74 with HdmiDeviceInfo

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

the class HdmiCecLocalDeviceTv method updateArcFeatureStatus.

@ServiceThreadOnly
private void updateArcFeatureStatus(int portId, boolean isConnected) {
    assertRunOnServiceThread();
    HdmiPortInfo portInfo = mService.getPortInfo(portId);
    if (!portInfo.isArcSupported()) {
        return;
    }
    HdmiDeviceInfo avr = getAvrDeviceInfo();
    if (avr == null) {
        if (isConnected) {
            // Update the status (since TV may not have seen AVR yet) so
            // that ARC can be initiated after discovery.
            mArcFeatureEnabled.put(portId, isConnected);
        }
        return;
    }
    // Should not activate ARC if +5V status is false.
    if (avr.getPortId() == portId) {
        changeArcFeatureEnabled(portId, isConnected);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) HdmiPortInfo(android.hardware.hdmi.HdmiPortInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 75 with HdmiDeviceInfo

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

the class HdmiCecLocalDeviceTv method startArcAction.

@ServiceThreadOnly
void startArcAction(boolean enabled) {
    assertRunOnServiceThread();
    HdmiDeviceInfo info = getAvrDeviceInfo();
    if (info == null) {
        Slog.w(TAG, "Failed to start arc action; No AVR device.");
        return;
    }
    if (!canStartArcUpdateAction(info.getLogicalAddress(), enabled)) {
        Slog.w(TAG, "Failed to start arc action; ARC configuration check failed.");
        if (enabled && !isConnectedToArcPort(info.getPhysicalAddress())) {
            displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
        }
        return;
    }
    // Terminate opposite action and start action if not exist.
    if (enabled) {
        removeAction(RequestArcTerminationAction.class);
        if (!hasAction(RequestArcInitiationAction.class)) {
            addAndStartAction(new RequestArcInitiationAction(this, info.getLogicalAddress()));
        }
    } else {
        removeAction(RequestArcInitiationAction.class);
        if (!hasAction(RequestArcTerminationAction.class)) {
            addAndStartAction(new RequestArcTerminationAction(this, info.getLogicalAddress()));
        }
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

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