Overview
These changes were made mainly for the following purposes.
Adding a limit parameter for the queries in local storage.
Persisting data from in-memory storage to disk storage periodically to avoid unexpected data loss in local storage
Adding a method to delete data in local storage entirely. It was required to delete the data of the previous user on Abbvie.
Details
The following changes have been made in this branch:
A. SensePlatform.java :
Added deleteAllLocalStorageData()
Local data had to be deleted on login with a different user from the previous login on Abbvie.
Added getLocalData(String sensorName, long endDate, int limit)
A method to get data points without specifying the startDate. It is used to obtain the last datapoints before a specific time in order to get baselines for sensors with cumulative values.
Added column id as the second "order by" parameter to getValues()
In case there are data points with the same time stamp in the local storage, this ensures to return the latest data point.
Added getValues(..) with endDate and limit. (without startDate)
To implement A-2
B. DataTransmitter .java:
Added periodic persistRecentData() call.
It saves the local data in in-memory storage to persisted storage periodically. This was the solution for the unexpected data loss problem on Abbvie.
C. SenseService.java
Added a persistRecentData() call on Destroy()
persistRecentData() before the service is destoyed. However, onDestroy() is not always called when the app crashes or force stop is performed. So this does not guarantee local data to be saved always.
A bug fix on registration.
It was sending encrypted username and password for user registration, which caused users can not log in with correct username and password after registration.
D. SenseServiceStub.java
A bug fix in putInt() method.
It was calling putFloat() method in putInt(), and was causing classCastException.
E. BufferTransmitHandler.java
Added limit to query in getUnsentData().
The basic flow here is calling getUnsentData() and send data to CommonSense via Post method.
Both of getUnsentData() and Post method has its limit. The intended usage of this construction seems to be that post method breaks down the data obtained by getUnsentData() into smaller pieces and send it until all the data is sent. However when the limit is not specified in getUnsentData(), then query(), which is called from getUnsentData(), takes the default limit of 100. Having 100 as the limit of getUnsentData() will cause sending only 100 data points every 30 minutes when the upload interval is set to Eco-mode, which does not seems to be the intended usage. To avoid having outOfMemory exception, the limit of getUnsentData() is currently set at 1000. It could be a larger number, or we should make it adaptive.
F. SensePrefs.java
Added several constants for new SharedPrefs attributes.
For H-2.
G. DbHelper.java
Modified getWritableDatabase().
* Ricky knows about the change here.
H. LocalStorage.java
Added deleteAllLocalValues()
For A-1.
Added deleteOldDataForCumulativeSensors( SharedPreferences prefs, long retentionLimit, String where )
This is meant for sensors with cumulative values. It will keep at least one data point before the retention limit in order to get correct baselines.
Modified deleteOldData()
It excludes the sensors with cumulative values, only if SharedPref preserveLastDatapoints is set to true. Sensors with cumulative values need to be specified in SharedPreference as well
I. SQLiteStorage.java
Added a limit parameter to query()
There was no query method with limit for local data. Now we have it!
Overview These changes were made mainly for the following purposes.
Details The following changes have been made in this branch:
A. SensePlatform.java :
B. DataTransmitter .java:
C. SenseService.java
D. SenseServiceStub.java
E. BufferTransmitHandler.java
F. SensePrefs.java
G. DbHelper.java
H. LocalStorage.java
I. SQLiteStorage.java