OSDN Git Service

Do not downgrade filtered scans to opportunistic
authorAndre Eisenbach <eisenbach@google.com>
Mon, 19 Sep 2016 19:23:15 +0000 (12:23 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 21 Sep 2016 18:22:05 +0000 (11:22 -0700)
Fixes: 31308591
Test: manual
Change-Id: I0d8bcffef9951c03607f7f3b25b79557062a9bec
(cherry picked from commit 8d6abb0a65bd4e9f4726a9c565b0c74fb6aed1a1)

src/com/android/bluetooth/gatt/ScanManager.java

index b7e1c07..ef103df 100644 (file)
@@ -240,7 +240,7 @@ public class ScanManager {
                 if (!mScanNative.isOpportunisticScanClient(client)) {
                     mScanNative.configureRegularScanParams();
 
-                    if (!mScanNative.isFirstMatchScanClient(client)) {
+                    if (!mScanNative.isExemptFromScanDowngrade(client)) {
                         Message msg = mHandler.obtainMessage(MSG_SCAN_TIMEOUT);
                         msg.obj = client;
                         // Only one timeout message should exist at any time
@@ -536,6 +536,12 @@ public class ScanManager {
             }
         }
 
+        private boolean isExemptFromScanDowngrade(ScanClient client) {
+          return isOpportunisticScanClient(client)
+              || isFirstMatchScanClient(client)
+              || !shouldUseAllPassFilter(client);
+        }
+
         private boolean isOpportunisticScanClient(ScanClient client) {
             return client.settings.getScanMode() == ScanSettings.SCAN_MODE_OPPORTUNISTIC;
         }
@@ -685,8 +691,9 @@ public class ScanManager {
 
         void regularScanTimeout() {
             for (ScanClient client : mRegularScanClients) {
-                if (!isOpportunisticScanClient(client) && !isFirstMatchScanClient(client)) {
-                    logd("clientIf set to scan opportunisticly: " + client.clientIf);
+                if (!isExemptFromScanDowngrade(client)) {
+                    Log.w(TAG, "Moving scan client to opportunistic (clientIf "
+                          + client.clientIf + ")");
                     setOpportunisticScanClient(client);
                     client.stats.setScanTimeout();
                 }