health_kit_raw_data_api.dart
4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import 'package:pigeon/pigeon.dart';
class HealthKitRawDataPoint {
int dataType;
int startTime;
int endTime;
double? value;
bool? isMotionLike;
HealthKitRawDataPoint({
required this.dataType,
required this.startTime,
required this.endTime,
this.value,
this.isMotionLike,
});
}
class HealthKitRawSleepDataPoint {
int dataType;
List<HealthKitRawDataPoint> sleepDataPoints;
HealthKitRawSleepDataPoint({
required this.dataType,
required this.sleepDataPoints,
});
}
class HealthKitRawWorkoutDataPoint {
int workoutType;
int startTime;
int endTime;
HealthKitRawWorkoutDataPoint({
required this.workoutType,
required this.startTime,
required this.endTime,
});
}
class HealthKitRawMotionDataPoint {
int motionType;
int startTime;
int endTime;
HealthKitRawMotionDataPoint({
required this.motionType,
required this.startTime,
required this.endTime,
});
}
class HealthKitRawActivityDataPoint {
int endTime;
int? activityMoveMode;
// 千卡
double? activeEnergyBurned;
double? activeEnergyBurnedGoal;
// 公里
double? appleMoveTime;
double? appleMoveTimeGoal;
// 分钟
double? appleExerciseTime;
double? exerciseTimeGoal;
//小时
double? appleStandHours;
double? standHoursGoal;
HealthKitRawActivityDataPoint({
required this.endTime,
this.activityMoveMode,
this.activeEnergyBurned,
this.activeEnergyBurnedGoal,
this.appleMoveTime,
this.appleMoveTimeGoal,
this.appleExerciseTime,
this.exerciseTimeGoal,
this.appleStandHours,
this.standHoursGoal,
});
}
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/pigeon/health_kit_raw_data_api.g.dart',
dartPackageName: 'doublefeel_flutter',
dartOptions: DartOptions(),
swiftOut: 'ios/Runner/Pigeon/HealthKitRawDataApi.swift',
swiftOptions: SwiftOptions(),
copyrightHeader: 'pigeon/copyright.txt',
),
)
@HostApi()
abstract class HealthKitRawDataHostApi {
/// 是否有AppleHealth数据
@async
bool hasHealthData();
/// 从AppleHealth 中读取原始数据
@async
List<HealthKitRawDataPoint> getHealthKitRawData(
int dataType, int startTime, int endTime);
/// 原生数据上传
@async
bool performHealthDataUpload();
/// 向原生同步数据库路径
@async
bool syncDatabase(
{required String hrDataPath,
required String hrvDataPath,
required String sleepDataPath,
required String avgRealtimeStressDataPath});
/// 上传心率 - 实时压力数据, 返回上传截止的时间戳, 方便flutter修改数据库
@async
int performHRDataUpload({required String sqliteFilePath});
/// 上传HRV - HRV压力数据, 返回上传截止的时间戳,方便flutter 修改数据库
@async
int performHRVDataUpload({required String sqliteFilePath});
/// 上传睡眠统计数据
@async
int performSleepAnalysisDataUpload({required String sqliteFilePath});
/// 上传当前实时压力(统计维度是当天)
@async
int performAvgRealtimeStressDataUpload({required String sqliteFilePath});
/// 从从AppleHealth中读取睡眠数据
@async
List<HealthKitRawSleepDataPoint> getHealthKitRawSleepData(
int startTime, int endTime);
/// 从从AppleHealth中读取活动统计数据
@async
List<HealthKitRawActivityDataPoint> getHealthKitRawActivityData(
int startTime, int endTime);
/// 从从AppleHealth中读取锻炼数据
@async
List<HealthKitRawWorkoutDataPoint> getHealthKitRawWorkoutData(
int startTime, int endTime);
// DEBUG
/// 原生是否通知了flutter ,apple health数据变化,让native 记录这次调用记录
/// 需要保存引起此次计算的数据变化类型列表、当前时间
@async
bool saveNativeCallFlutterChange({required List<int> relativeDataTypes});
/// caculate 一旦完成,让native 存储这次的计算记录
/// 需要保存引起此次计算的数据变化类型列表、当前时间
@async
bool saveFlutterCaculateFinished({required List<int> relativeDataTypes});
/// 让原生保存本地通知记录
@async
bool saveLocalNotificationRecord(
{required String notificationType, required int timestamp});
/// 让原生分享出来本地的记录文件
@async
bool shareNativeAppleHealthObserverRecord();
@async
bool saveLocalNotificationDebugEvent({required Map<String, Object?> event});
/// 让原生分享出来flutter的记录文件
@async
bool shareFlutterObserverRecord();
@async
bool shareLocalNotificationDebugRecord();
/// 让原生分享出来上传记录
@async
bool shareUploadTaskRecord();
}