Merge "Propagating core settings to the system process." into honeycomb-mr1
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b409f2f..bd83762 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -200,6 +200,8 @@
 
     static Handler sMainThreadHandler;  // set once in main()
 
+    Bundle mCoreSettings = null;
+
     private static final class ActivityClientRecord {
         IBinder token;
         int ident;
@@ -354,7 +356,6 @@
         boolean restrictedBackupMode;
         Configuration config;
         boolean handlingProfiling;
-        Bundle coreSettings;
         public String toString() {
             return "AppBindData{appInfo=" + appInfo + "}";
         }
@@ -559,6 +560,8 @@
                 ServiceManager.initServiceCache(services);
             }
 
+            setCoreSettings(coreSettings);
+
             AppBindData data = new AppBindData();
             data.processName = processName;
             data.appInfo = appInfo;
@@ -570,7 +573,6 @@
             data.debugMode = debugMode;
             data.restrictedBackupMode = isRestrictedBackupMode;
             data.config = config;
-            data.coreSettings = coreSettings;
             queueOrSendMessage(H.BIND_APPLICATION, data);
         }
 
@@ -898,8 +900,8 @@
             pw.println(String.format(format, objs));
         }
 
-        public void setCoreSettings(Bundle settings) {
-            queueOrSendMessage(H.SET_CORE_SETTINGS, settings);
+        public void setCoreSettings(Bundle coreSettings) {
+            queueOrSendMessage(H.SET_CORE_SETTINGS, coreSettings);
         }
     }
 
@@ -2720,10 +2722,8 @@
     }
 
     private void handleSetCoreSettings(Bundle coreSettings) {
-        if (mBoundApplication != null) {
-            synchronized (mBoundApplication) {
-                mBoundApplication.coreSettings = coreSettings;
-            }
+        synchronized (mPackages) {
+            mCoreSettings = coreSettings;
         }
     }
 
@@ -3990,13 +3990,9 @@
     }
 
     public int getIntCoreSetting(String key, int defaultValue) {
-        if (mBoundApplication == null) {
-            return defaultValue;
-        }
-        synchronized (mBoundApplication) {
-            Bundle coreSettings = mBoundApplication.coreSettings;
-            if (coreSettings != null) {
-                return coreSettings.getInt(key, defaultValue);
+        synchronized (mPackages) {
+            if (mCoreSettings != null) {
+                return mCoreSettings.getInt(key, defaultValue);
             } else {
                 return defaultValue;
             }
diff --git a/services/java/com/android/server/am/CoreSettingsObserver.java b/services/java/com/android/server/am/CoreSettingsObserver.java
index 25db84a..585cf2b 100644
--- a/services/java/com/android/server/am/CoreSettingsObserver.java
+++ b/services/java/com/android/server/am/CoreSettingsObserver.java
@@ -52,7 +52,7 @@
         super(activityManagerService.mHandler);
         mActivityManagerService = activityManagerService;
         beginObserveCoreSettings();
-        populateCoreSettings(mCoreSettings);
+        sendCoreSettings();
     }
 
     public Bundle getCoreSettingsLocked() {
@@ -62,11 +62,15 @@
     @Override
     public void onChange(boolean selfChange) {
         synchronized (mActivityManagerService) {
-            populateCoreSettings(mCoreSettings);
-            mActivityManagerService.onCoreSettingsChange(mCoreSettings);
+            sendCoreSettings();
         }
     }
 
+    private void sendCoreSettings() {
+        populateCoreSettings(mCoreSettings);
+        mActivityManagerService.onCoreSettingsChange(mCoreSettings);
+    }
+
     private void beginObserveCoreSettings() {
         for (String setting : sCoreSettingToTypeMap.keySet()) {
             Uri uri = Settings.Secure.getUriFor(setting);