OSDN Git Service

DO NOT MERGE ANYWHERE Publish AG audio route policy to native layers
authorZach Johnson <zachoverflow@google.com>
Wed, 19 Apr 2017 04:22:34 +0000 (21:22 -0700)
committerZach Johnson <zachoverflow@google.com>
Fri, 21 Apr 2017 17:15:57 +0000 (17:15 +0000)
Bug: 32958838
Test: manual
Change-Id: I97ec6e38b4f3243548732d2af644d6f0ad894e97

jni/com_android_bluetooth_hfp.cpp
src/com/android/bluetooth/hfp/HeadsetStateMachine.java

index 3b6c2ce..42111a9 100644 (file)
@@ -849,6 +849,17 @@ static jboolean configureWBSNative(JNIEnv *env, jobject object, jbyteArray addre
     return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
 }
 
+static jboolean setScoAllowedNative(JNIEnv *env, jobject object, jboolean value) {
+    bt_status_t status;
+
+    if (!sBluetoothHfpInterface) return JNI_FALSE;
+
+    if ((status = sBluetoothHfpInterface->set_sco_allowed(
+                      value == JNI_TRUE)) != BT_STATUS_SUCCESS) {
+        ALOGE("Failed HF set sco allowed, status: %d", status);
+    }
+    return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
+}
 
 static JNINativeMethod sMethods[] = {
     {"classInitNative", "()V", (void *) classInitNative},
@@ -870,6 +881,7 @@ static JNINativeMethod sMethods[] = {
     {"clccResponseNative", "(IIIIZLjava/lang/String;I[B)Z", (void *) clccResponseNative},
     {"phoneStateChangeNative", "(IIILjava/lang/String;I)Z", (void *) phoneStateChangeNative},
     {"configureWBSNative", "([BI)Z", (void *) configureWBSNative},
+    {"setScoAllowedNative", "(Z)Z", (void *) setScoAllowedNative},
 };
 
 int register_com_android_bluetooth_hfp(JNIEnv* env)
index eb2cdbc..4762c3c 100644 (file)
@@ -2197,6 +2197,7 @@ final class HeadsetStateMachine extends StateMachine {
 
     public void setAudioRouteAllowed(boolean allowed) {
         mAudioRouteAllowed = allowed;
+        setScoAllowedNative(allowed);
     }
 
     public boolean getAudioRouteAllowed() {
@@ -3566,4 +3567,5 @@ final class HeadsetStateMachine extends StateMachine {
     private native boolean phoneStateChangeNative(int numActive, int numHeld, int callState,
                                                   String number, int type);
     private native boolean configureWBSNative(byte[] address,int condec_config);
+    private native boolean setScoAllowedNative(boolean value);
 }