@capgo/capacitor-updater 7.11.12 → 7.12.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.
|
@@ -58,7 +58,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
58
58
|
private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
|
|
59
59
|
private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
|
|
60
60
|
|
|
61
|
-
private final String PLUGIN_VERSION = "7.
|
|
61
|
+
private final String PLUGIN_VERSION = "7.12.0";
|
|
62
62
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
63
63
|
|
|
64
64
|
private SharedPreferences.Editor editor;
|
|
@@ -73,6 +73,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
73
73
|
private Boolean autoUpdate = false;
|
|
74
74
|
private String updateUrl = "";
|
|
75
75
|
private Version currentVersionNative;
|
|
76
|
+
private String currentBuildVersion;
|
|
76
77
|
private Thread backgroundTask;
|
|
77
78
|
private Boolean taskRunning = false;
|
|
78
79
|
private Boolean keepUrlPathAfterReload = false;
|
|
@@ -169,6 +170,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
this.currentVersionNative = new Version(this.getConfig().getString("version", pInfo.versionName));
|
|
173
|
+
this.currentBuildVersion = Integer.toString(pInfo.versionCode);
|
|
172
174
|
this.delayUpdateUtils = new DelayUpdateUtils(
|
|
173
175
|
this.prefs,
|
|
174
176
|
this.editor,
|
|
@@ -389,8 +391,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
389
391
|
}
|
|
390
392
|
|
|
391
393
|
private boolean checkIfRecentlyInstalledOrUpdated() {
|
|
392
|
-
String currentVersion = this.
|
|
393
|
-
String lastKnownVersion = this.prefs.getString("
|
|
394
|
+
String currentVersion = this.currentBuildVersion;
|
|
395
|
+
String lastKnownVersion = this.prefs.getString("LatestNativeBuildVersion", "");
|
|
394
396
|
|
|
395
397
|
if (lastKnownVersion.isEmpty()) {
|
|
396
398
|
// First time running, consider it as recently installed
|
|
@@ -428,32 +430,21 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
428
430
|
}
|
|
429
431
|
|
|
430
432
|
private void cleanupObsoleteVersions() {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
logger.info("
|
|
439
|
-
this.implementation.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
try {
|
|
443
|
-
logger.info("Deleting obsolete bundle: " + bundle.getId());
|
|
444
|
-
this.implementation.delete(bundle.getId());
|
|
445
|
-
} catch (final Exception e) {
|
|
446
|
-
logger.error("Failed to delete: " + bundle.getId() + " " + e.getMessage());
|
|
447
|
-
}
|
|
448
|
-
}
|
|
433
|
+
final String previous = this.prefs.getString("LatestNativeBuildVersion", "");
|
|
434
|
+
if (!"".equals(previous) && !Objects.equals(this.currentBuildVersion, previous)) {
|
|
435
|
+
logger.info("New native build version detected: " + this.currentBuildVersion);
|
|
436
|
+
this.implementation.reset(true);
|
|
437
|
+
final List<BundleInfo> installed = this.implementation.list(false);
|
|
438
|
+
for (final BundleInfo bundle : installed) {
|
|
439
|
+
try {
|
|
440
|
+
logger.info("Deleting obsolete bundle: " + bundle.getId());
|
|
441
|
+
this.implementation.delete(bundle.getId());
|
|
442
|
+
} catch (final Exception e) {
|
|
443
|
+
logger.error("Failed to delete: " + bundle.getId() + " " + e.getMessage());
|
|
449
444
|
}
|
|
450
|
-
} catch (final Exception e) {
|
|
451
|
-
logger.error("Could not determine the current version " + e.getMessage());
|
|
452
445
|
}
|
|
453
|
-
} catch (final Exception e) {
|
|
454
|
-
logger.error("Error calculating previous native version " + e.getMessage());
|
|
455
446
|
}
|
|
456
|
-
this.editor.putString("
|
|
447
|
+
this.editor.putString("LatestNativeBuildVersion", this.currentBuildVersion);
|
|
457
448
|
this.editor.apply();
|
|
458
449
|
}
|
|
459
450
|
|
|
@@ -254,7 +254,7 @@ public class CapgoUpdater {
|
|
|
254
254
|
// Cleanup download tracking
|
|
255
255
|
DownloadWorkerManager.cancelBundleDownload(activity, id, version);
|
|
256
256
|
Map<String, Object> ret = new HashMap<>();
|
|
257
|
-
ret.put("version",
|
|
257
|
+
ret.put("version", version);
|
|
258
258
|
ret.put("error", "finish_download_fail");
|
|
259
259
|
sendStats("finish_download_fail", version);
|
|
260
260
|
notifyListeners("downloadFailed", ret);
|
|
@@ -275,7 +275,7 @@ public class CapgoUpdater {
|
|
|
275
275
|
// Cleanup download tracking for failed downloads
|
|
276
276
|
DownloadWorkerManager.cancelBundleDownload(activity, id, failedVersion);
|
|
277
277
|
Map<String, Object> ret = new HashMap<>();
|
|
278
|
-
ret.put("version",
|
|
278
|
+
ret.put("version", failedVersion);
|
|
279
279
|
if ("low_mem_fail".equals(error)) {
|
|
280
280
|
sendStats("low_mem_fail", failedVersion);
|
|
281
281
|
}
|
|
@@ -371,7 +371,7 @@ public class CapgoUpdater {
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
final Map<String, Object> ret = new HashMap<>();
|
|
374
|
-
ret.put("version",
|
|
374
|
+
ret.put("version", version);
|
|
375
375
|
|
|
376
376
|
CapgoUpdater.this.notifyListeners("downloadFailed", ret);
|
|
377
377
|
CapgoUpdater.this.sendStats("download_fail");
|
|
@@ -413,7 +413,7 @@ public class CapgoUpdater {
|
|
|
413
413
|
} catch (IOException e) {
|
|
414
414
|
e.printStackTrace();
|
|
415
415
|
final Map<String, Object> ret = new HashMap<>();
|
|
416
|
-
ret.put("version",
|
|
416
|
+
ret.put("version", version);
|
|
417
417
|
CapgoUpdater.this.notifyListeners("downloadFailed", ret);
|
|
418
418
|
CapgoUpdater.this.sendStats("download_fail");
|
|
419
419
|
return false;
|
|
@@ -50,7 +50,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
50
50
|
CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
|
|
51
51
|
]
|
|
52
52
|
public var implementation = CapgoUpdater()
|
|
53
|
-
private let PLUGIN_VERSION: String = "7.
|
|
53
|
+
private let PLUGIN_VERSION: String = "7.12.0"
|
|
54
54
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
55
55
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
56
56
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
|
@@ -59,6 +59,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
59
59
|
private var statsUrl = ""
|
|
60
60
|
private var backgroundTaskID: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid
|
|
61
61
|
private var currentVersionNative: Version = "0.0.0"
|
|
62
|
+
private var currentBuildVersion: String = "0"
|
|
62
63
|
private var autoUpdate = false
|
|
63
64
|
private var appReadyTimeout = 10000
|
|
64
65
|
private var appReadyCheck: DispatchWorkItem?
|
|
@@ -107,6 +108,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
107
108
|
} catch {
|
|
108
109
|
logger.error("Cannot parse versionName \(versionName)")
|
|
109
110
|
}
|
|
111
|
+
currentBuildVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "0"
|
|
110
112
|
logger.info("version native \(self.currentVersionNative.description)")
|
|
111
113
|
implementation.versionBuild = getConfig().getString("version", Bundle.main.versionName)!
|
|
112
114
|
autoDeleteFailed = getConfig().getBoolean("autoDeleteFailed", true)
|
|
@@ -235,13 +237,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
private func cleanupObsoleteVersions() {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
LatestVersionNative = try Version(UserDefaults.standard.string(forKey: "LatestVersionNative") ?? "0.0.0")
|
|
241
|
-
} catch {
|
|
242
|
-
logger.error("Cannot get version native \(currentVersionNative)")
|
|
243
|
-
}
|
|
244
|
-
if LatestVersionNative != "0.0.0" && self.currentVersionNative.description != LatestVersionNative.description {
|
|
240
|
+
let previous = UserDefaults.standard.string(forKey: "LatestNativeBuildVersion") ?? "0"
|
|
241
|
+
if previous != "0" && self.currentBuildVersion != previous {
|
|
245
242
|
_ = self._reset(toLastSuccessful: false)
|
|
246
243
|
let res = implementation.list()
|
|
247
244
|
res.forEach { version in
|
|
@@ -252,7 +249,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
}
|
|
255
|
-
UserDefaults.standard.set(
|
|
252
|
+
UserDefaults.standard.set(self.currentBuildVersion, forKey: "LatestNativeBuildVersion")
|
|
256
253
|
UserDefaults.standard.synchronize()
|
|
257
254
|
}
|
|
258
255
|
|
|
@@ -846,10 +843,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
846
843
|
|
|
847
844
|
private func checkIfRecentlyInstalledOrUpdated() -> Bool {
|
|
848
845
|
let userDefaults = UserDefaults.standard
|
|
849
|
-
let currentVersion = self.
|
|
850
|
-
let lastKnownVersion = userDefaults.string(forKey: "
|
|
846
|
+
let currentVersion = self.currentBuildVersion
|
|
847
|
+
let lastKnownVersion = userDefaults.string(forKey: "LatestNativeBuildVersion") ?? "0"
|
|
851
848
|
|
|
852
|
-
if lastKnownVersion == "0
|
|
849
|
+
if lastKnownVersion == "0" {
|
|
853
850
|
// First time running, consider it as recently installed
|
|
854
851
|
return true
|
|
855
852
|
} else if lastKnownVersion != currentVersion {
|