Fix b/20489973 for Telecom audio routing in sl4a
Change-Id: Ib5adafa8210de0e67615daf7ecf7e64c36768eb7
diff --git a/Common/src/com/googlecode/android_scripting/facade/tele/TelecomManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/tele/TelecomManagerFacade.java
index a5f3f95..d843f30 100644
--- a/Common/src/com/googlecode/android_scripting/facade/tele/TelecomManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/tele/TelecomManagerFacade.java
@@ -276,21 +276,29 @@
@Rpc(description = "Sets the audio route (SPEAKER, BLUETOOTH, etc...).")
public void telecomPhoneSetAudioRoute(
- @RpcParameter(name = "route")
+ @RpcParameter(name = "route")
String route) {
int r = 0;
- if (route == "BLUETOOTH") {
+ if (route.equals("BLUETOOTH")) {
r = AudioState.ROUTE_BLUETOOTH;
- } else if (route == "EARPIECE") {
+ } else if (route.equals("EARPIECE")) {
r = AudioState.ROUTE_EARPIECE;
- } else if (route == "SPEAKER") {
+ } else if (route.equals("SPEAKER")) {
r = AudioState.ROUTE_SPEAKER;
- } else if (route == "WIRED_HEADSET") {
+ } else if (route.equals("WIRED_HEADSET")) {
r = AudioState.ROUTE_WIRED_HEADSET;
- } else if (route == "WIRED_OR_EARPIECE") {
+ } else if (route.equals("WIRED_OR_EARPIECE")) {
r = AudioState.ROUTE_WIRED_OR_EARPIECE;
}
- InCallServiceImpl.mPhone.setAudioRoute(r);
+ else {
+ Log.d("Failed to find a translation for audio route.");
+ return;
+ }
+
+ Log.d(String.format("Setting Audio route to %d", r));
+ if (InCallServiceImpl.mPhone != null) {
+ InCallServiceImpl.mPhone.setAudioRoute(r);
+ }
}
@Rpc(description = "Turns the proximity sensor off. If screenOnImmediately is true, the screen will be turned on immediately")