TTY: Telecomm
This CL makes the following changes:
1. Added TtyManager. This class contains code that used
to live in PhoneGlobals to listen to preferred TTY
mode changes. Current TTY mode is based on the
preferred mode, wired headset state, and device TTY
support.
2. Moved ownership of WiredHeadsetManager to CallsManager
so that TtyManager can listen to headset plugged events.
3. Added plumbing to TelecommServiceImpl to impement
isTtySupported and getCurrentTtyMode.
4. Added tty_enabled to config.xml. This is moved over
from Telephony.
Change-Id: I652b095af30cc2732a06829dc23492e5355660da
diff --git a/src/com/android/telecomm/CallAudioManager.java b/src/com/android/telecomm/CallAudioManager.java
index 8156db0..e9008f8 100644
--- a/src/com/android/telecomm/CallAudioManager.java
+++ b/src/com/android/telecomm/CallAudioManager.java
@@ -26,13 +26,14 @@
/**
* This class manages audio modes, streams and other properties.
*/
-final class CallAudioManager extends CallsManagerListenerBase {
+final class CallAudioManager extends CallsManagerListenerBase
+ implements WiredHeadsetManager.Listener {
private static final int STREAM_NONE = -1;
private final StatusBarNotifier mStatusBarNotifier;
private final AudioManager mAudioManager;
- private final WiredHeadsetManager mWiredHeadsetManager;
private final BluetoothManager mBluetoothManager;
+ private final WiredHeadsetManager mWiredHeadsetManager;
private CallAudioState mAudioState;
private int mAudioFocusStreamType;
@@ -40,11 +41,13 @@
private boolean mIsTonePlaying;
private boolean mWasSpeakerOn;
- CallAudioManager(Context context, StatusBarNotifier statusBarNotifier) {
+ CallAudioManager(Context context, StatusBarNotifier statusBarNotifier,
+ WiredHeadsetManager wiredHeadsetManager) {
mStatusBarNotifier = statusBarNotifier;
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- mWiredHeadsetManager = new WiredHeadsetManager(this);
mBluetoothManager = new BluetoothManager(context, this);
+ mWiredHeadsetManager = wiredHeadsetManager;
+
saveAudioState(getInitialAudioState(null));
mAudioFocusStreamType = STREAM_NONE;
}
@@ -107,6 +110,25 @@
updateAudioStreamAndMode();
}
+ /**
+ * Updates the audio route when the headset plugged in state changes. For example, if audio is
+ * being routed over speakerphone and a headset is plugged in then switch to wired headset.
+ */
+ @Override
+ public void onWiredHeadsetPluggedInChanged(boolean oldIsPluggedIn, boolean newIsPluggedIn) {
+ int newRoute = CallAudioState.ROUTE_EARPIECE;
+ if (newIsPluggedIn) {
+ newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
+ } else if (mWasSpeakerOn) {
+ Call call = getForegroundCall();
+ if (call != null && call.isAlive()) {
+ // Restore the speaker state.
+ newRoute = CallAudioState.ROUTE_SPEAKER;
+ }
+ }
+ setSystemAudioState(mAudioState.isMuted, newRoute, calculateSupportedRoutes());
+ }
+
void toggleMute() {
mute(!mAudioState.isMuted);
}
@@ -176,24 +198,6 @@
}
/**
- * Updates the audio route when the headset plugged in state changes. For example, if audio is
- * being routed over speakerphone and a headset is plugged in then switch to wired headset.
- */
- void onHeadsetPluggedInChanged(boolean oldIsPluggedIn, boolean newIsPluggedIn) {
- int newRoute = CallAudioState.ROUTE_EARPIECE;
- if (newIsPluggedIn) {
- newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
- } else if (mWasSpeakerOn) {
- Call call = getForegroundCall();
- if (call != null && call.isAlive()) {
- // Restore the speaker state.
- newRoute = CallAudioState.ROUTE_SPEAKER;
- }
- }
- setSystemAudioState(mAudioState.isMuted, newRoute, calculateSupportedRoutes());
- }
-
- /**
* Updates the audio routing according to the bluetooth state.
*/
void onBluetoothStateChange(BluetoothManager bluetoothManager) {