Loading android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +33 −23 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ class AdvertiseManager { * Constructor of {@link AdvertiseManager}. */ AdvertiseManager(GattService service, AdapterService adapterService) { logd("advertise manager created"); if (DBG) Log.d(TAG, "advertise manager created"); mService = service; mAdapterService = adapterService; } Loading @@ -74,7 +74,7 @@ class AdvertiseManager { } void cleanup() { logd("cleanup()"); if (DBG) Log.d(TAG, "cleanup()"); cleanupNative(); mAdvertisers.clear(); sTempRegistrationId = -1; Loading Loading @@ -136,9 +136,10 @@ class AdvertiseManager { void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status) throws Exception { if (DBG) if (DBG) { Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id); Loading @@ -163,8 +164,10 @@ class AdvertiseManager { } void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { logd("onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading Loading @@ -197,14 +200,14 @@ class AdvertiseManager { int cb_id = --sTempRegistrationId; mAdvertisers.put(binder, new AdvertiserInfo(cb_id, deathRecipient, callback)); logd("startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder); if (DBG) Log.d(TAG, "startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder); startAdvertisingSetNative(parameters, adv_data, scan_response, periodicParameters, periodic_data, duration, maxExtAdvEvents, cb_id); } void onOwnAddressRead(int advertiser_id, int addressType, String address) throws RemoteException { logd("onOwnAddressRead() advertiser_id=" + advertiser_id); if (DBG) Log.d(TAG, "onOwnAddressRead() advertiser_id=" + advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading Loading @@ -278,7 +281,10 @@ class AdvertiseManager { } void onAdvertisingDataSet(int advertiser_id, int status) throws Exception { logd("onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -291,7 +297,9 @@ class AdvertiseManager { } void onScanResponseDataSet(int advertiser_id, int status) throws Exception { logd("onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) Log.d(TAG, "onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" + status); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -305,8 +313,10 @@ class AdvertiseManager { void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status) throws Exception { logd("onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -319,8 +329,10 @@ class AdvertiseManager { } void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception { logd("onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) { Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -334,8 +346,10 @@ class AdvertiseManager { } void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception { logd("onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" if (DBG) { Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -349,8 +363,10 @@ class AdvertiseManager { void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { logd("onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" if (DBG) { Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -362,12 +378,6 @@ class AdvertiseManager { callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status); } private void logd(String s) { if (DBG) { Log.d(TAG, s); } } static { classInitNative(); } Loading android/app/src/com/android/bluetooth/gatt/GattService.java +18 −13 Original line number Diff line number Diff line Loading @@ -716,13 +716,14 @@ public class GattService extends ProfileService { void onScanResult(int event_type, int address_type, String address, int primary_phy, int secondary_phy, int advertising_sid, int tx_power, int rssi, int periodic_adv_int, byte[] adv_data) { if (VDBG) if (VDBG) { Log.d(TAG, "onScanResult() - event_type=0x" + Integer.toHexString(event_type) + ", address_type=" + address_type + ", address=" + address + ", primary_phy=" + primary_phy + ", secondary_phy=" + secondary_phy + ", advertising_sid=0x" + Integer.toHexString(advertising_sid) + ", tx_power=" + tx_power + ", rssi=" + rssi + ", periodic_adv_int=0x" + Integer.toHexString(periodic_adv_int)); } List<UUID> remoteUuids = parseUuids(adv_data); addScanResult(); Loading Loading @@ -1203,7 +1204,8 @@ public class GattService extends ProfileService { void onBatchScanStorageConfigured(int status, int clientIf) { if (DBG) { Log.d(TAG, "onBatchScanStorageConfigured() - clientIf="+ clientIf + ", status=" + status); Log.d(TAG, "onBatchScanStorageConfigured() - clientIf=" + clientIf + ", status=" + status); } mScanManager.callbackDone(clientIf, status); } Loading Loading @@ -1321,7 +1323,7 @@ public class GattService extends ProfileService { } private Set<ScanResult> parseFullResults(int numRecords, byte[] batchRecord) { Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord)); if (DBG) Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord)); Set<ScanResult> results = new HashSet<ScanResult>(numRecords); int position = 0; long now = SystemClock.elapsedRealtimeNanos(); Loading Loading @@ -1350,7 +1352,7 @@ public class GattService extends ProfileService { System.arraycopy(advertiseBytes, 0, scanRecord, 0, advertisePacketLen); System.arraycopy(scanResponseBytes, 0, scanRecord, advertisePacketLen, scanResponsePacketLen); Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord)); if (DBG) Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord)); results.add(new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), rssi, timestampNanos)); } Loading Loading @@ -1432,9 +1434,11 @@ public class GattService extends ProfileService { ScanSettings.CALLBACK_TYPE_MATCH_LOST, client); } } else { if (DBG) { Log.d(TAG, "Not reporting onlost/onfound : " + advertiserState + " scannerId = " + client.scannerId + " callbackType " + settings.getCallbackType()); + " scannerId = " + client.scannerId + " callbackType " + settings.getCallbackType()); } } } } Loading @@ -1446,7 +1450,7 @@ public class GattService extends ProfileService { Log.e(TAG, "Advertise app or callback is null"); return; } Log.d(TAG, "onScanParamSetupCompleted : " + status); if (DBG) Log.d(TAG, "onScanParamSetupCompleted : " + status); } // callback from ScanManager for dispatch of errors apps. Loading Loading @@ -1791,9 +1795,10 @@ public class GattService extends ProfileService { void clientConnect(int clientIf, String address, boolean isDirect, int transport, int phy) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (DBG) if (DBG) { Log.d(TAG, "clientConnect() - address=" + address + ", isDirect=" + isDirect + ", phy= " + phy); } gattClientConnectNative(clientIf, address, isDirect, transport, phy); } Loading @@ -1811,7 +1816,7 @@ public class GattService extends ProfileService { Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address); if (DBG) Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address); return; } Loading @@ -1824,7 +1829,7 @@ public class GattService extends ProfileService { Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "clientReadPhy() - no connection to " + address); if (DBG) Log.d(TAG, "clientReadPhy() - no connection to " + address); return; } Loading Loading @@ -2362,7 +2367,7 @@ public class GattService extends ProfileService { Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address); if (DBG) Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address); return; } Loading @@ -2375,7 +2380,7 @@ public class GattService extends ProfileService { Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "serverReadPhy() - no connection to " + address); if (DBG) Log.d(TAG, "serverReadPhy() - no connection to " + address); return; } Loading android/app/src/com/android/bluetooth/gatt/GattServiceConfig.java +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ package com.android.bluetooth.gatt; * GattService configuration. */ /*package*/ class GattServiceConfig { public static final boolean DBG = true; public static final boolean DBG = false; public static final boolean VDBG = false; public static final String TAG_PREFIX = "BtGatt."; public static final boolean DEBUG_ADMIN = true; Loading android/app/src/com/android/bluetooth/gatt/PeriodicScanManager.java +10 −14 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class PeriodicScanManager { * Constructor of {@link SyncManager}. */ PeriodicScanManager(AdapterService adapterService) { logd("advertise manager created"); if (DBG) Log.d(TAG, "advertise manager created"); mAdapterService = adapterService; } Loading @@ -62,7 +62,7 @@ class PeriodicScanManager { } void cleanup() { logd("cleanup()"); if (DBG) Log.d(TAG, "cleanup()"); cleanupNative(); mSyncs.clear(); sTempRegistrationId = -1; Loading Loading @@ -114,8 +114,10 @@ class PeriodicScanManager { void onSyncStarted(int reg_id, int sync_handle, int sid, int address_type, String address, int phy, int interval, int status) throws Exception { logd("onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle + ", status=" + status); if (DBG) { Log.d(TAG, "onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle + ", status=" + status); } Map.Entry<IBinder, SyncInfo> entry = findSync(reg_id); if (entry == null) { Loading @@ -140,7 +142,7 @@ class PeriodicScanManager { void onSyncReport(int sync_handle, int tx_power, int rssi, int data_status, byte[] data) throws Exception { logd("onSyncReport() - sync_handle=" + sync_handle); if (DBG) Log.d(TAG, "onSyncReport() - sync_handle=" + sync_handle); Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle); if (entry == null) { Loading @@ -155,7 +157,7 @@ class PeriodicScanManager { } void onSyncLost(int sync_handle) throws Exception { logd("onSyncLost() - sync_handle=" + sync_handle); if (DBG) Log.d(TAG, "onSyncLost() - sync_handle=" + sync_handle); Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle); if (entry == null) { Loading Loading @@ -184,13 +186,13 @@ class PeriodicScanManager { int cb_id = --sTempRegistrationId; mSyncs.put(binder, new SyncInfo(cb_id, deathRecipient, callback)); logd("startSync() - reg_id=" + cb_id + ", callback: " + binder); if (DBG) Log.d(TAG, "startSync() - reg_id=" + cb_id + ", callback: " + binder); startSyncNative(sid, address, skip, timeout, cb_id); } void stopSync(IPeriodicAdvertisingCallback callback) { IBinder binder = toBinder(callback); logd("stopSync() " + binder); if (DBG) Log.d(TAG, "stopSync() " + binder); SyncInfo sync = mSyncs.remove(binder); if (sync == null) { Loading @@ -210,12 +212,6 @@ class PeriodicScanManager { stopSyncNative(sync_handle); } private void logd(String s) { if (DBG) { Log.d(TAG, s); } } static { classInitNative(); } Loading android/app/src/com/android/bluetooth/gatt/ScanManager.java +33 −25 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class ScanManager { } void callbackDone(int scannerId, int status) { logd("callback done for scannerId - " + scannerId + " status - " + status); if (DBG) Log.d(TAG, "callback done for scannerId - " + scannerId + " status - " + status); if (status == 0) { mLatch.countDown(); } Loading Loading @@ -223,7 +223,7 @@ public class ScanManager { void handleStartScan(ScanClient client) { Utils.enforceAdminPermission(mService); logd("handling starting scan"); if (DBG) Log.d(TAG, "handling starting scan"); if (!isScanSupported(client)) { Log.e(TAG, "Scan settings not supported"); Loading Loading @@ -272,7 +272,7 @@ public class ScanManager { mScanNative.stopBatchScan(client); } if (client.appDied) { logd("app died, unregister scanner - " + client.scannerId); if (DBG) Log.d(TAG, "app died, unregister scanner - " + client.scannerId); mService.unregisterScanner(client.scannerId); } } Loading Loading @@ -440,15 +440,19 @@ public class ScanManager { } void configureRegularScanParams() { logd("configureRegularScanParams() - queue=" + mRegularScanClients.size()); if (DBG) { Log.d(TAG, "configureRegularScanParams() - queue=" + mRegularScanClients.size()); } int curScanSetting = Integer.MIN_VALUE; ScanClient client = getAggressiveClient(mRegularScanClients); if (client != null) { curScanSetting = client.settings.getScanMode(); } logd("configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting); if (DBG) { Log.d(TAG, "configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting); } if (curScanSetting != Integer.MIN_VALUE && curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) { Loading @@ -459,15 +463,18 @@ public class ScanManager { scanWindow = Utils.millsToUnit(scanWindow); scanInterval = Utils.millsToUnit(scanInterval); gattClientScanNative(false); logd("configureRegularScanParams - scanInterval = " + scanInterval + "configureRegularScanParams - scanWindow = " + scanWindow); if (DBG) { Log.d(TAG, "configureRegularScanParams - scanInterval = " + scanInterval + "configureRegularScanParams - scanWindow = " + scanWindow); } gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow); gattClientScanNative(true); mLastConfiguredScanSetting = curScanSetting; } } else { mLastConfiguredScanSetting = curScanSetting; logd("configureRegularScanParams() - queue emtpy, scan stopped"); if (DBG) Log.d(TAG, "configureRegularScanParams() - queue emtpy, scan stopped"); } } Loading Loading @@ -539,7 +546,7 @@ public class ScanManager { BatchScanParams batchScanParams = getBatchScanParams(); // Stop batch if batch scan params changed and previous params is not null. if (mBatchScanParms != null && (!mBatchScanParms.equals(batchScanParams))) { logd("stopping BLe Batch"); if (DBG) Log.d(TAG, "stopping BLe Batch"); resetCountDownLatch(); gattClientStopBatchScanNative(scannerId); waitForCallback(); Loading @@ -550,11 +557,11 @@ public class ScanManager { // Start batch if batchScanParams changed and current params is not null. if (batchScanParams != null && (!batchScanParams.equals(mBatchScanParms))) { int notifyThreshold = 95; logd("Starting BLE batch scan"); if (DBG) Log.d(TAG, "Starting BLE batch scan"); int resultType = getResultType(batchScanParams); int fullScanPercent = getFullScanStoragePercent(resultType); resetCountDownLatch(); logd("configuring batch scan storage, appIf " + client.scannerId); if (DBG) Log.d(TAG, "configuring batch scan storage, appIf " + client.scannerId); gattClientConfigBatchScanStorageNative(client.scannerId, fullScanPercent, 100 - fullScanPercent, notifyThreshold); waitForCallback(); Loading Loading @@ -667,7 +674,7 @@ public class ScanManager { } mRegularScanClients.remove(client); if (numRegularScanClients() == 0) { logd("stop scan"); if (DBG) Log.d(TAG, "stop scan"); gattClientScanNative(false); } removeScanFilters(client.scannerId); Loading @@ -684,7 +691,7 @@ public class ScanManager { // The scan should continue for background scans configureRegularScanParams(); if (numRegularScanClients() == 0) { logd("stop scan"); if (DBG) Log.d(TAG, "stop scan"); gattClientScanNative(false); } } Loading Loading @@ -719,7 +726,7 @@ public class ScanManager { } void flushBatchResults(int scannerId) { logd("flushPendingBatchResults - scannerId = " + scannerId); if (DBG) Log.d(TAG, "flushPendingBatchResults - scannerId = " + scannerId); if (mBatchScanParms.fullScanscannerId != -1) { resetCountDownLatch(); gattClientReadScanReportsNative(mBatchScanParms.fullScanscannerId, Loading Loading @@ -898,10 +905,10 @@ public class ScanManager { private void addFilterToController(int scannerId, ScanFilterQueue.Entry entry, int filterIndex) { logd("addFilterToController: " + entry.type); if (DBG) Log.d(TAG, "addFilterToController: " + entry.type); switch (entry.type) { case ScanFilterQueue.TYPE_DEVICE_ADDRESS: logd("add address " + entry.address); if (DBG) Log.d(TAG, "add address " + entry.address); gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0, 0, "", entry.address, (byte) entry.addr_type, new byte[0], new byte[0]); Loading @@ -924,7 +931,7 @@ public class ScanManager { break; case ScanFilterQueue.TYPE_LOCAL_NAME: logd("adding filters: " + entry.name); if (DBG) Log.d(TAG, "adding filters: " + entry.name); gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0, 0, entry.name, "", (byte) 0, new byte[0], new byte[0]); Loading Loading @@ -963,8 +970,10 @@ public class ScanManager { int onLostTimeout = getOnFoundOnLostTimeoutMillis(settings, false); int onFoundCount = getOnFoundOnLostSightings(settings); onLostTimeout = 10000; logd("configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " " if (DBG) { Log.d(TAG, "configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " " + onFoundCount + " " + numOfTrackingEntries); } FilterParams FiltValue = new FilterParams(scannerId, filterIndex, featureSelection, LIST_LOGIC_TYPE, FILTER_LOGIC_TYPE, rssiThreshold, rssiThreshold, deliveryMode, onFoundTimeout, onLostTimeout, onFoundCount, numOfTrackingEntries); Loading Loading @@ -1064,7 +1073,10 @@ public class ScanManager { break; default: val = 1; logd("Invalid setting for getNumOfMatches() " + settings.getNumOfMatches()); if (DBG) { Log.d(TAG, "Invalid setting for getNumOfMatches() " + settings.getNumOfMatches()); } } return val; } Loading Loading @@ -1144,8 +1156,4 @@ public class ScanManager { private native void gattClientReadScanReportsNative(int client_if, int scan_type); } private void logd(String s) { if (DBG) Log.d(TAG, s); } } Loading
android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +33 −23 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ class AdvertiseManager { * Constructor of {@link AdvertiseManager}. */ AdvertiseManager(GattService service, AdapterService adapterService) { logd("advertise manager created"); if (DBG) Log.d(TAG, "advertise manager created"); mService = service; mAdapterService = adapterService; } Loading @@ -74,7 +74,7 @@ class AdvertiseManager { } void cleanup() { logd("cleanup()"); if (DBG) Log.d(TAG, "cleanup()"); cleanupNative(); mAdvertisers.clear(); sTempRegistrationId = -1; Loading Loading @@ -136,9 +136,10 @@ class AdvertiseManager { void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status) throws Exception { if (DBG) if (DBG) { Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id); Loading @@ -163,8 +164,10 @@ class AdvertiseManager { } void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { logd("onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading Loading @@ -197,14 +200,14 @@ class AdvertiseManager { int cb_id = --sTempRegistrationId; mAdvertisers.put(binder, new AdvertiserInfo(cb_id, deathRecipient, callback)); logd("startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder); if (DBG) Log.d(TAG, "startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder); startAdvertisingSetNative(parameters, adv_data, scan_response, periodicParameters, periodic_data, duration, maxExtAdvEvents, cb_id); } void onOwnAddressRead(int advertiser_id, int addressType, String address) throws RemoteException { logd("onOwnAddressRead() advertiser_id=" + advertiser_id); if (DBG) Log.d(TAG, "onOwnAddressRead() advertiser_id=" + advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading Loading @@ -278,7 +281,10 @@ class AdvertiseManager { } void onAdvertisingDataSet(int advertiser_id, int status) throws Exception { logd("onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -291,7 +297,9 @@ class AdvertiseManager { } void onScanResponseDataSet(int advertiser_id, int status) throws Exception { logd("onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) Log.d(TAG, "onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" + status); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -305,8 +313,10 @@ class AdvertiseManager { void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status) throws Exception { logd("onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); if (DBG) { Log.d(TAG, "onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -319,8 +329,10 @@ class AdvertiseManager { } void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception { logd("onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", status=" + status); if (DBG) { Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -334,8 +346,10 @@ class AdvertiseManager { } void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception { logd("onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" if (DBG) { Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -349,8 +363,10 @@ class AdvertiseManager { void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { logd("onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" if (DBG) { Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); if (entry == null) { Loading @@ -362,12 +378,6 @@ class AdvertiseManager { callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status); } private void logd(String s) { if (DBG) { Log.d(TAG, s); } } static { classInitNative(); } Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +18 −13 Original line number Diff line number Diff line Loading @@ -716,13 +716,14 @@ public class GattService extends ProfileService { void onScanResult(int event_type, int address_type, String address, int primary_phy, int secondary_phy, int advertising_sid, int tx_power, int rssi, int periodic_adv_int, byte[] adv_data) { if (VDBG) if (VDBG) { Log.d(TAG, "onScanResult() - event_type=0x" + Integer.toHexString(event_type) + ", address_type=" + address_type + ", address=" + address + ", primary_phy=" + primary_phy + ", secondary_phy=" + secondary_phy + ", advertising_sid=0x" + Integer.toHexString(advertising_sid) + ", tx_power=" + tx_power + ", rssi=" + rssi + ", periodic_adv_int=0x" + Integer.toHexString(periodic_adv_int)); } List<UUID> remoteUuids = parseUuids(adv_data); addScanResult(); Loading Loading @@ -1203,7 +1204,8 @@ public class GattService extends ProfileService { void onBatchScanStorageConfigured(int status, int clientIf) { if (DBG) { Log.d(TAG, "onBatchScanStorageConfigured() - clientIf="+ clientIf + ", status=" + status); Log.d(TAG, "onBatchScanStorageConfigured() - clientIf=" + clientIf + ", status=" + status); } mScanManager.callbackDone(clientIf, status); } Loading Loading @@ -1321,7 +1323,7 @@ public class GattService extends ProfileService { } private Set<ScanResult> parseFullResults(int numRecords, byte[] batchRecord) { Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord)); if (DBG) Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord)); Set<ScanResult> results = new HashSet<ScanResult>(numRecords); int position = 0; long now = SystemClock.elapsedRealtimeNanos(); Loading Loading @@ -1350,7 +1352,7 @@ public class GattService extends ProfileService { System.arraycopy(advertiseBytes, 0, scanRecord, 0, advertisePacketLen); System.arraycopy(scanResponseBytes, 0, scanRecord, advertisePacketLen, scanResponsePacketLen); Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord)); if (DBG) Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord)); results.add(new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), rssi, timestampNanos)); } Loading Loading @@ -1432,9 +1434,11 @@ public class GattService extends ProfileService { ScanSettings.CALLBACK_TYPE_MATCH_LOST, client); } } else { if (DBG) { Log.d(TAG, "Not reporting onlost/onfound : " + advertiserState + " scannerId = " + client.scannerId + " callbackType " + settings.getCallbackType()); + " scannerId = " + client.scannerId + " callbackType " + settings.getCallbackType()); } } } } Loading @@ -1446,7 +1450,7 @@ public class GattService extends ProfileService { Log.e(TAG, "Advertise app or callback is null"); return; } Log.d(TAG, "onScanParamSetupCompleted : " + status); if (DBG) Log.d(TAG, "onScanParamSetupCompleted : " + status); } // callback from ScanManager for dispatch of errors apps. Loading Loading @@ -1791,9 +1795,10 @@ public class GattService extends ProfileService { void clientConnect(int clientIf, String address, boolean isDirect, int transport, int phy) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (DBG) if (DBG) { Log.d(TAG, "clientConnect() - address=" + address + ", isDirect=" + isDirect + ", phy= " + phy); } gattClientConnectNative(clientIf, address, isDirect, transport, phy); } Loading @@ -1811,7 +1816,7 @@ public class GattService extends ProfileService { Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address); if (DBG) Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address); return; } Loading @@ -1824,7 +1829,7 @@ public class GattService extends ProfileService { Integer connId = mClientMap.connIdByAddress(clientIf, address); if (connId == null) { Log.d(TAG, "clientReadPhy() - no connection to " + address); if (DBG) Log.d(TAG, "clientReadPhy() - no connection to " + address); return; } Loading Loading @@ -2362,7 +2367,7 @@ public class GattService extends ProfileService { Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address); if (DBG) Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address); return; } Loading @@ -2375,7 +2380,7 @@ public class GattService extends ProfileService { Integer connId = mServerMap.connIdByAddress(serverIf, address); if (connId == null) { Log.d(TAG, "serverReadPhy() - no connection to " + address); if (DBG) Log.d(TAG, "serverReadPhy() - no connection to " + address); return; } Loading
android/app/src/com/android/bluetooth/gatt/GattServiceConfig.java +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ package com.android.bluetooth.gatt; * GattService configuration. */ /*package*/ class GattServiceConfig { public static final boolean DBG = true; public static final boolean DBG = false; public static final boolean VDBG = false; public static final String TAG_PREFIX = "BtGatt."; public static final boolean DEBUG_ADMIN = true; Loading
android/app/src/com/android/bluetooth/gatt/PeriodicScanManager.java +10 −14 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class PeriodicScanManager { * Constructor of {@link SyncManager}. */ PeriodicScanManager(AdapterService adapterService) { logd("advertise manager created"); if (DBG) Log.d(TAG, "advertise manager created"); mAdapterService = adapterService; } Loading @@ -62,7 +62,7 @@ class PeriodicScanManager { } void cleanup() { logd("cleanup()"); if (DBG) Log.d(TAG, "cleanup()"); cleanupNative(); mSyncs.clear(); sTempRegistrationId = -1; Loading Loading @@ -114,8 +114,10 @@ class PeriodicScanManager { void onSyncStarted(int reg_id, int sync_handle, int sid, int address_type, String address, int phy, int interval, int status) throws Exception { logd("onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle + ", status=" + status); if (DBG) { Log.d(TAG, "onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle + ", status=" + status); } Map.Entry<IBinder, SyncInfo> entry = findSync(reg_id); if (entry == null) { Loading @@ -140,7 +142,7 @@ class PeriodicScanManager { void onSyncReport(int sync_handle, int tx_power, int rssi, int data_status, byte[] data) throws Exception { logd("onSyncReport() - sync_handle=" + sync_handle); if (DBG) Log.d(TAG, "onSyncReport() - sync_handle=" + sync_handle); Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle); if (entry == null) { Loading @@ -155,7 +157,7 @@ class PeriodicScanManager { } void onSyncLost(int sync_handle) throws Exception { logd("onSyncLost() - sync_handle=" + sync_handle); if (DBG) Log.d(TAG, "onSyncLost() - sync_handle=" + sync_handle); Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle); if (entry == null) { Loading Loading @@ -184,13 +186,13 @@ class PeriodicScanManager { int cb_id = --sTempRegistrationId; mSyncs.put(binder, new SyncInfo(cb_id, deathRecipient, callback)); logd("startSync() - reg_id=" + cb_id + ", callback: " + binder); if (DBG) Log.d(TAG, "startSync() - reg_id=" + cb_id + ", callback: " + binder); startSyncNative(sid, address, skip, timeout, cb_id); } void stopSync(IPeriodicAdvertisingCallback callback) { IBinder binder = toBinder(callback); logd("stopSync() " + binder); if (DBG) Log.d(TAG, "stopSync() " + binder); SyncInfo sync = mSyncs.remove(binder); if (sync == null) { Loading @@ -210,12 +212,6 @@ class PeriodicScanManager { stopSyncNative(sync_handle); } private void logd(String s) { if (DBG) { Log.d(TAG, s); } } static { classInitNative(); } Loading
android/app/src/com/android/bluetooth/gatt/ScanManager.java +33 −25 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class ScanManager { } void callbackDone(int scannerId, int status) { logd("callback done for scannerId - " + scannerId + " status - " + status); if (DBG) Log.d(TAG, "callback done for scannerId - " + scannerId + " status - " + status); if (status == 0) { mLatch.countDown(); } Loading Loading @@ -223,7 +223,7 @@ public class ScanManager { void handleStartScan(ScanClient client) { Utils.enforceAdminPermission(mService); logd("handling starting scan"); if (DBG) Log.d(TAG, "handling starting scan"); if (!isScanSupported(client)) { Log.e(TAG, "Scan settings not supported"); Loading Loading @@ -272,7 +272,7 @@ public class ScanManager { mScanNative.stopBatchScan(client); } if (client.appDied) { logd("app died, unregister scanner - " + client.scannerId); if (DBG) Log.d(TAG, "app died, unregister scanner - " + client.scannerId); mService.unregisterScanner(client.scannerId); } } Loading Loading @@ -440,15 +440,19 @@ public class ScanManager { } void configureRegularScanParams() { logd("configureRegularScanParams() - queue=" + mRegularScanClients.size()); if (DBG) { Log.d(TAG, "configureRegularScanParams() - queue=" + mRegularScanClients.size()); } int curScanSetting = Integer.MIN_VALUE; ScanClient client = getAggressiveClient(mRegularScanClients); if (client != null) { curScanSetting = client.settings.getScanMode(); } logd("configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting); if (DBG) { Log.d(TAG, "configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting); } if (curScanSetting != Integer.MIN_VALUE && curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) { Loading @@ -459,15 +463,18 @@ public class ScanManager { scanWindow = Utils.millsToUnit(scanWindow); scanInterval = Utils.millsToUnit(scanInterval); gattClientScanNative(false); logd("configureRegularScanParams - scanInterval = " + scanInterval + "configureRegularScanParams - scanWindow = " + scanWindow); if (DBG) { Log.d(TAG, "configureRegularScanParams - scanInterval = " + scanInterval + "configureRegularScanParams - scanWindow = " + scanWindow); } gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow); gattClientScanNative(true); mLastConfiguredScanSetting = curScanSetting; } } else { mLastConfiguredScanSetting = curScanSetting; logd("configureRegularScanParams() - queue emtpy, scan stopped"); if (DBG) Log.d(TAG, "configureRegularScanParams() - queue emtpy, scan stopped"); } } Loading Loading @@ -539,7 +546,7 @@ public class ScanManager { BatchScanParams batchScanParams = getBatchScanParams(); // Stop batch if batch scan params changed and previous params is not null. if (mBatchScanParms != null && (!mBatchScanParms.equals(batchScanParams))) { logd("stopping BLe Batch"); if (DBG) Log.d(TAG, "stopping BLe Batch"); resetCountDownLatch(); gattClientStopBatchScanNative(scannerId); waitForCallback(); Loading @@ -550,11 +557,11 @@ public class ScanManager { // Start batch if batchScanParams changed and current params is not null. if (batchScanParams != null && (!batchScanParams.equals(mBatchScanParms))) { int notifyThreshold = 95; logd("Starting BLE batch scan"); if (DBG) Log.d(TAG, "Starting BLE batch scan"); int resultType = getResultType(batchScanParams); int fullScanPercent = getFullScanStoragePercent(resultType); resetCountDownLatch(); logd("configuring batch scan storage, appIf " + client.scannerId); if (DBG) Log.d(TAG, "configuring batch scan storage, appIf " + client.scannerId); gattClientConfigBatchScanStorageNative(client.scannerId, fullScanPercent, 100 - fullScanPercent, notifyThreshold); waitForCallback(); Loading Loading @@ -667,7 +674,7 @@ public class ScanManager { } mRegularScanClients.remove(client); if (numRegularScanClients() == 0) { logd("stop scan"); if (DBG) Log.d(TAG, "stop scan"); gattClientScanNative(false); } removeScanFilters(client.scannerId); Loading @@ -684,7 +691,7 @@ public class ScanManager { // The scan should continue for background scans configureRegularScanParams(); if (numRegularScanClients() == 0) { logd("stop scan"); if (DBG) Log.d(TAG, "stop scan"); gattClientScanNative(false); } } Loading Loading @@ -719,7 +726,7 @@ public class ScanManager { } void flushBatchResults(int scannerId) { logd("flushPendingBatchResults - scannerId = " + scannerId); if (DBG) Log.d(TAG, "flushPendingBatchResults - scannerId = " + scannerId); if (mBatchScanParms.fullScanscannerId != -1) { resetCountDownLatch(); gattClientReadScanReportsNative(mBatchScanParms.fullScanscannerId, Loading Loading @@ -898,10 +905,10 @@ public class ScanManager { private void addFilterToController(int scannerId, ScanFilterQueue.Entry entry, int filterIndex) { logd("addFilterToController: " + entry.type); if (DBG) Log.d(TAG, "addFilterToController: " + entry.type); switch (entry.type) { case ScanFilterQueue.TYPE_DEVICE_ADDRESS: logd("add address " + entry.address); if (DBG) Log.d(TAG, "add address " + entry.address); gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0, 0, "", entry.address, (byte) entry.addr_type, new byte[0], new byte[0]); Loading @@ -924,7 +931,7 @@ public class ScanManager { break; case ScanFilterQueue.TYPE_LOCAL_NAME: logd("adding filters: " + entry.name); if (DBG) Log.d(TAG, "adding filters: " + entry.name); gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0, 0, entry.name, "", (byte) 0, new byte[0], new byte[0]); Loading Loading @@ -963,8 +970,10 @@ public class ScanManager { int onLostTimeout = getOnFoundOnLostTimeoutMillis(settings, false); int onFoundCount = getOnFoundOnLostSightings(settings); onLostTimeout = 10000; logd("configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " " if (DBG) { Log.d(TAG, "configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " " + onFoundCount + " " + numOfTrackingEntries); } FilterParams FiltValue = new FilterParams(scannerId, filterIndex, featureSelection, LIST_LOGIC_TYPE, FILTER_LOGIC_TYPE, rssiThreshold, rssiThreshold, deliveryMode, onFoundTimeout, onLostTimeout, onFoundCount, numOfTrackingEntries); Loading Loading @@ -1064,7 +1073,10 @@ public class ScanManager { break; default: val = 1; logd("Invalid setting for getNumOfMatches() " + settings.getNumOfMatches()); if (DBG) { Log.d(TAG, "Invalid setting for getNumOfMatches() " + settings.getNumOfMatches()); } } return val; } Loading Loading @@ -1144,8 +1156,4 @@ public class ScanManager { private native void gattClientReadScanReportsNative(int client_if, int scan_type); } private void logd(String s) { if (DBG) Log.d(TAG, s); } }