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

Commit 03f0f57e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Only set locale in config for updating locale

To update locale, it doesn't need a full configuration because
system only applied the diff of config from non-undefined fields.

IActivityManager#getConfiguration actually gets the configuration
according to the pid, which is process configuration. And process
configuration can be overridden by the activity running in its
process. So the returned value shouldn't be used to update the
system persistent configuration.

Therefore it is enough to use a new Configuration instance with
setting the necessary fields. This is also more efficient that
saves a binder call to system.

Bug: 253386061
Test: atest LocaleManagerTests
Change-Id: Icdce437fcf1a3bef0562cfc4dd5ad3ba52ea08ef
parent 241b46e6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ public class LocaleManager {
    @TestApi
    public void setSystemLocales(@NonNull LocaleList locales) {
        try {
            Configuration conf = ActivityManager.getService().getConfiguration();
            Configuration conf = new Configuration();
            conf.setLocales(locales);
            ActivityManager.getService().updatePersistentConfiguration(conf);
        } catch (RemoteException e) {
+1 −2
Original line number Diff line number Diff line
@@ -311,8 +311,7 @@ public class LocalePicker extends ListFragment {

        try {
            final IActivityManager am = ActivityManager.getService();
            final Configuration config = am.getConfiguration();

            final Configuration config = new Configuration();
            config.setLocales(locales);
            config.userSetLocale = true;

+1 −1
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ public class SettingsHelper {

        try {
            IActivityManager am = ActivityManager.getService();
            Configuration config = am.getConfiguration();
            final Configuration config = new Configuration();
            config.setLocales(merged);
            // indicate this isn't some passing default - the user wants this remembered
            config.userSetLocale = true;