react-native-beidou 1.1.3 → 1.1.6

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 (55) hide show
  1. package/Compass.android.tsx +4 -12
  2. package/Compass.ios.tsx +2 -3
  3. package/android/build.gradle +22 -9
  4. package/android/src/main/AndroidManifest.xml +1 -0
  5. package/android/src/main/java/com/fxzs.rnbeidou/BeiDouBluetoothModule.java +528 -188
  6. package/android/src/main/java/com/fxzs.rnbeidou/BeiDouBluetoothPackage.java +10 -13
  7. package/android/src/main/java/com/fxzs.rnbeidou/BeidouAidlHelper.java +45 -13
  8. package/android/src/main/java/com/fxzs.rnbeidou/SuperSimModule.java +301 -0
  9. package/android/src/main/java/com/fxzs.rnbeidou/view/CompassManager.java +15 -15
  10. package/android/src/main/java/com/fxzs.rnbeidou/view/CompassView.java +10 -4
  11. package/index.ts +128 -228
  12. package/ios/BeiDouBluetoothModule.m +147 -20
  13. package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
  14. package/ios/BeidouBluetooth.framework/FMDB.bundle/Info.plist +0 -0
  15. package/ios/BeidouBluetooth.framework/Info.plist +0 -0
  16. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
  17. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
  18. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +4 -4
  19. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
  20. package/ios/CompassView.h +1 -0
  21. package/ios/CompassView.m +3 -0
  22. package/ios/CompassViewComponentView.h +11 -0
  23. package/ios/CompassViewComponentView.mm +64 -0
  24. package/package.json +3 -5
  25. package/react-native-beidou.podspec +6 -3
  26. package/react-native.config.js +2 -5
  27. package/src/CompassViewNativeComponent.ts +13 -0
  28. package/src/NativeBeiDouBluetooth.ts +57 -0
  29. package/src/NativeSuperSim.ts +21 -0
  30. package/BeiDouAIDLTestPage.tsx +0 -1196
  31. package/LogManager.ts +0 -285
  32. package/TestPage.ts +0 -6
  33. package/android/.gradle/8.10/checksums/checksums.lock +0 -0
  34. package/android/.gradle/8.10/dependencies-accessors/gc.properties +0 -0
  35. package/android/.gradle/8.10/fileChanges/last-build.bin +0 -0
  36. package/android/.gradle/8.10/fileHashes/fileHashes.lock +0 -0
  37. package/android/.gradle/8.10/gc.properties +0 -0
  38. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  39. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  40. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  41. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  42. package/android/.gradle/8.9/gc.properties +0 -0
  43. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  44. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  45. package/android/.gradle/config.properties +0 -2
  46. package/android/.gradle/vcs-1/gc.properties +0 -0
  47. package/android/.idea/AndroidProjectSystem.xml +0 -6
  48. package/android/.idea/caches/deviceStreaming.xml +0 -1138
  49. package/android/.idea/gradle.xml +0 -13
  50. package/android/.idea/migrations.xml +0 -10
  51. package/android/.idea/misc.xml +0 -9
  52. package/android/.idea/runConfigurations.xml +0 -17
  53. package/android/.idea/vcs.xml +0 -6
  54. package/android/local.properties +0 -8
  55. package/android/src/main/java/com/fxzs.rnbeidou/LogManager.java +0 -488
