@revopush/react-native-code-push 1.5.0 → 2.5.0-rc.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/CodePush.js +8 -5
- package/CodePush.podspec +9 -0
- package/android/build.gradle +52 -40
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/android/gradle.properties +1 -1
- package/android/libs/revopush-diff-release-v0.0.1.aar +0 -0
- package/android/settings.gradle +31 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePush.java +8 -4
- package/android/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +11 -7
- package/android/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +48 -41
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +67 -175
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +7 -244
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +16 -51
- package/android/src/main/java/com/microsoft/codepush/react/FileUtils.java +1 -130
- package/ios/CodePush/CodePush.h +1 -30
- package/ios/CodePush/CodePush.m +23 -7
- package/ios/CodePush/CodePushPackage.m +363 -294
- package/ios/CodePush/CodePushUpdateUtils.m +77 -28
- package/ios/CodePush.xcodeproj/project.pbxproj +0 -18
- package/ios/Frameworks/DiffUpdates.xcframework/Info.plist +44 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64/DiffUpdates.framework/DiffUpdates +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64/DiffUpdates.framework/Headers/DiffUpdates.h +61 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64/DiffUpdates.framework/Info.plist +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64/DiffUpdates.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/DiffUpdates +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/Headers/DiffUpdates.h +61 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/Info.plist +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/_CodeSignature/CodeResources +132 -0
- package/ios/Frameworks/DiffUpdates.xcframework/ios-arm64_x86_64-simulator/DiffUpdates.framework/_CodeSignature/CodeSignature +0 -0
- package/package.json +2 -2
- package/request-fetch-adapter.js +2 -2
- package/scripts/generateBundledResourcesHash.js +102 -65
- package/android/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +0 -72
- package/ios/CodePush/CodePushDownloadHandler.m +0 -130
- package/ios/CodePush/CodePushErrorUtils.m +0 -20
- package/ios/CodePush/CodePushUtils.m +0 -9
|
@@ -15,11 +15,8 @@ import org.json.JSONArray;
|
|
|
15
15
|
import org.json.JSONException;
|
|
16
16
|
import org.json.JSONObject;
|
|
17
17
|
|
|
18
|
-
import java.io.BufferedReader;
|
|
19
18
|
import java.io.File;
|
|
20
19
|
import java.io.IOException;
|
|
21
|
-
import java.io.InputStream;
|
|
22
|
-
import java.io.InputStreamReader;
|
|
23
20
|
import java.util.Iterator;
|
|
24
21
|
|
|
25
22
|
public class CodePushUtils {
|
|
@@ -30,7 +27,7 @@ public class CodePushUtils {
|
|
|
30
27
|
|
|
31
28
|
public static WritableArray convertJsonArrayToWritable(JSONArray jsonArr) {
|
|
32
29
|
WritableArray arr = Arguments.createArray();
|
|
33
|
-
for (int i=0; i<jsonArr.length(); i++) {
|
|
30
|
+
for (int i = 0; i < jsonArr.length(); i++) {
|
|
34
31
|
Object obj = null;
|
|
35
32
|
try {
|
|
36
33
|
obj = jsonArr.get(i);
|
|
@@ -43,18 +40,12 @@ public class CodePushUtils {
|
|
|
43
40
|
arr.pushMap(convertJsonObjectToWritable((JSONObject) obj));
|
|
44
41
|
else if (obj instanceof JSONArray)
|
|
45
42
|
arr.pushArray(convertJsonArrayToWritable((JSONArray) obj));
|
|
46
|
-
else if (obj instanceof String)
|
|
47
|
-
|
|
48
|
-
else if (obj instanceof
|
|
49
|
-
|
|
50
|
-
else if (obj
|
|
51
|
-
|
|
52
|
-
else if (obj instanceof Boolean)
|
|
53
|
-
arr.pushBoolean((Boolean) obj);
|
|
54
|
-
else if (obj == null)
|
|
55
|
-
arr.pushNull();
|
|
56
|
-
else
|
|
57
|
-
throw new CodePushUnknownException("Unrecognized object: " + obj);
|
|
43
|
+
else if (obj instanceof String) arr.pushString((String) obj);
|
|
44
|
+
else if (obj instanceof Double) arr.pushDouble((Double) obj);
|
|
45
|
+
else if (obj instanceof Integer) arr.pushInt((Integer) obj);
|
|
46
|
+
else if (obj instanceof Boolean) arr.pushBoolean((Boolean) obj);
|
|
47
|
+
else if (obj == null) arr.pushNull();
|
|
48
|
+
else throw new CodePushUnknownException("Unrecognized object: " + obj);
|
|
58
49
|
}
|
|
59
50
|
|
|
60
51
|
return arr;
|
|
@@ -63,7 +54,7 @@ public class CodePushUtils {
|
|
|
63
54
|
public static WritableMap convertJsonObjectToWritable(JSONObject jsonObj) {
|
|
64
55
|
WritableMap map = Arguments.createMap();
|
|
65
56
|
Iterator<String> it = jsonObj.keys();
|
|
66
|
-
while(it.hasNext()){
|
|
57
|
+
while (it.hasNext()) {
|
|
67
58
|
String key = it.next();
|
|
68
59
|
Object obj = null;
|
|
69
60
|
try {
|
|
@@ -79,20 +70,13 @@ public class CodePushUtils {
|
|
|
79
70
|
map.putMap(key, convertJsonObjectToWritable((JSONObject) obj));
|
|
80
71
|
else if (obj instanceof JSONArray)
|
|
81
72
|
map.putArray(key, convertJsonArrayToWritable((JSONArray) obj));
|
|
82
|
-
else if (obj instanceof String)
|
|
83
|
-
|
|
84
|
-
else if (obj instanceof
|
|
85
|
-
|
|
86
|
-
else if (obj instanceof
|
|
87
|
-
|
|
88
|
-
else
|
|
89
|
-
map.putInt(key, (Integer) obj);
|
|
90
|
-
else if (obj instanceof Boolean)
|
|
91
|
-
map.putBoolean(key, (Boolean) obj);
|
|
92
|
-
else if (obj == null)
|
|
93
|
-
map.putNull(key);
|
|
94
|
-
else
|
|
95
|
-
throw new CodePushUnknownException("Unrecognized object: " + obj);
|
|
73
|
+
else if (obj instanceof String) map.putString(key, (String) obj);
|
|
74
|
+
else if (obj instanceof Double) map.putDouble(key, (Double) obj);
|
|
75
|
+
else if (obj instanceof Long) map.putDouble(key, ((Long) obj).doubleValue());
|
|
76
|
+
else if (obj instanceof Integer) map.putInt(key, (Integer) obj);
|
|
77
|
+
else if (obj instanceof Boolean) map.putBoolean(key, (Boolean) obj);
|
|
78
|
+
else if (obj == null) map.putNull(key);
|
|
79
|
+
else throw new CodePushUnknownException("Unrecognized object: " + obj);
|
|
96
80
|
}
|
|
97
81
|
|
|
98
82
|
return map;
|
|
@@ -100,7 +84,7 @@ public class CodePushUtils {
|
|
|
100
84
|
|
|
101
85
|
public static JSONArray convertReadableToJsonArray(ReadableArray arr) {
|
|
102
86
|
JSONArray jsonArr = new JSONArray();
|
|
103
|
-
for (int i=0; i<arr.size(); i++) {
|
|
87
|
+
for (int i = 0; i < arr.size(); i++) {
|
|
104
88
|
ReadableType type = arr.getType(i);
|
|
105
89
|
switch (type) {
|
|
106
90
|
case Map:
|
|
@@ -174,25 +158,6 @@ public class CodePushUtils {
|
|
|
174
158
|
return jsonObj;
|
|
175
159
|
}
|
|
176
160
|
|
|
177
|
-
public static String getStringFromInputStream(InputStream inputStream) throws IOException {
|
|
178
|
-
BufferedReader bufferedReader = null;
|
|
179
|
-
try {
|
|
180
|
-
StringBuilder buffer = new StringBuilder();
|
|
181
|
-
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
|
182
|
-
|
|
183
|
-
String line;
|
|
184
|
-
while ((line = bufferedReader.readLine()) != null) {
|
|
185
|
-
buffer.append(line);
|
|
186
|
-
buffer.append("\n");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return buffer.toString().trim();
|
|
190
|
-
} finally {
|
|
191
|
-
if (bufferedReader != null) bufferedReader.close();
|
|
192
|
-
if (inputStream != null) inputStream.close();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
161
|
public static JSONObject getJsonObjectFromFile(String filePath) throws IOException {
|
|
197
162
|
String content = FileUtils.readFileToString(filePath);
|
|
198
163
|
try {
|
|
@@ -1,59 +1,14 @@
|
|
|
1
1
|
package com.microsoft.codepush.react;
|
|
2
2
|
|
|
3
|
-
import java.io.BufferedInputStream;
|
|
4
3
|
import java.io.BufferedReader;
|
|
5
4
|
import java.io.File;
|
|
6
5
|
import java.io.FileInputStream;
|
|
7
|
-
import java.io.FileOutputStream;
|
|
8
6
|
import java.io.IOException;
|
|
9
7
|
import java.io.InputStreamReader;
|
|
10
8
|
import java.io.PrintWriter;
|
|
11
|
-
import java.util.zip.ZipEntry;
|
|
12
|
-
import java.util.zip.ZipInputStream;
|
|
13
9
|
|
|
14
10
|
public class FileUtils {
|
|
15
11
|
|
|
16
|
-
private static final int WRITE_BUFFER_SIZE = 1024 * 8;
|
|
17
|
-
|
|
18
|
-
public static void copyDirectoryContents(String sourceDirectoryPath, String destinationDirectoryPath) throws IOException {
|
|
19
|
-
File sourceDir = new File(sourceDirectoryPath);
|
|
20
|
-
File destDir = new File(destinationDirectoryPath);
|
|
21
|
-
if (!destDir.exists()) {
|
|
22
|
-
destDir.mkdir();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
for (File sourceFile : sourceDir.listFiles()) {
|
|
26
|
-
if (sourceFile.isDirectory()) {
|
|
27
|
-
copyDirectoryContents(
|
|
28
|
-
CodePushUtils.appendPathComponent(sourceDirectoryPath, sourceFile.getName()),
|
|
29
|
-
CodePushUtils.appendPathComponent(destinationDirectoryPath, sourceFile.getName()));
|
|
30
|
-
} else {
|
|
31
|
-
File destFile = new File(destDir, sourceFile.getName());
|
|
32
|
-
FileInputStream fromFileStream = null;
|
|
33
|
-
BufferedInputStream fromBufferedStream = null;
|
|
34
|
-
FileOutputStream destStream = null;
|
|
35
|
-
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
|
|
36
|
-
try {
|
|
37
|
-
fromFileStream = new FileInputStream(sourceFile);
|
|
38
|
-
fromBufferedStream = new BufferedInputStream(fromFileStream);
|
|
39
|
-
destStream = new FileOutputStream(destFile);
|
|
40
|
-
int bytesRead;
|
|
41
|
-
while ((bytesRead = fromBufferedStream.read(buffer)) > 0) {
|
|
42
|
-
destStream.write(buffer, 0, bytesRead);
|
|
43
|
-
}
|
|
44
|
-
} finally {
|
|
45
|
-
try {
|
|
46
|
-
if (fromFileStream != null) fromFileStream.close();
|
|
47
|
-
if (fromBufferedStream != null) fromBufferedStream.close();
|
|
48
|
-
if (destStream != null) destStream.close();
|
|
49
|
-
} catch (IOException e) {
|
|
50
|
-
throw new CodePushUnknownException("Error closing IO resources.", e);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
12
|
public static void deleteDirectoryAtPath(String directoryPath) {
|
|
58
13
|
if (directoryPath == null) {
|
|
59
14
|
CodePushUtils.log("deleteDirectoryAtPath attempted with null directoryPath");
|
|
@@ -90,18 +45,6 @@ public class FileUtils {
|
|
|
90
45
|
return new File(filePath).exists();
|
|
91
46
|
}
|
|
92
47
|
|
|
93
|
-
public static void moveFile(File fileToMove, String newFolderPath, String newFileName) {
|
|
94
|
-
File newFolder = new File(newFolderPath);
|
|
95
|
-
if (!newFolder.exists()) {
|
|
96
|
-
newFolder.mkdirs();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
File newFilePath = new File(newFolderPath, newFileName);
|
|
100
|
-
if (!fileToMove.renameTo(newFilePath)) {
|
|
101
|
-
throw new CodePushUnknownException("Unable to move file from " +
|
|
102
|
-
fileToMove.getAbsolutePath() + " to " + newFilePath.getAbsolutePath() + ".");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
48
|
|
|
106
49
|
public static String readFileToString(String filePath) throws IOException {
|
|
107
50
|
FileInputStream fin = null;
|
|
@@ -123,81 +66,9 @@ public class FileUtils {
|
|
|
123
66
|
}
|
|
124
67
|
}
|
|
125
68
|
|
|
126
|
-
private static String validateFileName(String fileName, File destinationFolder) throws IOException {
|
|
127
|
-
String destinationFolderCanonicalPath = destinationFolder.getCanonicalPath() + File.separator;
|
|
128
|
-
|
|
129
|
-
File file = new File(destinationFolderCanonicalPath, fileName);
|
|
130
|
-
String canonicalPath = file.getCanonicalPath();
|
|
131
|
-
|
|
132
|
-
if (!canonicalPath.startsWith(destinationFolderCanonicalPath)) {
|
|
133
|
-
throw new IllegalStateException("File is outside extraction target directory.");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return canonicalPath;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public static void unzipFile(File zipFile, String destination) throws IOException {
|
|
140
|
-
FileInputStream fileStream = null;
|
|
141
|
-
BufferedInputStream bufferedStream = null;
|
|
142
|
-
ZipInputStream zipStream = null;
|
|
143
|
-
try {
|
|
144
|
-
fileStream = new FileInputStream(zipFile);
|
|
145
|
-
bufferedStream = new BufferedInputStream(fileStream);
|
|
146
|
-
zipStream = new ZipInputStream(bufferedStream);
|
|
147
|
-
ZipEntry entry;
|
|
148
|
-
|
|
149
|
-
File destinationFolder = new File(destination);
|
|
150
|
-
if (destinationFolder.exists()) {
|
|
151
|
-
deleteFileOrFolderSilently(destinationFolder);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
destinationFolder.mkdirs();
|
|
155
|
-
|
|
156
|
-
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
|
|
157
|
-
while ((entry = zipStream.getNextEntry()) != null) {
|
|
158
|
-
String fileName = validateFileName(entry.getName(), destinationFolder);
|
|
159
|
-
File file = new File(fileName);
|
|
160
|
-
if (entry.isDirectory()) {
|
|
161
|
-
file.mkdirs();
|
|
162
|
-
} else {
|
|
163
|
-
File parent = file.getParentFile();
|
|
164
|
-
if (!parent.exists()) {
|
|
165
|
-
parent.mkdirs();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
FileOutputStream fout = new FileOutputStream(file);
|
|
169
|
-
try {
|
|
170
|
-
int numBytesRead;
|
|
171
|
-
while ((numBytesRead = zipStream.read(buffer)) != -1) {
|
|
172
|
-
fout.write(buffer, 0, numBytesRead);
|
|
173
|
-
}
|
|
174
|
-
} finally {
|
|
175
|
-
fout.close();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
long time = entry.getTime();
|
|
179
|
-
if (time > 0) {
|
|
180
|
-
file.setLastModified(time);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
} finally {
|
|
184
|
-
try {
|
|
185
|
-
if (zipStream != null) zipStream.close();
|
|
186
|
-
if (bufferedStream != null) bufferedStream.close();
|
|
187
|
-
if (fileStream != null) fileStream.close();
|
|
188
|
-
} catch (IOException e) {
|
|
189
|
-
throw new CodePushUnknownException("Error closing IO resources.", e);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
69
|
public static void writeStringToFile(String content, String filePath) throws IOException {
|
|
195
|
-
PrintWriter out =
|
|
196
|
-
try {
|
|
197
|
-
out = new PrintWriter(filePath);
|
|
70
|
+
try (PrintWriter out = new PrintWriter(filePath)) {
|
|
198
71
|
out.print(content);
|
|
199
|
-
} finally {
|
|
200
|
-
if (out != null) out.close();
|
|
201
72
|
}
|
|
202
73
|
}
|
|
203
74
|
}
|
package/ios/CodePush/CodePush.h
CHANGED
|
@@ -108,34 +108,6 @@
|
|
|
108
108
|
|
|
109
109
|
@end
|
|
110
110
|
|
|
111
|
-
@interface CodePushDownloadHandler : NSObject <NSURLConnectionDelegate>
|
|
112
|
-
|
|
113
|
-
@property (strong) NSOutputStream *outputFileStream;
|
|
114
|
-
@property long long expectedContentLength;
|
|
115
|
-
@property long long receivedContentLength;
|
|
116
|
-
@property dispatch_queue_t operationQueue;
|
|
117
|
-
@property (copy) void (^progressCallback)(long long, long long);
|
|
118
|
-
@property (copy) void (^doneCallback)(BOOL);
|
|
119
|
-
@property (copy) void (^failCallback)(NSError *err);
|
|
120
|
-
@property NSString *downloadUrl;
|
|
121
|
-
|
|
122
|
-
- (id)init:(NSString *)downloadFilePath
|
|
123
|
-
operationQueue:(dispatch_queue_t)operationQueue
|
|
124
|
-
progressCallback:(void (^)(long long, long long))progressCallback
|
|
125
|
-
doneCallback:(void (^)(BOOL))doneCallback
|
|
126
|
-
failCallback:(void (^)(NSError *err))failCallback;
|
|
127
|
-
|
|
128
|
-
- (void)download:(NSString*)url;
|
|
129
|
-
|
|
130
|
-
@end
|
|
131
|
-
|
|
132
|
-
@interface CodePushErrorUtils : NSObject
|
|
133
|
-
|
|
134
|
-
+ (NSError *)errorWithMessage:(NSString *)errorMessage;
|
|
135
|
-
+ (BOOL)isCodePushError:(NSError *)error;
|
|
136
|
-
|
|
137
|
-
@end
|
|
138
|
-
|
|
139
111
|
@interface CodePushPackage : NSObject
|
|
140
112
|
|
|
141
113
|
+ (void)downloadPackage:(NSDictionary *)updatePackage
|
|
@@ -193,6 +165,7 @@ failCallback:(void (^)(NSError *err))failCallback;
|
|
|
193
165
|
+ (NSString *)assetsFolderName;
|
|
194
166
|
+ (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
|
|
195
167
|
error:(NSError **)error;
|
|
168
|
+
+ (NSString *)getHashForBinaryAssets:(NSError **)error;
|
|
196
169
|
|
|
197
170
|
+ (NSString *)manifestFolderPrefix;
|
|
198
171
|
+ (NSString *)modifiedDateStringOfFileAtURL:(NSURL *)fileURL;
|
|
@@ -219,8 +192,6 @@ failCallback:(void (^)(NSError *err))failCallback;
|
|
|
219
192
|
|
|
220
193
|
@end
|
|
221
194
|
|
|
222
|
-
void CPLog(NSString *formatString, ...);
|
|
223
|
-
|
|
224
195
|
typedef NS_ENUM(NSInteger, CodePushInstallMode) {
|
|
225
196
|
CodePushInstallModeImmediate,
|
|
226
197
|
CodePushInstallModeOnNextRestart,
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
#import "RCTUtils.h"
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
|
+
#import <DiffUpdates/DiffUpdates.h>
|
|
19
|
+
|
|
18
20
|
#import "CodePush.h"
|
|
19
21
|
|
|
20
22
|
@interface CodePush () <RCTBridgeModule, RCTFrameUpdateObserver>
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
long long _latestExpectedContentLength;
|
|
33
35
|
long long _latestReceivedConentLength;
|
|
34
36
|
BOOL _didUpdateProgress;
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
BOOL _allowed;
|
|
37
39
|
BOOL _restartInProgress;
|
|
38
40
|
NSMutableArray *_restartQueue;
|
|
@@ -52,6 +54,7 @@ static NSString *const DeploymentSucceeded = @"DeploymentSucceeded";
|
|
|
52
54
|
// These keys represent the names we use to store data in NSUserDefaults
|
|
53
55
|
static NSString *const FailedUpdatesKey = @"CODE_PUSH_FAILED_UPDATES";
|
|
54
56
|
static NSString *const PendingUpdateKey = @"CODE_PUSH_PENDING_UPDATE";
|
|
57
|
+
static NSString *const DiffFailedUpdatesKey = @"CODE_PUSH_DIFF_FAILED_UPDATES";
|
|
55
58
|
|
|
56
59
|
// These keys are already "namespaced" by the PendingUpdateKey, so
|
|
57
60
|
// their values don't need to be obfuscated to prevent collision with app data
|
|
@@ -377,7 +380,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
377
380
|
_allowed = YES;
|
|
378
381
|
_restartInProgress = NO;
|
|
379
382
|
_restartQueue = [NSMutableArray arrayWithCapacity:1];
|
|
380
|
-
|
|
383
|
+
|
|
381
384
|
self = [super init];
|
|
382
385
|
if (self) {
|
|
383
386
|
[self initializeUpdateAfterRestart];
|
|
@@ -583,7 +586,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
583
586
|
if ([[self class] isFailedHash:[failedPackage objectForKey:PackageHashKey]]) {
|
|
584
587
|
return;
|
|
585
588
|
}
|
|
586
|
-
|
|
589
|
+
|
|
587
590
|
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
|
588
591
|
NSMutableArray *failedUpdates = [preferences objectForKey:FailedUpdatesKey];
|
|
589
592
|
if (failedUpdates == nil) {
|
|
@@ -753,12 +756,14 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
|
|
|
753
756
|
NSDictionary *newPackage = [CodePushPackage getPackage:mutableUpdatePackage[PackageHashKey] error:&err];
|
|
754
757
|
|
|
755
758
|
if (err) {
|
|
759
|
+
CPLog(@"CodePushPackage doneCallback: %@", err);
|
|
756
760
|
return reject([NSString stringWithFormat: @"%lu", (long)err.code], err.localizedDescription, err);
|
|
757
761
|
}
|
|
758
762
|
resolve(newPackage);
|
|
759
763
|
}
|
|
760
764
|
// The download failed
|
|
761
765
|
failCallback:^(NSError *err) {
|
|
766
|
+
CPLog(@"CodePushPackage failCallback: %@", err);
|
|
762
767
|
if ([CodePushErrorUtils isCodePushError:err]) {
|
|
763
768
|
[self saveFailedUpdate:mutableUpdatePackage];
|
|
764
769
|
}
|
|
@@ -818,15 +823,24 @@ RCT_EXPORT_METHOD(getConfiguration:(RCTPromiseResolveBlock)resolve
|
|
|
818
823
|
}
|
|
819
824
|
|
|
820
825
|
if (binaryHash == nil) {
|
|
821
|
-
// The hash was not generated either due to a previous unknown error or the fact that
|
|
822
|
-
// the React Native assets were not bundled in the binary (e.g. during dev/simulator)
|
|
823
|
-
// builds.
|
|
824
826
|
resolve(configuration);
|
|
825
827
|
return;
|
|
826
828
|
}
|
|
827
829
|
|
|
828
830
|
NSMutableDictionary *mutableConfiguration = [configuration mutableCopy];
|
|
829
831
|
[mutableConfiguration setObject:binaryHash forKey:PackageHashKey];
|
|
832
|
+
|
|
833
|
+
CPLog(@"Package binary hash: %@", binaryHash);
|
|
834
|
+
|
|
835
|
+
NSError *assetsError = nil;
|
|
836
|
+
NSString *assetHash = [CodePushUpdateUtils getHashForBinaryAssets:&assetsError];
|
|
837
|
+
if (assetsError) {
|
|
838
|
+
CPLog(@"Error obtaining hash for assets contents: %@", assetsError);
|
|
839
|
+
} else if (assetHash != nil) {
|
|
840
|
+
CPLog(@"Asset binary hash: %@", assetHash);
|
|
841
|
+
[mutableConfiguration setObject:assetHash forKey:@"assetHash"];
|
|
842
|
+
}
|
|
843
|
+
|
|
830
844
|
resolve(mutableConfiguration);
|
|
831
845
|
return;
|
|
832
846
|
}
|
|
@@ -844,6 +858,8 @@ RCT_EXPORT_METHOD(getUpdateMetadata:(CodePushUpdateState)updateState
|
|
|
844
858
|
NSError *error;
|
|
845
859
|
NSMutableDictionary *package = [[CodePushPackage getCurrentPackage:&error] mutableCopy];
|
|
846
860
|
|
|
861
|
+
CPLog(@"Current package: %@", package);
|
|
862
|
+
|
|
847
863
|
if (error) {
|
|
848
864
|
return reject([NSString stringWithFormat: @"%lu", (long)error.code], error.localizedDescription, error);
|
|
849
865
|
} else if (package == nil) {
|
|
@@ -914,7 +930,7 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
|
|
|
914
930
|
selector:@selector(applicationDidBecomeActive)
|
|
915
931
|
name:UIApplicationDidBecomeActiveNotification
|
|
916
932
|
object:RCTSharedApplication()];
|
|
917
|
-
|
|
933
|
+
|
|
918
934
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
919
935
|
selector:@selector(applicationWillEnterForeground)
|
|
920
936
|
name:UIApplicationWillEnterForegroundNotification
|