From 015ab24c0ab5b01f068a3ac36578a9346c2a9391 Mon Sep 17 00:00:00 2001 From: Mehmet Murat Sevim Date: Mon, 11 May 2020 13:42:07 +0100 Subject: [PATCH] Add scan result logs. Some GMSCore modules are missing some scan result despite the peer device is discovered by the Android BT stack. These logs will help debug such problems. Bug: 154942993 Bug: 199827901 Test: IOP and BCST Tag: #stability Change-Id: I6bd98df09ea2beb695aa9b4ac63bde307e77b182 (cherry picked from commit db952a889cd494e20836dbfef47c60e79f7990a9) --- .../android/bluetooth/le/BluetoothLeScanner.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java index ee173dbc4ad46..e9bd64364e6e2 100644 --- a/core/java/android/bluetooth/le/BluetoothLeScanner.java +++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java @@ -514,16 +514,27 @@ public final class BluetoothLeScanner { @Override public void onScanResult(final ScanResult scanResult) { Attributable.setAttributionSource(scanResult, mAttributionSource); + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "onScanResult() - mScannerId=" + mScannerId); + } if (VDBG) Log.d(TAG, "onScanResult() - " + scanResult.toString()); // Check null in case the scan has been stopped synchronized (this) { - if (mScannerId <= 0) return; + if (mScannerId <= 0) { + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Ignoring result as scan stopped."); + } + return; + }; } Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "onScanResult() - handler run"); + } mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, scanResult); } });