Bluetooth: Handle SSR properly [2/3]
- In SSR case , BT process was killed abruptly
results in profile service getting restart
randomly and leading to JNI exceptions.
- This patch will handle SSR properly.
CRs-Fixed: 2409509
Change-Id: Iafdf4ce6b21d55c212b9a124755972e84ec71e06
diff --git a/packages_apps_bluetooth_ext/jni/com_android_bluetooth_btservice_vendor.cpp b/packages_apps_bluetooth_ext/jni/com_android_bluetooth_btservice_vendor.cpp
index 8e92d96..403df02 100644
--- a/packages_apps_bluetooth_ext/jni/com_android_bluetooth_btservice_vendor.cpp
+++ b/packages_apps_bluetooth_ext/jni/com_android_bluetooth_btservice_vendor.cpp
@@ -64,6 +64,7 @@
static jmethodID method_iotDeviceBroadcast;
static jmethodID method_devicePropertyChangedCallback;
static jmethodID method_adapterPropertyChangedCallback;
+static jmethodID method_ssrCleanupCallback;
static btvendor_interface_t *sBluetoothVendorInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -116,6 +117,16 @@
sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onBredrCleanup, (jboolean)status);
}
+static void ssr_cleanup_callback(void){
+
+ ALOGI("%s", __FUNCTION__);
+ CallbackEnv sCallbackEnv(__func__);
+
+ if (!sCallbackEnv.valid()) return;
+
+ sCallbackEnv->CallVoidMethod(mCallbacksObj, method_ssrCleanupCallback);
+}
+
static void iot_device_broadcast_callback(RawAddress* bd_addr, uint16_t error,
uint16_t error_info, uint32_t event_mask, uint8_t lmp_ver, uint16_t lmp_subver,
uint16_t manufacturer_id, uint8_t power_level, int8_t rssi, uint8_t link_quality,
@@ -236,6 +247,7 @@
remote_device_properties_callback,
NULL,
adapter_vendor_properties_callback,
+ ssr_cleanup_callback,
};
static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -246,6 +258,8 @@
clazz, "devicePropertyChangedCallback", "([B[I[[B)V");
method_adapterPropertyChangedCallback = env->GetMethodID(
clazz, "adapterPropertyChangedCallback", "([I[[B)V");
+ method_ssrCleanupCallback = env->GetMethodID(
+ clazz, "ssr_cleanup_callback", "()V");
ALOGI("%s: succeeds", __FUNCTION__);
}
diff --git a/packages_apps_bluetooth_ext/src/btservice/Vendor.java b/packages_apps_bluetooth_ext/src/btservice/Vendor.java
index ca22e55..b363eb2 100644
--- a/packages_apps_bluetooth_ext/src/btservice/Vendor.java
+++ b/packages_apps_bluetooth_ext/src/btservice/Vendor.java
@@ -150,6 +150,12 @@
intent.putExtra(BluetoothDevice.EXTRA_GLITCH_COUNT, glitchCount);
mService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM);
}
+
+ void ssr_cleanup_callback() {
+ Log.e(TAG,"ssr_cleanup_callback");
+ mService.ssrCleanupCallback();
+ }
+
void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] values) {
byte[] val;
int type;
diff --git a/vhal/include/hardware/vendor.h b/vhal/include/hardware/vendor.h
index f854702..2b6be6f 100644
--- a/vhal/include/hardware/vendor.h
+++ b/vhal/include/hardware/vendor.h
@@ -124,6 +124,9 @@
RawAddress *bd_addr, int num_properties,
bt_vendor_property_t *properties);
+/** Callback to handle SSR */
+typedef void (* ssr_vendor_callback)(void);
+
/** Bluetooth HCI event Callback */
/* Receive any HCI event from controller for raw commands */
typedef void (* hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len);
@@ -143,6 +146,7 @@
remote_dev_prop_callback rmt_dev_prop_cb;
hci_event_recv_callback hci_event_recv_cb;
adapter_vendor_prop_callback adapter_vendor_prop_cb;
+ ssr_vendor_callback ssr_vendor_cb;
} btvendor_callbacks_t;
typedef int (*property_set_callout)(const char* key, const char* value);