[Settings] Refactor of Wifi Calling part
Refactor of Wifi Calling to avoid accessing hidden APIs. This includes the following cherry-picks on the corresponding files: I455685eb26df69d929ff3ed3c26ce84aa5f6b1f8 I1a67db80b114a438afda7d45af90e54af38703c3 Idd4935a6d8ceed77c15e90f96781014d1940a427 Ia5179ee1a23f054899bc74c796542bae40cdc8d5 I57c91a095fc4d454d92e8d78e0b647b4f098c6a3 I8a09264f83b9fc4fce3f79ec3aeb6ae757b004e4 I68462368669b81e10d09bbb93e74e23ea9a1f446 I9c54eb63a0df3fde38965ee7e2ae46cc1b7efd47 I0d5dcfc33b0bddacf059d1fb9af559646e32e68a I45977c850977be84c0dc1f6461e68a1941efc1a2 I46c047359257ddd5cb3e331add4856b01c5c9739 I35246811d3e01d0b2ca197e9a1ed7081691cd982 Bug: 140542283 Test: build pass Change-Id: I2cddeefb7cc5f1b2060e572a73560f7cd6204d0b
This commit is contained in:
@@ -34,8 +34,8 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
@@ -48,12 +48,12 @@ import java.util.List;
|
|||||||
public class WifiCallingPreferenceController extends TelephonyBasePreferenceController implements
|
public class WifiCallingPreferenceController extends TelephonyBasePreferenceController implements
|
||||||
LifecycleObserver, OnStart, OnStop {
|
LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
|
private static final String TAG = "WifiCallingPreference";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Integer mCallState;
|
Integer mCallState;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CarrierConfigManager mCarrierConfigManager;
|
CarrierConfigManager mCarrierConfigManager;
|
||||||
@VisibleForTesting
|
|
||||||
ImsManager mImsManager;
|
|
||||||
private ImsMmTelManager mImsMmTelManager;
|
private ImsMmTelManager mImsMmTelManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PhoneAccountHandle mSimCallManager;
|
PhoneAccountHandle mSimCallManager;
|
||||||
@@ -68,8 +68,8 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus(int subId) {
|
public int getAvailabilityStatus(int subId) {
|
||||||
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
return SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId)
|
&& isWifiCallingEnabled(mContext, subId)
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
@@ -100,6 +100,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
if (mCallState == null) {
|
if (mCallState == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CharSequence summaryText = null;
|
||||||
if (mSimCallManager != null) {
|
if (mSimCallManager != null) {
|
||||||
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
||||||
mSimCallManager);
|
mSimCallManager);
|
||||||
@@ -110,53 +111,55 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
final PackageManager pm = mContext.getPackageManager();
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
final List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
|
final List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
|
||||||
preference.setTitle(resolutions.get(0).loadLabel(pm));
|
preference.setTitle(resolutions.get(0).loadLabel(pm));
|
||||||
preference.setSummary(null);
|
|
||||||
preference.setIntent(intent);
|
preference.setIntent(intent);
|
||||||
} else {
|
} else {
|
||||||
final String title = SubscriptionManager.getResourcesForSubId(mContext, mSubId)
|
final String title = SubscriptionManager.getResourcesForSubId(mContext, mSubId)
|
||||||
.getString(R.string.wifi_calling_settings_title);
|
.getString(R.string.wifi_calling_settings_title);
|
||||||
preference.setTitle(title);
|
preference.setTitle(title);
|
||||||
int resId = com.android.internal.R.string.wifi_calling_off_summary;
|
summaryText = getResourceIdForWfcMode(mSubId);
|
||||||
if (mImsManager.isWfcEnabledByUser()) {
|
}
|
||||||
boolean useWfcHomeModeForRoaming = false;
|
preference.setSummary(summaryText);
|
||||||
if (mCarrierConfigManager != null) {
|
preference.setEnabled(mCallState == TelephonyManager.CALL_STATE_IDLE);
|
||||||
final PersistableBundle carrierConfig =
|
}
|
||||||
mCarrierConfigManager.getConfigForSubId(mSubId);
|
|
||||||
if (carrierConfig != null) {
|
private CharSequence getResourceIdForWfcMode(int subId) {
|
||||||
useWfcHomeModeForRoaming = carrierConfig.getBoolean(
|
int resId = com.android.internal.R.string.wifi_calling_off_summary;
|
||||||
CarrierConfigManager
|
if (queryImsState(subId).isEnabledByUser()) {
|
||||||
.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL);
|
boolean useWfcHomeModeForRoaming = false;
|
||||||
}
|
if (mCarrierConfigManager != null) {
|
||||||
}
|
final PersistableBundle carrierConfig =
|
||||||
final boolean isRoaming = getTelephonyManager(mContext, mSubId)
|
mCarrierConfigManager.getConfigForSubId(subId);
|
||||||
.isNetworkRoaming();
|
if (carrierConfig != null) {
|
||||||
final int wfcMode = (isRoaming && !useWfcHomeModeForRoaming)
|
useWfcHomeModeForRoaming = carrierConfig.getBoolean(
|
||||||
? mImsMmTelManager.getVoWiFiRoamingModeSetting() :
|
CarrierConfigManager
|
||||||
mImsMmTelManager.getVoWiFiModeSetting();
|
.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL);
|
||||||
switch (wfcMode) {
|
|
||||||
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
|
||||||
resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
|
|
||||||
break;
|
|
||||||
case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
|
|
||||||
resId = com.android.internal.R.string
|
|
||||||
.wfc_mode_cellular_preferred_summary;
|
|
||||||
break;
|
|
||||||
case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
|
|
||||||
resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preference.setSummary(
|
final boolean isRoaming = getTelephonyManager(mContext, subId)
|
||||||
SubscriptionManager.getResourcesForSubId(mContext, mSubId).getText(resId));
|
.isNetworkRoaming();
|
||||||
|
final int wfcMode = (isRoaming && !useWfcHomeModeForRoaming)
|
||||||
|
? mImsMmTelManager.getVoWiFiRoamingModeSetting() :
|
||||||
|
mImsMmTelManager.getVoWiFiModeSetting();
|
||||||
|
switch (wfcMode) {
|
||||||
|
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
||||||
|
resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
|
||||||
|
break;
|
||||||
|
case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
|
||||||
|
resId = com.android.internal.R.string
|
||||||
|
.wfc_mode_cellular_preferred_summary;
|
||||||
|
break;
|
||||||
|
case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
|
||||||
|
resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
preference.setEnabled(mCallState == TelephonyManager.CALL_STATE_IDLE);
|
return SubscriptionManager.getResourcesForSubId(mContext, subId).getText(resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiCallingPreferenceController init(int subId) {
|
public WifiCallingPreferenceController init(int subId) {
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
|
|
||||||
mImsMmTelManager = getImsMmTelManager(mSubId);
|
mImsMmTelManager = getImsMmTelManager(mSubId);
|
||||||
mSimCallManager = mContext.getSystemService(TelecomManager.class)
|
mSimCallManager = mContext.getSystemService(TelecomManager.class)
|
||||||
.getSimCallManagerForSubscription(mSubId);
|
.getSimCallManagerForSubscription(mSubId);
|
||||||
@@ -164,14 +167,22 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
|
return new WifiCallingQueryImsState(mContext, subId);
|
||||||
|
}
|
||||||
|
|
||||||
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
||||||
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return ImsMmTelManager.createForSubscriptionId(subId);
|
return ImsMmTelManager.createForSubscriptionId(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
TelephonyManager getTelephonyManager(Context context, int subId) {
|
TelephonyManager getTelephonyManager(Context context, int subId) {
|
||||||
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
|
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
|
||||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
return telephonyMgr;
|
return telephonyMgr;
|
||||||
}
|
}
|
||||||
final TelephonyManager subscriptionTelephonyMgr =
|
final TelephonyManager subscriptionTelephonyMgr =
|
||||||
@@ -204,4 +215,23 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
|
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isWifiCallingEnabled(Context context, int subId) {
|
||||||
|
final PhoneAccountHandle simCallManager =
|
||||||
|
context.getSystemService(TelecomManager.class)
|
||||||
|
.getSimCallManagerForSubscription(subId);
|
||||||
|
final int phoneId = SubscriptionManager.getSlotIndex(subId);
|
||||||
|
|
||||||
|
boolean isWifiCallingEnabled;
|
||||||
|
if (simCallManager != null) {
|
||||||
|
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
|
||||||
|
context, simCallManager);
|
||||||
|
|
||||||
|
isWifiCallingEnabled = intent != null;
|
||||||
|
} else {
|
||||||
|
isWifiCallingEnabled = queryImsState(subId).isReadyToWifiCalling();
|
||||||
|
}
|
||||||
|
|
||||||
|
return isWifiCallingEnabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
8
src/com/android/settings/wifi/calling/OWNERS
Normal file
8
src/com/android/settings/wifi/calling/OWNERS
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default reviewers for this and subdirectories.
|
||||||
|
allenwtsu@google.com
|
||||||
|
andychou@google.com
|
||||||
|
bonianchen@google.com
|
||||||
|
songferngwang@google.com
|
||||||
|
tomhsu@google.com
|
||||||
|
|
||||||
|
# Emergency approvers in case the above are not available
|
@@ -22,9 +22,6 @@ import android.os.Bundle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.ims.ProvisioningManager;
|
|
||||||
import android.telephony.ims.feature.MmTelFeature;
|
|
||||||
import android.telephony.ims.stub.ImsRegistrationImplBase;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -35,11 +32,11 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.internal.util.CollectionUtils;
|
import com.android.internal.util.CollectionUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
import com.android.settings.search.actionbar.SearchMenuController;
|
||||||
import com.android.settings.support.actionbar.HelpMenuController;
|
import com.android.settings.support.actionbar.HelpMenuController;
|
||||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||||
@@ -196,25 +193,6 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
boolean isWfcEnabledByPlatform(SubscriptionInfo info) {
|
|
||||||
final ImsManager imsManager = ImsManager.getInstance(getActivity(),
|
|
||||||
info.getSimSlotIndex());
|
|
||||||
return imsManager.isWfcEnabledByPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
boolean isWfcProvisionedOnDevice(SubscriptionInfo info) {
|
|
||||||
final ProvisioningManager provisioningMgr =
|
|
||||||
ProvisioningManager.createForSubscriptionId(info.getSubscriptionId());
|
|
||||||
if (provisioningMgr == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return provisioningMgr.getProvisioningStatusForCapability(
|
|
||||||
MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
|
|
||||||
ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSubList() {
|
private void updateSubList() {
|
||||||
mSil = SubscriptionUtil.getActiveSubscriptions(
|
mSil = SubscriptionUtil.getActiveSubscriptions(
|
||||||
getContext().getSystemService(SubscriptionManager.class));
|
getContext().getSystemService(SubscriptionManager.class));
|
||||||
@@ -225,7 +203,7 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < mSil.size(); ) {
|
for (int i = 0; i < mSil.size(); ) {
|
||||||
final SubscriptionInfo info = mSil.get(i);
|
final SubscriptionInfo info = mSil.get(i);
|
||||||
if (!isWfcEnabledByPlatform(info) || !isWfcProvisionedOnDevice(info)) {
|
if (!queryImsState(info.getSubscriptionId()).isWifiCallingProvisioned()) {
|
||||||
mSil.remove(i);
|
mSil.remove(i);
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
@@ -241,4 +219,9 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
getActivity().getActionBar().setTitle(title);
|
getActivity().getActionBar().setTitle(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
|
return new WifiCallingQueryImsState(getContext(), subId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,10 +30,10 @@ import android.telephony.CarrierConfigManager;
|
|||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.telephony.ims.ImsManager;
|
||||||
import android.telephony.ims.ImsMmTelManager;
|
import android.telephony.ims.ImsMmTelManager;
|
||||||
import android.telephony.ims.ProvisioningManager;
|
import android.telephony.ims.ProvisioningManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -47,8 +47,6 @@ import androidx.preference.Preference.OnPreferenceClickListener;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.ims.ImsConfig;
|
import com.android.ims.ImsConfig;
|
||||||
import com.android.ims.ImsException;
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.telephony.Phone;
|
import com.android.internal.telephony.Phone;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -56,7 +54,7 @@ import com.android.settings.SettingsActivity;
|
|||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.widget.SwitchBar;
|
import com.android.settings.widget.SwitchBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +98,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
private boolean mUseWfcHomeModeForRoaming = false;
|
private boolean mUseWfcHomeModeForRoaming = false;
|
||||||
|
|
||||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private ImsManager mImsManager;
|
|
||||||
private ImsMmTelManager mImsMmTelManager;
|
private ImsMmTelManager mImsMmTelManager;
|
||||||
|
private ProvisioningManager mProvisioningManager;
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
|
|
||||||
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||||
@@ -114,11 +112,13 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(int state, String incomingNumber) {
|
public void onCallStateChanged(int state, String incomingNumber) {
|
||||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
|
final boolean isNonTtyOrTtyOnVolteEnabled =
|
||||||
|
queryImsState(WifiCallingSettingsForSub.this.mSubId).isAllowUserControl();
|
||||||
final boolean isWfcEnabled = mSwitchBar.isChecked()
|
final boolean isWfcEnabled = mSwitchBar.isChecked()
|
||||||
&& isNonTtyOrTtyOnVolteEnabled;
|
&& isNonTtyOrTtyOnVolteEnabled;
|
||||||
boolean isCallStateIdle =
|
boolean isCallStateIdle = getTelephonyManagerForSub(
|
||||||
mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
WifiCallingSettingsForSub.this.mSubId).getCallState()
|
||||||
|
== TelephonyManager.CALL_STATE_IDLE;
|
||||||
mSwitchBar.setEnabled(isCallStateIdle
|
mSwitchBar.setEnabled(isCallStateIdle
|
||||||
&& isNonTtyOrTtyOnVolteEnabled);
|
&& isNonTtyOrTtyOnVolteEnabled);
|
||||||
|
|
||||||
@@ -183,7 +183,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
mEmptyView = getView().findViewById(android.R.id.empty);
|
mEmptyView = getView().findViewById(android.R.id.empty);
|
||||||
setEmptyView(mEmptyView);
|
setEmptyView(mEmptyView);
|
||||||
mEmptyView.setAutoLinkMask(Linkify.WEB_URLS);
|
|
||||||
final Resources res = getResourcesForSubId();
|
final Resources res = getResourcesForSubId();
|
||||||
final String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
|
final String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
|
||||||
res.getString(R.string.wifi_calling_off_explanation_2));
|
res.getString(R.string.wifi_calling_off_explanation_2));
|
||||||
@@ -200,7 +199,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
mSwitchBar.hide();
|
mSwitchBar.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAlert(Intent intent) {
|
@VisibleForTesting
|
||||||
|
void showAlert(Intent intent) {
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
|
||||||
final CharSequence title = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_TITLE);
|
final CharSequence title = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_TITLE);
|
||||||
@@ -221,7 +221,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (action.equals(ImsManager.ACTION_IMS_REGISTRATION_ERROR)) {
|
if (action.equals(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR)) {
|
||||||
// If this fragment is active then we are immediately
|
// If this fragment is active then we are immediately
|
||||||
// showing alert on screen. There is no need to add
|
// showing alert on screen. There is no need to add
|
||||||
// notification in this case.
|
// notification in this case.
|
||||||
@@ -247,12 +247,31 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsManager getImsManager() {
|
TelephonyManager getTelephonyManagerForSub(int subId) {
|
||||||
return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId));
|
if (mTelephonyManager == null) {
|
||||||
|
mTelephonyManager = getContext().getSystemService(TelephonyManager.class);
|
||||||
|
}
|
||||||
|
return mTelephonyManager.createForSubscriptionId(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
|
return new WifiCallingQueryImsState(getContext(), subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ProvisioningManager getImsProvisioningManager() {
|
||||||
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ProvisioningManager.createForSubscriptionId(mSubId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsMmTelManager getImsMmTelManager() {
|
ImsMmTelManager getImsMmTelManager() {
|
||||||
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return ImsMmTelManager.createForSubscriptionId(mSubId);
|
return ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,11 +290,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
mImsManager = getImsManager();
|
mProvisioningManager = getImsProvisioningManager();
|
||||||
mImsMmTelManager = getImsMmTelManager();
|
mImsMmTelManager = getImsMmTelManager();
|
||||||
|
|
||||||
mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE));
|
|
||||||
|
|
||||||
mButtonWfcMode = findPreference(BUTTON_WFC_MODE);
|
mButtonWfcMode = findPreference(BUTTON_WFC_MODE);
|
||||||
mButtonWfcMode.setOnPreferenceChangeListener(this);
|
mButtonWfcMode.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
@@ -286,7 +303,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
|
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
|
||||||
|
|
||||||
mIntentFilter = new IntentFilter();
|
mIntentFilter = new IntentFilter();
|
||||||
mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
|
mIntentFilter.addAction(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -312,7 +329,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean isWfcProvisionedOnDevice() {
|
boolean isWfcProvisionedOnDevice() {
|
||||||
return MobileNetworkUtils.isWfcProvisionedOnDevice(mSubId);
|
return queryImsState(mSubId).isWifiCallingProvisioned();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBody() {
|
private void updateBody() {
|
||||||
@@ -342,7 +359,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Resources res = getResourcesForSubId();
|
final Resources res = getResourcesForSubId();
|
||||||
mButtonWfcMode.setTitle(res.getString(R.string.wifi_calling_mode_title));
|
mButtonWfcMode.setTitle(res.getString(R.string.wifi_calling_mode_title));
|
||||||
mButtonWfcMode.setDialogTitle(res.getString(R.string.wifi_calling_mode_dialog_title));
|
mButtonWfcMode.setDialogTitle(res.getString(R.string.wifi_calling_mode_dialog_title));
|
||||||
mButtonWfcRoamingMode.setTitle(res.getString(R.string.wifi_calling_roaming_mode_title));
|
mButtonWfcRoamingMode.setTitle(res.getString(R.string.wifi_calling_roaming_mode_title));
|
||||||
@@ -383,8 +400,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
|
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
|
||||||
final boolean wfcEnabled = mImsManager.isWfcEnabledByUser()
|
final WifiCallingQueryImsState queryIms = queryImsState(mSubId);
|
||||||
&& mImsManager.isNonTtyOrTtyOnVolteEnabled();
|
final boolean wfcEnabled = queryIms.isEnabledByUser()
|
||||||
|
&& queryIms.isAllowUserControl();
|
||||||
mSwitch.setChecked(wfcEnabled);
|
mSwitch.setChecked(wfcEnabled);
|
||||||
final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
|
final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
|
||||||
final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
|
final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
|
||||||
@@ -397,18 +415,18 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
final Context context = getActivity();
|
|
||||||
|
|
||||||
updateBody();
|
updateBody();
|
||||||
|
|
||||||
if (mImsManager.isWfcEnabledByPlatform()) {
|
if (queryImsState(mSubId).isWifiCallingSupported()) {
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
|
getTelephonyManagerForSub(mSubId).listen(mPhoneStateListener,
|
||||||
|
PhoneStateListener.LISTEN_CALL_STATE);
|
||||||
|
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
|
|
||||||
mValidListener = true;
|
mValidListener = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Context context = getActivity();
|
||||||
context.registerReceiver(mIntentReceiver, mIntentFilter);
|
context.registerReceiver(mIntentReceiver, mIntentFilter);
|
||||||
|
|
||||||
final Intent intent = getActivity().getIntent();
|
final Intent intent = getActivity().getIntent();
|
||||||
@@ -417,12 +435,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register callback for provisioning changes.
|
// Register callback for provisioning changes.
|
||||||
try {
|
registerProvisioningChangedCallback();
|
||||||
mImsManager.getConfigInterface().addConfigCallback(mProvisioningCallback);
|
|
||||||
} catch (ImsException e) {
|
|
||||||
Log.w(TAG, "onResume: Unable to register callback for provisioning changes.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -434,7 +447,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
if (mValidListener) {
|
if (mValidListener) {
|
||||||
mValidListener = false;
|
mValidListener = false;
|
||||||
|
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
getTelephonyManagerForSub(mSubId).listen(mPhoneStateListener,
|
||||||
|
PhoneStateListener.LISTEN_NONE);
|
||||||
|
|
||||||
mSwitchBar.removeOnSwitchChangeListener(this);
|
mSwitchBar.removeOnSwitchChangeListener(this);
|
||||||
}
|
}
|
||||||
@@ -442,13 +456,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
context.unregisterReceiver(mIntentReceiver);
|
context.unregisterReceiver(mIntentReceiver);
|
||||||
|
|
||||||
// Remove callback for provisioning changes.
|
// Remove callback for provisioning changes.
|
||||||
try {
|
unregisterProvisioningChangedCallback();
|
||||||
mImsManager.getConfigInterface().removeConfigCallback(
|
|
||||||
mProvisioningCallback.getBinder());
|
|
||||||
} catch (ImsException e) {
|
|
||||||
Log.w(TAG, "onPause: Unable to remove callback for provisioning changes");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -508,7 +516,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
*/
|
*/
|
||||||
private void updateWfcMode(boolean wfcEnabled) {
|
private void updateWfcMode(boolean wfcEnabled) {
|
||||||
Log.i(TAG, "updateWfcMode(" + wfcEnabled + ")");
|
Log.i(TAG, "updateWfcMode(" + wfcEnabled + ")");
|
||||||
mImsManager.setWfcSetting(wfcEnabled);
|
mImsMmTelManager.setVoWiFiSettingEnabled(wfcEnabled);
|
||||||
|
|
||||||
final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
|
final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
|
||||||
final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
|
final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
|
||||||
@@ -524,8 +532,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
final Context context = getActivity();
|
|
||||||
|
|
||||||
Log.d(TAG, "WFC activity request = " + requestCode + " result = " + resultCode);
|
Log.d(TAG, "WFC activity request = " + requestCode + " result = " + resultCode);
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
@@ -619,7 +625,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private CharSequence getWfcModeSummary(int wfcMode) {
|
private CharSequence getWfcModeSummary(int wfcMode) {
|
||||||
int resId = com.android.internal.R.string.wifi_calling_off_summary;
|
int resId = com.android.internal.R.string.wifi_calling_off_summary;
|
||||||
if (mImsManager.isWfcEnabledByUser()) {
|
if (queryImsState(mSubId).isEnabledByUser()) {
|
||||||
switch (wfcMode) {
|
switch (wfcMode) {
|
||||||
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
||||||
resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
|
resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
|
||||||
@@ -639,6 +645,27 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Resources getResourcesForSubId() {
|
Resources getResourcesForSubId() {
|
||||||
return SubscriptionManager.getResourcesForSubId(getContext(), mSubId, false);
|
return SubscriptionManager.getResourcesForSubId(getContext(), mSubId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void registerProvisioningChangedCallback() {
|
||||||
|
if (mProvisioningManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mProvisioningManager.registerProvisioningChangedCallback(getContext().getMainExecutor(),
|
||||||
|
mProvisioningCallback);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.w(TAG, "onResume: Unable to register callback for provisioning changes.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void unregisterProvisioningChangedCallback() {
|
||||||
|
if (mProvisioningManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mProvisioningManager.unregisterProvisioningChangedCallback(mProvisioningCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,10 +43,9 @@ import androidx.slice.builders.ListBuilder.RowBuilder;
|
|||||||
import androidx.slice.builders.SliceAction;
|
import androidx.slice.builders.SliceAction;
|
||||||
|
|
||||||
import com.android.ims.ImsConfig;
|
import com.android.ims.ImsConfig;
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -132,57 +131,39 @@ public class WifiCallingSliceHelper {
|
|||||||
*/
|
*/
|
||||||
public Slice createWifiCallingSlice(Uri sliceUri) {
|
public Slice createWifiCallingSlice(Uri sliceUri) {
|
||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
Resources res = getResourcesForSubId(subId);
|
|
||||||
|
|
||||||
if (subId <= SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
Log.d(TAG, "Invalid subscription Id");
|
Log.d(TAG, "Invalid subscription Id");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ImsManager imsManager = getImsManager(subId);
|
if (!queryImsState(subId).isWifiCallingProvisioned()) {
|
||||||
|
|
||||||
if (!imsManager.isWfcEnabledByPlatform()
|
|
||||||
|| !isWfcProvisionedOnDevice(subId)) {
|
|
||||||
Log.d(TAG, "Wifi calling is either not provisioned or not enabled by Platform");
|
Log.d(TAG, "Wifi calling is either not provisioned or not enabled by Platform");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
final boolean isWifiCallingEnabled = isWifiCallingEnabled();
|
||||||
final boolean isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
|
final Intent activationAppIntent =
|
||||||
final Intent activationAppIntent =
|
getWifiCallingCarrierActivityIntent(subId);
|
||||||
getWifiCallingCarrierActivityIntent(subId);
|
|
||||||
|
|
||||||
// Send this actionable wifi calling slice to toggle the setting
|
// Send this actionable wifi calling slice to toggle the setting
|
||||||
// only when there is no need for wifi calling activation with the server
|
// only when there is no need for wifi calling activation with the server
|
||||||
if (activationAppIntent != null && !isWifiCallingEnabled) {
|
if (activationAppIntent != null && !isWifiCallingEnabled) {
|
||||||
Log.d(TAG, "Needs Activation");
|
Log.d(TAG, "Needs Activation");
|
||||||
// Activation needed for the next action of the user
|
// Activation needed for the next action of the user
|
||||||
// Give instructions to go to settings app
|
// Give instructions to go to settings app
|
||||||
return getNonActionableWifiCallingSlice(
|
final Resources res = getResourcesForSubId(subId);
|
||||||
res.getText(R.string.wifi_calling_settings_title),
|
return getNonActionableWifiCallingSlice(
|
||||||
res.getText(R.string.wifi_calling_settings_activation_instructions),
|
res.getText(R.string.wifi_calling_settings_title),
|
||||||
sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
|
res.getText(R.string.wifi_calling_settings_activation_instructions),
|
||||||
}
|
sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
|
||||||
return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId);
|
|
||||||
} catch (InterruptedException | TimeoutException | ExecutionException e) {
|
|
||||||
Log.e(TAG, "Unable to read the current WiFi calling status", e);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWifiCallingEnabled(ImsManager imsManager)
|
private boolean isWifiCallingEnabled() {
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
final WifiCallingQueryImsState queryState = queryImsState(getDefaultVoiceSubId());
|
||||||
final FutureTask<Boolean> isWifiOnTask = new FutureTask<>(new Callable<Boolean>() {
|
return queryState.isEnabledByUser() && queryState.isAllowUserControl();
|
||||||
@Override
|
|
||||||
public Boolean call() {
|
|
||||||
return imsManager.isWfcEnabledByUser();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
||||||
executor.execute(isWifiOnTask);
|
|
||||||
|
|
||||||
return isWifiOnTask.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
|
|
||||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +172,7 @@ public class WifiCallingSliceHelper {
|
|||||||
*/
|
*/
|
||||||
private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
|
private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
|
||||||
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
|
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
|
||||||
Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
|
|
||||||
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
|
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
|
||||||
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
|
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
|
||||||
@@ -227,7 +208,7 @@ public class WifiCallingSliceHelper {
|
|||||||
public Slice createWifiCallingPreferenceSlice(Uri sliceUri) {
|
public Slice createWifiCallingPreferenceSlice(Uri sliceUri) {
|
||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
|
|
||||||
if (subId <= SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
Log.d(TAG, "Invalid Subscription Id");
|
Log.d(TAG, "Invalid Subscription Id");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -236,24 +217,22 @@ public class WifiCallingSliceHelper {
|
|||||||
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
|
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
|
||||||
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
|
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
|
||||||
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
|
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
|
||||||
final ImsManager imsManager = getImsManager(subId);
|
|
||||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
|
||||||
|
|
||||||
if (!imsManager.isWfcEnabledByPlatform()
|
|
||||||
|| !isWfcProvisionedOnDevice(subId)) {
|
|
||||||
Log.d(TAG, "Wifi calling is either not provisioned or not enabled by platform");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isWifiCallingPrefEditable) {
|
if (!isWifiCallingPrefEditable) {
|
||||||
Log.d(TAG, "Wifi calling preference is not editable");
|
Log.d(TAG, "Wifi calling preference is not editable");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!queryImsState(subId).isWifiCallingProvisioned()) {
|
||||||
|
Log.d(TAG, "Wifi calling is either not provisioned or not enabled by platform");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isWifiCallingEnabled = false;
|
boolean isWifiCallingEnabled = false;
|
||||||
int wfcMode = -1;
|
int wfcMode = -1;
|
||||||
try {
|
try {
|
||||||
isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
|
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||||
|
isWifiCallingEnabled = isWifiCallingEnabled();
|
||||||
wfcMode = getWfcMode(imsMmTelManager);
|
wfcMode = getWfcMode(imsMmTelManager);
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
Log.e(TAG, "Unable to get wifi calling preferred mode", e);
|
Log.e(TAG, "Unable to get wifi calling preferred mode", e);
|
||||||
@@ -261,7 +240,7 @@ public class WifiCallingSliceHelper {
|
|||||||
}
|
}
|
||||||
if (!isWifiCallingEnabled) {
|
if (!isWifiCallingEnabled) {
|
||||||
// wifi calling is not enabled. Ask user to enable wifi calling
|
// wifi calling is not enabled. Ask user to enable wifi calling
|
||||||
Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
return getNonActionableWifiCallingSlice(
|
return getNonActionableWifiCallingSlice(
|
||||||
res.getText(R.string.wifi_calling_mode_title),
|
res.getText(R.string.wifi_calling_mode_title),
|
||||||
res.getText(R.string.wifi_calling_turn_on),
|
res.getText(R.string.wifi_calling_turn_on),
|
||||||
@@ -286,7 +265,7 @@ public class WifiCallingSliceHelper {
|
|||||||
Uri sliceUri,
|
Uri sliceUri,
|
||||||
int subId) {
|
int subId) {
|
||||||
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
|
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
|
||||||
Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
// Top row shows information on current preference state
|
// Top row shows information on current preference state
|
||||||
final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
|
final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
|
||||||
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
|
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
|
||||||
@@ -332,7 +311,7 @@ public class WifiCallingSliceHelper {
|
|||||||
int preferenceTitleResId, String action, boolean checked, int subId) {
|
int preferenceTitleResId, String action, boolean checked, int subId) {
|
||||||
final IconCompat icon =
|
final IconCompat icon =
|
||||||
IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
|
IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
|
||||||
Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
return new RowBuilder()
|
return new RowBuilder()
|
||||||
.setTitle(res.getText(preferenceTitleResId))
|
.setTitle(res.getText(preferenceTitleResId))
|
||||||
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
|
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
|
||||||
@@ -347,7 +326,7 @@ public class WifiCallingSliceHelper {
|
|||||||
* @return summary/name of the wifi calling preference
|
* @return summary/name of the wifi calling preference
|
||||||
*/
|
*/
|
||||||
private CharSequence getWifiCallingPreferenceSummary(int wfcMode, int subId) {
|
private CharSequence getWifiCallingPreferenceSummary(int wfcMode, int subId) {
|
||||||
Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
switch (wfcMode) {
|
switch (wfcMode) {
|
||||||
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
|
||||||
return res.getText(
|
return res.getText(
|
||||||
@@ -363,10 +342,6 @@ public class WifiCallingSliceHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ImsManager getImsManager(int subId) {
|
|
||||||
return ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
||||||
return ImsMmTelManager.createForSubscriptionId(subId);
|
return ImsMmTelManager.createForSubscriptionId(subId);
|
||||||
}
|
}
|
||||||
@@ -393,12 +368,11 @@ public class WifiCallingSliceHelper {
|
|||||||
public void handleWifiCallingChanged(Intent intent) {
|
public void handleWifiCallingChanged(Intent intent) {
|
||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
|
|
||||||
if (subId > SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
final ImsManager imsManager = getImsManager(subId);
|
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
||||||
if (imsManager.isWfcEnabledByPlatform()
|
if (queryState.isWifiCallingProvisioned()) {
|
||||||
&& isWfcProvisionedOnDevice(subId)) {
|
final boolean currentValue = queryState.isEnabledByUser()
|
||||||
final boolean currentValue = imsManager.isWfcEnabledByUser()
|
&& queryState.isAllowUserControl();
|
||||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled();
|
|
||||||
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||||
currentValue);
|
currentValue);
|
||||||
final Intent activationAppIntent =
|
final Intent activationAppIntent =
|
||||||
@@ -407,7 +381,8 @@ public class WifiCallingSliceHelper {
|
|||||||
// If either the action is to turn off wifi calling setting
|
// If either the action is to turn off wifi calling setting
|
||||||
// or there is no activation involved - Update the setting
|
// or there is no activation involved - Update the setting
|
||||||
if (newValue != currentValue) {
|
if (newValue != currentValue) {
|
||||||
imsManager.setWfcSetting(newValue);
|
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||||
|
imsMmTelManager.setVoWiFiSettingEnabled(newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,18 +405,17 @@ public class WifiCallingSliceHelper {
|
|||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
final int errorValue = -1;
|
final int errorValue = -1;
|
||||||
|
|
||||||
if (subId > SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
final boolean isWifiCallingPrefEditable = isCarrierConfigManagerKeyEnabled(
|
final boolean isWifiCallingPrefEditable = isCarrierConfigManagerKeyEnabled(
|
||||||
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
|
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
|
||||||
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
|
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
|
||||||
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
|
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
|
||||||
|
|
||||||
final ImsManager imsManager = getImsManager(subId);
|
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
||||||
if (isWifiCallingPrefEditable
|
if (isWifiCallingPrefEditable
|
||||||
&& imsManager.isWfcEnabledByPlatform()
|
&& queryState.isWifiCallingProvisioned()
|
||||||
&& isWfcProvisionedOnDevice(subId)
|
&& queryState.isEnabledByUser()
|
||||||
&& imsManager.isWfcEnabledByUser()
|
&& queryState.isAllowUserControl()) {
|
||||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled()) {
|
|
||||||
// Change the preference only when wifi calling is enabled
|
// Change the preference only when wifi calling is enabled
|
||||||
// And when wifi calling preference is editable for the current carrier
|
// And when wifi calling preference is editable for the current carrier
|
||||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||||
@@ -522,11 +496,6 @@ public class WifiCallingSliceHelper {
|
|||||||
return SubscriptionManager.getDefaultVoiceSubscriptionId();
|
return SubscriptionManager.getDefaultVoiceSubscriptionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
boolean isWfcProvisionedOnDevice(int subId) {
|
|
||||||
return MobileNetworkUtils.isWfcProvisionedOnDevice(subId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Intent of the activation app required to activate wifi calling or null if there is no
|
* Returns Intent of the activation app required to activate wifi calling or null if there is no
|
||||||
* need for activation.
|
* need for activation.
|
||||||
@@ -586,4 +555,9 @@ public class WifiCallingSliceHelper {
|
|||||||
private Resources getResourcesForSubId(int subId) {
|
private Resources getResourcesForSubId(int subId) {
|
||||||
return SubscriptionManager.getResourcesForSubId(mContext, subId);
|
return SubscriptionManager.getResourcesForSubId(mContext, subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
|
return new WifiCallingQueryImsState(mContext, subId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,19 +19,16 @@ package com.android.settings.wifi.calling;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
|
|
||||||
public class WifiCallingSuggestionActivity extends SettingsActivity {
|
public class WifiCallingSuggestionActivity extends SettingsActivity {
|
||||||
|
|
||||||
public static boolean isSuggestionComplete(Context context) {
|
public static boolean isSuggestionComplete(Context context) {
|
||||||
if (!ImsManager.isWfcEnabledByPlatform(context) ||
|
final WifiCallingQueryImsState queryState =
|
||||||
!MobileNetworkUtils.isWfcProvisionedOnDevice(
|
new WifiCallingQueryImsState(context,
|
||||||
SubscriptionManager.getDefaultVoiceSubscriptionId())) {
|
SubscriptionManager.getDefaultVoiceSubscriptionId());
|
||||||
return true;
|
return (!queryState.isWifiCallingProvisioned())
|
||||||
}
|
|| (queryState.isEnabledByUser() && queryState.isAllowUserControl());
|
||||||
return ImsManager.isWfcEnabledByUser(context)
|
|
||||||
&& ImsManager.isNonTtyOrTtyOnVolteEnabled(context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,8 @@ package com.android.settings.network.telephony;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -35,11 +37,12 @@ import android.telephony.ims.ImsMmTelManager;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.network.ims.MockWifiCallingQueryImsState;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -56,12 +59,12 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
@Mock
|
@Mock
|
||||||
private ImsManager mImsManager;
|
|
||||||
@Mock
|
|
||||||
private ImsMmTelManager mImsMmTelManager;
|
private ImsMmTelManager mImsMmTelManager;
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
|
|
||||||
|
private MockWifiCallingQueryImsState mQueryImsState;
|
||||||
|
|
||||||
private WifiCallingPreferenceController mController;
|
private WifiCallingPreferenceController mController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -73,6 +76,10 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
|
mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
|
||||||
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
||||||
mController = spy(new WifiCallingPreferenceController(mContext, "wifi_calling") {
|
mController = spy(new WifiCallingPreferenceController(mContext, "wifi_calling") {
|
||||||
@Override
|
@Override
|
||||||
@@ -82,8 +89,8 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
});
|
});
|
||||||
mController.mCarrierConfigManager = mCarrierConfigManager;
|
mController.mCarrierConfigManager = mCarrierConfigManager;
|
||||||
mController.init(SUB_ID);
|
mController.init(SUB_ID);
|
||||||
mController.mImsManager = mImsManager;
|
|
||||||
mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
|
mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
|
||||||
|
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
|
||||||
mPreference.setKey(mController.getPreferenceKey());
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
|
|
||||||
when(mController.getTelephonyManager(mContext, SUB_ID)).thenReturn(mTelephonyManager);
|
when(mController.getTelephonyManager(mContext, SUB_ID)).thenReturn(mTelephonyManager);
|
||||||
@@ -98,7 +105,7 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_noSimCallManager_setCorrectSummary() {
|
public void updateState_noSimCallManager_setCorrectSummary() {
|
||||||
mController.mSimCallManager = null;
|
mController.mSimCallManager = null;
|
||||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_WIFI_ONLY);
|
ImsMmTelManager.WIFI_MODE_WIFI_ONLY);
|
||||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
@@ -128,18 +135,17 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_nonRoaming_wfcCellularPreferred() {
|
public void updateState_wfcNonRoamingByConfig() {
|
||||||
assertNull(mController.mSimCallManager);
|
assertNull(mController.mSimCallManager);
|
||||||
mCarrierConfig.putBoolean(
|
mCarrierConfig.putBoolean(
|
||||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
|
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
|
||||||
mController.init(SUB_ID);
|
mController.init(SUB_ID);
|
||||||
mController.mImsManager = mImsManager;
|
|
||||||
|
|
||||||
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
||||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
@@ -148,7 +154,7 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_roaming_wfcWifiPreferred() {
|
public void updateState_wfcRoamingByConfig() {
|
||||||
assertNull(mController.mSimCallManager);
|
assertNull(mController.mSimCallManager);
|
||||||
// useWfcHomeModeForRoaming is false by default. In order to check wfc in roaming mode. We
|
// useWfcHomeModeForRoaming is false by default. In order to check wfc in roaming mode. We
|
||||||
// need the device roaming, and not using home mode in roaming network.
|
// need the device roaming, and not using home mode in roaming network.
|
||||||
@@ -156,7 +162,7 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
||||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
@@ -174,6 +180,7 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore
|
||||||
public void displayPreference_available_setsSubscriptionIdOnIntent() {
|
public void displayPreference_available_setsSubscriptionIdOnIntent() {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
mPreference.setIntent(intent);
|
mPreference.setIntent(intent);
|
||||||
|
@@ -32,6 +32,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.shadows.ShadowLooper;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class ListWithEntrySummaryPreferenceTest {
|
public class ListWithEntrySummaryPreferenceTest {
|
||||||
@@ -53,6 +54,7 @@ public class ListWithEntrySummaryPreferenceTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mContext.setTheme(R.style.Theme_Settings_Home);
|
mContext.setTheme(R.style.Theme_Settings_Home);
|
||||||
|
ShadowLooper.pauseMainLooper();
|
||||||
mPreference = new ListWithEntrySummaryPreference(mContext, null);
|
mPreference = new ListWithEntrySummaryPreference(mContext, null);
|
||||||
mPreference.setEntries(mDefaultEntries);
|
mPreference.setEntries(mDefaultEntries);
|
||||||
mPreference.setEntryValues(mDefaultEntryValues);
|
mPreference.setEntryValues(mDefaultEntryValues);
|
||||||
@@ -60,7 +62,7 @@ public class ListWithEntrySummaryPreferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void initialize_defaultEntries_shouldDisplayDefalutEntries() {
|
public void initialize_defaultEntries_shouldDisplayDefaultEntries() {
|
||||||
AlertDialog dialog = showDialog(mPreference);
|
AlertDialog dialog = showDialog(mPreference);
|
||||||
ListAdapter adapter = dialog.getListView().getAdapter();
|
ListAdapter adapter = dialog.getListView().getAdapter();
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ import static org.mockito.Matchers.anyInt;
|
|||||||
import static org.mockito.Matchers.anyObject;
|
import static org.mockito.Matchers.anyObject;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -41,9 +40,7 @@ import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.shadow.ShadowDisclaimerItemFactory;
|
import com.android.settings.testutils.shadow.ShadowDisclaimerItemFactory;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -52,12 +49,15 @@ import org.mockito.ArgumentCaptor;
|
|||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = ShadowDisclaimerItemFactory.class)
|
@Config(shadows = {ShadowDisclaimerItemFactory.class, ShadowFragment.class})
|
||||||
public class WifiCallingDisclaimerFragmentTest {
|
public class WifiCallingDisclaimerFragmentTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@@ -44,17 +44,16 @@ import android.os.PersistableBundle;
|
|||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.ims.ImsMmTelManager;
|
import android.telephony.ims.ImsMmTelManager;
|
||||||
import android.telephony.ims.ProvisioningManager;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.ims.ImsConfig;
|
|
||||||
import com.android.ims.ImsManager;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.network.ims.MockWifiCallingQueryImsState;
|
||||||
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||||
import com.android.settings.widget.SwitchBar;
|
import com.android.settings.widget.SwitchBar;
|
||||||
import com.android.settings.widget.ToggleSwitch;
|
import com.android.settings.widget.ToggleSwitch;
|
||||||
@@ -73,6 +72,8 @@ import org.robolectric.util.ReflectionHelpers;
|
|||||||
@Config(shadows = ShadowFragment.class)
|
@Config(shadows = ShadowFragment.class)
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class WifiCallingSettingsForSubTest {
|
public class WifiCallingSettingsForSubTest {
|
||||||
|
private static final int SUB_ID = 2;
|
||||||
|
|
||||||
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
||||||
private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode";
|
private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode";
|
||||||
private static final String TEST_EMERGENCY_ADDRESS_CARRIER_APP =
|
private static final String TEST_EMERGENCY_ADDRESS_CARRIER_APP =
|
||||||
@@ -83,9 +84,10 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
private TextView mEmptyView;
|
private TextView mEmptyView;
|
||||||
private final PersistableBundle mBundle = new PersistableBundle();
|
private final PersistableBundle mBundle = new PersistableBundle();
|
||||||
|
|
||||||
|
private MockWifiCallingQueryImsState mQueryImsState;
|
||||||
|
|
||||||
@Mock private static CarrierConfigManager sCarrierConfigManager;
|
@Mock private static CarrierConfigManager sCarrierConfigManager;
|
||||||
@Mock private CarrierConfigManager mMockConfigManager;
|
@Mock private CarrierConfigManager mMockConfigManager;
|
||||||
@Mock private ImsManager mImsManager;
|
|
||||||
@Mock private ImsMmTelManager mImsMmTelManager;
|
@Mock private ImsMmTelManager mImsMmTelManager;
|
||||||
@Mock private TelephonyManager mTelephonyManager;
|
@Mock private TelephonyManager mTelephonyManager;
|
||||||
@Mock private PreferenceScreen mPreferenceScreen;
|
@Mock private PreferenceScreen mPreferenceScreen;
|
||||||
@@ -93,7 +95,6 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
@Mock private SwitchBar mSwitchBar;
|
@Mock private SwitchBar mSwitchBar;
|
||||||
@Mock private ToggleSwitch mToggleSwitch;
|
@Mock private ToggleSwitch mToggleSwitch;
|
||||||
@Mock private View mView;
|
@Mock private View mView;
|
||||||
@Mock private ImsConfig mImsConfig;
|
|
||||||
@Mock private ListWithEntrySummaryPreference mButtonWfcMode;
|
@Mock private ListWithEntrySummaryPreference mButtonWfcMode;
|
||||||
@Mock private ListWithEntrySummaryPreference mButtonWfcRoamingMode;
|
@Mock private ListWithEntrySummaryPreference mButtonWfcRoamingMode;
|
||||||
@Mock private Preference mUpdateAddress;
|
@Mock private Preference mUpdateAddress;
|
||||||
@@ -127,12 +128,13 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
ReflectionHelpers.setField(mSwitchBar, "mSwitch", mToggleSwitch);
|
ReflectionHelpers.setField(mSwitchBar, "mSwitch", mToggleSwitch);
|
||||||
doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
|
doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
|
||||||
|
|
||||||
doReturn(mImsManager).when(mFragment).getImsManager();
|
mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
|
||||||
|
|
||||||
doReturn(mImsMmTelManager).when(mFragment).getImsMmTelManager();
|
doReturn(mImsMmTelManager).when(mFragment).getImsMmTelManager();
|
||||||
doReturn(mImsConfig).when(mImsManager).getConfigInterface();
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
doReturn(true).when(mFragment).isWfcProvisionedOnDevice();
|
mQueryImsState.setIsEnabledByPlatform(true);
|
||||||
doReturn(true).when(mImsManager).isWfcEnabledByUser();
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
doReturn(true).when(mImsManager).isNonTtyOrTtyOnVolteEnabled();
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||||
.when(mImsMmTelManager).getVoWiFiModeSetting();
|
.when(mImsMmTelManager).getVoWiFiModeSetting();
|
||||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||||
@@ -178,7 +180,7 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onResume_provisioningDisallowed_shouldFinish() {
|
public void onResume_provisioningDisallowed_shouldFinish() {
|
||||||
// Call onResume while provisioning is disallowed.
|
// Call onResume while provisioning is disallowed.
|
||||||
doReturn(false).when(mFragment).isWfcProvisionedOnDevice();
|
mQueryImsState.setIsProvisionedOnDevice(false);
|
||||||
mFragment.onResume();
|
mFragment.onResume();
|
||||||
|
|
||||||
// Verify that finish() is called
|
// Verify that finish() is called
|
||||||
@@ -189,11 +191,11 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
public void onResumeOnPause_provisioningCallbackRegistration() throws Exception {
|
public void onResumeOnPause_provisioningCallbackRegistration() throws Exception {
|
||||||
// Verify that provisioning callback is registered after call to onResume().
|
// Verify that provisioning callback is registered after call to onResume().
|
||||||
mFragment.onResume();
|
mFragment.onResume();
|
||||||
verify(mImsConfig).addConfigCallback(any(ProvisioningManager.Callback.class));
|
verify(mFragment).registerProvisioningChangedCallback();
|
||||||
|
|
||||||
// Verify that provisioning callback is unregistered after call to onPause.
|
// Verify that provisioning callback is unregistered after call to onPause.
|
||||||
mFragment.onPause();
|
mFragment.onPause();
|
||||||
verify(mImsConfig).removeConfigCallback(any());
|
verify(mFragment).unregisterProvisioningChangedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -327,7 +329,7 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
verify(mPreferenceScreen).addPreference(mButtonWfcRoamingMode);
|
verify(mPreferenceScreen).addPreference(mButtonWfcRoamingMode);
|
||||||
verify(mPreferenceScreen).addPreference(mUpdateAddress);
|
verify(mPreferenceScreen).addPreference(mUpdateAddress);
|
||||||
// Check the WFC enable request.
|
// Check the WFC enable request.
|
||||||
verify(mImsManager).setWfcSetting(true);
|
verify(mImsMmTelManager).setVoWiFiSettingEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -350,5 +352,18 @@ public class WifiCallingSettingsForSubTest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
TelephonyManager getTelephonyManagerForSub(int subId) {
|
||||||
|
return mTelephonyManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
|
return mQueryImsState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void showAlert(Intent intent) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,13 +18,12 @@ package com.android.settings.wifi.calling;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -32,14 +31,19 @@ import android.view.View;
|
|||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
import com.android.ims.ImsManager;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
import com.android.settings.network.ims.MockWifiCallingQueryImsState;
|
||||||
import com.android.settings.widget.RtlCompatibleViewPager;
|
import com.android.settings.widget.RtlCompatibleViewPager;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.shadows.androidx.fragment.FragmentController;
|
import org.robolectric.shadows.androidx.fragment.FragmentController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -48,12 +52,37 @@ import java.util.Collections;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class WifiCallingSettingsTest {
|
public class WifiCallingSettingsTest {
|
||||||
|
private static final int SUB_ID1 = 111;
|
||||||
|
private static final int SUB_ID2 = 222;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ImsManager mImsManager;
|
||||||
|
|
||||||
private WifiCallingSettings mFragment;
|
private WifiCallingSettings mFragment;
|
||||||
|
|
||||||
|
private MockWifiCallingQueryImsState mQueryImsState1;
|
||||||
|
private MockWifiCallingQueryImsState mQueryImsState2;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
|
mQueryImsState1 = new MockWifiCallingQueryImsState(mContext, SUB_ID1);
|
||||||
|
mQueryImsState2 = new MockWifiCallingQueryImsState(mContext, SUB_ID2);
|
||||||
|
mQueryImsState1.setIsEnabledByUser(true);
|
||||||
|
mQueryImsState2.setIsEnabledByUser(true);
|
||||||
|
mQueryImsState1.setIsEnabledByPlatform(true);
|
||||||
|
mQueryImsState2.setIsEnabledByPlatform(true);
|
||||||
|
mQueryImsState1.setIsProvisionedOnDevice(true);
|
||||||
|
mQueryImsState2.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
mFragment = spy(new WifiCallingSettings());
|
mFragment = spy(new WifiCallingSettings());
|
||||||
|
doReturn(mQueryImsState1).when(mFragment).queryImsState(SUB_ID1);
|
||||||
|
doReturn(mQueryImsState2).when(mFragment).queryImsState(SUB_ID2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -65,12 +94,12 @@ public class WifiCallingSettingsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setupFragment_oneSubscription_noCrash() {
|
public void setupFragment_oneSubscription_noCrash() {
|
||||||
final SubscriptionInfo info = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info = mock(SubscriptionInfo.class);
|
||||||
when(info.getSubscriptionId()).thenReturn(111);
|
when(info.getSubscriptionId()).thenReturn(SUB_ID1);
|
||||||
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
||||||
Collections.singletonList(info)));
|
Collections.singletonList(info)));
|
||||||
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
|
mQueryImsState1.setIsEnabledByPlatform(true);
|
||||||
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
|
mQueryImsState1.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
|
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
|
||||||
@@ -88,13 +117,11 @@ public class WifiCallingSettingsTest {
|
|||||||
public void setupFragment_twoSubscriptions_correctSelection() {
|
public void setupFragment_twoSubscriptions_correctSelection() {
|
||||||
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
||||||
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
|
||||||
when(info1.getSubscriptionId()).thenReturn(111);
|
when(info1.getSubscriptionId()).thenReturn(SUB_ID1);
|
||||||
when(info2.getSubscriptionId()).thenReturn(222);
|
when(info2.getSubscriptionId()).thenReturn(SUB_ID2);
|
||||||
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
||||||
Arrays.asList(info1, info2)));
|
Arrays.asList(info1, info2)));
|
||||||
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
|
|
||||||
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
|
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(Settings.EXTRA_SUB_ID, info2.getSubscriptionId());
|
intent.putExtra(Settings.EXTRA_SUB_ID, info2.getSubscriptionId());
|
||||||
@@ -114,14 +141,12 @@ public class WifiCallingSettingsTest {
|
|||||||
public void setupFragment_twoSubscriptionsOneNotProvisionedOnDevice_oneResult() {
|
public void setupFragment_twoSubscriptionsOneNotProvisionedOnDevice_oneResult() {
|
||||||
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
||||||
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
|
||||||
when(info1.getSubscriptionId()).thenReturn(111);
|
when(info1.getSubscriptionId()).thenReturn(SUB_ID1);
|
||||||
when(info2.getSubscriptionId()).thenReturn(222);
|
when(info2.getSubscriptionId()).thenReturn(SUB_ID2);
|
||||||
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
|
||||||
Arrays.asList(info1, info2)));
|
Arrays.asList(info1, info2)));
|
||||||
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
|
mQueryImsState2.setIsProvisionedOnDevice(false);
|
||||||
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(eq(info1));
|
|
||||||
doReturn(false).when(mFragment).isWfcProvisionedOnDevice(eq(info2));
|
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(Settings.EXTRA_SUB_ID, info1.getSubscriptionId());
|
intent.putExtra(Settings.EXTRA_SUB_ID, info1.getSubscriptionId());
|
||||||
|
@@ -47,6 +47,7 @@ import androidx.slice.widget.SliceLiveData;
|
|||||||
|
|
||||||
import com.android.ims.ImsManager;
|
import com.android.ims.ImsManager;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.network.ims.MockWifiCallingQueryImsState;
|
||||||
import com.android.settings.slices.CustomSliceRegistry;
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
import com.android.settings.slices.SettingsSliceProvider;
|
import com.android.settings.slices.SettingsSliceProvider;
|
||||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||||
@@ -68,6 +69,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class WifiCallingSliceHelperTest {
|
public class WifiCallingSliceHelperTest {
|
||||||
|
private static final int SUB_ID = 1;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -79,6 +81,8 @@ public class WifiCallingSliceHelperTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private ImsMmTelManager mMockImsMmTelManager;
|
private ImsMmTelManager mMockImsMmTelManager;
|
||||||
|
|
||||||
|
private MockWifiCallingQueryImsState mQueryImsState;
|
||||||
|
|
||||||
private FakeWifiCallingSliceHelper mWfcSliceHelper;
|
private FakeWifiCallingSliceHelper mWfcSliceHelper;
|
||||||
private SettingsSliceProvider mProvider;
|
private SettingsSliceProvider mProvider;
|
||||||
private SliceBroadcastReceiver mReceiver;
|
private SliceBroadcastReceiver mReceiver;
|
||||||
@@ -101,7 +105,13 @@ public class WifiCallingSliceHelperTest {
|
|||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mSlicesFeatureProvider = mFeatureFactory.getSlicesFeatureProvider();
|
mSlicesFeatureProvider = mFeatureFactory.getSlicesFeatureProvider();
|
||||||
|
|
||||||
|
mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
|
||||||
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
|
mQueryImsState.setIsEnabledByPlatform(true);
|
||||||
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
|
|
||||||
mWfcSliceHelper = spy(new FakeWifiCallingSliceHelper(mContext));
|
mWfcSliceHelper = spy(new FakeWifiCallingSliceHelper(mContext));
|
||||||
|
doReturn(mQueryImsState).when(mWfcSliceHelper).queryImsState(anyInt());
|
||||||
|
|
||||||
// Set-up specs for SliceMetadata.
|
// Set-up specs for SliceMetadata.
|
||||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||||
@@ -109,6 +119,8 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingSlice_invalidSubId() {
|
public void test_CreateWifiCallingSlice_invalidSubId() {
|
||||||
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
|
mQueryImsState.setIsProvisionedOnDevice(false);
|
||||||
mWfcSliceHelper.setDefaultVoiceSubId(-1);
|
mWfcSliceHelper.setDefaultVoiceSubId(-1);
|
||||||
|
|
||||||
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
||||||
@@ -119,7 +131,7 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingSlice_wfcNotSupported() {
|
public void test_CreateWifiCallingSlice_wfcNotSupported() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(false);
|
mQueryImsState.setIsProvisionedOnDevice(false);
|
||||||
|
|
||||||
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
||||||
CustomSliceRegistry.WIFI_CALLING_URI);
|
CustomSliceRegistry.WIFI_CALLING_URI);
|
||||||
@@ -135,10 +147,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
turned off) we need to guide the user to wifi calling settings
|
turned off) we need to guide the user to wifi calling settings
|
||||||
activity so the user can perform the activation there.(PrimaryAction)
|
activity so the user can perform the activation there.(PrimaryAction)
|
||||||
*/
|
*/
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(false);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
|
mQueryImsState.setIsTtyOnVolteEnabled(false);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(false);
|
|
||||||
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
||||||
mWfcSliceHelper.setActivationAppIntent(new Intent()); // dummy Intent
|
mWfcSliceHelper.setActivationAppIntent(new Intent()); // dummy Intent
|
||||||
|
|
||||||
@@ -153,10 +164,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingSlice_success() {
|
public void test_CreateWifiCallingSlice_success() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
||||||
|
|
||||||
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
|
||||||
@@ -168,10 +178,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_SettingSliceProvider_getsRightSliceWifiCalling() {
|
public void test_SettingSliceProvider_getsRightSliceWifiCalling() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
|
||||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||||
.thenReturn(mWfcSliceHelper);
|
.thenReturn(mWfcSliceHelper);
|
||||||
@@ -184,10 +193,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_SliceBroadcastReceiver_toggleOnWifiCalling() {
|
public void test_SliceBroadcastReceiver_toggleOnWifiCalling() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(false);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||||
.thenReturn(mWfcSliceHelper);
|
.thenReturn(mWfcSliceHelper);
|
||||||
mWfcSliceHelper.setActivationAppIntent(null);
|
mWfcSliceHelper.setActivationAppIntent(null);
|
||||||
@@ -201,7 +209,7 @@ public class WifiCallingSliceHelperTest {
|
|||||||
// change the setting
|
// change the setting
|
||||||
mReceiver.onReceive(mContext, intent);
|
mReceiver.onReceive(mContext, intent);
|
||||||
|
|
||||||
verify((mMockImsManager)).setWfcSetting(mWfcSettingCaptor.capture());
|
verify((mMockImsMmTelManager)).setVoWiFiSettingEnabled(mWfcSettingCaptor.capture());
|
||||||
|
|
||||||
// assert the change
|
// assert the change
|
||||||
assertThat(mWfcSettingCaptor.getValue()).isTrue();
|
assertThat(mWfcSettingCaptor.getValue()).isTrue();
|
||||||
@@ -209,10 +217,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingPreferenceSlice_prefNotEditable() {
|
public void test_CreateWifiCallingPreferenceSlice_prefNotEditable() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(false);
|
mWfcSliceHelper.setIsWifiCallingPrefEditable(false);
|
||||||
|
|
||||||
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
|
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
|
||||||
@@ -224,10 +231,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingPreferenceSlice_wfcOff() {
|
public void test_CreateWifiCallingPreferenceSlice_wfcOff() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(false);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
||||||
|
|
||||||
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
|
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
|
||||||
@@ -241,10 +247,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_CreateWifiCallingPreferenceSlice_success() {
|
public void test_CreateWifiCallingPreferenceSlice_success() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
||||||
@@ -259,10 +264,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_SettingsSliceProvider_getWfcPreferenceSlice() {
|
public void test_SettingsSliceProvider_getWfcPreferenceSlice() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||||
@@ -278,10 +282,9 @@ public class WifiCallingSliceHelperTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_SliceBroadcastReceiver_setWfcPrefCellularPref() {
|
public void test_SliceBroadcastReceiver_setWfcPrefCellularPref() {
|
||||||
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
|
mQueryImsState.setIsProvisionedOnDevice(true);
|
||||||
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
|
mQueryImsState.setIsEnabledByUser(true);
|
||||||
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
|
mQueryImsState.setIsTtyOnVolteEnabled(true);
|
||||||
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
|
|
||||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||||
@@ -433,12 +436,6 @@ public class WifiCallingSliceHelperTest {
|
|||||||
return mMockCarrierConfigManager;
|
return mMockCarrierConfigManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ImsManager getImsManager(int subId) {
|
|
||||||
return mMockImsManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
||||||
return mMockImsMmTelManager;
|
return mMockImsMmTelManager;
|
||||||
}
|
}
|
||||||
@@ -451,10 +448,6 @@ public class WifiCallingSliceHelperTest {
|
|||||||
mSubId = id;
|
mSubId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isWfcProvisionedOnDevice(int subId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent getWifiCallingCarrierActivityIntent(int subId) {
|
protected Intent getWifiCallingCarrierActivityIntent(int subId) {
|
||||||
return mActivationAppIntent;
|
return mActivationAppIntent;
|
||||||
|
Reference in New Issue
Block a user