health_kit_api.dart
2.41 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
import 'package:pigeon/pigeon.dart';
class HealthAuthorization {
/// -1: AppleHealth不可用, 0: 需要请求授权, 1: 已被授权且能获取到部分数据, 2: 已被拒绝或者没有数据
final int status;
final bool hasData;
HealthAuthorization({required this.status, required this.hasData});
}
/// The user's current Huawei Health activity-ring goals.
///
/// Units: move is kcal, exercise is seconds, and stand is hours.
class HealthActivityGoal {
HealthActivityGoal({
this.move,
this.step,
this.stand,
this.exercise,
});
int? move;
int? step;
int? stand;
int? exercise;
}
/// One workout record read from Health Service Kit.
class HealthWorkoutDataPoint {
HealthWorkoutDataPoint({
required this.startTime,
required this.endTime,
required this.activityType,
});
/// Unix timestamp in seconds.
int startTime;
/// Unix timestamp in seconds.
int endTime;
/// The native Health Service Kit exercise-type identifier.
int activityType;
}
@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 {
/// Opens Huawei Health client authorization UI. Returns whether user granted.
@async
HealthAuthorization checkHealthAppAuthorization();
@async
bool requestHealthClientAuthorization();
/// Cancels all Huawei Health authorizations on OHOS.
@async
bool cancelAuthorizations();
/// Requests Huawei Health to upload the user's latest data to its cloud.
///
/// This only triggers the Health app's configured device-to-cloud sync; it
/// does not wait for, or return, the subsequently available cloud data.
@async
bool syncHealthDataToCloud();
/// Reads the current activity-ring goals from Huawei Health on OHOS.
@async
HealthActivityGoal? readActivityGoal();
/// Reads workout records in the supplied Unix-seconds time range on OHOS.
@async
List<HealthWorkoutDataPoint> readWorkoutData(int startTime, int endTime);
}