@capgo/capacitor-updater 4.14.8 → 4.14.16
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.md
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|

|
|
6
6
|
[](https://GitHub.com/Cap-go/capacitor-updater/commit/)
|
|
7
7
|
[](https://good-labs.github.io/greater-good-affirmation)
|
|
8
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
9
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
10
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
11
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
12
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
13
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
14
|
+
[](https://sonarcloud.io/summary/new_code?id=Cap-go_capacitor-updater)
|
|
8
15
|
|
|
9
16
|
Update Ionic Capacitor apps without App/Play Store review (Code-push / hot-code updates).
|
|
10
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="ee.forgr.capacitor_updater">
|
|
3
|
-
<application android:
|
|
3
|
+
<application android:usesCleartextTraffic="false">
|
|
4
4
|
<service android:name="ee.forgr.capacitor_updater.DownloadService" />
|
|
5
5
|
</application>
|
|
6
6
|
</manifest>
|
|
@@ -63,7 +63,7 @@ public class CapacitorUpdater {
|
|
|
63
63
|
private static final String bundleDirectory = "versions";
|
|
64
64
|
|
|
65
65
|
public static final String TAG = "Capacitor-updater";
|
|
66
|
-
public static final String pluginVersion = "4.14.
|
|
66
|
+
public static final String pluginVersion = "4.14.16";
|
|
67
67
|
|
|
68
68
|
public SharedPreferences.Editor editor;
|
|
69
69
|
public SharedPreferences prefs;
|
|
@@ -278,12 +278,20 @@ public class CapacitorUpdater {
|
|
|
278
278
|
" " +
|
|
279
279
|
checksum
|
|
280
280
|
);
|
|
281
|
-
|
|
281
|
+
if (dest == null) {
|
|
282
|
+
CapacitorUpdater.this.sendStats(
|
|
283
|
+
"download_fail",
|
|
284
|
+
CapacitorUpdater.this.getCurrentBundle().getVersionName()
|
|
285
|
+
);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
CapacitorUpdater.this.finishDownload(
|
|
282
289
|
id,
|
|
283
290
|
dest,
|
|
284
291
|
version,
|
|
285
292
|
sessionKey,
|
|
286
|
-
checksum
|
|
293
|
+
checksum,
|
|
294
|
+
true
|
|
287
295
|
);
|
|
288
296
|
} else {
|
|
289
297
|
Log.i(TAG, "Unknown action " + action);
|
|
@@ -292,19 +300,19 @@ public class CapacitorUpdater {
|
|
|
292
300
|
}
|
|
293
301
|
};
|
|
294
302
|
|
|
295
|
-
public void
|
|
303
|
+
public void finishDownload(
|
|
296
304
|
String id,
|
|
297
305
|
String dest,
|
|
298
306
|
String version,
|
|
299
307
|
String sessionKey,
|
|
300
|
-
String checksumRes
|
|
308
|
+
String checksumRes,
|
|
309
|
+
Boolean setNext
|
|
301
310
|
) {
|
|
302
311
|
try {
|
|
303
312
|
final File downloaded = new File(this.documentsDir, dest);
|
|
304
313
|
this.decryptFile(downloaded, sessionKey);
|
|
305
314
|
final String checksum;
|
|
306
315
|
checksum = this.getChecksum(downloaded);
|
|
307
|
-
|
|
308
316
|
this.notifyDownload(id, 71);
|
|
309
317
|
final File unzipped = this.unzip(id, downloaded, this.randomString(10));
|
|
310
318
|
downloaded.delete();
|
|
@@ -339,9 +347,15 @@ public class CapacitorUpdater {
|
|
|
339
347
|
final JSObject ret = new JSObject();
|
|
340
348
|
ret.put("bundle", info.toJSON());
|
|
341
349
|
CapacitorUpdater.this.notifyListeners("updateAvailable", ret);
|
|
342
|
-
|
|
350
|
+
if (setNext) {
|
|
351
|
+
this.setNextBundle(info.getId());
|
|
352
|
+
}
|
|
343
353
|
} catch (IOException e) {
|
|
344
354
|
e.printStackTrace();
|
|
355
|
+
CapacitorUpdater.this.sendStats(
|
|
356
|
+
"download_fail",
|
|
357
|
+
CapacitorUpdater.this.getCurrentBundle().getVersionName()
|
|
358
|
+
);
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
|
|
@@ -516,16 +530,10 @@ public class CapacitorUpdater {
|
|
|
516
530
|
this.notifyDownload(id, 0);
|
|
517
531
|
final String idName = bundleDirectory + "/" + id;
|
|
518
532
|
this.notifyDownload(id, 5);
|
|
519
|
-
final
|
|
520
|
-
this.
|
|
533
|
+
final String dest = this.randomString(10);
|
|
534
|
+
final File downloaded = this.downloadFile(id, url, dest);
|
|
521
535
|
final String checksum = this.getChecksum(downloaded);
|
|
522
|
-
this.
|
|
523
|
-
final File unzipped = this.unzip(id, downloaded, this.randomString(10));
|
|
524
|
-
downloaded.delete();
|
|
525
|
-
this.notifyDownload(id, 91);
|
|
526
|
-
this.flattenAssets(unzipped, idName);
|
|
527
|
-
this.notifyDownload(id, 100);
|
|
528
|
-
this.saveBundleInfo(id, null);
|
|
536
|
+
this.finishDownload(id, dest, version, sessionKey, checksum, false);
|
|
529
537
|
BundleInfo info = new BundleInfo(
|
|
530
538
|
id,
|
|
531
539
|
version,
|
|
@@ -685,16 +693,14 @@ public class CapacitorUpdater {
|
|
|
685
693
|
response.data,
|
|
686
694
|
HttpHeaderParser.parseCharset(response.headers)
|
|
687
695
|
);
|
|
688
|
-
Log.e(TAG, message + ": " + json);
|
|
689
696
|
retError.put("message", message + ": " + json);
|
|
690
697
|
} catch (UnsupportedEncodingException e) {
|
|
691
|
-
Log.e(TAG, message + ": " + e.toString());
|
|
692
698
|
retError.put("message", message + ": " + e.toString());
|
|
693
699
|
}
|
|
694
700
|
} else {
|
|
695
|
-
Log.e(TAG, message + ": " + error.toString());
|
|
696
701
|
retError.put("message", message + ": " + error.toString());
|
|
697
702
|
}
|
|
703
|
+
Log.e(TAG, message + ": " + retError);
|
|
698
704
|
return retError;
|
|
699
705
|
}
|
|
700
706
|
|
|
@@ -410,19 +410,19 @@ extension CustomError: LocalizedError {
|
|
|
410
410
|
if let major = response.value?.major {
|
|
411
411
|
latest.major = major
|
|
412
412
|
}
|
|
413
|
-
if let message = response.value?.message {
|
|
414
|
-
latest.message = message
|
|
415
|
-
}
|
|
416
413
|
if let error = response.value?.error {
|
|
417
414
|
latest.error = error
|
|
418
415
|
}
|
|
416
|
+
if let message = response.value?.message {
|
|
417
|
+
latest.message = message
|
|
418
|
+
}
|
|
419
419
|
if let sessionKey = response.value?.session_key {
|
|
420
420
|
latest.sessionKey = sessionKey
|
|
421
421
|
}
|
|
422
422
|
case let .failure(error):
|
|
423
|
-
print("\(self.TAG) Error getting Latest", response.value, error )
|
|
424
|
-
latest.message = "Error getting Latest \(response.value)"
|
|
425
|
-
latest.error = "
|
|
423
|
+
print("\(self.TAG) Error getting Latest", response.value ?? "", error )
|
|
424
|
+
latest.message = "Error getting Latest \(String(describing: response.value))"
|
|
425
|
+
latest.error = "response_error"
|
|
426
426
|
}
|
|
427
427
|
semaphore.signal()
|
|
428
428
|
}
|
|
@@ -647,7 +647,7 @@ extension CustomError: LocalizedError {
|
|
|
647
647
|
case let .failure(error):
|
|
648
648
|
print("\(self.TAG) Error set Channel", response.value, error)
|
|
649
649
|
setChannel.message = "Error set Channel \(String(describing: response.value))"
|
|
650
|
-
setChannel.error = "
|
|
650
|
+
setChannel.error = "response_error"
|
|
651
651
|
}
|
|
652
652
|
semaphore.signal()
|
|
653
653
|
}
|
|
@@ -676,6 +676,9 @@ extension CustomError: LocalizedError {
|
|
|
676
676
|
if let error = response.value?.error {
|
|
677
677
|
getChannel.error = error
|
|
678
678
|
}
|
|
679
|
+
if let message = response.value?.message {
|
|
680
|
+
getChannel.message = message
|
|
681
|
+
}
|
|
679
682
|
if let channel = response.value?.channel {
|
|
680
683
|
getChannel.channel = channel
|
|
681
684
|
}
|
|
@@ -683,9 +686,9 @@ extension CustomError: LocalizedError {
|
|
|
683
686
|
getChannel.allowSet = allowSet
|
|
684
687
|
}
|
|
685
688
|
case let .failure(error):
|
|
686
|
-
print("\(self.TAG) Error get Channel", response.value, error)
|
|
689
|
+
print("\(self.TAG) Error get Channel", response.value ?? "", error)
|
|
687
690
|
getChannel.message = "Error get Channel \(String(describing: response.value)))"
|
|
688
|
-
getChannel.error = "
|
|
691
|
+
getChannel.error = "response_error"
|
|
689
692
|
}
|
|
690
693
|
semaphore.signal()
|
|
691
694
|
}
|