From 45d17581844df55cfc85117819e41c33eb40ad96 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 26 Jun 2017 17:35:26 -0700 Subject: [PATCH] Don't apply locale as part of deferred restore Once the user has entered normal usage their locale configuration is essentially guaranteed to be what they intend to use. Don't override it during deferred restore. (We distinguish based on whether the device is already marked as 'provisioned'.) Bug 62224214 Test: manual Change-Id: Icedef6a86a2b8942937b1384b204def88f2238d2 --- .../com/android/providers/settings/SettingsHelper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java index 1e171d3f8210..8abdc641d675 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java @@ -37,10 +37,12 @@ import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArraySet; +import android.util.Slog; import java.util.Locale; public class SettingsHelper { + private static final String TAG = "SettingsHelper"; private static final String SILENT_RINGTONE = "_silent"; private Context mContext; private AudioManager mAudioManager; @@ -324,11 +326,17 @@ public class SettingsHelper { */ void setLocaleData(byte[] data, int size) { // Check if locale was set by the user: - Configuration conf = mContext.getResources().getConfiguration(); - // TODO: The following is not working as intended because the network is forcing a locale - // change after registering. Need to find some other way to detect if the user manually - // changed the locale - if (conf.userSetLocale) return; // Don't change if user set it in the SetupWizard + final ContentResolver cr = mContext.getContentResolver(); + final boolean userSetLocale = mContext.getResources().getConfiguration().userSetLocale; + final boolean provisioned = Settings.Global.getInt(cr, + Settings.Global.DEVICE_PROVISIONED, 0) != 0; + if (userSetLocale || provisioned) { + // Don't change if user set it in the SetupWizard, or if this is a post-setup + // deferred restore operation + Slog.i(TAG, "Not applying restored locale; " + + (userSetLocale ? "user already specified" : "device already provisioned")); + return; + } final String[] availableLocales = mContext.getAssets().getLocales(); // Replace "_" with "-" to deal with older backups. -- 2.11.0