From c68e6b3d90c1e97f77dc91e00ba0f967baaccb1b Mon Sep 17 00:00:00 2001 From: Malcolm Chen Date: Tue, 26 Jun 2018 14:39:04 -0700 Subject: [PATCH] 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 --- .../settings/wifi/calling/WifiCallingSettingsForSub.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java index 15137cc821a..0c0e733902d 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java @@ -88,6 +88,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private ImsManager mImsManager; + private TelephonyManager mTelephonyManager; private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { /* @@ -237,6 +238,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment 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 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment 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);