@@ -1,1196 +0,0 @@
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
- BDAuthResult,
17
- BDMsgEncryptResponse,
18
- BDMsgDecryptResponse,
19
- BDMsgEphemerisFileDLResponse,
20
- } from './index';
21
-
22
- interface TestResult {
23
- method: string;
24
- success: boolean;
25
- result?: any;
26
- error?: string;
27
- timestamp: Date;
28
- }
29
-
30
- const BeiDouAIDLTestPage: React.FC = () => {
31
- const [isServiceBound, setIsServiceBound] = useState(false);
32
- const [loading, setLoading] = useState(false);
33
- const [testResults, setTestResults] = useState<TestResult[]>([]);
34
-
35
- // 输入参数状态
36
- const [inputMsg, setInputMsg] = useState('测试消息内容');
37
- const [receiveList, setReceiveList] = useState('13800138000,13900139000');
38
- const [longitude, setLongitude] = useState('116.404');
39
- const [latitude, setLatitude] = useState('39.915');
40
- const [ephemerisType, setEphemerisType] = useState('GPS');
41
- const [ephemerisVersion, setEphemerisVersion] = useState('1.0.0');
42
- const [decryptMsg, setDecryptMsg] = useState('1,2,3,4,5');
43
- const [slotId, setSlotId] = useState('0');
44
- const [speedType, setSpeedType] = useState('0');
45
- const [msgType, setMsgType] = useState('00');
46
- const [richMediaData, setRichMediaData] = useState('1,2,3,4');
47
- const [richMediaText, setRichMediaText] = useState('富媒体文本示例');
48
- const [replyMobile, setReplyMobile] = useState('13800138000');
49
-
50
- // 服务配置参数
51
- const [packageName, setPackageName] = useState('com.test.aidlsetvicetest');
52
- const [actionName, setActionName] = useState('com.samsung.beidoupackage.BeidouMsgAidlService');
53
-
54
- const parseSlotId = () => {
55
- const parsed = parseInt(slotId, 10);
56
- return 0;
57
- };
58
-
59
- const parseReceiveList = () =>
60
- receiveList
61
- .split(',')
62
- .map(s => s.trim())
63
- .filter(Boolean);
64
-
65
- const parseRichMediaDataInput = () =>
66
- richMediaData
67
- .split(',')
68
- .map(s => parseInt(s.trim(), 10))
69
- .filter(n => Number.isInteger(n) && n >= 0);
70
-
71
- const addTestResult = (method: string, success: boolean, result?: any, error?: string) => {
72
- const newResult: TestResult = {
73
- method,
74
- success,
75
- result,
76
- error,
77
- timestamp: new Date(),
78
- };
79
- setTestResults(prev => [newResult, ...prev.slice(0, 9)]); // 保留最新的10条记录
80
- };
81
-
82
- const clearResults = () => {
83
- setTestResults([]);
84
- };
85
-
86
- // 绑定北斗服务
87
- const bindService = async () => {
88
- setLoading(true);
89
- try {
90
- if (!packageName.trim() || !actionName.trim()) {
91
- Alert.alert('错误', '请输入有效的包名和Action名');
92
- return;
93
- }
94
-
95
- const result = await BeiDouModule.beidou.bindService(packageName.trim(), actionName.trim());
96
- setIsServiceBound(result);
97
- addTestResult('bindService', result, { packageName: packageName.trim(), actionName: actionName.trim(), result });
98
- if (result) {
99
- Alert.alert('成功', `北斗服务绑定成功\n包名: ${packageName}\nAction: ${actionName}`);
100
- } else {
101
- Alert.alert('失败', '北斗服务绑定失败');
102
- }
103
- } catch (error) {
104
- const errorMsg = error instanceof Error ? error.message : String(error);
105
- addTestResult('bindService', false, undefined, errorMsg);
106
- Alert.alert('错误', `绑定服务失败: ${errorMsg}`);
107
- } finally {
108
- setLoading(false);
109
- }
110
- };
111
-
112
- // 解绑北斗服务
113
- const unbindService = async () => {
114
- setLoading(true);
115
- try {
116
- const result = await BeiDouModule.beidou.unbindService();
117
- setIsServiceBound(false);
118
- addTestResult('unbindService', result, result);
119
- Alert.alert('成功', '北斗服务已解绑');
120
- } catch (error) {
121
- const errorMsg = error instanceof Error ? error.message : String(error);
122
- addTestResult('unbindService', false, undefined, errorMsg);
123
- Alert.alert('错误', `解绑服务失败: ${errorMsg}`);
124
- } finally {
125
- setLoading(false);
126
- }
127
- };
128
-
129
- // 鉴权测试
130
- const testAuthenticate = async () => {
131
- setLoading(true);
132
- try {
133
- const result: BDAuthResult = await BeiDouModule.beidou.authenticate(parseSlotId());
134
- addTestResult('authenticate', true, result);
135
- Alert.alert(
136
- '鉴权结果',
137
- `Slot: ${result.slotId}\nCode: ${result.code}\n状态: ${result.statusMsg ?? ''}`
138
- );
139
- } catch (error) {
140
- const errorMsg = error instanceof Error ? error.message : String(error);
141
- addTestResult('authenticate', false, undefined, errorMsg);
142
- Alert.alert('错误', `鉴权失败: ${errorMsg}`);
143
- } finally {
144
- setLoading(false);
145
- }
146
- };
147
-
148
- // 获取用户状态
149
- const testGetStatus = async () => {
150
- setLoading(true);
151
- try {
152
- const result: BDStatusResponse = await BeiDouModule.beidou.getStatus(parseSlotId());
153
- addTestResult('getStatus', true, result);
154
- Alert.alert(
155
- '用户状态',
156
- `Slot: ${result.slotId ?? parseSlotId()}\n代码: ${result.code}\n状态: ${result.statusMsg}\n剩余额度: ${result.msgQuotaRemain}\n用户开通状态: ${result.userOpenStatus}`
157
- );
158
- } catch (error) {
159
- const errorMsg = error instanceof Error ? error.message : String(error);
160
- addTestResult('getStatus', false, undefined, errorMsg);
161
- Alert.alert('错误', `获取状态失败: ${errorMsg}`);
162
- } finally {
163
- setLoading(false);
164
- }
165
- };
166
-
167
- // 检查密钥状态
168
- const testCheckKey = async () => {
169
- setLoading(true);
170
- try {
171
- const result: number = await BeiDouModule.beidou.checkKey(parseSlotId());
172
- addTestResult('checkKey', true, result);
173
- Alert.alert('密钥状态', `密钥状态代码: ${result}`);
174
- } catch (error) {
175
- const errorMsg = error instanceof Error ? error.message : String(error);
176
- addTestResult('checkKey', false, undefined, errorMsg);
177
- Alert.alert('错误', `检查密钥失败: ${errorMsg}`);
178
- } finally {
179
- setLoading(false);
180
- }
181
- };
182
-
183
- // 通用报文加密测试
184
- const testCommonEncrypt = async () => {
185
- setLoading(true);
186
- try {
187
- const receivers = parseReceiveList();
188
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptCommonMessage(receivers, inputMsg, {
189
- slotId: parseSlotId(),
190
- speedType,
191
- });
192
- const first = result[0];
193
- addTestResult('commonEncrypt', result.length > 0, result, result.length > 0 ? undefined : '无返回数据');
194
- if (first) {
195
- Alert.alert(
196
- '加密成功',
197
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}\n数据长度: ${first.data.length}\nPayload Len: ${first.len}`
198
- );
199
- } else {
200
- Alert.alert('提示', '调用成功但未返回任何加密结果');
201
- }
202
- } catch (error) {
203
- const errorMsg = error instanceof Error ? error.message : String(error);
204
- addTestResult('commonEncrypt', false, undefined, errorMsg);
205
- Alert.alert('错误', `通用加密失败: ${errorMsg}`);
206
- } finally {
207
- setLoading(false);
208
- }
209
- };
210
-
211
- // 位置报文加密测试
212
- const testPositionEncrypt = async () => {
213
- setLoading(true);
214
- try {
215
- const receivers = parseReceiveList();
216
- const lng = parseFloat(longitude);
217
- const lat = parseFloat(latitude);
218
-
219
- if (isNaN(lng) || isNaN(lat)) {
220
- Alert.alert('错误', '请输入有效的经纬度');
221
- return;
222
- }
223
-
224
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptPositionMessage(
225
- receivers,
226
- inputMsg,
227
- lng,
228
- lat,
229
- {
230
- slotId: parseSlotId(),
231
- speedType,
232
- }
233
- );
234
- const first = result[0];
235
- addTestResult('positionEncrypt', result.length > 0, result, result.length > 0 ? undefined : '无返回数据');
236
- if (first) {
237
- Alert.alert(
238
- '位置加密成功',
239
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}\n数据长度: ${first.data.length}\nPayload Len: ${first.len}`
240
- );
241
- } else {
242
- Alert.alert('提示', '调用成功但未返回任何加密结果');
243
- }
244
- } catch (error) {
245
- const errorMsg = error instanceof Error ? error.message : String(error);
246
- addTestResult('positionEncrypt', false, undefined, errorMsg);
247
- Alert.alert('错误', `位置加密失败: ${errorMsg}`);
248
- } finally {
249
- setLoading(false);
250
- }
251
- };
252
-
253
- const testCommonEmergencyEncrypt = async () => {
254
- setLoading(true);
255
- try {
256
- const receivers = parseReceiveList();
257
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptCommonEmergencyMessage(
258
- receivers,
259
- inputMsg,
260
- {
261
- slotId: parseSlotId(),
262
- speedType,
263
- }
264
- );
265
- const first = result[0];
266
- addTestResult('commonEmergencyEncrypt', result.length > 0, result, result.length > 0 ? undefined : '无返回数据');
267
- if (first) {
268
- Alert.alert(
269
- '应急通用加密成功',
270
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}\n数据长度: ${first.data.length}`
271
- );
272
- } else {
273
- Alert.alert('提示', '调用成功但未返回任何加密结果');
274
- }
275
- } catch (error) {
276
- const errorMsg = error instanceof Error ? error.message : String(error);
277
- addTestResult('commonEmergencyEncrypt', false, undefined, errorMsg);
278
- Alert.alert('错误', `应急通用加密失败: ${errorMsg}`);
279
- } finally {
280
- setLoading(false);
281
- }
282
- };
283
-
284
- const testPositionEmergencyEncrypt = async () => {
285
- setLoading(true);
286
- try {
287
- const receivers = parseReceiveList();
288
- const lng = parseFloat(longitude);
289
- const lat = parseFloat(latitude);
290
-
291
- if (isNaN(lng) || isNaN(lat)) {
292
- Alert.alert('错误', '请输入有效的经纬度');
293
- return;
294
- }
295
-
296
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptPositionEmergencyMessage(
297
- receivers,
298
- inputMsg,
299
- lng,
300
- lat,
301
- {
302
- slotId: parseSlotId(),
303
- speedType,
304
- }
305
- );
306
- const first = result[0];
307
- addTestResult(
308
- 'positionEmergencyEncrypt',
309
- result.length > 0,
310
- result,
311
- result.length > 0 ? undefined : '无返回数据'
312
- );
313
- if (first) {
314
- Alert.alert(
315
- '应急位置加密成功',
316
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}\n数据长度: ${first.data.length}`
317
- );
318
- } else {
319
- Alert.alert('提示', '调用成功但未返回任何加密结果');
320
- }
321
- } catch (error) {
322
- const errorMsg = error instanceof Error ? error.message : String(error);
323
- addTestResult('positionEmergencyEncrypt', false, undefined, errorMsg);
324
- Alert.alert('错误', `应急位置加密失败: ${errorMsg}`);
325
- } finally {
326
- setLoading(false);
327
- }
328
- };
329
-
330
- // 信箱查询加密测试
331
- const testMailboxQuery = async () => {
332
- setLoading(true);
333
- try {
334
- const result: BDMsgEncryptResponse = await BeiDouModule.beidou.encryptMailboxQuery(parseSlotId());
335
- addTestResult('mailboxQuery', true, result);
336
- Alert.alert(
337
- '信箱查询成功',
338
- `代码: ${result.code}\n状态: ${result.statusMsg}\n发送方: ${result.sendMobile}\n数据长度: ${result.data.length}\nPayload Len: ${result.len}`
339
- );
340
- } catch (error) {
341
- const errorMsg = error instanceof Error ? error.message : String(error);
342
- addTestResult('mailboxQuery', false, undefined, errorMsg);
343
- Alert.alert('错误', `信箱查询失败: ${errorMsg}`);
344
- } finally {
345
- setLoading(false);
346
- }
347
- };
348
-
349
- const testEmergencyMailboxQuery = async () => {
350
- setLoading(true);
351
- try {
352
- const result: BDMsgEncryptResponse = await BeiDouModule.beidou.encryptEmergencyMailboxQuery(
353
- replyMobile,
354
- parseSlotId()
355
- );
356
- addTestResult('emergencyMailboxQuery', true, result);
357
- Alert.alert(
358
- '应急信箱查询成功',
359
- `代码: ${result.code}\n状态: ${result.statusMsg}\n发送方: ${result.sendMobile}\n数据长度: ${result.data.length}\nPayload Len: ${result.len}`
360
- );
361
- } catch (error) {
362
- const errorMsg = error instanceof Error ? error.message : String(error);
363
- addTestResult('emergencyMailboxQuery', false, undefined, errorMsg);
364
- Alert.alert('错误', `应急信箱查询失败: ${errorMsg}`);
365
- } finally {
366
- setLoading(false);
367
- }
368
- };
369
-
370
- const testCommonRichMediaEncrypt = async () => {
371
- setLoading(true);
372
- try {
373
- const receivers = parseReceiveList();
374
- const dataBytes = parseRichMediaDataInput();
375
- if (dataBytes.length === 0) {
376
- Alert.alert('错误', '请填写有效的富媒体数据(逗号分隔的数字)');
377
- return;
378
- }
379
-
380
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptCommonRichMediaMessage(
381
- receivers,
382
- msgType,
383
- dataBytes,
384
- {
385
- slotId: parseSlotId(),
386
- speedType,
387
- }
388
- );
389
- const first = result[0];
390
- addTestResult('commonRichMediaEncrypt', result.length > 0, result, result.length > 0 ? undefined : '无返回数据');
391
- if (first) {
392
- Alert.alert(
393
- '富媒体通用加密成功',
394
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}`
395
- );
396
- } else {
397
- Alert.alert('提示', '调用成功但未返回任何加密结果');
398
- }
399
- } catch (error) {
400
- const errorMsg = error instanceof Error ? error.message : String(error);
401
- addTestResult('commonRichMediaEncrypt', false, undefined, errorMsg);
402
- Alert.alert('错误', `富媒体通用加密失败: ${errorMsg}`);
403
- } finally {
404
- setLoading(false);
405
- }
406
- };
407
-
408
- const testPositionRichMediaEncrypt = async () => {
409
- setLoading(true);
410
- try {
411
- const receivers = parseReceiveList();
412
- const dataBytes = parseRichMediaDataInput();
413
- if (dataBytes.length === 0) {
414
- Alert.alert('错误', '请填写有效的富媒体数据(逗号分隔的数字)');
415
- return;
416
- }
417
-
418
- const lng = parseFloat(longitude);
419
- const lat = parseFloat(latitude);
420
-
421
- if (isNaN(lng) || isNaN(lat)) {
422
- Alert.alert('错误', '请输入有效的经纬度');
423
- return;
424
- }
425
-
426
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptPositionRichMediaMessage(
427
- receivers,
428
- msgType,
429
- dataBytes,
430
- lng,
431
- lat,
432
- {
433
- slotId: parseSlotId(),
434
- speedType,
435
- }
436
- );
437
- const first = result[0];
438
- addTestResult(
439
- 'positionRichMediaEncrypt',
440
- result.length > 0,
441
- result,
442
- result.length > 0 ? undefined : '无返回数据'
443
- );
444
- if (first) {
445
- Alert.alert(
446
- '富媒体位置加密成功',
447
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}`
448
- );
449
- } else {
450
- Alert.alert('提示', '调用成功但未返回任何加密结果');
451
- }
452
- } catch (error) {
453
- const errorMsg = error instanceof Error ? error.message : String(error);
454
- addTestResult('positionRichMediaEncrypt', false, undefined, errorMsg);
455
- Alert.alert('错误', `富媒体位置加密失败: ${errorMsg}`);
456
- } finally {
457
- setLoading(false);
458
- }
459
- };
460
-
461
- const testCommonRichMediaTextEncrypt = async () => {
462
- setLoading(true);
463
- try {
464
- const receivers = parseReceiveList();
465
- const dataBytes = parseRichMediaDataInput();
466
- if (dataBytes.length === 0) {
467
- Alert.alert('错误', '请填写有效的富媒体数据(逗号分隔的数字)');
468
- return;
469
- }
470
-
471
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptCommonRichMediaAndTextMessage(
472
- receivers,
473
- richMediaText,
474
- msgType,
475
- dataBytes,
476
- {
477
- slotId: parseSlotId(),
478
- speedType,
479
- }
480
- );
481
- const first = result[0];
482
- addTestResult(
483
- 'commonRichMediaTextEncrypt',
484
- result.length > 0,
485
- result,
486
- result.length > 0 ? undefined : '无返回数据'
487
- );
488
- if (first) {
489
- Alert.alert(
490
- '图文通用加密成功',
491
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}`
492
- );
493
- } else {
494
- Alert.alert('提示', '调用成功但未返回任何加密结果');
495
- }
496
- } catch (error) {
497
- const errorMsg = error instanceof Error ? error.message : String(error);
498
- addTestResult('commonRichMediaTextEncrypt', false, undefined, errorMsg);
499
- Alert.alert('错误', `图文通用加密失败: ${errorMsg}`);
500
- } finally {
501
- setLoading(false);
502
- }
503
- };
504
-
505
- const testPositionRichMediaTextEncrypt = async () => {
506
- setLoading(true);
507
- try {
508
- const receivers = parseReceiveList();
509
- const dataBytes = parseRichMediaDataInput();
510
- if (dataBytes.length === 0) {
511
- Alert.alert('错误', '请填写有效的富媒体数据(逗号分隔的数字)');
512
- return;
513
- }
514
-
515
- const lng = parseFloat(longitude);
516
- const lat = parseFloat(latitude);
517
-
518
- if (isNaN(lng) || isNaN(lat)) {
519
- Alert.alert('错误', '请输入有效的经纬度');
520
- return;
521
- }
522
-
523
- const result: BDMsgEncryptResponse[] = await BeiDouModule.beidou.encryptPositionRichMediaAndTextMessage(
524
- receivers,
525
- richMediaText,
526
- msgType,
527
- dataBytes,
528
- lng,
529
- lat,
530
- {
531
- slotId: parseSlotId(),
532
- speedType,
533
- }
534
- );
535
- const first = result[0];
536
- addTestResult(
537
- 'positionRichMediaTextEncrypt',
538
- result.length > 0,
539
- result,
540
- result.length > 0 ? undefined : '无返回数据'
541
- );
542
- if (first) {
543
- Alert.alert(
544
- '图文位置加密成功',
545
- `返回条数: ${result.length}\n代码: ${first.code}\n状态: ${first.statusMsg}\n发送方: ${first.sendMobile}`
546
- );
547
- } else {
548
- Alert.alert('提示', '调用成功但未返回任何加密结果');
549
- }
550
- } catch (error) {
551
- const errorMsg = error instanceof Error ? error.message : String(error);
552
- addTestResult('positionRichMediaTextEncrypt', false, undefined, errorMsg);
553
- Alert.alert('错误', `图文位置加密失败: ${errorMsg}`);
554
- } finally {
555
- setLoading(false);
556
- }
557
- };
558
-
559
- // 报文解密测试
560
- const testDecryptMessage = async () => {
561
- setLoading(true);
562
- try {
563
- const msgBytes = decryptMsg.split(',').map(s => parseInt(s.trim())).filter(n => !isNaN(n));
564
- if (msgBytes.length === 0) {
565
- Alert.alert('错误', '请输入有效的字节数组(用逗号分隔的数字)');
566
- return;
567
- }
568
-
569
- const result: BDMsgDecryptResponse = await BeiDouModule.beidou.decryptMessage(
570
- msgBytes,
571
- msgBytes.length,
572
- parseSlotId()
573
- );
574
- addTestResult('decryptMessage', true, result);
575
- Alert.alert('解密成功', `状态: ${result.statusMsg}\n是否还有消息: ${result.isRemainMsg}\n发送方: ${result.rcvMobile}\n内容: ${result.data}`);
576
- } catch (error) {
577
- const errorMsg = error instanceof Error ? error.message : String(error);
578
- addTestResult('decryptMessage', false, undefined, errorMsg);
579
- Alert.alert('错误', `解密失败: ${errorMsg}`);
580
- } finally {
581
- setLoading(false);
582
- }
583
- };
584
-
585
- // 下载星历文件测试
586
- const testDownloadEphemeris = async () => {
587
- setLoading(true);
588
- try {
589
- const result: BDMsgEphemerisFileDLResponse = await BeiDouModule.beidou.downloadEphemeris(
590
- ephemerisType,
591
- ephemerisVersion,
592
- parseSlotId()
593
- );
594
- addTestResult('downloadEphemeris', true, result);
595
- Alert.alert(
596
- '下载成功',
597
- `Slot: ${result.slotId}\n代码: ${result.code}\n状态: ${result.statusMsg}\n版本: ${result.version}\n文件名: ${result.ephemerisZipFileName ?? '未知'}\n文件大小: ${
598
- result.ephemerisZipFile.length
599
- } 字节`
600
- );
601
- } catch (error) {
602
- const errorMsg = error instanceof Error ? error.message : String(error);
603
- addTestResult('downloadEphemeris', false, undefined, errorMsg);
604
- Alert.alert('错误', `下载星历失败: ${errorMsg}`);
605
- } finally {
606
- setLoading(false);
607
- }
608
- };
609
-
610
- // 运行所有测试
611
- const runAllTests = async () => {
612
- if (!isServiceBound) {
613
- Alert.alert('提示', '请先绑定北斗服务');
614
- return;
615
- }
616
-
617
- const tests = [
618
- testAuthenticate,
619
- testGetStatus,
620
- testCheckKey,
621
- testCommonEncrypt,
622
- testPositionEncrypt,
623
- testCommonEmergencyEncrypt,
624
- testPositionEmergencyEncrypt,
625
- testMailboxQuery,
626
- testEmergencyMailboxQuery,
627
- testCommonRichMediaEncrypt,
628
- testPositionRichMediaEncrypt,
629
- testCommonRichMediaTextEncrypt,
630
- testPositionRichMediaTextEncrypt,
631
- testDecryptMessage,
632
- testDownloadEphemeris,
633
- ];
634
-
635
- for (const test of tests) {
636
- await test();
637
- // 在测试之间添加短暂延迟
638
- await new Promise(resolve => setTimeout(resolve, 500));
639
- }
640
- };
641
-
642
- return (
643
- <SafeAreaView style={styles.container}>
644
- <ScrollView style={styles.scrollView} contentContainerStyle={styles.contentContainer}>
645
- <Text style={styles.title}>北斗AIDL服务测试</Text>
646
-
647
- {/* 服务状态 */}
648
- <View style={styles.statusContainer}>
649
- <Text style={styles.statusText}>
650
- 服务状态: {isServiceBound ? '已绑定' : '未绑定'}
651
- </Text>
652
- {loading && <ActivityIndicator size="small" color="#007AFF" />}
653
- </View>
654
-
655
- {/* 服务绑定控制 */}
656
- <View style={styles.buttonGroup}>
657
- <TouchableOpacity
658
- style={[styles.button, styles.primaryButton]}
659
- onPress={bindService}
660
- disabled={loading || isServiceBound}
661
- >
662
- <Text style={styles.buttonText}>绑定服务</Text>
663
- </TouchableOpacity>
664
-
665
- <TouchableOpacity
666
- style={[styles.button, styles.secondaryButton]}
667
- onPress={unbindService}
668
- disabled={loading || !isServiceBound}
669
- >
670
- <Text style={styles.buttonText}>解绑服务</Text>
671
- </TouchableOpacity>
672
- </View>
673
-
674
- {/* 服务配置区域 */}
675
- <View style={styles.inputSection}>
676
- <Text style={styles.sectionTitle}>服务配置</Text>
677
-
678
- <View style={styles.inputGroup}>
679
- <Text style={styles.inputLabel}>包名 (Package Name):</Text>
680
- <TextInput
681
- style={styles.textInput}
682
- value={packageName}
683
- onChangeText={setPackageName}
684
- placeholder="com.test.aidlsetvicetest"
685
- />
686
- </View>
687
-
688
- <View style={styles.inputGroup}>
689
- <Text style={styles.inputLabel}>Action名:</Text>
690
- <TextInput
691
- style={styles.textInput}
692
- value={actionName}
693
- onChangeText={setActionName}
694
- placeholder="com.samsung.beidoupackage.BeidouMsgAidlService"
695
- />
696
- </View>
697
- </View>
698
-
699
- {/* 输入参数区域 */}
700
- <View style={styles.inputSection}>
701
- <Text style={styles.sectionTitle}>测试参数</Text>
702
-
703
- <View style={styles.row}>
704
- <View style={styles.halfInput}>
705
- <Text style={styles.inputLabel}>SIM Slot ID:</Text>
706
- <TextInput
707
- style={styles.textInput}
708
- value={slotId}
709
- onChangeText={setSlotId}
710
- placeholder="0"
711
- keyboardType="numeric"
712
- />
713
- </View>
714
- <View style={styles.halfInput}>
715
- <Text style={styles.inputLabel}>Speed Type:</Text>
716
- <TextInput
717
- style={styles.textInput}
718
- value={speedType}
719
- onChangeText={setSpeedType}
720
- placeholder="0"
721
- />
722
- </View>
723
- </View>
724
-
725
- <View style={styles.inputGroup}>
726
- <Text style={styles.inputLabel}>消息内容:</Text>
727
- <TextInput
728
- style={styles.textInput}
729
- value={inputMsg}
730
- onChangeText={setInputMsg}
731
- placeholder="输入测试消息"
732
- />
733
- </View>
734
-
735
- <View style={styles.inputGroup}>
736
- <Text style={styles.inputLabel}>接收方列表 (逗号分隔):</Text>
737
- <TextInput
738
- style={styles.textInput}
739
- value={receiveList}
740
- onChangeText={setReceiveList}
741
- placeholder="手机号1,手机号2"
742
- />
743
- </View>
744
-
745
- <View style={styles.row}>
746
- <View style={styles.halfInput}>
747
- <Text style={styles.inputLabel}>经度:</Text>
748
- <TextInput
749
- style={styles.textInput}
750
- value={longitude}
751
- onChangeText={setLongitude}
752
- placeholder="116.404"
753
- keyboardType="numeric"
754
- />
755
- </View>
756
- <View style={styles.halfInput}>
757
- <Text style={styles.inputLabel}>纬度:</Text>
758
- <TextInput
759
- style={styles.textInput}
760
- value={latitude}
761
- onChangeText={setLatitude}
762
- placeholder="39.915"
763
- keyboardType="numeric"
764
- />
765
- </View>
766
- </View>
767
-
768
- <View style={styles.row}>
769
- <View style={styles.halfInput}>
770
- <Text style={styles.inputLabel}>星历类型:</Text>
771
- <TextInput
772
- style={styles.textInput}
773
- value={ephemerisType}
774
- onChangeText={setEphemerisType}
775
- placeholder="GPS"
776
- />
777
- </View>
778
- <View style={styles.halfInput}>
779
- <Text style={styles.inputLabel}>星历版本:</Text>
780
- <TextInput
781
- style={styles.textInput}
782
- value={ephemerisVersion}
783
- onChangeText={setEphemerisVersion}
784
- placeholder="1.0.0"
785
- />
786
- </View>
787
- </View>
788
-
789
- <View style={styles.inputGroup}>
790
- <Text style={styles.inputLabel}>解密数据 (逗号分隔的数字):</Text>
791
- <TextInput
792
- style={styles.textInput}
793
- value={decryptMsg}
794
- onChangeText={setDecryptMsg}
795
- placeholder="1,2,3,4,5"
796
- />
797
- </View>
798
-
799
- <View style={styles.inputGroup}>
800
- <Text style={styles.inputLabel}>消息类型 (msgType):</Text>
801
- <TextInput
802
- style={styles.textInput}
803
- value={msgType}
804
- onChangeText={setMsgType}
805
- placeholder="00"
806
- />
807
- </View>
808
-
809
- <View style={styles.inputGroup}>
810
- <Text style={styles.inputLabel}>富媒体数据 (逗号分隔的数字):</Text>
811
- <TextInput
812
- style={styles.textInput}
813
- value={richMediaData}
814
- onChangeText={setRichMediaData}
815
- placeholder="1,2,3,4"
816
- />
817
- </View>
818
-
819
- <View style={styles.inputGroup}>
820
- <Text style={styles.inputLabel}>图文混排文本:</Text>
821
- <TextInput
822
- style={styles.textInput}
823
- value={richMediaText}
824
- onChangeText={setRichMediaText}
825
- placeholder="图文混排文本内容"
826
- />
827
- </View>
828
-
829
- <View style={styles.inputGroup}>
830
- <Text style={styles.inputLabel}>应急回执手机号:</Text>
831
- <TextInput
832
- style={styles.textInput}
833
- value={replyMobile}
834
- onChangeText={setReplyMobile}
835
- placeholder="13800138000"
836
- />
837
- </View>
838
- </View>
839
-
840
- {/* 测试按钮区域 */}
841
- <View style={styles.testSection}>
842
- <Text style={styles.sectionTitle}>功能测试</Text>
843
-
844
- <TouchableOpacity
845
- style={[styles.button, styles.primaryButton]}
846
- onPress={runAllTests}
847
- disabled={loading || !isServiceBound}
848
- >
849
- <Text style={styles.buttonText}>运行所有测试</Text>
850
- </TouchableOpacity>
851
-
852
- <View style={styles.buttonGrid}>
853
- <TouchableOpacity
854
- style={[styles.testButton, styles.primaryButton]}
855
- onPress={testAuthenticate}
856
- disabled={loading || !isServiceBound}
857
- >
858
- <Text style={styles.testButtonText}>鉴权</Text>
859
- </TouchableOpacity>
860
-
861
- <TouchableOpacity
862
- style={[styles.testButton, styles.primaryButton]}
863
- onPress={testGetStatus}
864
- disabled={loading || !isServiceBound}
865
- >
866
- <Text style={styles.testButtonText}>获取状态</Text>
867
- </TouchableOpacity>
868
-
869
- <TouchableOpacity
870
- style={[styles.testButton, styles.primaryButton]}
871
- onPress={testCheckKey}
872
- disabled={loading || !isServiceBound}
873
- >
874
- <Text style={styles.testButtonText}>检查密钥</Text>
875
- </TouchableOpacity>
876
-
877
- <TouchableOpacity
878
- style={[styles.testButton, styles.primaryButton]}
879
- onPress={testCommonEncrypt}
880
- disabled={loading || !isServiceBound}
881
- >
882
- <Text style={styles.testButtonText}>通用加密</Text>
883
- </TouchableOpacity>
884
-
885
- <TouchableOpacity
886
- style={[styles.testButton, styles.primaryButton]}
887
- onPress={testPositionEncrypt}
888
- disabled={loading || !isServiceBound}
889
- >
890
- <Text style={styles.testButtonText}>位置加密</Text>
891
- </TouchableOpacity>
892
-
893
- <TouchableOpacity
894
- style={[styles.testButton, styles.primaryButton]}
895
- onPress={testCommonEmergencyEncrypt}
896
- disabled={loading || !isServiceBound}
897
- >
898
- <Text style={styles.testButtonText}>应急通用加密</Text>
899
- </TouchableOpacity>
900
-
901
- <TouchableOpacity
902
- style={[styles.testButton, styles.primaryButton]}
903
- onPress={testPositionEmergencyEncrypt}
904
- disabled={loading || !isServiceBound}
905
- >
906
- <Text style={styles.testButtonText}>应急位置加密</Text>
907
- </TouchableOpacity>
908
-
909
- <TouchableOpacity
910
- style={[styles.testButton, styles.primaryButton]}
911
- onPress={testMailboxQuery}
912
- disabled={loading || !isServiceBound}
913
- >
914
- <Text style={styles.testButtonText}>信箱查询</Text>
915
- </TouchableOpacity>
916
-
917
- <TouchableOpacity
918
- style={[styles.testButton, styles.primaryButton]}
919
- onPress={testEmergencyMailboxQuery}
920
- disabled={loading || !isServiceBound}
921
- >
922
- <Text style={styles.testButtonText}>应急信箱查询</Text>
923
- </TouchableOpacity>
924
-
925
- <TouchableOpacity
926
- style={[styles.testButton, styles.primaryButton]}
927
- onPress={testCommonRichMediaEncrypt}
928
- disabled={loading || !isServiceBound}
929
- >
930
- <Text style={styles.testButtonText}>富媒体通用加密</Text>
931
- </TouchableOpacity>
932
-
933
- <TouchableOpacity
934
- style={[styles.testButton, styles.primaryButton]}
935
- onPress={testPositionRichMediaEncrypt}
936
- disabled={loading || !isServiceBound}
937
- >
938
- <Text style={styles.testButtonText}>富媒体位置加密</Text>
939
- </TouchableOpacity>
940
-
941
- <TouchableOpacity
942
- style={[styles.testButton, styles.primaryButton]}
943
- onPress={testCommonRichMediaTextEncrypt}
944
- disabled={loading || !isServiceBound}
945
- >
946
- <Text style={styles.testButtonText}>图文通用加密</Text>
947
- </TouchableOpacity>
948
-
949
- <TouchableOpacity
950
- style={[styles.testButton, styles.primaryButton]}
951
- onPress={testPositionRichMediaTextEncrypt}
952
- disabled={loading || !isServiceBound}
953
- >
954
- <Text style={styles.testButtonText}>图文位置加密</Text>
955
- </TouchableOpacity>
956
-
957
- <TouchableOpacity
958
- style={[styles.testButton, styles.primaryButton]}
959
- onPress={testDecryptMessage}
960
- disabled={loading || !isServiceBound}
961
- >
962
- <Text style={styles.testButtonText}>解密消息</Text>
963
- </TouchableOpacity>
964
-
965
- <TouchableOpacity
966
- style={[styles.testButton, styles.primaryButton]}
967
- onPress={testDownloadEphemeris}
968
- disabled={loading || !isServiceBound}
969
- >
970
- <Text style={styles.testButtonText}>下载星历</Text>
971
- </TouchableOpacity>
972
- </View>
973
- </View>
974
-
975
- {/* 测试结果区域 */}
976
- <View style={styles.resultsSection}>
977
- <View style={styles.resultsHeader}>
978
- <Text style={styles.sectionTitle}>测试结果</Text>
979
- <TouchableOpacity onPress={clearResults} style={styles.clearButton}>
980
- <Text style={styles.clearButtonText}>清空</Text>
981
- </TouchableOpacity>
982
- </View>
983
-
984
- {testResults.map((result, index) => (
985
- <View key={index} style={[styles.resultItem, result.success ? styles.successResult : styles.errorResult]}>
986
- <View style={styles.resultHeader}>
987
- <Text style={styles.resultMethod}>{result.method}</Text>
988
- <Text style={styles.resultTime}>
989
- {result.timestamp.toLocaleTimeString()}
990
- </Text>
991
- </View>
992
-
993
- {result.success ? (
994
- <Text style={styles.resultText}>
995
- ✅ {typeof result.result === 'object' ? JSON.stringify(result.result, null, 2) : String(result.result)}
996
- </Text>
997
- ) : (
998
- <Text style={styles.errorText}>
999
- ❌ {result.error}
1000
- </Text>
1001
- )}
1002
- </View>
1003
- ))}
1004
-
1005
- {testResults.length === 0 && (
1006
- <Text style={styles.noResults}>暂无测试结果</Text>
1007
- )}
1008
- </View>
1009
- </ScrollView>
1010
- </SafeAreaView>
1011
- );
1012
- };
1013
-
1014
- const styles = StyleSheet.create({
1015
- container: {
1016
- flex: 1,
1017
- backgroundColor: '#f5f5f5',
1018
- },
1019
- scrollView: {
1020
- flex: 1,
1021
- },
1022
- contentContainer: {
1023
- padding: 16,
1024
- },
1025
- title: {
1026
- fontSize: 24,
1027
- fontWeight: 'bold',
1028
- textAlign: 'center',
1029
- marginBottom: 20,
1030
- color: '#333',
1031
- },
1032
- statusContainer: {
1033
- flexDirection: 'row',
1034
- justifyContent: 'center',
1035
- alignItems: 'center',
1036
- marginBottom: 20,
1037
- },
1038
- statusText: {
1039
- fontSize: 16,
1040
- marginRight: 10,
1041
- color: '#666',
1042
- },
1043
- buttonGroup: {
1044
- flexDirection: 'row',
1045
- justifyContent: 'space-around',
1046
- marginBottom: 24,
1047
- },
1048
- button: {
1049
- paddingHorizontal: 20,
1050
- paddingVertical: 12,
1051
- borderRadius: 8,
1052
- minWidth: 100,
1053
- alignItems: 'center',
1054
- },
1055
- primaryButton: {
1056
- backgroundColor: '#007AFF',
1057
- },
1058
- secondaryButton: {
1059
- backgroundColor: '#FF3B30',
1060
- },
1061
- buttonText: {
1062
- color: '#fff',
1063
- fontSize: 16,
1064
- fontWeight: '600',
1065
- },
1066
- inputSection: {
1067
- backgroundColor: '#fff',
1068
- borderRadius: 12,
1069
- padding: 16,
1070
- marginBottom: 20,
1071
- },
1072
- sectionTitle: {
1073
- fontSize: 18,
1074
- fontWeight: 'bold',
1075
- marginBottom: 16,
1076
- color: '#333',
1077
- },
1078
- inputGroup: {
1079
- marginBottom: 16,
1080
- },
1081
- inputLabel: {
1082
- fontSize: 14,
1083
- fontWeight: '500',
1084
- marginBottom: 8,
1085
- color: '#666',
1086
- },
1087
- textInput: {
1088
- borderWidth: 1,
1089
- borderColor: '#ddd',
1090
- borderRadius: 8,
1091
- paddingHorizontal: 12,
1092
- paddingVertical: 10,
1093
- fontSize: 16,
1094
- backgroundColor: '#fff',
1095
- },
1096
- row: {
1097
- flexDirection: 'row',
1098
- justifyContent: 'space-between',
1099
- marginBottom: 16,
1100
- },
1101
- halfInput: {
1102
- flex: 1,
1103
- marginHorizontal: 4,
1104
- },
1105
- testSection: {
1106
- backgroundColor: '#fff',
1107
- borderRadius: 12,
1108
- padding: 16,
1109
- marginBottom: 20,
1110
- },
1111
- buttonGrid: {
1112
- flexDirection: 'row',
1113
- flexWrap: 'wrap',
1114
- justifyContent: 'space-between',
1115
- marginTop: 16,
1116
- },
1117
- testButton: {
1118
- width: '48%',
1119
- marginBottom: 12,
1120
- paddingVertical: 12,
1121
- borderRadius: 8,
1122
- alignItems: 'center',
1123
- },
1124
- testButtonText: {
1125
- color: '#fff',
1126
- fontSize: 14,
1127
- fontWeight: '600',
1128
- },
1129
- resultsSection: {
1130
- backgroundColor: '#fff',
1131
- borderRadius: 12,
1132
- padding: 16,
1133
- },
1134
- resultsHeader: {
1135
- flexDirection: 'row',
1136
- justifyContent: 'space-between',
1137
- alignItems: 'center',
1138
- marginBottom: 16,
1139
- },
1140
- clearButton: {
1141
- paddingHorizontal: 12,
1142
- paddingVertical: 6,
1143
- backgroundColor: '#FF3B30',
1144
- borderRadius: 6,
1145
- },
1146
- clearButtonText: {
1147
- color: '#fff',
1148
- fontSize: 12,
1149
- fontWeight: '600',
1150
- },
1151
- resultItem: {
1152
- padding: 12,
1153
- marginBottom: 8,
1154
- borderRadius: 8,
1155
- borderWidth: 1,
1156
- },
1157
- successResult: {
1158
- backgroundColor: '#f0fff4',
1159
- borderColor: '#68d391',
1160
- },
1161
- errorResult: {
1162
- backgroundColor: '#fff5f5',
1163
- borderColor: '#fc8181',
1164
- },
1165
- resultHeader: {
1166
- flexDirection: 'row',
1167
- justifyContent: 'space-between',
1168
- marginBottom: 8,
1169
- },
1170
- resultMethod: {
1171
- fontSize: 14,
1172
- fontWeight: 'bold',
1173
- color: '#333',
1174
- },
1175
- resultTime: {
1176
- fontSize: 12,
1177
- color: '#666',
1178
- },
1179
- resultText: {
1180
- fontSize: 12,
1181
- color: '#2d3748',
1182
- fontFamily: 'monospace',
1183
- },
1184
- errorText: {
1185
- fontSize: 12,
1186
- color: '#e53e3e',
1187
- },
1188
- noResults: {
1189
- textAlign: 'center',
1190
- color: '#999',
1191
- fontStyle: 'italic',
1192
- paddingVertical: 20,
1193
- },
1194
- });
1195
-
1196
- export default BeiDouAIDLTestPage;