Skip to content

Commit

Permalink
Merge pull request #432 from opsct/NoMonitoringInBg
Browse files Browse the repository at this point in the history
No Monitoring information after killing an application built with the minify mode
  • Loading branch information
davidgyoung authored Nov 13, 2016
2 parents 158ac20 + dd25a6f commit 7d3eb1d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public void stopRangingBeaconsInRegion(Region region) {

public void startMonitoringBeaconsInRegion(Region region, Callback callback) {
LogManager.d(TAG, "startMonitoring called");
monitoringStatus.addRegion(region);
monitoringStatus.addRegion(region, callback);
LogManager.d(TAG, "Currently monitoring %s regions.", monitoringStatus.regionsCount());
mCycledScanner.start();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/altbeacon/beacon/service/Callback.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public Intent getIntent() {
* @return false if it callback cannot be made
*/
public boolean call(Context context, String dataName, Parcelable data) {
if(intent == null){
initializeIntent();
}
if (intent != null) {
LogManager.d(TAG, "attempting callback via intent: %s", intent.getComponent());
intent.putExtra(dataName, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MonitoringStatus(Context context) {
this.mContext = context;
}

public synchronized void addRegion(Region region) {
public synchronized void addRegion(Region region, Callback callback) {
if (getRegionsStateMap().containsKey(region)) {
// if the region definition hasn't changed, becasue if it has, we need to clear state
// otherwise a region with the same uniqueId can never be changed
Expand All @@ -70,7 +70,7 @@ public synchronized void addRegion(Region region) {
}
}
}
getRegionsStateMap().put(region, new RegionMonitoringState(new Callback(mContext.getPackageName())));
getRegionsStateMap().put(region, new RegionMonitoringState(callback));
saveMonitoringStatusIfOn();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void savesStatusOfUpTo50RegionsTest() throws Exception {
MonitoringStatus monitoringStatus = new MonitoringStatus(context);
for (int i = 0; i < 50; i++) {
Region region = new Region(""+i, null, null, null);
monitoringStatus.addRegion(region);
monitoringStatus.addRegion(region, null);
}
monitoringStatus.saveMonitoringStatusIfOn();
MonitoringStatus monitoringStatus2 = new MonitoringStatus(context);
Expand All @@ -58,7 +58,7 @@ public void clearsStatusOfOver50RegionsTest() throws Exception {
MonitoringStatus monitoringStatus = new MonitoringStatus(context);
for (int i = 0; i < 51; i++) {
Region region = new Region(""+i, null, null, null);
monitoringStatus.addRegion(region);
monitoringStatus.addRegion(region, null);
}
monitoringStatus.saveMonitoringStatusIfOn();
MonitoringStatus monitoringStatus2 = new MonitoringStatus(context);
Expand All @@ -72,7 +72,7 @@ public void refusesToRestoreRegionsIfTooMuchTimeHasPassedSinceSavingTest() throw
MonitoringStatus monitoringStatus = new MonitoringStatus(context);
for (int i = 0; i < 50; i++) {
Region region = new Region(""+i, null, null, null);
monitoringStatus.addRegion(region);
monitoringStatus.addRegion(region, null);
}
monitoringStatus.saveMonitoringStatusIfOn();
// Set update time to one hour ago
Expand Down

0 comments on commit 7d3eb1d

Please sign in to comment.