From 001bbbb239d4ef1005a87039c7c53e26d8f13ad6 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 15 Jul 2014 14:40:39 -0700 Subject: [PATCH] TTY: frameworks/base changes This CL makes the following changes: 1. New public APIs: - TelecommManager.getCurrentTtyMode: This is used to get current TTY mode. It's used by Telephony to set the phone state before calls are created (which is why it can't be a Conneciton API). - TelecommConstants.TTY_MODE_*: These are constants copied from Phone.java - TelecommConstants.ACTION_CURRENT_TTY_MODE_CHANGED: This action is fired when the current TTY mode changes. Apps can listen to this before and during a call. The old version of this was in TtyIntent.java which I deleted. 2. New private API - TelecommManager.isTtySupported: This is used by Telephony to hide the TTY settings on devices that don't support TTY 3. Various updates to use the constants renamed in this CL Change-Id: I652b095af30cc2732a06829dc23492e5355660da --- api/current.txt | 9 +++ core/java/android/content/Context.java | 1 - .../statusbar/phone/PhoneStatusBarPolicy.java | 11 ++- .../java/android/telecomm/Connection.java | 13 ++- .../android/telecomm/ConnectionService.java | 6 +- .../android/telecomm/TelecommConstants.java | 79 +++++++++++++++++++ .../android/telecomm/TelecommManager.java | 52 ++++++++---- .../internal/telecomm/ITelecommService.aidl | 10 +++ 8 files changed, 152 insertions(+), 29 deletions(-) diff --git a/api/current.txt b/api/current.txt index b2689bbd163b6..6da33657f5d27 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7191,6 +7191,7 @@ package android.content { field public static final java.lang.String SEARCH_SERVICE = "search"; field public static final java.lang.String SENSOR_SERVICE = "sensor"; field public static final java.lang.String STORAGE_SERVICE = "storage"; + field public static final java.lang.String TELECOMM_SERVICE = "telecomm"; field public static final java.lang.String TELEPHONY_SERVICE = "phone"; field public static final java.lang.String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; field public static final java.lang.String TV_INPUT_SERVICE = "tv_input"; @@ -28425,6 +28426,14 @@ package android.telecomm { field public static final java.lang.String EXTRA_START_CALL_WITH_VIDEO_STATE = "android.intent.extra.START_CALL_WITH_VIDEO_STATE"; } + public class TelecommManager { + method public void clearAccounts(java.lang.String); + method public java.util.List getEnabledPhoneAccounts(); + method public android.telecomm.PhoneAccountMetadata getPhoneAccountMetadata(android.telecomm.PhoneAccount); + method public void registerPhoneAccount(android.telecomm.PhoneAccount, android.telecomm.PhoneAccountMetadata); + method public void unregisterPhoneAccount(android.telecomm.PhoneAccount); + } + public class VideoCallProfile implements android.os.Parcelable { ctor public VideoCallProfile(int, int); method public int describeContents(); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index d068b1fba06fb..1569b9ff39230 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -2539,7 +2539,6 @@ public abstract class Context { * * @see #getSystemService * @see android.telecomm.TelecommManager - * @hide */ public static final String TELECOMM_SERVICE = "telecomm"; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index 1bb36dd796d7c..8b5ff6734670f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -27,11 +27,12 @@ import android.media.AudioManager; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings.Global; +import android.telecomm.TelecommConstants; +import android.telecomm.TelecommManager; import android.util.Log; import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.TelephonyIntents; -import com.android.internal.telephony.cdma.TtyIntent; import com.android.systemui.R; /** @@ -89,7 +90,7 @@ public class PhoneStatusBarPolicy { else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { updateSimState(intent); } - else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) { + else if (action.equals(TelecommConstants.ACTION_CURRENT_TTY_MODE_CHANGED)) { updateTTY(intent); } else if (action.equals(Intent.ACTION_USER_SWITCHED)) { @@ -110,7 +111,7 @@ public class PhoneStatusBarPolicy { filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); - filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); + filter.addAction(TelecommConstants.ACTION_CURRENT_TTY_MODE_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); @@ -269,7 +270,9 @@ public class PhoneStatusBarPolicy { } private final void updateTTY(Intent intent) { - final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false); + int currentTtyMode = intent.getIntExtra(TelecommConstants.EXTRA_CURRENT_TTY_MODE, + TelecommConstants.TTY_MODE_OFF); + boolean enabled = currentTtyMode != TelecommConstants.TTY_MODE_OFF; if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled); diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java index fb820f0f3db2e..db834a4519ea3 100644 --- a/telecomm/java/android/telecomm/Connection.java +++ b/telecomm/java/android/telecomm/Connection.java @@ -44,9 +44,9 @@ public abstract class Connection { public void onDestroyed(Connection c) {} public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {} public void onParentConnectionChanged(Connection c, Connection parent) {} - public void onSetCallVideoProvider(Connection c, CallVideoProvider callVideoProvider) {} - public void onSetAudioModeIsVoip(Connection c, boolean isVoip) {} - public void onSetStatusHints(Connection c, StatusHints statusHints) {} + public void onCallVideoProviderChanged(Connection c, CallVideoProvider callVideoProvider) {} + public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} + public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} } public final class State { @@ -321,7 +321,7 @@ public abstract class Connection { public final void setCallVideoProvider(CallVideoProvider callVideoProvider) { mCallVideoProvider = callVideoProvider; for (Listener l : mListeners) { - l.onSetCallVideoProvider(this, callVideoProvider); + l.onCallVideoProviderChanged(this, callVideoProvider); } } @@ -415,7 +415,7 @@ public abstract class Connection { public final void setAudioModeIsVoip(boolean isVoip) { mAudioModeIsVoip = isVoip; for (Listener l : mListeners) { - l.onSetAudioModeIsVoip(this, isVoip); + l.onAudioModeIsVoipChanged(this, isVoip); } } @@ -427,7 +427,7 @@ public abstract class Connection { public final void setStatusHints(StatusHints statusHints) { mStatusHints = statusHints; for (Listener l : mListeners) { - l.onSetStatusHints(this, statusHints); + l.onStatusHintsChanged(this, statusHints); } } @@ -516,7 +516,6 @@ public abstract class Connection { */ protected void onPhoneAccountClicked() {} - private void addChild(Connection connection) { Log.d(this, "adding child %s", connection); mChildConnections.add(connection); diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java index 178cee8248cc4..2a6804b92eb4a 100644 --- a/telecomm/java/android/telecomm/ConnectionService.java +++ b/telecomm/java/android/telecomm/ConnectionService.java @@ -364,19 +364,19 @@ public abstract class ConnectionService extends Service { } @Override - public void onSetCallVideoProvider(Connection c, CallVideoProvider callVideoProvider) { + public void onCallVideoProviderChanged(Connection c, CallVideoProvider callVideoProvider) { String id = mIdByConnection.get(c); mAdapter.setCallVideoProvider(id, callVideoProvider); } @Override - public void onSetAudioModeIsVoip(Connection c, boolean isVoip) { + public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) { String id = mIdByConnection.get(c); mAdapter.setAudioModeIsVoip(id, isVoip); } @Override - public void onSetStatusHints(Connection c, StatusHints statusHints) { + public void onStatusHintsChanged(Connection c, StatusHints statusHints) { String id = mIdByConnection.get(c); mAdapter.setStatusHints(id, statusHints); } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index a94841fdd0499..b50c1d71212b9 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -121,4 +121,83 @@ public final class TelecommConstants { * wait for user confirmation before proceeding. */ public static final char DTMF_CHARACTER_WAIT = ';'; + + /** + * TTY (teletypewriter) mode is off. + * + * @hide + */ + public static final int TTY_MODE_OFF = 0; + + /** + * TTY (teletypewriter) mode is on. The speaker is off and the microphone is muted. The user + * will communicate with the remote party by sending and receiving text messages. + * + * @hide + */ + public static final int TTY_MODE_FULL = 1; + + /** + * TTY (teletypewriter) mode is in hearing carryover mode (HCO). The microphone is muted but the + * speaker is on. The user will communicate with the remote party by sending text messages and + * hearing an audible reply. + * + * @hide + */ + public static final int TTY_MODE_HCO = 2; + + /** + * TTY (teletypewriter) mode is in voice carryover mode (VCO). The speaker is off but the + * microphone is still on. User will communicate with the remote party by speaking and receiving + * text message replies. + * + * @hide + */ + public static final int TTY_MODE_VCO = 3; + + /** + * Broadcast intent action indicating that the current TTY mode has changed. An intent extra + * provides this state as an int. + * @see #EXTRA_CURRENT_TTY_MODE + * + * @hide + */ + public static final String ACTION_CURRENT_TTY_MODE_CHANGED = + "android.telecomm.intent.action.CURRENT_TTY_MODE_CHANGED"; + + /** + * The lookup key for an int that indicates the current TTY mode. + * Valid modes are: + * - {@link #TTY_MODE_OFF} + * - {@link #TTY_MODE_FULL} + * - {@link #TTY_MODE_HCO} + * - {@link #TTY_MODE_VCO} + * + * @hide + */ + public static final String EXTRA_CURRENT_TTY_MODE = + "android.telecomm.intent.extra.CURRENT_TTY_MODE"; + + /** + * Broadcast intent action indicating that the TTY preferred operating mode + * has changed. An intent extra provides the new mode as an int. + * @see #EXTRA_TTY_PREFERRED_MODE + * + * @hide + */ + public static final String ACTION_TTY_PREFERRED_MODE_CHANGED = + "android.telecomm.intent.action.TTY_PREFERRED_MODE_CHANGED"; + + /** + * The lookup key for an int that indicates preferred TTY mode. + * Valid modes are: + * - {@link #TTY_MODE_OFF} + * - {@link #TTY_MODE_FULL} + * - {@link #TTY_MODE_HCO} + * - {@link #TTY_MODE_VCO} + * + * @hide + */ + public static final String EXTRA_TTY_PREFERRED_MODE = + "android.telecomm.intent.extra.TTY_PREFERRED"; } diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java index fcd2eba7116f5..8bf80bb74e97c 100644 --- a/telecomm/java/android/telecomm/TelecommManager.java +++ b/telecomm/java/android/telecomm/TelecommManager.java @@ -28,21 +28,9 @@ import java.util.List; /** * Provides access to Telecomm-related functionality. * TODO(santoscordon): Move this all into PhoneManager. - * @hide */ public class TelecommManager { - /** - * The extra used with an {@link android.content.Intent#ACTION_CALL} or - * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a {@link PhoneAccount} - * to use when making the call. - * - *

