Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: ios/chrome/common/physical_web/physical_web_scanner.mm

Issue 2507213003: Stop providing Physical Web metadata after Bluetooth is disabled (Closed)
Patch Set: report URLs as lost when Bluetooth is disabled Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/common/physical_web/physical_web_scanner.mm
diff --git a/ios/chrome/common/physical_web/physical_web_scanner.mm b/ios/chrome/common/physical_web/physical_web_scanner.mm
index d35a6689a3aa44caa3fe2e9b864945c8a3628aa6..ff21017c5de75617e46b2b6a617632caa5c7f2e8 100644
--- a/ios/chrome/common/physical_web/physical_web_scanner.mm
+++ b/ios/chrome/common/physical_web/physical_web_scanner.mm
@@ -160,9 +160,15 @@ enum BeaconType {
}
pendingStart_ = NO;
started_ = NO;
+ if (onLostDetectionEnabled_ && [devices_ count]) {
+ [delegate_ scannerUpdatedDevices:self];
+ }
}
- (NSArray*)devices {
+ if (![self bluetoothEnabled]) {
+ return [NSArray array];
+ }
return [devices_ sortedArrayUsingComparator:^(id obj1, id obj2) {
PhysicalWebDevice* device1 = obj1;
PhysicalWebDevice* device2 = obj2;
@@ -265,11 +271,6 @@ enum BeaconType {
}
- (void)reallyStop {
- if (updateTimer_.get()) {
- [updateTimer_ invalidate];
- updateTimer_.reset();
- }
-
[centralManager_ stopScan];
}
@@ -320,12 +321,19 @@ enum BeaconType {
// For unknown reasons, when scanning for longer periods (on the order of
// minutes), the scanner is less reliable at detecting all nearby URLs. As a
// workaround, we restart the scanner each time we check for lost URLs.
- NSArray* serviceUUIDs = @[
- [CBUUID UUIDWithString:kUriBeaconServiceUUID],
- [CBUUID UUIDWithString:kEddystoneBeaconServiceUUID]
- ];
- [centralManager_ stopScan];
- [centralManager_ scanForPeripheralsWithServices:serviceUUIDs options:nil];
+ if (!pendingStart_) {
+ NSArray* serviceUUIDs = @[
+ [CBUUID UUIDWithString:kUriBeaconServiceUUID],
+ [CBUUID UUIDWithString:kEddystoneBeaconServiceUUID]
+ ];
+ [centralManager_ stopScan];
+ [centralManager_ scanForPeripheralsWithServices:serviceUUIDs options:nil];
+ }
+
+ if (updateTimer_.get() && pendingStart_ && [devices_ count] == 0) {
+ [updateTimer_ invalidate];
+ updateTimer_.reset();
+ }
}
#pragma mark -
@@ -338,7 +346,6 @@ enum BeaconType {
} else {
if (started_ && !pendingStart_) {
pendingStart_ = YES;
- [self reallyStop];
mattreynolds 2016/11/18 00:03:25 This was a bug, calling [centralManager_ stopScan]
}
}
[delegate_ scannerBluetoothStatusUpdated:self];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698