@capgo/capacitor-updater 5.51.15 → 5.51.21

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.
Files changed (29) hide show
  1. package/CapgoCapacitorUpdater.podspec +0 -2
  2. package/Package.swift +2 -4
  3. package/README.md +50 -41
  4. package/android/build.gradle +6 -6
  5. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +45 -36
  6. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +302 -318
  7. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +11 -0
  8. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +227 -64
  9. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +12 -1
  10. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +12 -16
  11. package/dist/docs.json +4 -4
  12. package/dist/esm/definitions.d.ts +12 -9
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/esm/history.js +7 -7
  15. package/dist/esm/history.js.map +1 -1
  16. package/dist/plugin.cjs.js +7 -7
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +7 -7
  19. package/dist/plugin.js.map +1 -1
  20. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +177 -55
  21. package/ios/Sources/CapacitorUpdaterPlugin/CapgoRawRsa.swift +36 -0
  22. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +27 -13
  23. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +30 -30
  24. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +16 -41
  25. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +5 -5
  26. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +73 -251
  27. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +2 -2
  28. package/package.json +8 -9
  29. package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +0 -39
@@ -146,7 +146,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
146
146
  static final int APPLICATION_EXIT_REASON_USER_REQUESTED = 10;
147
147
  static final int APPLICATION_EXIT_REASON_DEPENDENCY_DIED = 12;
148
148
 
149
- private final String pluginVersion = "5.51.15";
149
+ private final String pluginVersion = "5.51.21";
150
150
  private static final String DELAY_CONDITION_PREFERENCES = "";
151
151
 
152
152
  private SharedPreferences.Editor editor;
@@ -290,6 +290,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
290
290
 
291
291
  // Play Store In-App Updates
292
292
  private AppUpdateManager appUpdateManager;
293
+ private PluginCall pendingAppUpdateCall;
293
294
  private AppUpdateInfo cachedAppUpdateInfo;
294
295
  private static final int APP_UPDATE_REQUEST_CODE = 9001;
295
296
  private InstallStateUpdatedListener installStateUpdatedListener;
@@ -2138,9 +2139,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
2138
2139
  );
2139
2140
  }
2140
2141
  } else {
2141
- final boolean enabled = configuredMode != null
2142
- ? "true".equals(configuredMode)
2143
- : Boolean.TRUE.equals(this.getConfig().getBoolean("autoUpdate", true));
2142
+ final boolean enabled =
2143
+ configuredMode != null
2144
+ ? "true".equals(configuredMode)
2145
+ : Boolean.TRUE.equals(this.getConfig().getBoolean("autoUpdate", true));
2144
2146
  this.autoUpdateMode = enabled
2145
2147
  ? autoUpdateModeForLegacyDirectUpdateMode(this.resolveLegacyDirectUpdateModeFromConfig())
2146
2148
  : AUTO_UPDATE_MODE_OFF;
@@ -4012,33 +4014,30 @@ public class CapacitorUpdaterPlugin extends Plugin {
4012
4014
  this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, false);
4013
4015
  this.editor.apply();
4014
4016
 
4015
- new Handler(Looper.getMainLooper()).postDelayed(
4016
- () -> {
4017
- try {
4018
- if (!Boolean.TRUE.equals(this.previewSessionEnabled)) {
4019
- return;
4020
- }
4021
- if (getActivity() == null || getActivity().isFinishing()) {
4022
- this.previewSessionAlertPending = true;
4023
- this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4024
- this.editor.apply();
4025
- return;
4026
- }
4027
-
4028
- new AlertDialog.Builder(getActivity())
4029
- .setTitle("Preview started")
4030
- .setMessage("shake".equals(this.shakeMenuGesture) ? "Shake to open menu." : "Three-finger pinch to open menu.")
4031
- .setPositiveButton("Got it", (dialog, which) -> dialog.dismiss())
4032
- .show();
4033
- } catch (final Exception e) {
4017
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
4018
+ try {
4019
+ if (!Boolean.TRUE.equals(this.previewSessionEnabled)) {
4020
+ return;
4021
+ }
4022
+ if (getActivity() == null || getActivity().isFinishing()) {
4034
4023
  this.previewSessionAlertPending = true;
4035
4024
  this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4036
4025
  this.editor.apply();
4037
- logger.warn("Could not show preview session notice: " + e.getMessage());
4026
+ return;
4038
4027
  }
4039
- },
4040
- 600
4041
- );
4028
+
4029
+ new AlertDialog.Builder(getActivity())
4030
+ .setTitle("Preview started")
4031
+ .setMessage("shake".equals(this.shakeMenuGesture) ? "Shake to open menu." : "Three-finger pinch to open menu.")
4032
+ .setPositiveButton("Got it", (dialog, which) -> dialog.dismiss())
4033
+ .show();
4034
+ } catch (final Exception e) {
4035
+ this.previewSessionAlertPending = true;
4036
+ this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4037
+ this.editor.apply();
4038
+ logger.warn("Could not show preview session notice: " + e.getMessage());
4039
+ }
4040
+ }, 600);
4042
4041
  }
