В документации API указано, что для получения результата, такого как Google Fit App, необходимо запросить шаги у источника данных derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
https://developers.google.com/fit/scenarios/read-daily-step-total
https://developers.google.com/fit/faq#get-step-count
На практике это в большинстве случаев кажется правильным, но иногда результаты оказываются далеко не такими.
Проводя некоторые тесты, я заметил, что иногда использование источника данных derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas
дает мне лучшие результаты или, по крайней мере, значения, более похожие на значения, показанные в приложении Google Fit.
Я думаю, что если пользователь использует больше устройств для подсчета шагов, этот источник данных объединит все шаги, и это неправильно.
Правильно ли использовать источник данных estimated_steps
или я должен переключиться на merge_step_deltas
?
Или это что-то еще, что я могу сделать, чтобы получить правильное количество шагов?
Реальный пример
Шаги клиента не совпадают с шагами, показанными в приложении Google Fit.
Вот его список источников данных
{
"dataSource": [
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "duration",
"format": "integer"
}
],
"name": "com.google.active_minutes"
},
"dataStreamName": "from_activity<-merge_activity_segments",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.active_minutes:com.google.android.gms:from_activity<-merge_activity_segments",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "duration",
"format": "integer"
}
],
"name": "com.google.active_minutes"
},
"dataStreamName": "from_steps<-estimated_steps",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.active_minutes:com.google.android.gms:from_steps<-estimated_steps",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "duration",
"format": "integer"
}
],
"name": "com.google.active_minutes"
},
"dataStreamName": "merge_active_minutes",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.active_minutes:com.google.android.gms:merge_active_minutes",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "merge_activity_segments",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "platform_activity_segments",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:platform_activity_segments",
"type": "derived"
},
{
"dataStreamName": "activity_from_steps",
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataQualityStandard": [],
"application": {
"packageName": "com.google.android.gms"
},
"device": {
"model": "SM-A600FN",
"version": "",
"type": "phone",
"uid": "324bd687",
"manufacturer": "samsung"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:samsung:SM-A600FN:324bd687:activity_from_steps",
"type": "derived"
},
{
"dataStreamName": "from_activity_samples<-derived:com.google.activity.samples:com.google.android.gms:samsung:SM-A600FN:324bd687:detailed",
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataQualityStandard": [],
"application": {
"packageName": "com.google.android.gms"
},
"device": {
"model": "SM-A600FN",
"version": "",
"type": "phone",
"uid": "324bd687",
"manufacturer": "samsung"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:samsung:SM-A600FN:324bd687:from_activity_samples<-derived:com.google.activity.samples:com.google.android.gms:samsung:SM-A600FN:324bd687:detailed",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "calories",
"format": "floatPoint"
}
],
"name": "com.google.calories.expended"
},
"dataStreamName": "from_activities",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.calories.expended:com.google.android.gms:from_activities",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "calories",
"format": "floatPoint"
}
],
"name": "com.google.calories.expended"
},
"dataStreamName": "merge_calories_expended",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.calories.expended:com.google.android.gms:merge_calories_expended",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "calories",
"format": "floatPoint"
}
],
"name": "com.google.calories.expended"
},
"dataStreamName": "platform_calories_expended",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "from_activity<-merge_activity_segments",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_minutes:com.google.android.gms:from_activity<-merge_activity_segments",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "from_heart_rate<-merge_heart_rate_bpm",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_minutes:com.google.android.gms:from_heart_rate<-merge_heart_rate_bpm",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "from_steps<-estimated_steps",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_minutes:com.google.android.gms:from_steps<-estimated_steps",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "merge_heart_minutes",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes",
"type": "derived"
},
{
"dataStreamName": "soft_step_counter",
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.cumulative"
},
"dataQualityStandard": [],
"application": {
"packageName": "com.google.android.gms"
},
"device": {
"model": "SM-A600FN",
"version": "",
"type": "phone",
"uid": "324bd687",
"manufacturer": "samsung"
},
"dataStreamId": "derived:com.google.step_count.cumulative:com.google.android.gms:samsung:SM-A600FN:324bd687:soft_step_counter",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataStreamName": "estimated_steps",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataStreamName": "merge_step_deltas",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas",
"type": "derived"
},
{
"dataStreamName": "derive_step_deltas<-derived:com.google.step_count.cumulative:com.google.android.gms:samsung:SM-A600FN:324bd687:soft_step_counter",
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataQualityStandard": [],
"application": {
"packageName": "com.google.android.gms"
},
"device": {
"model": "SM-A600FN",
"version": "",
"type": "phone",
"uid": "324bd687",
"manufacturer": "samsung"
},
"dataStreamId": "derived:com.google.step_count.delta:com.google.android.gms:samsung:SM-A600FN:324bd687:derive_step_deltas<-derived:com.google.step_count.cumulative:com.google.android.gms:samsung:SM-A600FN:324bd687:soft_step_counter",
"type": "derived"
},
{
"name": "Generic ANT+ Sensor",
"dataStreamName": "AntPlus.0.124",
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataQualityStandard": [],
"application": {
"packageName": "com.dsi.ant.plugins.antplus"
},
"dataStreamId": "raw:com.google.step_count.delta:com.dsi.ant.plugins.antplus:AntPlus.0.124",
"type": "raw"
}
]
}
В день 2 мая приложение показывает что-то вроде 15000 шагов (соответствует источнику данных merge_step_deltas
), а запрос шагов из источника данных estimated_steps
дает мне около 7000 шагов.
derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
{
"bucket": [
{
"startTimeMillis": "1556748000000",
"endTimeMillis": "1556834400000",
"dataset": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1556748469517481594",
"originDataSourceId": "derived:com.google.step_count.cumulative:com.google.android.gms:samsung:SM-A600FN:4dc460aaeb28b288:soft_step_counter",
"endTimeNanos": "1556831065968126307",
"value": [
{
"mapVal": [],
"intVal": 7601
}
],
"dataTypeName": "com.google.step_count.delta"
}
]
}
]
}
]
}
derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas
{
"bucket": [
{
"startTimeMillis": "1556748000000",
"endTimeMillis": "1556834400000",
"dataset": [
{
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1556748469517481594",
"originDataSourceId": "derived:com.google.step_count.cumulative:com.google.android.gms:samsung:SM-A600FN:4dc460aaeb28b288:soft_step_counter",
"endTimeNanos": "1556831065968126307",
"value": [
{
"mapVal": [],
"intVal": 15368
}
],
"dataTypeName": "com.google.step_count.delta"
}
]
}
]
}
]
}