@onekeyfe/react-native-device-utils 1.1.38 → 1.1.40

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.
@@ -39,6 +39,9 @@ class ReactNativeDeviceUtils : HybridReactNativeDeviceUtilsSpec(), LifecycleEven
39
39
  private const val PREF_KEY_FOLDABLE = "1k_fold"
40
40
  private const val PREF_KEY_UI_STYLE = "1k_user_interface_style"
41
41
  private const val PREF_KEY_DEVICE_TOKEN = "1k_device_token"
42
+ private const val RECOVERY_PREFS_NAME = "onekey_recovery"
43
+ private const val BOOT_FAIL_COUNT_KEY = "consecutive_boot_fail_count"
44
+ private const val RECOVERY_ACTION_KEY = "recovery_action"
42
45
 
43
46
  @JvmStatic
44
47
  var staticStartupTime: Long? = null
@@ -987,4 +990,41 @@ class ReactNativeDeviceUtils : HybridReactNativeDeviceUtilsSpec(), LifecycleEven
987
990
  }
988
991
  }
989
992
  }
993
+
994
+ // MARK: - Boot Recovery
995
+
996
+ private fun getRecoveryPrefs(): android.content.SharedPreferences {
997
+ val context = NitroModules.applicationContext
998
+ ?: throw Exception("Application context unavailable")
999
+ return context.getSharedPreferences(RECOVERY_PREFS_NAME, Context.MODE_PRIVATE)
1000
+ }
1001
+
1002
+ override fun markBootSuccess() {
1003
+ getRecoveryPrefs().edit().putInt(BOOT_FAIL_COUNT_KEY, 0).commit()
1004
+ }
1005
+
1006
+ override fun getConsecutiveBootFailCount(): Promise<Double> {
1007
+ return Promise.resolved(
1008
+ getRecoveryPrefs().getInt(BOOT_FAIL_COUNT_KEY, 0).toDouble()
1009
+ )
1010
+ }
1011
+
1012
+ override fun incrementConsecutiveBootFailCount() {
1013
+ val prefs = getRecoveryPrefs()
1014
+ val current = prefs.getInt(BOOT_FAIL_COUNT_KEY, 0)
1015
+ prefs.edit().putInt(BOOT_FAIL_COUNT_KEY, current + 1).commit()
1016
+ }
1017
+
1018
+ override fun setConsecutiveBootFailCount(count: Double) {
1019
+ getRecoveryPrefs().edit().putInt(BOOT_FAIL_COUNT_KEY, count.toInt()).commit()
1020
+ }
1021
+
1022
+ override fun getAndClearRecoveryAction(): Promise<String> {
1023
+ val prefs = getRecoveryPrefs()
1024
+ val action = prefs.getString(RECOVERY_ACTION_KEY, "") ?: ""
1025
+ if (action.isNotEmpty()) {
1026
+ prefs.edit().remove(RECOVERY_ACTION_KEY).commit()
1027
+ }
1028
+ return Promise.resolved(action)
1029
+ }
990
1030
  }
@@ -200,4 +200,40 @@ class ReactNativeDeviceUtils: HybridReactNativeDeviceUtilsSpec {
200
200
  isAvailable: false
201
201
  ))
202
202
  }
203
+
204
+ // MARK: - Boot Recovery
205
+
206
+ private static let bootFailCountKey = "onekey_consecutive_boot_fail_count"
207
+ private static let recoveryActionKey = "onekey_recovery_action"
208
+
209
+ func markBootSuccess() throws -> Void {
210
+ UserDefaults.standard.set(0, forKey: ReactNativeDeviceUtils.bootFailCountKey)
211
+ UserDefaults.standard.synchronize()
212
+ }
213
+
214
+ func getConsecutiveBootFailCount() throws -> Promise<Double> {
215
+ return Promise.resolved(withResult:
216
+ Double(UserDefaults.standard.integer(forKey: ReactNativeDeviceUtils.bootFailCountKey))
217
+ )
218
+ }
219
+
220
+ func incrementConsecutiveBootFailCount() throws -> Void {
221
+ let current = UserDefaults.standard.integer(forKey: ReactNativeDeviceUtils.bootFailCountKey)
222
+ UserDefaults.standard.set(current + 1, forKey: ReactNativeDeviceUtils.bootFailCountKey)
223
+ UserDefaults.standard.synchronize()
224
+ }
225
+
226
+ func setConsecutiveBootFailCount(count: Double) throws -> Void {
227
+ UserDefaults.standard.set(Int(count), forKey: ReactNativeDeviceUtils.bootFailCountKey)
228
+ UserDefaults.standard.synchronize()
229
+ }
230
+
231
+ func getAndClearRecoveryAction() throws -> Promise<String> {
232
+ let action = UserDefaults.standard.string(forKey: ReactNativeDeviceUtils.recoveryActionKey) ?? ""
233
+ if !action.isEmpty {
234
+ UserDefaults.standard.removeObject(forKey: ReactNativeDeviceUtils.recoveryActionKey)
235
+ UserDefaults.standard.synchronize()
236
+ }
237
+ return Promise.resolved(withResult: action)
238
+ }
203
239
  }
