Chromium Code Reviews| 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]; |