- * Retrieve with - * {@link android.content.Intent#getParcelableExtra(String)}. - */ - public static final String EXTRA_PHONE_ACCOUNT = "account"; - private static final String TAG = "TelecommManager"; private static final String TELECOMM_SERVICE_NAME = "telecomm"; @@ -138,8 +126,6 @@ public class TelecommManager { * Remove all Accounts for a given package from the system. * * @param packageName A package name that may have registered Accounts. - * - * @hide */ @SystemApi public void clearAccounts(String packageName) { @@ -254,6 +240,44 @@ public class TelecommManager { } } + /** + * Returns whether TTY is supported on this device. + * + * @hide + */ + @SystemApi + public boolean isTtySupported() { + try { + if (isServiceConnected()) { + return getTelecommService().isTtySupported(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); + } + return false; + } + + /** + * Returns the current TTY mode of the device. For TTY to be on the user must enable it in + * settings and have a wired headset plugged in. Valid modes are: + * - {@link android.telecomm.TelecommConstants#TTY_MODE_OFF} + * - {@link android.telecomm.TelecommConstants#TTY_MODE_FULL} + * - {@link android.telecomm.TelecommConstants#TTY_MODE_HCO} + * - {@link android.telecomm.TelecommConstants#TTY_MODE_VCO} + * + * @hide + */ + public int getCurrentTtyMode() { + try { + if (isServiceConnected()) { + return getTelecommService().getCurrentTtyMode(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); + } + return TelecommConstants.TTY_MODE_OFF; + } + private ITelecommService getTelecommService() { return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME)); } diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl index 3334385b3f57e..43caa1e7e18d4 100644 --- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl @@ -101,4 +101,14 @@ interface ITelecommService { * @see PhoneManager#handlePinMmi */ boolean handlePinMmi(String dialString); + + /** + * @see TelecomManager#isTtySupported + */ + boolean isTtySupported(); + + /** + * @see TelecomManager#getCurrentTtyMode + */ + int getCurrentTtyMode(); }