Fix bug of phoneListener always listens to default subId in WFC.

In WiFi calling settings, although each WifiCallingSettingsForSub
instance has its mSubId, the mPhoneStateListener always listens to
state of default subId, which is incorrect. This is to fix that.

Bug: 109787945
Test: In DSDS device, open WFC settings. Make phone call using default
voice phone, and check that WFC setting tab of the other phone is
not greyed out.
Change-Id: I126047c6099bf156b40e0145aa55df0fdf8ef882
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 15137cc..0c0e733 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -88,6 +88,7 @@
 
     private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
     private ImsManager mImsManager;
+    private TelephonyManager mTelephonyManager;
 
     private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
         /*
@@ -237,6 +238,9 @@
         mImsManager = ImsManager.getInstance(
                 getActivity(), SubscriptionManager.getPhoneId(mSubId));
 
+        mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
+                .createForSubscriptionId(mSubId);
+
         mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
         mButtonWfcMode.setOnPreferenceChangeListener(this);
 
@@ -318,9 +322,7 @@
         updateBody();
 
         if (mImsManager.isWfcEnabledByPlatform()) {
-            TelephonyManager tm =
-                    (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
-            tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
+            mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
 
             mSwitchBar.addOnSwitchChangeListener(this);