@capgo/capacitor-updater 7.0.57 → 7.2.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.
@@ -295,7 +295,8 @@ public class CapacitorUpdater {
295
295
  sessionKey,
296
296
  checksum,
297
297
  this.publicKey,
298
- manifest != null
298
+ manifest != null,
299
+ this.isEmulator()
299
300
  );
300
301
 
301
302
  if (manifest != null) {
@@ -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 = "7.0.57";
60
+ private final String PLUGIN_VERSION = "7.2.0";
61
61
  private static final String DELAY_CONDITION_PREFERENCES = "";
62
62
 
63
63
  private SharedPreferences.Editor editor;
@@ -1106,6 +1106,20 @@ public class CapacitorUpdaterPlugin extends Plugin {
1106
1106
  "Latest bundle already exists and download is NOT required. " + messageUpdate
1107
1107
  );
1108
1108
  if (CapacitorUpdaterPlugin.this.implementation.directUpdate) {
1109
+ Gson gson = new Gson();
1110
+ String delayUpdatePreferences = prefs.getString(DELAY_CONDITION_PREFERENCES, "[]");
1111
+ Type type = new TypeToken<ArrayList<DelayCondition>>() {}.getType();
1112
+ ArrayList<DelayCondition> delayConditionList = gson.fromJson(delayUpdatePreferences, type);
1113
+ if (delayConditionList != null && !delayConditionList.isEmpty()) {
1114
+ Log.i(CapacitorUpdater.TAG, "Update delayed until delay conditions met");
1115
+ CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
1116
+ "Update delayed until delay conditions met",
1117
+ latestVersionName,
1118
+ latest,
1119
+ false
1120
+ );
1121
+ return;
1122
+ }
1109
1123
  CapacitorUpdaterPlugin.this.implementation.set(latest);
1110
1124
  CapacitorUpdaterPlugin.this._reload();
1111
1125
  CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
@@ -46,7 +46,8 @@ public class DownloadWorkerManager {
46
46
  String sessionKey,
47
47
  String checksum,
48
48
  String publicKey,
49
- boolean isManifest
49
+ boolean isManifest,
50
+ boolean isEmulator
50
51
  ) {
51
52
  initializeIfNeeded(context.getApplicationContext());
52
53
 
@@ -70,18 +71,33 @@ public class DownloadWorkerManager {
70
71
  .putString(DownloadService.PUBLIC_KEY, publicKey)
71
72
  .build();
72
73
 
73
- // Create network constraints
74
- Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
74
+ // Create network constraints - be more lenient on emulators
75
+ Constraints.Builder constraintsBuilder = new Constraints.Builder();
76
+ if (isEmulator) {
77
+ Log.i(TAG, "Emulator detected - using lenient network constraints");
78
+ // On emulators, use UNMETERED to avoid background network issues
79
+ constraintsBuilder.setRequiredNetworkType(NetworkType.UNMETERED);
80
+ } else {
81
+ constraintsBuilder.setRequiredNetworkType(NetworkType.CONNECTED);
82
+ }
83
+ Constraints constraints = constraintsBuilder.build();
75
84
 
76
85
  // Create work request with tags for tracking
77
- OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(DownloadService.class)
86
+ OneTimeWorkRequest.Builder workRequestBuilder = new OneTimeWorkRequest.Builder(DownloadService.class)
78
87
  .setConstraints(constraints)
79
88
  .setInputData(inputData)
80
89
  .addTag(id)
81
90
  .addTag(version) // Add version tag for tracking
82
- .addTag("capacitor_updater_download")
83
- .setBackoffCriteria(BackoffPolicy.LINEAR, WorkRequest.MIN_BACKOFF_MILLIS, TimeUnit.MILLISECONDS)
84
- .build();
91
+ .addTag("capacitor_updater_download");
92
+
93
+ // More aggressive retry policy for emulators
94
+ if (isEmulator) {
95
+ workRequestBuilder.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 30, TimeUnit.SECONDS);
96
+ } else {
97
+ workRequestBuilder.setBackoffCriteria(BackoffPolicy.LINEAR, WorkRequest.MIN_BACKOFF_MILLIS, TimeUnit.MILLISECONDS);
98
+ }
99
+
100
+ OneTimeWorkRequest workRequest = workRequestBuilder.build();
85
101
 
86
102
  // Enqueue work
87
103
  WorkManager.getInstance(context).enqueue(workRequest);
@@ -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 = "7.0.57"
48
+ private let PLUGIN_VERSION: String = "7.2.0"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.0.57",
3
+ "version": "7.2.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",