cph-cachet / carp.sensing-flutter

CARP Mobile Sensing for Flutter, including mobile sensing framework, data backend support, and the CARP mobile sensing app.
MIT License
80 stars 28 forks source link

Update after 'Save the actual measurement range in app_usage' cph-cachet/flutter-plugins #282

Closed sc00n closed 1 year ago

sc00n commented 2 years ago

The big problem with the previous version is that the range in which the app usage was measured was not saved. This range cannot be set and therefore is not the same as the input time range (see https://github.com/cph-cachet/flutter-plugins/issues/592). Additionally some extra information on appusage is gathered (last time app was in foreground).

First of course the pull request from https://github.com/cph-cachet/flutter-plugins/pull/624 needs to be accepted. After that there probably needs to be a change in pubspec.yaml.

This pull requests makes sure that the range for each app is saved. Instead of one, there are now 4 maps in the output.

  Map<String, int> usage = {};
  Map<String,DateTime> startRange={};
  Map<String,DateTime>stopRange={};
  Map<String,DateTime>lastUseForeground={};

The maps go from the string of the package name to the following: usage : total time in foreground startRange: The start of the range stopRange: The end of the range lastUseForeground: The last time the app was in foreground

I'm not sure if 4 separate maps is the best way of outputting the information though.

Additionally, the maps now have the full package name. Only taking the last part doesn't give enough information for all apps. Examples:

I think I did the automatic JsonSerializableGenerator correct, but I have no experience with this...