senseobservationsystems / sense-android-library

Sense Platform library for Android
Apache License 2.0
12 stars 8 forks source link

Encryption abbvie update #150

Open kanekin opened 9 years ago

kanekin commented 9 years ago

Overview These changes were made mainly for the following purposes.

Details The following changes have been made in this branch:

A. SensePlatform.java :

  1. Added deleteAllLocalStorageData()
    • Local data had to be deleted on login with a different user from the previous login on Abbvie.
  2. 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.
  3. 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.
  4. Added getValues(..) with endDate and limit. (without startDate)
    • To implement A-2

B. DataTransmitter .java:

  1. 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

  1. 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.
  2. 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

  1. A bug fix in putInt() method.
    • It was calling putFloat() method in putInt(), and was causing classCastException.

E. BufferTransmitHandler.java

  1. 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

  1. Added several constants for new SharedPrefs attributes.
    • For H-2.

G. DbHelper.java

  1. Modified getWritableDatabase(). * Ricky knows about the change here.

H. LocalStorage.java

  1. Added deleteAllLocalValues()
    • For A-1.
  2. 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.
  3. 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

  1. Added a limit parameter to query()
    • There was no query method with limit for local data. Now we have it!