[Settings] Hidden API remove - WFC mode settings

Change API from getWfcMode/setWfcMode into APIs within ImsMmTelManager.

Bug: 140542283
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest
atest WifiCallingSettingUiTest

Change-Id: I2ee01852cb4ee90fe9db256d3333f461cc070da5
This commit is contained in:
Bonian Chen
2019-11-06 10:57:01 +08:00
parent 5243629d25
commit c3b94292ea
7 changed files with 183 additions and 139 deletions

View File

@@ -30,6 +30,7 @@ import android.os.PersistableBundle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsMmTelManager;
import android.text.TextUtils;
import android.util.Log;
@@ -233,6 +234,7 @@ public class WifiCallingSliceHelper {
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
final ImsManager imsManager = getImsManager(subId);
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
if (!imsManager.isWfcEnabledByPlatform()
|| !imsManager.isWfcProvisionedOnDevice()) {
@@ -249,7 +251,7 @@ public class WifiCallingSliceHelper {
int wfcMode = -1;
try {
isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
wfcMode = getWfcMode(imsManager);
wfcMode = getWfcMode(imsMmTelManager);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
Log.e(TAG, "Unable to get wifi calling preferred mode", e);
return null;
@@ -279,7 +281,7 @@ public class WifiCallingSliceHelper {
Uri sliceUri) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
// Top row shows information on current preference state
ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
listBuilder.setHeader(new ListBuilder.HeaderBuilder()
.setTitle(mContext.getText(R.string.wifi_calling_mode_title))
@@ -294,18 +296,18 @@ public class WifiCallingSliceHelper {
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_wifi_only_summary,
ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY,
currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY));
}
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_wifi_preferred_summary,
ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED,
currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED));
currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED));
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_cellular_preferred_summary,
ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED,
currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
return listBuilder.build();
}
@@ -337,13 +339,13 @@ public class WifiCallingSliceHelper {
*/
private CharSequence getWifiCallingPreferenceSummary(int wfcMode) {
switch (wfcMode) {
case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
return mContext.getText(
com.android.internal.R.string.wfc_mode_wifi_only_summary);
case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
return mContext.getText(
com.android.internal.R.string.wfc_mode_wifi_preferred_summary);
case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
return mContext.getText(
com.android.internal.R.string.wfc_mode_cellular_preferred_summary);
default:
@@ -355,15 +357,19 @@ public class WifiCallingSliceHelper {
return ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId));
}
private int getWfcMode(ImsManager imsManager)
protected ImsMmTelManager getImsMmTelManager(int subId) {
return ImsMmTelManager.createForSubscriptionId(subId);
}
private int getWfcMode(ImsMmTelManager imsMmTelManager)
throws InterruptedException, ExecutionException, TimeoutException {
FutureTask<Integer> wfcModeTask = new FutureTask<>(new Callable<Integer>() {
final FutureTask<Integer> wfcModeTask = new FutureTask<>(new Callable<Integer>() {
@Override
public Integer call() {
return imsManager.getWfcMode(false);
return imsMmTelManager.getVoWiFiModeSetting();
}
});
ExecutorService executor = Executors.newSingleThreadExecutor();
final ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(wfcModeTask);
return wfcModeTask.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@@ -420,7 +426,7 @@ public class WifiCallingSliceHelper {
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
ImsManager imsManager = getImsManager(subId);
final ImsManager imsManager = getImsManager(subId);
if (isWifiCallingPrefEditable
&& imsManager.isWfcEnabledByPlatform()
&& imsManager.isWfcProvisionedOnDevice()
@@ -428,25 +434,26 @@ public class WifiCallingSliceHelper {
&& imsManager.isNonTtyOrTtyOnVolteEnabled()) {
// Change the preference only when wifi calling is enabled
// And when wifi calling preference is editable for the current carrier
final int currentValue = imsManager.getWfcMode(false);
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
final int currentValue = imsMmTelManager.getVoWiFiModeSetting();
int newValue = errorValue;
switch (intent.getAction()) {
case ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY:
if (isWifiOnlySupported) {
// change to wifi_only when wifi_only is enabled.
newValue = ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
newValue = ImsMmTelManager.WIFI_MODE_WIFI_ONLY;
}
break;
case ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED:
newValue = ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED;
newValue = ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED;
break;
case ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED:
newValue = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
newValue = ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED;
break;
}
if (newValue != errorValue && newValue != currentValue) {
// Update the setting only when there is a valid update
imsManager.setWfcMode(newValue, false);
imsMmTelManager.setVoWiFiModeSetting(newValue);
}
}
}