Loading android/app/src/com/android/bluetooth/gatt/AppScanStats.java +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ import com.android.bluetooth.btservice.BluetoothProto; // earliest recorded scan exits this window. static final long EXCESSIVE_SCANNING_PERIOD_MS = 30 * 1000; // Maximum msec before scan gets downgraded to opportunistic static final int SCAN_TIMEOUT_MS = 30 * 60 * 1000; String appName; int scansStarted = 0; int scansStopped = 0; Loading Loading @@ -162,6 +165,14 @@ import com.android.bluetooth.btservice.BluetoothProto; EXCESSIVE_SCANNING_PERIOD_MS; } synchronized boolean isScanningTooLong() { if (lastScans.isEmpty() || !isScanning) { return false; } return (System.currentTimeMillis() - startTime) > SCAN_TIMEOUT_MS; } // This function truncates the app name for privacy reasons. Apps with // four part package names or more get truncated to three parts, and apps // with three part package names names get truncated to two. Apps with two Loading android/app/src/com/android/bluetooth/gatt/ScanManager.java +8 −14 Original line number Diff line number Diff line Loading @@ -71,9 +71,6 @@ public class ScanManager { private static final int MSG_FLUSH_BATCH_RESULTS = 2; private static final int MSG_SCAN_TIMEOUT = 3; // Maximum msec before scan gets downgraded to opportunistic private static final int SCAN_TIMEOUT_MS = 30 * 60 * 1000; private static final String ACTION_REFRESH_BATCHED_SCAN = "com.android.bluetooth.gatt.REFRESH_BATCHED_SCAN"; Loading Loading @@ -219,7 +216,7 @@ public class ScanManager { handleFlushBatchResults(client); break; case MSG_SCAN_TIMEOUT: mScanNative.regularScanTimeout(); mScanNative.regularScanTimeout(client); break; default: // Shouldn't happen. Loading Loading @@ -254,8 +251,7 @@ public class ScanManager { Message msg = mHandler.obtainMessage(MSG_SCAN_TIMEOUT); msg.obj = client; // Only one timeout message should exist at any time mHandler.removeMessages(MSG_SCAN_TIMEOUT); mHandler.sendMessageDelayed(msg, SCAN_TIMEOUT_MS); mHandler.sendMessageDelayed(msg, AppScanStats.SCAN_TIMEOUT_MS); } } Loading Loading @@ -699,15 +695,13 @@ public class ScanManager { removeScanFilters(client.scannerId); } void regularScanTimeout() { for (ScanClient client : mRegularScanClients) { if (!isExemptFromScanDowngrade(client)) { Log.w(TAG, "Moving scan client to opportunistic (scannerId " + client.scannerId + ")"); void regularScanTimeout(ScanClient client) { if (!isExemptFromScanDowngrade(client) && client.stats.isScanningTooLong()) { Log.w(TAG, "Moving scan client to opportunistic (scannerId " + client.scannerId + ")"); setOpportunisticScanClient(client); client.stats.setScanTimeout(); } } // The scan should continue for background scans configureRegularScanParams(); Loading Loading
android/app/src/com/android/bluetooth/gatt/AppScanStats.java +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ import com.android.bluetooth.btservice.BluetoothProto; // earliest recorded scan exits this window. static final long EXCESSIVE_SCANNING_PERIOD_MS = 30 * 1000; // Maximum msec before scan gets downgraded to opportunistic static final int SCAN_TIMEOUT_MS = 30 * 60 * 1000; String appName; int scansStarted = 0; int scansStopped = 0; Loading Loading @@ -162,6 +165,14 @@ import com.android.bluetooth.btservice.BluetoothProto; EXCESSIVE_SCANNING_PERIOD_MS; } synchronized boolean isScanningTooLong() { if (lastScans.isEmpty() || !isScanning) { return false; } return (System.currentTimeMillis() - startTime) > SCAN_TIMEOUT_MS; } // This function truncates the app name for privacy reasons. Apps with // four part package names or more get truncated to three parts, and apps // with three part package names names get truncated to two. Apps with two Loading
android/app/src/com/android/bluetooth/gatt/ScanManager.java +8 −14 Original line number Diff line number Diff line Loading @@ -71,9 +71,6 @@ public class ScanManager { private static final int MSG_FLUSH_BATCH_RESULTS = 2; private static final int MSG_SCAN_TIMEOUT = 3; // Maximum msec before scan gets downgraded to opportunistic private static final int SCAN_TIMEOUT_MS = 30 * 60 * 1000; private static final String ACTION_REFRESH_BATCHED_SCAN = "com.android.bluetooth.gatt.REFRESH_BATCHED_SCAN"; Loading Loading @@ -219,7 +216,7 @@ public class ScanManager { handleFlushBatchResults(client); break; case MSG_SCAN_TIMEOUT: mScanNative.regularScanTimeout(); mScanNative.regularScanTimeout(client); break; default: // Shouldn't happen. Loading Loading @@ -254,8 +251,7 @@ public class ScanManager { Message msg = mHandler.obtainMessage(MSG_SCAN_TIMEOUT); msg.obj = client; // Only one timeout message should exist at any time mHandler.removeMessages(MSG_SCAN_TIMEOUT); mHandler.sendMessageDelayed(msg, SCAN_TIMEOUT_MS); mHandler.sendMessageDelayed(msg, AppScanStats.SCAN_TIMEOUT_MS); } } Loading Loading @@ -699,15 +695,13 @@ public class ScanManager { removeScanFilters(client.scannerId); } void regularScanTimeout() { for (ScanClient client : mRegularScanClients) { if (!isExemptFromScanDowngrade(client)) { Log.w(TAG, "Moving scan client to opportunistic (scannerId " + client.scannerId + ")"); void regularScanTimeout(ScanClient client) { if (!isExemptFromScanDowngrade(client) && client.stats.isScanningTooLong()) { Log.w(TAG, "Moving scan client to opportunistic (scannerId " + client.scannerId + ")"); setOpportunisticScanClient(client); client.stats.setScanTimeout(); } } // The scan should continue for background scans configureRegularScanParams(); Loading