@@ -41,5 +41,10 @@ export interface ReactNativeDeviceUtils extends HybridObject<{
41
41
  exitApp(): void;
42
42
  getCurrentWebViewPackageInfo(): Promise<WebViewPackageInfo>;
43
43
  isGooglePlayServicesAvailable(): Promise<GooglePlayServicesStatus>;
44
+ markBootSuccess(): void;
45
+ getConsecutiveBootFailCount(): Promise<number>;
46
+ incrementConsecutiveBootFailCount(): void;
47
+ setConsecutiveBootFailCount(count: number): void;
48
+ getAndClearRecoveryAction(): Promise<string>;
44
49
  }
45
50
  //# sourceMappingURL=ReactNativeDeviceUtils.nitro.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeDeviceUtils.nitro.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeDeviceUtils.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO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AO,CAAC,OAAO,CAAC,CAAC;IACvC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAGlC,OAAO,IAAI,IAAI,CAAC;IAGhB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5D,6BAA6B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAGnE,eAAe,IAAI,IAAI,CAAC;IACxB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,iCAAiC,IAAI,IAAI,CAAC;IAC1C,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C"}
@@ -272,5 +272,49 @@ namespace margelo::nitro::reactnativedeviceutils {
272
272
  return __promise;
273
273
  }();
274
274
  }
275
+ void JHybridReactNativeDeviceUtilsSpec::markBootSuccess() {
276
+ static const auto method = javaClassStatic()->getMethod<void()>("markBootSuccess");
277
+ method(_javaPart);
278
+ }
279
+ std::shared_ptr<Promise<double>> JHybridReactNativeDeviceUtilsSpec::getConsecutiveBootFailCount() {
280
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConsecutiveBootFailCount");
281
+ auto __result = method(_javaPart);
282
+ return [&]() {
283
+ auto __promise = Promise<double>::create();
284
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
285
+ auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
286
+ __promise->resolve(__result->value());
287
+ });
288
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
289
+ jni::JniException __jniError(__throwable);
290
+ __promise->reject(std::make_exception_ptr(__jniError));
291
+ });
292
+ return __promise;
293
+ }();
294
+ }
295
+ void JHybridReactNativeDeviceUtilsSpec::incrementConsecutiveBootFailCount() {
296
+ static const auto method = javaClassStatic()->getMethod<void()>("incrementConsecutiveBootFailCount");
297
+ method(_javaPart);
298
+ }
299
+ void JHybridReactNativeDeviceUtilsSpec::setConsecutiveBootFailCount(double count) {
300
+ static const auto method = javaClassStatic()->getMethod<void(double /* count */)>("setConsecutiveBootFailCount");
301
+ method(_javaPart, count);
302
+ }
303
+ std::shared_ptr<Promise<std::string>> JHybridReactNativeDeviceUtilsSpec::getAndClearRecoveryAction() {
304
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAndClearRecoveryAction");
305
+ auto __result = method(_javaPart);
306
+ return [&]() {
307
+ auto __promise = Promise<std::string>::create();
308
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
309
+ auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
310
+ __promise->resolve(__result->toStdString());
311
+ });
312
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
313
+ jni::JniException __jniError(__throwable);
314
+ __promise->reject(std::make_exception_ptr(__jniError));
315
+ });
316
+ return __promise;
317
+ }();
318
+ }
275
319
 
276
320
  } // namespace margelo::nitro::reactnativedeviceutils
