@capgo/capacitor-updater 5.50.2 → 5.51.15
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/CapgoCapacitorUpdater.podspec +1 -1
- package/Package.swift +3 -2
- package/README.md +53 -48
- package/android/build.gradle +1 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +29 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +7 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +452 -139
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1354 -412
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +102 -31
- package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +23 -7
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +2 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +540 -224
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +103 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +131 -145
- package/dist/docs.json +32 -8
- package/dist/esm/definitions.d.ts +41 -17
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +124 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +9 -1
- package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +3 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +787 -92
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1014 -268
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +49 -31
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +44 -20
- package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +28 -0
- package/package.json +12 -7
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '13.
|
|
14
|
+
s.ios.deployment_target = '13.4'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.dependency 'ZIPFoundation', '~> 0.9'
|
|
17
17
|
s.dependency 'Alamofire', '5.10.2'
|
package/Package.swift
CHANGED
|
@@ -3,7 +3,7 @@ import PackageDescription
|
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
5
|
name: "CapgoCapacitorUpdater",
|
|
6
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS("13.4")],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
9
|
name: "CapgoCapacitorUpdater",
|
|
@@ -32,7 +32,8 @@ let package = Package(
|
|
|
32
32
|
name: "CapacitorUpdaterPluginTests",
|
|
33
33
|
dependencies: [
|
|
34
34
|
"CapacitorUpdaterPlugin",
|
|
35
|
-
.product(name: "Version", package: "Version")
|
|
35
|
+
.product(name: "Version", package: "Version"),
|
|
36
|
+
.product(name: "ZIPFoundation", package: "ZIPFoundation")
|
|
36
37
|
],
|
|
37
38
|
path: "ios/Tests/CapacitorUpdaterPluginTests")
|
|
38
39
|
],
|
package/README.md
CHANGED
|
@@ -300,46 +300,47 @@ Downgrading to a previous version of the updater plugin is not supported.
|
|
|
300
300
|
|
|
301
301
|
CapacitorUpdater can be configured with these options:
|
|
302
302
|
|
|
303
|
-
| Prop
|
|
304
|
-
|
|
|
305
|
-
| **`appReadyTimeout`**
|
|
306
|
-
| **`responseTimeout`**
|
|
307
|
-
| **`autoDeleteFailed`**
|
|
308
|
-
| **`autoDeletePrevious`**
|
|
309
|
-
| **`autoUpdate`**
|
|
310
|
-
| **`resetWhenUpdate`**
|
|
311
|
-
| **`updateUrl`**
|
|
312
|
-
| **`channelUrl`**
|
|
313
|
-
| **`statsUrl`**
|
|
314
|
-
| **`publicKey`**
|
|
315
|
-
| **`version`**
|
|
316
|
-
| **`directUpdate`**
|
|
317
|
-
| **`autoSplashscreen`**
|
|
318
|
-
| **`autoSplashscreenLoader`**
|
|
319
|
-
| **`autoSplashscreenTimeout`**
|
|
320
|
-
| **`periodCheckDelay`**
|
|
321
|
-
| **`localS3`**
|
|
322
|
-
| **`localHost`**
|
|
323
|
-
| **`localWebHost`**
|
|
324
|
-
| **`localSupa`**
|
|
325
|
-
| **`localSupaAnon`**
|
|
326
|
-
| **`localApi`**
|
|
327
|
-
| **`localApiFiles`**
|
|
328
|
-
| **`allowModifyUrl`**
|
|
329
|
-
| **`allowModifyAppId`**
|
|
330
|
-
| **`allowManualBundleError`**
|
|
331
|
-
| **`allowPreview`**
|
|
332
|
-
| **`persistCustomId`**
|
|
333
|
-
| **`persistModifyUrl`**
|
|
334
|
-
| **`allowSetDefaultChannel`**
|
|
335
|
-
| **`
|
|
336
|
-
| **`
|
|
337
|
-
| **`
|
|
338
|
-
| **`
|
|
339
|
-
| **`
|
|
340
|
-
| **`
|
|
341
|
-
| **`
|
|
342
|
-
| **`
|
|
303
|
+
| Prop | Type | Description | Default | Since |
|
|
304
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
|
|
305
|
+
| **`appReadyTimeout`** | <code>number</code> | Configure the number of milliseconds the native plugin should wait before considering an update 'failed'. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | |
|
|
306
|
+
| **`responseTimeout`** | <code>number</code> | Configure the number of seconds the native plugin should wait before considering an HTTP timeout. Applies to update checks and file downloads. On Android these are idle connect/read/write timeouts and do not cap total download time; on iOS the request timeout also bounds the total download duration. Only available for Android and iOS. | <code>20 // (20 second)</code> | |
|
|
307
|
+
| **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | <code>true</code> | |
|
|
308
|
+
| **`autoDeletePrevious`** | <code>boolean</code> | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. | <code>true</code> | |
|
|
309
|
+
| **`autoUpdate`** | <code>boolean \| 'always' \| 'off' \| 'atBackground' \| 'atInstall' \| 'onLaunch' \| 'onlyDownload'</code> | Configure how the plugin checks for, downloads, and applies live updates. The plugin checks for updates when the app moves to the foreground. When {@link periodCheckDelay} is greater than 0, it also checks on a repeating timer while the app stays open. Boolean values keep their existing behavior: - `true`: Same as `"atBackground"`. - `false`: Same as `"off"`. String values merge the previous Auto Update and Direct Update configuration: - `"off"`: Disable automatic update checks. - `"atBackground"`: Check and download automatically on each foreground check, then apply the update the next time the app moves to background. - `"atInstall"`: Apply immediately only after a fresh install or native app store update; otherwise use `"atBackground"` behavior. - `"onLaunch"`: Apply immediately only when the app is brought to the foreground from a killed state (cold start). After that first check, fall back to `"atBackground"` behavior. - `"always"`: Check on every foreground transition and apply immediately whenever an update is available. - `"onlyDownload"`: Check and download automatically, emit `updateAvailable`, and never set the next bundle or apply an update automatically. Only available for Android and iOS. | <code>true</code> | |
|
|
310
|
+
| **`resetWhenUpdate`** | <code>boolean</code> | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. 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. Only available for Android and iOS. | <code>true</code> | |
|
|
311
|
+
| **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | <code>https://plugin.capgo.app/updates</code> | |
|
|
312
|
+
| **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | <code>https://plugin.capgo.app/channel_self</code> | |
|
|
313
|
+
| **`statsUrl`** | <code>string</code> | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. Native stats include update lifecycle events, app health signals such as crashes, Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals such as JavaScript errors, unhandled promise rejections, resource load failures, WebView renderer exits, unclean WebView restarts, app launch readiness timing, and WebView load milestones when available. | <code>https://plugin.capgo.app/stats</code> | |
|
|
314
|
+
| **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | <code>undefined</code> | 6.2.0 |
|
|
315
|
+
| **`version`** | <code>string</code> | Configure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS. | <code>undefined</code> | 4.17.48 |
|
|
316
|
+
| **`directUpdate`** | <code>boolean \| 'always' \| 'atInstall' \| 'onLaunch'</code> | Configure when the plugin should direct install updates. Only for autoUpdate mode. | <code>false</code> | 5.1.0 |
|
|
317
|
+
| **`autoSplashscreen`** | <code>boolean</code> | 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. This removes the need to manually listen for appReady events and call SplashScreen.hide(). 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. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Requires Auto Update and Direct Update behavior to be enabled. Only available for Android and iOS. | <code>false</code> | 7.6.0 |
|
|
318
|
+
| **`autoSplashscreenLoader`** | <code>boolean</code> | Display a native loading indicator on top of the splashscreen while automatic direct updates are running. Only takes effect when {@link autoSplashscreen} is enabled. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Only available for Android and iOS. | <code>false</code> | 7.19.0 |
|
|
319
|
+
| **`autoSplashscreenTimeout`** | <code>number</code> | Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates. If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed. Set to `0` (zero) to disable the timeout. When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch. Requires {@link autoSplashscreen} to be enabled. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | 7.19.0 |
|
|
320
|
+
| **`periodCheckDelay`** | <code>number</code> | Configure the interval in seconds for repeating update checks while the app stays open. Foreground checks still run when this is 0. Values below 600 are normalized to 600. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes). | <code>0 (disabled)</code> | |
|
|
321
|
+
| **`localS3`** | <code>boolean</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
|
|
322
|
+
| **`localHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
|
|
323
|
+
| **`localWebHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
|
|
324
|
+
| **`localSupa`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
|
|
325
|
+
| **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing. | <code>undefined</code> | 4.17.48 |
|
|
326
|
+
| **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing. | <code>undefined</code> | 6.3.3 |
|
|
327
|
+
| **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing. | <code>undefined</code> | 6.3.3 |
|
|
328
|
+
| **`allowModifyUrl`** | <code>boolean</code> | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. | <code>false</code> | 5.4.0 |
|
|
329
|
+
| **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side. | <code>false</code> | 7.14.0 |
|
|
330
|
+
| **`allowManualBundleError`** | <code>boolean</code> | Allow marking bundles as errored from JavaScript while using manual update flows. When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`. | <code>false</code> | 7.20.0 |
|
|
331
|
+
| **`allowPreview`** | <code>boolean</code> | Allow JavaScript to start a native preview session and temporarily request updates for another app id. This is intended for trusted container apps that implement Expo Go-style preview flows. Only available for Android and iOS. | <code>false</code> | 8.47.0 |
|
|
332
|
+
| **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS. | <code>false (will be true by default in a future major release v8.x.x)</code> | 7.17.3 |
|
|
333
|
+
| **`persistModifyUrl`** | <code>boolean</code> | Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl}, {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts. Only available for Android and iOS. | <code>false</code> | 7.20.0 |
|
|
334
|
+
| **`allowSetDefaultChannel`** | <code>boolean</code> | Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel. When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`. | <code>true</code> | 7.34.0 |
|
|
335
|
+
| **`persistDefaultChannelOnReinstall`** | <code>boolean</code> | Keep the default channel stored by {@link CapacitorUpdaterPlugin.setChannel} or refreshed by {@link CapacitorUpdaterPlugin.getChannel} when app data is restored into a new app install. `setChannel()` and a successful `getChannel()` still persist the selected channel across app restarts. When this option is `false`, native startup clears that persisted channel when it detects app data restored into a new installation. Native build cleanup clears the persisted channel only when `persistDefaultChannelOnReinstall` is `false`, `resetWhenUpdate` is `true`, and the native build version has changed. Only available for Android and iOS. | <code>true</code> | 8.51.0 |
|
|
336
|
+
| **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options | <code>undefined</code> | 5.5.0 |
|
|
337
|
+
| **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
|
|
338
|
+
| **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
|
|
339
|
+
| **`disableJSLogging`** | <code>boolean</code> | Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done | <code>false</code> | 7.3.0 |
|
|
340
|
+
| **`osLogging`** | <code>boolean</code> | Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds. - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments - **Android**: Logs to Logcat (android.util.Log) When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled). This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android). | <code>true</code> | 8.42.0 |
|
|
341
|
+
| **`shakeMenu`** | <code>boolean</code> | Enable the native preview menu gesture while a preview session is active. Outside preview sessions this preview menu is ignored, unless {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled. | <code>false</code> | 7.5.0 |
|
|
342
|
+
| **`shakeMenuGesture`** | <code><a href="#shakemenugesture">ShakeMenuGesture</a></code> | Choose which native gesture opens the preview/channel menu. This applies to both {@link PluginsConfig.CapacitorUpdater.shakeMenu} and {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}. Only available for Android and iOS. | <code>'shake'</code> | 8.48.0 |
|
|
343
|
+
| **`allowShakeChannelSelector`** | <code>boolean</code> | Enable the native menu gesture to show a channel selector menu for switching between update channels. If {@link PluginsConfig.CapacitorUpdater.shakeMenu} is also enabled while a preview session is active, the shake menu includes both preview actions and channel switching. The native gesture can be changed with {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}. Only available for Android and iOS. | <code>false</code> | 8.43.0 |
|
|
343
344
|
|
|
344
345
|
### Examples
|
|
345
346
|
|
|
@@ -379,6 +380,7 @@ In `capacitor.config.json`:
|
|
|
379
380
|
"persistCustomId": undefined,
|
|
380
381
|
"persistModifyUrl": undefined,
|
|
381
382
|
"allowSetDefaultChannel": undefined,
|
|
383
|
+
"persistDefaultChannelOnReinstall": undefined,
|
|
382
384
|
"defaultChannel": undefined,
|
|
383
385
|
"appId": undefined,
|
|
384
386
|
"keepUrlPathAfterReload": undefined,
|
|
@@ -432,6 +434,7 @@ const config: CapacitorConfig = {
|
|
|
432
434
|
persistCustomId: undefined,
|
|
433
435
|
persistModifyUrl: undefined,
|
|
434
436
|
allowSetDefaultChannel: undefined,
|
|
437
|
+
persistDefaultChannelOnReinstall: undefined,
|
|
435
438
|
defaultChannel: undefined,
|
|
436
439
|
appId: undefined,
|
|
437
440
|
keepUrlPathAfterReload: undefined,
|
|
@@ -659,7 +662,9 @@ For multi-file delta updates, provide the `manifest` array.
|
|
|
659
662
|
**Android Background Runner note:** `@capacitor/background-runner` loads its
|
|
660
663
|
configured runner script from native APK assets. Live updates cannot replace
|
|
661
664
|
that runner script. Keep it stable across OTA updates and ship a native app
|
|
662
|
-
update when the runner code changes.
|
|
665
|
+
update when the runner code changes. When a bundle switch happens, Capacitor
|
|
666
|
+
Updater cancels and reschedules configured Background Runner WorkManager jobs
|
|
667
|
+
and syncs the bundled runner script into native `public/` storage when present.
|
|
663
668
|
|
|
664
669
|
| Param | Type | Description |
|
|
665
670
|
| ------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
@@ -1261,9 +1266,9 @@ Channels allow you to distribute different bundle versions to different groups o
|
|
|
1261
1266
|
(e.g., "production", "beta", "staging"). This method switches the device to a new channel.
|
|
1262
1267
|
|
|
1263
1268
|
**Device Override UI:** `setChannel()` validates the channel with the backend, then stores the
|
|
1264
|
-
selected channel locally on the device. It does not create or update
|
|
1265
|
-
so the device will not appear as overridden in the Capgo dashboard.
|
|
1266
|
-
from the dashboard or the Public API are shown in the Device Override UI.
|
|
1269
|
+
selected channel locally on the device for future app restarts. It does not create or update
|
|
1270
|
+
a backend Device Override, so the device will not appear as overridden in the Capgo dashboard.
|
|
1271
|
+
Only assignments created from the dashboard or the Public API are shown in the Device Override UI.
|
|
1267
1272
|
|
|
1268
1273
|
**Requirements:**
|
|
1269
1274
|
- The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
|
|
@@ -1292,7 +1297,7 @@ CapacitorUpdater.addListener('channelPrivate', (data) => {
|
|
|
1292
1297
|
```
|
|
1293
1298
|
|
|
1294
1299
|
This sends a request to the Capgo backend to validate the specified channel, then stores the
|
|
1295
|
-
channel locally on the device.
|
|
1300
|
+
channel locally on the device for future app restarts.
|
|
1296
1301
|
|
|
1297
1302
|
| Param | Type | Description |
|
|
1298
1303
|
| ------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -1351,8 +1356,8 @@ Use this to:
|
|
|
1351
1356
|
- Check if a device is on a specific channel before showing features
|
|
1352
1357
|
- Verify channel assignment after calling {@link setChannel}
|
|
1353
1358
|
|
|
1354
|
-
On native platforms, a successful response also refreshes the
|
|
1355
|
-
|
|
1359
|
+
On native platforms, a successful response also refreshes the default channel used by update checks.
|
|
1360
|
+
This refresh is persisted across app restarts.
|
|
1356
1361
|
|
|
1357
1362
|
**Returns:** <code>Promise<<a href="#getchannelres">GetChannelRes</a>></code>
|
|
1358
1363
|
|
|
@@ -2855,7 +2860,7 @@ downloading: The bundle is being downloaded.
|
|
|
2855
2860
|
success: The bundle has been downloaded and is ready to be **SET** as the next bundle.
|
|
2856
2861
|
error: The bundle has failed to download.
|
|
2857
2862
|
|
|
2858
|
-
<code>'success' | 'error' | 'pending' | 'downloading'</code>
|
|
2863
|
+
<code>'success' | 'error' | 'pending' | 'downloading' | 'deleted' | 'deleting'</code>
|
|
2859
2864
|
|
|
2860
2865
|
|
|
2861
2866
|
##### DelayUntilNext
|
package/android/build.gradle
CHANGED
|
@@ -53,6 +53,7 @@ dependencies {
|
|
|
53
53
|
def lifecycle_version = "2.10.0"
|
|
54
54
|
implementation "androidx.work:work-runtime:$work_version"
|
|
55
55
|
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
|
|
56
|
+
// play-services-tasks 18.4.1 requires minSdk 23
|
|
56
57
|
implementation "com.google.android.gms:play-services-tasks:18.4.1"
|
|
57
58
|
implementation "com.google.guava:guava:33.6.0-android"
|
|
58
59
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
package ee.forgr.capacitor_updater;
|
|
8
8
|
|
|
9
|
+
import android.content.Context;
|
|
9
10
|
import androidx.annotation.NonNull;
|
|
10
11
|
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
11
12
|
import androidx.lifecycle.LifecycleOwner;
|
|
13
|
+
import androidx.lifecycle.ProcessLifecycleInitializer;
|
|
12
14
|
import androidx.lifecycle.ProcessLifecycleOwner;
|
|
15
|
+
import androidx.startup.AppInitializer;
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Observes app-level lifecycle events using ProcessLifecycleOwner.
|
|
@@ -41,16 +44,40 @@ public class AppLifecycleObserver implements DefaultLifecycleObserver {
|
|
|
41
44
|
this.logger = logger;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
public
|
|
47
|
+
public boolean isRegistered() {
|
|
48
|
+
return isRegistered;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void register(Context context) {
|
|
45
52
|
if (isRegistered) {
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
55
|
+
if (context == null) {
|
|
56
|
+
logger.error("Cannot register AppLifecycleObserver without context");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// get()/addObserver() succeed even when ProcessLifecycleOwner.init() never ran.
|
|
60
|
+
// Initialize first; if that fails, leave isRegistered false so activity fallback runs.
|
|
61
|
+
try {
|
|
62
|
+
AppInitializer.getInstance(context.getApplicationContext()).initializeComponent(ProcessLifecycleInitializer.class);
|
|
63
|
+
} catch (Exception e) {
|
|
64
|
+
logger.error("Failed to initialize ProcessLifecycleOwner: " + e.getMessage());
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!addObserver()) {
|
|
68
|
+
logger.error("Failed to register AppLifecycleObserver with ProcessLifecycleOwner");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private boolean addObserver() {
|
|
48
73
|
try {
|
|
49
74
|
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
|
50
75
|
isRegistered = true;
|
|
51
76
|
logger.info("AppLifecycleObserver registered with ProcessLifecycleOwner");
|
|
77
|
+
return true;
|
|
52
78
|
} catch (Exception e) {
|
|
53
|
-
logger.error("Failed to
|
|
79
|
+
logger.error("Failed to add AppLifecycleObserver: " + e.getMessage());
|
|
80
|
+
return false;
|
|
54
81
|
}
|
|
55
82
|
}
|
|
56
83
|
|
|
@@ -94,12 +94,16 @@ public class BundleInfo {
|
|
|
94
94
|
return BundleStatus.DELETED == this.status;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
public Boolean isDeleting() {
|
|
98
|
+
return BundleStatus.DELETING == this.status;
|
|
99
|
+
}
|
|
100
|
+
|
|
97
101
|
public boolean isDownloaded() {
|
|
98
|
-
return
|
|
102
|
+
return !this.isBuiltin() && this.downloaded != null && !this.downloaded.isEmpty() && !this.isDeleted() && !this.isDeleting();
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
public String getDownloaded() {
|
|
102
|
-
return this.isBuiltin() ? DOWNLOADED_BUILTIN :
|
|
106
|
+
return this.isBuiltin() ? DOWNLOADED_BUILTIN : this.downloaded != null ? this.downloaded : "";
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
public BundleInfo setDownloaded(Date downloaded) {
|
|
@@ -107,7 +111,7 @@ public class BundleInfo {
|
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
public String getChecksum() {
|
|
110
|
-
return this.isBuiltin() ? "" :
|
|
114
|
+
return this.isBuiltin() ? "" : this.checksum != null ? this.checksum : "";
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
public BundleInfo setChecksum(String checksum) {
|