Merge "Import translations. DO NOT MERGE" into jb-mr1-dev
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java
index d64a092..d055345 100644
--- a/src/com/android/settings/AccessibilitySettings.java
+++ b/src/com/android/settings/AccessibilitySettings.java
@@ -30,6 +30,7 @@
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
 import android.content.res.Configuration;
+import android.database.ContentObserver;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
@@ -150,6 +151,9 @@
         }
     };
 
+    private final SettingsContentObserver mSettingsContentObserver =
+            new SettingsContentObserver(mHandler);
+
     private final RotationPolicy.RotationPolicyListener mRotationPolicyListener =
             new RotationPolicy.RotationPolicyListener() {
                 @Override
@@ -190,6 +194,7 @@
         offerInstallAccessibilitySerivceOnce();
 
         mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
+        mSettingsContentObserver.register();
         RotationPolicy.registerRotationPolicyListener(getActivity(),
                 mRotationPolicyListener);
     }
@@ -199,6 +204,7 @@
         mSettingsPackageMonitor.unregister();
         RotationPolicy.unregisterRotationPolicyListener(getActivity(),
                 mRotationPolicyListener);
+        mSettingsContentObserver.unregister();
         super.onPause();
     }
 
@@ -1009,4 +1015,28 @@
             mSummaryPreference.setSummary(summary);
         }
     }
+
+    private final class SettingsContentObserver extends ContentObserver {
+
+        public SettingsContentObserver(Handler handler) {
+            super(handler);
+        }
+
+        public void register() {
+            getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
+                    Settings.Secure.ACCESSIBILITY_ENABLED), false, this);
+            getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
+                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES), false, this);
+        }
+
+        public void unregister() {
+            getContentResolver().unregisterContentObserver(this);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri) {
+            loadInstalledServices();
+            updateServicesPreferences();
+        }
+    }
 }
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 75d905d..f07d6fa 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -247,7 +247,6 @@
         if (mNotificationCountdown > 0) {
             --mNotificationCountdown;
         } else if (mAudioManager != null) {
-            Log.d(TAG, "Notifying user that we are waiting for input...");
             try {
                 // Play the standard keypress sound at full volume. This should be available on
                 // every device. We cannot play a ringtone here because media services aren't
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 67d2258..335d888 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -241,7 +241,7 @@
             mCachedDevice.setName((String) newValue);
         } else if (preference instanceof CheckBoxPreference) {
             LocalBluetoothProfile prof = getProfileOf(preference);
-            onProfileClicked(prof);
+            onProfileClicked(prof, (CheckBoxPreference) preference);
             return false;   // checkbox will update from onDeviceAttributesChanged() callback
         } else {
             return false;
@@ -250,7 +250,7 @@
         return true;
     }
 
-    private void onProfileClicked(LocalBluetoothProfile profile) {
+    private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) {
         BluetoothDevice device = mCachedDevice.getDevice();
 
         int status = profile.getConnectionStatus(device);
@@ -260,8 +260,14 @@
         if (isConnected) {
             askDisconnect(getActivity(), profile);
         } else {
-            profile.setPreferred(device, true);
-            mCachedDevice.connectProfile(profile);
+            if (profile.isPreferred(device)) {
+                // profile is preferred but not connected: disable auto-connect
+                profile.setPreferred(device, false);
+                refreshProfilePreference(profilePref, profile);
+            } else {
+                profile.setPreferred(device, true);
+                mCachedDevice.connectProfile(profile);
+            }
         }
     }
 
@@ -357,8 +363,4 @@
     private void unpairDevice() {
         mCachedDevice.unpair();
     }
-
-    private boolean getAutoConnect(LocalBluetoothProfile prof) {
-        return prof.isPreferred(mCachedDevice.getDevice());
-    }
 }
diff --git a/src/com/android/settings/bluetooth/PanProfile.java b/src/com/android/settings/bluetooth/PanProfile.java
index b9db77b..f6e0691 100755
--- a/src/com/android/settings/bluetooth/PanProfile.java
+++ b/src/com/android/settings/bluetooth/PanProfile.java
@@ -106,7 +106,8 @@
     }
 
     public boolean isPreferred(BluetoothDevice device) {
-        return true;
+        // return current connection status so profile checkbox is set correctly
+        return getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED;
     }
 
     public int getPreferred(BluetoothDevice device) {