react-native-beidou 1.0.8 → 1.1.2

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 (26) hide show
  1. package/BeiDouAIDLTestPage.tsx +505 -19
  2. package/LogManager.ts +4 -0
  3. package/README.md +108 -63
  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 +2 -2
  8. package/android/.idea/caches/deviceStreaming.xml +993 -0
  9. package/android/build.gradle +9 -9
  10. package/android/src/main/AndroidManifest.xml +2 -0
  11. package/android/src/main/java/com/fxzs.rnbeidou/BeiDouBluetoothModule.java +195 -217
  12. package/android/src/main/java/com/fxzs.rnbeidou/BeidouAidlHelper.java +643 -0
  13. package/index.ts +223 -89
  14. package/ios/BeiDouBluetoothModule.m +26 -1
  15. package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
  16. package/ios/BeidouBluetooth.framework/FMDB.bundle/Info.plist +0 -0
  17. package/ios/BeidouBluetooth.framework/FMDB.bundle/PrivacyInfo.xcprivacy +14 -0
  18. package/ios/BeidouBluetooth.framework/Headers/BDTLocationService.h +24 -0
  19. package/ios/BeidouBluetooth.framework/Headers/BeidouBluetooth.h +3 -1
  20. package/ios/BeidouBluetooth.framework/Info.plist +0 -0
  21. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
  22. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
  23. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +49 -4
  24. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
  25. package/package.json +2 -1
  26. package/react-native-beidou.podspec +26 -0
