interface.uts
5.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
/// 用户拒绝访问所请求的功能,需要先请求权限。
denied,
/// 用户授予了所请求功能的访问权限。
granted,
/// 操作系统拒绝访问所请求的功能。用户无法更改此应用的状态,
/// 可能是由于启用了家长控制等活动限制。
///
/// *仅支持 iOS。*
restricted,
/// 用户已授权此应用程序进行有限访问。目前这仅与照片库选择器相关。
///
/// *仅支持 iOS(iOS14+)和 Android(Android 14+)。*
limited,
/// 请求的功能权限被永久拒绝,再次请求权限时不会显示权限对话框。
/// 用户仍可以在设置中更改权限状态。
///
/// **在 Android 上:**
/// - Android 11+(API 30+):表示用户第二次拒绝权限。
/// - Android 11 以下(API 30 以下):表示用户拒绝访问所请求功能,并选择不再显示请求。
///
/// **在 iOS 上:**
/// - 如果用户拒绝了对所请求功能的访问。
permanentlyDenied,
/// 应用程序被临时授权发送非打扰性用户通知。
///
/// *仅支持 iOS(iOS12+)。*
provisional,
*/
export function permissionStatusName(status : Int) : string {
switch (status) {
case 0:
return "denied"
case 1:
return "granted"
case 2:
return "restricted"
case 3:
return "limited"
case 4:
return "permanentlyDenied"
case 5:
return "provisional"
default:
return "unkonwn"
}
}
/**
* 根据名称获取枚举的索引值
* @param name 枚举名称
* @returns 对应的索引值,如果名称无效则返回 -1
*/
export function permissionIdByName(name: string): Int {
switch (name) {
case "Calendar":
return 0;
case "Camera":
return 1;
case "Contacts":
return 2;
case "Location":
return 3;
case "LocationAlways":
return 4;
case "LocationWhenInUse":
return 5;
case "MediaLibrary":
return 6;
case "Microphone":
return 7;
case "Phone":
return 8;
case "Photos":
return 9;
case "PhotosAddOnly":
return 10;
case "Reminders":
return 11;
case "Sensors":
return 12;
case "Sms":
return 13;
case "Speech":
return 14;
case "Storage":
return 15;
case "IgnoreBatteryOptimizations":
return 16;
case "Notification":
return 17;
case "AccessMediaLocation":
return 18;
case "ActivityRecognition":
return 19;
case "Unknown":
return 20;
case "Bluetooth":
return 21;
case "ManageExternalStorage":
return 22;
case "SystemAlertWindow":
return 23;
case "RequestInstallPackages":
return 24;
case "AppTrackingTransparency":
return 25;
case "RriticalAlerts":
return 26;
case "AccessNotificationPolicy":
return 27;
case "BluetoothScan":
return 28;
case "BluetoothAdvertise":
return 29;
case "BluetoothConnect":
return 30;
case "NearbyWifiDevices":
return 31;
case "Videos":
return 32;
case "Audio":
return 33;
case "ScheduleExactAlarm":
return 34;
case "SensorsAlways":
return 35;
case "CalendarWriteOnly":
return 36;
case "CalendarFullAccess":
return 37;
case "Assistant":
return 38;
case "BackgroundRefresh":
return 39;
default:
return -1;
}
}
/**
* 根据索引值获取枚举的名称
* @param id 枚举索引值
* @returns 对应的名称,如果索引值无效则返回 "Unknown"
*/
export function permissionNameById(id: Int): string {
switch (id) {
case 0:
return "Calendar";
case 1:
return "Camera";
case 2:
return "Contacts";
case 3:
return "Location";
case 4:
return "LocationAlways";
case 5:
return "LocationWhenInUse";
case 6:
return "MediaLibrary";
case 7:
return "Microphone";
case 8:
return "Phone";
case 9:
return "Photos";
case 10:
return "PhotosAddOnly";
case 11:
return "Reminders";
case 12:
return "Sensors";
case 13:
return "Sms";
case 14:
return "Speech";
case 15:
return "Storage";
case 16:
return "IgnoreBatteryOptimizations";
case 17:
return "Notification";
case 18:
return "AccessMediaLocation";
case 19:
return "ActivityRecognition";
case 20:
return "Unknown";
case 21:
return "Bluetooth";
case 22:
return "ManageExternalStorage";
case 23:
return "SystemAlertWindow";
case 24:
return "RequestInstallPackages";
case 25:
return "AppTrackingTransparency";
case 26:
return "RriticalAlerts";
case 27:
return "AccessNotificationPolicy";
case 28:
return "BluetoothScan";
case 29:
return "BluetoothAdvertise";
case 30:
return "BluetoothConnect";
case 31:
return "NearbyWifiDevices";
case 32:
return "Videos";
case 33:
return "Audio";
case 34:
return "ScheduleExactAlarm";
case 35:
return "SensorsAlways";
case 36:
return "CalendarWriteOnly";
case 37:
return "CalendarFullAccess";
case 38:
return "Assistant";
case 39:
return "BackgroundRefresh";
default:
return "Unknown";
}
}
export type SuccessCallBack = (result:any) => void
export type FailCallBack = (error:any) => void
export type PermissionObject = {
names: Array<string>,
success: SuccessCallBack,
fail: FailCallBack,
}