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

Commit 70392818 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Don't set userSetLocale from Configuration.setLocale.

This seems to have been a mistake : userSetLocale controls whether
a locale is persisted and as written it's too easy to make system wide
locale changes without intending to. Third party apps do not have
sufficient permissions to set global locales anyway, so they won't care
whether it's set or not.

Also, set userSetLocale = true in the LocalePicker.updateLocale internal
API, which is what all platform apps use to set the locale.

In addition, this commit fixes a bug where we were not setting RTL
directionality for the default locale loaded by the activity manager
service.

Change-Id: I2e11ad31e012dfa314ab8d78034f986b49ecae60
parent 492e501f
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -1284,14 +1284,12 @@ public final class Configuration implements Parcelable, Comparable<Configuration


    /**
    /**
     * Set the locale. This is the preferred way for setting up the locale (instead of using the
     * Set the locale. This is the preferred way for setting up the locale (instead of using the
     * direct accessor). This will also set the userLocale and layout direction according to
     * direct accessor). This will also set the layout direction according to the locale.
     * the locale.
     *
     *
     * @param loc The locale. Can be null.
     * @param loc The locale. Can be null.
     */
     */
    public void setLocale(Locale loc) {
    public void setLocale(Locale loc) {
        locale = loc;
        locale = loc;
        userSetLocale = true;
        setLayoutDirection(locale);
        setLayoutDirection(locale);
    }
    }


+1 −2
Original line number Original line Diff line number Diff line
@@ -246,9 +246,8 @@ public class LocalePicker extends ListFragment {
            IActivityManager am = ActivityManagerNative.getDefault();
            IActivityManager am = ActivityManagerNative.getDefault();
            Configuration config = am.getConfiguration();
            Configuration config = am.getConfiguration();


            // Will set userSetLocale to indicate this isn't some passing default - the user
            // wants this remembered
            config.setLocale(locale);
            config.setLocale(locale);
            config.userSetLocale = true;


            am.updateConfiguration(config);
            am.updateConfiguration(config);
            // Trigger the dirty bit for the Settings Provider.
            // Trigger the dirty bit for the Settings Provider.
+1 −1
Original line number Original line Diff line number Diff line
@@ -2204,7 +2204,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations"));
        mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations"));
        mConfiguration.setToDefaults();
        mConfiguration.setToDefaults();
        mConfiguration.locale = Locale.getDefault();
        mConfiguration.setLocale(Locale.getDefault());
        mConfigurationSeq = mConfiguration.seq = 1;
        mConfigurationSeq = mConfiguration.seq = 1;
        mProcessCpuTracker.init();
        mProcessCpuTracker.init();