@otakit/capacitor-updater 2.3.2 → 2.3.3
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.
|
@@ -319,7 +319,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
319
319
|
if (hasStagedBundle) {
|
|
320
320
|
resolveCurrentRuntimeKey();
|
|
321
321
|
try {
|
|
322
|
-
if (!applyStaged(
|
|
322
|
+
if (!applyStaged()) {
|
|
323
323
|
android.util.Log.w(
|
|
324
324
|
"OtaKit",
|
|
325
325
|
"Failed to apply a valid staged bundle during runtime handling"
|
|
@@ -334,7 +334,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
334
334
|
DownloadResolution result = downloadLatest(false, null);
|
|
335
335
|
resolveCurrentRuntimeKey();
|
|
336
336
|
if (result.isForcedStaged()) {
|
|
337
|
-
requireApplyStaged(
|
|
337
|
+
requireApplyStaged();
|
|
338
338
|
}
|
|
339
339
|
});
|
|
340
340
|
return;
|
|
@@ -343,7 +343,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
343
343
|
DownloadResolution result = downloadLatest(false, null);
|
|
344
344
|
resolveCurrentRuntimeKey();
|
|
345
345
|
if (result.isForcedStaged()) {
|
|
346
|
-
requireApplyStaged(
|
|
346
|
+
requireApplyStaged();
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
return;
|
|
@@ -355,7 +355,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
resolveCurrentRuntimeKey();
|
|
358
|
-
requireApplyStaged(
|
|
358
|
+
requireApplyStaged();
|
|
359
359
|
});
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
@@ -367,7 +367,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
367
367
|
return;
|
|
368
368
|
case APPLY_STAGED:
|
|
369
369
|
try {
|
|
370
|
-
if (applyStaged(
|
|
370
|
+
if (applyStaged()) {
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
373
|
} catch (Exception e) {
|
|
@@ -377,7 +377,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
377
377
|
executeAutomaticUpdate("launch apply-staged fallback", () -> {
|
|
378
378
|
DownloadResolution result = downloadLatest(false, null);
|
|
379
379
|
if (result.isForcedStaged()) {
|
|
380
|
-
requireApplyStaged(
|
|
380
|
+
requireApplyStaged();
|
|
381
381
|
}
|
|
382
382
|
});
|
|
383
383
|
return;
|
|
@@ -385,7 +385,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
385
385
|
executeAutomaticUpdate("launch shadow", () -> {
|
|
386
386
|
DownloadResolution result = downloadLatest(false, null);
|
|
387
387
|
if (result.isForcedStaged()) {
|
|
388
|
-
requireApplyStaged(
|
|
388
|
+
requireApplyStaged();
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
return;
|
|
@@ -393,7 +393,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
393
393
|
executeAutomaticUpdate("launch immediate", () -> {
|
|
394
394
|
DownloadResolution result = downloadLatest(false, null);
|
|
395
395
|
if ("staged".equals(result.kind)) {
|
|
396
|
-
requireApplyStaged(
|
|
396
|
+
requireApplyStaged();
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
399
|
return;
|
|
@@ -406,12 +406,12 @@ public class UpdaterPlugin extends Plugin {
|
|
|
406
406
|
return;
|
|
407
407
|
case APPLY_STAGED:
|
|
408
408
|
executeAutomaticUpdate("resume apply-staged", () -> {
|
|
409
|
-
if (applyStaged(
|
|
409
|
+
if (applyStaged()) {
|
|
410
410
|
return;
|
|
411
411
|
}
|
|
412
412
|
DownloadResolution result = downloadLatest(true, null);
|
|
413
413
|
if (result.isForcedStaged()) {
|
|
414
|
-
requireApplyStaged(
|
|
414
|
+
requireApplyStaged();
|
|
415
415
|
}
|
|
416
416
|
});
|
|
417
417
|
return;
|
|
@@ -419,7 +419,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
419
419
|
executeAutomaticUpdate("resume shadow", () -> {
|
|
420
420
|
DownloadResolution result = downloadLatest(true, null);
|
|
421
421
|
if (result.isForcedStaged()) {
|
|
422
|
-
requireApplyStaged(
|
|
422
|
+
requireApplyStaged();
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
425
|
return;
|
|
@@ -427,7 +427,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
427
427
|
executeAutomaticUpdate("resume immediate", () -> {
|
|
428
428
|
DownloadResolution result = downloadLatest(false, null);
|
|
429
429
|
if ("staged".equals(result.kind)) {
|
|
430
|
-
requireApplyStaged(
|
|
430
|
+
requireApplyStaged();
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
433
|
return;
|
|
@@ -539,7 +539,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
539
539
|
}
|
|
540
540
|
executor.execute(() -> {
|
|
541
541
|
try {
|
|
542
|
-
requireApplyStaged(
|
|
542
|
+
requireApplyStaged();
|
|
543
543
|
} catch (Exception e) {
|
|
544
544
|
call.reject("apply failed: " + e.getMessage());
|
|
545
545
|
} finally {
|
|
@@ -558,7 +558,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
558
558
|
try {
|
|
559
559
|
DownloadResolution result = downloadLatest(false, null);
|
|
560
560
|
if ("staged".equals(result.kind)) {
|
|
561
|
-
requireApplyStaged(
|
|
561
|
+
requireApplyStaged();
|
|
562
562
|
return;
|
|
563
563
|
}
|
|
564
564
|
call.resolve();
|
|
@@ -983,7 +983,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
983
983
|
throw new IllegalStateException("Bundle archive does not contain index.html");
|
|
984
984
|
}
|
|
985
985
|
|
|
986
|
-
private boolean applyStaged(
|
|
986
|
+
private boolean applyStaged() throws Exception {
|
|
987
987
|
UpdaterCoordinator.ApplyPreparation preparation = coordinator.prepareApplyStaged(
|
|
988
988
|
this::isCompatibleRuntime,
|
|
989
989
|
this::isBundleUsable
|
|
@@ -994,9 +994,6 @@ public class UpdaterPlugin extends Plugin {
|
|
|
994
994
|
}
|
|
995
995
|
|
|
996
996
|
applyServerBasePathSynchronously(preparation.activationPath);
|
|
997
|
-
if (reloadAfterApply) {
|
|
998
|
-
reloadWebViewSynchronously();
|
|
999
|
-
}
|
|
1000
997
|
|
|
1001
998
|
cancelTrialTimeout();
|
|
1002
999
|
if (preparation.trialBundleId != null) {
|
|
@@ -1005,8 +1002,8 @@ public class UpdaterPlugin extends Plugin {
|
|
|
1005
1002
|
return true;
|
|
1006
1003
|
}
|
|
1007
1004
|
|
|
1008
|
-
private void requireApplyStaged(
|
|
1009
|
-
if (!applyStaged(
|
|
1005
|
+
private void requireApplyStaged() throws Exception {
|
|
1006
|
+
if (!applyStaged()) {
|
|
1010
1007
|
throw new IllegalStateException("Expected a staged bundle to be ready for apply");
|
|
1011
1008
|
}
|
|
1012
1009
|
}
|
|
@@ -1015,7 +1012,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
1015
1012
|
cancelTrialTimeout();
|
|
1016
1013
|
trialTimeoutRunnable = () -> {
|
|
1017
1014
|
if (coordinator.isCurrentTrialBundle(bundleId)) {
|
|
1018
|
-
rollbackCurrentBundle("notify_timeout"
|
|
1015
|
+
rollbackCurrentBundle("notify_timeout");
|
|
1019
1016
|
}
|
|
1020
1017
|
};
|
|
1021
1018
|
mainHandler.postDelayed(trialTimeoutRunnable, appReadyTimeoutMs);
|
|
@@ -1028,7 +1025,7 @@ public class UpdaterPlugin extends Plugin {
|
|
|
1028
1025
|
}
|
|
1029
1026
|
}
|
|
1030
1027
|
|
|
1031
|
-
private void rollbackCurrentBundle(String reason
|
|
1028
|
+
private void rollbackCurrentBundle(String reason) {
|
|
1032
1029
|
cancelTrialTimeout();
|
|
1033
1030
|
UpdaterCoordinator.RollbackPreparation preparation = coordinator.prepareRollback(
|
|
1034
1031
|
reason,
|
|
@@ -1056,9 +1053,6 @@ public class UpdaterPlugin extends Plugin {
|
|
|
1056
1053
|
|
|
1057
1054
|
try {
|
|
1058
1055
|
applyServerBasePathSynchronously(preparation.activationPath);
|
|
1059
|
-
if (shouldReload) {
|
|
1060
|
-
reloadWebViewSynchronously();
|
|
1061
|
-
}
|
|
1062
1056
|
} catch (Exception e) {
|
|
1063
1057
|
android.util.Log.w("OtaKit", "rollback activation failed", e);
|
|
1064
1058
|
}
|
|
@@ -1069,20 +1063,12 @@ public class UpdaterPlugin extends Plugin {
|
|
|
1069
1063
|
if (bridge == null) {
|
|
1070
1064
|
throw new IllegalStateException("Bridge not available for activation");
|
|
1071
1065
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
bridge
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
private void reloadWebViewSynchronously() throws Exception {
|
|
1081
|
-
runOnMainSynchronously(() -> {
|
|
1082
|
-
if (bridge == null || bridge.getWebView() == null) {
|
|
1083
|
-
throw new IllegalStateException("WebView not available for reload");
|
|
1084
|
-
}
|
|
1085
|
-
bridge.getWebView().reload();
|
|
1066
|
+
WebViewActivation.activate(
|
|
1067
|
+
path,
|
|
1068
|
+
BUILTIN_ASSET_PATH,
|
|
1069
|
+
bridge::setServerBasePath,
|
|
1070
|
+
bridge::setServerAssetPath
|
|
1071
|
+
);
|
|
1086
1072
|
});
|
|
1087
1073
|
}
|
|
1088
1074
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.otakit.updater;
|
|
2
|
+
|
|
3
|
+
final class WebViewActivation {
|
|
4
|
+
|
|
5
|
+
@FunctionalInterface
|
|
6
|
+
interface PathActivator {
|
|
7
|
+
void activate(String path);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
private WebViewActivation() {}
|
|
11
|
+
|
|
12
|
+
static void activate(
|
|
13
|
+
String path,
|
|
14
|
+
String builtinAssetPath,
|
|
15
|
+
PathActivator setServerBasePath,
|
|
16
|
+
PathActivator setServerAssetPath
|
|
17
|
+
) {
|
|
18
|
+
// Capacitor's Android setters both switch the hosted files and enqueue the
|
|
19
|
+
// WebView navigation. Calling WebView.reload() as well causes two navigations.
|
|
20
|
+
if (path == null || path.isEmpty()) {
|
|
21
|
+
setServerAssetPath.activate(builtinAssetPath);
|
|
22
|
+
} else {
|
|
23
|
+
setServerBasePath.activate(path);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|