Audio routing part 2
- Added WIRED_HEADSET and SPEAKER to AudioModes
- Added WiredHeadsetManager class
- AudioRouter now listens to WiredHeadsetManager and PhoneUtils for
speakerphone
- AudioRouter maintains state across earpiece,headset,bluetooth,speaker
- Most code copied from InCallScreen for speaker logic
- CallHandlerService listens to audioRouter for audio states
- Moved Wired headset logic from phoneglobals to wiredheadsetmanager
- Better toString for logging Call objects
Change-Id: Iebc8c83934ce5eff6f1918b0610804fadb163b43
diff --git a/common/Android.mk b/common/Android.mk
index 972ed39..2667e45 100644
--- a/common/Android.mk
+++ b/common/Android.mk
@@ -16,6 +16,8 @@
include $(CLEAR_VARS)
+LOCAL_STATIC_JAVA_LIBRARIES := guava
+
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
$(call all-Iaidl-files-under, src)
diff --git a/common/src/com/android/services/telephony/common/AudioMode.java b/common/src/com/android/services/telephony/common/AudioMode.java
index f296a93..b0043ef 100644
--- a/common/src/com/android/services/telephony/common/AudioMode.java
+++ b/common/src/com/android/services/telephony/common/AudioMode.java
@@ -21,10 +21,13 @@
*/
public class AudioMode {
// These can be used as a bit mask
- public static int EARPIECE = 0x00000001;
- public static int BLUETOOTH = 0x00000002;
+ public static int EARPIECE = 0x00000001;
+ public static int BLUETOOTH = 0x00000002;
+ public static int WIRED_HEADSET = 0x00000004;
+ public static int SPEAKER = 0x00000008;
- public static int ALL_MODES = EARPIECE | BLUETOOTH;
+ public static int WIRED_OR_EARPIECE = EARPIECE | WIRED_HEADSET;
+ public static int ALL_MODES = EARPIECE | BLUETOOTH | WIRED_HEADSET | SPEAKER;
public static String toString(int mode) {
if ((mode & ~ALL_MODES) != 0x0) {
@@ -38,6 +41,12 @@
if ((mode & BLUETOOTH) == BLUETOOTH) {
listAppend(buffer, "BLUETOOTH");
}
+ if ((mode & WIRED_HEADSET) == WIRED_HEADSET) {
+ listAppend(buffer, "WIRED_HEADSET");
+ }
+ if ((mode & SPEAKER) == SPEAKER) {
+ listAppend(buffer, "SPEAKER");
+ }
return buffer.toString();
}
diff --git a/common/src/com/android/services/telephony/common/Call.java b/common/src/com/android/services/telephony/common/Call.java
index 68b493f..a3ba003 100644
--- a/common/src/com/android/services/telephony/common/Call.java
+++ b/common/src/com/android/services/telephony/common/Call.java
@@ -16,9 +16,14 @@
package com.android.services.telephony.common;
+import com.google.common.collect.ImmutableMap;
+
import android.os.Parcel;
import android.os.Parcelable;
+import java.nio.Buffer;
+import java.util.Map;
+
import com.android.internal.telephony.PhoneConstants;
/**
@@ -52,6 +57,16 @@
public static final int ONHOLD = 6;
}
+ private static final Map<Integer, String> STATE_MAP = ImmutableMap.<Integer, String>builder()
+ .put(Call.State.ACTIVE, "ACTIVE")
+ .put(Call.State.CALL_WAITING, "CALL_WAITING")
+ .put(Call.State.DIALING, "DIALING")
+ .put(Call.State.IDLE, "IDLE")
+ .put(Call.State.INCOMING, "INCOMING")
+ .put(Call.State.ONHOLD, "ONHOLD")
+ .put(Call.State.INVALID, "INVALID")
+ .build();
+
// Number presentation type for caller id display
// normal
public static int PRESENTATION_ALLOWED = PhoneConstants.PRESENTATION_ALLOWED;
@@ -157,4 +172,13 @@
mCnapName = in.readString();
}
+ @Override
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("callId: ");
+ buffer.append(mCallId);
+ buffer.append(", state: ");
+ buffer.append(STATE_MAP.get(mState));
+ return buffer.toString();
+ }
}
diff --git a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
index 33055c5..4b6f913 100644
--- a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
+++ b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
@@ -61,5 +61,5 @@
* Called when the supported audio modes change.
* {@see AudioMode}
*/
- void onAudioModeSupportChange(in int modeMask);
+ void onSupportedAudioModeChange(in int modeMask);
}