@capgo/capacitor-updater 9.0.0 → 9.0.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.
Files changed (109) hide show
  1. package/CapgoCapacitorUpdater.podspec +3 -6
  2. package/Package.swift +30 -0
  3. package/README.md +2406 -291
  4. package/android/build.gradle +37 -17
  5. package/android/consumer-rules.pro +48 -0
  6. package/android/proguard-rules.pro +23 -0
  7. package/android/src/main/AndroidManifest.xml +0 -1
  8. package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
  9. package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +115 -0
  10. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +227 -195
  11. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +24 -23
  12. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  13. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +7927 -1243
  14. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +5785 -0
  15. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +564 -121
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +44 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +427 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +230 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +2041 -118
  22. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +301 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +569 -0
  24. package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +436 -0
  25. package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +604 -0
  26. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +79 -0
  27. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +419 -0
  28. package/android/src/main/java/ee/forgr/capacitor_updater/NativeUpdatePrompt.java +303 -0
  29. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  30. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +963 -0
  31. package/android/src/main/java/ee/forgr/capacitor_updater/StatsBatchFailureDiagnostics.java +40 -0
  32. package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
  33. package/android/src/main/java/ee/forgr/capacitor_updater/Version.java +306 -0
  34. package/dist/docs.json +4431 -840
  35. package/dist/esm/definitions.d.ts +2641 -225
  36. package/dist/esm/definitions.js +103 -1
  37. package/dist/esm/definitions.js.map +1 -1
  38. package/dist/esm/history.d.ts +1 -0
  39. package/dist/esm/history.js +283 -0
  40. package/dist/esm/history.js.map +1 -0
  41. package/dist/esm/index.d.ts +3 -2
  42. package/dist/esm/index.js +5 -4
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/web.d.ts +53 -42
  45. package/dist/esm/web.js +180 -37
  46. package/dist/esm/web.js.map +1 -1
  47. package/dist/plugin.cjs.js +570 -37
  48. package/dist/plugin.cjs.js.map +1 -1
  49. package/dist/plugin.js +570 -37
  50. package/dist/plugin.js.map +1 -1
  51. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +262 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
  53. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +185 -0
  54. package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +127 -0
  55. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +6813 -0
  56. package/ios/Sources/CapacitorUpdaterPlugin/CapgoRawRsa.swift +36 -0
  57. package/ios/Sources/CapacitorUpdaterPlugin/CapgoSemanticVersion.swift +200 -0
  58. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +5099 -0
  59. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +387 -0
  60. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +343 -0
  61. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  62. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +452 -0
  63. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +380 -0
  64. package/ios/Sources/CapacitorUpdaterPlugin/NativeUpdatePrompt.swift +183 -0
  65. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +96 -0
  66. package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +97 -0
  67. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +876 -0
  68. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  69. package/ios/Sources/CapacitorUpdaterPlugin/WKWebView+CapgoObjcBridge.swift +20 -0
  70. package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +304 -0
  71. package/ios/Sources/CapacitorUpdaterPlugin/ZipArchiveReader.swift +247 -0
  72. package/ios/Sources/CapacitorUpdaterPlugin/ZipCentralDirectory.swift +280 -0
  73. package/ios/Tests/CapacitorUpdaterPluginTests/BuiltinHashesTests.swift +210 -0
  74. package/ios/Tests/CapacitorUpdaterPluginTests/BundleHardeningTests.swift +292 -0
  75. package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +6533 -0
  76. package/ios/Tests/CapacitorUpdaterPluginTests/CapgoSemanticVersionTests.swift +64 -0
  77. package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +156 -0
  78. package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +314 -0
  79. package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +653 -0
  80. package/ios/Tests/CapacitorUpdaterPluginTests/InstallPerfTests.swift +174 -0
  81. package/ios/Tests/CapacitorUpdaterPluginTests/ListChannelsTests.swift +74 -0
  82. package/ios/Tests/CapacitorUpdaterPluginTests/LoggerSecurityTests.swift +149 -0
  83. package/ios/Tests/CapacitorUpdaterPluginTests/NativeContractTests.swift +160 -0
  84. package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +1109 -0
  85. package/ios/Tests/CapacitorUpdaterPluginTests/PopulateDeltaCacheTests.swift +573 -0
  86. package/ios/Tests/CapacitorUpdaterPluginTests/RedirectPolicyTests.swift +63 -0
  87. package/ios/Tests/CapacitorUpdaterPluginTests/RsaContractTests.swift +281 -0
  88. package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +196 -0
  89. package/ios/Tests/CapacitorUpdaterPluginTests/TestZipWriter.swift +235 -0
  90. package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +470 -0
  91. package/ios/Tests/CapacitorUpdaterPluginTests/WebKitOverlayGuardTests.swift +32 -0
  92. package/ios/Tests/CapacitorUpdaterPluginTests/ZipArchiveReaderTests.swift +302 -0
  93. package/ios/Tests/CapacitorUpdaterPluginTests/ZipBundleExtractionTests.swift +122 -0
  94. package/package.json +80 -43
  95. package/scripts/builtin-hashes-lib.mjs +148 -0
  96. package/scripts/capacitor-builtin-hashes-hook.mjs +65 -0
  97. package/scripts/resolve-real-path.mjs +25 -0
  98. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
  99. package/ios/Plugin/BundleInfo.swift +0 -113
  100. package/ios/Plugin/BundleStatus.swift +0 -48
  101. package/ios/Plugin/CapacitorUpdater.swift +0 -858
  102. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  103. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  104. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -677
  105. package/ios/Plugin/CryptoCipher.swift +0 -240
  106. /package/{LICENCE → LICENSE} +0 -0
  107. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  108. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  109. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
