Loading android/app/jni/com_android_bluetooth_gatt.cpp +22 −0 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,7 @@ static jmethodID method_onServerConnUpdate; * Advertiser callback methods * Advertiser callback methods */ */ static jmethodID method_onAdvertisingSetStarted; static jmethodID method_onAdvertisingSetStarted; static jmethodID method_onOwnAddressRead; static jmethodID method_onAdvertisingEnabled; static jmethodID method_onAdvertisingEnabled; static jmethodID method_onAdvertisingDataSet; static jmethodID method_onAdvertisingDataSet; static jmethodID method_onScanResponseDataSet; static jmethodID method_onScanResponseDataSet; Loading Loading @@ -1683,6 +1684,8 @@ static void gattServerSendResponseNative(JNIEnv* env, jobject object, static void advertiseClassInitNative(JNIEnv* env, jclass clazz) { static void advertiseClassInitNative(JNIEnv* env, jclass clazz) { method_onAdvertisingSetStarted = method_onAdvertisingSetStarted = env->GetMethodID(clazz, "onAdvertisingSetStarted", "(IIII)V"); env->GetMethodID(clazz, "onAdvertisingSetStarted", "(IIII)V"); method_onOwnAddressRead = env->GetMethodID(clazz, "onOwnAddressRead", "(IILjava/lang/String;)V"); method_onAdvertisingEnabled = method_onAdvertisingEnabled = env->GetMethodID(clazz, "onAdvertisingEnabled", "(IZI)V"); env->GetMethodID(clazz, "onAdvertisingEnabled", "(IZI)V"); method_onAdvertisingDataSet = method_onAdvertisingDataSet = Loading Loading @@ -1845,6 +1848,24 @@ static void stopAdvertisingSetNative(JNIEnv* env, jobject object, sGattIf->advertiser->Unregister(advertiser_id); sGattIf->advertiser->Unregister(advertiser_id); } } static void getOwnAddressCb(uint8_t advertiser_id, uint8_t address_type, bt_bdaddr_t address) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; ScopedLocalRef<jstring> addr(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &address)); sCallbackEnv->CallVoidMethod(mAdvertiseCallbacksObj, method_onOwnAddressRead, advertiser_id, address_type, addr.get()); } static void getOwnAddressNative(JNIEnv* env, jobject object, jint advertiser_id) { if (!sGattIf) return; sGattIf->advertiser->GetOwnAddress( advertiser_id, base::Bind(&getOwnAddressCb, advertiser_id)); } static void callJniCallback(jmethodID method, uint8_t advertiser_id, static void callJniCallback(jmethodID method, uint8_t advertiser_id, uint8_t status) { uint8_t status) { CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -2066,6 +2087,7 @@ static JNINativeMethod sAdvertiseMethods[] = { "(Landroid/bluetooth/le/AdvertisingSetParameters;[B[BLandroid/bluetooth/" "(Landroid/bluetooth/le/AdvertisingSetParameters;[B[BLandroid/bluetooth/" "le/PeriodicAdvertisingParameters;[BIII)V", "le/PeriodicAdvertisingParameters;[BIII)V", (void*)startAdvertisingSetNative}, (void*)startAdvertisingSetNative}, {"getOwnAddressNative", "(I)V", (void*)getOwnAddressNative}, {"stopAdvertisingSetNative", "(I)V", (void*)stopAdvertisingSetNative}, {"stopAdvertisingSetNative", "(I)V", (void*)stopAdvertisingSetNative}, {"enableAdvertisingSetNative", "(IZII)V", {"enableAdvertisingSetNative", "(IZII)V", (void*)enableAdvertisingSetNative}, (void*)enableAdvertisingSetNative}, Loading android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -202,6 +202,24 @@ class AdvertiseManager { periodic_data, duration, maxExtAdvEvents, cb_id); periodic_data, duration, maxExtAdvEvents, cb_id); } } void onOwnAddressRead(int advertiser_id, int addressType, String address) throws RemoteException { logd("onOwnAddressRead() advertiser_id=" + advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Log.i(TAG, "onOwnAddressRead() - bad advertiser_id " + advertiser_id); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onOwnAddressRead(advertiser_id, addressType, address); } void getOwnAddress(int advertiserId) { getOwnAddressNative(advertiserId); } void stopAdvertisingSet(IAdvertisingSetCallback callback) { void stopAdvertisingSet(IAdvertisingSetCallback callback) { IBinder binder = toBinder(callback); IBinder binder = toBinder(callback); if (DBG) Log.d(TAG, "stopAdvertisingSet() " + binder); if (DBG) Log.d(TAG, "stopAdvertisingSet() " + binder); Loading Loading @@ -361,6 +379,7 @@ class AdvertiseManager { byte[] advertiseData, byte[] scanResponse, byte[] advertiseData, byte[] scanResponse, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, int maxExtAdvEvents, int reg_id); int maxExtAdvEvents, int reg_id); private native void getOwnAddressNative(int advertiserId); private native void stopAdvertisingSetNative(int advertiser_id); private native void stopAdvertisingSetNative(int advertiser_id); private native void enableAdvertisingSetNative( private native void enableAdvertisingSetNative( int advertiserId, boolean enable, int duration, int maxExtAdvEvents); int advertiserId, boolean enable, int duration, int maxExtAdvEvents); Loading android/app/src/com/android/bluetooth/gatt/GattService.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -597,6 +597,12 @@ public class GattService extends ProfileService { service.stopAdvertisingSet(callback); service.stopAdvertisingSet(callback); } } public void getOwnAddress(int advertiserId) { GattService service = getService(); if (service == null) return; service.getOwnAddress(advertiserId); } public void enableAdvertisingSet( public void enableAdvertisingSet( int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { GattService service = getService(); GattService service = getService(); Loading Loading @@ -1547,6 +1553,11 @@ public class GattService extends ProfileService { mAdvertiseManager.stopAdvertisingSet(callback); mAdvertiseManager.stopAdvertisingSet(callback); } } void getOwnAddress(int advertiserId) { enforcePrivilegedPermission(); mAdvertiseManager.getOwnAddress(advertiserId); } void enableAdvertisingSet(int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { void enableAdvertisingSet(int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { enforceAdminPermission(); enforceAdminPermission(); mAdvertiseManager.enableAdvertisingSet(advertiserId, enable, duration, maxExtAdvEvents); mAdvertiseManager.enableAdvertisingSet(advertiserId, enable, duration, maxExtAdvEvents); Loading Loading
android/app/jni/com_android_bluetooth_gatt.cpp +22 −0 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,7 @@ static jmethodID method_onServerConnUpdate; * Advertiser callback methods * Advertiser callback methods */ */ static jmethodID method_onAdvertisingSetStarted; static jmethodID method_onAdvertisingSetStarted; static jmethodID method_onOwnAddressRead; static jmethodID method_onAdvertisingEnabled; static jmethodID method_onAdvertisingEnabled; static jmethodID method_onAdvertisingDataSet; static jmethodID method_onAdvertisingDataSet; static jmethodID method_onScanResponseDataSet; static jmethodID method_onScanResponseDataSet; Loading Loading @@ -1683,6 +1684,8 @@ static void gattServerSendResponseNative(JNIEnv* env, jobject object, static void advertiseClassInitNative(JNIEnv* env, jclass clazz) { static void advertiseClassInitNative(JNIEnv* env, jclass clazz) { method_onAdvertisingSetStarted = method_onAdvertisingSetStarted = env->GetMethodID(clazz, "onAdvertisingSetStarted", "(IIII)V"); env->GetMethodID(clazz, "onAdvertisingSetStarted", "(IIII)V"); method_onOwnAddressRead = env->GetMethodID(clazz, "onOwnAddressRead", "(IILjava/lang/String;)V"); method_onAdvertisingEnabled = method_onAdvertisingEnabled = env->GetMethodID(clazz, "onAdvertisingEnabled", "(IZI)V"); env->GetMethodID(clazz, "onAdvertisingEnabled", "(IZI)V"); method_onAdvertisingDataSet = method_onAdvertisingDataSet = Loading Loading @@ -1845,6 +1848,24 @@ static void stopAdvertisingSetNative(JNIEnv* env, jobject object, sGattIf->advertiser->Unregister(advertiser_id); sGattIf->advertiser->Unregister(advertiser_id); } } static void getOwnAddressCb(uint8_t advertiser_id, uint8_t address_type, bt_bdaddr_t address) { CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid()) return; ScopedLocalRef<jstring> addr(sCallbackEnv.get(), bdaddr2newjstr(sCallbackEnv.get(), &address)); sCallbackEnv->CallVoidMethod(mAdvertiseCallbacksObj, method_onOwnAddressRead, advertiser_id, address_type, addr.get()); } static void getOwnAddressNative(JNIEnv* env, jobject object, jint advertiser_id) { if (!sGattIf) return; sGattIf->advertiser->GetOwnAddress( advertiser_id, base::Bind(&getOwnAddressCb, advertiser_id)); } static void callJniCallback(jmethodID method, uint8_t advertiser_id, static void callJniCallback(jmethodID method, uint8_t advertiser_id, uint8_t status) { uint8_t status) { CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -2066,6 +2087,7 @@ static JNINativeMethod sAdvertiseMethods[] = { "(Landroid/bluetooth/le/AdvertisingSetParameters;[B[BLandroid/bluetooth/" "(Landroid/bluetooth/le/AdvertisingSetParameters;[B[BLandroid/bluetooth/" "le/PeriodicAdvertisingParameters;[BIII)V", "le/PeriodicAdvertisingParameters;[BIII)V", (void*)startAdvertisingSetNative}, (void*)startAdvertisingSetNative}, {"getOwnAddressNative", "(I)V", (void*)getOwnAddressNative}, {"stopAdvertisingSetNative", "(I)V", (void*)stopAdvertisingSetNative}, {"stopAdvertisingSetNative", "(I)V", (void*)stopAdvertisingSetNative}, {"enableAdvertisingSetNative", "(IZII)V", {"enableAdvertisingSetNative", "(IZII)V", (void*)enableAdvertisingSetNative}, (void*)enableAdvertisingSetNative}, Loading
android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -202,6 +202,24 @@ class AdvertiseManager { periodic_data, duration, maxExtAdvEvents, cb_id); periodic_data, duration, maxExtAdvEvents, cb_id); } } void onOwnAddressRead(int advertiser_id, int addressType, String address) throws RemoteException { logd("onOwnAddressRead() advertiser_id=" + advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Log.i(TAG, "onOwnAddressRead() - bad advertiser_id " + advertiser_id); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onOwnAddressRead(advertiser_id, addressType, address); } void getOwnAddress(int advertiserId) { getOwnAddressNative(advertiserId); } void stopAdvertisingSet(IAdvertisingSetCallback callback) { void stopAdvertisingSet(IAdvertisingSetCallback callback) { IBinder binder = toBinder(callback); IBinder binder = toBinder(callback); if (DBG) Log.d(TAG, "stopAdvertisingSet() " + binder); if (DBG) Log.d(TAG, "stopAdvertisingSet() " + binder); Loading Loading @@ -361,6 +379,7 @@ class AdvertiseManager { byte[] advertiseData, byte[] scanResponse, byte[] advertiseData, byte[] scanResponse, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, int maxExtAdvEvents, int reg_id); int maxExtAdvEvents, int reg_id); private native void getOwnAddressNative(int advertiserId); private native void stopAdvertisingSetNative(int advertiser_id); private native void stopAdvertisingSetNative(int advertiser_id); private native void enableAdvertisingSetNative( private native void enableAdvertisingSetNative( int advertiserId, boolean enable, int duration, int maxExtAdvEvents); int advertiserId, boolean enable, int duration, int maxExtAdvEvents); Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -597,6 +597,12 @@ public class GattService extends ProfileService { service.stopAdvertisingSet(callback); service.stopAdvertisingSet(callback); } } public void getOwnAddress(int advertiserId) { GattService service = getService(); if (service == null) return; service.getOwnAddress(advertiserId); } public void enableAdvertisingSet( public void enableAdvertisingSet( int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { GattService service = getService(); GattService service = getService(); Loading Loading @@ -1547,6 +1553,11 @@ public class GattService extends ProfileService { mAdvertiseManager.stopAdvertisingSet(callback); mAdvertiseManager.stopAdvertisingSet(callback); } } void getOwnAddress(int advertiserId) { enforcePrivilegedPermission(); mAdvertiseManager.getOwnAddress(advertiserId); } void enableAdvertisingSet(int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { void enableAdvertisingSet(int advertiserId, boolean enable, int duration, int maxExtAdvEvents) { enforceAdminPermission(); enforceAdminPermission(); mAdvertiseManager.enableAdvertisingSet(advertiserId, enable, duration, maxExtAdvEvents); mAdvertiseManager.enableAdvertisingSet(advertiserId, enable, duration, maxExtAdvEvents); Loading