react-native-update 10.59.2 → 10.60.0
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/README-CN.md +7 -7
- package/README.md +7 -6
- package/android/build.gradle +25 -33
- package/android/jni/Android.mk +16 -24
- 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/proguard.pro +9 -7
- package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +2 -7
- package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +23 -6
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +50 -51
- package/android/src/main/java/cn/reactnative/modules/update/CleanupKeepNames.java +12 -13
- package/android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java +3 -0
- package/android/src/main/java/cn/reactnative/modules/update/CrashHold.java +22 -30
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +181 -332
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +3 -1
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +27 -0
- package/android/src/main/java/cn/reactnative/modules/update/FileOperationException.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/FlowBridge.java +32 -8
- package/android/src/main/java/cn/reactnative/modules/update/HttpClients.java +63 -0
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +0 -11
- package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +66 -116
- package/android/src/main/java/cn/reactnative/modules/update/NativeCore.java +9 -1
- package/android/src/main/java/cn/reactnative/modules/update/PatchFailedException.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/PushyRuntime.java +32 -60
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +8 -23
- package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +42 -80
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +22 -39
- package/android/src/main/java/cn/reactnative/modules/update/SyncCoordinator.java +176 -299
- package/android/src/main/java/cn/reactnative/modules/update/Threads.java +35 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +242 -174
- package/android/src/main/java/cn/reactnative/modules/update/UpdateEventEmitter.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +75 -17
- package/android/src/main/java/cn/reactnative/modules/update/{UpdateModuleImpl.java → UpdateModule.java} +113 -95
- package/android/src/main/java/cn/reactnative/modules/update/UpdatePackage.java +16 -19
- package/android/src/oldarch/cn/reactnative/modules/update/NativePushySpec.java +69 -0
- package/cpp/android_jni/archive_limits_jni.cpp +83 -0
- package/cpp/android_jni/install_record_jni.cpp +89 -0
- package/cpp/android_jni/jni_log.h +31 -0
- package/cpp/android_jni/jni_natives.h +40 -0
- package/cpp/android_jni/jni_registration.cpp +133 -0
- package/cpp/android_jni/jni_util.h +160 -0
- package/cpp/android_jni/update_core_android.cpp +450 -0
- package/cpp/android_jni/update_flow_jni.cpp +133 -0
- package/{android/jni → cpp/hpatch}/hpatch.c +5 -5
- package/{android/jni → cpp/hpatch}/hpatch.h +4 -1
- package/cpp/patch_core/archive_limits.cpp +194 -0
- package/cpp/patch_core/archive_limits.h +99 -10
- package/cpp/patch_core/archive_patch_core.cpp +96 -12
- package/cpp/patch_core/archive_patch_core.h +49 -0
- package/cpp/patch_core/digest.h +5 -4
- package/cpp/patch_core/error_codes.h +5 -3
- package/cpp/patch_core/install_record.cpp +430 -0
- package/cpp/patch_core/install_record.h +163 -9
- package/cpp/patch_core/patch_core.cpp +62 -16
- package/cpp/patch_core/patch_core.h +27 -7
- package/cpp/patch_core/patch_manifest.cpp +201 -0
- package/cpp/patch_core/patch_manifest.h +74 -0
- package/cpp/patch_core/state_ops.h +3 -3
- package/cpp/update_flow_core/flow_json.cpp +82 -8
- package/cpp/update_flow_core/flow_json.h +21 -0
- package/cpp/update_flow_core/native_config.cpp +456 -0
- package/cpp/update_flow_core/native_config.h +84 -0
- package/cpp/update_flow_core/native_round.cpp +326 -0
- package/cpp/update_flow_core/native_round.h +90 -0
- package/cpp/update_flow_core/update_flow_core.h +2 -2
- package/harmony/hvigor-plugin.ts +11 -19
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +17 -26
- package/harmony/pushy/src/main/cpp/PushyPackage.h +2 -2
- package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +55 -94
- package/harmony/pushy/src/main/cpp/pushy.cpp +694 -517
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +48 -72
- package/harmony/pushy/src/main/ets/DownloadTask.ts +164 -404
- package/harmony/pushy/src/main/ets/DownloadTaskParams.ts +1 -3
- package/harmony/pushy/src/main/ets/ErrorCodes.ts +1 -14
- package/harmony/pushy/src/main/ets/EventHub.ts +1 -1
- package/harmony/pushy/src/main/ets/InstallRecord.ts +52 -151
- package/harmony/pushy/src/main/ets/Logger.ts +20 -34
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +116 -42
- package/harmony/pushy/src/main/ets/PushyConfiguration.ts +8 -85
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +11 -25
- package/harmony/pushy/src/main/ets/SaveFile.ts +99 -18
- package/harmony/pushy/src/main/ets/SyncCoordinator.ts +136 -335
- package/harmony/pushy/src/main/ets/Texts.ts +0 -4
- package/harmony/pushy/src/main/ets/UpdateContext.ts +106 -119
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy+Launch.mm +185 -0
- package/ios/RCTPushy/RCTPushy.h +12 -0
- package/ios/RCTPushy/RCTPushy.mm +87 -2634
- package/ios/RCTPushy/RCTPushyCommon.h +34 -0
- package/ios/RCTPushy/RCTPushyConfiguration.h +0 -8
- package/ios/RCTPushy/RCTPushyConfiguration.mm +40 -121
- package/ios/RCTPushy/RCTPushyDownloader.mm +40 -37
- package/ios/RCTPushy/RCTPushyInstallRecord.mm +61 -0
- package/ios/RCTPushy/RCTPushyInstaller.mm +689 -0
- package/ios/RCTPushy/RCTPushyInternal.h +144 -0
- package/ios/RCTPushy/RCTPushyOrchestrator.mm +1001 -0
- package/ios/RCTPushy/RCTPushyState.mm +314 -0
- package/package.json +25 -23
- package/react-native-update.podspec +73 -82
- package/src/client.ts +361 -451
- package/src/context.ts +1 -1
- package/src/core.ts +35 -8
- package/src/endpoint.ts +0 -2
- package/src/error.ts +13 -32
- package/src/i18n.ts +18 -83
- package/src/locales/en.ts +0 -4
- package/src/locales/zh.ts +0 -4
- package/src/provider.tsx +60 -53
- package/src/telemetry.ts +0 -13
- package/src/type.ts +0 -15
- package/src/updateFlowCore.ts +116 -10
- package/src/utils.ts +49 -42
- package/android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java +0 -6
- package/android/src/main/java/cn/reactnative/modules/update/PushyConfiguration.java +0 -104
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +0 -37
- package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +0 -121
- package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +0 -125
- package/cpp/patch_core/jni_natives.h +0 -27
- package/cpp/patch_core/jni_registration.cpp +0 -103
- package/cpp/patch_core/jni_util.h +0 -60
- package/cpp/patch_core/patch_core_android.cpp +0 -97
- package/cpp/patch_core/update_core_android.cpp +0 -485
- package/cpp/update_flow_core/update_flow_jni.cpp +0 -150
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#ifndef PUSHY_PATCH_CORE_JNI_NATIVES_H_
|
|
2
|
-
#define PUSHY_PATCH_CORE_JNI_NATIVES_H_
|
|
3
|
-
|
|
4
|
-
#include <jni.h>
|
|
5
|
-
|
|
6
|
-
// Android native methods. They are registered by name from JNI_OnLoad
|
|
7
|
-
// (jni_registration.cpp) instead of being exported as Java_* symbols, so the
|
|
8
|
-
// shared library's dynamic symbol table carries no class or method names.
|
|
9
|
-
namespace pushy {
|
|
10
|
-
namespace jni_natives {
|
|
11
|
-
|
|
12
|
-
jint SupportedDiffVersion(JNIEnv*, jclass);
|
|
13
|
-
jobject SyncStateWithBinaryVersion(JNIEnv* env, jclass, jstring package_version, jstring build_time, jobject state_result);
|
|
14
|
-
jobject RunStateCore(JNIEnv* env, jclass, jint operation, jobject state_result, jstring string_arg, jboolean flag_a, jboolean flag_b);
|
|
15
|
-
jobject BuildArchivePlan(JNIEnv* env, jclass, jint patch_type, jobjectArray entry_names, jobjectArray copy_froms, jobjectArray copy_tos, jobjectArray deletes);
|
|
16
|
-
jobjectArray BuildCopyGroups(JNIEnv* env, jclass, jobjectArray copy_froms, jobjectArray copy_tos);
|
|
17
|
-
void ApplyDeltaFromSource(JNIEnv* env, jclass, jstring source_root, jstring target_root, jstring origin_bundle_path, jstring bundle_patch_path, jstring bundle_output_path, jstring merge_source_subdir, jboolean enable_merge, jobjectArray copy_froms, jobjectArray copy_tos, jobjectArray deletes, jstring hbc_transform_meta);
|
|
18
|
-
void CleanupOldEntries(JNIEnv* env, jclass, jstring root_dir, jstring keep_current, jstring keep_previous, jint max_age_days);
|
|
19
|
-
jstring FlowBuildRequestBody(JNIEnv* env, jclass, jstring inputJson);
|
|
20
|
-
jstring FlowOrderEndpointCandidates(JNIEnv* env, jclass, jstring endpointsJson, jdouble randomSample);
|
|
21
|
-
jboolean FlowIsValidResponse(JNIEnv* env, jclass, jstring responseText);
|
|
22
|
-
jstring FlowHandleResponse(JNIEnv* env, jclass, jstring responseText, jstring identityJson, jstring afterDownload);
|
|
23
|
-
|
|
24
|
-
} // namespace jni_natives
|
|
25
|
-
} // namespace pushy
|
|
26
|
-
|
|
27
|
-
#endif // PUSHY_PATCH_CORE_JNI_NATIVES_H_
|
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <jni.h>
|
|
4
|
-
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <vector>
|
|
7
|
-
|
|
8
|
-
// Small JNI helpers shared by the Android glue translation units
|
|
9
|
-
// (patch_core_android.cpp and update_core_android.cpp). Header-only with inline
|
|
10
|
-
// linkage so both can include it without a separate compilation unit.
|
|
11
|
-
|
|
12
|
-
namespace pushy {
|
|
13
|
-
namespace jni_util {
|
|
14
|
-
|
|
15
|
-
inline std::string JStringToString(JNIEnv* env, jstring value) {
|
|
16
|
-
if (value == nullptr) {
|
|
17
|
-
return std::string();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const char* chars = env->GetStringUTFChars(value, nullptr);
|
|
21
|
-
if (chars == nullptr) {
|
|
22
|
-
return std::string();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
std::string result(chars);
|
|
26
|
-
env->ReleaseStringUTFChars(value, chars);
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
inline std::vector<std::string> JArrayToVector(
|
|
31
|
-
JNIEnv* env,
|
|
32
|
-
jobjectArray values) {
|
|
33
|
-
std::vector<std::string> result;
|
|
34
|
-
if (values == nullptr) {
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const jsize size = env->GetArrayLength(values);
|
|
39
|
-
result.reserve(static_cast<size_t>(size));
|
|
40
|
-
for (jsize index = 0; index < size; ++index) {
|
|
41
|
-
auto* item = static_cast<jstring>(env->GetObjectArrayElement(values, index));
|
|
42
|
-
result.push_back(JStringToString(env, item));
|
|
43
|
-
env->DeleteLocalRef(item);
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
inline void ThrowRuntimeException(JNIEnv* env, const char* message) {
|
|
49
|
-
jclass exception = env->FindClass("java/lang/RuntimeException");
|
|
50
|
-
if (exception != nullptr) {
|
|
51
|
-
env->ThrowNew(exception, message);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
inline void ThrowRuntimeException(JNIEnv* env, const std::string& message) {
|
|
56
|
-
ThrowRuntimeException(env, message.c_str());
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
} // namespace jni_util
|
|
60
|
-
} // namespace pushy
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
#include <jni.h>
|
|
2
|
-
|
|
3
|
-
#include "jni_natives.h"
|
|
4
|
-
|
|
5
|
-
#include <exception>
|
|
6
|
-
#include <string>
|
|
7
|
-
#include <vector>
|
|
8
|
-
|
|
9
|
-
#include "jni_util.h"
|
|
10
|
-
#include "patch_core.h"
|
|
11
|
-
|
|
12
|
-
namespace {
|
|
13
|
-
|
|
14
|
-
using pushy::jni_util::JArrayToVector;
|
|
15
|
-
using pushy::jni_util::JStringToString;
|
|
16
|
-
using pushy::jni_util::ThrowRuntimeException;
|
|
17
|
-
|
|
18
|
-
} // namespace
|
|
19
|
-
|
|
20
|
-
void pushy::jni_natives::ApplyDeltaFromSource(
|
|
21
|
-
JNIEnv* env,
|
|
22
|
-
jclass,
|
|
23
|
-
jstring source_root,
|
|
24
|
-
jstring target_root,
|
|
25
|
-
jstring origin_bundle_path,
|
|
26
|
-
jstring bundle_patch_path,
|
|
27
|
-
jstring bundle_output_path,
|
|
28
|
-
jstring merge_source_subdir,
|
|
29
|
-
jboolean enable_merge,
|
|
30
|
-
jobjectArray copy_froms,
|
|
31
|
-
jobjectArray copy_tos,
|
|
32
|
-
jobjectArray deletes,
|
|
33
|
-
jstring hbc_transform_meta) {
|
|
34
|
-
// C++ exceptions (bad_alloc/length_error from input-proportional STL
|
|
35
|
-
// allocations) must not unwind through the JNI boundary: convert them to a
|
|
36
|
-
// Java RuntimeException like every other failure of this entry point.
|
|
37
|
-
try {
|
|
38
|
-
const std::vector<std::string> from_values = JArrayToVector(env, copy_froms);
|
|
39
|
-
const std::vector<std::string> to_values = JArrayToVector(env, copy_tos);
|
|
40
|
-
|
|
41
|
-
if (from_values.size() != to_values.size()) {
|
|
42
|
-
ThrowRuntimeException(env, "copy_froms and copy_tos length mismatch");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pushy::delta::FileSourcePatchOptions options;
|
|
47
|
-
options.source_root = JStringToString(env, source_root);
|
|
48
|
-
options.target_root = JStringToString(env, target_root);
|
|
49
|
-
options.origin_bundle_path = JStringToString(env, origin_bundle_path);
|
|
50
|
-
options.bundle_patch_path = JStringToString(env, bundle_patch_path);
|
|
51
|
-
options.bundle_output_path = JStringToString(env, bundle_output_path);
|
|
52
|
-
options.merge_source_subdir = JStringToString(env, merge_source_subdir);
|
|
53
|
-
options.enable_merge = enable_merge == JNI_TRUE;
|
|
54
|
-
options.bundle_hbc_transform_meta = JStringToString(env, hbc_transform_meta);
|
|
55
|
-
|
|
56
|
-
for (size_t index = 0; index < from_values.size(); ++index) {
|
|
57
|
-
options.manifest.copies.push_back(pushy::delta::CopyOperation{
|
|
58
|
-
from_values[index],
|
|
59
|
-
to_values[index],
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
options.manifest.deletes = JArrayToVector(env, deletes);
|
|
63
|
-
|
|
64
|
-
const pushy::delta::Status status =
|
|
65
|
-
pushy::delta::ApplyPatchFromFileSource(options);
|
|
66
|
-
if (!status.ok) {
|
|
67
|
-
ThrowRuntimeException(env, status.message);
|
|
68
|
-
}
|
|
69
|
-
} catch (const std::exception& error) {
|
|
70
|
-
ThrowRuntimeException(env, error.what());
|
|
71
|
-
} catch (...) {
|
|
72
|
-
ThrowRuntimeException(env, "Unexpected native exception while applying delta");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
void pushy::jni_natives::CleanupOldEntries(
|
|
77
|
-
JNIEnv* env,
|
|
78
|
-
jclass,
|
|
79
|
-
jstring root_dir,
|
|
80
|
-
jstring keep_current,
|
|
81
|
-
jstring keep_previous,
|
|
82
|
-
jint max_age_days) {
|
|
83
|
-
try {
|
|
84
|
-
const pushy::delta::Status status = pushy::delta::CleanupOldEntries(
|
|
85
|
-
JStringToString(env, root_dir),
|
|
86
|
-
JStringToString(env, keep_current),
|
|
87
|
-
JStringToString(env, keep_previous),
|
|
88
|
-
static_cast<int>(max_age_days));
|
|
89
|
-
if (!status.ok) {
|
|
90
|
-
ThrowRuntimeException(env, status.message);
|
|
91
|
-
}
|
|
92
|
-
} catch (const std::exception& error) {
|
|
93
|
-
ThrowRuntimeException(env, error.what());
|
|
94
|
-
} catch (...) {
|
|
95
|
-
ThrowRuntimeException(env, "Unexpected native exception in cleanupOldEntries");
|
|
96
|
-
}
|
|
97
|
-
}
|