react-native-update 10.59.0 → 10.59.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.
- 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 +20 -16
- 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 +10 -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 +154 -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 +16 -4
- 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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Registers the Android native methods from JNI_OnLoad instead of exporting
|
|
2
|
+
// Java_<package>_<class>_<method> symbols: the shared library then exports only
|
|
3
|
+
// JNI_OnLoad, and the class names, method names and signatures used for
|
|
4
|
+
// registration are stored encoded (obscured_text.h,
|
|
5
|
+
// scripts/encode-native-text.ts). Regenerate the table when a native method
|
|
6
|
+
// is added or its Java signature changes.
|
|
7
|
+
#include <jni.h>
|
|
8
|
+
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
#include "jni_natives.h"
|
|
13
|
+
#include "obscured_text.h"
|
|
14
|
+
|
|
15
|
+
namespace {
|
|
16
|
+
|
|
17
|
+
struct NativeMethod {
|
|
18
|
+
const char* name;
|
|
19
|
+
const char* signature;
|
|
20
|
+
void* function;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
struct NativeClass {
|
|
24
|
+
const char* name;
|
|
25
|
+
std::vector<NativeMethod> methods;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const std::vector<NativeClass>& NativeClasses() {
|
|
29
|
+
static const std::vector<NativeClass> classes = {
|
|
30
|
+
{"3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c8ebc8e7e42342de4daa0", // NativeCore
|
|
31
|
+
{
|
|
32
|
+
{"3d12e0e2bb9b784a302b19fdf2ba966b7c2216f2f7d4b6", "725edd",
|
|
33
|
+
reinterpret_cast<void*>(&pushy::jni_natives::SupportedDiffVersion)},
|
|
34
|
+
}},
|
|
35
|
+
{"3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c95ad9e7640342de4c6b1878768", // UpdateContext
|
|
36
|
+
{
|
|
37
|
+
{"290efad29d9f6951270815edde9199634b351dd7fbc9ab9c7d41", "723bfed0b88a274923311bb6e5a7826444205fcdf4daae943d432d07e18c93a9887e5a3655c7cbabcd8d79583507feccbe8e7244113617f1c7a3897a09361019fbc3b1de5d5f2911e7dcd3ab9341553e1febd0faf7b77b5b7d1de9c8a5976e7c4e3e02f481a687615753390ab9c6a0896b53214e2defd9a1974c433b03d1c5ceaf9b600a",
|
|
38
|
+
reinterpret_cast<void*>(&pushy::jni_natives::SyncStateWithBinaryVersion)},
|
|
39
|
+
{"2802fae2ba8a7c4001300efc", "723ed8d2a0c47a40233c08f7d7a7997b4f6809eefaceb49061003919e2c2b4b8d54440301aeeebaa909a4e5c2506fcd9f1ab6e40483a57f9d3a18b2675371214f4d0efab54020406ecb0cebc977044230bf3cdb7bbd4755a361ae0ccb5cc756d5e3600f481989c64565a1f16e4d682887952281545",
|
|
40
|
+
reinterpret_cast<void*>(&pushy::jni_natives::RunStateCore)},
|
|
41
|
+
}},
|
|
42
|
+
{"3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c84b28d79583e0feffca49194", // DownloadTask
|
|
43
|
+
{
|
|
44
|
+
{"3802fdddaaaa7a462a360afce6bf9163", "723ecffda48a7e446d331df7d1fca379582e0ae6a5e0949f73592d46eac2aebad544402307e5cffeb9b376582012bfc1ab89630e6d2f0afcdca8d7526a29010bfb98b890604c6736f6edd5b79128190109e98bb3bb9a7b413c0ef8c0b0862f70553301fdcbb8c770525b3d0df39c919f694f2d171bcbd9a191677c2507edf2d8a982784575",
|
|
45
|
+
reinterpret_cast<void*>(&pushy::jni_natives::BuildArchivePlan)},
|
|
46
|
+
{"3802fdddaaa867553b180ef6c3a383", "722cd8dbaf9d690a2e3e12fe9980847f432903bac5f7b294644e6305e7cda7f2a963463800ec93ecb9b37f577901f5cca9936a404a320ef09da2836d532f050eb5c2a4956f5f2d4ac1f0cca0b1615f381ad5c1b2ab976c0e",
|
|
47
|
+
reinterpret_cast<void*>(&pushy::jni_natives::BuildCopyGroups)},
|
|
48
|
+
{"3b07e4ddb7af6d49363e3aebd9bea3625f3507e4", "723bfed0b88a274923311bb6e5a7826444205fcdf4daae943d432d07e18c93a9887e5a3655c7c2a4949e3355371df78299937648503c43d9d8ae9a68092f0113fd9887857c422602b9d3d6b880721f210be9c3ee8d8f6a5c3c08b7e5ac82767c153b15ffc9e4bb715056321eade98ba16046320051f7d9bb95207f3d14eacedae1ac585b2f1de98aaebe927e190004ffc3a9833a45773214e4cee385674d277229e3c6b8806c1309081eead8f99f71432d48d7d5ccb2967209663a",
|
|
49
|
+
reinterpret_cast<void*>(&pushy::jni_natives::ApplyDeltaFromSource)},
|
|
50
|
+
{"391bf1d0a09e786a2e3b39f7c2a1996859", "723bfed0b88a274923311bb6e5a7826444205fcdf4daae943d432d07e18c93a9887e5a3655c7c2a4949e3355371df78299937648503c43dc9b99",
|
|
51
|
+
reinterpret_cast<void*>(&pushy::jni_natives::CleanupOldEntries)},
|
|
52
|
+
}},
|
|
53
|
+
{"3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c86b19560762307efcfa0", // FlowBridge
|
|
54
|
+
{
|
|
55
|
+
{"3802fdddaab96d54373a0fedf4bc9474", "723bfed0b88a274923311bb6e5a7826444205fa8d2d1b98373002008e8c4ef8e8e655d3f09b0",
|
|
56
|
+
reinterpret_cast<void*>(&pushy::jni_natives::FlowBuildRequestBody)},
|
|
57
|
+
{"3505f0d4bcae6641323015f7c29091634e2e00e0eadeab", "723bfed0b88a274923311bb6e5a7826444205fc5b7f7b294644e6305e7cda7f2a963463800ec93",
|
|
58
|
+
reinterpret_cast<void*>(&pushy::jni_natives::FlowOrderEndpointCandidates)},
|
|
59
|
+
{"3304c2d0a2826c77272c0cf6d8a095", "723bfed0b88a274923311bb6e5a7826444205fa8c4",
|
|
60
|
+
reinterpret_cast<void*>(&pushy::jni_natives::FlowIsValidResponse)},
|
|
61
|
+
{"3216fad5a28e5a40312f13f7c5b6", "723bfed0b88a274923311bb6e5a7826444205fcdf4daae943d432d07e18c93a9887e5a3655c7c2a4949e3355371df78299937648503c43bcfea58d7f476c0c1cf4d0fba27a59210be5a4",
|
|
62
|
+
reinterpret_cast<void*>(&pushy::jni_natives::FlowHandleResponse)},
|
|
63
|
+
}},
|
|
64
|
+
};
|
|
65
|
+
return classes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Registers each method on its own: a host's R8 build may drop an unused
|
|
69
|
+
// class or native method, which must not prevent the rest from binding.
|
|
70
|
+
void RegisterAll(JNIEnv* env) {
|
|
71
|
+
for (const NativeClass& native_class : NativeClasses()) {
|
|
72
|
+
const std::string class_name = pushy::text::Reveal(native_class.name);
|
|
73
|
+
jclass clazz = env->FindClass(class_name.c_str());
|
|
74
|
+
if (clazz == nullptr) {
|
|
75
|
+
env->ExceptionClear();
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
for (const NativeMethod& method : native_class.methods) {
|
|
79
|
+
const std::string name = pushy::text::Reveal(method.name);
|
|
80
|
+
const std::string signature = pushy::text::Reveal(method.signature);
|
|
81
|
+
const JNINativeMethod entry = {
|
|
82
|
+
const_cast<char*>(name.c_str()),
|
|
83
|
+
const_cast<char*>(signature.c_str()),
|
|
84
|
+
method.function,
|
|
85
|
+
};
|
|
86
|
+
if (env->RegisterNatives(clazz, &entry, 1) != JNI_OK) {
|
|
87
|
+
env->ExceptionClear();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
env->DeleteLocalRef(clazz);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} // namespace
|
|
95
|
+
|
|
96
|
+
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
97
|
+
JNIEnv* env = nullptr;
|
|
98
|
+
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
|
99
|
+
return JNI_ERR;
|
|
100
|
+
}
|
|
101
|
+
RegisterAll(env);
|
|
102
|
+
return JNI_VERSION_1_6;
|
|
103
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#ifndef PUSHY_PATCH_CORE_OBSCURED_TEXT_H_
|
|
2
|
+
#define PUSHY_PATCH_CORE_OBSCURED_TEXT_H_
|
|
3
|
+
|
|
4
|
+
#include <cstdlib>
|
|
5
|
+
#include <cstring>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
// Keep the core internal to whichever binary links it (see podspec Core).
|
|
9
|
+
#pragma GCC visibility push(hidden)
|
|
10
|
+
|
|
11
|
+
namespace pushy {
|
|
12
|
+
namespace text {
|
|
13
|
+
|
|
14
|
+
// Decodes text produced by scripts/encode-native-text.ts: byte i is XORed with
|
|
15
|
+
// (0x5A + 0x1D * i) & 0xFF. Keeps class names, method names and protocol
|
|
16
|
+
// strings out of static string scans of the binary; it is not a secret. The
|
|
17
|
+
// key base is read through a volatile so the optimizer cannot fold a constant
|
|
18
|
+
// argument back into a plain string.
|
|
19
|
+
inline std::string Reveal(const char* hex) {
|
|
20
|
+
static volatile unsigned char key_base = 0x5A;
|
|
21
|
+
const unsigned char base = key_base;
|
|
22
|
+
const size_t length = std::strlen(hex) / 2;
|
|
23
|
+
std::string out(length, '\0');
|
|
24
|
+
for (size_t i = 0; i < length; ++i) {
|
|
25
|
+
const char pair[3] = {hex[i * 2], hex[i * 2 + 1], 0};
|
|
26
|
+
const unsigned char byte =
|
|
27
|
+
static_cast<unsigned char>(std::strtoul(pair, nullptr, 16));
|
|
28
|
+
out[i] = static_cast<char>(byte ^ static_cast<unsigned char>(base + 0x1D * i));
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Decodes once into storage that lives for the whole process, for constants
|
|
34
|
+
// that must stay valid as const char* (error codes and the like).
|
|
35
|
+
inline const char* RevealStatic(const char* hex) {
|
|
36
|
+
return (new std::string(Reveal(hex)))->c_str();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
} // namespace text
|
|
40
|
+
} // namespace pushy
|
|
41
|
+
|
|
42
|
+
#pragma GCC visibility pop
|
|
43
|
+
|
|
44
|
+
#endif // PUSHY_PATCH_CORE_OBSCURED_TEXT_H_
|
|
@@ -25,7 +25,7 @@ extern "C" {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
namespace pushy {
|
|
28
|
-
namespace
|
|
28
|
+
namespace delta {
|
|
29
29
|
|
|
30
30
|
namespace internal {
|
|
31
31
|
bool g_disable_hard_links = false;
|
|
@@ -41,7 +41,7 @@ constexpr size_t kCopyBufferSize = 16 * 1024;
|
|
|
41
41
|
// flowjson::kMaxDepth). Real bundles nest a handful of levels.
|
|
42
42
|
constexpr int kMaxDirectoryDepth = 64;
|
|
43
43
|
|
|
44
|
-
class
|
|
44
|
+
class HdiffBundleRebuilder final : public BundleRebuilder {
|
|
45
45
|
public:
|
|
46
46
|
Status Apply(
|
|
47
47
|
const std::string& origin_bundle_path,
|
|
@@ -499,8 +499,8 @@ Status ValidateManifest(const PatchManifest& manifest) {
|
|
|
499
499
|
return ValidateManifestImpl(manifest);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
const
|
|
503
|
-
static const
|
|
502
|
+
const BundleRebuilder& DefaultBundleRebuilder() {
|
|
503
|
+
static const HdiffBundleRebuilder kPatcher;
|
|
504
504
|
return kPatcher;
|
|
505
505
|
}
|
|
506
506
|
|
|
@@ -517,7 +517,7 @@ Status TransformFileInPlace(
|
|
|
517
517
|
const hbc::HbcLayoutDesc& layout,
|
|
518
518
|
bool inverse) {
|
|
519
519
|
const char* failure = inverse
|
|
520
|
-
? "hbcTransform inverse failed on
|
|
520
|
+
? "hbcTransform inverse failed on rebuilt bundle"
|
|
521
521
|
: "hbcTransform failed on origin bundle";
|
|
522
522
|
|
|
523
523
|
const int fd = open(path.c_str(), O_RDWR);
|
|
@@ -578,7 +578,7 @@ Status TransformFileInPlace(
|
|
|
578
578
|
// 端到端不把 bundle 整体读进内存。
|
|
579
579
|
Status ApplyBundlePatchWithHbcTransform(
|
|
580
580
|
const FileSourcePatchOptions& options,
|
|
581
|
-
const
|
|
581
|
+
const BundleRebuilder& bundle_patcher) {
|
|
582
582
|
hbc::HbcTransformMeta meta;
|
|
583
583
|
if (!hbc::ParseHbcTransformMeta(options.bundle_hbc_transform_meta, &meta)) {
|
|
584
584
|
return Status::Error("Invalid hbcTransform metadata");
|
|
@@ -596,7 +596,7 @@ Status ApplyBundlePatchWithHbcTransform(
|
|
|
596
596
|
return dir_status;
|
|
597
597
|
}
|
|
598
598
|
const std::string temp_origin = options.bundle_output_path + ".hbct-origin";
|
|
599
|
-
const std::string temp_patched = options.bundle_output_path + ".hbct-
|
|
599
|
+
const std::string temp_patched = options.bundle_output_path + ".hbct-rebuilt";
|
|
600
600
|
remove(temp_origin.c_str());
|
|
601
601
|
remove(temp_patched.c_str());
|
|
602
602
|
|
|
@@ -636,7 +636,7 @@ Status ApplyBundlePatchWithHbcTransform(
|
|
|
636
636
|
}
|
|
637
637
|
if (rename(temp_patched.c_str(), options.bundle_output_path.c_str()) != 0) {
|
|
638
638
|
Status rename_status = MakeErrnoStatus(
|
|
639
|
-
"Failed to move
|
|
639
|
+
"Failed to move rebuilt bundle into place " + options.bundle_output_path);
|
|
640
640
|
remove(temp_patched.c_str());
|
|
641
641
|
return rename_status;
|
|
642
642
|
}
|
|
@@ -647,7 +647,7 @@ Status ApplyBundlePatchWithHbcTransform(
|
|
|
647
647
|
|
|
648
648
|
Status ApplyPatchFromFileSource(
|
|
649
649
|
const FileSourcePatchOptions& options,
|
|
650
|
-
const
|
|
650
|
+
const BundleRebuilder& bundle_patcher) {
|
|
651
651
|
Status manifest_status = ValidateManifest(options.manifest);
|
|
652
652
|
if (!manifest_status) {
|
|
653
653
|
return manifest_status;
|
|
@@ -805,7 +805,7 @@ bool IsSafeRelativePath(const std::string& path) {
|
|
|
805
805
|
return true;
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
-
Status
|
|
808
|
+
Status HdiffBundleRebuilder::Apply(
|
|
809
809
|
const std::string& origin_bundle_path,
|
|
810
810
|
const std::string& bundle_patch_path,
|
|
811
811
|
const std::string& destination_bundle_path) const {
|
|
@@ -813,7 +813,7 @@ Status HdiffBundlePatcher::Apply(
|
|
|
813
813
|
return Status::Error("Origin bundle not found: " + origin_bundle_path);
|
|
814
814
|
}
|
|
815
815
|
if (!PathExists(bundle_patch_path)) {
|
|
816
|
-
return Status::Error("Bundle
|
|
816
|
+
return Status::Error("Bundle delta not found: " + bundle_patch_path);
|
|
817
817
|
}
|
|
818
818
|
|
|
819
819
|
const std::string parent = Dirname(destination_bundle_path);
|
|
@@ -835,10 +835,10 @@ Status HdiffBundlePatcher::Apply(
|
|
|
835
835
|
bundle_patch_path.c_str());
|
|
836
836
|
if (result != 0) {
|
|
837
837
|
return Status::Error(
|
|
838
|
-
"Failed to apply bundle
|
|
838
|
+
"Failed to apply bundle delta, error " + IntToString(result));
|
|
839
839
|
}
|
|
840
840
|
return Status::Ok();
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
-
} // namespace
|
|
843
|
+
} // namespace delta
|
|
844
844
|
} // namespace pushy
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
#include <string>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
+
// Keep the core internal to whichever binary links it (see podspec Core).
|
|
9
|
+
#pragma GCC visibility push(hidden)
|
|
10
|
+
|
|
8
11
|
namespace pushy {
|
|
9
|
-
namespace
|
|
12
|
+
namespace delta {
|
|
10
13
|
|
|
11
14
|
struct Status {
|
|
12
15
|
bool ok;
|
|
@@ -51,22 +54,22 @@ struct FileSourcePatchOptions {
|
|
|
51
54
|
std::string bundle_hbc_transform_meta;
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
class
|
|
57
|
+
class BundleRebuilder {
|
|
55
58
|
public:
|
|
56
|
-
virtual ~
|
|
59
|
+
virtual ~BundleRebuilder() = default;
|
|
57
60
|
virtual Status Apply(
|
|
58
61
|
const std::string& origin_bundle_path,
|
|
59
62
|
const std::string& bundle_patch_path,
|
|
60
63
|
const std::string& destination_bundle_path) const = 0;
|
|
61
64
|
};
|
|
62
65
|
|
|
63
|
-
const
|
|
66
|
+
const BundleRebuilder& DefaultBundleRebuilder();
|
|
64
67
|
|
|
65
68
|
Status ValidateManifest(const PatchManifest& manifest);
|
|
66
69
|
|
|
67
70
|
Status ApplyPatchFromFileSource(
|
|
68
71
|
const FileSourcePatchOptions& options,
|
|
69
|
-
const
|
|
72
|
+
const BundleRebuilder& bundle_patcher = DefaultBundleRebuilder());
|
|
70
73
|
|
|
71
74
|
// Removes every non-dot entry under root_dir older than max_age_days whose
|
|
72
75
|
// name is not in keep_names. Callers must include every version that may
|
|
@@ -94,5 +97,7 @@ namespace internal {
|
|
|
94
97
|
extern bool g_disable_hard_links;
|
|
95
98
|
} // namespace internal
|
|
96
99
|
|
|
97
|
-
} // namespace
|
|
100
|
+
} // namespace delta
|
|
98
101
|
} // namespace pushy
|
|
102
|
+
|
|
103
|
+
#pragma GCC visibility pop
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#include <jni.h>
|
|
2
2
|
|
|
3
|
+
#include "jni_natives.h"
|
|
4
|
+
|
|
3
5
|
#include <exception>
|
|
4
6
|
#include <string>
|
|
5
7
|
#include <vector>
|
|
@@ -15,8 +17,7 @@ using pushy::jni_util::ThrowRuntimeException;
|
|
|
15
17
|
|
|
16
18
|
} // namespace
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
Java_cn_reactnative_modules_update_DownloadTask_applyPatchFromFileSource(
|
|
20
|
+
void pushy::jni_natives::ApplyDeltaFromSource(
|
|
20
21
|
JNIEnv* env,
|
|
21
22
|
jclass,
|
|
22
23
|
jstring source_root,
|
|
@@ -42,7 +43,7 @@ Java_cn_reactnative_modules_update_DownloadTask_applyPatchFromFileSource(
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
pushy::
|
|
46
|
+
pushy::delta::FileSourcePatchOptions options;
|
|
46
47
|
options.source_root = JStringToString(env, source_root);
|
|
47
48
|
options.target_root = JStringToString(env, target_root);
|
|
48
49
|
options.origin_bundle_path = JStringToString(env, origin_bundle_path);
|
|
@@ -53,27 +54,26 @@ Java_cn_reactnative_modules_update_DownloadTask_applyPatchFromFileSource(
|
|
|
53
54
|
options.bundle_hbc_transform_meta = JStringToString(env, hbc_transform_meta);
|
|
54
55
|
|
|
55
56
|
for (size_t index = 0; index < from_values.size(); ++index) {
|
|
56
|
-
options.manifest.copies.push_back(pushy::
|
|
57
|
+
options.manifest.copies.push_back(pushy::delta::CopyOperation{
|
|
57
58
|
from_values[index],
|
|
58
59
|
to_values[index],
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
options.manifest.deletes = JArrayToVector(env, deletes);
|
|
62
63
|
|
|
63
|
-
const pushy::
|
|
64
|
-
pushy::
|
|
64
|
+
const pushy::delta::Status status =
|
|
65
|
+
pushy::delta::ApplyPatchFromFileSource(options);
|
|
65
66
|
if (!status.ok) {
|
|
66
67
|
ThrowRuntimeException(env, status.message);
|
|
67
68
|
}
|
|
68
69
|
} catch (const std::exception& error) {
|
|
69
70
|
ThrowRuntimeException(env, error.what());
|
|
70
71
|
} catch (...) {
|
|
71
|
-
ThrowRuntimeException(env, "Unexpected native exception
|
|
72
|
+
ThrowRuntimeException(env, "Unexpected native exception while applying delta");
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
Java_cn_reactnative_modules_update_DownloadTask_cleanupOldEntries(
|
|
76
|
+
void pushy::jni_natives::CleanupOldEntries(
|
|
77
77
|
JNIEnv* env,
|
|
78
78
|
jclass,
|
|
79
79
|
jstring root_dir,
|
|
@@ -81,7 +81,7 @@ Java_cn_reactnative_modules_update_DownloadTask_cleanupOldEntries(
|
|
|
81
81
|
jstring keep_previous,
|
|
82
82
|
jint max_age_days) {
|
|
83
83
|
try {
|
|
84
|
-
const pushy::
|
|
84
|
+
const pushy::delta::Status status = pushy::delta::CleanupOldEntries(
|
|
85
85
|
JStringToString(env, root_dir),
|
|
86
86
|
JStringToString(env, keep_current),
|
|
87
87
|
JStringToString(env, keep_previous),
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
#include <string>
|
|
4
4
|
|
|
5
|
+
// Keep the core internal to whichever binary links it (see podspec Core).
|
|
6
|
+
#pragma GCC visibility push(hidden)
|
|
7
|
+
|
|
5
8
|
namespace pushy {
|
|
6
9
|
namespace state {
|
|
7
10
|
|
|
@@ -62,3 +65,5 @@ LaunchDecision ResolveLaunchState(
|
|
|
62
65
|
|
|
63
66
|
} // namespace state
|
|
64
67
|
} // namespace pushy
|
|
68
|
+
|
|
69
|
+
#pragma GCC visibility pop
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
// - HarmonyOS: UpdateContext.ts (StateOperation usage)
|
|
9
9
|
// Do not renumber existing entries; only append new ones.
|
|
10
10
|
|
|
11
|
+
// Keep the core internal to whichever binary links it (see podspec Core).
|
|
12
|
+
#pragma GCC visibility push(hidden)
|
|
13
|
+
|
|
11
14
|
namespace pushy {
|
|
12
15
|
namespace state_ops {
|
|
13
16
|
|
|
@@ -22,3 +25,5 @@ enum class StateOperation {
|
|
|
22
25
|
|
|
23
26
|
} // namespace state_ops
|
|
24
27
|
} // namespace pushy
|
|
28
|
+
|
|
29
|
+
#pragma GCC visibility pop
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#include <jni.h>
|
|
2
2
|
|
|
3
|
+
#include "jni_natives.h"
|
|
4
|
+
#include "obscured_text.h"
|
|
5
|
+
|
|
3
6
|
#include <exception>
|
|
4
7
|
#include <string>
|
|
5
8
|
#include <vector>
|
|
@@ -137,7 +140,8 @@ jobject NewStateCoreResult(
|
|
|
137
140
|
bool did_rollback,
|
|
138
141
|
bool consumed_first_time) {
|
|
139
142
|
jclass result_class =
|
|
140
|
-
env->FindClass(
|
|
143
|
+
env->FindClass(
|
|
144
|
+
pushy::text::Reveal("3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c93a99b63511201f9cd97878c695522").c_str());
|
|
141
145
|
if (result_class == nullptr) {
|
|
142
146
|
return nullptr;
|
|
143
147
|
}
|
|
@@ -186,7 +190,8 @@ jobject NewArchivePatchPlanResult(
|
|
|
186
190
|
JNIEnv* env,
|
|
187
191
|
const pushy::archive_patch::ArchivePatchPlan& plan) {
|
|
188
192
|
jclass result_class =
|
|
189
|
-
env->FindClass(
|
|
193
|
+
env->FindClass(
|
|
194
|
+
pushy::text::Reveal("3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c81af997f5d270bdbc9b181974c55371dc2c8b9926855").c_str());
|
|
190
195
|
if (result_class == nullptr) {
|
|
191
196
|
return nullptr;
|
|
192
197
|
}
|
|
@@ -258,14 +263,14 @@ bool ToArchivePatchType(
|
|
|
258
263
|
static_cast<int>(patch_type), out);
|
|
259
264
|
}
|
|
260
265
|
|
|
261
|
-
pushy::
|
|
266
|
+
pushy::delta::PatchManifest BuildManifest(
|
|
262
267
|
const std::vector<std::string>& copy_froms,
|
|
263
268
|
const std::vector<std::string>& copy_tos,
|
|
264
269
|
const std::vector<std::string>& deletes) {
|
|
265
|
-
pushy::
|
|
270
|
+
pushy::delta::PatchManifest manifest;
|
|
266
271
|
for (size_t index = 0; index < copy_froms.size(); ++index) {
|
|
267
272
|
manifest.copies.push_back(
|
|
268
|
-
pushy::
|
|
273
|
+
pushy::delta::CopyOperation{copy_froms[index], copy_tos[index]});
|
|
269
274
|
}
|
|
270
275
|
manifest.deletes = deletes;
|
|
271
276
|
return manifest;
|
|
@@ -293,15 +298,13 @@ jobject MakeStateResult(
|
|
|
293
298
|
|
|
294
299
|
// 客户端可消费的 diff 轨道版本(能力上报,而非 SDK 版本映射);JS 层经
|
|
295
300
|
// getConstants 暴露,随 checkUpdate 以 diffV 上报,服务端据此下发 v2 轨道。
|
|
296
|
-
|
|
297
|
-
Java_cn_reactnative_modules_update_NativeUpdateCore_getSupportedDiffVersion(
|
|
301
|
+
jint pushy::jni_natives::SupportedDiffVersion(
|
|
298
302
|
JNIEnv*,
|
|
299
303
|
jclass) {
|
|
300
304
|
return static_cast<jint>(pushy::hbc::kSupportedDiffVersion);
|
|
301
305
|
}
|
|
302
306
|
|
|
303
|
-
|
|
304
|
-
Java_cn_reactnative_modules_update_UpdateContext_syncStateWithBinaryVersion(
|
|
307
|
+
jobject pushy::jni_natives::SyncStateWithBinaryVersion(
|
|
305
308
|
JNIEnv* env,
|
|
306
309
|
jclass,
|
|
307
310
|
jstring package_version,
|
|
@@ -325,8 +328,7 @@ Java_cn_reactnative_modules_update_UpdateContext_syncStateWithBinaryVersion(
|
|
|
325
328
|
return nullptr;
|
|
326
329
|
}
|
|
327
330
|
|
|
328
|
-
|
|
329
|
-
Java_cn_reactnative_modules_update_UpdateContext_runStateCore(
|
|
331
|
+
jobject pushy::jni_natives::RunStateCore(
|
|
330
332
|
JNIEnv* env,
|
|
331
333
|
jclass,
|
|
332
334
|
jint operation,
|
|
@@ -383,8 +385,7 @@ Java_cn_reactnative_modules_update_UpdateContext_runStateCore(
|
|
|
383
385
|
return nullptr;
|
|
384
386
|
}
|
|
385
387
|
|
|
386
|
-
|
|
387
|
-
Java_cn_reactnative_modules_update_DownloadTask_buildArchivePatchPlan(
|
|
388
|
+
jobject pushy::jni_natives::BuildArchivePlan(
|
|
388
389
|
JNIEnv* env,
|
|
389
390
|
jclass,
|
|
390
391
|
jint patch_type,
|
|
@@ -400,15 +401,15 @@ Java_cn_reactnative_modules_update_DownloadTask_buildArchivePatchPlan(
|
|
|
400
401
|
return nullptr;
|
|
401
402
|
}
|
|
402
403
|
|
|
403
|
-
pushy::
|
|
404
|
+
pushy::delta::PatchManifest manifest =
|
|
404
405
|
BuildManifest(from_values, to_values, JArrayToVector(env, deletes));
|
|
405
406
|
pushy::archive_patch::ArchivePatchType archive_type;
|
|
406
407
|
if (!ToArchivePatchType(patch_type, &archive_type)) {
|
|
407
|
-
ThrowRuntimeException(env, "Unknown archive
|
|
408
|
+
ThrowRuntimeException(env, "Unknown archive delta type");
|
|
408
409
|
return nullptr;
|
|
409
410
|
}
|
|
410
411
|
pushy::archive_patch::ArchivePatchPlan plan;
|
|
411
|
-
pushy::
|
|
412
|
+
pushy::delta::Status status = pushy::archive_patch::BuildArchivePatchPlan(
|
|
412
413
|
archive_type,
|
|
413
414
|
manifest,
|
|
414
415
|
JArrayToVector(env, entry_names),
|
|
@@ -422,13 +423,12 @@ Java_cn_reactnative_modules_update_DownloadTask_buildArchivePatchPlan(
|
|
|
422
423
|
} catch (const std::exception& error) {
|
|
423
424
|
ThrowRuntimeException(env, error.what());
|
|
424
425
|
} catch (...) {
|
|
425
|
-
ThrowRuntimeException(env, "Unexpected native exception
|
|
426
|
+
ThrowRuntimeException(env, "Unexpected native exception while planning archive");
|
|
426
427
|
}
|
|
427
428
|
return nullptr;
|
|
428
429
|
}
|
|
429
430
|
|
|
430
|
-
|
|
431
|
-
Java_cn_reactnative_modules_update_DownloadTask_buildCopyGroups(
|
|
431
|
+
jobjectArray pushy::jni_natives::BuildCopyGroups(
|
|
432
432
|
JNIEnv* env,
|
|
433
433
|
jclass,
|
|
434
434
|
jobjectArray copy_froms,
|
|
@@ -441,10 +441,10 @@ Java_cn_reactnative_modules_update_DownloadTask_buildCopyGroups(
|
|
|
441
441
|
return nullptr;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
pushy::
|
|
444
|
+
pushy::delta::PatchManifest manifest = BuildManifest(
|
|
445
445
|
from_values, to_values, std::vector<std::string>());
|
|
446
446
|
std::vector<pushy::archive_patch::CopyGroup> groups;
|
|
447
|
-
pushy::
|
|
447
|
+
pushy::delta::Status status =
|
|
448
448
|
pushy::archive_patch::BuildCopyGroups(manifest, &groups);
|
|
449
449
|
if (!status.ok) {
|
|
450
450
|
ThrowRuntimeException(env, status.message);
|
|
@@ -452,7 +452,8 @@ Java_cn_reactnative_modules_update_DownloadTask_buildCopyGroups(
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
jclass result_class =
|
|
455
|
-
env->FindClass(
|
|
455
|
+
env->FindClass(
|
|
456
|
+
pushy::text::Reveal("3919bbc3ab8a6b512c3e08f0c0b6df60452311edfbc8f780624b2d1de38c83b28a6e732301fed897878c695522").c_str());
|
|
456
457
|
if (result_class == nullptr) {
|
|
457
458
|
return nullptr;
|
|
458
459
|
}
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
// falsy; empty arrays and objects are truthy);
|
|
19
19
|
// - StrictEquals() implements === for primitives only (never for
|
|
20
20
|
// arrays/objects — reference equality cannot hold across a parse).
|
|
21
|
+
// Keep the core internal to whichever binary links it (see podspec Core).
|
|
22
|
+
#pragma GCC visibility push(hidden)
|
|
23
|
+
|
|
21
24
|
namespace flowjson {
|
|
22
25
|
|
|
23
26
|
class Value;
|
|
@@ -100,7 +103,7 @@ std::string Stringify(const Value& v);
|
|
|
100
103
|
// and the divergence is deliberate: this parser runs inside the native
|
|
101
104
|
// orchestrators on the raw checkUpdate body, and with sizeof(Value) ~ 96 a
|
|
102
105
|
// 1 MB "[0,0,...]" balloons to ~100 MB of heap. A response over either cap is
|
|
103
|
-
// treated as malformed (
|
|
106
|
+
// treated as malformed (HandleResponse -> invalidResponse). Real
|
|
104
107
|
// responses are a few KB and a few hundred nodes.
|
|
105
108
|
constexpr size_t kMaxInputBytes = 1024 * 1024;
|
|
106
109
|
constexpr size_t kMaxNodes = 65536;
|
|
@@ -114,3 +117,5 @@ constexpr size_t kMaxNodes = 65536;
|
|
|
114
117
|
Value Parse(const std::string& text, bool* ok);
|
|
115
118
|
|
|
116
119
|
} // namespace flowjson
|
|
120
|
+
|
|
121
|
+
#pragma GCC visibility pop
|