|
...
|
...
|
@@ -210,17 +210,6 @@ class OHOSHealthRawDataCoreService { |
|
|
|
}
|
|
|
|
|
|
|
|
final userId = _userId;
|
|
|
|
final hasAuthorization = await _hasHealthReadAuthorization();
|
|
|
|
if (!hasAuthorization) {
|
|
|
|
_logInfo('skip calculate without OHOS health privacy authorization');
|
|
|
|
return HealthRawStressCalculationResult(
|
|
|
|
userId: userId,
|
|
|
|
hrvStressPoints: const <HealthRawHrvStressPoint>[],
|
|
|
|
realtimeStressPoints: const <HealthRawRealtimeStressPoint>[],
|
|
|
|
dailyStressPoints: const <HealthRawDailyStressPoint>[],
|
|
|
|
sleepResults: const <HealthRawSleepResult>[],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
await _localStore.ensureReadable(userId);
|
|
|
|
final effectiveEndTime =
|
|
|
|
endTime ?? DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
|
...
|
...
|
@@ -233,10 +222,19 @@ class OHOSHealthRawDataCoreService { |
|
|
|
if (effectiveEndTime < requestedStartTime) {
|
|
|
|
throw ArgumentError.value(endTime, 'endTime');
|
|
|
|
}
|
|
|
|
final syncResults = await _syncCalculationRawDataIfNeeded(
|
|
|
|
startTime: requestedStartTime,
|
|
|
|
endTime: effectiveEndTime,
|
|
|
|
);
|
|
|
|
final hasAuthorization = await _hasHealthReadAuthorization();
|
|
|
|
final syncResults = hasAuthorization
|
|
|
|
? await _syncCalculationRawDataIfNeeded(
|
|
|
|
startTime: requestedStartTime,
|
|
|
|
endTime: effectiveEndTime,
|
|
|
|
)
|
|
|
|
: const <OhosHealthRawDataSyncResult>[];
|
|
|
|
if (!hasAuthorization) {
|
|
|
|
_logInfo(
|
|
|
|
'skip OHOS raw data sync without health privacy authorization; '
|
|
|
|
'continue calculate and upload from local database',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
_logInfo(
|
|
|
|
'calculate_sync_finish startTime=$requestedStartTime '
|
|
|
|
'endTime=$effectiveEndTime syncResults=$syncResults',
|
|
...
|
...
|
@@ -495,9 +493,6 @@ class OHOSHealthRawDataCoreService { |
|
|
|
required int endTime,
|
|
|
|
int readChunkDays = defaultReadChunkDays,
|
|
|
|
}) async {
|
|
|
|
if (!await _hasHealthReadAuthorization()) {
|
|
|
|
return const <HealthKitRawDataPoint>[];
|
|
|
|
}
|
|
|
|
return _fetchRawDataInChunks(
|
|
|
|
dataType,
|
|
|
|
startTime,
|
|
...
|
...
|
@@ -511,9 +506,6 @@ class OHOSHealthRawDataCoreService { |
|
|
|
required int endTime,
|
|
|
|
int readChunkDays = defaultReadChunkDays,
|
|
|
|
}) async {
|
|
|
|
if (!await _hasHealthReadAuthorization()) {
|
|
|
|
return const <HealthKitRawDataPoint>[];
|
|
|
|
}
|
|
|
|
return _fetchSleepIntervalsInChunks(
|
|
|
|
startTime,
|
|
|
|
endTime,
|
|
...
|
...
|
@@ -525,9 +517,6 @@ class OHOSHealthRawDataCoreService { |
|
|
|
required int startTime,
|
|
|
|
required int endTime,
|
|
|
|
}) async {
|
|
|
|
if (!await _hasHealthReadAuthorization()) {
|
|
|
|
return const <HealthKitRawActivityDataPoint>[];
|
|
|
|
}
|
|
|
|
final points = await _rawDataSource.getRawActivityData(startTime, endTime);
|
|
|
|
return points
|
|
|
|
.where((e) => e.endTime >= startTime && e.endTime <= endTime)
|
|
...
|
...
|
@@ -581,6 +570,7 @@ class OHOSHealthRawDataCoreService { |
|
|
|
if (rawDataSource is! OhosHealthRawDataSource) {
|
|
|
|
return const <OhosHealthRawDataSyncResult>[];
|
|
|
|
}
|
|
|
|
await rawDataSource.getActivityGoal(refresh: true);
|
|
|
|
return rawDataSource.syncCalculationRawData(
|
|
|
|
startTime: startTime,
|
|
|
|
endTime: endTime,
|
...
|
...
|
|