summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
diff options
context:
space:
mode:
authorSumit Bajpai <sbajpai@codeaurora.org>2015-06-09 18:58:47 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:25:52 -0600
commitaa20b98ddb70c4377b1b07405123f117d7477889 (patch)
tree4c2c53d60f19723e1305cf89801ebfff8819170f /src/com/android/bluetooth/hfp/HeadsetStateMachine.java
parente9b5ace257010e5b6dc325159a980f09a6437630 (diff)
downloadandroid_packages_apps_Bluetooth-aa20b98ddb70c4377b1b07405123f117d7477889.tar.gz
android_packages_apps_Bluetooth-aa20b98ddb70c4377b1b07405123f117d7477889.tar.bz2
android_packages_apps_Bluetooth-aa20b98ddb70c4377b1b07405123f117d7477889.zip
BT:[3/3] Send VSC to SOC for VOIP connectivity network type.
- Get Connectivity Manager instance to find current active network when VOIP requests BT app to create SCO. - If active connectivity network is WIFI, update same to SOC via vendor specific command before sending SCO request for VOIP CRs-Fixed: 821566 Change-Id: I5835e71b533e00a6e4b82607b10657ef311877ae
Diffstat (limited to 'src/com/android/bluetooth/hfp/HeadsetStateMachine.java')
-rw-r--r--src/com/android/bluetooth/hfp/HeadsetStateMachine.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 13f544d5f..2ac722fbb 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -49,6 +49,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.ActivityNotFoundException;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.media.AudioManager;
import android.net.Uri;
import android.os.IBinder;
@@ -171,6 +173,7 @@ final class HeadsetStateMachine extends StateMachine {
private boolean mWaitingForVoiceRecognition = false;
private WakeLock mStartVoiceRecognitionWakeLock; // held while waiting for voice recognition
+ private ConnectivityManager mConnectivityManager;
private boolean mDialingOut = false;
private AudioManager mAudioManager;
private AtPhonebook mPhonebook;
@@ -239,6 +242,9 @@ final class HeadsetStateMachine extends StateMachine {
TAG + ":VoiceRecognition");
mStartVoiceRecognitionWakeLock.setReferenceCounted(false);
+ mConnectivityManager = (ConnectivityManager)
+ context.getSystemService(Context.CONNECTIVITY_SERVICE);
+
mDialingOut = false;
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
mPhonebook = new AtPhonebook(mService, this);
@@ -2802,6 +2808,10 @@ final class HeadsetStateMachine extends StateMachine {
return false;
}
setVirtualCallInProgress(true);
+
+ // 2. Update the connectivity network type to controller for CxM optimisation.
+ sendVoipConnectivityNetworktype(true);
+
if (mA2dpState == BluetoothProfile.STATE_CONNECTED) {
mAudioManager.setParameters("A2dpSuspended=true");
mA2dpSuspend = true;
@@ -2812,8 +2822,7 @@ final class HeadsetStateMachine extends StateMachine {
}
}
-
- // 2. Send virtual phone state changed to initialize SCO
+ // 3. Send virtual phone state changed to initialize SCO
processCallState(new HeadsetCallState(0, 0,
HeadsetHalConstants.CALL_STATE_DIALING, "", 0), true);
processCallState(new HeadsetCallState(0, 0,
@@ -2838,6 +2847,8 @@ final class HeadsetStateMachine extends StateMachine {
processCallState(new HeadsetCallState(0, 0,
HeadsetHalConstants.CALL_STATE_IDLE, "", 0), true);
setVirtualCallInProgress(false);
+ sendVoipConnectivityNetworktype(false);
+
// Virtual call is Ended set A2dpSuspended to false
if (mA2dpSuspend) {
log("Virtual call ended, set A2dpSuspended=false");
@@ -3834,6 +3845,23 @@ final class HeadsetStateMachine extends StateMachine {
return ret;
}
+ private void sendVoipConnectivityNetworktype(boolean isVoipStarted) {
+ NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
+ if (networkInfo == null || !networkInfo.isAvailable() || !networkInfo.isConnected()) {
+ Log.e(TAG, "No connected/available connectivity network, don't update soc");
+ return;
+ }
+
+ if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+ log("Voip started/stopped on n/w TYPE_MOBILE, don't update to soc");
+ } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+ log("Voip started/stopped on n/w TYPE_WIFI, update n/w type & start/stop to soc");
+ voipNetworkWifiInfoNative(isVoipStarted, true);
+ } else {
+ log("Voip started/stopped on some other n/w, don't update to soc");
+ }
+ }
+
@Override
protected void log(String msg) {
if (DBG) {
@@ -3954,4 +3982,7 @@ final class HeadsetStateMachine extends StateMachine {
private native boolean bindResponseNative(int anum, boolean state, byte[] address);
private native boolean bindStringResponseNative(String result, byte[] address);
+
+ private native boolean voipNetworkWifiInfoNative(boolean isVoipStarted,
+ boolean isNetworkWifi);
}