[Settings] Replace ImsManager#isWfcEnabledByPlatform()
Replace ImsManager#isWfcEnabledByPlatform(). Bug: 140542283 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest Change-Id: I85907efb39aecdb3fb18cacf11ce4510b898edc4
This commit is contained in:
@@ -20,8 +20,10 @@ import android.content.Context;
|
|||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.AccessNetworkConstants;
|
import android.telephony.AccessNetworkConstants;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.ims.ImsException;
|
||||||
import android.telephony.ims.feature.MmTelFeature;
|
import android.telephony.ims.feature.MmTelFeature;
|
||||||
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -34,6 +36,8 @@ import com.android.settings.network.telephony.MobileNetworkUtils;
|
|||||||
*/
|
*/
|
||||||
public class WifiCallingQueryImsState extends ImsQueryController {
|
public class WifiCallingQueryImsState extends ImsQueryController {
|
||||||
|
|
||||||
|
private static final String LOG_TAG = "WifiCallingQueryImsState";
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private int mSubId;
|
private int mSubId;
|
||||||
|
|
||||||
@@ -68,22 +72,30 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
SubscriptionUtil.getPhoneId(mContext, subId));
|
SubscriptionUtil.getPhoneId(mContext, subId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether Wifi Calling is a supported feature on this subscription
|
||||||
|
*
|
||||||
|
* @return true when Wifi Calling is a supported feature, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean isWifiCallingSupported() {
|
||||||
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return isEnabledByPlatform(mSubId);
|
||||||
|
} catch (InterruptedException | IllegalArgumentException | ImsException exception) {
|
||||||
|
Log.w(LOG_TAG, "fail to get WFC supporting status. subId=" + mSubId, exception);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether Wifi Calling has been provisioned or not on this subscription
|
* Check whether Wifi Calling has been provisioned or not on this subscription
|
||||||
*
|
*
|
||||||
* @return true when Wifi Calling has been enabled, otherwise false
|
* @return true when Wifi Calling has been enabled, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isWifiCallingProvisioned() {
|
public boolean isWifiCallingProvisioned() {
|
||||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
return isWifiCallingSupported() && isProvisionedOnDevice(mSubId);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final ImsManager imsManager = getImsManager(mSubId);
|
|
||||||
if (imsManager == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return imsManager.isWfcEnabledByPlatform()
|
|
||||||
&& isProvisionedOnDevice(mSubId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -419,7 +419,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
updateBody();
|
updateBody();
|
||||||
|
|
||||||
if (mImsManager.isWfcEnabledByPlatform()) {
|
if (queryImsState(mSubId).isWifiCallingSupported()) {
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
|
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
|
||||||
|
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.telephony.ims.ImsException;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
import com.android.ims.ImsManager;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ import com.android.ims.ImsManager;
|
|||||||
public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
||||||
|
|
||||||
private Boolean mIsTtyOnVolteEnabled;
|
private Boolean mIsTtyOnVolteEnabled;
|
||||||
|
private Boolean mIsEnabledOnPlatform;
|
||||||
private Boolean mIsProvisionedOnDevice;
|
private Boolean mIsProvisionedOnDevice;
|
||||||
private Boolean mIsEnabledByUser;
|
private Boolean mIsEnabledByUser;
|
||||||
|
|
||||||
@@ -56,6 +58,20 @@ public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
|||||||
return super.isTtyOnVolteEnabled(subId);
|
return super.isTtyOnVolteEnabled(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setIsEnabledByPlatform(boolean isEnabled) {
|
||||||
|
mIsEnabledOnPlatform = isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean isEnabledByPlatform(int subId) throws InterruptedException, ImsException,
|
||||||
|
IllegalArgumentException {
|
||||||
|
if (mIsEnabledOnPlatform != null) {
|
||||||
|
return mIsEnabledOnPlatform;
|
||||||
|
}
|
||||||
|
return super.isEnabledByPlatform(subId);
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
||||||
mIsProvisionedOnDevice = isProvisioned;
|
mIsProvisionedOnDevice = isProvisioned;
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,8 @@ public class WifiCallingSettingsTest {
|
|||||||
doReturn(true).when(mQueryImsState2).isEnabledByUser();
|
doReturn(true).when(mQueryImsState2).isEnabledByUser();
|
||||||
doReturn(mImsManager).when(mQueryImsState1).getImsManager(anyInt());
|
doReturn(mImsManager).when(mQueryImsState1).getImsManager(anyInt());
|
||||||
doReturn(mImsManager).when(mQueryImsState2).getImsManager(anyInt());
|
doReturn(mImsManager).when(mQueryImsState2).getImsManager(anyInt());
|
||||||
doReturn(true).when(mImsManager).isWfcEnabledByPlatform();
|
mQueryImsState1.setIsEnabledByPlatform(true);
|
||||||
|
mQueryImsState2.setIsEnabledByPlatform(true);
|
||||||
mQueryImsState1.setIsProvisionedOnDevice(true);
|
mQueryImsState1.setIsProvisionedOnDevice(true);
|
||||||
mQueryImsState2.setIsProvisionedOnDevice(true);
|
mQueryImsState2.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ public class WifiCallingSettingsTest {
|
|||||||
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
||||||
Collections.singletonList(info)));
|
Collections.singletonList(info)));
|
||||||
doReturn(true).when(mImsManager).isWfcEnabledByPlatform();
|
mQueryImsState1.setIsEnabledByPlatform(true);
|
||||||
mQueryImsState1.setIsProvisionedOnDevice(true);
|
mQueryImsState1.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
|
Reference in New Issue
Block a user