Prevent video calling when tty mode is enabled.
This code was originally in Telecom, and it really didn't belong there.
If TTY is enabled and the user attempts to make a non-emergency video
call (same check as was in Telecom), we will fail the call with a new
disconnect cause.
See screenshot in the bug if you're curious what this will look like.
This code uses the existing code in InCall to inform the user of a failed
call reason.
Bug: 20090652
Change-Id: Iadb537e63f9eaa7b2502639d58ce2abf17511f6f
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index 235c4b9..d7db345 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -92,6 +92,7 @@
case android.telephony.DisconnectCause.EMERGENCY_ONLY:
case android.telephony.DisconnectCause.FDN_BLOCKED:
case android.telephony.DisconnectCause.LIMIT_EXCEEDED:
+ case android.telephony.DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED:
return DisconnectCause.RESTRICTED;
case android.telephony.DisconnectCause.CDMA_ACCESS_FAILURE:
@@ -324,6 +325,10 @@
resourceId = R.string.incall_error_missing_voicemail_number;
break;
+ case android.telephony.DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED:
+ resourceId = R.string.callFailed_video_call_tty_enabled;
+ break;
+
case android.telephony.DisconnectCause.OUTGOING_CANCELED:
// We don't want to show any dialog for the canceled case since the call was
// either canceled by the user explicitly (end-call button pushed immediately)
@@ -371,6 +376,7 @@
case android.telephony.DisconnectCause.ERROR_UNSPECIFIED:
case android.telephony.DisconnectCause.LOCAL:
case android.telephony.DisconnectCause.NORMAL:
+ case android.telephony.DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED:
return ToneGenerator.TONE_PROP_PROMPT;
case android.telephony.DisconnectCause.IMS_MERGED_SUCCESSFULLY:
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 5f68d9a..c919059 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -26,6 +26,8 @@
import android.telecom.ConnectionService;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import android.telecom.VideoProfile;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
@@ -275,6 +277,14 @@
}
}
+ final Context context = getApplicationContext();
+ if (VideoProfile.isVideo(request.getVideoState()) && isTtyModeEnabled(context) &&
+ !isEmergencyNumber) {
+ return Connection.createFailedConnection(
+ DisconnectCauseUtil.toTelecomDisconnectCause(
+ DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED));
+ }
+
final TelephonyConnection connection =
createConnectionFor(phone, null, true /* isOutgoing */, request.getAccountHandle(),
request.getTelecomCallId());
@@ -623,4 +633,11 @@
mImsConferenceController.remove(connection);
}
}
+
+ private boolean isTtyModeEnabled(Context context) {
+ return (android.provider.Settings.Secure.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Secure.PREFERRED_TTY_MODE,
+ TelecomManager.TTY_MODE_OFF) != TelecomManager.TTY_MODE_OFF);
+ }
}