Merge "Associate PhoneAccount RTT capability to UI toggle"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 0756029..c440096 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -3342,6 +3342,11 @@
return isCarrierSupported && isDeviceSupported;
}
+ public boolean isRttEnabled() {
+ return isRttSupported() && Settings.Secure.getInt(mPhone.getContext().getContentResolver(),
+ Settings.Secure.RTT_CALLING_MODE, 0) != 0;
+ }
+
/**
* Returns the unique device ID of phone, for example, the IMEI for
* GSM and the MEID for CDMA phones. Return null if device ID is not available.
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 3fb8d32..f7632c7 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -22,6 +22,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
+import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
@@ -29,9 +30,12 @@
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.os.UserManager;
+import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -234,7 +238,7 @@
extras.putBoolean(PhoneAccount.EXTRA_PLAY_CALL_RECORDING_TONE, true);
}
- if (PhoneGlobals.getInstance().phoneMgr.isRttSupported()) {
+ if (PhoneGlobals.getInstance().phoneMgr.isRttEnabled()) {
capabilities |= PhoneAccount.CAPABILITY_RTT;
}
@@ -496,6 +500,13 @@
}
}
+ public void updateRttCapability() {
+ boolean isRttEnabled = PhoneGlobals.getInstance().phoneMgr.isRttEnabled();
+ boolean oldRttEnabled = mAccount.hasCapabilities(PhoneAccount.CAPABILITY_RTT);
+ if (isRttEnabled != oldRttEnabled) {
+ mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+ }
+ }
/**
* Indicates whether this account supports pausing video calls.
* @return {@code true} if the account supports pausing video calls, {@code false}
@@ -601,7 +612,7 @@
private final TelephonyManager mTelephonyManager;
private final SubscriptionManager mSubscriptionManager;
private List<AccountEntry> mAccounts = new LinkedList<AccountEntry>();
- private Object mAccountsLock = new Object();
+ private final Object mAccountsLock = new Object();
private int mServiceState = ServiceState.STATE_POWER_OFF;
private boolean mIsPrimaryUser = true;
@@ -804,6 +815,23 @@
// use is not the primary user we disable video calling.
mContext.registerReceiver(mUserSwitchedReceiver,
new IntentFilter(Intent.ACTION_USER_SWITCHED));
+
+ // Listen to the RTT system setting so that we update it when the user flips it.
+ ContentObserver rttUiSettingObserver = new ContentObserver(
+ new Handler(Looper.getMainLooper())) {
+ @Override
+ public void onChange(boolean selfChange) {
+ synchronized (mAccountsLock) {
+ for (AccountEntry account : mAccounts) {
+ account.updateRttCapability();
+ }
+ }
+ }
+ };
+
+ Uri rttSettingUri = Settings.Secure.getUriFor(Settings.Secure.RTT_CALLING_MODE);
+ mContext.getContentResolver().registerContentObserver(
+ rttSettingUri, false, rttUiSettingObserver);
}
/**