Merge "Adjust Telephony code to use Telecom constants"
diff --git a/res/values/config.xml b/res/values/config.xml
index d4e4c79..2f0fcc6 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -257,6 +257,16 @@
audio stream which the remote party will be able to hear. -->
<bool name="config_support_telephony_audio_device">false</bool>
+ <!-- Whether the device supports dialing emergency RTT calls when there's no SIM card installed
+ -->
+ <bool name="config_support_simless_emergency_rtt">false</bool>
+
+ <!-- Array of countries that support sim-less emergency RTT calls. Values should be
+ ISO3166 country codes in lowercase. -->
+ <string-array name="config_simless_emergency_rtt_supported_countries" translatable="false">
+ <item>us</item>
+ </string-array>
+
<string-array translatable="false" name="config_volte_provision_error_on_publish_response">
<item>403 not authorized for presence</item>
</string-array>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 9faffa1..ef83ead 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -97,6 +97,7 @@
"phone_account_settings_preference_screen";
private static final String ENABLE_VIDEO_CALLING_KEY = "button_enable_video_calling";
+ private static final String BUTTON_VP_KEY = "button_voice_privacy_key";
private Phone mPhone;
private ImsManager mImsMgr;
@@ -397,6 +398,9 @@
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
prefSet.removePreference(fdnButton);
addPreferencesFromResource(R.xml.cdma_call_privacy);
+ CdmaVoicePrivacySwitchPreference buttonVoicePrivacy =
+ (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY);
+ buttonVoicePrivacy.setPhone(mPhone);
} else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
if (mPhone.getIccCard() == null || !mPhone.getIccCard().getIccFdnAvailable()) {
prefSet.removePreference(fdnButton);
diff --git a/src/com/android/phone/CdmaCallOptions.java b/src/com/android/phone/CdmaCallOptions.java
index 8f4fa67..2e310aa 100644
--- a/src/com/android/phone/CdmaCallOptions.java
+++ b/src/com/android/phone/CdmaCallOptions.java
@@ -19,9 +19,7 @@
import android.os.Bundle;
import android.os.PersistableBundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
-import android.preference.SwitchPreference;
import android.telephony.CarrierConfigManager;
import android.view.MenuItem;
@@ -34,7 +32,7 @@
private static final String BUTTON_VP_KEY = "button_voice_privacy_key";
private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
private static final String CALL_WAITING_KEY = "call_waiting_key";
- private SwitchPreference mButtonVoicePrivacy;
+ private CdmaVoicePrivacySwitchPreference mButtonVoicePrivacy;
@Override
protected void onCreate(Bundle icicle) {
@@ -46,7 +44,8 @@
subInfoHelper.setActionBarTitle(
getActionBar(), getResources(), R.string.labelCdmaMore_with_label);
- mButtonVoicePrivacy = (SwitchPreference) findPreference(BUTTON_VP_KEY);
+ mButtonVoicePrivacy = (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY);
+ mButtonVoicePrivacy.setPhone(subInfoHelper.getPhone());
PersistableBundle carrierConfig;
if (subInfoHelper.hasSubId()) {
carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId(
diff --git a/src/com/android/phone/CdmaVoicePrivacySwitchPreference.java b/src/com/android/phone/CdmaVoicePrivacySwitchPreference.java
index b79a3f0..0192c2a 100644
--- a/src/com/android/phone/CdmaVoicePrivacySwitchPreference.java
+++ b/src/com/android/phone/CdmaVoicePrivacySwitchPreference.java
@@ -102,4 +102,8 @@
phone.getEnhancedVoicePrivacy(obtainMessage(MESSAGE_GET_VP));
}
}
+
+ public void setPhone(Phone phone) {
+ this.phone = phone;
+ }
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 05f7872..3901ac4 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -3436,6 +3436,9 @@
Phone phone = getPhone(subId);
if (phone == null) return false;
return phone.isImsCapabilityAvailable(capability, regTech);
+ } catch (com.android.ims.ImsException e) {
+ Log.w(LOG_TAG, "IMS isAvailable - service unavailable: " + e.getMessage());
+ return false;
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index e31de64..37212cf 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -25,6 +25,7 @@
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.provider.Settings;
+import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
@@ -39,6 +40,11 @@
import com.android.phone.PhoneGlobals;
import com.android.phone.R;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
public class AccessibilitySettingsFragment extends PreferenceFragment {
private static final String LOG_TAG = AccessibilitySettingsFragment.class.getSimpleName();
private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
@@ -48,6 +54,8 @@
private static final String BUTTON_RTT_KEY = "button_rtt_key";
private static final String RTT_INFO_PREF = "button_rtt_more_information_key";
+ private static final int WFC_QUERY_TIMEOUT_MILLIS = 20;
+
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
/**
* Disable the TTY setting when in/out of a call (and if carrier doesn't
@@ -110,10 +118,13 @@
}
if (shouldShowRttSetting()) {
- // TODO: this is going to be a on/off switch for now. Ask UX about how to integrate
- // this settings with TTY
- if (TelephonyManager.getDefault().isNetworkRoaming(
- SubscriptionManager.getDefaultVoiceSubscriptionId())) {
+ TelephonyManager tm =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ boolean isRoaming = tm.isNetworkRoaming(
+ SubscriptionManager.getDefaultVoiceSubscriptionId());
+
+ boolean shouldDisableBecauseRoamingOffWfc = isRoaming && !isOnWfc();
+ if (shouldDisableBecauseRoamingOffWfc) {
mButtonRtt.setSummary(TextUtils.concat(getText(R.string.rtt_mode_summary), "\n",
getText(R.string.no_rtt_when_roaming)));
}
@@ -230,6 +241,21 @@
return false;
}
+ private boolean isOnWfc() {
+ LinkedBlockingQueue<Integer> result = new LinkedBlockingQueue<>(1);
+ Executor executor = Executors.newSingleThreadExecutor();
+ mContext.getSystemService(android.telephony.ims.ImsManager.class)
+ .getImsMmTelManager(SubscriptionManager.getDefaultSubscriptionId())
+ .getRegistrationTransportType(executor, result::offer);
+ try {
+ Integer transportType = result.poll(WFC_QUERY_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ return transportType != null
+ && transportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN;
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
private boolean shouldShowRttSetting() {
// Go through all the subs -- if we want to display the RTT setting for any of them, do
// display it.
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 7811f6b..9e880a5 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -57,6 +57,7 @@
import android.text.TextUtils;
import com.android.ims.ImsManager;
+import com.android.internal.telephony.LocaleTracker;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SubscriptionController;
@@ -69,6 +70,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
+import java.util.function.Predicate;
/**
* Owns all data we have registered with Telecom including handling dynamic addition and
@@ -809,14 +811,51 @@
* device.
*/
private boolean isRttCurrentlySupported() {
+ // First check the emergency case -- if it's supported and turned on,
+ // we want to present RTT as available on the emergency-only phone account
+ if (mIsEmergency) {
+ // First check whether the device supports it
+ boolean devicesSupportsRtt =
+ mContext.getResources().getBoolean(R.bool.config_support_rtt);
+ boolean deviceSupportsEmergencyRtt = mContext.getResources().getBoolean(
+ R.bool.config_support_simless_emergency_rtt);
+ if (!(deviceSupportsEmergencyRtt && devicesSupportsRtt)) {
+ Log.i(this, "isRttCurrentlySupported -- emergency acct and no device support");
+ return false;
+ }
+ // Next check whether we're in or near a country that supports it
+ String country =
+ mPhone.getServiceStateTracker().getLocaleTracker()
+ .getCurrentCountry().toLowerCase();
+ String[] supportedCountries = mContext.getResources().getStringArray(
+ R.array.config_simless_emergency_rtt_supported_countries);
+ if (supportedCountries == null || Arrays.stream(supportedCountries).noneMatch(
+ Predicate.isEqual(country))) {
+ Log.i(this, "isRttCurrentlySupported -- emergency acct and"
+ + " not supported in this country: " + country);
+ return false;
+ }
+
+ return true;
+ }
+
boolean hasVoiceAvailability = isImsVoiceAvailable();
boolean isRttSupported = PhoneGlobals.getInstance().phoneMgr
.isRttEnabled(mPhone.getSubId());
boolean isRoaming = mTelephonyManager.isNetworkRoaming(mPhone.getSubId());
+ boolean isOnWfc = mPhone.getImsRegistrationTech()
+ == ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN;
- return hasVoiceAvailability && isRttSupported && !isRoaming;
+ boolean shouldDisableBecauseRoamingOffWfc = isRoaming && !isOnWfc;
+ Log.i(this, "isRttCurrentlySupported -- regular acct,"
+ + " hasVoiceAvailability: " + hasVoiceAvailability + "\n"
+ + " isRttSupported: " + isRttSupported + "\n"
+ + " isRoaming: " + isRoaming + "\n"
+ + " isOnWfc: " + isOnWfc + "\n");
+
+ return hasVoiceAvailability && isRttSupported && !shouldDisableBecauseRoamingOffWfc;
}
/**
@@ -1234,8 +1273,9 @@
//We also need to listen for locale changes
//(e.g. system language changed -> SIM card name changed)
- mContext.registerReceiver(mLocaleChangeReceiver,
- new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
+ IntentFilter localeChangeFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
+ localeChangeFilter.addAction(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED);
+ mContext.registerReceiver(mLocaleChangeReceiver, localeChangeFilter);
registerContentObservers();
}
diff --git a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
index 25df848..d55a2fa 100644
--- a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
+++ b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
@@ -69,6 +69,8 @@
@Override
@After
public void tearDown() throws Exception {
+ mListener.setTimeBetweenRetriesMillis(5000);
+ mListener.setMaxNumRetries(5);
mListener.getHandler().removeCallbacksAndMessages(null);
// Wait for the queue to clear...
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS /*ms timeout*/);