@onekeyfe/react-native-device-utils 3.0.19 → 3.0.20

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 (25) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/consumer-rules.pro +10 -0
  3. package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +102 -0
  4. package/ios/ReactNativeDeviceUtils.swift +24 -0
  5. package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +4 -0
  6. package/nitrogen/generated/android/c++/JAndroidChannel.hpp +65 -0
  7. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +18 -0
  8. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +2 -0
  9. package/nitrogen/generated/android/c++/JInstallerPackageName.hpp +71 -0
  10. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/AndroidChannel.kt +23 -0
  11. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +8 -0
  12. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/InstallerPackageName.kt +25 -0
  13. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +24 -0
  14. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +6 -0
  15. package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +22 -0
  16. package/nitrogen/generated/ios/swift/AndroidChannel.swift +48 -0
  17. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +2 -0
  18. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +24 -0
  19. package/nitrogen/generated/ios/swift/InstallerPackageName.swift +56 -0
  20. package/nitrogen/generated/shared/c++/AndroidChannel.hpp +84 -0
  21. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +2 -0
  22. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +8 -0
  23. package/nitrogen/generated/shared/c++/InstallerPackageName.hpp +92 -0
  24. package/package.json +1 -1
  25. package/src/ReactNativeDeviceUtils.nitro.ts +18 -0
@@ -39,6 +39,8 @@ android {
39
39
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
40
40
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
41
41
 
42
+ consumerProguardFiles 'consumer-rules.pro'
43
+
42
44
  externalNativeBuild {
43
45
  cmake {
44
46
  cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
@@ -0,0 +1,10 @@
1
+ # Keep host app's BuildConfig class name AND its ANDROID_CHANNEL field so
2
+ # getAndroidChannel() can read it via `Class.forName(...).getField("ANDROID_CHANNEL")`
3
+ # when R8/Proguard is enabled in the consumer app.
4
+ #
5
+ # `-keep class` (not `-keepclassmembers`) is required because the class is
6
+ # only referenced as a string literal in reflection, so R8 cannot detect the
7
+ # usage and would otherwise rename/strip the class entirely.
8
+ -keep class **.BuildConfig {
9
+ public static final java.lang.String ANDROID_CHANNEL;
10
+ }
@@ -1027,4 +1027,106 @@ class ReactNativeDeviceUtils : HybridReactNativeDeviceUtilsSpec(), LifecycleEven
1027
1027
  }
1028
1028
  return Promise.resolved(action)
1029
1029
  }
1030
+
1031
+ // MARK: - Android Channel & Installer
1032
+
1033
+ override fun getAndroidChannel(): AndroidChannel {
1034
+ return try {
1035
+ val context = NitroModules.applicationContext
1036
+ ?: return AndroidChannel.DIRECT // Match gradle default when context unavailable
1037
+ val raw = readAndroidChannelFromBuildConfig(context)
1038
+ when (raw) {
1039
+ "direct" -> AndroidChannel.DIRECT
1040
+ "google" -> AndroidChannel.GOOGLE
1041
+ "huawei" -> AndroidChannel.HUAWEI
1042
+ null -> {
1043
+ // Reflection found no BuildConfig.ANDROID_CHANNEL — match gradle default.
1044
+ OneKeyLog.warn("DeviceUtils", "getAndroidChannel: BuildConfig.ANDROID_CHANNEL not found, defaulting to direct")
1045
+ AndroidChannel.DIRECT
1046
+ }
1047
+ else -> {
1048
+ // Read a string we don't know how to map — host has a custom channel value.
1049
+ OneKeyLog.warn("DeviceUtils", "getAndroidChannel unrecognized value: $raw")
1050
+ AndroidChannel.UNKNOWN
1051
+ }
1052
+ }
1053
+ } catch (e: Exception) {
1054
+ OneKeyLog.warn("DeviceUtils", "getAndroidChannel failed: ${e.message}")
1055
+ AndroidChannel.DIRECT // Match gradle default on unexpected errors
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * Reflect the host app's BuildConfig.ANDROID_CHANNEL. BuildConfig is generated at the
1061
+ * module `namespace` package, which is not always the runtime `applicationId`
1062
+ * (AGP's applicationIdSuffix appends to packageName; custom Application classes may live
1063
+ * in a sub-package of the namespace). Strategy:
1064
+ * 1. Try `context.packageName` as-is (matches the common case where namespace == applicationId).
1065
+ * 2. Progressively strip trailing package segments from packageName (covers any
1066
+ * applicationIdSuffix, including custom ones beyond `.debug`/`.beta`).
1067
+ * 3. Try the Application class's declared package, then walk up its parents (covers
1068
+ * cases where the Application class is in a sub-package of the namespace).
1069
+ * We pick the first candidate whose BuildConfig exposes an ANDROID_CHANNEL field.
1070
+ */
1071
+ private fun readAndroidChannelFromBuildConfig(context: Context): String? {
1072
+ val candidates = LinkedHashSet<String>()
1073
+ addPackageAndParents(candidates, context.packageName, maxParents = 2)
1074
+ context.applicationContext.javaClass.`package`?.name?.let { parentPkg ->
1075
+ addPackageAndParents(candidates, parentPkg, maxParents = 3)
1076
+ }
1077
+
1078
+ for (candidate in candidates) {
1079
+ try {
1080
+ val cls = Class.forName("$candidate.BuildConfig")
1081
+ val field = cls.getField("ANDROID_CHANNEL")
1082
+ return field.get(null) as? String
1083
+ } catch (_: ClassNotFoundException) {
1084
+ // Candidate has no BuildConfig at this package — try next
1085
+ } catch (_: NoSuchFieldException) {
1086
+ // BuildConfig exists but has no ANDROID_CHANNEL — try next
1087
+ }
1088
+ }
1089
+ return null
1090
+ }
1091
+
1092
+ /** Add the given package name and up to [maxParents] parent packages (strip trailing segments). */
1093
+ private fun addPackageAndParents(
1094
+ out: LinkedHashSet<String>,
1095
+ packageName: String,
1096
+ maxParents: Int,
1097
+ ) {
1098
+ out.add(packageName)
1099
+ var current = packageName
1100
+ for (i in 0 until maxParents) {
1101
+ val lastDot = current.lastIndexOf('.')
1102
+ if (lastDot <= 0) break
1103
+ current = current.substring(0, lastDot)
1104
+ out.add(current)
1105
+ }
1106
+ }
1107
+
1108
+ override fun getInstallerPackageName(): InstallerPackageName {
1109
+ return try {
1110
+ val context = NitroModules.applicationContext ?: return InstallerPackageName.UNKNOWN
1111
+ val packageName = context.packageName
1112
+ val pm = context.packageManager
1113
+ val installer: String? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
1114
+ pm.getInstallSourceInfo(packageName).installingPackageName
1115
+ } else {
1116
+ @Suppress("DEPRECATION")
1117
+ pm.getInstallerPackageName(packageName)
1118
+ }
1119
+ when (installer) {
1120
+ "com.android.vending" -> InstallerPackageName.PLAYSTORE
1121
+ "com.huawei.appmarket" -> InstallerPackageName.HUAWEIAPPGALLERY
1122
+ null, "" -> InstallerPackageName.UNKNOWN
1123
+ else -> InstallerPackageName.OTHER
1124
+ }
1125
+ } catch (e: PackageManager.NameNotFoundException) {
1126
+ InstallerPackageName.UNKNOWN
1127
+ } catch (e: Exception) {
1128
+ OneKeyLog.warn("DeviceUtils", "getInstallerPackageName failed: ${e.message}")
1129
+ InstallerPackageName.UNKNOWN
1130
+ }
1131
+ }
1030
1132
  }
