Search in sources :

Example 46 with ServiceThreadOnly

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

the class HdmiCecLocalDevicePlayback method handleSetMenuLanguage.

@ServiceThreadOnly
protected boolean handleSetMenuLanguage(HdmiCecMessage message) {
    assertRunOnServiceThread();
    if (!SET_MENU_LANGUAGE) {
        return false;
    }
    try {
        String iso3Language = new String(message.getParams(), 0, 3, "US-ASCII");
        Locale currentLocale = mService.getContext().getResources().getConfiguration().locale;
        if (currentLocale.getISO3Language().equals(iso3Language)) {
            // due to the limitation of CEC. See the warning below.
            return true;
        }
        // Don't use Locale.getAvailableLocales() since it returns a locale
        // which is not available on Settings.
        final List<LocaleInfo> localeInfos = LocalePicker.getAllAssetLocales(mService.getContext(), false);
        for (LocaleInfo localeInfo : localeInfos) {
            if (localeInfo.getLocale().getISO3Language().equals(iso3Language)) {
                // WARNING: CEC adopts ISO/FDIS-2 for language code, while Android requires
                // additional country variant to pinpoint the locale. This keeps the right
                // locale from being chosen. 'eng' in the CEC command, for instance,
                // will always be mapped to en-AU among other variants like en-US, en-GB,
                // an en-IN, which may not be the expected one.
                LocalePicker.updateLocale(localeInfo.getLocale());
                return true;
            }
        }
        Slog.w(TAG, "Can't handle <Set Menu Language> of " + iso3Language);
        return false;
    } catch (UnsupportedEncodingException e) {
        Slog.w(TAG, "Can't handle <Set Menu Language>", e);
        return false;
    }
}
Also used : Locale(java.util.Locale) LocaleInfo(com.android.internal.app.LocalePicker.LocaleInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 47 with ServiceThreadOnly

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

the class HdmiCecLocalDeviceTv method disableArcIfExist.

@ServiceThreadOnly
private void disableArcIfExist() {
    assertRunOnServiceThread();
    HdmiDeviceInfo avr = getAvrDeviceInfo();
    if (avr == null) {
        return;
    }
    // Seq #44.
    removeAction(RequestArcInitiationAction.class);
    if (!hasAction(RequestArcTerminationAction.class) && isArcEstablished()) {
        addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress()));
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 48 with ServiceThreadOnly

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

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)

Example 49 with ServiceThreadOnly

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

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

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

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)

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