@hot-updater/react-native 0.27.0 → 0.28.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/android/build.gradle +12 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/cpp/CMakeLists.txt +9 -0
- package/android/src/main/cpp/HotUpdaterRecovery.cpp +143 -0
- package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +170 -204
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +73 -16
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +39 -13
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +533 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryReceiver.kt +14 -0
- package/android/src/newarch/HotUpdaterModule.kt +2 -8
- package/android/src/oldarch/HotUpdaterModule.kt +2 -8
- package/android/src/oldarch/HotUpdaterSpec.kt +1 -1
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +189 -203
- package/ios/HotUpdater/Internal/BundleMetadata.swift +61 -8
- package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +9 -1
- package/ios/HotUpdater/Internal/HotUpdater.mm +265 -11
- package/ios/HotUpdater/Internal/HotUpdaterCrashHandler.h +7 -0
- package/ios/HotUpdater/Internal/HotUpdaterCrashHandler.mm +4 -0
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +293 -9
- package/lib/commonjs/native.js +18 -21
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/native.spec.js +86 -0
- package/lib/commonjs/native.spec.js.map +1 -0
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/wrap.js +4 -5
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/native.js +17 -20
- package/lib/module/native.js.map +1 -1
- package/lib/module/native.spec.js +85 -0
- package/lib/module/native.spec.js.map +1 -0
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/wrap.js +5 -6
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +4 -15
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.spec.d.ts +2 -0
- package/lib/typescript/commonjs/native.spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +4 -8
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +2 -3
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.d.ts +2 -5
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +4 -15
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/native.spec.d.ts +2 -0
- package/lib/typescript/module/native.spec.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +4 -8
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +2 -3
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/wrap.d.ts +2 -5
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/native.spec.ts +84 -0
- package/src/native.ts +20 -19
- package/src/specs/NativeHotUpdater.ts +4 -6
- package/src/types.ts +2 -3
- package/src/wrap.tsx +7 -11
package/android/build.gradle
CHANGED
|
@@ -69,6 +69,12 @@ android {
|
|
|
69
69
|
consumerProguardFiles 'proguard-rules.pro'
|
|
70
70
|
buildConfigField "long", "BUILD_TIMESTAMP", "${System.currentTimeMillis()}L"
|
|
71
71
|
|
|
72
|
+
externalNativeBuild {
|
|
73
|
+
cmake {
|
|
74
|
+
arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
def minBundleId = project.hasProperty("MIN_BUNDLE_ID") ? project.properties["MIN_BUNDLE_ID"] : null
|
|
73
79
|
buildConfigField "String", "MIN_BUNDLE_ID", minBundleId == null ? "\"null\"" : "\"${minBundleId}\""
|
|
74
80
|
}
|
|
@@ -106,6 +112,12 @@ android {
|
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
}
|
|
115
|
+
|
|
116
|
+
externalNativeBuild {
|
|
117
|
+
cmake {
|
|
118
|
+
path file("src/main/cpp/CMakeLists.txt")
|
|
119
|
+
}
|
|
120
|
+
}
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
repositories {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="com.hotupdater">
|
|
3
3
|
<application>
|
|
4
|
+
<receiver
|
|
5
|
+
android:name="com.hotupdater.HotUpdaterRecoveryReceiver"
|
|
6
|
+
android:exported="false" />
|
|
4
7
|
<activity
|
|
5
8
|
android:name="com.hotupdater.HotUpdaterRestartActivity"
|
|
6
9
|
android:excludeFromRecents="true"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
2
|
<application>
|
|
3
|
+
<receiver
|
|
4
|
+
android:name="com.hotupdater.HotUpdaterRecoveryReceiver"
|
|
5
|
+
android:exported="false" />
|
|
3
6
|
<activity
|
|
4
7
|
android:name="com.hotupdater.HotUpdaterRestartActivity"
|
|
5
8
|
android:excludeFromRecents="true"
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#include <jni.h>
|
|
2
|
+
#include <signal.h>
|
|
3
|
+
#include <unistd.h>
|
|
4
|
+
#include <fcntl.h>
|
|
5
|
+
#include <cstring>
|
|
6
|
+
#include <limits.h>
|
|
7
|
+
|
|
8
|
+
namespace {
|
|
9
|
+
constexpr size_t kMaxBundleIdLength = 128;
|
|
10
|
+
constexpr int kSignals[] = {SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP};
|
|
11
|
+
|
|
12
|
+
char gCrashMarkerPath[PATH_MAX] = {0};
|
|
13
|
+
char gBundleId[kMaxBundleIdLength] = {0};
|
|
14
|
+
volatile sig_atomic_t gShouldRollback = 0;
|
|
15
|
+
struct sigaction gPreviousActions[NSIG];
|
|
16
|
+
|
|
17
|
+
void signalHandler(int signum, siginfo_t *info, void *context);
|
|
18
|
+
|
|
19
|
+
size_t safeStringLength(const char *value, size_t maxLength) {
|
|
20
|
+
size_t length = 0;
|
|
21
|
+
while (length < maxLength && value[length] != '\0') {
|
|
22
|
+
++length;
|
|
23
|
+
}
|
|
24
|
+
return length;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void safeCopy(char *destination, size_t destinationSize, const char *source) {
|
|
28
|
+
if (destinationSize == 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
size_t index = 0;
|
|
33
|
+
while (index + 1 < destinationSize && source[index] != '\0') {
|
|
34
|
+
destination[index] = source[index];
|
|
35
|
+
++index;
|
|
36
|
+
}
|
|
37
|
+
destination[index] = '\0';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void safeCopyJString(JNIEnv *env, jstring source, char *destination, size_t destinationSize) {
|
|
41
|
+
if (source == nullptr) {
|
|
42
|
+
destination[0] = '\0';
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const char *utfChars = env->GetStringUTFChars(source, nullptr);
|
|
47
|
+
if (utfChars == nullptr) {
|
|
48
|
+
destination[0] = '\0';
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
safeCopy(destination, destinationSize, utfChars);
|
|
53
|
+
env->ReleaseStringUTFChars(source, utfChars);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void writeCrashMarker() {
|
|
57
|
+
if (gCrashMarkerPath[0] == '\0') {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const int fd = open(gCrashMarkerPath, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
|
62
|
+
if (fd < 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
constexpr char prefix[] = "{\"bundleId\":\"";
|
|
67
|
+
constexpr char middle[] = "\",\"shouldRollback\":";
|
|
68
|
+
constexpr char trueLiteral[] = "true";
|
|
69
|
+
constexpr char falseLiteral[] = "false";
|
|
70
|
+
constexpr char suffix[] = "}\n";
|
|
71
|
+
|
|
72
|
+
write(fd, prefix, sizeof(prefix) - 1);
|
|
73
|
+
if (gBundleId[0] != '\0') {
|
|
74
|
+
write(fd, gBundleId, safeStringLength(gBundleId, kMaxBundleIdLength));
|
|
75
|
+
}
|
|
76
|
+
write(fd, middle, sizeof(middle) - 1);
|
|
77
|
+
if (gShouldRollback != 0) {
|
|
78
|
+
write(fd, trueLiteral, sizeof(trueLiteral) - 1);
|
|
79
|
+
} else {
|
|
80
|
+
write(fd, falseLiteral, sizeof(falseLiteral) - 1);
|
|
81
|
+
}
|
|
82
|
+
write(fd, suffix, sizeof(suffix) - 1);
|
|
83
|
+
close(fd);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void forwardToPreviousHandler(int signum, siginfo_t *info, void *context) {
|
|
87
|
+
const struct sigaction &previousAction = gPreviousActions[signum];
|
|
88
|
+
|
|
89
|
+
if ((previousAction.sa_flags & SA_SIGINFO) != 0 && previousAction.sa_sigaction != nullptr &&
|
|
90
|
+
previousAction.sa_sigaction != signalHandler) {
|
|
91
|
+
previousAction.sa_sigaction(signum, info, context);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (previousAction.sa_handler == SIG_IGN) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (previousAction.sa_handler != nullptr && previousAction.sa_handler != SIG_DFL &&
|
|
100
|
+
previousAction.sa_handler != SIG_ERR) {
|
|
101
|
+
previousAction.sa_handler(signum);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
struct sigaction defaultAction {};
|
|
106
|
+
defaultAction.sa_handler = SIG_DFL;
|
|
107
|
+
sigemptyset(&defaultAction.sa_mask);
|
|
108
|
+
sigaction(signum, &defaultAction, nullptr);
|
|
109
|
+
raise(signum);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void signalHandler(int signum, siginfo_t *info, void *context) {
|
|
113
|
+
writeCrashMarker();
|
|
114
|
+
forwardToPreviousHandler(signum, info, context);
|
|
115
|
+
}
|
|
116
|
+
} // namespace
|
|
117
|
+
|
|
118
|
+
extern "C" JNIEXPORT void JNICALL
|
|
119
|
+
Java_com_hotupdater_HotUpdaterRecoveryManager_nativeInstallSignalHandler(
|
|
120
|
+
JNIEnv *env,
|
|
121
|
+
jobject /* this */,
|
|
122
|
+
jstring crashMarkerPath) {
|
|
123
|
+
safeCopyJString(env, crashMarkerPath, gCrashMarkerPath, sizeof(gCrashMarkerPath));
|
|
124
|
+
|
|
125
|
+
struct sigaction action {};
|
|
126
|
+
action.sa_sigaction = signalHandler;
|
|
127
|
+
action.sa_flags = SA_SIGINFO | SA_ONSTACK;
|
|
128
|
+
sigemptyset(&action.sa_mask);
|
|
129
|
+
|
|
130
|
+
for (const int signum : kSignals) {
|
|
131
|
+
sigaction(signum, &action, &gPreviousActions[signum]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
extern "C" JNIEXPORT void JNICALL
|
|
136
|
+
Java_com_hotupdater_HotUpdaterRecoveryManager_nativeUpdateLaunchState(
|
|
137
|
+
JNIEnv *env,
|
|
138
|
+
jobject /* this */,
|
|
139
|
+
jstring bundleId,
|
|
140
|
+
jboolean shouldRollback) {
|
|
141
|
+
safeCopyJString(env, bundleId, gBundleId, sizeof(gBundleId));
|
|
142
|
+
gShouldRollback = shouldRollback ? 1 : 0;
|
|
143
|
+
}
|