diff --git a/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/DataCollectionService.java b/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/DataCollectionService.java index e92d346..ff1b04e 100644 --- a/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/DataCollectionService.java +++ b/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/DataCollectionService.java @@ -152,31 +152,40 @@ protected Boolean doInBackground(Integer... params) { boolean success = new Rest(mContext).getBg(requestCount); Thread.sleep(10000); if (success) { - //quick fix: stay awake a bit to handover wakelog + // stay awake a bit to handover wakelog PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE); - powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, - "quickFix2").acquire(TIMEOUT); + powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "quickFix2").acquire(TIMEOUT); mContext.startService(new Intent(mContext, WatchUpdaterService.class)); } getApplicationContext().startService(new Intent(getApplicationContext(), Notifications.class)); if(mWakeLock != null && mWakeLock.isHeld()) { mWakeLock.release(); } - return true; + if (success) + { + return true; + } } + } + catch (RetrofitError e) { Log.d("Retrofit Error: ", "BOOOO"); } + catch (InterruptedException exx) { Log.d("Interruption Error: ", "BOOOO"); } + catch (Exception ex) { Log.d("Unrecognized Error: ", "BOOOO"); } + try { if(mPrefs.getBoolean("share_poll", false)) { Log.d("ShareRest", "fetching " + requestCount); boolean success = new ShareRest(mContext).getBg(requestCount); Thread.sleep(10000); if (success) { - //test wakelock: stay awake a bit to handover wakelog + // stay awake a bit to handover wakelog PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE); - powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, - "quickFix3").acquire(TIMEOUT); + powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "quickFix3").acquire(TIMEOUT); mContext.startService(new Intent(mContext, WatchUpdaterService.class)); } getApplicationContext().startService(new Intent(getApplicationContext(), Notifications.class)); if(mWakeLock != null && mWakeLock.isHeld()) { mWakeLock.release(); } - return true; + if (success) + { + return true; + } } return true; } diff --git a/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/alerts/Notifications.java b/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/alerts/Notifications.java index d670f94..052bd40 100644 --- a/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/alerts/Notifications.java +++ b/mobile/src/main/java/com/dexdrip/stephenblack/nightwatch/alerts/Notifications.java @@ -139,7 +139,7 @@ private void FileBasedNotifications(Context context) { // If the last reading does not have a sensor, or that sensor was stopped. // or the sensor was started, but the 2 hours did not still pass? or there is no calibrations. // In all this cases, bgReading.sgv_double() should be 0. - if (bgReading != null && bgReading.sgv_double() != 0) { + if (bgReading != null && bgReading.sgv_double() != 0 && bgReading.timeSince() < 14400) { AlertType newAlert = AlertType.get_highest_active_alert(context, bgReading.sgv_double()); if (newAlert == null) {