Skip to content

Fix failure to stop scans #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Enhancements:

Bug Fixes:

- TODO
- Fix failure to stop scanning when unbinding from service or when the between scan period
is nonzero. (#507, David G. Young)

### 2.10 / 2017-04-21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public void stop() {
mScanningEnabled = false;
if (mScanCyclerStarted) {
scanLeDevice(false);
LogManager.d(TAG, "forcing scanning to stop even for devices capable of multiple detections per cycle");
stopScan();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is stopScan() required here?

The call to scanLeDevice(false) will call it.

} else {
LogManager.d(TAG, "scanning already stopped");
}
Expand Down Expand Up @@ -285,7 +287,7 @@ private void finishScanCycle() {
// so it is best avoided. If we know the device has detected to distinct
// packets in the same cycle, we will not restart scanning and just keep it
// going.
if (!getDistinctPacketsDetectedPerScan()) {
if (!getDistinctPacketsDetectedPerScan() || mBetweenScanPeriod != 0) {
long now = SystemClock.elapsedRealtime();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
mBetweenScanPeriod+mScanPeriod < ANDROID_N_MIN_SCAN_CYCLE_MILLIS &&
Expand Down