Loading jni/com_android_bluetooth_gatt.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -1364,20 +1364,23 @@ static void registerAdvertiserNative(JNIEnv* env, jobject object, base::Bind(&ble_advertiser_register_cb, uuid)); } static void startAdvertiserNative(JNIEnv* env, jobject object, jint advertiser_id, jint min_interval, jint max_interval, jint adv_type, jint chnl_map, jint tx_power, jbyteArray adv_data, jbyteArray scan_resp, jint timeout_s) { static void startAdvertiserNative( JNIEnv* env, jobject object, jint advertiser_id, jint advertising_event_properties, jint min_interval, jint max_interval, jint chnl_map, jint tx_power, jint primary_advertising_phy, jint secondary_advertising_phy, jint scan_request_notification_enable, jbyteArray adv_data, jbyteArray scan_resp, jint timeout_s) { if (!sGattIf) return; AdvertiseParameters params; params.advertising_event_properties = advertising_event_properties; params.min_interval = min_interval; params.max_interval = max_interval; params.adv_type = adv_type; params.channel_map = chnl_map; params.tx_power = tx_power; params.primary_advertising_phy = primary_advertising_phy; params.secondary_advertising_phy = secondary_advertising_phy; params.scan_request_notification_enable = scan_request_notification_enable; jbyte* adv_data_data = env->GetByteArrayElements(adv_data, NULL); uint16_t adv_data_len = (uint16_t)env->GetArrayLength(adv_data); Loading @@ -1395,6 +1398,7 @@ static void startAdvertiserNative(JNIEnv* env, jobject object, params, data_vec, scan_resp_vec, timeout_s, base::Bind(&ble_advertiser_enable_cb, false, advertiser_id)); } static void unregisterAdvertiserNative(JNIEnv* env, jobject object, jint advertiser_id) { if (!sGattIf) return; Loading Loading @@ -1651,7 +1655,8 @@ static JNINativeMethod sAdvertiseMethods[] = { {"registerAdvertiserNative", "(JJ)V", (void*)registerAdvertiserNative}, {"unregisterAdvertiserNative", "(I)V", (void*)unregisterAdvertiserNative}, {"gattClientEnableAdvNative", "(IZI)V", (void*)gattClientEnableAdvNative}, {"startAdvertiserNative", "(IIIIII[B[BI)V", (void*)startAdvertiserNative}, {"startAdvertiserNative", "(IIIIIIIII[B[BI)V", (void*)startAdvertiserNative}, }; // JNI functions defined in ScanManager class. Loading src/com/android/bluetooth/gatt/AdvertiseHelper.java +7 −7 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ class AdvertiseHelper { private static final int ADVERTISING_TX_POWER_MAX = 4; // Note we don't expose connectable directed advertising to API. private static final int ADVERTISING_EVENT_TYPE_CONNECTABLE = 0; private static final int ADVERTISING_EVENT_TYPE_SCANNABLE = 2; private static final int ADVERTISING_EVENT_TYPE_NON_CONNECTABLE = 3; private static final int ADVERTISING_EVENT_TYPE_LEGACY_CONNECTABLE = 0x13; private static final int ADVERTISING_EVENT_TYPE_LEGACY_SCANNABLE = 0x12; private static final int ADVERTISING_EVENT_TYPE_LEGACY_NON_CONNECTABLE = 0x10; private static final int DEVICE_NAME_MAX = 18; Loading Loading @@ -203,14 +203,14 @@ class AdvertiseHelper { } // Convert advertising event type to stack values. public static int getAdvertisingEventType(AdvertiseClient client) { public static int getAdvertisingEventProperties(AdvertiseClient client) { AdvertiseSettings settings = client.settings; if (settings.isConnectable()) { return ADVERTISING_EVENT_TYPE_CONNECTABLE; return ADVERTISING_EVENT_TYPE_LEGACY_CONNECTABLE; } return client.scanResponse == null ? ADVERTISING_EVENT_TYPE_NON_CONNECTABLE : ADVERTISING_EVENT_TYPE_SCANNABLE; ? ADVERTISING_EVENT_TYPE_LEGACY_NON_CONNECTABLE : ADVERTISING_EVENT_TYPE_LEGACY_SCANNABLE; } // Convert advertising milliseconds to advertising units(one unit is 0.625 millisecond). Loading src/com/android/bluetooth/gatt/AdvertiseManager.java +22 −8 Original line number Diff line number Diff line Loading @@ -215,13 +215,22 @@ class AdvertiseManager { private static final int ADVERTISING_CHANNEL_ALL = ADVERTISING_CHANNEL_37 | ADVERTISING_CHANNEL_38 | ADVERTISING_CHANNEL_39; private static final int ADVERTISING_PHY_LE_1M = 0X01; private static final int ADVERTISING_PHY_LE_2M = 0X02; // only for secondary advertising channel private static final int ADVERTISING_PHY_LE_CODED = 0X03; private static final int SCAN_REQUEST_NOTIFICATIONS_DISABLE = 0X00; private static final int SCAN_REQUEST_NOTIFICATIONS_ENABLE = 0X01; void startAdverising(AdvertiseClient client) { logd("starting advertising"); int advertiserId = client.advertiserId; int advertisingEventProperties = AdvertiseHelper.getAdvertisingEventProperties(client); int minAdvertiseUnit = (int) AdvertiseHelper.getAdvertisingIntervalUnit(client.settings); int maxAdvertiseUnit = minAdvertiseUnit + ADVERTISING_INTERVAL_DELTA_UNIT; int advertiseEventType = AdvertiseHelper.getAdvertisingEventType(client); int txPowerLevel = AdvertiseHelper.getTxPowerLevel(client.settings); byte [] adv_data = AdvertiseHelper.advertiseDataToBytes(client.advertiseData, Loading @@ -232,8 +241,11 @@ class AdvertiseManager { int advertiseTimeoutSeconds = (int) TimeUnit.MILLISECONDS.toSeconds( client.settings.getTimeout()); startAdvertiserNative(advertiserId, minAdvertiseUnit, maxAdvertiseUnit, advertiseEventType, ADVERTISING_CHANNEL_ALL, txPowerLevel, adv_data, startAdvertiserNative(advertiserId, advertisingEventProperties, minAdvertiseUnit, maxAdvertiseUnit, ADVERTISING_CHANNEL_ALL, txPowerLevel, ADVERTISING_PHY_LE_1M, ADVERTISING_PHY_LE_1M, SCAN_REQUEST_NOTIFICATIONS_DISABLE, adv_data, scan_resp_data, advertiseTimeoutSeconds); } Loading @@ -250,10 +262,12 @@ class AdvertiseManager { private native void gattClientEnableAdvNative(int advertiserId, boolean enable, int timeout_s); private native void startAdvertiserNative(int advertiserId, int min_interval, int max_interval, int adv_type, int chnl_map, int tx_power, byte[] adv_data, byte[] scan_resp_data, int timeout_s); private native void startAdvertiserNative( int advertiserId, int advertising_event_properties, int min_interval, int max_interval, int chnl_map, int tx_power, int primary_advertising_phy, int secondary_advertising_phy, int scan_request_notification_enable, byte[] adv_data, byte[] scan_resp_data, int timeout_s); } private void logd(String s) { Loading Loading
jni/com_android_bluetooth_gatt.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -1364,20 +1364,23 @@ static void registerAdvertiserNative(JNIEnv* env, jobject object, base::Bind(&ble_advertiser_register_cb, uuid)); } static void startAdvertiserNative(JNIEnv* env, jobject object, jint advertiser_id, jint min_interval, jint max_interval, jint adv_type, jint chnl_map, jint tx_power, jbyteArray adv_data, jbyteArray scan_resp, jint timeout_s) { static void startAdvertiserNative( JNIEnv* env, jobject object, jint advertiser_id, jint advertising_event_properties, jint min_interval, jint max_interval, jint chnl_map, jint tx_power, jint primary_advertising_phy, jint secondary_advertising_phy, jint scan_request_notification_enable, jbyteArray adv_data, jbyteArray scan_resp, jint timeout_s) { if (!sGattIf) return; AdvertiseParameters params; params.advertising_event_properties = advertising_event_properties; params.min_interval = min_interval; params.max_interval = max_interval; params.adv_type = adv_type; params.channel_map = chnl_map; params.tx_power = tx_power; params.primary_advertising_phy = primary_advertising_phy; params.secondary_advertising_phy = secondary_advertising_phy; params.scan_request_notification_enable = scan_request_notification_enable; jbyte* adv_data_data = env->GetByteArrayElements(adv_data, NULL); uint16_t adv_data_len = (uint16_t)env->GetArrayLength(adv_data); Loading @@ -1395,6 +1398,7 @@ static void startAdvertiserNative(JNIEnv* env, jobject object, params, data_vec, scan_resp_vec, timeout_s, base::Bind(&ble_advertiser_enable_cb, false, advertiser_id)); } static void unregisterAdvertiserNative(JNIEnv* env, jobject object, jint advertiser_id) { if (!sGattIf) return; Loading Loading @@ -1651,7 +1655,8 @@ static JNINativeMethod sAdvertiseMethods[] = { {"registerAdvertiserNative", "(JJ)V", (void*)registerAdvertiserNative}, {"unregisterAdvertiserNative", "(I)V", (void*)unregisterAdvertiserNative}, {"gattClientEnableAdvNative", "(IZI)V", (void*)gattClientEnableAdvNative}, {"startAdvertiserNative", "(IIIIII[B[BI)V", (void*)startAdvertiserNative}, {"startAdvertiserNative", "(IIIIIIIII[B[BI)V", (void*)startAdvertiserNative}, }; // JNI functions defined in ScanManager class. Loading
src/com/android/bluetooth/gatt/AdvertiseHelper.java +7 −7 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ class AdvertiseHelper { private static final int ADVERTISING_TX_POWER_MAX = 4; // Note we don't expose connectable directed advertising to API. private static final int ADVERTISING_EVENT_TYPE_CONNECTABLE = 0; private static final int ADVERTISING_EVENT_TYPE_SCANNABLE = 2; private static final int ADVERTISING_EVENT_TYPE_NON_CONNECTABLE = 3; private static final int ADVERTISING_EVENT_TYPE_LEGACY_CONNECTABLE = 0x13; private static final int ADVERTISING_EVENT_TYPE_LEGACY_SCANNABLE = 0x12; private static final int ADVERTISING_EVENT_TYPE_LEGACY_NON_CONNECTABLE = 0x10; private static final int DEVICE_NAME_MAX = 18; Loading Loading @@ -203,14 +203,14 @@ class AdvertiseHelper { } // Convert advertising event type to stack values. public static int getAdvertisingEventType(AdvertiseClient client) { public static int getAdvertisingEventProperties(AdvertiseClient client) { AdvertiseSettings settings = client.settings; if (settings.isConnectable()) { return ADVERTISING_EVENT_TYPE_CONNECTABLE; return ADVERTISING_EVENT_TYPE_LEGACY_CONNECTABLE; } return client.scanResponse == null ? ADVERTISING_EVENT_TYPE_NON_CONNECTABLE : ADVERTISING_EVENT_TYPE_SCANNABLE; ? ADVERTISING_EVENT_TYPE_LEGACY_NON_CONNECTABLE : ADVERTISING_EVENT_TYPE_LEGACY_SCANNABLE; } // Convert advertising milliseconds to advertising units(one unit is 0.625 millisecond). Loading
src/com/android/bluetooth/gatt/AdvertiseManager.java +22 −8 Original line number Diff line number Diff line Loading @@ -215,13 +215,22 @@ class AdvertiseManager { private static final int ADVERTISING_CHANNEL_ALL = ADVERTISING_CHANNEL_37 | ADVERTISING_CHANNEL_38 | ADVERTISING_CHANNEL_39; private static final int ADVERTISING_PHY_LE_1M = 0X01; private static final int ADVERTISING_PHY_LE_2M = 0X02; // only for secondary advertising channel private static final int ADVERTISING_PHY_LE_CODED = 0X03; private static final int SCAN_REQUEST_NOTIFICATIONS_DISABLE = 0X00; private static final int SCAN_REQUEST_NOTIFICATIONS_ENABLE = 0X01; void startAdverising(AdvertiseClient client) { logd("starting advertising"); int advertiserId = client.advertiserId; int advertisingEventProperties = AdvertiseHelper.getAdvertisingEventProperties(client); int minAdvertiseUnit = (int) AdvertiseHelper.getAdvertisingIntervalUnit(client.settings); int maxAdvertiseUnit = minAdvertiseUnit + ADVERTISING_INTERVAL_DELTA_UNIT; int advertiseEventType = AdvertiseHelper.getAdvertisingEventType(client); int txPowerLevel = AdvertiseHelper.getTxPowerLevel(client.settings); byte [] adv_data = AdvertiseHelper.advertiseDataToBytes(client.advertiseData, Loading @@ -232,8 +241,11 @@ class AdvertiseManager { int advertiseTimeoutSeconds = (int) TimeUnit.MILLISECONDS.toSeconds( client.settings.getTimeout()); startAdvertiserNative(advertiserId, minAdvertiseUnit, maxAdvertiseUnit, advertiseEventType, ADVERTISING_CHANNEL_ALL, txPowerLevel, adv_data, startAdvertiserNative(advertiserId, advertisingEventProperties, minAdvertiseUnit, maxAdvertiseUnit, ADVERTISING_CHANNEL_ALL, txPowerLevel, ADVERTISING_PHY_LE_1M, ADVERTISING_PHY_LE_1M, SCAN_REQUEST_NOTIFICATIONS_DISABLE, adv_data, scan_resp_data, advertiseTimeoutSeconds); } Loading @@ -250,10 +262,12 @@ class AdvertiseManager { private native void gattClientEnableAdvNative(int advertiserId, boolean enable, int timeout_s); private native void startAdvertiserNative(int advertiserId, int min_interval, int max_interval, int adv_type, int chnl_map, int tx_power, byte[] adv_data, byte[] scan_resp_data, int timeout_s); private native void startAdvertiserNative( int advertiserId, int advertising_event_properties, int min_interval, int max_interval, int chnl_map, int tx_power, int primary_advertising_phy, int secondary_advertising_phy, int scan_request_notification_enable, byte[] adv_data, byte[] scan_resp_data, int timeout_s); } private void logd(String s) { Loading