[Settings] Remove WFC enabled state condition of querying Telecomm.
- Query WFC enabled state by querying Telecomm may have problem. - Only use ImsMmTelManager API to check WFC enabled state. Bug: 278108377 Test: atest passed Change-Id: I6d1122bcf66ed5cd274e99b7b4f13558ab922162
This commit is contained in:
@@ -940,28 +940,11 @@ public class MobileNetworkUtils {
|
|||||||
* Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
|
* Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
|
||||||
*/
|
*/
|
||||||
public static boolean isWifiCallingEnabled(Context context, int subId,
|
public static boolean isWifiCallingEnabled(Context context, int subId,
|
||||||
@Nullable WifiCallingQueryImsState queryImsState,
|
@Nullable WifiCallingQueryImsState queryImsState) {
|
||||||
@Nullable PhoneAccountHandle phoneAccountHandle) {
|
if (queryImsState == null) {
|
||||||
if (phoneAccountHandle == null){
|
queryImsState = new WifiCallingQueryImsState(context, subId);
|
||||||
phoneAccountHandle = context.getSystemService(TelecomManager.class)
|
|
||||||
.getSimCallManagerForSubscription(subId);
|
|
||||||
}
|
}
|
||||||
boolean isWifiCallingEnabled;
|
return queryImsState.isReadyToWifiCalling();
|
||||||
if (phoneAccountHandle != null) {
|
|
||||||
final Intent intent = buildPhoneAccountConfigureIntent(context, phoneAccountHandle);
|
|
||||||
if (intent == null) {
|
|
||||||
Log.d(TAG, "Can not get phoneAccount configure intent.");
|
|
||||||
isWifiCallingEnabled = false;
|
|
||||||
} else {
|
|
||||||
isWifiCallingEnabled = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (queryImsState == null) {
|
|
||||||
queryImsState = new WifiCallingQueryImsState(context, subId);
|
|
||||||
}
|
|
||||||
isWifiCallingEnabled = queryImsState.isReadyToWifiCalling();
|
|
||||||
}
|
|
||||||
return isWifiCallingEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,7 +22,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.PersistableBundle;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telecom.PhoneAccountHandle;
|
import android.telecom.PhoneAccountHandle;
|
||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
@@ -314,8 +313,7 @@ public class NetworkProviderWifiCallingGroup extends
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean shouldShowWifiCallingForSub(int subId) {
|
protected boolean shouldShowWifiCallingForSub(int subId) {
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)
|
if (SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId),
|
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId))) {
|
||||||
null)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -71,7 +71,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus(int subId) {
|
public int getAvailabilityStatus(int subId) {
|
||||||
return SubscriptionManager.isValidSubscriptionId(subId)
|
return SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null, null)
|
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null)
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
@@ -257,8 +257,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
for (SubscriptionInfo subInfo : subInfoList) {
|
for (SubscriptionInfo subInfo : subInfoList) {
|
||||||
int subId = subInfo.getSubscriptionId();
|
int subId = subInfo.getSubscriptionId();
|
||||||
try {
|
try {
|
||||||
if (MobileNetworkUtils.isWifiCallingEnabled(getContext(), subId,
|
if (MobileNetworkUtils.isWifiCallingEnabled(
|
||||||
queryImsState(subId), null)) {
|
getContext(),
|
||||||
|
subId,
|
||||||
|
queryImsState(subId))) {
|
||||||
selectedList.add(subInfo);
|
selectedList.add(subInfo);
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {}
|
} catch (Exception exception) {}
|
||||||
|
@@ -385,35 +385,19 @@ public class MobileNetworkUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isWifiCallingEnabled_hasPhoneAccountHandleAndHasActivityHandleIntent_returnTrue() {
|
public void isWifiCallingEnabled_wifiCallingIsReady_returnTrue() {
|
||||||
buildPhoneAccountConfigureIntent(true);
|
|
||||||
|
|
||||||
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
|
||||||
null, mPhoneAccountHandle));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isWifiCallingEnabled_hasPhoneAccountHandleAndNoActivityHandleIntent_returnFalse() {
|
|
||||||
buildPhoneAccountConfigureIntent(false);
|
|
||||||
|
|
||||||
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
|
||||||
null, mPhoneAccountHandle));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isWifiCallingEnabled_noPhoneAccountHandleAndWifiCallingIsReady_returnTrue() {
|
|
||||||
setWifiCallingEnabled(true);
|
setWifiCallingEnabled(true);
|
||||||
|
|
||||||
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
||||||
mMockQueryWfcState, null));
|
mMockQueryWfcState));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isWifiCallingEnabled_noPhoneAccountHandleAndWifiCallingNotReady_returnFalse() {
|
public void isWifiCallingEnabled_wifiCallingNotReady_returnFalse() {
|
||||||
setWifiCallingEnabled(false);
|
setWifiCallingEnabled(false);
|
||||||
|
|
||||||
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
||||||
mMockQueryWfcState, null));
|
mMockQueryWfcState));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWifiCallingEnabled(boolean enabled){
|
private void setWifiCallingEnabled(boolean enabled){
|
||||||
|
Reference in New Issue
Block a user