Loading android/app/jni/com_android_bluetooth_gatt.cpp +20 −1 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ static jmethodID method_onGetIncludedService; static jmethodID method_onRegisterForNotifications; static jmethodID method_onReadRemoteRssi; static jmethodID method_onAdvertiseCallback; static jmethodID method_onConfigureMTU; /** * Server callback methods Loading Loading @@ -430,6 +431,14 @@ void btgattc_advertise_cb(int status, int client_if) checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } void btgattc_configure_mtu_cb(int conn_id, int status, int mtu) { CHECK_CALLBACK_ENV sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConfigureMTU, conn_id, status, mtu); checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_register_app_cb, btgattc_scan_result_cb, Loading @@ -448,7 +457,8 @@ static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_write_descriptor_cb, btgattc_execute_write_cb, btgattc_remote_rssi_cb, btgattc_advertise_cb btgattc_advertise_cb, btgattc_configure_mtu_cb, }; Loading Loading @@ -663,6 +673,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onGetIncludedService = env->GetMethodID(clazz, "onGetIncludedService", "(IIIIJJIIJJ)V"); method_onRegisterForNotifications = env->GetMethodID(clazz, "onRegisterForNotifications", "(IIIIIJJIJJ)V"); method_onReadRemoteRssi = env->GetMethodID(clazz, "onReadRemoteRssi", "(ILjava/lang/String;II)V"); method_onConfigureMTU = env->GetMethodID(clazz, "onConfigureMTU", "(III)V"); // Server callbacks Loading Loading @@ -1090,6 +1101,13 @@ static void gattSetAdvDataNative(JNIEnv *env, jobject object, jint client_if, jb } static void gattClientConfigureMTUNative(JNIEnv *env, jobject object, jint conn_id, jint mtu) { if (!sGattIf) return; sGattIf->client->configure_mtu(conn_id, mtu); } /** * Native server functions */ Loading Loading @@ -1303,6 +1321,7 @@ static JNINativeMethod sMethods[] = { {"gattClientRegisterForNotificationsNative", "(ILjava/lang/String;IIJJIJJZ)V", (void *) gattClientRegisterForNotificationsNative}, {"gattClientReadRemoteRssiNative", "(ILjava/lang/String;)V", (void *) gattClientReadRemoteRssiNative}, {"gattAdvertiseNative", "(IZ)V", (void *) gattAdvertiseNative}, {"gattClientConfigureMTUNative", "(II)V", (void *) gattClientConfigureMTUNative}, {"gattServerRegisterAppNative", "(JJ)V", (void *) gattServerRegisterAppNative}, {"gattServerUnregisterAppNative", "(I)V", (void *) gattServerUnregisterAppNative}, Loading android/app/src/com/android/bluetooth/gatt/GattService.java +32 −0 Original line number Diff line number Diff line Loading @@ -415,6 +415,12 @@ public class GattService extends ProfileService { service.readRemoteRssi(clientIf, address); } public void configureMTU(int clientIf, String address, int mtu) { GattService service = getService(); if (service == null) return; service.configureMTU(clientIf, address, mtu); } public void registerServer(ParcelUuid uuid, IBluetoothGattServerCallback callback) { GattService service = getService(); if (service == null) return; Loading Loading @@ -968,6 +974,18 @@ public class GattService extends ProfileService { app.callback.onAdvertiseStateChange(mAdvertisingState, status); } void onConfigureMTU(int connId, int status, int mtu) throws RemoteException { String address = mClientMap.addressByConnId(connId); if (DBG) Log.d(TAG, "onConfigureMTU() address=" + address + ", status=" + status + ", mtu=" + mtu); ClientMap.App app = mClientMap.getByConnId(connId); if (app != null) { app.callback.onConfigureMTU(address, mtu, status); } } /************************************************************************** * GATT Service functions - Shared CLIENT/SERVER *************************************************************************/ Loading Loading @@ -1384,6 +1402,18 @@ public class GattService extends ProfileService { gattClientReadRemoteRssiNative(clientIf, address); } void configureMTU(int clientIf, String address, int mtu) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (DBG) Log.d(TAG, "configureMTU() - address=" + address + " mtu=" + mtu); Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId != null) { gattClientConfigureMTUNative(connId, mtu); } else { Log.e(TAG, "configureMTU() - No connection for " + address + "..."); } } /************************************************************************** * Callback functions - SERVER *************************************************************************/ Loading Loading @@ -2051,6 +2081,8 @@ public class GattService extends ProfileService { private native void gattAdvertiseNative(int client_if, boolean start); private native void gattClientConfigureMTUNative(int conn_id, int mtu); private native void gattSetAdvDataNative(int serverIf, boolean setScanRsp, boolean inclName, boolean inclTxPower, int minInterval, int maxInterval, int appearance, byte[] manufacturerData, byte[] serviceData, byte[] serviceUuid); Loading Loading
android/app/jni/com_android_bluetooth_gatt.cpp +20 −1 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ static jmethodID method_onGetIncludedService; static jmethodID method_onRegisterForNotifications; static jmethodID method_onReadRemoteRssi; static jmethodID method_onAdvertiseCallback; static jmethodID method_onConfigureMTU; /** * Server callback methods Loading Loading @@ -430,6 +431,14 @@ void btgattc_advertise_cb(int status, int client_if) checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } void btgattc_configure_mtu_cb(int conn_id, int status, int mtu) { CHECK_CALLBACK_ENV sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConfigureMTU, conn_id, status, mtu); checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_register_app_cb, btgattc_scan_result_cb, Loading @@ -448,7 +457,8 @@ static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_write_descriptor_cb, btgattc_execute_write_cb, btgattc_remote_rssi_cb, btgattc_advertise_cb btgattc_advertise_cb, btgattc_configure_mtu_cb, }; Loading Loading @@ -663,6 +673,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onGetIncludedService = env->GetMethodID(clazz, "onGetIncludedService", "(IIIIJJIIJJ)V"); method_onRegisterForNotifications = env->GetMethodID(clazz, "onRegisterForNotifications", "(IIIIIJJIJJ)V"); method_onReadRemoteRssi = env->GetMethodID(clazz, "onReadRemoteRssi", "(ILjava/lang/String;II)V"); method_onConfigureMTU = env->GetMethodID(clazz, "onConfigureMTU", "(III)V"); // Server callbacks Loading Loading @@ -1090,6 +1101,13 @@ static void gattSetAdvDataNative(JNIEnv *env, jobject object, jint client_if, jb } static void gattClientConfigureMTUNative(JNIEnv *env, jobject object, jint conn_id, jint mtu) { if (!sGattIf) return; sGattIf->client->configure_mtu(conn_id, mtu); } /** * Native server functions */ Loading Loading @@ -1303,6 +1321,7 @@ static JNINativeMethod sMethods[] = { {"gattClientRegisterForNotificationsNative", "(ILjava/lang/String;IIJJIJJZ)V", (void *) gattClientRegisterForNotificationsNative}, {"gattClientReadRemoteRssiNative", "(ILjava/lang/String;)V", (void *) gattClientReadRemoteRssiNative}, {"gattAdvertiseNative", "(IZ)V", (void *) gattAdvertiseNative}, {"gattClientConfigureMTUNative", "(II)V", (void *) gattClientConfigureMTUNative}, {"gattServerRegisterAppNative", "(JJ)V", (void *) gattServerRegisterAppNative}, {"gattServerUnregisterAppNative", "(I)V", (void *) gattServerUnregisterAppNative}, Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +32 −0 Original line number Diff line number Diff line Loading @@ -415,6 +415,12 @@ public class GattService extends ProfileService { service.readRemoteRssi(clientIf, address); } public void configureMTU(int clientIf, String address, int mtu) { GattService service = getService(); if (service == null) return; service.configureMTU(clientIf, address, mtu); } public void registerServer(ParcelUuid uuid, IBluetoothGattServerCallback callback) { GattService service = getService(); if (service == null) return; Loading Loading @@ -968,6 +974,18 @@ public class GattService extends ProfileService { app.callback.onAdvertiseStateChange(mAdvertisingState, status); } void onConfigureMTU(int connId, int status, int mtu) throws RemoteException { String address = mClientMap.addressByConnId(connId); if (DBG) Log.d(TAG, "onConfigureMTU() address=" + address + ", status=" + status + ", mtu=" + mtu); ClientMap.App app = mClientMap.getByConnId(connId); if (app != null) { app.callback.onConfigureMTU(address, mtu, status); } } /************************************************************************** * GATT Service functions - Shared CLIENT/SERVER *************************************************************************/ Loading Loading @@ -1384,6 +1402,18 @@ public class GattService extends ProfileService { gattClientReadRemoteRssiNative(clientIf, address); } void configureMTU(int clientIf, String address, int mtu) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (DBG) Log.d(TAG, "configureMTU() - address=" + address + " mtu=" + mtu); Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId != null) { gattClientConfigureMTUNative(connId, mtu); } else { Log.e(TAG, "configureMTU() - No connection for " + address + "..."); } } /************************************************************************** * Callback functions - SERVER *************************************************************************/ Loading Loading @@ -2051,6 +2081,8 @@ public class GattService extends ProfileService { private native void gattAdvertiseNative(int client_if, boolean start); private native void gattClientConfigureMTUNative(int conn_id, int mtu); private native void gattSetAdvDataNative(int serverIf, boolean setScanRsp, boolean inclName, boolean inclTxPower, int minInterval, int maxInterval, int appearance, byte[] manufacturerData, byte[] serviceData, byte[] serviceUuid); Loading