@@ -72,6 +72,11 @@ namespace margelo::nitro::reactnativedeviceutils {
72
72
  void exitApp() override;
73
73
  std::shared_ptr<Promise<WebViewPackageInfo>> getCurrentWebViewPackageInfo() override;
74
74
  std::shared_ptr<Promise<GooglePlayServicesStatus>> isGooglePlayServicesAvailable() override;
75
+ void markBootSuccess() override;
76
+ std::shared_ptr<Promise<double>> getConsecutiveBootFailCount() override;
77
+ void incrementConsecutiveBootFailCount() override;
78
+ void setConsecutiveBootFailCount(double count) override;
79
+ std::shared_ptr<Promise<std::string>> getAndClearRecoveryAction() override;
75
80
 
76
81
  private:
77
82
  friend HybridBase;
@@ -122,6 +122,26 @@ abstract class HybridReactNativeDeviceUtilsSpec: HybridObject() {
122
122
  @DoNotStrip
123
123
  @Keep
124
124
  abstract fun isGooglePlayServicesAvailable(): Promise<GooglePlayServicesStatus>
125
+
126
+ @DoNotStrip
127
+ @Keep
128
+ abstract fun markBootSuccess(): Unit
129
+
130
+ @DoNotStrip
131
+ @Keep
132
+ abstract fun getConsecutiveBootFailCount(): Promise<Double>
133
+
134
+ @DoNotStrip
135
+ @Keep
136
+ abstract fun incrementConsecutiveBootFailCount(): Unit
137
+
138
+ @DoNotStrip
139
+ @Keep
140
+ abstract fun setConsecutiveBootFailCount(count: Double): Unit
141
+
142
+ @DoNotStrip
143
+ @Keep
144
+ abstract fun getAndClearRecoveryAction(): Promise<String>
125
145
 
126
146
  private external fun initHybrid(): HybridData
127
147
 
@@ -212,6 +212,40 @@ namespace margelo::nitro::reactnativedeviceutils {
212
212
  auto __value = std::move(__result.value());
213
213
  return __value;
214
214
  }
215
+ inline void markBootSuccess() override {
216
+ auto __result = _swiftPart.markBootSuccess();
217
+ if (__result.hasError()) [[unlikely]] {
218
+ std::rethrow_exception(__result.error());
219
+ }
220
+ }
221
+ inline std::shared_ptr<Promise<double>> getConsecutiveBootFailCount() override {
222
+ auto __result = _swiftPart.getConsecutiveBootFailCount();
223
+ if (__result.hasError()) [[unlikely]] {
224
+ std::rethrow_exception(__result.error());
225
+ }
226
+ auto __value = std::move(__result.value());
227
+ return __value;
228
+ }
229
+ inline void incrementConsecutiveBootFailCount() override {
230
+ auto __result = _swiftPart.incrementConsecutiveBootFailCount();
231
+ if (__result.hasError()) [[unlikely]] {
232
+ std::rethrow_exception(__result.error());
233
+ }
234
+ }
235
+ inline void setConsecutiveBootFailCount(double count) override {
236
+ auto __result = _swiftPart.setConsecutiveBootFailCount(std::forward<decltype(count)>(count));
237
+ if (__result.hasError()) [[unlikely]] {
238
+ std::rethrow_exception(__result.error());
239
+ }
240
+ }
241
+ inline std::shared_ptr<Promise<std::string>> getAndClearRecoveryAction() override {
242
+ auto __result = _swiftPart.getAndClearRecoveryAction();
243
+ if (__result.hasError()) [[unlikely]] {
244
+ std::rethrow_exception(__result.error());
245
+ }
246
+ auto __value = std::move(__result.value());
247
+ return __value;
248
+ }
215
249
 
216
250
  private:
217
251
  ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx _swiftPart;
@@ -32,6 +32,11 @@ public protocol HybridReactNativeDeviceUtilsSpec_protocol: HybridObject {
32
32
  func exitApp() throws -> Void
33
33
  func getCurrentWebViewPackageInfo() throws -> Promise<WebViewPackageInfo>
34
34
  func isGooglePlayServicesAvailable() throws -> Promise<GooglePlayServicesStatus>
35
+ func markBootSuccess() throws -> Void
36
+ func getConsecutiveBootFailCount() throws -> Promise<Double>
37
+ func incrementConsecutiveBootFailCount() throws -> Void
38
+ func setConsecutiveBootFailCount(count: Double) throws -> Void
39
+ func getAndClearRecoveryAction() throws -> Promise<String>
35
40
  }
36
41
 
37
42
  public extension HybridReactNativeDeviceUtilsSpec_protocol {
@@ -408,4 +408,75 @@ open class HybridReactNativeDeviceUtilsSpec_cxx {
408
408
  return bridge.create_Result_std__shared_ptr_Promise_GooglePlayServicesStatus___(__exceptionPtr)
409
409
  }
410
410
  }
411
+
412
+ @inline(__always)
413
+ public final func markBootSuccess() -> bridge.Result_void_ {
414
+ do {
415
+ try self.__implementation.markBootSuccess()
416
+ return bridge.create_Result_void_()
417
+ } catch (let __error) {
418
+ let __exceptionPtr = __error.toCpp()
419
+ return bridge.create_Result_void_(__exceptionPtr)
420
+ }
421
+ }
422
+
423
+ @inline(__always)
424
+ public final func getConsecutiveBootFailCount() -> bridge.Result_std__shared_ptr_Promise_double___ {
425
+ do {
426
+ let __result = try self.__implementation.getConsecutiveBootFailCount()
427
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_double__ in
428
+ let __promise = bridge.create_std__shared_ptr_Promise_double__()
429
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_double__(__promise)
430
+ __result
431
+ .then({ __result in __promiseHolder.resolve(__result) })
432
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
433
+ return __promise
434
+ }()
435
+ return bridge.create_Result_std__shared_ptr_Promise_double___(__resultCpp)
436
+ } catch (let __error) {
437
+ let __exceptionPtr = __error.toCpp()
438
+ return bridge.create_Result_std__shared_ptr_Promise_double___(__exceptionPtr)
439
+ }
440
+ }
441
+
442
+ @inline(__always)
443
+ public final func incrementConsecutiveBootFailCount() -> bridge.Result_void_ {
444
+ do {
445
+ try self.__implementation.incrementConsecutiveBootFailCount()
446
+ return bridge.create_Result_void_()
447
+ } catch (let __error) {
448
+ let __exceptionPtr = __error.toCpp()
449
+ return bridge.create_Result_void_(__exceptionPtr)
450
+ }
451
+ }
452
+
453
+ @inline(__always)
454
+ public final func setConsecutiveBootFailCount(count: Double) -> bridge.Result_void_ {
455
+ do {
456
+ try self.__implementation.setConsecutiveBootFailCount(count: count)
457
+ return bridge.create_Result_void_()
458
+ } catch (let __error) {
459
+ let __exceptionPtr = __error.toCpp()
460
+ return bridge.create_Result_void_(__exceptionPtr)
461
+ }
462
+ }
463
+
464
+ @inline(__always)
465
+ public final func getAndClearRecoveryAction() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
466
+ do {
467
+ let __result = try self.__implementation.getAndClearRecoveryAction()
468
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
469
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
470
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
471
+ __result
472
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
473
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
474
+ return __promise
475
+ }()
476
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
477
+ } catch (let __error) {
478
+ let __exceptionPtr = __error.toCpp()
479
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
480
+ }
481
+ }
411
482
  }
