Commit f027d9eab119eafaa346091ea7b1671732d56ba4

Authored by 权海
1 parent 3e164451

feat(ui):华为目标值的获取和上传

xx

feat(ui):修复ohos目标写法

xx

(cherry picked from commit 3e164451)

# Conflicts:
#	lib/core/services/raw_data_service/platform_ohos/ohos_harmony_health_raw_data_sync_service_factory.dart

xx

feat(ui):首页提供的数据也从本地数据库取

(cherry picked from commit e64a4559)

# Conflicts:
#	lib/core/services/raw_data_service/platform_ohos/ohos_harmony_health_raw_data_sync_service_factory.dart
@@ -159,10 +159,6 @@ class HarmonyApiOhosRawDataClient implements OhosHarmonyRawDataClient { @@ -159,10 +159,6 @@ class HarmonyApiOhosRawDataClient implements OhosHarmonyRawDataClient {
159 '[OHOS_ACTIVITY_GOAL] ' 159 '[OHOS_ACTIVITY_GOAL] '
160 'source=native value=${_goalLogValue(nativeGoal)}', 160 'source=native value=${_goalLogValue(nativeGoal)}',
161 ); 161 );
162 - AppLogger.i(  
163 - '[OHOS_ACTIVITY_GOAL] '  
164 - 'upload_scheduled value=${_goalLogValue(nativeGoal)}',  
165 - );  
166 // Deliberately do not await: a failed request must not prevent the 162 // Deliberately do not await: a failed request must not prevent the
167 // user from entering the app or the health-data sync from continuing. 163 // user from entering the app or the health-data sync from continuing.
168 unawaited(_uploadNativeActivityGoal(nativeGoal)); 164 unawaited(_uploadNativeActivityGoal(nativeGoal));
@@ -245,6 +245,18 @@ class LocalHealthDataSource implements HealthDataSource { @@ -245,6 +245,18 @@ class LocalHealthDataSource implements HealthDataSource {
245 Future<AppResult<V2ActivityTarget>> getV2ActivityTarget( 245 Future<AppResult<V2ActivityTarget>> getV2ActivityTarget(
246 int? queryUserId, int intDate) async { 246 int? queryUserId, int intDate) async {
247 try { 247 try {
  248 + if (_isOhosPlatform) {
  249 + // The OHOS sync pipeline persists the native activity ring goal in
  250 + // the local activity_goal table. Prefer that exact value here instead
  251 + // of reconstructing it from a day's activity summary.
  252 + final storedGoal = await coreService.queryOhosActivityGoal(
  253 + refresh: false,
  254 + );
  255 + if (storedGoal != null) {
  256 + return AppSuccess(storedGoal);
  257 + }
  258 + }
  259 +
248 final day = LocalHealthDataConvert.dateFromKey(intDate); 260 final day = LocalHealthDataConvert.dateFromKey(intDate);
249 final queryStart = LocalHealthDataConvert.unixSeconds(day); 261 final queryStart = LocalHealthDataConvert.unixSeconds(day);
250 final queryEnd = LocalHealthDataConvert.unixSeconds( 262 final queryEnd = LocalHealthDataConvert.unixSeconds(
@@ -256,13 +268,10 @@ class LocalHealthDataSource implements HealthDataSource { @@ -256,13 +268,10 @@ class LocalHealthDataSource implements HealthDataSource {
256 ); 268 );
257 final resolvedActivity = _resolveActivityTarget(activity); 269 final resolvedActivity = _resolveActivityTarget(activity);
258 if (_isOhosPlatform) { 270 if (_isOhosPlatform) {
259 - final activityGoal = await coreService.queryOhosActivityGoal(  
260 - refresh: false,  
261 - );  
262 return AppSuccess( 271 return AppSuccess(
263 _ohosActivityTarget( 272 _ohosActivityTarget(
264 userId: queryUserId ?? 0, 273 userId: queryUserId ?? 0,
265 - remoteOrCachedTarget: activityGoal, 274 + remoteOrCachedTarget: null,
266 activity: resolvedActivity, 275 activity: resolvedActivity,
267 fallbackUpdateTime: queryEnd, 276 fallbackUpdateTime: queryEnd,
268 ), 277 ),