[Settings] replace isNonTtyOrTtyOnVolteEnabled() and isWfcEnabledByUser() in WFC
1. Code refactor 2. Replace ImsManager#isNonTtyOrTtyOnVolteEnabled() by combination of TelecomManager#getCurrentTtyMode() and ImsMmTelManager#isTtyOverVolteEnabled() 3. Replace ImsManager#isWfcEnabledByUser() by ImsMmTelManager#isVoWiFiSettingEnabled() Bug: 140542283 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest Change-Id: I57c91a095fc4d454d92e8d78e0b647b4f098c6a3
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network.ims;
|
||||
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
|
||||
|
||||
/**
|
||||
* An {@code ImsQuery} for accessing IMS WFC enabled settings from user
|
||||
*/
|
||||
public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param subId subscription id
|
||||
*/
|
||||
public ImsQueryWfcUserSetting(int subId) {
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
private volatile int mSubId;
|
||||
|
||||
/**
|
||||
* Query running within a {@code Callable}
|
||||
*
|
||||
* @return result of query
|
||||
*/
|
||||
public Boolean call() {
|
||||
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||
return imsMmTelManager.isVoWiFiSettingEnabled();
|
||||
}
|
||||
}
|
@@ -19,8 +19,7 @@ package com.android.settings.network.ims;
|
||||
import android.content.Context;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Controller class for querying Wifi calling status
|
||||
@@ -41,6 +40,14 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
ImsDirectQuery isEnabledByUser(int subId) {
|
||||
return new ImsQueryWfcUserSetting(subId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowance status for user to alter configuration
|
||||
*
|
||||
@@ -64,8 +71,6 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
|
||||
mContext, mSubId));
|
||||
return imsManager.isWfcEnabledByUser();
|
||||
return isEnabledByUser(mSubId).directQuery();
|
||||
}
|
||||
}
|
||||
|
@@ -115,7 +115,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber) {
|
||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||
final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
|
||||
final boolean isNonTtyOrTtyOnVolteEnabled =
|
||||
queryImsState(WifiCallingSettingsForSub.this.mSubId).isAllowUserControl();
|
||||
final boolean isWfcEnabled = mSwitchBar.isChecked()
|
||||
&& isNonTtyOrTtyOnVolteEnabled;
|
||||
boolean isCallStateIdle =
|
||||
@@ -403,7 +404,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
|
||||
final WifiCallingQueryImsState queryIms = queryImsState(mSubId);
|
||||
final boolean wfcEnabled = queryIms.isEnabledByUser()
|
||||
&& mImsManager.isNonTtyOrTtyOnVolteEnabled();
|
||||
&& queryIms.isAllowUserControl();
|
||||
mSwitch.setChecked(wfcEnabled);
|
||||
final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
|
||||
final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
|
||||
|
@@ -148,35 +148,29 @@ public class WifiCallingSliceHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
final boolean isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
|
||||
final Intent activationAppIntent =
|
||||
getWifiCallingCarrierActivityIntent(subId);
|
||||
final boolean isWifiCallingEnabled = isWifiCallingEnabled();
|
||||
final Intent activationAppIntent =
|
||||
getWifiCallingCarrierActivityIntent(subId);
|
||||
|
||||
// Send this actionable wifi calling slice to toggle the setting
|
||||
// only when there is no need for wifi calling activation with the server
|
||||
if (activationAppIntent != null && !isWifiCallingEnabled) {
|
||||
Log.d(TAG, "Needs Activation");
|
||||
// Activation needed for the next action of the user
|
||||
// Give instructions to go to settings app
|
||||
final Resources res = getResourcesForSubId(subId);
|
||||
return getNonActionableWifiCallingSlice(
|
||||
res.getText(R.string.wifi_calling_settings_title),
|
||||
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;
|
||||
// Send this actionable wifi calling slice to toggle the setting
|
||||
// only when there is no need for wifi calling activation with the server
|
||||
if (activationAppIntent != null && !isWifiCallingEnabled) {
|
||||
Log.d(TAG, "Needs Activation");
|
||||
// Activation needed for the next action of the user
|
||||
// Give instructions to go to settings app
|
||||
final Resources res = getResourcesForSubId(subId);
|
||||
return getNonActionableWifiCallingSlice(
|
||||
res.getText(R.string.wifi_calling_settings_title),
|
||||
res.getText(R.string.wifi_calling_settings_activation_instructions),
|
||||
sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
|
||||
}
|
||||
return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId);
|
||||
}
|
||||
|
||||
private boolean isWifiCallingEnabled(ImsManager imsManager)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
private boolean isWifiCallingEnabled() {
|
||||
final int subId = getDefaultVoiceSubId();
|
||||
return queryImsState(subId).isEnabledByUser()
|
||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled();
|
||||
&& queryImsState(subId).isAllowUserControl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +241,7 @@ public class WifiCallingSliceHelper {
|
||||
boolean isWifiCallingEnabled = false;
|
||||
int wfcMode = -1;
|
||||
try {
|
||||
isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
|
||||
isWifiCallingEnabled = isWifiCallingEnabled();
|
||||
wfcMode = getWfcMode(imsMmTelManager);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
Log.e(TAG, "Unable to get wifi calling preferred mode", e);
|
||||
@@ -392,7 +386,7 @@ public class WifiCallingSliceHelper {
|
||||
if (imsManager.isWfcEnabledByPlatform()
|
||||
&& isWfcProvisionedOnDevice(subId)) {
|
||||
final boolean currentValue = queryImsState(subId).isEnabledByUser()
|
||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled();
|
||||
&& queryImsState(subId).isAllowUserControl();
|
||||
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||
currentValue);
|
||||
final Intent activationAppIntent =
|
||||
@@ -436,7 +430,7 @@ public class WifiCallingSliceHelper {
|
||||
&& imsManager.isWfcEnabledByPlatform()
|
||||
&& isWfcProvisionedOnDevice(subId)
|
||||
&& queryImsState(subId).isEnabledByUser()
|
||||
&& imsManager.isNonTtyOrTtyOnVolteEnabled()) {
|
||||
&& queryImsState(subId).isAllowUserControl()) {
|
||||
// Change the preference only when wifi calling is enabled
|
||||
// And when wifi calling preference is editable for the current carrier
|
||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||
|
Reference in New Issue
Block a user