react-native-beidou 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/BeiDouAIDLTestPage.tsx +710 -0
  2. package/Compass.android.tsx +20 -0
  3. package/TestPage.ts +6 -0
  4. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  8. package/android/.idea/AndroidProjectSystem.xml +6 -0
  9. package/android/.idea/gradle.xml +13 -0
  10. package/android/.idea/migrations.xml +10 -0
  11. package/android/.idea/misc.xml +9 -0
  12. package/android/.idea/runConfigurations.xml +17 -0
  13. package/android/.idea/vcs.xml +6 -0
  14. package/android/build.gradle +3 -0
  15. package/android/src/main/AndroidManifest.xml +7 -0
  16. package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothModule.java +343 -101
  17. package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothPackage.java +4 -1
  18. package/android/src/main/java/com/cmcc_rn_module/ChatDBManager.java +306 -0
  19. package/android/src/main/java/com/cmcc_rn_module/JsonUtil.java +113 -7
  20. package/android/src/main/java/com/cmcc_rn_module/view/CompassManager.java +41 -0
  21. package/android/src/main/java/com/cmcc_rn_module/view/CompassView.java +277 -0
  22. package/android/src/main/libs/bluetooth-sdk.aar +0 -0
  23. package/index.ts +188 -10
  24. package/ios/BDTCompassViewManager.h +15 -0
  25. package/ios/BDTCompassViewManager.m +24 -0
  26. package/ios/BeiDouBluetoothModule.h +20 -0
  27. package/ios/BeiDouBluetoothModule.m +424 -0
  28. package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
  29. package/ios/BeidouBluetooth.framework/Headers/BDTBluetoothManager.h +76 -0
  30. package/ios/BeidouBluetooth.framework/Headers/BDTChatDBManager.h +41 -0
  31. package/ios/BeidouBluetooth.framework/Headers/BDTDataPacketBuilder.h +62 -0
  32. package/ios/BeidouBluetooth.framework/Headers/BeidouBluetooth.h +21 -0
  33. package/ios/BeidouBluetooth.framework/Info.plist +0 -0
  34. package/ios/BeidouBluetooth.framework/Modules/module.modulemap +6 -0
  35. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
  36. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements +0 -0
  37. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
  38. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +177 -0
  39. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
  40. package/ios/CompassView.h +20 -0
  41. package/ios/CompassView.m +201 -0
  42. package/package.json +5 -2
  43. package/android/.gradle/8.8/checksums/checksums.lock +0 -0
  44. package/android/.gradle/8.8/dependencies-accessors/gc.properties +0 -0
  45. package/android/.gradle/8.8/fileChanges/last-build.bin +0 -0
  46. package/android/.gradle/8.8/fileHashes/fileHashes.bin +0 -0
  47. package/android/.gradle/8.8/fileHashes/fileHashes.lock +0 -0
  48. package/android/.gradle/8.8/gc.properties +0 -0
  49. package/ios/Podfile +0 -79
  50. package/ios/build_sdk.sh +0 -30
  51. package/ios/cmcc_rn_module/AppDelegate.h +0 -8
  52. package/ios/cmcc_rn_module/AppDelegate.mm +0 -108
  53. package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.h +0 -17
  54. package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.m +0 -38
  55. package/ios/cmcc_rn_module/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  56. package/ios/cmcc_rn_module/Images.xcassets/Contents.json +0 -6
  57. package/ios/cmcc_rn_module/Info.plist +0 -62
  58. package/ios/cmcc_rn_module/LaunchScreen.storyboard +0 -47
  59. package/ios/cmcc_rn_module/main.m +0 -10
  60. package/ios/cmcc_rn_module.xcodeproj/project.pbxproj +0 -708
  61. package/ios/cmcc_rn_module.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  62. package/ios/cmcc_rn_module.xcodeproj/xcshareddata/xcschemes/cmcc_rn_module.xcscheme +0 -88
  63. package/ios/cmcc_rn_module.xcworkspace/contents.xcworkspacedata +0 -10
  64. package/ios/cmcc_rn_module.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  65. package/ios/cmcc_rn_moduleTests/Info.plist +0 -24
  66. package/ios/cmcc_rn_moduleTests/cmcc_rn_moduleTests.m +0 -66
  67. package/ios/reset_env.sh +0 -24
  68. package/ios/scripts/RNReanimated.podspec +0 -90
  69. package/ios/scripts/generate_dynamic_pod.rb +0 -166
  70. package/ios/scripts/native_modules_dy.rb +0 -317
  71. package/ios/scripts/react_native_pods_dy.rb +0 -773