@@ -46,14 +46,14 @@ repositories {
46
46
  google()
47
47
  mavenCentral()
48
48
  maven { url 'https://www.jitpack.io' }
49
- maven {
50
- url "http://10.18.1.5:8081/repository/maven-releases/"
51
- allowInsecureProtocol = true // 如果私服是HTTP而非HTTPS,需要此配置
52
- credentials {
53
- username = "admin" // 如果需要认证
54
- password = "ZTUz-Yjg0OGRm"
55
- }
56
- }
49
+ // maven {
50
+ // url "http://10.18.1.5:8081/repository/maven-releases/"
51
+ // allowInsecureProtocol = true
52
+ // credentials {
53
+ // username = "admin"
54
+ // password = "ZTUz-Yjg0OGRm"
55
+ // }
56
+ // }
57
57
  maven {
58
58
  url 'http://117.149.10.66:38185/repository/cmcc-android-public/'
59
59
  allowInsecureProtocol(true)
@@ -68,7 +68,7 @@ repositories {
68
68
  dependencies {
69
69
  //noinspection GradleDynamicVersion
70
70
  implementation "com.facebook.react:react-native:${_reactNativeVersion}"
71
- implementation 'com.fxzs:beidousdk:1.0.3@aar' // 关键:添加 @aar 后缀
71
+ implementation 'com.fxzs:beidousdk:1.0.7@aar'
72
72
  // Add local AAR files
73
73
  implementation fileTree(dir: "src/main/libs", include: ["*.jar", "*.aar"])
74
74
  }
@@ -2,6 +2,8 @@
2
2
  package="com.fxzs.rnbeidou">
3
3
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
4
4
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
5
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
6
+ <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
5
7
  <!-- Android 10+ 建議聲明後台定位,如不需要可去除 -->
6
8
  <!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> -->
7
9
  </manifest>
@@ -13,6 +13,9 @@ import android.os.Build;
13
13
  import android.util.Log;
14
14
  import android.location.Location;
15
15
  import android.location.LocationManager;
16
+ import android.telephony.SubscriptionInfo;
17
+ import android.telephony.SubscriptionManager;
18
+ import android.telephony.TelephonyManager;
16
19
 
17
20
  import androidx.annotation.NonNull;
18
21
  import androidx.annotation.Nullable;
@@ -31,7 +34,10 @@ import com.facebook.react.bridge.ReactContext;
31
34
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
32
35
  import com.facebook.react.bridge.ReactMethod;
33
36
  import com.facebook.react.bridge.WritableMap;
37
+ import com.facebook.react.bridge.ReadableArray;
38
+ import com.facebook.react.bridge.WritableArray;
34
39
  import com.facebook.react.bridge.WritableNativeMap;
40
+ import com.facebook.react.bridge.WritableNativeArray;
35
41
  import com.facebook.react.modules.core.DeviceEventManagerModule;
36
42
 
37
43
  import org.json.JSONException;
@@ -40,30 +46,15 @@ import java.util.Arrays;
40
46
  import java.util.Base64;
41
47
  import java.util.Map;
42
48
  import java.util.Objects;
43
- import java.util.List;
44
49
  import java.util.ArrayList;
45
-
46
- // 北斗AIDL服务相关导入
47
- import com.satnav.beidouservice.IBeidouMsgAidlInterface;
48
- import com.satnav.beidouservice.BDStatusResponse;
49
- import com.satnav.beidouservice.BDMsgEncryptResponse;
50
- import com.satnav.beidouservice.BDMsgDecryptResponse;
51
- import com.satnav.beidouservice.BDMsgEphemerisFileDLResponse;
52
- import android.content.ServiceConnection;
53
- import android.content.ComponentName;
54
- import android.content.Intent;
55
- import android.os.IBinder;
56
- import com.facebook.react.bridge.ReadableArray;
57
- import com.facebook.react.bridge.WritableArray;
58
- import com.facebook.react.bridge.WritableNativeArray;
50
+ import java.util.List;
59
51
 
60
52
  public class BeiDouBluetoothModule extends ReactContextBaseJavaModule {
61
53
  private ReactContext reactContext;
62
54
  private LogManager logger;
63
55
 
64
- // 北斗AIDL服务相关字段
65
- private IBeidouMsgAidlInterface beidouService;
66
- private boolean isBeidouServiceBound = false;
56
+ // 北斗AIDL服务辅助类
57
+ private final BeidouAidlHelper beidouAidlHelper;
67
58
 
68
59
  @NonNull
69
60
  @Override
@@ -74,6 +65,7 @@ public class BeiDouBluetoothModule extends ReactContextBaseJavaModule {
74
65
  public BeiDouBluetoothModule(@Nullable ReactApplicationContext reactContext) {
75
66
  super(reactContext);
76
67
  this.reactContext = reactContext;
68
+ this.beidouAidlHelper = new BeidouAidlHelper(reactContext);
77
69
 
78
70
  // 初始化日志管理器
79
71
  this.logger = LogManager.getInstance();
@@ -611,256 +603,242 @@ public class BeiDouBluetoothModule extends ReactContextBaseJavaModule {
611
603
  callback.invoke(wifiName);
612
604
  }
613
605
 
614
- // ================== 北斗AIDL服务相关方法 ==================
606
+ /**
607
+ * 获取当前设备的SIM卡信息列表
608
+ */
609
+ @ReactMethod
610
+ public void getSimCardList(Promise promise) {
611
+ try {
612
+ if (reactContext == null) {
613
+ promise.reject("CONTEXT_NULL", "React上下文不可用");
614
+ return;
615
+ }
615
616
 
616
- private final ServiceConnection beidouServiceConnection = new ServiceConnection() {
617
- @Override
618
- public void onServiceConnected(ComponentName name, IBinder service) {
619
- beidouService = IBeidouMsgAidlInterface.Stub.asInterface(service);
620
- isBeidouServiceBound = true;
621
- Log.d("BeiDouService", "北斗服务连接成功");
622
- }
617
+ boolean hasReadPhoneStatePermission = ContextCompat.checkSelfPermission(reactContext,
618
+ Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
623
619
 
624
- @Override
625
- public void onServiceDisconnected(ComponentName name) {
626
- beidouService = null;
627
- isBeidouServiceBound = false;
628
- Log.d("BeiDouService", "北斗服务连接断开");
629
- }
630
- };
620
+ if (!hasReadPhoneStatePermission) {
621
+ promise.reject("PERMISSION_DENIED", "缺少READ_PHONE_STATE权限");
622
+ return;
623
+ }
631
624
 
632
- private void bindBeidouService(String packageName, String actionName) {
633
- if (!isBeidouServiceBound && reactContext != null) {
634
- Intent intent = new Intent();
635
- // 使用ComponentName方式,actionName作为className
636
- intent.setComponent(new android.content.ComponentName(packageName, actionName));
637
- try {
638
- boolean result = reactContext.bindService(intent, beidouServiceConnection, Context.BIND_AUTO_CREATE);
639
- Log.d("BeiDouService", "绑定北斗服务结果: " + result + ", 包名: " + packageName + ", 类名: " + actionName);
640
- } catch (Exception e) {
641
- Log.e("BeiDouService", "绑定北斗服务失败: " + e.getMessage());
625
+ boolean hasReadPhoneNumbersPermission = true;
626
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
627
+ hasReadPhoneNumbersPermission = ContextCompat.checkSelfPermission(reactContext,
628
+ Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED;
642
629
  }
643
- }
644
- }
645
630
 
646
- private void unbindBeidouService() {
647
- if (isBeidouServiceBound && reactContext != null) {
648
- try {
649
- reactContext.unbindService(beidouServiceConnection);
650
- isBeidouServiceBound = false;
651
- Log.d("BeiDouService", "解绑北斗服务成功");
652
- } catch (Exception e) {
653
- Log.e("BeiDouService", "解绑北斗服务失败: " + e.getMessage());
631
+ WritableArray result = new WritableNativeArray();
632
+ Context context = reactContext;
633
+
634
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
635
+ SubscriptionManager subscriptionManager = (SubscriptionManager) context
636
+ .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
637
+
638
+ if (subscriptionManager != null) {
639
+ List<SubscriptionInfo> subscriptionInfoList;
640
+ try {
641
+ subscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
642
+ } catch (SecurityException permissionException) {
643
+ promise.reject("PERMISSION_DENIED", "访问SubscriptionManager失败: " + permissionException.getMessage(),
644
+ permissionException);
645
+ return;
646
+ }
647
+
648
+ if (subscriptionInfoList != null) {
649
+ for (SubscriptionInfo info : subscriptionInfoList) {
650
+ WritableMap map = new WritableNativeMap();
651
+ CharSequence carrierName = info.getCarrierName();
652
+ CharSequence displayName = info.getDisplayName();
653
+
654
+ map.putInt("subscriptionId", info.getSubscriptionId());
655
+ map.putInt("simSlotIndex", info.getSimSlotIndex());
656
+ map.putString("carrierName", carrierName != null ? carrierName.toString() : null);
657
+ map.putString("displayName", displayName != null ? displayName.toString() : null);
658
+ map.putString("countryIso", info.getCountryIso());
659
+ map.putInt("mcc", info.getMcc());
660
+ map.putInt("mnc", info.getMnc());
661
+
662
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
663
+ map.putBoolean("isEmbedded", info.isEmbedded());
664
+ map.putBoolean("isOpportunistic", info.isOpportunistic());
665
+ } else {
666
+ map.putBoolean("isEmbedded", false);
667
+ map.putBoolean("isOpportunistic", false);
668
+ }
669
+
670
+ if (hasReadPhoneNumbersPermission) {
671
+ String phoneNumber;
672
+ try {
673
+ phoneNumber = info.getNumber();
674
+ } catch (SecurityException numberException) {
675
+ phoneNumber = null;
676
+ }
677
+ map.putString("number", phoneNumber);
678
+ } else {
679
+ map.putNull("number");
680
+ }
681
+
682
+ result.pushMap(map);
683
+ }
684
+ }
685
+ }
654
686
  }
655
- }
656
- }
657
687
 
658
- // 将byte数组转换为WritableArray
659
- private WritableArray byteArrayToWritableArray(byte[] byteArray) {
660
- WritableArray array = new WritableNativeArray();
661
- if (byteArray != null) {
662
- for (byte b : byteArray) {
663
- array.pushInt(b & 0xFF); // 将byte转换为无符号int
688
+ // 如果未获取到任何SIM卡信息,尝试使用TelephonyManager做兼容
689
+ if (result.size() == 0) {
690
+ TelephonyManager telephonyManager = (TelephonyManager) context
691
+ .getSystemService(Context.TELEPHONY_SERVICE);
692
+
693
+ if (telephonyManager != null) {
694
+ WritableMap map = new WritableNativeMap();
695
+ map.putInt("subscriptionId", -1);
696
+ map.putInt("simSlotIndex", 0);
697
+ map.putString("carrierName", telephonyManager.getSimOperatorName());
698
+ map.putString("displayName", telephonyManager.getSimOperatorName());
699
+ map.putString("countryIso", telephonyManager.getSimCountryIso());
700
+
701
+ String operator = telephonyManager.getSimOperator();
702
+ if (operator != null && operator.length() >= 5) {
703
+ try {
704
+ int mcc = Integer.parseInt(operator.substring(0, 3));
705
+ int mnc = Integer.parseInt(operator.substring(3));
706
+ map.putInt("mcc", mcc);
707
+ map.putInt("mnc", mnc);
708
+ } catch (NumberFormatException ignored) {
709
+ map.putInt("mcc", -1);
710
+ map.putInt("mnc", -1);
711
+ }
712
+ } else {
713
+ map.putInt("mcc", -1);
714
+ map.putInt("mnc", -1);
715
+ }
716
+
717
+ map.putBoolean("isEmbedded", false);
718
+ map.putBoolean("isOpportunistic", false);
719
+
720
+ if (hasReadPhoneNumbersPermission) {
721
+ String phoneNumber;
722
+ try {
723
+ phoneNumber = telephonyManager.getLine1Number();
724
+ } catch (SecurityException numberException) {
725
+ phoneNumber = null;
726
+ }
727
+ map.putString("number", phoneNumber);
728
+ } else {
729
+ map.putNull("number");
730
+ }
731
+
732
+ result.pushMap(map);
733
+ }
664
734
  }
665
- }
666
- return array;
667
- }
668
735
 
669
- // 将ReadableArray转换为List<String>
670
- private List<String> readableArrayToStringList(ReadableArray readableArray) {
671
- List<String> list = new ArrayList<>();
672
- for (int i = 0; i < readableArray.size(); i++) {
673
- list.add(readableArray.getString(i));
736
+ promise.resolve(result);
737
+ } catch (SecurityException permissionException) {
738
+ promise.reject("PERMISSION_DENIED", "获取SIM卡信息权限被拒绝: " + permissionException.getMessage(),
739
+ permissionException);
740
+ } catch (Exception e) {
741
+ logger.e("BeiDouBluetoothModule", "获取SIM卡信息失败: " + e.getMessage(), e);
742
+ promise.reject("SIM_INFO_ERROR", "获取SIM卡信息失败: " + e.getMessage(), e);
674
743
  }
675
- return list;
676
744
  }
677
745
 
678
- // 将ReadableArray转换为byte数组
679
- private byte[] readableArrayToByteArray(ReadableArray readableArray) {
680
- byte[] bytes = new byte[readableArray.size()];
681
- for (int i = 0; i < readableArray.size(); i++) {
682
- bytes[i] = (byte) readableArray.getInt(i);
683
- }
684
- return bytes;
685
- }
746
+ // ================== 北斗AIDL服务相关方法 ==================
686
747
 
687
748
  @ReactMethod
688
749
  public void bindBeidouServiceMethod(String packageName, String actionName, Promise promise) {
689
- try {
690
- bindBeidouService(packageName, actionName);
691
- promise.resolve(true);
692
- } catch (Exception e) {
693
- promise.reject("BIND_ERROR", "绑定北斗服务失败: " + e.getMessage());
694
- }
750
+ beidouAidlHelper.bindService(packageName, actionName, promise);
695
751
  }
696
752
 
697
753
  @ReactMethod
698
754
  public void unbindBeidouServiceMethod(Promise promise) {
699
- try {
700
- unbindBeidouService();
701
- promise.resolve(true);
702
- } catch (Exception e) {
703
- promise.reject("UNBIND_ERROR", "解绑北斗服务失败: " + e.getMessage());
704
- }
755
+ beidouAidlHelper.unbindService(promise);
705
756
  }
706
757
 
707
758
  @ReactMethod
708
- public void BDAuthenticate(Promise promise) {
709
- if (!isBeidouServiceBound || beidouService == null) {
710
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
711
- return;
712
- }
713
-
714
- try {
715
- boolean result = beidouService.BDAuthenticate();
716
- promise.resolve(result);
717
- } catch (Exception e) {
718
- promise.reject("REMOTE_ERROR", "北斗鉴权失败: " + e.getMessage());
719
- }
759
+ public void BDAuthenticate(int slotId, Promise promise) {
760
+ beidouAidlHelper.authenticate(slotId, promise);
720
761
  }
721
762
 
722
763
  @ReactMethod
723
- public void getBDMsgStatus(Promise promise) {
724
- if (!isBeidouServiceBound || beidouService == null) {
725
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
726
- return;
727
- }
728
-
729
- try {
730
- BDStatusResponse response = beidouService.getBDMsgStatus();
731
- WritableMap map = new WritableNativeMap();
732
- map.putInt("code", response.code);
733
- map.putString("statusMsg", response.statusMsg);
734
- map.putInt("msgQuotaRemain", response.msgQuotaRemain);
735
- promise.resolve(map);
736
- } catch (Exception e) {
737
- promise.reject("REMOTE_ERROR", "获取北斗状态失败: " + e.getMessage());
738
- }
764
+ public void getBDMsgStatus(int slotId, Promise promise) {
765
+ beidouAidlHelper.getStatus(slotId, promise);
739
766
  }
740
767
 
741
768
  @ReactMethod
742
- public void checkValidatedKey(Promise promise) {
743
- if (!isBeidouServiceBound || beidouService == null) {
744
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
745
- return;
746
- }
747
-
748
- try {
749
- int result = beidouService.checkValidatedKey();
750
- promise.resolve(result);
751
- } catch (Exception e) {
752
- promise.reject("REMOTE_ERROR", "检查北斗密钥失败: " + e.getMessage());
753
- }
769
+ public void checkValidatedKey(int slotId, Promise promise) {
770
+ beidouAidlHelper.checkValidatedKey(slotId, promise);
754
771
  }
755
772
 
756
773
  @ReactMethod
757
- public void commonBDMsgEncrypt(ReadableArray receiveList, String inputMsg, Promise promise) {
758
- if (!isBeidouServiceBound || beidouService == null) {
759
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
760
- return;
761
- }
762
-
763
- try {
764
- List<String> receiveStringList = readableArrayToStringList(receiveList);
765
- BDMsgEncryptResponse response = beidouService.commonBDMsgEncrypt(receiveStringList, inputMsg);
774
+ public void commonBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String inputMsg,
775
+ Promise promise) {
776
+ beidouAidlHelper.commonBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, promise);
777
+ }
766
778
 
767
- WritableMap map = new WritableNativeMap();
768
- map.putInt("code", response.code);
769
- map.putString("statusMsg", response.statusMsg);
770
- map.putArray("data", byteArrayToWritableArray(response.data));
771
- map.putString("sendMobile", response.sendMobile);
772
- promise.resolve(map);
773
- } catch (Exception e) {
774
- promise.reject("REMOTE_ERROR", "通用报文加密失败: " + e.getMessage());
775
- }
779
+ @ReactMethod
780
+ public void positionBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String inputMsg,
781
+ double longitude, double latitude, Promise promise) {
782
+ beidouAidlHelper.positionBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, longitude, latitude, promise);
776
783
  }
777
784
 
778
785
  @ReactMethod
779
- public void positionBDMsgEncrypt(ReadableArray receiveList, String inputMsg, double longitude, double latitude,
786
+ public void commonEmergencyBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String inputMsg,
780
787
  Promise promise) {
781
- if (!isBeidouServiceBound || beidouService == null) {
782
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
783
- return;
784
- }
785
-
786
- try {
787
- List<String> receiveStringList = readableArrayToStringList(receiveList);
788
- BDMsgEncryptResponse response = beidouService.positionBDMsgEncrypt(receiveStringList, inputMsg, longitude,
789
- latitude);
790
-
791
- WritableMap map = new WritableNativeMap();
792
- map.putInt("code", response.code);
793
- map.putString("statusMsg", response.statusMsg);
794
- map.putArray("data", byteArrayToWritableArray(response.data));
795
- map.putString("sendMobile", response.sendMobile);
796
- promise.resolve(map);
797
- } catch (Exception e) {
798
- promise.reject("REMOTE_ERROR", "位置报文加密失败: " + e.getMessage());
799
- }
788
+ beidouAidlHelper.commonEmergencyBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, promise);
800
789
  }
801
790
 
802
791
  @ReactMethod
803
- public void BDMailboxQueryEncrypt(Promise promise) {
804
- if (!isBeidouServiceBound || beidouService == null) {
805
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
806
- return;
807
- }
792
+ public void positionEmergencyBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String inputMsg,
793
+ double longitude, double latitude, Promise promise) {
794
+ beidouAidlHelper.positionEmergencyBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, longitude, latitude, promise);
795
+ }
808
796
 
809
- try {
810
- BDMsgEncryptResponse response = beidouService.BDMailboxQueryEncrypt();
797
+ @ReactMethod
798
+ public void commonRichMediaBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String msgType,
799
+ @Nullable ReadableArray inputRichMediaData, Promise promise) {
800
+ beidouAidlHelper.commonRichMediaBDMsgEncrypt(slotId, speedType, receiveList, msgType, inputRichMediaData, promise);
801
+ }
811
802
 
812
- WritableMap map = new WritableNativeMap();
813
- map.putInt("code", response.code);
814
- map.putString("statusMsg", response.statusMsg);
815
- map.putArray("data", byteArrayToWritableArray(response.data));
816
- map.putString("sendMobile", response.sendMobile);
817
- promise.resolve(map);
818
- } catch (Exception e) {
819
- promise.reject("REMOTE_ERROR", "信箱查询加密失败: " + e.getMessage());
820
- }
803
+ @ReactMethod
804
+ public void positionRichMediaBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String msgType,
805
+ @Nullable ReadableArray inputRichMediaData, double longitude, double latitude, Promise promise) {
806
+ beidouAidlHelper.positionRichMediaBDMsgEncrypt(slotId, speedType, receiveList, msgType, inputRichMediaData, longitude,
807
+ latitude, promise);
821
808
  }
822
809
 
823
810
  @ReactMethod
824
- public void BDMsgDecrypt(ReadableArray msg, int len, Promise promise) {
825
- if (!isBeidouServiceBound || beidouService == null) {
826
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
827
- return;
828
- }
811
+ public void commonRichMediaAndTextBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String text,
812
+ String msgType, @Nullable ReadableArray inputRichMediaData, Promise promise) {
813
+ beidouAidlHelper.commonRichMediaAndTextBDMsgEncrypt(slotId, speedType, receiveList, text, msgType, inputRichMediaData,
814
+ promise);
815
+ }
829
816
 
830
- try {
831
- byte[] msgBytes = readableArrayToByteArray(msg);
832
- BDMsgDecryptResponse response = beidouService.BDMsgDecrypt(msgBytes, len);
817
+ @ReactMethod
818
+ public void positionRichMediaAndTextBDMsgEncrypt(int slotId, String speedType, @Nullable ReadableArray receiveList, String text,
819
+ String msgType, @Nullable ReadableArray inputRichMediaData, double longitude, double latitude, Promise promise) {
820
+ beidouAidlHelper.positionRichMediaAndTextBDMsgEncrypt(slotId, speedType, receiveList, text, msgType, inputRichMediaData,
821
+ longitude, latitude, promise);
822
+ }
833
823
 
834
- WritableMap map = new WritableNativeMap();
835
- map.putInt("statusMsg", response.statusMsg);
836
- map.putInt("isRemainMsg", response.isRemainMsg);
837
- map.putString("rcvMobile", response.rcvMobile);
838
- map.putString("data", response.data);
839
- promise.resolve(map);
840
- } catch (Exception e) {
841
- promise.reject("REMOTE_ERROR", "报文解密失败: " + e.getMessage());
842
- }
824
+ @ReactMethod
825
+ public void BDMailboxQueryEncrypt(int slotId, Promise promise) {
826
+ beidouAidlHelper.mailboxQueryEncrypt(slotId, promise);
843
827
  }
844
828
 
845
829
  @ReactMethod
846
- public void DLEphemerisFile(String type, String version, Promise promise) {
847
- if (!isBeidouServiceBound || beidouService == null) {
848
- promise.reject("SERVICE_NOT_BOUND", "北斗服务未绑定,请先调用bindBeidouServiceMethod");
849
- return;
850
- }
830
+ public void EmergencyBDMailboxQueryEncrypt(int slotId, String replyMobile, Promise promise) {
831
+ beidouAidlHelper.emergencyMailboxQueryEncrypt(slotId, replyMobile, promise);
832
+ }
851
833
 
852
- try {
853
- BDMsgEphemerisFileDLResponse response = beidouService.DLEphemerisFile(type, version);
834
+ @ReactMethod
835
+ public void BDMsgDecrypt(int slotId, @Nullable ReadableArray msg, int len, Promise promise) {
836
+ beidouAidlHelper.decryptMessage(slotId, msg, len, promise);
837
+ }
854
838
 
855
- WritableMap map = new WritableNativeMap();
856
- map.putInt("code", response.code);
857
- map.putString("statusMsg", response.statusMsg);
858
- map.putArray("ephemerisZipFile", byteArrayToWritableArray(response.ephemerisZipFile));
859
- map.putString("version", response.version);
860
- promise.resolve(map);
861
- } catch (Exception e) {
862
- promise.reject("REMOTE_ERROR", "下载星历文件失败: " + e.getMessage());
863
- }
839
+ @ReactMethod
840
+ public void DLEphemerisFile(int slotId, String type, String version, Promise promise) {
841
+ beidouAidlHelper.downloadEphemerisFile(slotId, type, version, promise);
864
842
  }
865
843
 
866
844
  // 设置BLE密钥