Loading android/app/jni/com_android_bluetooth_gatt.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -1083,6 +1083,17 @@ static void gattClientReadCharacteristicNative(JNIEnv* env, jobject object, sGattIf->client->read_characteristic(conn_id, handle, authReq); } static void gattClientReadUsingCharacteristicUuidNative( JNIEnv* env, jobject object, jint conn_id, jlong uuid_lsb, jlong uuid_msb, jint s_handle, jint e_handle, jint authReq) { if (!sGattIf) return; bt_uuid_t uuid; set_uuid(uuid.uu, uuid_msb, uuid_lsb); sGattIf->client->read_using_characteristic_uuid(conn_id, &uuid, s_handle, e_handle, authReq); } static void gattClientReadDescriptorNative(JNIEnv* env, jobject object, jint conn_id, jint handle, jint authReq) { Loading Loading @@ -2142,6 +2153,8 @@ static JNINativeMethod sMethods[] = { {"gattClientGetGattDbNative", "(I)V", (void*)gattClientGetGattDbNative}, {"gattClientReadCharacteristicNative", "(III)V", (void*)gattClientReadCharacteristicNative}, {"gattClientReadUsingCharacteristicUuidNative", "(IJJIII)V", (void*)gattClientReadUsingCharacteristicUuidNative}, {"gattClientReadDescriptorNative", "(III)V", (void*)gattClientReadDescriptorNative}, {"gattClientWriteCharacteristicNative", "(IIII[B)V", Loading android/app/src/com/android/bluetooth/gatt/GattService.java +39 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,13 @@ public class GattService extends ProfileService { return true; } boolean permissionCheck(UUID uuid) { if (isRestrictedCharUuid(uuid) && (0 != checkCallingOrSelfPermission(BLUETOOTH_PRIVILEGED))) return false; else return true; } boolean permissionCheck(int connId, int handle) { List<BluetoothGattService> db = gattClientDatabases.get(connId); if (db == null) return true; Loading Loading @@ -426,6 +433,14 @@ public class GattService extends ProfileService { service.readCharacteristic(clientIf, address, handle, authReq); } public void readUsingCharacteristicUuid(int clientIf, String address, ParcelUuid uuid, int startHandle, int endHandle, int authReq) { GattService service = getService(); if (service == null) return; service.readUsingCharacteristicUuid( clientIf, address, uuid.getUuid(), startHandle, endHandle, authReq); } public void writeCharacteristic(int clientIf, String address, int handle, int writeType, int authReq, byte[] value) { GattService service = getService(); Loading Loading @@ -1682,6 +1697,27 @@ public class GattService extends ProfileService { gattClientReadCharacteristicNative(connId, handle, authReq); } void readUsingCharacteristicUuid( int clientIf, String address, UUID uuid, int startHandle, int endHandle, int authReq) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (VDBG) Log.d(TAG, "readUsingCharacteristicUuid() - address=" + address); Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.e(TAG, "readUsingCharacteristicUuid() - No connection for " + address + "..."); return; } if (!permissionCheck(uuid)) { Log.w(TAG, "readUsingCharacteristicUuid() - permission check failed!"); return; } gattClientReadUsingCharacteristicUuidNative(connId, uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), startHandle, endHandle, authReq); } void writeCharacteristic(int clientIf, String address, int handle, int writeType, int authReq, byte[] value) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); Loading Loading @@ -2457,6 +2493,9 @@ public class GattService extends ProfileService { private native void gattClientReadCharacteristicNative(int conn_id, int handle, int authReq); private native void gattClientReadUsingCharacteristicUuidNative( int conn_id, long uuid_msb, long uuid_lsb, int s_handle, int e_handle, int authReq); private native void gattClientReadDescriptorNative(int conn_id, int handle, int authReq); private native void gattClientWriteCharacteristicNative(int conn_id, Loading Loading
android/app/jni/com_android_bluetooth_gatt.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -1083,6 +1083,17 @@ static void gattClientReadCharacteristicNative(JNIEnv* env, jobject object, sGattIf->client->read_characteristic(conn_id, handle, authReq); } static void gattClientReadUsingCharacteristicUuidNative( JNIEnv* env, jobject object, jint conn_id, jlong uuid_lsb, jlong uuid_msb, jint s_handle, jint e_handle, jint authReq) { if (!sGattIf) return; bt_uuid_t uuid; set_uuid(uuid.uu, uuid_msb, uuid_lsb); sGattIf->client->read_using_characteristic_uuid(conn_id, &uuid, s_handle, e_handle, authReq); } static void gattClientReadDescriptorNative(JNIEnv* env, jobject object, jint conn_id, jint handle, jint authReq) { Loading Loading @@ -2142,6 +2153,8 @@ static JNINativeMethod sMethods[] = { {"gattClientGetGattDbNative", "(I)V", (void*)gattClientGetGattDbNative}, {"gattClientReadCharacteristicNative", "(III)V", (void*)gattClientReadCharacteristicNative}, {"gattClientReadUsingCharacteristicUuidNative", "(IJJIII)V", (void*)gattClientReadUsingCharacteristicUuidNative}, {"gattClientReadDescriptorNative", "(III)V", (void*)gattClientReadDescriptorNative}, {"gattClientWriteCharacteristicNative", "(IIII[B)V", Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +39 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,13 @@ public class GattService extends ProfileService { return true; } boolean permissionCheck(UUID uuid) { if (isRestrictedCharUuid(uuid) && (0 != checkCallingOrSelfPermission(BLUETOOTH_PRIVILEGED))) return false; else return true; } boolean permissionCheck(int connId, int handle) { List<BluetoothGattService> db = gattClientDatabases.get(connId); if (db == null) return true; Loading Loading @@ -426,6 +433,14 @@ public class GattService extends ProfileService { service.readCharacteristic(clientIf, address, handle, authReq); } public void readUsingCharacteristicUuid(int clientIf, String address, ParcelUuid uuid, int startHandle, int endHandle, int authReq) { GattService service = getService(); if (service == null) return; service.readUsingCharacteristicUuid( clientIf, address, uuid.getUuid(), startHandle, endHandle, authReq); } public void writeCharacteristic(int clientIf, String address, int handle, int writeType, int authReq, byte[] value) { GattService service = getService(); Loading Loading @@ -1682,6 +1697,27 @@ public class GattService extends ProfileService { gattClientReadCharacteristicNative(connId, handle, authReq); } void readUsingCharacteristicUuid( int clientIf, String address, UUID uuid, int startHandle, int endHandle, int authReq) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (VDBG) Log.d(TAG, "readUsingCharacteristicUuid() - address=" + address); Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.e(TAG, "readUsingCharacteristicUuid() - No connection for " + address + "..."); return; } if (!permissionCheck(uuid)) { Log.w(TAG, "readUsingCharacteristicUuid() - permission check failed!"); return; } gattClientReadUsingCharacteristicUuidNative(connId, uuid.getLeastSignificantBits(), uuid.getMostSignificantBits(), startHandle, endHandle, authReq); } void writeCharacteristic(int clientIf, String address, int handle, int writeType, int authReq, byte[] value) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); Loading Loading @@ -2457,6 +2493,9 @@ public class GattService extends ProfileService { private native void gattClientReadCharacteristicNative(int conn_id, int handle, int authReq); private native void gattClientReadUsingCharacteristicUuidNative( int conn_id, long uuid_msb, long uuid_lsb, int s_handle, int e_handle, int authReq); private native void gattClientReadDescriptorNative(int conn_id, int handle, int authReq); private native void gattClientWriteCharacteristicNative(int conn_id, Loading