[Settings] Apply WifiCallingQueryImsState

Apply design of WifiCallingQueryImsState to source code which accessing
WifiCalling.

Bug:  140542283
Test: m RunSettingsRoboTests -j
ROBOTEST_FILTER=WifiCallingSettingsForSubTest
Test: m RunSettingsRoboTests -j
ROBOTEST_FILTER=WifiCallingPreferenceControllerTest
Test: m RunSettingsRoboTests -j
ROBOTEST_FILTER=WifiCallingSettingsTest
Test: m RunSettingsRoboTests -j
ROBOTEST_FILTER=WifiCallingSliceHelperTest

Change-Id: I0db966742d63cfe9a1ef4e1b06f6b5c81f681927
This commit is contained in:
Bonian Chen
2020-03-31 14:31:41 +08:00
parent 268bdc12c6
commit 7520adccee
8 changed files with 89 additions and 111 deletions

View File

@@ -27,10 +27,6 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import com.android.ims.ImsManager;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkUtils;
/**
* Controller class for querying Wifi calling status
*/
@@ -66,12 +62,6 @@ public class WifiCallingQueryImsState extends ImsQueryController {
return (new ImsQueryWfcUserSetting(subId)).query();
}
@VisibleForTesting
ImsManager getImsManager(int subId) {
return ImsManager.getInstance(mContext,
SubscriptionUtil.getPhoneId(mContext, subId));
}
/**
* Check whether Wifi Calling is a supported feature on this subscription
*
@@ -107,8 +97,15 @@ public class WifiCallingQueryImsState extends ImsQueryController {
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
return isWifiCallingProvisioned()
&& MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
if (!isWifiCallingProvisioned()) {
return false;
}
try {
return isServiceStateReady(mSubId);
} catch (InterruptedException | IllegalArgumentException | ImsException exception) {
Log.w(LOG_TAG, "fail to get WFC service status. subId=" + mSubId, exception);
}
return false;
}
/**