Skip to content

Commit

Permalink
Merge pull request #626 from AltBeacon/fix-npe-on-extra-beacon-data-t…
Browse files Browse the repository at this point in the history
…racker

Fix NPE on extra beacon data tracker
  • Loading branch information
davidgyoung authored Dec 13, 2017
2 parents e20226d + d2b3004 commit 9dd917e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bug Fixes:
- Fix performance problems when using identifiers 3-15 bytes caused by
Identifier#toHexString(). (#615, David G. Young)
- Restore missing runningAverageRssi values (#621, David G. Young)
- Fix NPE on ExtraBeaconDataTracker (#626, David G. Young)
- Fix regression with `RunningAverageRssiFilter.setSampleExpirationMilliseconds`
being overwritten when committing ranged beacon measurements. (#629, Aaron Kromer)

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/altbeacon/beacon/service/ScanJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ScanJob extends JobService {

@Override
public boolean onStartJob(final JobParameters jobParameters) {
mScanHelper = new ScanHelper(this);
initialzeScanHelper();
if (jobParameters.getJobId() == IMMEDIATE_SCAN_JOB_ID) {
LogManager.i(TAG, "Running immediate scan job: instance is "+this);
}
Expand Down Expand Up @@ -164,8 +164,8 @@ private void stopScanning() {
LogManager.d(TAG, "Scanning stopped");
}

// Returns true of scanning actually was started, false if it did not need to be
private boolean restartScanning() {
private void initialzeScanHelper() {
mScanHelper = new ScanHelper(this);
mScanState = ScanState.restore(ScanJob.this);
mScanState.setLastScanStartTimeMillis(System.currentTimeMillis());
mScanHelper.setMonitoringStatus(mScanState.getMonitoringStatus());
Expand All @@ -175,10 +175,13 @@ private boolean restartScanning() {
if (mScanHelper.getCycledScanner() == null) {
mScanHelper.createCycledLeScanner(mScanState.getBackgroundMode(), null);
}
}

// Returns true of scanning actually was started, false if it did not need to be
private boolean restartScanning() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mScanHelper.stopAndroidOBackgroundScan();
}

long scanPeriod = mScanState.getBackgroundMode() ? mScanState.getBackgroundScanPeriod() : mScanState.getForegroundScanPeriod();
long betweenScanPeriod = mScanState.getBackgroundMode() ? mScanState.getBackgroundBetweenScanPeriod() : mScanState.getForegroundBetweenScanPeriod();
mScanHelper.getCycledScanner().setScanPeriods(scanPeriod,
Expand Down

0 comments on commit 9dd917e

Please sign in to comment.