health_kit_api.dart
3.63 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
import 'package:pigeon/pigeon.dart';
class HealthUploadResult {
HealthUploadResult({
required this.commonUploadSuccess,
required this.sleepUploadSuccess,
this.errorMessage,
});
bool commonUploadSuccess;
bool sleepUploadSuccess;
String? errorMessage;
}
class HealthUploadDataPoint {
HealthUploadDataPoint({
required this.dataType,
required this.time,
required this.value,
});
int dataType;
int time;
double value;
}
class HealthSleepUploadDataPoint {
HealthSleepUploadDataPoint({
required this.dataType,
required this.fromTime,
required this.toTime,
});
int dataType;
int fromTime;
int toTime;
}
class HealthActivityTargetData {
HealthActivityTargetData({
this.move,
this.stand,
});
int? move;
int? stand;
}
class HealthAuthorization {
/// -1: AppleHealth不可用, 0: 需要请求授权, 1: 已被授权且能获取到部分数据, 2: 已被拒绝或者没有数据
final int status;
final bool hasData;
HealthAuthorization({required this.status, required this.hasData});
}
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/pigeon/health_kit_api.g.dart',
dartPackageName: 'doublefeel_flutter',
dartOptions: DartOptions(),
kotlinOut:
'android/app/src/main/kotlin/com/doublefeel/app/pigeon/HealthKitApi.kt',
kotlinOptions: KotlinOptions(
package: 'com.doublefeel.app.pigeon',
),
swiftOut: 'ios/Runner/Pigeon/HealthKitApi.swift',
swiftOptions: SwiftOptions(),
arkTSOut: 'ohos/entry/src/main/ets/pigeon/HealthKitApi.ets',
copyrightHeader: 'pigeon/copyright.txt',
),
)
@HostApi()
abstract class HealthKitHostApi {
// @optional
@async
String getHealthServerAuthUrl();
bool cancelHealthAppAuthorization();
/// Runs native health read and server upload pipeline.
@async
HealthUploadResult performHealthUpload();
/// 获取当前已上传的健康数据点,主要用于调试
// List<HealthUploadDataPoint> getDebugCurrentUploadedData();
// @required
/// Opens Huawei Health client authorization UI. Returns whether user granted.
@async
HealthAuthorization checkHealthAppAuthorization();
@async
bool requestHealthClientAuthorization();
@async
List<HealthUploadDataPoint> fetchHrvData(int startTime, int endTime);
@async
List<HealthUploadDataPoint> fetchHeartRateData(int startTime, int endTime);
@async
List<HealthUploadDataPoint> fetchWalkingHeartRateData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchRestingHeartRateData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchSleepingHeartRateData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchOxygenSaturationData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchActiveEnergyData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchExerciseData(int startTime, int endTime);
@async
List<HealthUploadDataPoint> fetchStandData(int startTime, int endTime);
@async
List<HealthUploadDataPoint> fetchStepCountData(int startTime, int endTime);
@async
List<HealthSleepUploadDataPoint> fetchSleepData(int startTime, int endTime);
@async
List<HealthUploadDataPoint> fetchSleepingWristTemperatureData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchRespiratoryRateData(
int startTime,
int endTime,
);
@async
List<HealthUploadDataPoint> fetchIrregularHeartRhythmData(
int startTime,
int endTime,
);
@async
HealthActivityTargetData? fetchActivityTargetData(
int startTime,
int endTime,
);
}