LA.UM.7.6.2/LINUX/android/frameworks/base/telecomm/java/android/telecom/InCallService.java
index f3af514..6cbed0c 100644
@@ -44,4 +44,7 @@ import java.io.BufferedReader;
import java.io.FileReader;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+
/**
* This service is implemented by any app that wishes to provide the user-interface for managing
@@ -107,4 +110,7 @@ public abstract class InCallService extends Service {
private static final int MSG_ON_HANDOVER_FAILED = 12;
private static final int MSG_ON_HANDOVER_COMPLETE = 13;
+
+ //private static AudioState mPrevAudioState;
+ private final BroadcastReceiver mReceiver = new InCallServiceBroadcastReceiver();
private static final String CRADLE_CHARGING_NODE = "/sys/class/switchs/dock/state";
@@ -135,4 +141,37 @@ public abstract class InCallService extends Service {
}
+ /**
+ * Receiver for misc intent broadcasts the Phone app cares about.
+ */
+ private class InCallServiceBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+
+ if (action.equals(Intent.ACTION_DOCK_EVENT)) {
+ if(!getCalls().isEmpty()) {
+ int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
+ Intent.EXTRA_DOCK_STATE_UNDOCKED);
+ android.util.Log.d("heyimin","phone is inCall :: dockState = " + dockState);
+ switch (dockState) {
+ case Intent.EXTRA_DOCK_STATE_DESK:
+ case Intent.EXTRA_DOCK_STATE_CAR:
+ case Intent.EXTRA_DOCK_STATE_LE_DESK:
+ case Intent.EXTRA_DOCK_STATE_HE_DESK:
+ setAudioRoute(CallAudioState.ROUTE_SPEAKER);
+ android.util.Log.d("heyimin","state change to dock :: setAudioRoute to ROUTE_SPEAKER");
+ break;
+ case Intent.EXTRA_DOCK_STATE_UNDOCKED:
+ default:
+ setAudioRoute(CallAudioState.ROUTE_WIRED_OR_EARPIECE);
+ android.util.Log.d("heyimin","state change to undock :: setAudioRoute to ROUTE_WIRED_OR_EARPIECE");
+ }
+ } else {
+ android.util.Log.d("heyimin","phone is not InCall, do nothing...");
+ }
+ }
+ }
+ } // end class InCallServiceBroadcastReceiver
+
/** Default Handler used to consolidate binder method calls onto a single thread. */
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@@ -150,7 +189,7 @@ public abstract class InCallService extends Service {
mPhone.addListener(mPhoneListener);
onPhoneCreated(mPhone);
-
if (getCradleStatus()) {
setAudioRoute(CallAudioState.ROUTE_SPEAKER);
+ android.util.Log.d("heyimin","set in call :: CradleStatus = true, setAudioRoute to ROUTE_SPEAKER");
}
break;
require to switch to the speaker mode when the call is in the dock mode
最新推荐文章于 2024-11-04 11:45:54 发布