4043
4042
 
4044
4043
  @PluginMethod
@@ -4784,8 +4783,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
4784
4783
  final String messageUpdate = initialDirectUpdateAllowed
4785
4784
  ? "Update will occur now."
4786
4785
  : this.shouldAutoSetNextBundle()
4787
- ? "Update will occur next time app moves to background."
4788
- : "Update will be downloaded and made available.";
4786
+ ? "Update will occur next time app moves to background."
4787
+ : "Update will be downloaded and made available.";
4789
4788
  Thread newTask = startNewThread(() -> {
4790
4789
  if (CapacitorUpdaterPlugin.this.shouldBlockAutoUpdateForPreviewSession()) {
4791
4790
  CapacitorUpdaterPlugin.this.clearBackgroundDownloadState();
@@ -5681,8 +5680,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
5681
5680
  return;
5682
5681
  }
5683
5682
 
5684
- // Save the call for later resolution
5685
- bridge.saveCall(call);
5683
+ if (pendingAppUpdateCall != null) {
5684
+ call.reject("An app update flow is already in progress");
5685
+ return;
5686
+ }
5687
+
5688
+ call.setKeepAlive(true);
5689
+ pendingAppUpdateCall = call;
5686
5690
 
5687
5691
  AppUpdateManager manager = getAppUpdateManager();
5688
5692
  manager.startUpdateFlowForResult(
@@ -5754,8 +5758,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
5754
5758
 
5755
5759
  manager.registerListener(installStateUpdatedListener);
5756
5760
 
5757
- // Save the call for later resolution
5758
- bridge.saveCall(call);
5761
+ if (pendingAppUpdateCall != null) {
5762
+ call.reject("An app update flow is already in progress");
5763
+ return;
5764
+ }
5765
+
5766
+ call.setKeepAlive(true);
5767
+ pendingAppUpdateCall = call;
5759
5768
 
5760
5769
  manager.startUpdateFlowForResult(
5761
5770
  cachedAppUpdateInfo,
@@ -5796,11 +5805,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
5796
5805
  super.handleOnActivityResult(requestCode, resultCode, data);
5797
5806
 
5798
5807
  if (requestCode == APP_UPDATE_REQUEST_CODE) {
5799
- PluginCall savedCall = bridge.getSavedCall("com.getcapacitor.PluginCall");
5808
+ PluginCall savedCall = pendingAppUpdateCall;
5800
5809
  if (savedCall == null) {
5801
- // Try to get any saved call (for backward compatibility)
5802
5810
  return;
5803
5811
  }
5812
+ pendingAppUpdateCall = null;
5804
5813
 
5805
5814
  JSObject result = new JSObject();
5806
5815
  if (resultCode == Activity.RESULT_OK) {
@@ -5810,8 +5819,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
5810
5819
  } else {
5811
5820
  result.put("code", RESULT_FAILED);
5812
5821
  }
5822
+ savedCall.setKeepAlive(false);
5813
5823
  savedCall.resolve(result);
5814
- bridge.releaseCall(savedCall);
5815
5824
  }
5816
5825
  }
5817
5826