Browse Source

Bug Fix: Prevent triggers getting categorised in wrong folder on disk

- setting mPrefs.setCurrentSession() in alert() is errorneous since the file corresponding
  to the `EventTrigger` will be created by then. This will be created with an in-correct path;
  ie, with the session folder corresponding to the previous session.
- trade-off: the session folder will have a timestamp different to that of the `Event`
  start timestamp in the DB (and in UI). This may cause a difficulty in navigating the
  directories in disk.

Signed-off-by: Arka Prava Basu <arkaprava94@gmail.com>
Arka Prava Basu 9 months ago
parent
commit
97936d392c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/main/java/org/havenapp/main/service/MonitorService.java

+ 3 - 2
src/main/java/org/havenapp/main/service/MonitorService.java

@@ -237,6 +237,9 @@ public class MonitorService extends Service {
237 237
     {
238 238
         mIsMonitoringActive = true;
239 239
 
240
+        // set current event start date in prefs
241
+        mPrefs.setCurrentSession(new Date(System.currentTimeMillis()));
242
+
240 243
         if (!mPrefs.getAccelerometerSensitivity().equals(PreferenceManager.OFF)) {
241 244
             mAccelManager = new AccelerometerMonitor(this);
242 245
             if(Build.VERSION.SDK_INT>=18) {
@@ -316,8 +319,6 @@ public class MonitorService extends Service {
316 319
                     .getEventDAO().insert(mLastEvent);
317 320
             mLastEvent.setId(eventId);
318 321
             doNotification = true;
319
-            // set current event start date in prefs
320
-            mPrefs.setCurrentSession(mLastEvent.getStartTime());
321 322
         }
322 323
         else if (mPrefs.getNotificationTimeMs() == 0)
323 324
         {