@@ -32,6 +32,11 @@ namespace margelo::nitro::reactnativedeviceutils {
32
32
  prototype.registerHybridMethod("exitApp", &HybridReactNativeDeviceUtilsSpec::exitApp);
33
33
  prototype.registerHybridMethod("getCurrentWebViewPackageInfo", &HybridReactNativeDeviceUtilsSpec::getCurrentWebViewPackageInfo);
34
34
  prototype.registerHybridMethod("isGooglePlayServicesAvailable", &HybridReactNativeDeviceUtilsSpec::isGooglePlayServicesAvailable);
35
+ prototype.registerHybridMethod("markBootSuccess", &HybridReactNativeDeviceUtilsSpec::markBootSuccess);
36
+ prototype.registerHybridMethod("getConsecutiveBootFailCount", &HybridReactNativeDeviceUtilsSpec::getConsecutiveBootFailCount);
37
+ prototype.registerHybridMethod("incrementConsecutiveBootFailCount", &HybridReactNativeDeviceUtilsSpec::incrementConsecutiveBootFailCount);
38
+ prototype.registerHybridMethod("setConsecutiveBootFailCount", &HybridReactNativeDeviceUtilsSpec::setConsecutiveBootFailCount);
39
+ prototype.registerHybridMethod("getAndClearRecoveryAction", &HybridReactNativeDeviceUtilsSpec::getAndClearRecoveryAction);
35
40
  });
36
41
  }
37
42
 
@@ -83,6 +83,11 @@ namespace margelo::nitro::reactnativedeviceutils {
83
83
  virtual void exitApp() = 0;
84
84
  virtual std::shared_ptr<Promise<WebViewPackageInfo>> getCurrentWebViewPackageInfo() = 0;
85
85
  virtual std::shared_ptr<Promise<GooglePlayServicesStatus>> isGooglePlayServicesAvailable() = 0;
86
+ virtual void markBootSuccess() = 0;
87
+ virtual std::shared_ptr<Promise<double>> getConsecutiveBootFailCount() = 0;
88
+ virtual void incrementConsecutiveBootFailCount() = 0;
89
+ virtual void setConsecutiveBootFailCount(double count) = 0;
90
+ virtual std::shared_ptr<Promise<std::string>> getAndClearRecoveryAction() = 0;
86
91
 
87
92
  protected:
88
93
  // Hybrid Setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-device-utils",
3
- "version": "1.1.38",
3
+ "version": "1.1.40",
4
4
  "description": "react-native-device-utils",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -52,4 +52,11 @@ export interface ReactNativeDeviceUtils
52
52
  // WebView & Play Services
53
53
  getCurrentWebViewPackageInfo(): Promise<WebViewPackageInfo>;
54
54
  isGooglePlayServicesAvailable(): Promise<GooglePlayServicesStatus>;
55
+
56
+ // Boot Recovery
57
+ markBootSuccess(): void;
58
+ getConsecutiveBootFailCount(): Promise<number>;
59
+ incrementConsecutiveBootFailCount(): void;
60
+ setConsecutiveBootFailCount(count: number): void;
61
+ getAndClearRecoveryAction(): Promise<string>;
55
62
  }