@@ -6,9 +6,10 @@
6
6
 
7
7
  package ee.forgr.capacitor_updater;
8
8
 
9
- import com.getcapacitor.JSObject;
10
9
  import java.text.SimpleDateFormat;
11
10
  import java.util.Date;
11
+ import java.util.HashMap;
12
+ import java.util.Map;
12
13
  import java.util.Objects;
13
14
  import java.util.TimeZone;
14
15
  import org.json.JSONException;
@@ -17,198 +18,229 @@ import org.json.JSONTokener;
17
18
 
18
19
  public class BundleInfo {
19
20
 
20
- private static final SimpleDateFormat sdf = new SimpleDateFormat(
21
- "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
22
- );
23
-
24
- public static final String ID_BUILTIN = "builtin";
25
- public static final String VERSION_UNKNOWN = "unknown";
26
- public static final String DOWNLOADED_BUILTIN = "1970-01-01T00:00:00.000Z";
27
-
28
- private final String downloaded;
29
- private final String id;
30
- private final String version;
31
- private final String checksum;
32
- private final BundleStatus status;
33
-
34
- static {
35
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
36
- }
37
-
38
- public BundleInfo(final BundleInfo source) {
39
- this(
40
- source.id,
41
- source.version,
42
- source.status,
43
- source.downloaded,
44
- source.checksum
45
- );
46
- }
47
-
48
- public BundleInfo(
49
- final String id,
50
- final String version,
51
- final BundleStatus status,
52
- final Date downloaded,
53
- final String checksum
54
- ) {
55
- this(id, version, status, sdf.format(downloaded), checksum);
56
- }
57
-
58
- public BundleInfo(
59
- final String id,
60
- final String version,
61
- final BundleStatus status,
62
- final String downloaded,
63
- final String checksum
64
- ) {
65
- this.downloaded = downloaded.trim();
66
- this.id = id;
67
- this.version = version;
68
- this.checksum = checksum;
69
- this.status = status;
70
- }
71
-
72
- public Boolean isBuiltin() {
73
- return ID_BUILTIN.equals(this.id);
74
- }
75
-
76
- public Boolean isUnknown() {
77
- return VERSION_UNKNOWN.equals(this.id);
78
- }
79
-
80
- public Boolean isErrorStatus() {
81
- return BundleStatus.ERROR == this.status;
82
- }
83
-
84
- public Boolean isDeleted() {
85
- return BundleStatus.DELETED == this.status;
86
- }
87
-
88
- public boolean isDownloaded() {
89
- return (
90
- !this.isBuiltin() &&
91
- this.downloaded != null &&
92
- !this.downloaded.isEmpty() &&
93
- !this.isDeleted()
94
- );
95
- }
96
-
97
- public String getDownloaded() {
98
- return this.isBuiltin() ? DOWNLOADED_BUILTIN : this.downloaded;
99
- }
100
-
101
- public BundleInfo setDownloaded(Date downloaded) {
102
- return new BundleInfo(
103
- this.id,
104
- this.version,
105
- this.status,
106
- downloaded,
107
- this.checksum
108
- );
109
- }
110
-
111
- public String getChecksum() {
112
- return this.isBuiltin() ? "" : this.checksum;
113
- }
114
-
115
- public BundleInfo setChecksum(String checksum) {
116
- return new BundleInfo(
117
- this.id,
118
- this.version,
119
- this.status,
120
- this.downloaded,
121
- checksum
122
- );
123
- }
124
-
125
- public String getId() {
126
- return this.isBuiltin() ? ID_BUILTIN : this.id;
127
- }
128
-
129
- public BundleInfo setId(String id) {
130
- return new BundleInfo(
131
- id,
132
- this.version,
133
- this.status,
134
- this.downloaded,
135
- this.checksum
136
- );
137
- }
138
-
139
- public String getVersionName() {
140
- return this.version == null ? ID_BUILTIN : this.version;
141
- }
142
-
143
- public BundleInfo setVersionName(String version) {
144
- return new BundleInfo(
145
- this.id,
146
- version,
147
- this.status,
148
- this.downloaded,
149
- this.checksum
150
- );
151
- }
152
-
153
- public BundleStatus getStatus() {
154
- return this.isBuiltin() ? BundleStatus.SUCCESS : this.status;
155
- }
156
-
157
- public BundleInfo setStatus(BundleStatus status) {
158
- return new BundleInfo(
159
- this.id,
160
- this.version,
161
- status,
162
- this.downloaded,
163
- this.checksum
164
- );
165
- }
166
-
167
- public static BundleInfo fromJSON(final JSObject json) throws JSONException {
168
- return BundleInfo.fromJSON(json.toString());
169
- }
170
-
171
- public static BundleInfo fromJSON(final String jsonString)
172
- throws JSONException {
173
- JSONObject json = new JSONObject(new JSONTokener(jsonString));
174
- return new BundleInfo(
175
- json.has("id") ? json.getString("id") : "",
176
- json.has("version")
177
- ? json.getString("version")
178
- : BundleInfo.VERSION_UNKNOWN,
179
- json.has("status")
180
- ? BundleStatus.fromString(json.getString("status"))
181
- : BundleStatus.PENDING,
182
- json.has("downloaded") ? json.getString("downloaded") : "",
183
- json.has("checksum") ? json.getString("checksum") : ""
184
- );
185
- }
186
-
187
- public JSObject toJSON() {
188
- final JSObject result = new JSObject();
189
- result.put("id", this.getId());
190
- result.put("version", this.getVersionName());
191
- result.put("downloaded", this.getDownloaded());
192
- result.put("checksum", this.getChecksum());
193
- result.put("status", this.getStatus());
194
- return result;
195
- }
196
-
197
- @Override
198
- public boolean equals(final Object o) {
199
- if (this == o) return true;
200
- if (!(o instanceof BundleInfo)) return false;
201
- final BundleInfo that = (BundleInfo) o;
202
- return this.getId().equals(that.getId());
203
- }
204
-
205
- @Override
206
- public int hashCode() {
207
- return Objects.hash(this.version);
208
- }
209
-
210
- @Override
211
- public String toString() {
212
- return this.toJSON().toString();
213
- }
21
+ private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
22
+
23
+ public static final String ID_BUILTIN = "builtin";
24
+ public static final String VERSION_UNKNOWN = "unknown";
25
+ public static final String DOWNLOADED_BUILTIN = "1970-01-01T00:00:00.000Z";
26
+
27
+ private final String downloaded;
28
+ private final String id;
29
+ private final String version;
30
+ private final String checksum;
31
+ private final BundleStatus status;
32
+ private final String link;
33
+ private final String comment;
34
+
35
+ static {
36
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
37
+ }
38
+
39
+ public BundleInfo(final BundleInfo source) {
40
+ this(source.id, source.version, source.status, source.downloaded, source.checksum, source.link, source.comment);
41
+ }
42
+
43
+ public BundleInfo(final String id, final String version, final BundleStatus status, final Date downloaded, final String checksum) {
44
+ this(id, version, status, sdf.format(downloaded), checksum, null, null);
45
+ }
46
+
47
+ public BundleInfo(
48
+ final String id,
49
+ final String version,
50
+ final BundleStatus status,
51
+ final Date downloaded,
52
+ final String checksum,
53
+ final String link,
54
+ final String comment
55
+ ) {
56
+ this(id, version, status, sdf.format(downloaded), checksum, link, comment);
57
+ }
58
+
59
+ public BundleInfo(final String id, final String version, final BundleStatus status, final String downloaded, final String checksum) {
60
+ this(id, version, status, downloaded, checksum, null, null);
61
+ }
62
+
63
+ public BundleInfo(
64
+ final String id,
65
+ final String version,
66
+ final BundleStatus status,
67
+ final String downloaded,
68
+ final String checksum,
69
+ final String link,
70
+ final String comment
71
+ ) {
72
+ this.downloaded = downloaded != null ? downloaded.trim() : "";
73
+ this.id = id != null ? id : "";
74
+ this.version = version;
75
+ this.checksum = checksum != null ? checksum : "";
76
+ this.status = status != null ? status : BundleStatus.ERROR;
77
+ this.link = link;
78
+ this.comment = comment;
79
+ }
80
+
81
+ public Boolean isBuiltin() {
82
+ return ID_BUILTIN.equals(this.id);
83
+ }
84
+
85
+ public Boolean isUnknown() {
86
+ return VERSION_UNKNOWN.equals(this.id);
87
+ }
88
+
89
+ public Boolean isErrorStatus() {
90
+ return BundleStatus.ERROR == this.status;
91
+ }
92
+
93
+ public Boolean isDeleted() {
94
+ return BundleStatus.DELETED == this.status;
95
+ }
96
+
97
+ public Boolean isDeleting() {
98
+ return BundleStatus.DELETING == this.status;
99
+ }
100
+
101
+ public boolean isDownloaded() {
102
+ return !this.isBuiltin() && this.downloaded != null && !this.downloaded.isEmpty() && !this.isDeleted() && !this.isDeleting();
103
+ }
104
+
105
+ public String getDownloaded() {
106
+ return this.isBuiltin() ? DOWNLOADED_BUILTIN : this.downloaded != null ? this.downloaded : "";
107
+ }
108
+
109
+ public BundleInfo setDownloaded(Date downloaded) {
110
+ return new BundleInfo(this.id, this.version, this.status, downloaded, this.checksum, this.link, this.comment);
111
+ }
112
+
113
+ public String getChecksum() {
114
+ return this.isBuiltin() ? "" : this.checksum != null ? this.checksum : "";
115
+ }
116
+
117
+ public BundleInfo setChecksum(String checksum) {
118
+ return new BundleInfo(this.id, this.version, this.status, this.downloaded, checksum, this.link, this.comment);
119
+ }
120
+
121
+ public String getId() {
122
+ return this.isBuiltin() ? ID_BUILTIN : this.id;
123
+ }
124
+
125
+ public BundleInfo setId(String id) {
126
+ return new BundleInfo(id, this.version, this.status, this.downloaded, this.checksum, this.link, this.comment);
127
+ }
128
+
129
+ public String getVersionName() {
130
+ return this.version == null ? ID_BUILTIN : this.version;
131
+ }
132
+
133
+ public BundleInfo setVersionName(String version) {
134
+ return new BundleInfo(this.id, version, this.status, this.downloaded, this.checksum, this.link, this.comment);
135
+ }
136
+
137
+ public BundleStatus getStatus() {
138
+ if (this.isBuiltin()) {
139
+ return BundleStatus.SUCCESS;
140
+ }
141
+ return this.status != null ? this.status : BundleStatus.ERROR;
142
+ }
143
+
144
+ public BundleInfo setStatus(BundleStatus status) {
145
+ return new BundleInfo(this.id, this.version, status, this.downloaded, this.checksum, this.link, this.comment);
146
+ }
147
+
148
+ public String getLink() {
149
+ return this.link;
150
+ }
151
+
152
+ public BundleInfo setLink(String link) {
153
+ return new BundleInfo(this.id, this.version, this.status, this.downloaded, this.checksum, link, this.comment);
154
+ }
155
+
156
+ public String getComment() {
157
+ return this.comment;
158
+ }
159
+
160
+ public BundleInfo setComment(String comment) {
161
+ return new BundleInfo(this.id, this.version, this.status, this.downloaded, this.checksum, this.link, comment);
162
+ }
163
+
164
+ public static BundleInfo fromJSON(final String jsonString) throws JSONException {
165
+ JSONObject json = new JSONObject(new JSONTokener(jsonString));
166
+ return new BundleInfo(
167
+ json.has("id") ? json.getString("id") : "",
168
+ json.has("version") ? json.getString("version") : BundleInfo.VERSION_UNKNOWN,
169
+ json.has("status") ? BundleStatus.fromString(json.getString("status")) : BundleStatus.PENDING,
170
+ json.has("downloaded") ? json.getString("downloaded") : "",
171
+ json.has("checksum") ? json.getString("checksum") : "",
172
+ json.has("link") ? json.getString("link") : null,
173
+ json.has("comment") ? json.getString("comment") : null
174
+ );
175
+ }
176
+
177
+ public Map<String, Object> toJSONMap() {
178
+ final Map<String, Object> result = new HashMap<>();
179
+ result.put("id", this.getId());
180
+ result.put("version", this.getVersionName());
181
+ result.put("downloaded", this.getDownloaded());
182
+ result.put("checksum", this.getChecksum());
183
+ result.put("status", this.getStatus().toString());
184
+ if (this.link != null && !this.link.isEmpty()) {
185
+ result.put("link", this.link);
186
+ }
187
+ if (this.comment != null && !this.comment.isEmpty()) {
188
+ result.put("comment", this.comment);
189
+ }
190
+ return result;
191
+ }
192
+
193
+ @Override
194
+ public boolean equals(final Object o) {
195
+ if (this == o) return true;
196
+ if (!(o instanceof BundleInfo)) return false;
197
+ final BundleInfo that = (BundleInfo) o;
198
+ return this.getId().equals(that.getId());
199
+ }
200
+
201
+ @Override
202
+ public int hashCode() {
203
+ return Objects.hash(this.version);
204
+ }
205
+
206
+ @Override
207
+ public String toString() {
208
+ try {
209
+ // Build JSON manually with extra safety checks
210
+ StringBuilder json = new StringBuilder();
211
+ json.append("{");
212
+
213
+ // Safe ID access
214
+ String safeId = this.id != null ? this.id : "";
215
+ if (this.isBuiltin()) safeId = ID_BUILTIN;
216
+ json.append("\"id\":\"").append(safeId).append("\",");
217
+
218
+ // Safe version access
219
+ String safeVersion = this.version != null ? this.version : ID_BUILTIN;
220
+ json.append("\"version\":\"").append(safeVersion).append("\",");
221
+
222
+ // Safe downloaded access
223
+ String safeDownloaded = this.downloaded != null ? this.downloaded : "";
224
+ if (this.isBuiltin()) safeDownloaded = DOWNLOADED_BUILTIN;
225
+ json.append("\"downloaded\":\"").append(safeDownloaded).append("\",");
226
+
227
+ // Safe checksum access
228
+ String safeChecksum = this.checksum != null ? this.checksum : "";
229
+ json.append("\"checksum\":\"").append(safeChecksum).append("\",");
230
+
231
+ // Safe status access
232
+ BundleStatus safeStatus = this.status != null ? this.status : BundleStatus.ERROR;
233
+ if (this.isBuiltin()) safeStatus = BundleStatus.SUCCESS;
234
+ json.append("\"status\":\"").append(safeStatus.toString()).append("\"");
235
+
236
+ json.append("}");
237
+ return json.toString();
238
+ } catch (Exception e) {
239
+ // Log the error for debugging but still return valid JSON
240
+ System.err.println("BundleInfo toString() error: " + e.getMessage());
241
+ e.printStackTrace();
242
+ // Return absolute minimal JSON
243
+ return "{\"id\":\"" + (this.id != null ? this.id : "unknown") + "\",\"status\":\"error\"}";
244
+ }
245
+ }
214
246
  }
