Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34c4756e authored by Roozbeh Pournader's avatar Roozbeh Pournader Committed by Android (Google) Code Review
Browse files

Merge "Optimize locale negotiation when there's only one locale"

parents 59dad14d 9ae46d8e
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -18117,10 +18117,18 @@ public final class ActivityManagerService extends ActivityManagerNative
                EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
                if (!initLocale && !values.getLocales().isEmpty() && values.userSetLocale) {
                    final Locale locale;
                    if (values.getLocales().size() == 1) {
                        // This is an optimization to avoid the JNI call when the result of
                        // getFirstMatch() does not depend on the supported locales.
                        locale = values.getLocales().getPrimary();
                    } else {
                        if (mSupportedSystemLocales == null) {
                        mSupportedSystemLocales = Resources.getSystem().getAssets().getLocales();
                            mSupportedSystemLocales =
                                    Resources.getSystem().getAssets().getLocales();
                        }
                        locale = values.getLocales().getFirstMatch(mSupportedSystemLocales);
                    }
                    final Locale locale = values.getLocales().getFirstMatch(mSupportedSystemLocales);
                    SystemProperties.set("persist.sys.locale", locale.toLanguageTag());
                    mHandler.sendMessage(mHandler.obtainMessage(SEND_LOCALE_TO_MOUNT_DAEMON_MSG,
                            locale));