@@ -0,0 +1,710 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ScrollView,
8
+ Alert,
9
+ TextInput,
10
+ SafeAreaView,
11
+ ActivityIndicator,
12
+ } from 'react-native';
13
+ import { BeiDouModule } from './index';
14
+ import type {
15
+ BDStatusResponse,
16
+ BDMsgEncryptResponse,
17
+ BDMsgDecryptResponse,
18
+ BDMsgEphemerisFileDLResponse,
19
+ } from './index';
20
+
21
+ interface TestResult {
22
+ method: string;
23
+ success: boolean;
24
+ result?: any;
25
+ error?: string;
26
+ timestamp: Date;
27
+ }
28
+
29
+ const BeiDouAIDLTestPage: React.FC = () => {
30
+ const [isServiceBound, setIsServiceBound] = useState(false);
31
+ const [loading, setLoading] = useState(false);
32
+ const [testResults, setTestResults] = useState<TestResult[]>([]);
33
+
34
+ // 输入参数状态
35
+ const [inputMsg, setInputMsg] = useState('测试消息内容');
36
+ const [receiveList, setReceiveList] = useState('13800138000,13900139000');
37
+ const [longitude, setLongitude] = useState('116.404');
38
+ const [latitude, setLatitude] = useState('39.915');
39
+ const [ephemerisType, setEphemerisType] = useState('GPS');
40
+ const [ephemerisVersion, setEphemerisVersion] = useState('1.0.0');
41
+ const [decryptMsg, setDecryptMsg] = useState('1,2,3,4,5');
42
+
43
+ // 服务配置参数
44
+ const [packageName, setPackageName] = useState('com.test.aidlsetvicetest');
45
+ const [actionName, setActionName] = useState('com.samsung.beidoupackage.BeidouMsgAidlService');
46
+
47
+ const addTestResult = (method: string, success: boolean, result?: any, error?: string) => {
48
+ const newResult: TestResult = {
49
+ method,
50
+ success,
51
+ result,
52
+ error,
53
+ timestamp: new Date(),
54
+ };
55
+ setTestResults(prev => [newResult, ...prev.slice(0, 9)]); // 保留最新的10条记录
56
+ };
57
+
58
+ const clearResults = () => {
59
+ setTestResults([]);
60
+ };
61
+
62
+ // 绑定北斗服务
63
+ const bindService = async () => {
64
+ setLoading(true);
65
+ try {
66
+ if (!packageName.trim() || !actionName.trim()) {
67
+ Alert.alert('错误', '请输入有效的包名和Action名');
68
+ return;
69
+ }
70
+
71
+ const result = await BeiDouModule.beidou.bindService(packageName.trim(), actionName.trim());
72
+ setIsServiceBound(result);
73
+ addTestResult('bindService', result, { packageName: packageName.trim(), actionName: actionName.trim(), result });
74
+ if (result) {
75
+ Alert.alert('成功', `北斗服务绑定成功\n包名: ${packageName}\nAction: ${actionName}`);
76
+ } else {
77
+ Alert.alert('失败', '北斗服务绑定失败');
78
+ }
79
+ } catch (error) {
80
+ const errorMsg = error instanceof Error ? error.message : String(error);
81
+ addTestResult('bindService', false, undefined, errorMsg);
82
+ Alert.alert('错误', `绑定服务失败: ${errorMsg}`);
83
+ } finally {
84
+ setLoading(false);
85
+ }
86
+ };
87
+
88
+ // 解绑北斗服务
89
+ const unbindService = async () => {
90
+ setLoading(true);
91
+ try {
92
+ const result = await BeiDouModule.beidou.unbindService();
93
+ setIsServiceBound(false);
94
+ addTestResult('unbindService', result, result);
95
+ Alert.alert('成功', '北斗服务已解绑');
96
+ } catch (error) {
97
+ const errorMsg = error instanceof Error ? error.message : String(error);
98
+ addTestResult('unbindService', false, undefined, errorMsg);
99
+ Alert.alert('错误', `解绑服务失败: ${errorMsg}`);
100
+ } finally {
101
+ setLoading(false);
102
+ }
103
+ };
104
+
105
+ // 鉴权测试
106
+ const testAuthenticate = async () => {
107
+ setLoading(true);
108
+ try {
109
+ const result = await BeiDouModule.beidou.authenticate();
110
+ addTestResult('authenticate', result, result);
111
+ Alert.alert('鉴权结果', result ? '鉴权成功' : '鉴权失败');
112
+ } catch (error) {
113
+ const errorMsg = error instanceof Error ? error.message : String(error);
114
+ addTestResult('authenticate', false, undefined, errorMsg);
115
+ Alert.alert('错误', `鉴权失败: ${errorMsg}`);
116
+ } finally {
117
+ setLoading(false);
118
+ }
119
+ };
120
+
121
+ // 获取用户状态
122
+ const testGetStatus = async () => {
123
+ setLoading(true);
124
+ try {
125
+ const result: BDStatusResponse = await BeiDouModule.beidou.getStatus();
126
+ addTestResult('getStatus', true, result);
127
+ Alert.alert('用户状态', `代码: ${result.code}\n状态: ${result.statusMsg}\n剩余额度: ${result.msgQuotaRemain}`);
128
+ } catch (error) {
129
+ const errorMsg = error instanceof Error ? error.message : String(error);
130
+ addTestResult('getStatus', false, undefined, errorMsg);
131
+ Alert.alert('错误', `获取状态失败: ${errorMsg}`);
132
+ } finally {
133
+ setLoading(false);
134
+ }
135
+ };
136
+
137
+ // 检查密钥状态
138
+ const testCheckKey = async () => {
139
+ setLoading(true);
140
+ try {
141
+ const result: number = await BeiDouModule.beidou.checkKey();
142
+ addTestResult('checkKey', true, result);
143
+ Alert.alert('密钥状态', `密钥状态代码: ${result}`);
144
+ } catch (error) {
145
+ const errorMsg = error instanceof Error ? error.message : String(error);
146
+ addTestResult('checkKey', false, undefined, errorMsg);
147
+ Alert.alert('错误', `检查密钥失败: ${errorMsg}`);
148
+ } finally {
149
+ setLoading(false);
150
+ }
151
+ };
152
+
153
+ // 通用报文加密测试
154
+ const testCommonEncrypt = async () => {
155
+ setLoading(true);
156
+ try {
157
+ const receivers = receiveList.split(',').map(s => s.trim()).filter(s => s);
158
+ const result: BDMsgEncryptResponse = await BeiDouModule.beidou.encryptCommonMessage(receivers, inputMsg);
159
+ addTestResult('commonEncrypt', true, result);
160
+ Alert.alert('加密成功', `代码: ${result.code}\n状态: ${result.statusMsg}\n发送方: ${result.sendMobile}\n数据长度: ${result.data.length}`);
161
+ } catch (error) {
162
+ const errorMsg = error instanceof Error ? error.message : String(error);
163
+ addTestResult('commonEncrypt', false, undefined, errorMsg);
164
+ Alert.alert('错误', `通用加密失败: ${errorMsg}`);
165
+ } finally {
166
+ setLoading(false);
167
+ }
168
+ };
169
+
170
+ // 位置报文加密测试
171
+ const testPositionEncrypt = async () => {
172
+ setLoading(true);
173
+ try {
174
+ const receivers = receiveList.split(',').map(s => s.trim()).filter(s => s);
175
+ const lng = parseFloat(longitude);
176
+ const lat = parseFloat(latitude);
177
+
178
+ if (isNaN(lng) || isNaN(lat)) {
179
+ Alert.alert('错误', '请输入有效的经纬度');
180
+ return;
181
+ }
182
+
183
+ const result: BDMsgEncryptResponse = await BeiDouModule.beidou.encryptPositionMessage(receivers, inputMsg, lng, lat);
184
+ addTestResult('positionEncrypt', true, result);
185
+ Alert.alert('位置加密成功', `代码: ${result.code}\n状态: ${result.statusMsg}\n发送方: ${result.sendMobile}\n数据长度: ${result.data.length}`);
186
+ } catch (error) {
187
+ const errorMsg = error instanceof Error ? error.message : String(error);
188
+ addTestResult('positionEncrypt', false, undefined, errorMsg);
189
+ Alert.alert('错误', `位置加密失败: ${errorMsg}`);
190
+ } finally {
191
+ setLoading(false);
192
+ }
193
+ };
194
+
195
+ // 信箱查询加密测试
196
+ const testMailboxQuery = async () => {
197
+ setLoading(true);
198
+ try {
199
+ const result: BDMsgEncryptResponse = await BeiDouModule.beidou.encryptMailboxQuery();
200
+ addTestResult('mailboxQuery', true, result);
201
+ Alert.alert('信箱查询成功', `代码: ${result.code}\n状态: ${result.statusMsg}\n发送方: ${result.sendMobile}\n数据长度: ${result.data.length}`);
202
+ } catch (error) {
203
+ const errorMsg = error instanceof Error ? error.message : String(error);
204
+ addTestResult('mailboxQuery', false, undefined, errorMsg);
205
+ Alert.alert('错误', `信箱查询失败: ${errorMsg}`);
206
+ } finally {
207
+ setLoading(false);
208
+ }
209
+ };
210
+
211
+ // 报文解密测试
212
+ const testDecryptMessage = async () => {
213
+ setLoading(true);
214
+ try {
215
+ const msgBytes = decryptMsg.split(',').map(s => parseInt(s.trim())).filter(n => !isNaN(n));
216
+ if (msgBytes.length === 0) {
217
+ Alert.alert('错误', '请输入有效的字节数组(用逗号分隔的数字)');
218
+ return;
219
+ }
220
+
221
+ const result: BDMsgDecryptResponse = await BeiDouModule.beidou.decryptMessage(msgBytes, msgBytes.length);
222
+ addTestResult('decryptMessage', true, result);
223
+ Alert.alert('解密成功', `状态: ${result.statusMsg}\n是否还有消息: ${result.isRemainMsg}\n发送方: ${result.rcvMobile}\n内容: ${result.data}`);
224
+ } catch (error) {
225
+ const errorMsg = error instanceof Error ? error.message : String(error);
226
+ addTestResult('decryptMessage', false, undefined, errorMsg);
227
+ Alert.alert('错误', `解密失败: ${errorMsg}`);
228
+ } finally {
229
+ setLoading(false);
230
+ }
231
+ };
232
+
233
+ // 下载星历文件测试
234
+ const testDownloadEphemeris = async () => {
235
+ setLoading(true);
236
+ try {
237
+ const result: BDMsgEphemerisFileDLResponse = await BeiDouModule.beidou.downloadEphemeris(ephemerisType, ephemerisVersion);
238
+ addTestResult('downloadEphemeris', true, result);
239
+ Alert.alert('下载成功', `代码: ${result.code}\n状态: ${result.statusMsg}\n版本: ${result.version}\n文件大小: ${result.ephemerisZipFile.length} 字节`);
240
+ } catch (error) {
241
+ const errorMsg = error instanceof Error ? error.message : String(error);
242
+ addTestResult('downloadEphemeris', false, undefined, errorMsg);
243
+ Alert.alert('错误', `下载星历失败: ${errorMsg}`);
244
+ } finally {
245
+ setLoading(false);
246
+ }
247
+ };
248
+
249
+ // 运行所有测试
250
+ const runAllTests = async () => {
251
+ if (!isServiceBound) {
252
+ Alert.alert('提示', '请先绑定北斗服务');
253
+ return;
254
+ }
255
+
256
+ const tests = [
257
+ testAuthenticate,
258
+ testGetStatus,
259
+ testCheckKey,
260
+ testCommonEncrypt,
261
+ testPositionEncrypt,
262
+ testMailboxQuery,
263
+ testDecryptMessage,
264
+ testDownloadEphemeris,
265
+ ];
266
+
267
+ for (const test of tests) {
268
+ await test();
269
+ // 在测试之间添加短暂延迟
270
+ await new Promise(resolve => setTimeout(resolve, 500));
271
+ }
272
+ };
273
+
274
+ return (
275
+ <SafeAreaView style={styles.container}>
276
+ <ScrollView style={styles.scrollView} contentContainerStyle={styles.contentContainer}>
277
+ <Text style={styles.title}>北斗AIDL服务测试</Text>
278
+
279
+ {/* 服务状态 */}
280
+ <View style={styles.statusContainer}>
281
+ <Text style={styles.statusText}>
282
+ 服务状态: {isServiceBound ? '已绑定' : '未绑定'}
283
+ </Text>
284
+ {loading && <ActivityIndicator size="small" color="#007AFF" />}
285
+ </View>
286
+
287
+ {/* 服务绑定控制 */}
288
+ <View style={styles.buttonGroup}>
289
+ <TouchableOpacity
290
+ style={[styles.button, styles.primaryButton]}
291
+ onPress={bindService}
292
+ disabled={loading || isServiceBound}
293
+ >
294
+ <Text style={styles.buttonText}>绑定服务</Text>
295
+ </TouchableOpacity>
296
+
297
+ <TouchableOpacity
298
+ style={[styles.button, styles.secondaryButton]}
299
+ onPress={unbindService}
300
+ disabled={loading || !isServiceBound}
301
+ >
302
+ <Text style={styles.buttonText}>解绑服务</Text>
303
+ </TouchableOpacity>
304
+ </View>
305
+
306
+ {/* 服务配置区域 */}
307
+ <View style={styles.inputSection}>
308
+ <Text style={styles.sectionTitle}>服务配置</Text>
309
+
310
+ <View style={styles.inputGroup}>
311
+ <Text style={styles.inputLabel}>包名 (Package Name):</Text>
312
+ <TextInput
313
+ style={styles.textInput}
314
+ value={packageName}
315
+ onChangeText={setPackageName}
316
+ placeholder="com.test.aidlsetvicetest"
317
+ />
318
+ </View>
319
+
320
+ <View style={styles.inputGroup}>
321
+ <Text style={styles.inputLabel}>Action名:</Text>
322
+ <TextInput
323
+ style={styles.textInput}
324
+ value={actionName}
325
+ onChangeText={setActionName}
326
+ placeholder="com.samsung.beidoupackage.BeidouMsgAidlService"
327
+ />
328
+ </View>
329
+ </View>
330
+
331
+ {/* 输入参数区域 */}
332
+ <View style={styles.inputSection}>
333
+ <Text style={styles.sectionTitle}>测试参数</Text>
334
+
335
+ <View style={styles.inputGroup}>
336
+ <Text style={styles.inputLabel}>消息内容:</Text>
337
+ <TextInput
338
+ style={styles.textInput}
339
+ value={inputMsg}
340
+ onChangeText={setInputMsg}
341
+ placeholder="输入测试消息"
342
+ />
343
+ </View>
344
+
345
+ <View style={styles.inputGroup}>
346
+ <Text style={styles.inputLabel}>接收方列表 (逗号分隔):</Text>
347
+ <TextInput
348
+ style={styles.textInput}
349
+ value={receiveList}
350
+ onChangeText={setReceiveList}
351
+ placeholder="手机号1,手机号2"
352
+ />
353
+ </View>
354
+
355
+ <View style={styles.row}>
356
+ <View style={styles.halfInput}>
357
+ <Text style={styles.inputLabel}>经度:</Text>
358
+ <TextInput
359
+ style={styles.textInput}
360
+ value={longitude}
361
+ onChangeText={setLongitude}
362
+ placeholder="116.404"
363
+ keyboardType="numeric"
364
+ />
365
+ </View>
366
+ <View style={styles.halfInput}>
367
+ <Text style={styles.inputLabel}>纬度:</Text>
368
+ <TextInput
369
+ style={styles.textInput}
370
+ value={latitude}
371
+ onChangeText={setLatitude}
372
+ placeholder="39.915"
373
+ keyboardType="numeric"
374
+ />
375
+ </View>
376
+ </View>
377
+
378
+ <View style={styles.row}>
379
+ <View style={styles.halfInput}>
380
+ <Text style={styles.inputLabel}>星历类型:</Text>
381
+ <TextInput
382
+ style={styles.textInput}
383
+ value={ephemerisType}
384
+ onChangeText={setEphemerisType}
385
+ placeholder="GPS"
386
+ />
387
+ </View>
388
+ <View style={styles.halfInput}>
389
+ <Text style={styles.inputLabel}>星历版本:</Text>
390
+ <TextInput
391
+ style={styles.textInput}
392
+ value={ephemerisVersion}
393
+ onChangeText={setEphemerisVersion}
394
+ placeholder="1.0.0"
395
+ />
396
+ </View>
397
+ </View>
398
+
399
+ <View style={styles.inputGroup}>
400
+ <Text style={styles.inputLabel}>解密数据 (逗号分隔的数字):</Text>
401
+ <TextInput
402
+ style={styles.textInput}
403
+ value={decryptMsg}
404
+ onChangeText={setDecryptMsg}
405
+ placeholder="1,2,3,4,5"
406
+ />
407
+ </View>
408
+ </View>
409
+
410
+ {/* 测试按钮区域 */}
411
+ <View style={styles.testSection}>
412
+ <Text style={styles.sectionTitle}>功能测试</Text>
413
+
414
+ <TouchableOpacity
415
+ style={[styles.button, styles.primaryButton]}
416
+ onPress={runAllTests}
417
+ disabled={loading || !isServiceBound}
418
+ >
419
+ <Text style={styles.buttonText}>运行所有测试</Text>
420
+ </TouchableOpacity>
421
+
422
+ <View style={styles.buttonGrid}>
423
+ <TouchableOpacity
424
+ style={[styles.testButton, styles.primaryButton]}
425
+ onPress={testAuthenticate}
426
+ disabled={loading || !isServiceBound}
427
+ >
428
+ <Text style={styles.testButtonText}>鉴权</Text>
429
+ </TouchableOpacity>
430
+
431
+ <TouchableOpacity
432
+ style={[styles.testButton, styles.primaryButton]}
433
+ onPress={testGetStatus}
434
+ disabled={loading || !isServiceBound}
435
+ >
436
+ <Text style={styles.testButtonText}>获取状态</Text>
437
+ </TouchableOpacity>
438
+
439
+ <TouchableOpacity
440
+ style={[styles.testButton, styles.primaryButton]}
441
+ onPress={testCheckKey}
442
+ disabled={loading || !isServiceBound}
443
+ >
444
+ <Text style={styles.testButtonText}>检查密钥</Text>
445
+ </TouchableOpacity>
446
+
447
+ <TouchableOpacity
448
+ style={[styles.testButton, styles.primaryButton]}
449
+ onPress={testCommonEncrypt}
450
+ disabled={loading || !isServiceBound}
451
+ >
452
+ <Text style={styles.testButtonText}>通用加密</Text>
453
+ </TouchableOpacity>
454
+
455
+ <TouchableOpacity
456
+ style={[styles.testButton, styles.primaryButton]}
457
+ onPress={testPositionEncrypt}
458
+ disabled={loading || !isServiceBound}
459
+ >
460
+ <Text style={styles.testButtonText}>位置加密</Text>
461
+ </TouchableOpacity>
462
+
463
+ <TouchableOpacity
464
+ style={[styles.testButton, styles.primaryButton]}
465
+ onPress={testMailboxQuery}
466
+ disabled={loading || !isServiceBound}
467
+ >
468
+ <Text style={styles.testButtonText}>信箱查询</Text>
469
+ </TouchableOpacity>
470
+
471
+ <TouchableOpacity
472
+ style={[styles.testButton, styles.primaryButton]}
473
+ onPress={testDecryptMessage}
474
+ disabled={loading || !isServiceBound}
475
+ >
476
+ <Text style={styles.testButtonText}>解密消息</Text>
477
+ </TouchableOpacity>
478
+
479
+ <TouchableOpacity
480
+ style={[styles.testButton, styles.primaryButton]}
481
+ onPress={testDownloadEphemeris}
482
+ disabled={loading || !isServiceBound}
483
+ >
484
+ <Text style={styles.testButtonText}>下载星历</Text>
485
+ </TouchableOpacity>
486
+ </View>
487
+ </View>
488
+
489
+ {/* 测试结果区域 */}
490
+ <View style={styles.resultsSection}>
491
+ <View style={styles.resultsHeader}>
492
+ <Text style={styles.sectionTitle}>测试结果</Text>
493
+ <TouchableOpacity onPress={clearResults} style={styles.clearButton}>
494
+ <Text style={styles.clearButtonText}>清空</Text>
495
+ </TouchableOpacity>
496
+ </View>
497
+
498
+ {testResults.map((result, index) => (
499
+ <View key={index} style={[styles.resultItem, result.success ? styles.successResult : styles.errorResult]}>
500
+ <View style={styles.resultHeader}>
501
+ <Text style={styles.resultMethod}>{result.method}</Text>
502
+ <Text style={styles.resultTime}>
503
+ {result.timestamp.toLocaleTimeString()}
504
+ </Text>
505
+ </View>
506
+
507
+ {result.success ? (
508
+ <Text style={styles.resultText}>
509
+ ✅ {typeof result.result === 'object' ? JSON.stringify(result.result, null, 2) : String(result.result)}
510
+ </Text>
511
+ ) : (
512
+ <Text style={styles.errorText}>
513
+ ❌ {result.error}
514
+ </Text>
515
+ )}
516
+ </View>
517
+ ))}
518
+
519
+ {testResults.length === 0 && (
520
+ <Text style={styles.noResults}>暂无测试结果</Text>
521
+ )}
522
+ </View>
523
+ </ScrollView>
524
+ </SafeAreaView>
525
+ );
526
+ };
527
+
528
+ const styles = StyleSheet.create({
529
+ container: {
530
+ flex: 1,
531
+ backgroundColor: '#f5f5f5',
532
+ },
533
+ scrollView: {
534
+ flex: 1,
535
+ },
536
+ contentContainer: {
537
+ padding: 16,
538
+ },
539
+ title: {
540
+ fontSize: 24,
541
+ fontWeight: 'bold',
542
+ textAlign: 'center',
543
+ marginBottom: 20,
544
+ color: '#333',
545
+ },
546
+ statusContainer: {
547
+ flexDirection: 'row',
548
+ justifyContent: 'center',
549
+ alignItems: 'center',
550
+ marginBottom: 20,
551
+ },
552
+ statusText: {
553
+ fontSize: 16,
554
+ marginRight: 10,
555
+ color: '#666',
556
+ },
557
+ buttonGroup: {
558
+ flexDirection: 'row',
559
+ justifyContent: 'space-around',
560
+ marginBottom: 24,
561
+ },
562
+ button: {
563
+ paddingHorizontal: 20,
564
+ paddingVertical: 12,
565
+ borderRadius: 8,
566
+ minWidth: 100,
567
+ alignItems: 'center',
568
+ },
569
+ primaryButton: {
570
+ backgroundColor: '#007AFF',
571
+ },
572
+ secondaryButton: {
573
+ backgroundColor: '#FF3B30',
574
+ },
575
+ buttonText: {
576
+ color: '#fff',
577
+ fontSize: 16,
578
+ fontWeight: '600',
579
+ },
580
+ inputSection: {
581
+ backgroundColor: '#fff',
582
+ borderRadius: 12,
583
+ padding: 16,
584
+ marginBottom: 20,
585
+ },
586
+ sectionTitle: {
587
+ fontSize: 18,
588
+ fontWeight: 'bold',
589
+ marginBottom: 16,
590
+ color: '#333',
591
+ },
592
+ inputGroup: {
593
+ marginBottom: 16,
594
+ },
595
+ inputLabel: {
596
+ fontSize: 14,
597
+ fontWeight: '500',
598
+ marginBottom: 8,
599
+ color: '#666',
600
+ },
601
+ textInput: {
602
+ borderWidth: 1,
603
+ borderColor: '#ddd',
604
+ borderRadius: 8,
605
+ paddingHorizontal: 12,
606
+ paddingVertical: 10,
607
+ fontSize: 16,
608
+ backgroundColor: '#fff',
609
+ },
610
+ row: {
611
+ flexDirection: 'row',
612
+ justifyContent: 'space-between',
613
+ marginBottom: 16,
614
+ },
615
+ halfInput: {
616
+ flex: 1,
617
+ marginHorizontal: 4,
618
+ },
619
+ testSection: {
620
+ backgroundColor: '#fff',
621
+ borderRadius: 12,
622
+ padding: 16,
623
+ marginBottom: 20,
624
+ },
625
+ buttonGrid: {
626
+ flexDirection: 'row',
627
+ flexWrap: 'wrap',
628
+ justifyContent: 'space-between',
629
+ marginTop: 16,
630
+ },
631
+ testButton: {
632
+ width: '48%',
633
+ marginBottom: 12,
634
+ paddingVertical: 12,
635
+ borderRadius: 8,
636
+ alignItems: 'center',
637
+ },
638
+ testButtonText: {
639
+ color: '#fff',
640
+ fontSize: 14,
641
+ fontWeight: '600',
642
+ },
643
+ resultsSection: {
644
+ backgroundColor: '#fff',
645
+ borderRadius: 12,
646
+ padding: 16,
647
+ },
648
+ resultsHeader: {
649
+ flexDirection: 'row',
650
+ justifyContent: 'space-between',
651
+ alignItems: 'center',
652
+ marginBottom: 16,
653
+ },
654
+ clearButton: {
655
+ paddingHorizontal: 12,
656
+ paddingVertical: 6,
657
+ backgroundColor: '#FF3B30',
658
+ borderRadius: 6,
659
+ },
660
+ clearButtonText: {
661
+ color: '#fff',
662
+ fontSize: 12,
663
+ fontWeight: '600',
664
+ },
665
+ resultItem: {
666
+ padding: 12,
667
+ marginBottom: 8,
668
+ borderRadius: 8,
669
+ borderWidth: 1,
670
+ },
671
+ successResult: {
672
+ backgroundColor: '#f0fff4',
673
+ borderColor: '#68d391',
674
+ },
675
+ errorResult: {
676
+ backgroundColor: '#fff5f5',
677
+ borderColor: '#fc8181',
678
+ },
679
+ resultHeader: {
680
+ flexDirection: 'row',
681
+ justifyContent: 'space-between',
682
+ marginBottom: 8,
683
+ },
684
+ resultMethod: {
685
+ fontSize: 14,
686
+ fontWeight: 'bold',
687
+ color: '#333',
688
+ },
689
+ resultTime: {
690
+ fontSize: 12,
691
+ color: '#666',
692
+ },
693
+ resultText: {
694
+ fontSize: 12,
695
+ color: '#2d3748',
696
+ fontFamily: 'monospace',
697
+ },
698
+ errorText: {
699
+ fontSize: 12,
700
+ color: '#e53e3e',
701
+ },
702
+ noResults: {
703
+ textAlign: 'center',
704
+ color: '#999',
705
+ fontStyle: 'italic',
706
+ paddingVertical: 20,
707
+ },
708
+ });
709
+
710
+ export default BeiDouAIDLTestPage;