@@ -10,35 +10,36 @@ import java.util.HashMap;
10
10
  import java.util.Map;
11
11
 
12
12
  public enum BundleStatus {
13
- SUCCESS("success"),
14
- ERROR("error"),
15
- PENDING("pending"),
16
- DELETED("deleted"),
17
- DOWNLOADING("downloading");
13
+ SUCCESS("success"),
14
+ ERROR("error"),
15
+ PENDING("pending"),
16
+ DELETED("deleted"),
17
+ DELETING("deleting"),
18
+ DOWNLOADING("downloading");
18
19
 
19
- public final String label;
20
+ public final String label;
20
21
 
21
- private static final Map<String, BundleStatus> BY_LABEL = new HashMap<>();
22
+ private static final Map<String, BundleStatus> BY_LABEL = new HashMap<>();
22
23
 
23
- static {
24
- for (final BundleStatus e : values()) {
25
- BY_LABEL.put(e.label, e);
24
+ static {
25
+ for (final BundleStatus e : values()) {
26
+ BY_LABEL.put(e.label, e);
27
+ }
26
28
  }
27
- }
28
29
 
29
- BundleStatus(final String label) {
30
- this.label = label;
31
- }
30
+ BundleStatus(final String label) {
31
+ this.label = label;
32
+ }
32
33
 
33
- @Override
34
- public String toString() {
35
- return this.label;
36
- }
34
+ @Override
35
+ public String toString() {
36
+ return this.label;
37
+ }
37
38
 
38
- public static BundleStatus fromString(final String status) {
39
- if (status == null || status.isEmpty()) {
40
- return BundleStatus.PENDING;
39
+ public static BundleStatus fromString(final String status) {
40
+ if (status == null || status.isEmpty()) {
41
+ return BundleStatus.PENDING;
42
+ }
43
+ return BundleStatus.BY_LABEL.get(status);
41
44
  }
42
- return BundleStatus.BY_LABEL.get(status);
43
- }
44
45
  }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+
7
+ package ee.forgr.capacitor_updater;
8
+
9
+ import java.util.Map;
10
+
11
+ public interface Callback {
12
+ void callback(Map<String, Object> result);
13
+ }