The FakeDataLibrary generates periodically fake metrics (Activity, HRV, PPG, Workout, Sleep).
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.maximemmt:MMTFakeDataGenerator:2.0'
}
The FakeDataLibrary is based on a background service which is periodically called in order to generate fake metric data. The period can be set with the function:
void setFakeDataRefreshPeriodMs(long periodMs)
Example:
setFakeDataRefreshPeriodMs(30*1000L); // Set the refresh period to 30 seconds
By default, the period is set to 5 minutes (it sticks to the functionment of the watch, which sends data every 5 minutes to the app). Each minute, the service will be called, and new fake data will be added into the Realm database.
You also have the possibility to choose which metric will be enabled/disabled (Activity/HRV/PPG/Workout) by calling the following functions with state set to true (metric enabled) or to false (metric disabled):
void enableActivity(state)
void enableHRV(state)
void enablePPG(state)
void enableWorkout(state)
Example (to enable HRV + PPG and disable Activity + workout):
enableActivity(false);
enableHRV(true);
enablePPG(true);
enableWorkout(false);
By default, only Activity and HRV metric are enabled.
To start the service, please use this function:
void startFakeDataService(Activity activity, Context context)
Example:
startFakeDataService(MainActivity.this, getApplicationContext());
To stop this service, please use this function:
void stopFakeDataService(Activity activity, Context context)
Example:
stopFakeDataService(MainActivity.this, getApplicationContext());
If you want to erase all the fake data generated by the FakeDataLibrary, use this function:
void eraseAllRealmDatabase()
Example:
eraseAllRealmDatabase();
Please note that the Sleep metric is not automatically generated by the FakeDataGeneratorService, since with a real watch, the app can't determine the value of the sleep state during the night. After the wake-up, the app retrieve the full night and store it into the Realm database : this library emulate the same behavior. To generate a fake sleep, please call this function:
void generateFakeSleepData()
Example:
generateFakeSleepData();
The generated sleep is always with the same pattern, and the end date is always the current date at 07:40:00
To get/delete the raw data, it is needed to use a dataTypeEnum, whose possible values are:
public enum DataTypeEnum {
ACTIVITY,
HRV,
PPG,
SLEEP,
WORKOUT;
}
To get all the data of one of the metrics:
RealmResults getRawData(DataTypeEnum dataTypeEnum)
Example:
RealmResults sleepResults = getRawData(SLEEP);
To get all the data of one metric whose timestamps are between 2 specified timestamps:
RealmResults getRawDataBetweenTimestamps(DataTypeEnum dataTypeEnum, long timestampStart, long timestampStop)
Example:
RealmResults sleepFilteredResults = getRawDataBetweenTimestamps(SLEEP, 1588629600906L, 1588629840906L);
To get all the data of one metric whose timestamps are older or equal than a particular timestamp:
RealmResults getRawDataOlderOrEqualThanTimestamp(DataTypeEnum dataTypeEnum, long timestampMax)
Example:
RealmResults sleepOlderResults = getRawDataOlderOrEqualThanTimestamp(SLEEP, 1588629600906L);
To get all the data of one metric whose timestamps are newer or equal than a particular timestamp:
RealmResults getRawDataNewerOrEqualThanTimestamp(DataTypeEnum dataTypeEnum, long timestampMin)
Example:
RealmResults sleepNewerResults = getRawDataNewerOrEqualThanTimestamp(SLEEP, 1588629600906L);
To get all the data of one of the metrics:
RealmResults deleteRawData(DataTypeEnum dataTypeEnum)
Example:
deleteRawData(SLEEP);
To delete all the data of one metric whose timestamps are between 2 specified timestamps:
void deleteRawDataBetweenTimestamps(DataTypeEnum dataTypeEnum, final long timestampStart, final long timestampStop)
Example:
deleteRawDataBetweenTimestamps(SLEEP, 1588629600906L, 1588629840906L);
To delete all the data of one metric whose timestamps are older or equal than a particular timestamp:
void deleteRawDataOlderOrEqualThanTimestamp(DataTypeEnum dataTypeEnum, final long timestampMax)
Example:
deleteRawDataOlderOrEqualThanTimestamp(SLEEP, 1588629780821L);
To delete all the data of one metric whose timestamps are newer or equal than a particular timestamp:
void deleteRawDataNewerOrEqualThanTimestamp(DataTypeEnum dataTypeEnum, final long timestampMin)
Example:
deleteRawDataNewerOrEqualThanTimestamp(SLEEP, 1588656510924L);
MetricActivity: it contains all the data dealing with activity:
timestamp -> the unix timestamp in milliseconds
date -> the date formated with ISO8601
bpm -> the heart beat per minute (generated values: from 50 to 170 bpm)
q -> the quality factor of the measurment (generated values: from 0 to 4)
last_steps -> the last number of steps recorded (generated values: from 1 to 7)
activity_type -> the activity type (generated values: from 1 to 7)
speed -> the last speed measured (generated values: from 0 to 30 km/h)
skin_proximity -> the skin proximity (always 0)
energy_exp -> the energy of the expiration (generated values: from 0 to 200)
respiration_rate -> the respiration rate (always 0)
MetricHRV: it contains the hear rate variability data:
timestamp -> the unix timestamp in milliseconds
date -> the date formated with ISO8601
beats -> the heart rate variability (generated values: from 400 to 2000 in milliseconds)
MetricPPG: it contains the raw data of the PPG:
timestamp -> the unix timestamp in milliseconds
date -> the date formated with ISO8601
ppg -> the PPG value (from 14'000 to 17'000 without unit)
acc -> the euclidean norm of the 3 axis of the accelerometer (from 240 to 270 without unit )
bpm -> the last heart beat per minute (generated values: from 50 to 170 bpm)
MetricWorkout: it contains everything dealing with the workouts:
timestamp -> the unix timestamp in milliseconds
date -> the date formated with ISO8601
bpm -> the heart beat per minute (generated values: from 50 to 170 bpm)
q -> the quality factor of the measurment (generated values: from 0 to 4)
last_steps -> the last number of steps recorded (generated values: from 1 to 7)
activity_type -> the activity type (generated values: from 1 to 7)
speed -> the last speed measured (generated values: from 0 to 30 km/h)
energy_exp -> the energy of the expiration (generated values: from 0 to 10)
respiration_rate -> the respiration rate (generated values: from 0 to 10)
vo2_max -> the maximum expired vo2 (generated values: from 0 to 100)
cfi -> the cfi, for development (generated values: from 0 to 10)
MetricSleep: it contains the sleep sessions:
timestamp -> the unix timestamp in milliseconds
date -> the date formated with ISO8601
sleepState -> the sleep state. Possible values: Awake=4, RemSleep=3, LightSleep=2, DeepSleep=1, Unspecified=0