@@ -236,4 +236,28 @@ class ReactNativeDeviceUtils: HybridReactNativeDeviceUtilsSpec {
236
236
  }
237
237
  return Promise.resolved(withResult: action)
238
238
  }
239
+
240
+ // MARK: - Android Channel & Installer
241
+
242
+ func getAndroidChannel() throws -> AndroidChannel {
243
+ // iOS has no ANDROID_CHANNEL concept; signal with `.unknown` for API parity.
244
+ return .unknown
245
+ }
246
+
247
+ func getInstallerPackageName() throws -> InstallerPackageName {
248
+ // Mirror react-native-device-info: distinguish AppStore / TestFlight / Other
249
+ // via receipt path and embedded mobileprovision. Simulator has neither.
250
+ #if targetEnvironment(simulator)
251
+ return .unknown
252
+ #else
253
+ let hasEmbeddedProvision = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil
254
+ if let receiptUrl = Bundle.main.appStoreReceiptURL {
255
+ if receiptUrl.lastPathComponent == "sandboxReceipt" {
256
+ return hasEmbeddedProvision ? .other : .testflight
257
+ }
258
+ return hasEmbeddedProvision ? .other : .appstore
259
+ }
260
+ return hasEmbeddedProvision ? .other : .unknown
261
+ #endif
262
+ }
239
263
  }
@@ -1,5 +1,7 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
2
  export type UserInterfaceStyle = 'light' | 'dark' | 'unspecified';
