Loading android/app/jni/com_android_bluetooth_gatt.cpp +42 −22 Original line number Diff line number Diff line Loading @@ -848,7 +848,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onGetGattDb = env->GetMethodID(clazz, "onGetGattDb", "(ILjava/util/ArrayList;)V"); method_onClientPhyRead = env->GetMethodID(clazz, "onClientPhyRead", "(IIII)V"); env->GetMethodID(clazz, "onClientPhyRead", "(ILjava/lang/String;III)V"); method_onClientPhyUpdate = env->GetMethodID(clazz, "onClientPhyUpdate", "(IIII)V"); method_onClientConnUpdate = Loading Loading @@ -884,7 +884,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { env->GetMethodID(clazz, "onServerCongestion", "(IZ)V"); method_onServerMtuChanged = env->GetMethodID(clazz, "onMtuChanged", "(II)V"); method_onServerPhyRead = env->GetMethodID(clazz, "onServerPhyRead", "(IIII)V"); env->GetMethodID(clazz, "onServerPhyRead", "(ILjava/lang/String;III)V"); method_onServerPhyUpdate = env->GetMethodID(clazz, "onServerPhyUpdate", "(IIII)V"); method_onServerConnUpdate = Loading Loading @@ -1027,26 +1027,35 @@ static void gattClientDisconnectNative(JNIEnv* env, jobject object, } static void gattClientSetPreferredPhyNative(JNIEnv* env, jobject object, jint clientIf, jint conn_id, jint clientIf, jstring address, jint tx_phy, jint rx_phy, jint phy_options) { if (!sGattIf) return; sGattIf->client->set_preferred_phy(conn_id, tx_phy, rx_phy, phy_options); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->set_preferred_phy(bda, tx_phy, rx_phy, phy_options); } static void readClientPhyCb(int conn_id, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { static void readClientPhyCb(uint8_t clientIf, bt_bdaddr_t bda, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientPhyRead, conn_id, tx_phy, rx_phy, status); ScopedLocalRef<jstring> address(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &bda)); sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientPhyRead, clientIf, address.get(), tx_phy, rx_phy, status); } static void gattClientReadPhyNative(JNIEnv* env, jobject object, jint clientIf, jint conn_id) { jstring address) { if (!sGattIf) return; sGattIf->client->read_phy(conn_id, base::Bind(readClientPhyCb, conn_id)); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->read_phy(bda, base::Bind(&readClientPhyCb, clientIf, bda)); } static void gattClientRefreshNative(JNIEnv* env, jobject object, jint clientIf, Loading @@ -1055,6 +1064,7 @@ static void gattClientRefreshNative(JNIEnv* env, jobject object, jint clientIf, bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->refresh(clientIf, &bda); } Loading Loading @@ -1535,26 +1545,34 @@ static void gattServerDisconnectNative(JNIEnv* env, jobject object, } static void gattServerSetPreferredPhyNative(JNIEnv* env, jobject object, jint serverIf, jint conn_id, jint serverIf, jstring address, jint tx_phy, jint rx_phy, jint phy_options) { if (!sGattIf) return; sGattIf->server->set_preferred_phy(conn_id, tx_phy, rx_phy, phy_options); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->server->set_preferred_phy(bda, tx_phy, rx_phy, phy_options); } static void readServerPhyCb(int conn_id, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { static void readServerPhyCb(uint8_t serverIf, bt_bdaddr_t bda, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerPhyRead, conn_id, tx_phy, rx_phy, status); ScopedLocalRef<jstring> address(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &bda)); sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerPhyRead, serverIf, address.get(), tx_phy, rx_phy, status); } static void gattServerReadPhyNative(JNIEnv* env, jobject object, jint serverIf, jint conn_id) { jstring address) { if (!sGattIf) return; sGattIf->server->read_phy(conn_id, base::Bind(readServerPhyCb, conn_id)); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->server->read_phy(bda, base::Bind(&readServerPhyCb, serverIf, bda)); } static void gattServerAddServiceNative(JNIEnv* env, jobject object, Loading Loading @@ -2176,9 +2194,10 @@ static JNINativeMethod sMethods[] = { (void*)gattClientConnectNative}, {"gattClientDisconnectNative", "(ILjava/lang/String;I)V", (void*)gattClientDisconnectNative}, {"gattClientSetPreferredPhyNative", "(IIIII)V", {"gattClientSetPreferredPhyNative", "(ILjava/lang/String;III)V", (void*)gattClientSetPreferredPhyNative}, {"gattClientReadPhyNative", "(II)V", (void*)gattClientReadPhyNative}, {"gattClientReadPhyNative", "(ILjava/lang/String;)V", (void*)gattClientReadPhyNative}, {"gattClientRefreshNative", "(ILjava/lang/String;)V", (void*)gattClientRefreshNative}, {"gattClientSearchServiceNative", "(IZJJ)V", Loading Loading @@ -2214,9 +2233,10 @@ static JNINativeMethod sMethods[] = { (void*)gattServerConnectNative}, {"gattServerDisconnectNative", "(ILjava/lang/String;I)V", (void*)gattServerDisconnectNative}, {"gattServerSetPreferredPhyNative", "(IIIII)V", {"gattServerSetPreferredPhyNative", "(ILjava/lang/String;III)V", (void*)gattServerSetPreferredPhyNative}, {"gattServerReadPhyNative", "(II)V", (void*)gattServerReadPhyNative}, {"gattServerReadPhyNative", "(ILjava/lang/String;)V", (void*)gattServerReadPhyNative}, {"gattServerAddServiceNative", "(ILjava/util/List;)V", (void*)gattServerAddServiceNative}, {"gattServerStopServiceNative", "(II)V", Loading android/app/src/com/android/bluetooth/gatt/GattService.java +26 −16 Original line number Diff line number Diff line Loading @@ -934,11 +934,17 @@ public class GattService extends ProfileService { app.callback.onPhyUpdate(address, txPhy, rxPhy, status); } void onClientPhyRead(int connId, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onClientPhyRead() - connId=" + connId + ", status=" + status); void onClientPhyRead(int clientIf, String address, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onClientPhyRead() - address=" + address + ", status=" + status + ", clientIf=" + clientIf); String address = mClientMap.addressByConnId(connId); if (address == null) return; Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "onClientPhyRead() - no connection to " + address); return; } ClientMap.App app = mClientMap.getByConnId(connId); if (app == null) return; Loading Loading @@ -971,11 +977,15 @@ public class GattService extends ProfileService { app.callback.onPhyUpdate(address, txPhy, rxPhy, status); } void onServerPhyRead(int connId, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onServerPhyRead() - connId=" + connId + ", status=" + status); void onServerPhyRead(int serverIf, String address, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onServerPhyRead() - address=" + address + ", status=" + status); String address = mServerMap.addressByConnId(connId); if (address == null) return; Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "onServerPhyRead() - no connection to " + address); return; } ServerMap.App app = mServerMap.getByConnId(connId); if (app == null) return; Loading Loading @@ -1821,7 +1831,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "clientSetPreferredPhy() - address=" + address + ", connId=" + connId); gattClientSetPreferredPhyNative(clientIf, connId, txPhy, rxPhy, phyOptions); gattClientSetPreferredPhyNative(clientIf, address, txPhy, rxPhy, phyOptions); } void clientReadPhy(int clientIf, String address) { Loading @@ -1834,7 +1844,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "clientReadPhy() - address=" + address + ", connId=" + connId); gattClientReadPhyNative(clientIf, connId); gattClientReadPhyNative(clientIf, address); } int numHwTrackFiltersAvailable() { Loading Loading @@ -2372,7 +2382,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "serverSetPreferredPhy() - address=" + address + ", connId=" + connId); gattServerSetPreferredPhyNative(serverIf, connId, txPhy, rxPhy, phyOptions); gattServerSetPreferredPhyNative(serverIf, address, txPhy, rxPhy, phyOptions); } void serverReadPhy(int serverIf, String address) { Loading @@ -2385,7 +2395,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "serverReadPhy() - address=" + address + ", connId=" + connId); gattServerReadPhyNative(serverIf, connId); gattServerReadPhyNative(serverIf, address); } void addService(int serverIf, BluetoothGattService service) { Loading Loading @@ -2693,9 +2703,9 @@ public class GattService extends ProfileService { int conn_id); private native void gattClientSetPreferredPhyNative( int clientIf, int conn_id, int tx_phy, int rx_phy, int phy_options); int clientIf, String address, int tx_phy, int rx_phy, int phy_options); private native void gattClientReadPhyNative(int clientIf, int conn_id); private native void gattClientReadPhyNative(int clientIf, String address); private native void gattClientRefreshNative(int clientIf, String address); Loading Loading @@ -2745,9 +2755,9 @@ public class GattService extends ProfileService { int conn_id); private native void gattServerSetPreferredPhyNative( int clientIf, int conn_id, int tx_phy, int rx_phy, int phy_options); int clientIf, String address, int tx_phy, int rx_phy, int phy_options); private native void gattServerReadPhyNative(int clientIf, int conn_id); private native void gattServerReadPhyNative(int clientIf, String address); private native void gattServerAddServiceNative(int server_if, List<GattDbElement> service); Loading Loading
android/app/jni/com_android_bluetooth_gatt.cpp +42 −22 Original line number Diff line number Diff line Loading @@ -848,7 +848,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onGetGattDb = env->GetMethodID(clazz, "onGetGattDb", "(ILjava/util/ArrayList;)V"); method_onClientPhyRead = env->GetMethodID(clazz, "onClientPhyRead", "(IIII)V"); env->GetMethodID(clazz, "onClientPhyRead", "(ILjava/lang/String;III)V"); method_onClientPhyUpdate = env->GetMethodID(clazz, "onClientPhyUpdate", "(IIII)V"); method_onClientConnUpdate = Loading Loading @@ -884,7 +884,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { env->GetMethodID(clazz, "onServerCongestion", "(IZ)V"); method_onServerMtuChanged = env->GetMethodID(clazz, "onMtuChanged", "(II)V"); method_onServerPhyRead = env->GetMethodID(clazz, "onServerPhyRead", "(IIII)V"); env->GetMethodID(clazz, "onServerPhyRead", "(ILjava/lang/String;III)V"); method_onServerPhyUpdate = env->GetMethodID(clazz, "onServerPhyUpdate", "(IIII)V"); method_onServerConnUpdate = Loading Loading @@ -1027,26 +1027,35 @@ static void gattClientDisconnectNative(JNIEnv* env, jobject object, } static void gattClientSetPreferredPhyNative(JNIEnv* env, jobject object, jint clientIf, jint conn_id, jint clientIf, jstring address, jint tx_phy, jint rx_phy, jint phy_options) { if (!sGattIf) return; sGattIf->client->set_preferred_phy(conn_id, tx_phy, rx_phy, phy_options); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->set_preferred_phy(bda, tx_phy, rx_phy, phy_options); } static void readClientPhyCb(int conn_id, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { static void readClientPhyCb(uint8_t clientIf, bt_bdaddr_t bda, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientPhyRead, conn_id, tx_phy, rx_phy, status); ScopedLocalRef<jstring> address(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &bda)); sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientPhyRead, clientIf, address.get(), tx_phy, rx_phy, status); } static void gattClientReadPhyNative(JNIEnv* env, jobject object, jint clientIf, jint conn_id) { jstring address) { if (!sGattIf) return; sGattIf->client->read_phy(conn_id, base::Bind(readClientPhyCb, conn_id)); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->read_phy(bda, base::Bind(&readClientPhyCb, clientIf, bda)); } static void gattClientRefreshNative(JNIEnv* env, jobject object, jint clientIf, Loading @@ -1055,6 +1064,7 @@ static void gattClientRefreshNative(JNIEnv* env, jobject object, jint clientIf, bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->client->refresh(clientIf, &bda); } Loading Loading @@ -1535,26 +1545,34 @@ static void gattServerDisconnectNative(JNIEnv* env, jobject object, } static void gattServerSetPreferredPhyNative(JNIEnv* env, jobject object, jint serverIf, jint conn_id, jint serverIf, jstring address, jint tx_phy, jint rx_phy, jint phy_options) { if (!sGattIf) return; sGattIf->server->set_preferred_phy(conn_id, tx_phy, rx_phy, phy_options); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->server->set_preferred_phy(bda, tx_phy, rx_phy, phy_options); } static void readServerPhyCb(int conn_id, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { static void readServerPhyCb(uint8_t serverIf, bt_bdaddr_t bda, uint8_t tx_phy, uint8_t rx_phy, uint8_t status) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerPhyRead, conn_id, tx_phy, rx_phy, status); ScopedLocalRef<jstring> address(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &bda)); sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerPhyRead, serverIf, address.get(), tx_phy, rx_phy, status); } static void gattServerReadPhyNative(JNIEnv* env, jobject object, jint serverIf, jint conn_id) { jstring address) { if (!sGattIf) return; sGattIf->server->read_phy(conn_id, base::Bind(readServerPhyCb, conn_id)); bt_bdaddr_t bda; jstr2bdaddr(env, &bda, address); sGattIf->server->read_phy(bda, base::Bind(&readServerPhyCb, serverIf, bda)); } static void gattServerAddServiceNative(JNIEnv* env, jobject object, Loading Loading @@ -2176,9 +2194,10 @@ static JNINativeMethod sMethods[] = { (void*)gattClientConnectNative}, {"gattClientDisconnectNative", "(ILjava/lang/String;I)V", (void*)gattClientDisconnectNative}, {"gattClientSetPreferredPhyNative", "(IIIII)V", {"gattClientSetPreferredPhyNative", "(ILjava/lang/String;III)V", (void*)gattClientSetPreferredPhyNative}, {"gattClientReadPhyNative", "(II)V", (void*)gattClientReadPhyNative}, {"gattClientReadPhyNative", "(ILjava/lang/String;)V", (void*)gattClientReadPhyNative}, {"gattClientRefreshNative", "(ILjava/lang/String;)V", (void*)gattClientRefreshNative}, {"gattClientSearchServiceNative", "(IZJJ)V", Loading Loading @@ -2214,9 +2233,10 @@ static JNINativeMethod sMethods[] = { (void*)gattServerConnectNative}, {"gattServerDisconnectNative", "(ILjava/lang/String;I)V", (void*)gattServerDisconnectNative}, {"gattServerSetPreferredPhyNative", "(IIIII)V", {"gattServerSetPreferredPhyNative", "(ILjava/lang/String;III)V", (void*)gattServerSetPreferredPhyNative}, {"gattServerReadPhyNative", "(II)V", (void*)gattServerReadPhyNative}, {"gattServerReadPhyNative", "(ILjava/lang/String;)V", (void*)gattServerReadPhyNative}, {"gattServerAddServiceNative", "(ILjava/util/List;)V", (void*)gattServerAddServiceNative}, {"gattServerStopServiceNative", "(II)V", Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +26 −16 Original line number Diff line number Diff line Loading @@ -934,11 +934,17 @@ public class GattService extends ProfileService { app.callback.onPhyUpdate(address, txPhy, rxPhy, status); } void onClientPhyRead(int connId, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onClientPhyRead() - connId=" + connId + ", status=" + status); void onClientPhyRead(int clientIf, String address, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onClientPhyRead() - address=" + address + ", status=" + status + ", clientIf=" + clientIf); String address = mClientMap.addressByConnId(connId); if (address == null) return; Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "onClientPhyRead() - no connection to " + address); return; } ClientMap.App app = mClientMap.getByConnId(connId); if (app == null) return; Loading Loading @@ -971,11 +977,15 @@ public class GattService extends ProfileService { app.callback.onPhyUpdate(address, txPhy, rxPhy, status); } void onServerPhyRead(int connId, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onServerPhyRead() - connId=" + connId + ", status=" + status); void onServerPhyRead(int serverIf, String address, int txPhy, int rxPhy, int status) throws RemoteException { if (DBG) Log.d(TAG, "onServerPhyRead() - address=" + address + ", status=" + status); String address = mServerMap.addressByConnId(connId); if (address == null) return; Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "onServerPhyRead() - no connection to " + address); return; } ServerMap.App app = mServerMap.getByConnId(connId); if (app == null) return; Loading Loading @@ -1821,7 +1831,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "clientSetPreferredPhy() - address=" + address + ", connId=" + connId); gattClientSetPreferredPhyNative(clientIf, connId, txPhy, rxPhy, phyOptions); gattClientSetPreferredPhyNative(clientIf, address, txPhy, rxPhy, phyOptions); } void clientReadPhy(int clientIf, String address) { Loading @@ -1834,7 +1844,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "clientReadPhy() - address=" + address + ", connId=" + connId); gattClientReadPhyNative(clientIf, connId); gattClientReadPhyNative(clientIf, address); } int numHwTrackFiltersAvailable() { Loading Loading @@ -2372,7 +2382,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "serverSetPreferredPhy() - address=" + address + ", connId=" + connId); gattServerSetPreferredPhyNative(serverIf, connId, txPhy, rxPhy, phyOptions); gattServerSetPreferredPhyNative(serverIf, address, txPhy, rxPhy, phyOptions); } void serverReadPhy(int serverIf, String address) { Loading @@ -2385,7 +2395,7 @@ public class GattService extends ProfileService { } if (DBG) Log.d(TAG, "serverReadPhy() - address=" + address + ", connId=" + connId); gattServerReadPhyNative(serverIf, connId); gattServerReadPhyNative(serverIf, address); } void addService(int serverIf, BluetoothGattService service) { Loading Loading @@ -2693,9 +2703,9 @@ public class GattService extends ProfileService { int conn_id); private native void gattClientSetPreferredPhyNative( int clientIf, int conn_id, int tx_phy, int rx_phy, int phy_options); int clientIf, String address, int tx_phy, int rx_phy, int phy_options); private native void gattClientReadPhyNative(int clientIf, int conn_id); private native void gattClientReadPhyNative(int clientIf, String address); private native void gattClientRefreshNative(int clientIf, String address); Loading Loading @@ -2745,9 +2755,9 @@ public class GattService extends ProfileService { int conn_id); private native void gattServerSetPreferredPhyNative( int clientIf, int conn_id, int tx_phy, int rx_phy, int phy_options); int clientIf, String address, int tx_phy, int rx_phy, int phy_options); private native void gattServerReadPhyNative(int clientIf, int conn_id); private native void gattServerReadPhyNative(int clientIf, String address); private native void gattServerAddServiceNative(int server_if, List<GattDbElement> service); Loading