Search in sources :

Example 1 with LocaleInfo

use of com.android.internal.app.LocalePicker.LocaleInfo in project android_frameworks_base by DirtyUnicorns.

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 2 with LocaleInfo

use of com.android.internal.app.LocalePicker.LocaleInfo 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 3 with LocaleInfo

use of com.android.internal.app.LocalePicker.LocaleInfo in project android_frameworks_base by crdroidandroid.

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 4 with LocaleInfo

use of com.android.internal.app.LocalePicker.LocaleInfo in project platform_frameworks_base by android.

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 5 with LocaleInfo

use of com.android.internal.app.LocalePicker.LocaleInfo in project android_frameworks_base by ResurrectionRemix.

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)

Aggregations

LocaleInfo (com.android.internal.app.LocalePicker.LocaleInfo)5 ServiceThreadOnly (com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 Locale (java.util.Locale)5