3
+ export type AndroidChannel = 'direct' | 'google' | 'huawei' | 'unknown';
4
+ export type InstallerPackageName = 'appStore' | 'testFlight' | 'other' | 'playStore' | 'huaweiAppGallery' | 'unknown';
3
5
  export interface DualScreenInfoRect {
4
6
  x: number;
5
7
  y: number;
@@ -46,5 +48,7 @@ export interface ReactNativeDeviceUtils extends HybridObject<{
46
48
  incrementConsecutiveBootFailCount(): void;
47
49
  setConsecutiveBootFailCount(count: number): void;
48
50
  getAndClearRecoveryAction(): Promise<string>;
51
+ getAndroidChannel(): AndroidChannel;
52
+ getInstallerPackageName(): InstallerPackageName;
49
53
  }
50
54
  //# sourceMappingURL=ReactNativeDeviceUtils.nitro.d.ts.map
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// JAndroidChannel.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "AndroidChannel.hpp"
12
+
13
+ namespace margelo::nitro::reactnativedeviceutils {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "AndroidChannel" and the the Kotlin enum "AndroidChannel".
19
+ */
20
+ struct JAndroidChannel final: public jni::JavaClass<JAndroidChannel> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/AndroidChannel;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum AndroidChannel.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ AndroidChannel toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<AndroidChannel>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JAndroidChannel> fromCpp(AndroidChannel value) {
43
+ static const auto clazz = javaClassStatic();
44
+ static const auto fieldDIRECT = clazz->getStaticField<JAndroidChannel>("DIRECT");
45
+ static const auto fieldGOOGLE = clazz->getStaticField<JAndroidChannel>("GOOGLE");
46
+ static const auto fieldHUAWEI = clazz->getStaticField<JAndroidChannel>("HUAWEI");
47
+ static const auto fieldUNKNOWN = clazz->getStaticField<JAndroidChannel>("UNKNOWN");
48
+
49
+ switch (value) {
50
+ case AndroidChannel::DIRECT:
51
+ return clazz->getStaticFieldValue(fieldDIRECT);
52
+ case AndroidChannel::GOOGLE:
53
+ return clazz->getStaticFieldValue(fieldGOOGLE);
54
+ case AndroidChannel::HUAWEI:
55
+ return clazz->getStaticFieldValue(fieldHUAWEI);
56
+ case AndroidChannel::UNKNOWN:
57
+ return clazz->getStaticFieldValue(fieldUNKNOWN);
58
+ default:
59
+ std::string stringValue = std::to_string(static_cast<int>(value));
60
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
61
+ }
62
+ }
63
+ };
64
+
65
+ } // namespace margelo::nitro::reactnativedeviceutils
@@ -15,6 +15,10 @@ namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
15
15
  namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
16
16
  // Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
17
17
  namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
18
+ // Forward declaration of `AndroidChannel` to properly resolve imports.
19
+ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
20
+ // Forward declaration of `InstallerPackageName` to properly resolve imports.
21
+ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
18
22
  // Forward declaration of `UserInterfaceStyle` to properly resolve imports.
19
23
  namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle; }
20
24
 
@@ -31,6 +35,10 @@ namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle
31
35
  #include "JWebViewPackageInfo.hpp"
32
36
  #include "GooglePlayServicesStatus.hpp"
33
37
  #include "JGooglePlayServicesStatus.hpp"
38
+ #include "AndroidChannel.hpp"
39
+ #include "JAndroidChannel.hpp"
40
+ #include "InstallerPackageName.hpp"
41
+ #include "JInstallerPackageName.hpp"
34
42
  #include <functional>
35
43
  #include "JFunc_void_bool.hpp"
36
44
  #include <NitroModules/JNICallable.hpp>
@@ -316,5 +324,15 @@ namespace margelo::nitro::reactnativedeviceutils {
316
324
  return __promise;
317
325
  }();
318
326
  }
327
+ AndroidChannel JHybridReactNativeDeviceUtilsSpec::getAndroidChannel() {
328
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JAndroidChannel>()>("getAndroidChannel");
329
+ auto __result = method(_javaPart);
330
+ return __result->toCpp();
331
+ }
332
+ InstallerPackageName JHybridReactNativeDeviceUtilsSpec::getInstallerPackageName() {
333
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JInstallerPackageName>()>("getInstallerPackageName");
334
+ auto __result = method(_javaPart);
335
+ return __result->toCpp();
336
+ }
319
337
 
320
338
  } // namespace margelo::nitro::reactnativedeviceutils
