IMS: Grey out Wifi calling option when either sub is having call.
The WifiCallingSettingsForSub was not checking for call state reported
by telephony manager, hence, when call was on other sub, the option was not
getting greyed out.
Use the TelephonyManager API to fetch callstate.
Test: Manual
Bug: 130706399
Change-Id: Ib4b0e1191c83e23377ccf8ed013252728ef9dd95
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 11be7c3..8447fcf 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -116,8 +116,9 @@
final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
final boolean isWfcEnabled = mSwitchBar.isChecked()
&& isNonTtyOrTtyOnVolteEnabled;
-
- mSwitchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE)
+ boolean isCallStateIdle =
+ mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE;
+ mSwitchBar.setEnabled(isCallStateIdle
&& isNonTtyOrTtyOnVolteEnabled);
boolean isWfcModeEditable = true;
@@ -138,13 +139,13 @@
final Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
if (pref != null) {
pref.setEnabled(isWfcEnabled && isWfcModeEditable
- && (state == TelephonyManager.CALL_STATE_IDLE));
+ && isCallStateIdle);
}
final Preference pref_roam =
getPreferenceScreen().findPreference(BUTTON_WFC_ROAMING_MODE);
if (pref_roam != null) {
pref_roam.setEnabled(isWfcEnabled && isWfcRoamingModeEditable
- && (state == TelephonyManager.CALL_STATE_IDLE));
+ && isCallStateIdle);
}
}
};
@@ -271,8 +272,7 @@
mImsManager = getImsManager();
mImsMmTelManager = getImsMmTelManager();
- mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
- .createForSubscriptionId(mSubId);
+ mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE));
mButtonWfcMode = findPreference(BUTTON_WFC_MODE);
mButtonWfcMode.setOnPreferenceChangeListener(this);
@@ -406,9 +406,7 @@
if (mValidListener) {
mValidListener = false;
- final TelephonyManager tm = (TelephonyManager)
- getSystemService(Context.TELEPHONY_SERVICE);
- tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
mSwitchBar.removeOnSwitchChangeListener(this);
}