react-native-update 10.59.0 → 10.59.1
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.
- package/android/build.gradle +46 -14
- package/android/jni/Android.mk +2 -1
- package/android/lib/arm64-v8a/librnpushy.so +0 -0
- package/android/lib/armeabi-v7a/librnpushy.so +0 -0
- package/android/lib/x86/librnpushy.so +0 -0
- package/android/lib/x86_64/librnpushy.so +0 -0
- package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/{CrashRescue.java → CrashHold.java} +12 -12
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +28 -24
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +2 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateFlow.java → FlowBridge.java} +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +6 -3
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateCore.java → NativeCore.java} +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/PushyConfiguration.java +10 -5
- package/android/src/main/java/cn/reactnative/modules/update/PushyRuntime.java +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +7 -7
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeCheckOrchestrator.java → SyncCoordinator.java} +79 -75
- package/android/src/main/java/cn/reactnative/modules/update/Texts.java +28 -0
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +28 -28
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +12 -9
- package/cpp/patch_core/archive_limits.h +5 -0
- package/cpp/patch_core/archive_patch_core.cpp +26 -19
- package/cpp/patch_core/archive_patch_core.h +17 -8
- package/cpp/patch_core/digest.h +6 -1
- package/cpp/patch_core/error_codes.h +8 -1
- package/cpp/patch_core/hbc_transform.h +5 -0
- package/cpp/patch_core/hbc_transform_wire.h +5 -0
- package/cpp/patch_core/install_record.h +5 -0
- package/cpp/patch_core/jni_natives.h +27 -0
- package/cpp/patch_core/jni_registration.cpp +103 -0
- package/cpp/patch_core/obscured_text.h +44 -0
- package/cpp/patch_core/patch_core.cpp +13 -13
- package/cpp/patch_core/patch_core.h +11 -6
- package/cpp/patch_core/patch_core_android.cpp +10 -10
- package/cpp/patch_core/state_core.h +5 -0
- package/cpp/patch_core/state_ops.h +5 -0
- package/cpp/patch_core/update_core_android.cpp +23 -22
- package/cpp/update_flow_core/flow_json.h +6 -1
- package/cpp/update_flow_core/update_flow_core.cpp +35 -18
- package/cpp/update_flow_core/update_flow_core.h +13 -8
- package/cpp/update_flow_core/update_flow_jni.cpp +11 -13
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/pushy/src/main/cpp/pushy.cpp +33 -33
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +15 -15
- package/harmony/pushy/src/main/ets/DownloadTask.ts +60 -60
- package/harmony/pushy/src/main/ets/ErrorCodes.ts +13 -11
- package/harmony/pushy/src/main/ets/InstallRecord.ts +4 -4
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +9 -9
- package/harmony/pushy/src/main/ets/PathUtils.ts +2 -2
- package/harmony/pushy/src/main/ets/PushyConfiguration.ts +8 -6
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +1 -1
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +42 -41
- package/harmony/pushy/src/main/ets/{NativeCheckOrchestrator.ts → SyncCoordinator.ts} +33 -32
- package/harmony/pushy/src/main/ets/Texts.ts +28 -0
- package/harmony/pushy/src/main/ets/UpdateContext.ts +31 -30
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.mm +148 -140
- package/ios/RCTPushy/RCTPushyConfiguration.h +8 -0
- package/ios/RCTPushy/RCTPushyConfiguration.mm +32 -5
- package/package.json +1 -1
- package/react-native-update.podspec +15 -3
- package/android/lib/arm64-v8a/librnupdate.so +0 -0
- package/android/lib/armeabi-v7a/librnupdate.so +0 -0
- package/android/lib/x86/librnupdate.so +0 -0
- package/android/lib/x86_64/librnupdate.so +0 -0
|
@@ -14,9 +14,9 @@ import logger from './Logger';
|
|
|
14
14
|
import {
|
|
15
15
|
KEY_CONFIG,
|
|
16
16
|
KEY_RESP_CACHE,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './
|
|
17
|
+
recordJsRound,
|
|
18
|
+
scheduleNativeSync,
|
|
19
|
+
} from './SyncCoordinator';
|
|
20
20
|
import NativePatchCore, {
|
|
21
21
|
STATE_OP_CLEAR_FIRST_TIME,
|
|
22
22
|
STATE_OP_CLEAR_ROLLBACK_MARK,
|
|
@@ -29,14 +29,15 @@ import NativePatchCore, {
|
|
|
29
29
|
import { assertSafePathComponent } from './PathUtils';
|
|
30
30
|
import {
|
|
31
31
|
ERROR_SWITCH_VERSION_FAILED,
|
|
32
|
-
|
|
32
|
+
createPushyError,
|
|
33
33
|
getErrorMessage,
|
|
34
|
-
|
|
34
|
+
toPushyError,
|
|
35
35
|
} from './ErrorCodes';
|
|
36
|
+
import { APP_DELTA_SUFFIX, PPK_DELTA_SUFFIX, PREFERENCES_NAME, STORAGE_DIR_NAME } from './Texts';
|
|
36
37
|
|
|
37
38
|
export { isSafePathComponent } from './PathUtils';
|
|
38
39
|
|
|
39
|
-
const TAG = '
|
|
40
|
+
const TAG = 'PushyContext';
|
|
40
41
|
// 常规清理保留最近 3 天内触碰过的条目(续传 partial、staging 同样按 mtime)。
|
|
41
42
|
const CLEANUP_MAX_AGE_DAYS = 3;
|
|
42
43
|
|
|
@@ -101,7 +102,7 @@ export class UpdateContext {
|
|
|
101
102
|
|
|
102
103
|
private constructor(context: common.UIAbilityContext) {
|
|
103
104
|
this.context = context;
|
|
104
|
-
this.rootDir = context.filesDir
|
|
105
|
+
this.rootDir = `${context.filesDir}/${STORAGE_DIR_NAME}`;
|
|
105
106
|
this.instanceId = `uc#${++UpdateContext.instanceCounter}`;
|
|
106
107
|
|
|
107
108
|
try {
|
|
@@ -145,7 +146,7 @@ export class UpdateContext {
|
|
|
145
146
|
private initPreferences() {
|
|
146
147
|
try {
|
|
147
148
|
this.preferences = preferences.getPreferencesSync(this.context, {
|
|
148
|
-
name:
|
|
149
|
+
name: PREFERENCES_NAME,
|
|
149
150
|
});
|
|
150
151
|
} catch (e) {
|
|
151
152
|
// Fail fast: a missing preferences store means no state can be persisted,
|
|
@@ -447,7 +448,7 @@ export class UpdateContext {
|
|
|
447
448
|
|
|
448
449
|
logger.info(
|
|
449
450
|
TAG,
|
|
450
|
-
`binary version changed, resetting
|
|
451
|
+
`binary version changed, resetting state id=${this.instanceId}`,
|
|
451
452
|
);
|
|
452
453
|
UpdateContext.ignoreRollback = false;
|
|
453
454
|
this.cleanUp();
|
|
@@ -477,7 +478,7 @@ export class UpdateContext {
|
|
|
477
478
|
UpdateContext.nativeConfigGeneration += 1;
|
|
478
479
|
this.preferences.putSync(KEY_CONFIG, config);
|
|
479
480
|
this.preferences.deleteSync(KEY_RESP_CACHE);
|
|
480
|
-
|
|
481
|
+
recordJsRound('');
|
|
481
482
|
}
|
|
482
483
|
// Flush even an equal value so a retry after a storage error can succeed.
|
|
483
484
|
return this.flushPreferences('persist configuration');
|
|
@@ -614,7 +615,7 @@ export class UpdateContext {
|
|
|
614
615
|
* 可插入 reset 的窗口(iOS/Android 用锁达到同一效果)。三项写入以一次
|
|
615
616
|
* flush 落盘,失败拒绝。返回是否提交成功。
|
|
616
617
|
*/
|
|
617
|
-
public async
|
|
618
|
+
public async commitSyncResult(
|
|
618
619
|
expectedGeneration: number,
|
|
619
620
|
hash: string,
|
|
620
621
|
hashInfoJson: string,
|
|
@@ -646,7 +647,7 @@ export class UpdateContext {
|
|
|
646
647
|
this.preferences.putSync(KEY_RESP_CACHE, responseCacheJson);
|
|
647
648
|
}
|
|
648
649
|
} finally {
|
|
649
|
-
flushed = this.endFlushBatch('commit
|
|
650
|
+
flushed = this.endFlushBatch('commit sync result');
|
|
650
651
|
}
|
|
651
652
|
await flushed;
|
|
652
653
|
return true;
|
|
@@ -668,7 +669,7 @@ export class UpdateContext {
|
|
|
668
669
|
params.deadlineUptimeMs = deadlineUptimeMs;
|
|
669
670
|
await this.executeTask(params);
|
|
670
671
|
} catch (e) {
|
|
671
|
-
logger.error(TAG, `Failed to download full
|
|
672
|
+
logger.error(TAG, `Failed to download full package: ${getErrorMessage(e)}`);
|
|
672
673
|
throw e;
|
|
673
674
|
}
|
|
674
675
|
}
|
|
@@ -685,7 +686,7 @@ export class UpdateContext {
|
|
|
685
686
|
hash,
|
|
686
687
|
);
|
|
687
688
|
params.originHash = assertSafePathComponent(originHash);
|
|
688
|
-
params.targetFile = `${this.rootDir}/${originHash}_${hash}
|
|
689
|
+
params.targetFile = `${this.rootDir}/${originHash}_${hash}${PPK_DELTA_SUFFIX}`;
|
|
689
690
|
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
|
690
691
|
params.originDirectory = `${this.rootDir}/${params.originHash}`;
|
|
691
692
|
params.deadlineUptimeMs = deadlineUptimeMs;
|
|
@@ -703,14 +704,14 @@ export class UpdateContext {
|
|
|
703
704
|
url,
|
|
704
705
|
hash,
|
|
705
706
|
);
|
|
706
|
-
params.targetFile = `${this.rootDir}/${hash}
|
|
707
|
+
params.targetFile = `${this.rootDir}/${hash}${APP_DELTA_SUFFIX}`;
|
|
707
708
|
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
|
708
709
|
params.deadlineUptimeMs = deadlineUptimeMs;
|
|
709
710
|
return await this.executeTask(params);
|
|
710
711
|
} catch (e) {
|
|
711
712
|
logger.error(
|
|
712
713
|
TAG,
|
|
713
|
-
`Failed to download package
|
|
714
|
+
`Failed to download package delta: ${getErrorMessage(e)}`,
|
|
714
715
|
);
|
|
715
716
|
throw e;
|
|
716
717
|
}
|
|
@@ -732,7 +733,7 @@ export class UpdateContext {
|
|
|
732
733
|
}
|
|
733
734
|
}
|
|
734
735
|
|
|
735
|
-
// 原生冷启动检测(
|
|
736
|
+
// 原生冷启动检测(SyncCoordinator)用来跳过已就绪版本的重复下载
|
|
736
737
|
// ——alert 类策略下版本已下载但未激活,若不判在这里会每次冷启动重下一遍。
|
|
737
738
|
public hasDownloadedVersion(hash: string): boolean {
|
|
738
739
|
try {
|
|
@@ -752,7 +753,7 @@ export class UpdateContext {
|
|
|
752
753
|
*/
|
|
753
754
|
private assertActivatable(safeHash: string): boolean {
|
|
754
755
|
if (!fileIo.accessSync(this.getBundlePath(safeHash))) {
|
|
755
|
-
throw
|
|
756
|
+
throw createPushyError(
|
|
756
757
|
ERROR_SWITCH_VERSION_FAILED,
|
|
757
758
|
`Bundle version ${safeHash} not found.`,
|
|
758
759
|
);
|
|
@@ -761,7 +762,7 @@ export class UpdateContext {
|
|
|
761
762
|
this.readString('currentVersion') === safeHash ||
|
|
762
763
|
this.readString('lastVersion') === safeHash;
|
|
763
764
|
if (!this.hasDownloadedVersion(safeHash) && !legacyActivated) {
|
|
764
|
-
throw
|
|
765
|
+
throw createPushyError(
|
|
765
766
|
ERROR_SWITCH_VERSION_FAILED,
|
|
766
767
|
`Bundle version ${safeHash} is incomplete.`,
|
|
767
768
|
);
|
|
@@ -801,7 +802,7 @@ export class UpdateContext {
|
|
|
801
802
|
await this.flushPreferences(`switch version ${safeHash}`);
|
|
802
803
|
} catch (e) {
|
|
803
804
|
logger.error(TAG, `Failed to switch version: ${getErrorMessage(e)}`);
|
|
804
|
-
throw
|
|
805
|
+
throw toPushyError(e, ERROR_SWITCH_VERSION_FAILED);
|
|
805
806
|
}
|
|
806
807
|
}
|
|
807
808
|
|
|
@@ -818,7 +819,7 @@ export class UpdateContext {
|
|
|
818
819
|
public getBundleUrl() {
|
|
819
820
|
UpdateContext.isUsingBundleUrl = true;
|
|
820
821
|
this.trace('getBundleUrl:enter');
|
|
821
|
-
let
|
|
822
|
+
let syncRolledBackVersion = '';
|
|
822
823
|
try {
|
|
823
824
|
const stateBeforeLaunch = this.getStateSnapshot();
|
|
824
825
|
const launchState = NativePatchCore.runStateCore(
|
|
@@ -828,7 +829,7 @@ export class UpdateContext {
|
|
|
828
829
|
UpdateContext.ignoreRollback,
|
|
829
830
|
true,
|
|
830
831
|
);
|
|
831
|
-
|
|
832
|
+
syncRolledBackVersion = launchState.rolledBackVersion || '';
|
|
832
833
|
if (launchState.didRollback) {
|
|
833
834
|
// The crash-protection rollback: the new version never called
|
|
834
835
|
// markSuccess. Keep this visible in release logs.
|
|
@@ -865,24 +866,24 @@ export class UpdateContext {
|
|
|
865
866
|
if (!fileIo.accessSync(bundleFile)) {
|
|
866
867
|
logger.error(TAG, `Bundle version ${version} not found.`);
|
|
867
868
|
version = this.rollBack();
|
|
868
|
-
|
|
869
|
+
syncRolledBackVersion = this.rolledBackVersion();
|
|
869
870
|
continue;
|
|
870
871
|
}
|
|
871
872
|
UpdateContext.launchVersion = version;
|
|
872
|
-
|
|
873
|
+
syncRolledBackVersion = this.rolledBackVersion();
|
|
873
874
|
return bundleFile;
|
|
874
875
|
} catch (e) {
|
|
875
876
|
logger.error(TAG, `Failed to access bundle file: ${getErrorMessage(e)}`);
|
|
876
877
|
version = this.rollBack();
|
|
877
|
-
|
|
878
|
+
syncRolledBackVersion = this.rolledBackVersion();
|
|
878
879
|
}
|
|
879
880
|
}
|
|
880
|
-
|
|
881
|
+
syncRolledBackVersion = this.rolledBackVersion();
|
|
881
882
|
return '';
|
|
882
883
|
} finally {
|
|
883
884
|
// State corruption is exactly when the native rescue check is needed;
|
|
884
885
|
// schedule even if state parsing/rollback throws before a normal exit.
|
|
885
|
-
|
|
886
|
+
scheduleNativeSync(this, syncRolledBackVersion);
|
|
886
887
|
}
|
|
887
888
|
}
|
|
888
889
|
|
|
@@ -936,7 +937,7 @@ export class UpdateContext {
|
|
|
936
937
|
// 安装的二进制,每次(覆盖)安装 updateTime 都会变,每个安装只算一次。
|
|
937
938
|
private static readonly KEY_BUNDLE_HASH_CACHE = 'bundleHashCache';
|
|
938
939
|
|
|
939
|
-
private
|
|
940
|
+
private getBundleModifiedTime(): number {
|
|
940
941
|
try {
|
|
941
942
|
const bundleInfo = bundleManager.getBundleInfoForSelfSync(
|
|
942
943
|
this.getBundleFlags(),
|
|
@@ -945,7 +946,7 @@ export class UpdateContext {
|
|
|
945
946
|
} catch (error) {
|
|
946
947
|
logger.error(
|
|
947
948
|
TAG,
|
|
948
|
-
`Failed to get bundle
|
|
949
|
+
`Failed to get bundle modification time: ${getErrorMessage(error)}`,
|
|
949
950
|
);
|
|
950
951
|
return 0;
|
|
951
952
|
}
|
|
@@ -962,7 +963,7 @@ export class UpdateContext {
|
|
|
962
963
|
// debug 下 bundle 由 metro 提供,与 dev 删 buildTime 的行为对齐。
|
|
963
964
|
return '';
|
|
964
965
|
}
|
|
965
|
-
const cachePrefix = `${this.getPackageVersion()}|${this.
|
|
966
|
+
const cachePrefix = `${this.getPackageVersion()}|${this.getBundleModifiedTime()}|`;
|
|
966
967
|
const cached = this.readString(UpdateContext.KEY_BUNDLE_HASH_CACHE);
|
|
967
968
|
if (cached.startsWith(cachePrefix)) {
|
|
968
969
|
return cached.slice(cachePrefix.length);
|
package/harmony/pushy.har
CHANGED
|
Binary file
|