Example usage for android.os.storage StorageManager SYSTEM_LOCALE_KEY

List of usage examples for android.os.storage StorageManager SYSTEM_LOCALE_KEY

Introduction

In this page you can find the example usage for android.os.storage StorageManager SYSTEM_LOCALE_KEY.

Prototype

String SYSTEM_LOCALE_KEY

To view the source code for android.os.storage StorageManager SYSTEM_LOCALE_KEY.

Click Source Link

Usage

From source file:com.android.server.MountService.java

private void copyLocaleFromMountService() {
    String systemLocale;/*from   w  w w .j av a  2s  . co  m*/
    try {
        systemLocale = getField(StorageManager.SYSTEM_LOCALE_KEY);
    } catch (RemoteException e) {
        return;
    }
    if (TextUtils.isEmpty(systemLocale)) {
        return;
    }

    Slog.d(TAG, "Got locale " + systemLocale + " from mount service");
    Locale locale = Locale.forLanguageTag(systemLocale);
    Configuration config = new Configuration();
    config.setLocale(locale);
    try {
        ActivityManagerNative.getDefault().updateConfiguration(config);
    } catch (RemoteException e) {
        Slog.e(TAG, "Error setting system locale from mount service", e);
    }

    // Temporary workaround for http://b/17945169.
    Slog.d(TAG, "Setting system properties to " + systemLocale + " from mount service");
    SystemProperties.set("persist.sys.language", locale.getLanguage());
    SystemProperties.set("persist.sys.country", locale.getCountry());
}