Merge "Modify listener for changing phone account ID in calling account settings in of call settings" am: 97acc377d7 am: 72fe4a3828 am: a766f1e090

Change-Id: I432269972d32ad515a4afae523a87636e7ea3f6a
diff --git a/src/com/android/server/telecom/settings/EnableAccountPreferenceFragment.java b/src/com/android/server/telecom/settings/EnableAccountPreferenceFragment.java
index 83eb113..c2a0500 100644
--- a/src/com/android/server/telecom/settings/EnableAccountPreferenceFragment.java
+++ b/src/com/android/server/telecom/settings/EnableAccountPreferenceFragment.java
@@ -19,9 +19,11 @@
 import android.content.Context;
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
+import android.preference.Preference;
 import android.preference.PreferenceFragment;
 import android.preference.PreferenceScreen;
 import android.preference.SwitchPreference;
+import android.telecom.Log;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
@@ -52,14 +54,16 @@
                 setIcon(icon.loadDrawable(context));
             }
             setChecked(account.isEnabled());
+            setOnPreferenceChangeListener(this::onPreferenceChange);
         }
 
-        /** ${inheritDoc} */
-        @Override
-        protected void onClick() {
-            super.onClick();
+        private boolean onPreferenceChange(Preference preference, Object newValue) {
+            Log.d(this, "onPreferenceChange: key = %s", preference.getKey());
+            Log.d(this, "  preference = '%s'", preference);
+            Log.d(this, "  newValue = '%b'", newValue);
 
-            mTelecomManager.enablePhoneAccount(mAccount.getAccountHandle(), isChecked());
+            mTelecomManager.enablePhoneAccount(mAccount.getAccountHandle(), (boolean) newValue);
+            return true;
         }
     }