Loading android/app/src/com/android/bluetooth/gatt/ScanClient.java +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import java.util.Objects; public boolean hasNetworkSettingsPermission; public boolean hasNetworkSetupWizardPermission; public boolean hasScanWithoutLocationPermission; public boolean hasDisavowedLocation; public List<String> associatedDevices; public AppScanStats stats = null; Loading android/app/src/com/android/bluetooth/gatt/ScanManager.java +22 −10 Original line number Diff line number Diff line Loading @@ -301,7 +301,6 @@ public class ScanManager { void handleStartScan(ScanClient client) { Utils.enforceAdminPermission(mService); boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); if (DBG) { Log.d(TAG, "handling starting scan"); } Loading @@ -316,7 +315,7 @@ public class ScanManager { return; } if (!mScanNative.isOpportunisticScanClient(client) && !isScreenOn() && !isFiltered) { if (requiresScreenOn(client) && !isScreenOn()) { Log.w(TAG, "Cannot start unfiltered scan in screen-off. This scan will be resumed " + "later: " + client.scannerId); mSuspendedScanClients.add(client); Loading @@ -327,7 +326,7 @@ public class ScanManager { } final boolean locationEnabled = mLocationManager.isLocationEnabled(); if (!locationEnabled && !isFiltered) { if (requiresLocationOn(client) && !locationEnabled) { Log.i(TAG, "Cannot start unfiltered scan in location-off. This scan will be" + " resumed when location is on: " + client.scannerId); mSuspendedScanClients.add(client); Loading Loading @@ -357,6 +356,16 @@ public class ScanManager { } } private boolean requiresScreenOn(ScanClient client) { boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); return !mScanNative.isOpportunisticScanClient(client) && !isFiltered; } private boolean requiresLocationOn(ScanClient client) { boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); return !client.hasDisavowedLocation && !isFiltered; } void handleStopScan(ScanClient client) { Utils.enforceAdminPermission(mService); if (client == null) { Loading Loading @@ -419,8 +428,8 @@ public class ScanManager { void handleSuspendScans() { for (ScanClient client : mRegularScanClients) { if (!mScanNative.isOpportunisticScanClient(client) && (client.filters == null || client.filters.isEmpty())) { if ((requiresScreenOn(client) && !isScreenOn()) || (requiresLocationOn(client) && !mLocationManager.isLocationEnabled())) { /*Suspend unfiltered scans*/ if (client.stats != null) { client.stats.recordScanSuspend(client.scannerId); Loading @@ -433,11 +442,14 @@ public class ScanManager { void handleResumeScans() { for (ScanClient client : mSuspendedScanClients) { if ((!requiresScreenOn(client) || isScreenOn()) && (!requiresLocationOn(client) || mLocationManager.isLocationEnabled())) { if (client.stats != null) { client.stats.recordScanResume(client.scannerId); } handleStartScan(client); } } mSuspendedScanClients.clear(); } } Loading Loading @@ -1328,7 +1340,7 @@ public class ScanManager { @Override public void onDisplayChanged(int displayId) { if (isScreenOn() && mLocationManager.isLocationEnabled()) { if (isScreenOn()) { sendMessage(MSG_RESUME_SCANS, null); } else { sendMessage(MSG_SUSPEND_SCANS, null); Loading Loading @@ -1356,7 +1368,7 @@ public class ScanManager { String action = intent.getAction(); if (LocationManager.MODE_CHANGED_ACTION.equals(action)) { final boolean locationEnabled = mLocationManager.isLocationEnabled(); if (locationEnabled && isScreenOn()) { if (locationEnabled) { sendMessage(MSG_RESUME_SCANS, null); } else { sendMessage(MSG_SUSPEND_SCANS, null); Loading Loading
android/app/src/com/android/bluetooth/gatt/ScanClient.java +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import java.util.Objects; public boolean hasNetworkSettingsPermission; public boolean hasNetworkSetupWizardPermission; public boolean hasScanWithoutLocationPermission; public boolean hasDisavowedLocation; public List<String> associatedDevices; public AppScanStats stats = null; Loading
android/app/src/com/android/bluetooth/gatt/ScanManager.java +22 −10 Original line number Diff line number Diff line Loading @@ -301,7 +301,6 @@ public class ScanManager { void handleStartScan(ScanClient client) { Utils.enforceAdminPermission(mService); boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); if (DBG) { Log.d(TAG, "handling starting scan"); } Loading @@ -316,7 +315,7 @@ public class ScanManager { return; } if (!mScanNative.isOpportunisticScanClient(client) && !isScreenOn() && !isFiltered) { if (requiresScreenOn(client) && !isScreenOn()) { Log.w(TAG, "Cannot start unfiltered scan in screen-off. This scan will be resumed " + "later: " + client.scannerId); mSuspendedScanClients.add(client); Loading @@ -327,7 +326,7 @@ public class ScanManager { } final boolean locationEnabled = mLocationManager.isLocationEnabled(); if (!locationEnabled && !isFiltered) { if (requiresLocationOn(client) && !locationEnabled) { Log.i(TAG, "Cannot start unfiltered scan in location-off. This scan will be" + " resumed when location is on: " + client.scannerId); mSuspendedScanClients.add(client); Loading Loading @@ -357,6 +356,16 @@ public class ScanManager { } } private boolean requiresScreenOn(ScanClient client) { boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); return !mScanNative.isOpportunisticScanClient(client) && !isFiltered; } private boolean requiresLocationOn(ScanClient client) { boolean isFiltered = (client.filters != null) && !client.filters.isEmpty(); return !client.hasDisavowedLocation && !isFiltered; } void handleStopScan(ScanClient client) { Utils.enforceAdminPermission(mService); if (client == null) { Loading Loading @@ -419,8 +428,8 @@ public class ScanManager { void handleSuspendScans() { for (ScanClient client : mRegularScanClients) { if (!mScanNative.isOpportunisticScanClient(client) && (client.filters == null || client.filters.isEmpty())) { if ((requiresScreenOn(client) && !isScreenOn()) || (requiresLocationOn(client) && !mLocationManager.isLocationEnabled())) { /*Suspend unfiltered scans*/ if (client.stats != null) { client.stats.recordScanSuspend(client.scannerId); Loading @@ -433,11 +442,14 @@ public class ScanManager { void handleResumeScans() { for (ScanClient client : mSuspendedScanClients) { if ((!requiresScreenOn(client) || isScreenOn()) && (!requiresLocationOn(client) || mLocationManager.isLocationEnabled())) { if (client.stats != null) { client.stats.recordScanResume(client.scannerId); } handleStartScan(client); } } mSuspendedScanClients.clear(); } } Loading Loading @@ -1328,7 +1340,7 @@ public class ScanManager { @Override public void onDisplayChanged(int displayId) { if (isScreenOn() && mLocationManager.isLocationEnabled()) { if (isScreenOn()) { sendMessage(MSG_RESUME_SCANS, null); } else { sendMessage(MSG_SUSPEND_SCANS, null); Loading Loading @@ -1356,7 +1368,7 @@ public class ScanManager { String action = intent.getAction(); if (LocationManager.MODE_CHANGED_ACTION.equals(action)) { final boolean locationEnabled = mLocationManager.isLocationEnabled(); if (locationEnabled && isScreenOn()) { if (locationEnabled) { sendMessage(MSG_RESUME_SCANS, null); } else { sendMessage(MSG_SUSPEND_SCANS, null); Loading