Loading core/java/android/provider/Settings.java +17 −2 Original line number Diff line number Diff line Loading @@ -1359,8 +1359,21 @@ public final class Settings { SCREEN_BRIGHTNESS, VIBRATE_ON, NOTIFICATIONS_USE_RING_VOLUME, RINGTONE, NOTIFICATION_SOUND, MODE_RINGER, MODE_RINGER_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED, VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC, VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE, VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE, VOLUME_RING + APPEND_FOR_LAST_AUDIBLE, VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE, VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE, VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE, TEXT_AUTO_REPLACE, TEXT_AUTO_CAPS, TEXT_AUTO_PUNCTUATE, Loading Loading @@ -2299,6 +2312,8 @@ public final class Settings { * @hide */ public static final String[] SETTINGS_TO_BACKUP = { ADB_ENABLED, ALLOW_MOCK_LOCATION, INSTALL_NON_MARKET_APPS, PARENTAL_CONTROL_ENABLED, PARENTAL_CONTROL_REDIRECT_URL, Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +14 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public class SettingsBackupAgent extends BackupHelperAgent { private static final String KEY_SYSTEM = "system"; private static final String KEY_SECURE = "secure"; private static final String KEY_SYNC = "sync_providers"; private static final String KEY_LOCALE = "locale"; private static String[] sortedSystemKeys = null; private static String[] sortedSecureKeys = null; Loading Loading @@ -85,6 +86,7 @@ public class SettingsBackupAgent extends BackupHelperAgent { byte[] systemSettingsData = getSystemSettings(); byte[] secureSettingsData = getSecureSettings(); byte[] syncProviders = mSettingsHelper.getSyncProviders(); byte[] locale = mSettingsHelper.getLocaleData(); data.writeEntityHeader(KEY_SYSTEM, systemSettingsData.length); data.writeEntityData(systemSettingsData, systemSettingsData.length); Loading @@ -95,6 +97,9 @@ public class SettingsBackupAgent extends BackupHelperAgent { data.writeEntityHeader(KEY_SYNC, syncProviders.length); data.writeEntityData(syncProviders, syncProviders.length); data.writeEntityHeader(KEY_LOCALE, locale.length); data.writeEntityData(locale, locale.length); backupFile(FILE_WIFI_SUPPLICANT, data); } Loading @@ -107,14 +112,20 @@ public class SettingsBackupAgent extends BackupHelperAgent { while (data.readNextHeader()) { final String key = data.getKey(); final int size = data.getDataSize(); if (KEY_SYSTEM.equals(key)) { restoreSettings(data, Settings.System.CONTENT_URI); } else if (KEY_SECURE.equals(key)) { restoreSettings(data, Settings.Secure.CONTENT_URI); } else if (FILE_WIFI_SUPPLICANT.equals(key)) { restoreFile(FILE_WIFI_SUPPLICANT, data); // TODO: Re-enable WIFI restore when we figure out a solution for the permissions // } else if (FILE_WIFI_SUPPLICANT.equals(key)) { // restoreFile(FILE_WIFI_SUPPLICANT, data); } else if (KEY_SYNC.equals(key)) { mSettingsHelper.setSyncProviders(data); } else if (KEY_LOCALE.equals(key)) { byte[] localeData = new byte[size]; data.readEntityData(localeData, 0, size); mSettingsHelper.setLocaleData(localeData); } else { data.skipEntityData(); } Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +55 −1 Original line number Diff line number Diff line Loading @@ -16,16 +16,22 @@ package com.android.providers.settings; import java.util.Locale; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.backup.BackupDataInput; import android.content.ContentResolver; import android.content.Context; import android.content.IContentService; import android.content.res.Configuration; import android.location.LocationManager; import android.media.AudioManager; import android.os.IHardwareService; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; public class SettingsHelper { Loading Loading @@ -110,7 +116,6 @@ public class SettingsHelper { } } /* TODO: Get a list of all sync providers and save/restore the settings */ byte[] getSyncProviders() { byte[] sync = new byte[1 + PROVIDERS.length]; try { Loading Loading @@ -141,4 +146,53 @@ public class SettingsHelper { Log.w(TAG, "Unable to read sync settings"); } } byte[] getLocaleData() { Configuration conf = mContext.getResources().getConfiguration(); final Locale loc = conf.locale; String localeString = loc.getLanguage(); String country = loc.getCountry(); if (!TextUtils.isEmpty(country)) { localeString += "_" + country; } return localeString.getBytes(); } /** * Sets the locale specified. Input data is the equivalent of "ll_cc".getBytes(), where * "ll" is the language code and "cc" is the country code. * @param data the locale string in bytes. */ void setLocaleData(byte[] data) { // Check if locale was set by the user: Configuration conf = mContext.getResources().getConfiguration(); Locale loc = conf.locale; if (conf.userSetLocale) return; // Don't change if user set it in the SetupWizard final String[] availableLocales = mContext.getAssets().getLocales(); String localeCode = new String(data); String language = new String(data, 0, 2); String country = data.length > 4 ? new String(data, 3, 2) : ""; loc = null; for (int i = 0; i < availableLocales.length; i++) { if (availableLocales[i].equals(localeCode)) { loc = new Locale(language, country); break; } } if (loc == null) return; // Couldn't find the saved locale in this version of the software try { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); config.locale = loc; // indicate this isn't some passing default - the user wants this remembered config.userSetLocale = true; am.updateConfiguration(config); } catch (RemoteException e) { // Intentionally left blank } } } packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +5 −11 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.providers.settings; import java.io.FileNotFoundException; import android.backup.IBackupManager; import android.backup.BackupManager; import android.content.ContentProvider; import android.content.ContentUris; import android.content.ContentValues; Loading Loading @@ -47,6 +47,8 @@ public class SettingsProvider extends ContentProvider { private DatabaseHelper mOpenHelper; private BackupManager mBackupManager; /** * Decode a content URL into the table, projection, and arguments * used to access the corresponding database rows. Loading Loading @@ -140,16 +142,7 @@ public class SettingsProvider extends ContentProvider { } // Inform the backup manager about a data change IBackupManager ibm = IBackupManager.Stub.asInterface( ServiceManager.getService(Context.BACKUP_SERVICE)); if (ibm != null) { try { ibm.dataChanged(getContext().getPackageName()); } catch (Exception e) { // Try again later } } mBackupManager.dataChanged(); // Now send the notification through the content framework. String notify = uri.getQueryParameter("notify"); Loading Loading @@ -189,6 +182,7 @@ public class SettingsProvider extends ContentProvider { @Override public boolean onCreate() { mOpenHelper = new DatabaseHelper(getContext()); mBackupManager = new BackupManager(getContext()); return true; } Loading Loading
core/java/android/provider/Settings.java +17 −2 Original line number Diff line number Diff line Loading @@ -1359,8 +1359,21 @@ public final class Settings { SCREEN_BRIGHTNESS, VIBRATE_ON, NOTIFICATIONS_USE_RING_VOLUME, RINGTONE, NOTIFICATION_SOUND, MODE_RINGER, MODE_RINGER_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED, VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC, VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE, VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE, VOLUME_RING + APPEND_FOR_LAST_AUDIBLE, VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE, VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE, VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE, TEXT_AUTO_REPLACE, TEXT_AUTO_CAPS, TEXT_AUTO_PUNCTUATE, Loading Loading @@ -2299,6 +2312,8 @@ public final class Settings { * @hide */ public static final String[] SETTINGS_TO_BACKUP = { ADB_ENABLED, ALLOW_MOCK_LOCATION, INSTALL_NON_MARKET_APPS, PARENTAL_CONTROL_ENABLED, PARENTAL_CONTROL_REDIRECT_URL, Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +14 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public class SettingsBackupAgent extends BackupHelperAgent { private static final String KEY_SYSTEM = "system"; private static final String KEY_SECURE = "secure"; private static final String KEY_SYNC = "sync_providers"; private static final String KEY_LOCALE = "locale"; private static String[] sortedSystemKeys = null; private static String[] sortedSecureKeys = null; Loading Loading @@ -85,6 +86,7 @@ public class SettingsBackupAgent extends BackupHelperAgent { byte[] systemSettingsData = getSystemSettings(); byte[] secureSettingsData = getSecureSettings(); byte[] syncProviders = mSettingsHelper.getSyncProviders(); byte[] locale = mSettingsHelper.getLocaleData(); data.writeEntityHeader(KEY_SYSTEM, systemSettingsData.length); data.writeEntityData(systemSettingsData, systemSettingsData.length); Loading @@ -95,6 +97,9 @@ public class SettingsBackupAgent extends BackupHelperAgent { data.writeEntityHeader(KEY_SYNC, syncProviders.length); data.writeEntityData(syncProviders, syncProviders.length); data.writeEntityHeader(KEY_LOCALE, locale.length); data.writeEntityData(locale, locale.length); backupFile(FILE_WIFI_SUPPLICANT, data); } Loading @@ -107,14 +112,20 @@ public class SettingsBackupAgent extends BackupHelperAgent { while (data.readNextHeader()) { final String key = data.getKey(); final int size = data.getDataSize(); if (KEY_SYSTEM.equals(key)) { restoreSettings(data, Settings.System.CONTENT_URI); } else if (KEY_SECURE.equals(key)) { restoreSettings(data, Settings.Secure.CONTENT_URI); } else if (FILE_WIFI_SUPPLICANT.equals(key)) { restoreFile(FILE_WIFI_SUPPLICANT, data); // TODO: Re-enable WIFI restore when we figure out a solution for the permissions // } else if (FILE_WIFI_SUPPLICANT.equals(key)) { // restoreFile(FILE_WIFI_SUPPLICANT, data); } else if (KEY_SYNC.equals(key)) { mSettingsHelper.setSyncProviders(data); } else if (KEY_LOCALE.equals(key)) { byte[] localeData = new byte[size]; data.readEntityData(localeData, 0, size); mSettingsHelper.setLocaleData(localeData); } else { data.skipEntityData(); } Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +55 −1 Original line number Diff line number Diff line Loading @@ -16,16 +16,22 @@ package com.android.providers.settings; import java.util.Locale; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.backup.BackupDataInput; import android.content.ContentResolver; import android.content.Context; import android.content.IContentService; import android.content.res.Configuration; import android.location.LocationManager; import android.media.AudioManager; import android.os.IHardwareService; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; public class SettingsHelper { Loading Loading @@ -110,7 +116,6 @@ public class SettingsHelper { } } /* TODO: Get a list of all sync providers and save/restore the settings */ byte[] getSyncProviders() { byte[] sync = new byte[1 + PROVIDERS.length]; try { Loading Loading @@ -141,4 +146,53 @@ public class SettingsHelper { Log.w(TAG, "Unable to read sync settings"); } } byte[] getLocaleData() { Configuration conf = mContext.getResources().getConfiguration(); final Locale loc = conf.locale; String localeString = loc.getLanguage(); String country = loc.getCountry(); if (!TextUtils.isEmpty(country)) { localeString += "_" + country; } return localeString.getBytes(); } /** * Sets the locale specified. Input data is the equivalent of "ll_cc".getBytes(), where * "ll" is the language code and "cc" is the country code. * @param data the locale string in bytes. */ void setLocaleData(byte[] data) { // Check if locale was set by the user: Configuration conf = mContext.getResources().getConfiguration(); Locale loc = conf.locale; if (conf.userSetLocale) return; // Don't change if user set it in the SetupWizard final String[] availableLocales = mContext.getAssets().getLocales(); String localeCode = new String(data); String language = new String(data, 0, 2); String country = data.length > 4 ? new String(data, 3, 2) : ""; loc = null; for (int i = 0; i < availableLocales.length; i++) { if (availableLocales[i].equals(localeCode)) { loc = new Locale(language, country); break; } } if (loc == null) return; // Couldn't find the saved locale in this version of the software try { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); config.locale = loc; // indicate this isn't some passing default - the user wants this remembered config.userSetLocale = true; am.updateConfiguration(config); } catch (RemoteException e) { // Intentionally left blank } } }
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +5 −11 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.providers.settings; import java.io.FileNotFoundException; import android.backup.IBackupManager; import android.backup.BackupManager; import android.content.ContentProvider; import android.content.ContentUris; import android.content.ContentValues; Loading Loading @@ -47,6 +47,8 @@ public class SettingsProvider extends ContentProvider { private DatabaseHelper mOpenHelper; private BackupManager mBackupManager; /** * Decode a content URL into the table, projection, and arguments * used to access the corresponding database rows. Loading Loading @@ -140,16 +142,7 @@ public class SettingsProvider extends ContentProvider { } // Inform the backup manager about a data change IBackupManager ibm = IBackupManager.Stub.asInterface( ServiceManager.getService(Context.BACKUP_SERVICE)); if (ibm != null) { try { ibm.dataChanged(getContext().getPackageName()); } catch (Exception e) { // Try again later } } mBackupManager.dataChanged(); // Now send the notification through the content framework. String notify = uri.getQueryParameter("notify"); Loading Loading @@ -189,6 +182,7 @@ public class SettingsProvider extends ContentProvider { @Override public boolean onCreate() { mOpenHelper = new DatabaseHelper(getContext()); mBackupManager = new BackupManager(getContext()); return true; } Loading