@capgo/capacitor-updater 8.47.0 → 8.47.2
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 +41 -41
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +210 -49
- package/dist/docs.json +9 -5
- package/dist/esm/definitions.d.ts +19 -5
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +157 -35
- package/package.json +1 -1
|
@@ -75,6 +75,13 @@ import org.json.JSONObject;
|
|
|
75
75
|
@CapacitorPlugin(name = "CapacitorUpdater")
|
|
76
76
|
public class CapacitorUpdaterPlugin extends Plugin {
|
|
77
77
|
|
|
78
|
+
private static final String AUTO_UPDATE_MODE_OFF = "off";
|
|
79
|
+
private static final String AUTO_UPDATE_MODE_BACKGROUND = "atBackground";
|
|
80
|
+
private static final String AUTO_UPDATE_MODE_INSTALL = "atInstall";
|
|
81
|
+
private static final String AUTO_UPDATE_MODE_LAUNCH = "onLaunch";
|
|
82
|
+
private static final String AUTO_UPDATE_MODE_ALWAYS = "always";
|
|
83
|
+
private static final String AUTO_UPDATE_MODE_ONLY_DOWNLOAD = "onlyDownload";
|
|
84
|
+
|
|
78
85
|
private Logger logger;
|
|
79
86
|
|
|
80
87
|
private static final String updateUrlDefault = "https://plugin.capgo.app/updates";
|
|
@@ -113,7 +120,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
113
120
|
static final int APPLICATION_EXIT_REASON_USER_REQUESTED = 10;
|
|
114
121
|
static final int APPLICATION_EXIT_REASON_DEPENDENCY_DIED = 12;
|
|
115
122
|
|
|
116
|
-
private final String pluginVersion = "8.47.
|
|
123
|
+
private final String pluginVersion = "8.47.2";
|
|
117
124
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
118
125
|
|
|
119
126
|
private SharedPreferences.Editor editor;
|
|
@@ -127,6 +134,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
127
134
|
private Boolean autoDeleteFailed = true;
|
|
128
135
|
private Boolean autoDeletePrevious = true;
|
|
129
136
|
private Boolean autoUpdate = false;
|
|
137
|
+
private String autoUpdateMode = AUTO_UPDATE_MODE_OFF;
|
|
130
138
|
private String updateUrl = "";
|
|
131
139
|
private Version currentVersionNative;
|
|
132
140
|
private String currentBuildVersion;
|
|
@@ -357,45 +365,6 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
357
365
|
this.implementation.pluginVersion = this.pluginVersion;
|
|
358
366
|
this.implementation.versionCode = this.getVersionCode(pInfo);
|
|
359
367
|
// Removed unused OkHttpClient creation - using shared client in DownloadService instead
|
|
360
|
-
// Handle directUpdate configuration - support string values and backward compatibility
|
|
361
|
-
String directUpdateConfig = this.getConfig().getString("directUpdate", null);
|
|
362
|
-
if (directUpdateConfig != null) {
|
|
363
|
-
// Handle backward compatibility for boolean true
|
|
364
|
-
if (directUpdateConfig.equals("true")) {
|
|
365
|
-
this.directUpdateMode = "always";
|
|
366
|
-
this.implementation.directUpdate = true;
|
|
367
|
-
} else {
|
|
368
|
-
this.directUpdateMode = directUpdateConfig;
|
|
369
|
-
this.implementation.directUpdate =
|
|
370
|
-
directUpdateConfig.equals("always") ||
|
|
371
|
-
directUpdateConfig.equals("atInstall") ||
|
|
372
|
-
directUpdateConfig.equals("onLaunch");
|
|
373
|
-
// Validate directUpdate value
|
|
374
|
-
if (
|
|
375
|
-
!directUpdateConfig.equals("false") &&
|
|
376
|
-
!directUpdateConfig.equals("always") &&
|
|
377
|
-
!directUpdateConfig.equals("atInstall") &&
|
|
378
|
-
!directUpdateConfig.equals("onLaunch")
|
|
379
|
-
) {
|
|
380
|
-
logger.error(
|
|
381
|
-
"Invalid directUpdate value: \"" +
|
|
382
|
-
directUpdateConfig +
|
|
383
|
-
"\". Supported values are: \"false\", \"true\", \"always\", \"atInstall\", \"onLaunch\". Defaulting to \"false\"."
|
|
384
|
-
);
|
|
385
|
-
this.directUpdateMode = "false";
|
|
386
|
-
this.implementation.directUpdate = false;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
} else {
|
|
390
|
-
Boolean directUpdateBool = this.getConfig().getBoolean("directUpdate", false);
|
|
391
|
-
if (directUpdateBool) {
|
|
392
|
-
this.directUpdateMode = "always"; // backward compatibility: true = always
|
|
393
|
-
this.implementation.directUpdate = true;
|
|
394
|
-
} else {
|
|
395
|
-
this.directUpdateMode = "false";
|
|
396
|
-
this.implementation.directUpdate = false;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
368
|
this.currentVersionNative = new Version(this.getConfig().getString("version", pInfo.versionName));
|
|
400
369
|
this.currentBuildVersion = this.getVersionCode(pInfo);
|
|
401
370
|
this.delayUpdateUtils = new DelayUpdateUtils(this.prefs, this.editor, this.currentVersionNative, logger);
|
|
@@ -508,7 +477,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
508
477
|
}
|
|
509
478
|
}
|
|
510
479
|
}
|
|
511
|
-
this.
|
|
480
|
+
this.configureAutoUpdateModeFromConfig();
|
|
512
481
|
this.appReadyTimeout = Math.max(1000, this.getConfig().getInt("appReadyTimeout", 10000)); // Minimum 1 second
|
|
513
482
|
this.keepUrlPathAfterReload = this.getConfig().getBoolean("keepUrlPathAfterReload", false);
|
|
514
483
|
this.syncKeepUrlPathFlag(this.keepUrlPathAfterReload);
|
|
@@ -1301,6 +1270,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1301
1270
|
}
|
|
1302
1271
|
|
|
1303
1272
|
private boolean shouldUseDirectUpdate() {
|
|
1273
|
+
if (!Boolean.TRUE.equals(this.autoUpdate) || AUTO_UPDATE_MODE_ONLY_DOWNLOAD.equals(this.autoUpdateMode)) {
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1304
1276
|
if (Boolean.TRUE.equals(this.autoSplashscreenTimedOut)) {
|
|
1305
1277
|
return false;
|
|
1306
1278
|
}
|
|
@@ -1331,6 +1303,115 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1331
1303
|
}
|
|
1332
1304
|
}
|
|
1333
1305
|
|
|
1306
|
+
private void configureAutoUpdateModeFromConfig() {
|
|
1307
|
+
final String configuredMode = this.getConfig().getString("autoUpdate", null);
|
|
1308
|
+
if (configuredMode != null && !configuredMode.isEmpty() && !"true".equals(configuredMode) && !"false".equals(configuredMode)) {
|
|
1309
|
+
this.autoUpdateMode = normalizedAutoUpdateMode(configuredMode);
|
|
1310
|
+
if (!this.autoUpdateMode.equals(configuredMode)) {
|
|
1311
|
+
logger.error(
|
|
1312
|
+
"Invalid autoUpdate value: \"" +
|
|
1313
|
+
configuredMode +
|
|
1314
|
+
"\". Supported values are: true, false, \"off\", \"atBackground\", \"atInstall\", \"onLaunch\", \"always\", \"onlyDownload\". Defaulting to \"atBackground\"."
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1317
|
+
} else {
|
|
1318
|
+
final boolean enabled = configuredMode != null
|
|
1319
|
+
? "true".equals(configuredMode)
|
|
1320
|
+
: Boolean.TRUE.equals(this.getConfig().getBoolean("autoUpdate", true));
|
|
1321
|
+
this.autoUpdateMode = enabled
|
|
1322
|
+
? autoUpdateModeForLegacyDirectUpdateMode(this.resolveLegacyDirectUpdateModeFromConfig())
|
|
1323
|
+
: AUTO_UPDATE_MODE_OFF;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
this.autoUpdate = isAutoUpdateModeEnabled(this.autoUpdateMode);
|
|
1327
|
+
this.directUpdateMode = directUpdateModeForAutoUpdateMode(this.autoUpdateMode);
|
|
1328
|
+
this.implementation.directUpdate = isDirectUpdateMode(this.directUpdateMode);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
private String resolveLegacyDirectUpdateModeFromConfig() {
|
|
1332
|
+
final String directUpdateConfig = this.getConfig().getString("directUpdate", null);
|
|
1333
|
+
if (directUpdateConfig != null) {
|
|
1334
|
+
if ("true".equals(directUpdateConfig)) {
|
|
1335
|
+
return AUTO_UPDATE_MODE_ALWAYS;
|
|
1336
|
+
}
|
|
1337
|
+
if ("false".equals(directUpdateConfig) || isDirectUpdateMode(directUpdateConfig)) {
|
|
1338
|
+
return directUpdateConfig;
|
|
1339
|
+
}
|
|
1340
|
+
logger.error(
|
|
1341
|
+
"Invalid directUpdate value: \"" +
|
|
1342
|
+
directUpdateConfig +
|
|
1343
|
+
"\". Supported values are: false, true, \"always\", \"atInstall\", \"onLaunch\". Defaulting to \"false\"."
|
|
1344
|
+
);
|
|
1345
|
+
return "false";
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return Boolean.TRUE.equals(this.getConfig().getBoolean("directUpdate", false)) ? AUTO_UPDATE_MODE_ALWAYS : "false";
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
static String normalizedAutoUpdateMode(final String value) {
|
|
1352
|
+
if (value == null) {
|
|
1353
|
+
return AUTO_UPDATE_MODE_BACKGROUND;
|
|
1354
|
+
}
|
|
1355
|
+
switch (value) {
|
|
1356
|
+
case "false":
|
|
1357
|
+
case AUTO_UPDATE_MODE_OFF:
|
|
1358
|
+
return AUTO_UPDATE_MODE_OFF;
|
|
1359
|
+
case "true":
|
|
1360
|
+
case AUTO_UPDATE_MODE_BACKGROUND:
|
|
1361
|
+
return AUTO_UPDATE_MODE_BACKGROUND;
|
|
1362
|
+
case AUTO_UPDATE_MODE_INSTALL:
|
|
1363
|
+
case AUTO_UPDATE_MODE_LAUNCH:
|
|
1364
|
+
case AUTO_UPDATE_MODE_ALWAYS:
|
|
1365
|
+
case AUTO_UPDATE_MODE_ONLY_DOWNLOAD:
|
|
1366
|
+
return value;
|
|
1367
|
+
default:
|
|
1368
|
+
return AUTO_UPDATE_MODE_BACKGROUND;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
static String autoUpdateModeForLegacyDirectUpdateMode(final String directUpdateMode) {
|
|
1373
|
+
switch (directUpdateMode) {
|
|
1374
|
+
case AUTO_UPDATE_MODE_INSTALL:
|
|
1375
|
+
case AUTO_UPDATE_MODE_LAUNCH:
|
|
1376
|
+
case AUTO_UPDATE_MODE_ALWAYS:
|
|
1377
|
+
return directUpdateMode;
|
|
1378
|
+
case "false":
|
|
1379
|
+
default:
|
|
1380
|
+
return AUTO_UPDATE_MODE_BACKGROUND;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
static String directUpdateModeForAutoUpdateMode(final String autoUpdateMode) {
|
|
1385
|
+
switch (autoUpdateMode) {
|
|
1386
|
+
case AUTO_UPDATE_MODE_INSTALL:
|
|
1387
|
+
case AUTO_UPDATE_MODE_LAUNCH:
|
|
1388
|
+
case AUTO_UPDATE_MODE_ALWAYS:
|
|
1389
|
+
return autoUpdateMode;
|
|
1390
|
+
default:
|
|
1391
|
+
return "false";
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
static boolean isAutoUpdateModeEnabled(final String autoUpdateMode) {
|
|
1396
|
+
return !AUTO_UPDATE_MODE_OFF.equals(autoUpdateMode);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
static boolean shouldAutoUpdateModeSetNextBundle(final String autoUpdateMode) {
|
|
1400
|
+
return isAutoUpdateModeEnabled(autoUpdateMode) && !AUTO_UPDATE_MODE_ONLY_DOWNLOAD.equals(autoUpdateMode);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
static boolean isDirectUpdateMode(final String directUpdateMode) {
|
|
1404
|
+
return (
|
|
1405
|
+
AUTO_UPDATE_MODE_INSTALL.equals(directUpdateMode) ||
|
|
1406
|
+
AUTO_UPDATE_MODE_LAUNCH.equals(directUpdateMode) ||
|
|
1407
|
+
AUTO_UPDATE_MODE_ALWAYS.equals(directUpdateMode)
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
private boolean shouldAutoSetNextBundle() {
|
|
1412
|
+
return shouldAutoUpdateModeSetNextBundle(this.autoUpdateMode);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1334
1415
|
private boolean isDirectUpdateCurrentlyAllowed(final boolean plannedDirectUpdate) {
|
|
1335
1416
|
return plannedDirectUpdate && !Boolean.TRUE.equals(this.autoSplashscreenTimedOut);
|
|
1336
1417
|
}
|
|
@@ -1365,9 +1446,23 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1365
1446
|
|
|
1366
1447
|
void configureDirectUpdateModeForTesting(final String directUpdateMode, final boolean onLaunchDirectUpdateUsed) {
|
|
1367
1448
|
this.directUpdateMode = directUpdateMode;
|
|
1449
|
+
this.autoUpdateMode = autoUpdateModeForLegacyDirectUpdateMode(directUpdateMode);
|
|
1450
|
+
this.autoUpdate = isAutoUpdateModeEnabled(this.autoUpdateMode);
|
|
1451
|
+
if (this.implementation != null) {
|
|
1452
|
+
this.implementation.directUpdate = isDirectUpdateMode(this.directUpdateMode);
|
|
1453
|
+
}
|
|
1368
1454
|
this.onLaunchDirectUpdateUsed = onLaunchDirectUpdateUsed;
|
|
1369
1455
|
}
|
|
1370
1456
|
|
|
1457
|
+
void setAutoUpdateModeForTesting(final String autoUpdateMode) {
|
|
1458
|
+
this.autoUpdateMode = normalizedAutoUpdateMode(autoUpdateMode);
|
|
1459
|
+
this.autoUpdate = isAutoUpdateModeEnabled(this.autoUpdateMode);
|
|
1460
|
+
this.directUpdateMode = directUpdateModeForAutoUpdateMode(this.autoUpdateMode);
|
|
1461
|
+
if (this.implementation != null) {
|
|
1462
|
+
this.implementation.directUpdate = isDirectUpdateMode(this.directUpdateMode);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1371
1466
|
boolean shouldUseDirectUpdateForTesting() {
|
|
1372
1467
|
return this.shouldUseDirectUpdate();
|
|
1373
1468
|
}
|
|
@@ -3056,6 +3151,30 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3056
3151
|
String failureAction,
|
|
3057
3152
|
String failureEvent,
|
|
3058
3153
|
boolean shouldSendStats
|
|
3154
|
+
) {
|
|
3155
|
+
endBackGroundTaskWithNotif(
|
|
3156
|
+
msg,
|
|
3157
|
+
latestVersionName,
|
|
3158
|
+
current,
|
|
3159
|
+
error,
|
|
3160
|
+
plannedDirectUpdate,
|
|
3161
|
+
failureAction,
|
|
3162
|
+
failureEvent,
|
|
3163
|
+
shouldSendStats,
|
|
3164
|
+
true
|
|
3165
|
+
);
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
private void endBackGroundTaskWithNotif(
|
|
3169
|
+
String msg,
|
|
3170
|
+
String latestVersionName,
|
|
3171
|
+
BundleInfo current,
|
|
3172
|
+
Boolean error,
|
|
3173
|
+
Boolean plannedDirectUpdate,
|
|
3174
|
+
String failureAction,
|
|
3175
|
+
String failureEvent,
|
|
3176
|
+
boolean shouldSendStats,
|
|
3177
|
+
boolean shouldNotifyNoNeedUpdate
|
|
3059
3178
|
) {
|
|
3060
3179
|
this.consumeOnLaunchDirectUpdateAttempt(Boolean.TRUE.equals(plannedDirectUpdate));
|
|
3061
3180
|
if (error) {
|
|
@@ -3074,9 +3193,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3074
3193
|
ret.put("version", latestVersionName);
|
|
3075
3194
|
this.notifyListeners(failureEvent, ret);
|
|
3076
3195
|
}
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3196
|
+
if (shouldNotifyNoNeedUpdate) {
|
|
3197
|
+
final JSObject ret = new JSObject();
|
|
3198
|
+
ret.put("bundle", InternalUtils.mapToJSObject(current.toJSONMap()));
|
|
3199
|
+
this.notifyListeners("noNeedUpdate", ret);
|
|
3200
|
+
}
|
|
3080
3201
|
this.sendReadyToJs(current, msg, plannedDirectUpdate);
|
|
3081
3202
|
this.backgroundDownloadTask = null;
|
|
3082
3203
|
this.downloadStartTimeMs = 0;
|
|
@@ -3113,7 +3234,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3113
3234
|
final boolean initialDirectUpdateAllowed = this.isDirectUpdateCurrentlyAllowed(plannedDirectUpdate);
|
|
3114
3235
|
final String messageUpdate = initialDirectUpdateAllowed
|
|
3115
3236
|
? "Update will occur now."
|
|
3116
|
-
:
|
|
3237
|
+
: this.shouldAutoSetNextBundle()
|
|
3238
|
+
? "Update will occur next time app moves to background."
|
|
3239
|
+
: "Update will be downloaded and made available.";
|
|
3117
3240
|
Thread newTask = startNewThread(() -> {
|
|
3118
3241
|
// Wait for cleanup to complete before starting download
|
|
3119
3242
|
waitForCleanupIfNeeded();
|
|
@@ -3177,7 +3300,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3177
3300
|
false,
|
|
3178
3301
|
true
|
|
3179
3302
|
);
|
|
3180
|
-
} else {
|
|
3303
|
+
} else if (CapacitorUpdaterPlugin.this.shouldAutoSetNextBundle()) {
|
|
3181
3304
|
if (plannedDirectUpdate && !directUpdateAllowedNow) {
|
|
3182
3305
|
logger.info(
|
|
3183
3306
|
"Direct update skipped because splashscreen timeout occurred. Update will be applied later."
|
|
@@ -3192,6 +3315,28 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3192
3315
|
false,
|
|
3193
3316
|
plannedDirectUpdate
|
|
3194
3317
|
);
|
|
3318
|
+
} else {
|
|
3319
|
+
logger.info("autoUpdate is set to onlyDownload, builtin version will not be set as next bundle");
|
|
3320
|
+
final boolean builtinUpdateAvailable = !current.isBuiltin();
|
|
3321
|
+
if (builtinUpdateAvailable) {
|
|
3322
|
+
final JSObject ret = new JSObject();
|
|
3323
|
+
final BundleInfo builtinBundle = CapacitorUpdaterPlugin.this.implementation.getBundleInfo(
|
|
3324
|
+
BundleInfo.ID_BUILTIN
|
|
3325
|
+
);
|
|
3326
|
+
ret.put("bundle", InternalUtils.mapToJSObject(builtinBundle.toJSONMap()));
|
|
3327
|
+
CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
|
|
3328
|
+
}
|
|
3329
|
+
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
3330
|
+
"Latest version is builtin, autoUpdate onlyDownload",
|
|
3331
|
+
latestVersionName,
|
|
3332
|
+
current,
|
|
3333
|
+
false,
|
|
3334
|
+
plannedDirectUpdate,
|
|
3335
|
+
"download_fail",
|
|
3336
|
+
"downloadFailed",
|
|
3337
|
+
true,
|
|
3338
|
+
!builtinUpdateAvailable
|
|
3339
|
+
);
|
|
3195
3340
|
}
|
|
3196
3341
|
return;
|
|
3197
3342
|
}
|
|
@@ -3268,7 +3413,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3268
3413
|
true
|
|
3269
3414
|
);
|
|
3270
3415
|
}
|
|
3271
|
-
} else {
|
|
3416
|
+
} else if (CapacitorUpdaterPlugin.this.shouldAutoSetNextBundle()) {
|
|
3272
3417
|
if (plannedDirectUpdate && !directUpdateAllowedNow) {
|
|
3273
3418
|
logger.info(
|
|
3274
3419
|
"Direct update skipped because splashscreen timeout occurred. Update will install on next background."
|
|
@@ -3283,6 +3428,20 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3283
3428
|
false,
|
|
3284
3429
|
plannedDirectUpdate
|
|
3285
3430
|
);
|
|
3431
|
+
} else {
|
|
3432
|
+
logger.info("autoUpdate is set to onlyDownload, downloaded update will not be set as next bundle");
|
|
3433
|
+
CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
|
|
3434
|
+
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
3435
|
+
"update downloaded, autoUpdate onlyDownload",
|
|
3436
|
+
latestVersionName,
|
|
3437
|
+
current,
|
|
3438
|
+
false,
|
|
3439
|
+
plannedDirectUpdate,
|
|
3440
|
+
"download_fail",
|
|
3441
|
+
"downloadFailed",
|
|
3442
|
+
true,
|
|
3443
|
+
false
|
|
3444
|
+
);
|
|
3286
3445
|
}
|
|
3287
3446
|
return;
|
|
3288
3447
|
}
|
|
@@ -3329,7 +3488,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3329
3488
|
latestVersionName,
|
|
3330
3489
|
sessionKey,
|
|
3331
3490
|
checksum,
|
|
3332
|
-
manifest
|
|
3491
|
+
manifest,
|
|
3492
|
+
CapacitorUpdaterPlugin.this.shouldAutoSetNextBundle()
|
|
3333
3493
|
);
|
|
3334
3494
|
} else {
|
|
3335
3495
|
// Handle single file download (existing code)
|
|
@@ -3338,7 +3498,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
3338
3498
|
latestVersionName,
|
|
3339
3499
|
sessionKey,
|
|
3340
3500
|
checksum,
|
|
3341
|
-
null
|
|
3501
|
+
null,
|
|
3502
|
+
CapacitorUpdaterPlugin.this.shouldAutoSetNextBundle()
|
|
3342
3503
|
);
|
|
3343
3504
|
}
|
|
3344
3505
|
} catch (final Exception e) {
|
package/dist/docs.json
CHANGED
|
@@ -4049,13 +4049,13 @@
|
|
|
4049
4049
|
"name": "default"
|
|
4050
4050
|
},
|
|
4051
4051
|
{
|
|
4052
|
-
"text": "
|
|
4052
|
+
"text": "\"onlyDownload\"",
|
|
4053
4053
|
"name": "example"
|
|
4054
4054
|
}
|
|
4055
4055
|
],
|
|
4056
|
-
"docs": "Configure
|
|
4056
|
+
"docs": "Configure how the plugin should use Auto Update via an update server.\n\nBoolean values keep their existing behavior:\n- `true`: Same as `\"atBackground\"`.\n- `false`: Same as `\"off\"`.\n\nString values merge the previous Auto Update and Direct Update configuration:\n- `\"off\"`: Disable Auto Update.\n- `\"atBackground\"`: Check and download updates automatically, then apply them the next time the app moves to background.\n- `\"atInstall\"`: Direct install only after app install or native app update, otherwise use `\"atBackground\"` behavior.\n- `\"onLaunch\"`: Direct install on app launch, otherwise use `\"atBackground\"` behavior after the first launch attempt.\n- `\"always\"`: Direct install whenever Auto Update runs.\n- `\"onlyDownload\"`: Check and download updates automatically, emit `updateAvailable`, but never direct install or set the next bundle automatically.\n\nOnly available for Android and iOS.",
|
|
4057
4057
|
"complexTypes": [],
|
|
4058
|
-
"type": "boolean | undefined"
|
|
4058
|
+
"type": "boolean | 'always' | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'onlyDownload' | undefined"
|
|
4059
4059
|
},
|
|
4060
4060
|
{
|
|
4061
4061
|
"name": "resetWhenUpdate",
|
|
@@ -4156,6 +4156,10 @@
|
|
|
4156
4156
|
{
|
|
4157
4157
|
"name": "directUpdate",
|
|
4158
4158
|
"tags": [
|
|
4159
|
+
{
|
|
4160
|
+
"text": "Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.\nWorks well for apps less than 10MB and with uploads done using --delta flag.\nZip or apps more than 10MB will be relatively slow for users to update.\n- false: Never do direct updates (use default behavior: download at start, set when backgrounded)\n- atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false\n- onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false\n- always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false\n- true: (deprecated) Same as \"always\" for backward compatibility\n\nActivate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads.\nOnly available for Android and iOS.",
|
|
4161
|
+
"name": "deprecated"
|
|
4162
|
+
},
|
|
4159
4163
|
{
|
|
4160
4164
|
"text": "false",
|
|
4161
4165
|
"name": "default"
|
|
@@ -4165,7 +4169,7 @@
|
|
|
4165
4169
|
"name": "since"
|
|
4166
4170
|
}
|
|
4167
4171
|
],
|
|
4168
|
-
"docs": "Configure when the plugin should direct install updates. Only for autoUpdate mode
|
|
4172
|
+
"docs": "Configure when the plugin should direct install updates. Only for autoUpdate mode.",
|
|
4169
4173
|
"complexTypes": [],
|
|
4170
4174
|
"type": "boolean | 'always' | 'atInstall' | 'onLaunch' | undefined"
|
|
4171
4175
|
},
|
|
@@ -4181,7 +4185,7 @@
|
|
|
4181
4185
|
"name": "since"
|
|
4182
4186
|
}
|
|
4183
4187
|
],
|
|
4184
|
-
"docs": "Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\nThis removes the need to manually listen for appReady events and call SplashScreen.hide().\nOnly works when directUpdate is set to \"atInstall\", \"always\", \"onLaunch\", or true.\nRequires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\nRequires
|
|
4188
|
+
"docs": "Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\nThis removes the need to manually listen for appReady events and call SplashScreen.hide().\nOnly works when autoUpdate is set to \"atInstall\", \"always\", or \"onLaunch\", or when the deprecated directUpdate option is set to \"atInstall\", \"always\", \"onLaunch\", or true.\nRequires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\nRequires Auto Update and Direct Update behavior to be enabled.\n\nOnly available for Android and iOS.",
|
|
4185
4189
|
"complexTypes": [],
|
|
4186
4190
|
"type": "boolean | undefined"
|
|
4187
4191
|
},
|
|
@@ -42,14 +42,26 @@ declare module '@capacitor/cli' {
|
|
|
42
42
|
*/
|
|
43
43
|
autoDeletePrevious?: boolean;
|
|
44
44
|
/**
|
|
45
|
-
* Configure
|
|
45
|
+
* Configure how the plugin should use Auto Update via an update server.
|
|
46
|
+
*
|
|
47
|
+
* Boolean values keep their existing behavior:
|
|
48
|
+
* - `true`: Same as `"atBackground"`.
|
|
49
|
+
* - `false`: Same as `"off"`.
|
|
50
|
+
*
|
|
51
|
+
* String values merge the previous Auto Update and Direct Update configuration:
|
|
52
|
+
* - `"off"`: Disable Auto Update.
|
|
53
|
+
* - `"atBackground"`: Check and download updates automatically, then apply them the next time the app moves to background.
|
|
54
|
+
* - `"atInstall"`: Direct install only after app install or native app update, otherwise use `"atBackground"` behavior.
|
|
55
|
+
* - `"onLaunch"`: Direct install on app launch, otherwise use `"atBackground"` behavior after the first launch attempt.
|
|
56
|
+
* - `"always"`: Direct install whenever Auto Update runs.
|
|
57
|
+
* - `"onlyDownload"`: Check and download updates automatically, emit `updateAvailable`, but never direct install or set the next bundle automatically.
|
|
46
58
|
*
|
|
47
59
|
* Only available for Android and iOS.
|
|
48
60
|
*
|
|
49
61
|
* @default true
|
|
50
|
-
* @example
|
|
62
|
+
* @example "onlyDownload"
|
|
51
63
|
*/
|
|
52
|
-
autoUpdate?: boolean;
|
|
64
|
+
autoUpdate?: boolean | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload';
|
|
53
65
|
/**
|
|
54
66
|
* Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.
|
|
55
67
|
* Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native.
|
|
@@ -111,6 +123,8 @@ declare module '@capacitor/cli' {
|
|
|
111
123
|
version?: string;
|
|
112
124
|
/**
|
|
113
125
|
* Configure when the plugin should direct install updates. Only for autoUpdate mode.
|
|
126
|
+
*
|
|
127
|
+
* @deprecated Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.
|
|
114
128
|
* Works well for apps less than 10MB and with uploads done using --delta flag.
|
|
115
129
|
* Zip or apps more than 10MB will be relatively slow for users to update.
|
|
116
130
|
* - false: Never do direct updates (use default behavior: download at start, set when backgrounded)
|
|
@@ -129,9 +143,9 @@ declare module '@capacitor/cli' {
|
|
|
129
143
|
/**
|
|
130
144
|
* Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.
|
|
131
145
|
* This removes the need to manually listen for appReady events and call SplashScreen.hide().
|
|
132
|
-
* Only works when directUpdate is set to "atInstall", "always", "onLaunch", or true.
|
|
146
|
+
* Only works when autoUpdate is set to "atInstall", "always", or "onLaunch", or when the deprecated directUpdate option is set to "atInstall", "always", "onLaunch", or true.
|
|
133
147
|
* Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
|
|
134
|
-
* Requires
|
|
148
|
+
* Requires Auto Update and Direct Update behavior to be enabled.
|
|
135
149
|
*
|
|
136
150
|
* Only available for Android and iOS.
|
|
137
151
|
*
|