Loading android/app/src/com/android/bluetooth/gatt/AdvertiseClient.java +5 −5 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.bluetooth.gatt; import android.annotation.Nullable; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; /** * @hide Loading @@ -26,12 +26,12 @@ import android.bluetooth.le.AdvertisementData; class AdvertiseClient { int clientIf; AdvertiseSettings settings; AdvertisementData advertiseData; AdvertiseData advertiseData; @Nullable AdvertisementData scanResponse; AdvertiseData scanResponse; AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertisementData data, AdvertisementData scanResponse) { AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse) { this.clientIf = clientIf; this.settings = settings; this.advertiseData = data; Loading android/app/src/com/android/bluetooth/gatt/GattService.java +10 −10 Original line number Diff line number Diff line Loading @@ -25,8 +25,8 @@ import android.bluetooth.IBluetoothGatt; import android.bluetooth.IBluetoothGattCallback; import android.bluetooth.IBluetoothGattServerCallback; import android.bluetooth.le.AdvertiseCallback; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; Loading Loading @@ -579,8 +579,8 @@ public class GattService extends ProfileService { } @Override public void startMultiAdvertising(int clientIf, AdvertisementData advertiseData, AdvertisementData scanResponse, public void startMultiAdvertising(int clientIf, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseSettings settings) { GattService service = getService(); if (service == null) return; Loading Loading @@ -1278,10 +1278,10 @@ public class GattService extends ProfileService { ClientMap.App app = mClientMap.getById(clientIf); if (app != null) { if (status == 0) { app.callback.onMultiAdvertiseCallback(AdvertiseCallback.SUCCESS); app.callback.onMultiAdvertiseCallback(AdvertiseCallback.ADVERTISE_SUCCESS); } else { app.callback.onMultiAdvertiseCallback( AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } } } Loading @@ -1294,10 +1294,10 @@ public class GattService extends ProfileService { if (app != null) { Log.d(TAG, "Client app is not null!"); if (status == 0) { app.callback.onMultiAdvertiseCallback(AdvertiseCallback.SUCCESS); app.callback.onMultiAdvertiseCallback(AdvertiseCallback.ADVERTISE_SUCCESS); } else { app.callback.onMultiAdvertiseCallback( AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } } } Loading Loading @@ -1407,7 +1407,7 @@ public class GattService extends ProfileService { ", isServer=" + isServer); ScanClient scanClient = getScanClient(clientIf, isServer); if (scanClient == null || scanClient.settings == null || scanClient.settings.getReportDelayNanos() == 0) { || scanClient.settings.getReportDelaySeconds() == 0) { // Not a batch scan client. Log.e(TAG, "called flushPendingBatchResults without a proper app!"); return; Loading Loading @@ -1663,8 +1663,8 @@ public class GattService extends ProfileService { } } void startMultiAdvertising(int clientIf, AdvertisementData advertiseData, AdvertisementData scanResponse, AdvertiseSettings settings) { void startMultiAdvertising(int clientIf, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseSettings settings) { enforceAdminPermission(); Message message = mStateMachine.obtainMessage(GattServiceStateMachine.START_ADVERTISING); message.obj = new AdvertiseClient(clientIf, settings, advertiseData, scanResponse); Loading android/app/src/com/android/bluetooth/gatt/GattServiceStateMachine.java +16 −28 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.bluetooth.gatt; import android.bluetooth.le.AdvertiseCallback; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanSettings; import android.os.Message; Loading Loading @@ -254,17 +254,11 @@ public class GattServiceStateMachine extends StateMachine { break; case STOP_ADVERTISING: clientIf = message.arg1; if (!mAdvertiseClients.containsKey(clientIf)) { try { mService.onMultipleAdvertiseCallback(clientIf, AdvertiseCallback.ADVERTISE_FAILED_NOT_STARTED); } catch (RemoteException e) { loge("failed to stop advertising", e); } } if (mAdvertiseClients.containsKey(clientIf)) { log("disabling client" + clientIf); gattClientDisableAdvNative(clientIf); mAdvertiseClients.remove(clientIf); } break; default: Loading Loading @@ -362,7 +356,7 @@ public class GattServiceStateMachine extends StateMachine { private void enableBleScan(ScanClient client) { if (client == null || client.settings == null || client.settings.getReportDelayNanos() == 0) { || client.settings.getReportDelaySeconds() == 0) { gattClientScanNative(true); return; } Loading Loading @@ -485,7 +479,7 @@ public class GattServiceStateMachine extends StateMachine { clientIf = message.arg1; try { mService.onMultipleAdvertiseCallback(clientIf, AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } catch (RemoteException e) { loge("failed to start advertising", e); } Loading @@ -498,7 +492,7 @@ public class GattServiceStateMachine extends StateMachine { } } private void setAdvertisingData(int clientIf, AdvertisementData data, boolean isScanResponse) { private void setAdvertisingData(int clientIf, AdvertiseData data, boolean isScanResponse) { if (data == null) { return; } Loading Loading @@ -564,18 +558,12 @@ public class GattServiceStateMachine extends StateMachine { // Convert advertising event type to stack advertising event type. private int getAdvertisingEventType(AdvertiseSettings settings) { switch (settings.getType()) { case AdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE: // TODO: Check if we have scan response data to control SCANABLE // TODO: Also check for limited discovery and set flag to LIMITED here? if (settings.getIsConnectable()) return ADVERTISING_EVENT_TYPE_CONNECTABLE; case AdvertiseSettings.ADVERTISE_TYPE_SCANNABLE: return ADVERTISING_EVENT_TYPE_SCANNABLE; case AdvertiseSettings.ADVERTISE_TYPE_NON_CONNECTABLE: return ADVERTISING_EVENT_TYPE_NON_CONNECTABLE; default: // Should't happen, just in case. return ADVERTISING_EVENT_TYPE_NON_CONNECTABLE; } } // Convert advertising milliseconds to advertising units(one unit is 0.625 millisecond). private long getAdvertisingIntervalUnit(AdvertiseSettings settings) { Loading Loading @@ -607,11 +595,11 @@ public class GattServiceStateMachine extends StateMachine { } // TODO: double check whether it makes sense to use the same delivery mode for found and // lost. if (settings.getCallbackType() == ScanSettings.CALLBACK_TYPE_ON_FOUND || settings.getCallbackType() == ScanSettings.CALLBACK_TYPE_ON_LOST) { if ( (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0 || (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { return DELIVERY_MODE_ON_FOUND; } return settings.getReportDelayNanos() == 0 ? DELIVERY_MODE_IMMEDIATE : DELIVERY_MODE_BATCH; return settings.getReportDelaySeconds() == 0 ? DELIVERY_MODE_IMMEDIATE : DELIVERY_MODE_BATCH; } private long millsToUnit(int millisecond) { Loading android/app/src/com/android/bluetooth/gatt/ScanFilterQueue.java +2 −2 Original line number Diff line number Diff line Loading @@ -190,8 +190,8 @@ import java.util.UUID; void addScanFilter(ScanFilter filter) { if (filter == null) return; if (filter.getLocalName() != null) { addName(filter.getLocalName()); if (filter.getDeviceName() != null) { addName(filter.getDeviceName()); } if (filter.getDeviceAddress() != null) { addDeviceAddress(filter.getDeviceAddress(), DEVICE_TYPE_ALL); Loading Loading
android/app/src/com/android/bluetooth/gatt/AdvertiseClient.java +5 −5 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.bluetooth.gatt; import android.annotation.Nullable; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; /** * @hide Loading @@ -26,12 +26,12 @@ import android.bluetooth.le.AdvertisementData; class AdvertiseClient { int clientIf; AdvertiseSettings settings; AdvertisementData advertiseData; AdvertiseData advertiseData; @Nullable AdvertisementData scanResponse; AdvertiseData scanResponse; AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertisementData data, AdvertisementData scanResponse) { AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse) { this.clientIf = clientIf; this.settings = settings; this.advertiseData = data; Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +10 −10 Original line number Diff line number Diff line Loading @@ -25,8 +25,8 @@ import android.bluetooth.IBluetoothGatt; import android.bluetooth.IBluetoothGattCallback; import android.bluetooth.IBluetoothGattServerCallback; import android.bluetooth.le.AdvertiseCallback; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; Loading Loading @@ -579,8 +579,8 @@ public class GattService extends ProfileService { } @Override public void startMultiAdvertising(int clientIf, AdvertisementData advertiseData, AdvertisementData scanResponse, public void startMultiAdvertising(int clientIf, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseSettings settings) { GattService service = getService(); if (service == null) return; Loading Loading @@ -1278,10 +1278,10 @@ public class GattService extends ProfileService { ClientMap.App app = mClientMap.getById(clientIf); if (app != null) { if (status == 0) { app.callback.onMultiAdvertiseCallback(AdvertiseCallback.SUCCESS); app.callback.onMultiAdvertiseCallback(AdvertiseCallback.ADVERTISE_SUCCESS); } else { app.callback.onMultiAdvertiseCallback( AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } } } Loading @@ -1294,10 +1294,10 @@ public class GattService extends ProfileService { if (app != null) { Log.d(TAG, "Client app is not null!"); if (status == 0) { app.callback.onMultiAdvertiseCallback(AdvertiseCallback.SUCCESS); app.callback.onMultiAdvertiseCallback(AdvertiseCallback.ADVERTISE_SUCCESS); } else { app.callback.onMultiAdvertiseCallback( AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } } } Loading Loading @@ -1407,7 +1407,7 @@ public class GattService extends ProfileService { ", isServer=" + isServer); ScanClient scanClient = getScanClient(clientIf, isServer); if (scanClient == null || scanClient.settings == null || scanClient.settings.getReportDelayNanos() == 0) { || scanClient.settings.getReportDelaySeconds() == 0) { // Not a batch scan client. Log.e(TAG, "called flushPendingBatchResults without a proper app!"); return; Loading Loading @@ -1663,8 +1663,8 @@ public class GattService extends ProfileService { } } void startMultiAdvertising(int clientIf, AdvertisementData advertiseData, AdvertisementData scanResponse, AdvertiseSettings settings) { void startMultiAdvertising(int clientIf, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseSettings settings) { enforceAdminPermission(); Message message = mStateMachine.obtainMessage(GattServiceStateMachine.START_ADVERTISING); message.obj = new AdvertiseClient(clientIf, settings, advertiseData, scanResponse); Loading
android/app/src/com/android/bluetooth/gatt/GattServiceStateMachine.java +16 −28 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.bluetooth.gatt; import android.bluetooth.le.AdvertiseCallback; import android.bluetooth.le.AdvertiseSettings; import android.bluetooth.le.AdvertisementData; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanSettings; import android.os.Message; Loading Loading @@ -254,17 +254,11 @@ public class GattServiceStateMachine extends StateMachine { break; case STOP_ADVERTISING: clientIf = message.arg1; if (!mAdvertiseClients.containsKey(clientIf)) { try { mService.onMultipleAdvertiseCallback(clientIf, AdvertiseCallback.ADVERTISE_FAILED_NOT_STARTED); } catch (RemoteException e) { loge("failed to stop advertising", e); } } if (mAdvertiseClients.containsKey(clientIf)) { log("disabling client" + clientIf); gattClientDisableAdvNative(clientIf); mAdvertiseClients.remove(clientIf); } break; default: Loading Loading @@ -362,7 +356,7 @@ public class GattServiceStateMachine extends StateMachine { private void enableBleScan(ScanClient client) { if (client == null || client.settings == null || client.settings.getReportDelayNanos() == 0) { || client.settings.getReportDelaySeconds() == 0) { gattClientScanNative(true); return; } Loading Loading @@ -485,7 +479,7 @@ public class GattServiceStateMachine extends StateMachine { clientIf = message.arg1; try { mService.onMultipleAdvertiseCallback(clientIf, AdvertiseCallback.ADVERTISE_FAILED_CONTROLLER_FAILURE); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); } catch (RemoteException e) { loge("failed to start advertising", e); } Loading @@ -498,7 +492,7 @@ public class GattServiceStateMachine extends StateMachine { } } private void setAdvertisingData(int clientIf, AdvertisementData data, boolean isScanResponse) { private void setAdvertisingData(int clientIf, AdvertiseData data, boolean isScanResponse) { if (data == null) { return; } Loading Loading @@ -564,18 +558,12 @@ public class GattServiceStateMachine extends StateMachine { // Convert advertising event type to stack advertising event type. private int getAdvertisingEventType(AdvertiseSettings settings) { switch (settings.getType()) { case AdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE: // TODO: Check if we have scan response data to control SCANABLE // TODO: Also check for limited discovery and set flag to LIMITED here? if (settings.getIsConnectable()) return ADVERTISING_EVENT_TYPE_CONNECTABLE; case AdvertiseSettings.ADVERTISE_TYPE_SCANNABLE: return ADVERTISING_EVENT_TYPE_SCANNABLE; case AdvertiseSettings.ADVERTISE_TYPE_NON_CONNECTABLE: return ADVERTISING_EVENT_TYPE_NON_CONNECTABLE; default: // Should't happen, just in case. return ADVERTISING_EVENT_TYPE_NON_CONNECTABLE; } } // Convert advertising milliseconds to advertising units(one unit is 0.625 millisecond). private long getAdvertisingIntervalUnit(AdvertiseSettings settings) { Loading Loading @@ -607,11 +595,11 @@ public class GattServiceStateMachine extends StateMachine { } // TODO: double check whether it makes sense to use the same delivery mode for found and // lost. if (settings.getCallbackType() == ScanSettings.CALLBACK_TYPE_ON_FOUND || settings.getCallbackType() == ScanSettings.CALLBACK_TYPE_ON_LOST) { if ( (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0 || (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { return DELIVERY_MODE_ON_FOUND; } return settings.getReportDelayNanos() == 0 ? DELIVERY_MODE_IMMEDIATE : DELIVERY_MODE_BATCH; return settings.getReportDelaySeconds() == 0 ? DELIVERY_MODE_IMMEDIATE : DELIVERY_MODE_BATCH; } private long millsToUnit(int millisecond) { Loading
android/app/src/com/android/bluetooth/gatt/ScanFilterQueue.java +2 −2 Original line number Diff line number Diff line Loading @@ -190,8 +190,8 @@ import java.util.UUID; void addScanFilter(ScanFilter filter) { if (filter == null) return; if (filter.getLocalName() != null) { addName(filter.getLocalName()); if (filter.getDeviceName() != null) { addName(filter.getDeviceName()); } if (filter.getDeviceAddress() != null) { addDeviceAddress(filter.getDeviceAddress(), DEVICE_TYPE_ALL); Loading