@capgo/capacitor-updater 6.14.24 → 6.14.25
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.
|
@@ -57,7 +57,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
57
57
|
private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
|
|
58
58
|
private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
|
|
59
59
|
|
|
60
|
-
private final String PLUGIN_VERSION = "6.14.
|
|
60
|
+
private final String PLUGIN_VERSION = "6.14.25";
|
|
61
61
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
62
62
|
|
|
63
63
|
private SharedPreferences.Editor editor;
|
|
@@ -1002,6 +1002,17 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
1004
|
private void endBackGroundTaskWithNotif(String msg, String latestVersionName, BundleInfo current, Boolean error) {
|
|
1005
|
+
endBackGroundTaskWithNotif(msg, latestVersionName, current, error, "download_fail", "downloadFailed");
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
private void endBackGroundTaskWithNotif(
|
|
1009
|
+
String msg,
|
|
1010
|
+
String latestVersionName,
|
|
1011
|
+
BundleInfo current,
|
|
1012
|
+
Boolean error,
|
|
1013
|
+
String failureAction,
|
|
1014
|
+
String failureEvent
|
|
1015
|
+
) {
|
|
1005
1016
|
if (error) {
|
|
1006
1017
|
Log.i(
|
|
1007
1018
|
CapacitorUpdater.TAG,
|
|
@@ -1012,10 +1023,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1012
1023
|
"latestVersionName: " +
|
|
1013
1024
|
latestVersionName
|
|
1014
1025
|
);
|
|
1015
|
-
this.implementation.sendStats(
|
|
1026
|
+
this.implementation.sendStats(failureAction, current.getVersionName());
|
|
1016
1027
|
final JSObject ret = new JSObject();
|
|
1017
1028
|
ret.put("version", latestVersionName);
|
|
1018
|
-
this.notifyListeners(
|
|
1029
|
+
this.notifyListeners(failureEvent, ret);
|
|
1019
1030
|
}
|
|
1020
1031
|
final JSObject ret = new JSObject();
|
|
1021
1032
|
ret.put("bundle", current.toJSON());
|
|
@@ -1034,6 +1045,34 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1034
1045
|
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, null, res -> {
|
|
1035
1046
|
final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
|
|
1036
1047
|
try {
|
|
1048
|
+
if (res.has("error")) {
|
|
1049
|
+
final String error = res.optString("error", "");
|
|
1050
|
+
if (error != null && !error.isEmpty()) {
|
|
1051
|
+
Log.e(CapacitorUpdater.TAG, "getLatest failed with error: " + error);
|
|
1052
|
+
final String latestVersion = res.has("version")
|
|
1053
|
+
? res.optString("version", current.getVersionName())
|
|
1054
|
+
: current.getVersionName();
|
|
1055
|
+
if ("response_error".equals(error)) {
|
|
1056
|
+
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
1057
|
+
"Network error: " + error,
|
|
1058
|
+
latestVersion,
|
|
1059
|
+
current,
|
|
1060
|
+
true
|
|
1061
|
+
);
|
|
1062
|
+
} else {
|
|
1063
|
+
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
1064
|
+
error,
|
|
1065
|
+
latestVersion,
|
|
1066
|
+
current,
|
|
1067
|
+
true,
|
|
1068
|
+
"backend_refusal",
|
|
1069
|
+
"backendRefused"
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1037
1076
|
if (res.has("message")) {
|
|
1038
1077
|
Log.i(CapacitorUpdater.TAG, "API message: " + res.get("message"));
|
|
1039
1078
|
if (res.has("major") && res.getBoolean("major") && res.has("version")) {
|
|
@@ -1041,11 +1080,16 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1041
1080
|
majorAvailable.put("version", res.getString("version"));
|
|
1042
1081
|
CapacitorUpdaterPlugin.this.notifyListeners("majorAvailable", majorAvailable);
|
|
1043
1082
|
}
|
|
1083
|
+
final String latestVersion = res.has("version")
|
|
1084
|
+
? res.optString("version", current.getVersionName())
|
|
1085
|
+
: current.getVersionName();
|
|
1044
1086
|
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
1045
1087
|
res.getString("message"),
|
|
1046
|
-
|
|
1088
|
+
latestVersion,
|
|
1047
1089
|
current,
|
|
1048
|
-
true
|
|
1090
|
+
true,
|
|
1091
|
+
"backend_refusal",
|
|
1092
|
+
"backendRefused"
|
|
1049
1093
|
);
|
|
1050
1094
|
return;
|
|
1051
1095
|
}
|
|
@@ -45,7 +45,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
45
45
|
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise)
|
|
46
46
|
]
|
|
47
47
|
public var implementation = CapacitorUpdater()
|
|
48
|
-
private let PLUGIN_VERSION: String = "6.14.
|
|
48
|
+
private let PLUGIN_VERSION: String = "6.14.25"
|
|
49
49
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
50
50
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
51
51
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
|
@@ -732,10 +732,17 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
func endBackGroundTaskWithNotif(
|
|
735
|
+
func endBackGroundTaskWithNotif(
|
|
736
|
+
msg: String,
|
|
737
|
+
latestVersionName: String,
|
|
738
|
+
current: BundleInfo,
|
|
739
|
+
error: Bool = true,
|
|
740
|
+
failureAction: String = "download_fail",
|
|
741
|
+
failureEvent: String = "downloadFailed"
|
|
742
|
+
) {
|
|
736
743
|
if error {
|
|
737
|
-
self.implementation.sendStats(action:
|
|
738
|
-
self.notifyListeners(
|
|
744
|
+
self.implementation.sendStats(action: failureAction, versionName: current.getVersionName())
|
|
745
|
+
self.notifyListeners(failureEvent, data: ["version": latestVersionName])
|
|
739
746
|
}
|
|
740
747
|
self.notifyListeners("noNeedUpdate", data: ["bundle": current.toJSON()])
|
|
741
748
|
self.sendReadyToJs(current: current, msg: msg)
|
|
@@ -758,12 +765,43 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
758
765
|
let res = self.implementation.getLatest(url: url, channel: nil)
|
|
759
766
|
let current = self.implementation.getCurrentBundle()
|
|
760
767
|
|
|
761
|
-
if
|
|
762
|
-
print("\(CapacitorUpdater.TAG)
|
|
768
|
+
if let backendError = res.error, !backendError.isEmpty {
|
|
769
|
+
print("\(CapacitorUpdater.TAG) getLatest failed with error: \(backendError)")
|
|
770
|
+
let latestVersionName = res.version.isEmpty ? current.getVersionName() : res.version
|
|
771
|
+
if backendError == "response_error" {
|
|
772
|
+
self.endBackGroundTaskWithNotif(
|
|
773
|
+
msg: "Network error: \(backendError)",
|
|
774
|
+
latestVersionName: latestVersionName,
|
|
775
|
+
current: current,
|
|
776
|
+
error: true
|
|
777
|
+
)
|
|
778
|
+
} else {
|
|
779
|
+
self.endBackGroundTaskWithNotif(
|
|
780
|
+
msg: backendError,
|
|
781
|
+
latestVersionName: latestVersionName,
|
|
782
|
+
current: current,
|
|
783
|
+
error: true,
|
|
784
|
+
failureAction: "backend_refusal",
|
|
785
|
+
failureEvent: "backendRefused"
|
|
786
|
+
)
|
|
787
|
+
}
|
|
788
|
+
return
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if let message = res.message, !message.isEmpty {
|
|
792
|
+
print("\(CapacitorUpdater.TAG) API message: \(message)")
|
|
763
793
|
if res.major == true {
|
|
764
794
|
self.notifyListeners("majorAvailable", data: ["version": res.version])
|
|
765
795
|
}
|
|
766
|
-
|
|
796
|
+
let latestVersionName = res.version.isEmpty ? current.getVersionName() : res.version
|
|
797
|
+
self.endBackGroundTaskWithNotif(
|
|
798
|
+
msg: message,
|
|
799
|
+
latestVersionName: latestVersionName,
|
|
800
|
+
current: current,
|
|
801
|
+
error: true,
|
|
802
|
+
failureAction: "backend_refusal",
|
|
803
|
+
failureEvent: "backendRefused"
|
|
804
|
+
)
|
|
767
805
|
return
|
|
768
806
|
}
|
|
769
807
|
if res.version == "builtin" {
|