@@ -77,6 +77,8 @@ namespace margelo::nitro::reactnativedeviceutils {
77
77
  void incrementConsecutiveBootFailCount() override;
78
78
  void setConsecutiveBootFailCount(double count) override;
79
79
  std::shared_ptr<Promise<std::string>> getAndClearRecoveryAction() override;
80
+ AndroidChannel getAndroidChannel() override;
81
+ InstallerPackageName getInstallerPackageName() override;
80
82
 
81
83
  private:
82
84
  friend HybridBase;
@@ -0,0 +1,71 @@
1
+ ///
2
+ /// JInstallerPackageName.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "InstallerPackageName.hpp"
12
+
13
+ namespace margelo::nitro::reactnativedeviceutils {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "InstallerPackageName" and the the Kotlin enum "InstallerPackageName".
19
+ */
20
+ struct JInstallerPackageName final: public jni::JavaClass<JInstallerPackageName> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/InstallerPackageName;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum InstallerPackageName.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ InstallerPackageName toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<InstallerPackageName>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JInstallerPackageName> fromCpp(InstallerPackageName value) {
43
+ static const auto clazz = javaClassStatic();
44
+ static const auto fieldUNKNOWN = clazz->getStaticField<JInstallerPackageName>("UNKNOWN");
45
+ static const auto fieldAPPSTORE = clazz->getStaticField<JInstallerPackageName>("APPSTORE");
46
+ static const auto fieldTESTFLIGHT = clazz->getStaticField<JInstallerPackageName>("TESTFLIGHT");
47
+ static const auto fieldOTHER = clazz->getStaticField<JInstallerPackageName>("OTHER");
48
+ static const auto fieldPLAYSTORE = clazz->getStaticField<JInstallerPackageName>("PLAYSTORE");
49
+ static const auto fieldHUAWEIAPPGALLERY = clazz->getStaticField<JInstallerPackageName>("HUAWEIAPPGALLERY");
50
+
51
+ switch (value) {
52
+ case InstallerPackageName::UNKNOWN:
53
+ return clazz->getStaticFieldValue(fieldUNKNOWN);
54
+ case InstallerPackageName::APPSTORE:
55
+ return clazz->getStaticFieldValue(fieldAPPSTORE);
56
+ case InstallerPackageName::TESTFLIGHT:
57
+ return clazz->getStaticFieldValue(fieldTESTFLIGHT);
58
+ case InstallerPackageName::OTHER:
59
+ return clazz->getStaticFieldValue(fieldOTHER);
60
+ case InstallerPackageName::PLAYSTORE:
61
+ return clazz->getStaticFieldValue(fieldPLAYSTORE);
62
+ case InstallerPackageName::HUAWEIAPPGALLERY:
63
+ return clazz->getStaticFieldValue(fieldHUAWEIAPPGALLERY);
64
+ default:
65
+ std::string stringValue = std::to_string(static_cast<int>(value));
66
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
67
+ }
68
+ }
69
+ };
70
+
71
+ } // namespace margelo::nitro::reactnativedeviceutils
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// AndroidChannel.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativedeviceutils
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "AndroidChannel".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class AndroidChannel(@DoNotStrip @Keep val value: Int) {
19
+ DIRECT(0),
20
+ GOOGLE(1),
21
+ HUAWEI(2),
22
+ UNKNOWN(3);
23
+ }
@@ -142,6 +142,14 @@ abstract class HybridReactNativeDeviceUtilsSpec: HybridObject() {
142
142
  @DoNotStrip
143
143
  @Keep
144
144
  abstract fun getAndClearRecoveryAction(): Promise<String>
145
+
146
+ @DoNotStrip
147
+ @Keep
148
+ abstract fun getAndroidChannel(): AndroidChannel
149
+
150
+ @DoNotStrip
151
+ @Keep
152
+ abstract fun getInstallerPackageName(): InstallerPackageName
145
153
 
146
154
  private external fun initHybrid(): HybridData
147
155
 
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// InstallerPackageName.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativedeviceutils
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "InstallerPackageName".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class InstallerPackageName(@DoNotStrip @Keep val value: Int) {
19
+ UNKNOWN(0),
20
+ APPSTORE(1),
21
+ TESTFLIGHT(2),
22
+ OTHER(3),
23
+ PLAYSTORE(4),
24
+ HUAWEIAPPGALLERY(5);
25
+ }
@@ -8,12 +8,16 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `AndroidChannel` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
11
13
  // Forward declaration of `DualScreenInfoRect` to properly resolve imports.
12
14
  namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
13
15
  // Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
14
16
  namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
15
17
  // Forward declaration of `HybridReactNativeDeviceUtilsSpec` to properly resolve imports.
16
18
  namespace margelo::nitro::reactnativedeviceutils { class HybridReactNativeDeviceUtilsSpec; }
19
+ // Forward declaration of `InstallerPackageName` to properly resolve imports.
20
+ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
17
21
  // Forward declaration of `LaunchOptions` to properly resolve imports.
18
22
  namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
19
23
  // Forward declaration of `WebViewPackageInfo` to properly resolve imports.
@@ -24,9 +28,11 @@ namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
24
28
  namespace ReactNativeDeviceUtils { class HybridReactNativeDeviceUtilsSpec_cxx; }
25
29
 
26
30
  // Include C++ defined types
31
+ #include "AndroidChannel.hpp"
27
32
  #include "DualScreenInfoRect.hpp"
28
33
  #include "GooglePlayServicesStatus.hpp"
29
34
  #include "HybridReactNativeDeviceUtilsSpec.hpp"
35
+ #include "InstallerPackageName.hpp"
30
36
  #include "LaunchOptions.hpp"
31
37
  #include "WebViewPackageInfo.hpp"
32
38
  #include <NitroModules/Promise.hpp>
@@ -518,5 +524,23 @@ namespace margelo::nitro::reactnativedeviceutils::bridge::swift {
518
524
  inline Result_std__shared_ptr_Promise_GooglePlayServicesStatus___ create_Result_std__shared_ptr_Promise_GooglePlayServicesStatus___(const std::exception_ptr& error) noexcept {
519
525
  return Result<std::shared_ptr<Promise<GooglePlayServicesStatus>>>::withError(error);
520
526
  }
527
+
528
+ // pragma MARK: Result<AndroidChannel>
529
+ using Result_AndroidChannel_ = Result<AndroidChannel>;
530
+ inline Result_AndroidChannel_ create_Result_AndroidChannel_(AndroidChannel value) noexcept {
531
+ return Result<AndroidChannel>::withValue(std::move(value));
532
+ }
533
+ inline Result_AndroidChannel_ create_Result_AndroidChannel_(const std::exception_ptr& error) noexcept {
534
+ return Result<AndroidChannel>::withError(error);
535
+ }
536
+
537
+ // pragma MARK: Result<InstallerPackageName>
538
+ using Result_InstallerPackageName_ = Result<InstallerPackageName>;
539
+ inline Result_InstallerPackageName_ create_Result_InstallerPackageName_(InstallerPackageName value) noexcept {
540
+ return Result<InstallerPackageName>::withValue(std::move(value));
541
+ }
542
+ inline Result_InstallerPackageName_ create_Result_InstallerPackageName_(const std::exception_ptr& error) noexcept {
543
+ return Result<InstallerPackageName>::withError(error);
544
+ }
521
545
 
522
546
  } // namespace margelo::nitro::reactnativedeviceutils::bridge::swift
@@ -8,12 +8,16 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `AndroidChannel` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
11
13
  // Forward declaration of `DualScreenInfoRect` to properly resolve imports.
12
14
  namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
13
15
  // Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
14
16
  namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
15
17
  // Forward declaration of `HybridReactNativeDeviceUtilsSpec` to properly resolve imports.
16
18
  namespace margelo::nitro::reactnativedeviceutils { class HybridReactNativeDeviceUtilsSpec; }
19
+ // Forward declaration of `InstallerPackageName` to properly resolve imports.
20
+ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
17
21
  // Forward declaration of `LaunchOptions` to properly resolve imports.
18
22
  namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
19
23
  // Forward declaration of `UserInterfaceStyle` to properly resolve imports.
@@ -22,9 +26,11 @@ namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle
22
26
  namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
23
27
 
24
28
  // Include C++ defined types
29
+ #include "AndroidChannel.hpp"
25
30
  #include "DualScreenInfoRect.hpp"
26
31
  #include "GooglePlayServicesStatus.hpp"
27
32
  #include "HybridReactNativeDeviceUtilsSpec.hpp"
33
+ #include "InstallerPackageName.hpp"
28
34
  #include "LaunchOptions.hpp"
29
35
  #include "UserInterfaceStyle.hpp"
30
36
  #include "WebViewPackageInfo.hpp"
@@ -22,6 +22,10 @@ namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
22
22
  namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
23
23
  // Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
24
24
  namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
25
+ // Forward declaration of `AndroidChannel` to properly resolve imports.
26
+ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
27
+ // Forward declaration of `InstallerPackageName` to properly resolve imports.
28
+ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
25
29
 
26
30
  #include "DualScreenInfoRect.hpp"
27
31
  #include <vector>
@@ -33,6 +37,8 @@ namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStat
33
37
  #include <optional>
34
38
  #include "WebViewPackageInfo.hpp"
35
39
  #include "GooglePlayServicesStatus.hpp"
40
+ #include "AndroidChannel.hpp"
41
+ #include "InstallerPackageName.hpp"
36
42
 
37
43
  #include "ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp"
38
44
 
@@ -246,6 +252,22 @@ namespace margelo::nitro::reactnativedeviceutils {
246
252
  auto __value = std::move(__result.value());
247
253
  return __value;
248
254
  }
255
+ inline AndroidChannel getAndroidChannel() override {
256
+ auto __result = _swiftPart.getAndroidChannel();
257
+ if (__result.hasError()) [[unlikely]] {
258
+ std::rethrow_exception(__result.error());
259
+ }
260
+ auto __value = std::move(__result.value());
261
+ return __value;
262
+ }
263
+ inline InstallerPackageName getInstallerPackageName() override {
264
+ auto __result = _swiftPart.getInstallerPackageName();
265
+ if (__result.hasError()) [[unlikely]] {
266
+ std::rethrow_exception(__result.error());
267
+ }
268
+ auto __value = std::move(__result.value());
269
+ return __value;
270
+ }
249
271
 
250
272
  private:
251
273
  ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx _swiftPart;
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// AndroidChannel.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `AndroidChannel`, backed by a C++ enum.
10
+ */
11
+ public typealias AndroidChannel = margelo.nitro.reactnativedeviceutils.AndroidChannel
12
+
13
+ public extension AndroidChannel {
14
+ /**
15
+ * Get a AndroidChannel for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "direct":
21
+ self = .direct
22
+ case "google":
23
+ self = .google
24
+ case "huawei":
25
+ self = .huawei
26
+ case "unknown":
27
+ self = .unknown
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this AndroidChannel represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .direct:
39
+ return "direct"
40
+ case .google:
41
+ return "google"
42
+ case .huawei:
43
+ return "huawei"
44
+ case .unknown:
45
+ return "unknown"
46
+ }
47
+ }
48
+ }
@@ -37,6 +37,8 @@ public protocol HybridReactNativeDeviceUtilsSpec_protocol: HybridObject {
37
37
  func incrementConsecutiveBootFailCount() throws -> Void
38
38
  func setConsecutiveBootFailCount(count: Double) throws -> Void
39
39
  func getAndClearRecoveryAction() throws -> Promise<String>
40
+ func getAndroidChannel() throws -> AndroidChannel
41
+ func getInstallerPackageName() throws -> InstallerPackageName
40
42
  }
41
43
 
42
44
  public extension HybridReactNativeDeviceUtilsSpec_protocol {
@@ -479,4 +479,28 @@ open class HybridReactNativeDeviceUtilsSpec_cxx {
479
479
  return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
480
480
  }
481
481
  }
482
+
483
+ @inline(__always)
484
+ public final func getAndroidChannel() -> bridge.Result_AndroidChannel_ {
485
+ do {
486
+ let __result = try self.__implementation.getAndroidChannel()
487
+ let __resultCpp = __result
488
+ return bridge.create_Result_AndroidChannel_(__resultCpp)
489
+ } catch (let __error) {
490
+ let __exceptionPtr = __error.toCpp()
491
+ return bridge.create_Result_AndroidChannel_(__exceptionPtr)
492
+ }
493
+ }
494
+
495
+ @inline(__always)
496
+ public final func getInstallerPackageName() -> bridge.Result_InstallerPackageName_ {
497
+ do {
498
+ let __result = try self.__implementation.getInstallerPackageName()
499
+ let __resultCpp = __result
500
+ return bridge.create_Result_InstallerPackageName_(__resultCpp)
501
+ } catch (let __error) {
502
+ let __exceptionPtr = __error.toCpp()
503
+ return bridge.create_Result_InstallerPackageName_(__exceptionPtr)
504
+ }
505
+ }
482
506
  }
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// InstallerPackageName.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `InstallerPackageName`, backed by a C++ enum.
10
+ */
11
+ public typealias InstallerPackageName = margelo.nitro.reactnativedeviceutils.InstallerPackageName
12
+
13
+ public extension InstallerPackageName {
14
+ /**
15
+ * Get a InstallerPackageName for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "unknown":
21
+ self = .unknown
22
+ case "appStore":
23
+ self = .appstore
24
+ case "testFlight":
25
+ self = .testflight
26
+ case "other":
27
+ self = .other
28
+ case "playStore":
29
+ self = .playstore
30
+ case "huaweiAppGallery":
31
+ self = .huaweiappgallery
32
+ default:
33
+ return nil
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Get the String value this InstallerPackageName represents.
39
+ */
40
+ var stringValue: String {
41
+ switch self {
42
+ case .unknown:
43
+ return "unknown"
44
+ case .appstore:
45
+ return "appStore"
46
+ case .testflight:
47
+ return "testFlight"
48
+ case .other:
49
+ return "other"
50
+ case .playstore:
51
+ return "playStore"
52
+ case .huaweiappgallery:
53
+ return "huaweiAppGallery"
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// AndroidChannel.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::reactnativedeviceutils {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (AndroidChannel).
30
+ */
31
+ enum class AndroidChannel {
32
+ DIRECT SWIFT_NAME(direct) = 0,
33
+ GOOGLE SWIFT_NAME(google) = 1,
34
+ HUAWEI SWIFT_NAME(huawei) = 2,
35
+ UNKNOWN SWIFT_NAME(unknown) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::reactnativedeviceutils
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ AndroidChannel <> JS AndroidChannel (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::reactnativedeviceutils::AndroidChannel> final {
45
+ static inline margelo::nitro::reactnativedeviceutils::AndroidChannel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
48
+ case hashString("direct"): return margelo::nitro::reactnativedeviceutils::AndroidChannel::DIRECT;
49
+ case hashString("google"): return margelo::nitro::reactnativedeviceutils::AndroidChannel::GOOGLE;
50
+ case hashString("huawei"): return margelo::nitro::reactnativedeviceutils::AndroidChannel::HUAWEI;
51
+ case hashString("unknown"): return margelo::nitro::reactnativedeviceutils::AndroidChannel::UNKNOWN;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AndroidChannel - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativedeviceutils::AndroidChannel arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::reactnativedeviceutils::AndroidChannel::DIRECT: return JSIConverter<std::string>::toJSI(runtime, "direct");
59
+ case margelo::nitro::reactnativedeviceutils::AndroidChannel::GOOGLE: return JSIConverter<std::string>::toJSI(runtime, "google");
60
+ case margelo::nitro::reactnativedeviceutils::AndroidChannel::HUAWEI: return JSIConverter<std::string>::toJSI(runtime, "huawei");
61
+ case margelo::nitro::reactnativedeviceutils::AndroidChannel::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert AndroidChannel to JS - invalid value: "
64
+ + std::to_string(static_cast<int>(arg)) + "!");
65
+ }
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isString()) {
69
+ return false;
70
+ }
71
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
72
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
73
+ case hashString("direct"):
74
+ case hashString("google"):
75
+ case hashString("huawei"):
76
+ case hashString("unknown"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -37,6 +37,8 @@ namespace margelo::nitro::reactnativedeviceutils {
37
37
  prototype.registerHybridMethod("incrementConsecutiveBootFailCount", &HybridReactNativeDeviceUtilsSpec::incrementConsecutiveBootFailCount);
38
38
  prototype.registerHybridMethod("setConsecutiveBootFailCount", &HybridReactNativeDeviceUtilsSpec::setConsecutiveBootFailCount);
39
39
  prototype.registerHybridMethod("getAndClearRecoveryAction", &HybridReactNativeDeviceUtilsSpec::getAndClearRecoveryAction);
40
+ prototype.registerHybridMethod("getAndroidChannel", &HybridReactNativeDeviceUtilsSpec::getAndroidChannel);
41
+ prototype.registerHybridMethod("getInstallerPackageName", &HybridReactNativeDeviceUtilsSpec::getInstallerPackageName);
40
42
  });
41
43
  }
42
44
 
@@ -23,6 +23,10 @@ namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
23
23
  namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
24
24
  // Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
25
25
  namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
26
+ // Forward declaration of `AndroidChannel` to properly resolve imports.
27
+ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
28
+ // Forward declaration of `InstallerPackageName` to properly resolve imports.
29
+ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
26
30
 
27
31
  #include "DualScreenInfoRect.hpp"
28
32
  #include <vector>
@@ -33,6 +37,8 @@ namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStat
33
37
  #include <string>
34
38
  #include "WebViewPackageInfo.hpp"
35
39
  #include "GooglePlayServicesStatus.hpp"
40
+ #include "AndroidChannel.hpp"
41
+ #include "InstallerPackageName.hpp"
36
42
 
37
43
  namespace margelo::nitro::reactnativedeviceutils {
38
44
 
@@ -88,6 +94,8 @@ namespace margelo::nitro::reactnativedeviceutils {
88
94
  virtual void incrementConsecutiveBootFailCount() = 0;
89
95
  virtual void setConsecutiveBootFailCount(double count) = 0;
90
96
  virtual std::shared_ptr<Promise<std::string>> getAndClearRecoveryAction() = 0;
97
+ virtual AndroidChannel getAndroidChannel() = 0;
98
+ virtual InstallerPackageName getInstallerPackageName() = 0;
91
99
 
92
100
  protected:
93
101
  // Hybrid Setup
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// InstallerPackageName.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::reactnativedeviceutils {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (InstallerPackageName).
30
+ */
31
+ enum class InstallerPackageName {
32
+ UNKNOWN SWIFT_NAME(unknown) = 0,
33
+ APPSTORE SWIFT_NAME(appstore) = 1,
34
+ TESTFLIGHT SWIFT_NAME(testflight) = 2,
35
+ OTHER SWIFT_NAME(other) = 3,
36
+ PLAYSTORE SWIFT_NAME(playstore) = 4,
37
+ HUAWEIAPPGALLERY SWIFT_NAME(huaweiappgallery) = 5,
38
+ } CLOSED_ENUM;
39
+
40
+ } // namespace margelo::nitro::reactnativedeviceutils
41
+
42
+ namespace margelo::nitro {
43
+
44
+ // C++ InstallerPackageName <> JS InstallerPackageName (union)
45
+ template <>
46
+ struct JSIConverter<margelo::nitro::reactnativedeviceutils::InstallerPackageName> final {
47
+ static inline margelo::nitro::reactnativedeviceutils::InstallerPackageName fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
49
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
50
+ case hashString("unknown"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::UNKNOWN;
51
+ case hashString("appStore"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::APPSTORE;
52
+ case hashString("testFlight"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::TESTFLIGHT;
53
+ case hashString("other"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::OTHER;
54
+ case hashString("playStore"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::PLAYSTORE;
55
+ case hashString("huaweiAppGallery"): return margelo::nitro::reactnativedeviceutils::InstallerPackageName::HUAWEIAPPGALLERY;
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum InstallerPackageName - invalid value!");
58
+ }
59
+ }
60
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativedeviceutils::InstallerPackageName arg) {
61
+ switch (arg) {
62
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
63
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::APPSTORE: return JSIConverter<std::string>::toJSI(runtime, "appStore");
64
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::TESTFLIGHT: return JSIConverter<std::string>::toJSI(runtime, "testFlight");
65
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::OTHER: return JSIConverter<std::string>::toJSI(runtime, "other");
66
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::PLAYSTORE: return JSIConverter<std::string>::toJSI(runtime, "playStore");
67
+ case margelo::nitro::reactnativedeviceutils::InstallerPackageName::HUAWEIAPPGALLERY: return JSIConverter<std::string>::toJSI(runtime, "huaweiAppGallery");
68
+ default: [[unlikely]]
69
+ throw std::invalid_argument("Cannot convert InstallerPackageName to JS - invalid value: "
70
+ + std::to_string(static_cast<int>(arg)) + "!");
71
+ }
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isString()) {
75
+ return false;
76
+ }
77
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
78
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
79
+ case hashString("unknown"):
80
+ case hashString("appStore"):
81
+ case hashString("testFlight"):
82
+ case hashString("other"):
83
+ case hashString("playStore"):
84
+ case hashString("huaweiAppGallery"):
85
+ return true;
86
+ default:
87
+ return false;
88
+ }
89
+ }
90
+ };
91
+
92
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-device-utils",
3
- "version": "3.0.19",
3
+ "version": "3.0.20",
4
4
  "description": "react-native-device-utils",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -3,6 +3,20 @@ import type { HybridObject } from 'react-native-nitro-modules';
3
3
 
4
4
  export type UserInterfaceStyle = 'light' | 'dark' | 'unspecified';
5
5
 
6
+ export type AndroidChannel =
7
+ | 'direct'
8
+ | 'google'
9
+ | 'huawei'
10
+ | 'unknown';
11
+
12
+ export type InstallerPackageName =
13
+ | 'appStore'
14
+ | 'testFlight'
15
+ | 'other'
16
+ | 'playStore'
17
+ | 'huaweiAppGallery'
18
+ | 'unknown';
19
+
6
20
  export interface DualScreenInfoRect {
7
21
  x: number;
8
22
  y: number;
@@ -59,4 +73,8 @@ export interface ReactNativeDeviceUtils
59
73
  incrementConsecutiveBootFailCount(): void;
60
74
  setConsecutiveBootFailCount(count: number): void;
61
75
  getAndClearRecoveryAction(): Promise<string>;
76
+
77
+ // Android Channel & Installer
78
+ getAndroidChannel(): AndroidChannel;
79
+ getInstallerPackageName(): InstallerPackageName;
62
80
  }