@capgo/capacitor-updater 5.9.4 → 5.10.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.
Files changed (64) hide show
  1. package/CapgoCapacitorUpdater.podspec +7 -5
  2. package/Package.swift +37 -0
  3. package/README.md +1030 -212
  4. package/android/build.gradle +28 -11
  5. package/android/proguard-rules.pro +22 -5
  6. package/android/src/main/AndroidManifest.xml +0 -1
  7. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +171 -195
  8. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
  9. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +2 -2
  10. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +2111 -1538
  11. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1551 -0
  12. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +229 -111
  13. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +28 -0
  14. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +42 -49
  15. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +260 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +221 -0
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +795 -124
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +156 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +19 -28
  21. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
  22. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
  24. package/dist/docs.json +1072 -162
  25. package/dist/esm/definitions.d.ts +899 -118
  26. package/dist/esm/definitions.js.map +1 -1
  27. package/dist/esm/history.d.ts +1 -0
  28. package/dist/esm/history.js +283 -0
  29. package/dist/esm/history.js.map +1 -0
  30. package/dist/esm/index.d.ts +3 -2
  31. package/dist/esm/index.js +5 -4
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/web.d.ts +16 -2
  34. package/dist/esm/web.js +79 -40
  35. package/dist/esm/web.js.map +1 -1
  36. package/dist/plugin.cjs.js +361 -40
  37. package/dist/plugin.cjs.js.map +1 -1
  38. package/dist/plugin.js +361 -40
  39. package/dist/plugin.js.map +1 -1
  40. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +69 -0
  41. package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
  42. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +1 -1
  43. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1582 -0
  44. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1513 -0
  45. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +187 -0
  46. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +220 -0
  47. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  48. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +307 -0
  49. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
  50. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
  51. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +112 -0
  52. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  53. package/package.json +33 -28
  54. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1187
  55. package/ios/Plugin/CapacitorUpdater.swift +0 -1032
  56. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  57. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -31
  58. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -843
  59. package/ios/Plugin/CryptoCipher.swift +0 -246
  60. /package/{LICENCE → LICENSE} +0 -0
  61. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleInfo.swift +0 -0
  62. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  63. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  64. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
@@ -12,134 +12,252 @@ package ee.forgr.capacitor_updater;
12
12
  * references: http://stackoverflow.com/questions/12471999/rsa-encryption-decryption-in-android
13
13
  */
14
14
  import android.util.Base64;
15
+ import java.io.BufferedInputStream;
16
+ import java.io.DataInputStream;
17
+ import java.io.File;
18
+ import java.io.FileInputStream;
19
+ import java.io.FileOutputStream;
20
+ import java.io.IOException;
15
21
  import java.security.GeneralSecurityException;
16
22
  import java.security.InvalidAlgorithmParameterException;
17
23
  import java.security.InvalidKeyException;
18
24
  import java.security.KeyFactory;
25
+ import java.security.MessageDigest;
19
26
  import java.security.NoSuchAlgorithmException;
20
- import java.security.PrivateKey;
27
+ import java.security.PublicKey;
21
28
  import java.security.spec.InvalidKeySpecException;
22
- import java.security.spec.MGF1ParameterSpec;
23
- import java.security.spec.PKCS8EncodedKeySpec;
29
+ import java.security.spec.X509EncodedKeySpec;
24
30
  import javax.crypto.BadPaddingException;
25
31
  import javax.crypto.Cipher;
26
32
  import javax.crypto.IllegalBlockSizeException;
27
33
  import javax.crypto.NoSuchPaddingException;
28
34
  import javax.crypto.SecretKey;
29
35
  import javax.crypto.spec.IvParameterSpec;
30
- import javax.crypto.spec.OAEPParameterSpec;
31
- import javax.crypto.spec.PSource;
32
36
  import javax.crypto.spec.SecretKeySpec;
33
37
 
34
38
  public class CryptoCipher {
35
39
 
36
- public static byte[] decryptRSA(byte[] source, PrivateKey privateKey)
37
- throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
38
- Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPPadding");
39
- OAEPParameterSpec oaepParams = new OAEPParameterSpec(
40
- "SHA-256",
41
- "MGF1",
42
- new MGF1ParameterSpec("SHA-256"),
43
- PSource.PSpecified.DEFAULT
44
- );
45
- cipher.init(Cipher.DECRYPT_MODE, privateKey, oaepParams);
46
- return cipher.doFinal(source);
47
- }
48
-
49
- public static byte[] decryptAES(byte[] cipherText, SecretKey key, byte[] iv) {
50
- try {
51
- IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
52
- Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
53
- SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), "AES");
54
- cipher.init(Cipher.DECRYPT_MODE, keySpec, ivParameterSpec);
55
- return cipher.doFinal(cipherText);
56
- } catch (Exception e) {
57
- e.printStackTrace();
40
+ private static Logger logger;
41
+
42
+ public static void setLogger(Logger loggerInstance) {
43
+ logger = loggerInstance;
44
+ }
45
+
46
+ public static byte[] decryptRSA(byte[] source, PublicKey publicKey)
47
+ throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
48
+ Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
49
+ cipher.init(Cipher.DECRYPT_MODE, publicKey);
50
+ byte[] decryptedBytes = cipher.doFinal(source);
51
+ return decryptedBytes;
52
+ }
53
+
54
+ public static byte[] decryptAES(byte[] cipherText, SecretKey key, byte[] iv) {
55
+ try {
56
+ IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
57
+ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
58
+ SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), "AES");
59
+ cipher.init(Cipher.DECRYPT_MODE, keySpec, ivParameterSpec);
60
+ return cipher.doFinal(cipherText);
61
+ } catch (Exception e) {
62
+ e.printStackTrace();
63
+ }
64
+ return null;
58
65
  }
59
- return null;
60
- }
61
-
62
- public static SecretKey byteToSessionKey(byte[] sessionKey) {
63
- // rebuild key using SecretKeySpec
64
- return new SecretKeySpec(sessionKey, 0, sessionKey.length, "AES");
65
- }
66
-
67
- private static PrivateKey readPkcs8PrivateKey(byte[] pkcs8Bytes)
68
- throws GeneralSecurityException {
69
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
70
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8Bytes);
71
- try {
72
- return keyFactory.generatePrivate(keySpec);
73
- } catch (InvalidKeySpecException e) {
74
- throw new IllegalArgumentException("Unexpected key format!", e);
66
+
67
+ public static SecretKey byteToSessionKey(byte[] sessionKey) {
68
+ // rebuild key using SecretKeySpec
69
+ return new SecretKeySpec(sessionKey, 0, sessionKey.length, "AES");
70
+ }
71
+
72
+ private static PublicKey readX509PublicKey(byte[] x509Bytes) throws GeneralSecurityException {
73
+ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
74
+ X509EncodedKeySpec keySpec = new X509EncodedKeySpec(x509Bytes);
75
+ try {
76
+ return keyFactory.generatePublic(keySpec);
77
+ } catch (InvalidKeySpecException e) {
78
+ throw new IllegalArgumentException("Unexpected key format!", e);
79
+ }
75
80
  }
76
- }
77
-
78
- private static byte[] join(byte[] byteArray1, byte[] byteArray2) {
79
- byte[] bytes = new byte[byteArray1.length + byteArray2.length];
80
- System.arraycopy(byteArray1, 0, bytes, 0, byteArray1.length);
81
- System.arraycopy(
82
- byteArray2,
83
- 0,
84
- bytes,
85
- byteArray1.length,
86
- byteArray2.length
87
- );
88
- return bytes;
89
- }
90
-
91
- private static PrivateKey readPkcs1PrivateKey(byte[] pkcs1Bytes)
92
- throws GeneralSecurityException {
93
- // We can't use Java internal APIs to parse ASN.1 structures, so we build a PKCS#8 key Java can understand
94
- int pkcs1Length = pkcs1Bytes.length;
95
- int totalLength = pkcs1Length + 22;
96
- byte[] pkcs8Header = new byte[] {
97
- 0x30,
98
- (byte) 0x82,
99
- (byte) ((totalLength >> 8) & 0xff),
100
- (byte) (totalLength & 0xff), // Sequence + total length
101
- 0x2,
102
- 0x1,
103
- 0x0, // Integer (0)
104
- 0x30,
105
- 0xD,
106
- 0x6,
107
- 0x9,
108
- 0x2A,
109
- (byte) 0x86,
110
- 0x48,
111
- (byte) 0x86,
112
- (byte) 0xF7,
113
- 0xD,
114
- 0x1,
115
- 0x1,
116
- 0x1,
117
- 0x5,
118
- 0x0, // Sequence: 1.2.840.113549.1.1.1, NULL
119
- 0x4,
120
- (byte) 0x82,
121
- (byte) ((pkcs1Length >> 8) & 0xff),
122
- (byte) (pkcs1Length & 0xff), // Octet string + length
81
+
82
+ public static PublicKey stringToPublicKey(String public_key) throws GeneralSecurityException {
83
+ String pkcs1Pem = public_key
84
+ .replaceAll("\\s+", "")
85
+ .replace("-----BEGINRSAPUBLICKEY-----", "")
86
+ .replace("-----ENDRSAPUBLICKEY-----", "");
87
+
88
+ byte[] pkcs1EncodedBytes = Base64.decode(pkcs1Pem, Base64.DEFAULT);
89
+ return readPkcs1PublicKey(pkcs1EncodedBytes);
90
+ }
91
+
92
+ // since the public key is in pkcs1 format, we have to convert it to x509 format similar
93
+ // to what needs done with the private key converting to pkcs8 format
94
+ // so, the rest of the code below here is adapted from here https://stackoverflow.com/a/54246646
95
+ private static final int SEQUENCE_TAG = 0x30;
96
+ private static final int BIT_STRING_TAG = 0x03;
97
+ private static final byte[] NO_UNUSED_BITS = new byte[] { 0x00 };
98
+ private static final byte[] RSA_ALGORITHM_IDENTIFIER_SEQUENCE = {
99
+ (byte) 0x30,
100
+ (byte) 0x0d,
101
+ (byte) 0x06,
102
+ (byte) 0x09,
103
+ (byte) 0x2a,
104
+ (byte) 0x86,
105
+ (byte) 0x48,
106
+ (byte) 0x86,
107
+ (byte) 0xf7,
108
+ (byte) 0x0d,
109
+ (byte) 0x01,
110
+ (byte) 0x01,
111
+ (byte) 0x01,
112
+ (byte) 0x05,
113
+ (byte) 0x00
123
114
  };
124
- byte[] pkcs8bytes = join(pkcs8Header, pkcs1Bytes);
125
- return readPkcs8PrivateKey(pkcs8bytes);
126
- }
127
-
128
- public static PrivateKey stringToPrivateKey(String private_key)
129
- throws GeneralSecurityException {
130
- // Base64 decode the result
131
-
132
- String pkcs1Pem = private_key;
133
- pkcs1Pem = pkcs1Pem.replace("-----BEGIN RSA PRIVATE KEY-----", "");
134
- pkcs1Pem = pkcs1Pem.replace("-----END RSA PRIVATE KEY-----", "");
135
- pkcs1Pem = pkcs1Pem.replace("\\n", "");
136
- pkcs1Pem = pkcs1Pem.replace(" ", "");
137
-
138
- byte[] pkcs1EncodedBytes = Base64.decode(
139
- pkcs1Pem.getBytes(),
140
- Base64.DEFAULT
141
- );
142
- // extract the private key
143
- return readPkcs1PrivateKey(pkcs1EncodedBytes);
144
- }
115
+
116
+ private static PublicKey readPkcs1PublicKey(byte[] pkcs1Bytes)
117
+ throws NoSuchAlgorithmException, InvalidKeySpecException, GeneralSecurityException {
118
+ // convert the pkcs1 public key to an x509 favorable format
119
+ byte[] keyBitString = createDEREncoding(BIT_STRING_TAG, joinPublic(NO_UNUSED_BITS, pkcs1Bytes));
120
+ byte[] keyInfoValue = joinPublic(RSA_ALGORITHM_IDENTIFIER_SEQUENCE, keyBitString);
121
+ byte[] keyInfoSequence = createDEREncoding(SEQUENCE_TAG, keyInfoValue);
122
+ return readX509PublicKey(keyInfoSequence);
123
+ }
124
+
125
+ private static byte[] joinPublic(byte[]... bas) {
126
+ int len = 0;
127
+ for (int i = 0; i < bas.length; i++) {
128
+ len += bas[i].length;
129
+ }
130
+
131
+ byte[] buf = new byte[len];
132
+ int off = 0;
133
+ for (int i = 0; i < bas.length; i++) {
134
+ System.arraycopy(bas[i], 0, buf, off, bas[i].length);
135
+ off += bas[i].length;
136
+ }
137
+
138
+ return buf;
139
+ }
140
+
141
+ public static void decryptFile(final File file, final String publicKey, final String ivSessionKey) throws IOException {
142
+ if (publicKey.isEmpty() || ivSessionKey == null || ivSessionKey.isEmpty() || ivSessionKey.split(":").length != 2) {
143
+ logger.info("Encryption not set, no public key or session, ignored");
144
+ return;
145
+ }
146
+ if (!publicKey.startsWith("-----BEGIN RSA PUBLIC KEY-----")) {
147
+ logger.error("The public key is not a valid RSA Public key");
148
+ return;
149
+ }
150
+
151
+ try {
152
+ String ivB64 = ivSessionKey.split(":")[0];
153
+ String sessionKeyB64 = ivSessionKey.split(":")[1];
154
+ byte[] iv = Base64.decode(ivB64.getBytes(), Base64.DEFAULT);
155
+ byte[] sessionKey = Base64.decode(sessionKeyB64.getBytes(), Base64.DEFAULT);
156
+ PublicKey pKey = CryptoCipher.stringToPublicKey(publicKey);
157
+ byte[] decryptedSessionKey = CryptoCipher.decryptRSA(sessionKey, pKey);
158
+
159
+ SecretKey sKey = CryptoCipher.byteToSessionKey(decryptedSessionKey);
160
+ byte[] content = new byte[(int) file.length()];
161
+
162
+ try (
163
+ final FileInputStream fis = new FileInputStream(file);
164
+ final BufferedInputStream bis = new BufferedInputStream(fis);
165
+ final DataInputStream dis = new DataInputStream(bis)
166
+ ) {
167
+ dis.readFully(content);
168
+ dis.close();
169
+ byte[] decrypted = CryptoCipher.decryptAES(content, sKey, iv);
170
+ // write the decrypted string to the file
171
+ try (final FileOutputStream fos = new FileOutputStream(file.getAbsolutePath())) {
172
+ fos.write(decrypted);
173
+ }
174
+ }
175
+ } catch (GeneralSecurityException e) {
176
+ logger.info("decryptFile fail");
177
+ e.printStackTrace();
178
+ throw new IOException("GeneralSecurityException");
179
+ }
180
+ }
181
+
182
+ public static String decryptChecksum(String checksum, String publicKey) throws IOException {
183
+ if (publicKey.isEmpty()) {
184
+ logger.error("No encryption set (public key) ignored");
185
+ return checksum;
186
+ }
187
+ try {
188
+ byte[] checksumBytes = Base64.decode(checksum, Base64.DEFAULT);
189
+ PublicKey pKey = CryptoCipher.stringToPublicKey(publicKey);
190
+ byte[] decryptedChecksum = CryptoCipher.decryptRSA(checksumBytes, pKey);
191
+ // return Base64.encodeToString(decryptedChecksum, Base64.DEFAULT);
192
+ String result = Base64.encodeToString(decryptedChecksum, Base64.DEFAULT);
193
+ return result.replaceAll("\\s", ""); // Remove all whitespace, including newlines
194
+ } catch (GeneralSecurityException e) {
195
+ logger.error("decryptChecksum fail: " + e.getMessage());
196
+ throw new IOException("Decryption failed: " + e.getMessage());
197
+ }
198
+ }
199
+
200
+ public static String calcChecksum(File file) {
201
+ final int BUFFER_SIZE = 1024 * 1024 * 5; // 5 MB buffer size
202
+ MessageDigest digest;
203
+ try {
204
+ digest = MessageDigest.getInstance("SHA-256");
205
+ } catch (java.security.NoSuchAlgorithmException e) {
206
+ logger.error("SHA-256 algorithm not available");
207
+ return "";
208
+ }
209
+
210
+ try (FileInputStream fis = new FileInputStream(file)) {
211
+ byte[] buffer = new byte[BUFFER_SIZE];
212
+ int length;
213
+ while ((length = fis.read(buffer)) != -1) {
214
+ digest.update(buffer, 0, length);
215
+ }
216
+ byte[] hash = digest.digest();
217
+ StringBuilder hexString = new StringBuilder();
218
+ for (byte b : hash) {
219
+ String hex = Integer.toHexString(0xff & b);
220
+ if (hex.length() == 1) hexString.append('0');
221
+ hexString.append(hex);
222
+ }
223
+ return hexString.toString();
224
+ } catch (IOException e) {
225
+ logger.error("Cannot calc checksum v2: " + file.getPath() + " " + e.getMessage());
226
+ return "";
227
+ }
228
+ }
229
+
230
+ private static byte[] createDEREncoding(int tag, byte[] value) {
231
+ if (tag < 0 || tag >= 0xFF) {
232
+ throw new IllegalArgumentException("Currently only single byte tags supported");
233
+ }
234
+
235
+ byte[] lengthEncoding = createDERLengthEncoding(value.length);
236
+
237
+ int size = 1 + lengthEncoding.length + value.length;
238
+ byte[] derEncodingBuf = new byte[size];
239
+
240
+ int off = 0;
241
+ derEncodingBuf[off++] = (byte) tag;
242
+ System.arraycopy(lengthEncoding, 0, derEncodingBuf, off, lengthEncoding.length);
243
+ off += lengthEncoding.length;
244
+ System.arraycopy(value, 0, derEncodingBuf, off, value.length);
245
+
246
+ return derEncodingBuf;
247
+ }
248
+
249
+ private static byte[] createDERLengthEncoding(int size) {
250
+ if (size <= 0x7F) {
251
+ // single byte length encoding
252
+ return new byte[] { (byte) size };
253
+ } else if (size <= 0xFF) {
254
+ // double byte length encoding
255
+ return new byte[] { (byte) 0x81, (byte) size };
256
+ } else if (size <= 0xFFFF) {
257
+ // triple byte length encoding
258
+ return new byte[] { (byte) 0x82, (byte) (size >> Byte.SIZE), (byte) size };
259
+ }
260
+
261
+ throw new IllegalArgumentException("size too large, only up to 64KiB length encoding supported: " + size);
262
+ }
145
263
  }
@@ -0,0 +1,28 @@
1
+ package ee.forgr.capacitor_updater;
2
+
3
+ import org.json.JSONArray;
4
+
5
+ public class DataManager {
6
+
7
+ private static DataManager instance;
8
+ private JSONArray currentManifest;
9
+
10
+ private DataManager() {}
11
+
12
+ public static synchronized DataManager getInstance() {
13
+ if (instance == null) {
14
+ instance = new DataManager();
15
+ }
16
+ return instance;
17
+ }
18
+
19
+ public void setManifest(JSONArray manifest) {
20
+ this.currentManifest = manifest;
21
+ }
22
+
23
+ public JSONArray getAndClearManifest() {
24
+ JSONArray manifest = this.currentManifest;
25
+ this.currentManifest = null;
26
+ return manifest;
27
+ }
28
+ }
@@ -7,57 +7,50 @@
7
7
  package ee.forgr.capacitor_updater;
8
8
 
9
9
  import androidx.annotation.NonNull;
10
- import com.google.gson.annotations.SerializedName;
11
10
  import java.util.Objects;
12
11
 
13
12
  public class DelayCondition {
14
13
 
15
- @SerializedName("kind")
16
- private DelayUntilNext kind;
17
-
18
- @SerializedName("value")
19
- private String value;
20
-
21
- public DelayCondition(DelayUntilNext kind, String value) {
22
- this.kind = kind;
23
- this.value = value;
24
- }
25
-
26
- public DelayUntilNext getKind() {
27
- return kind;
28
- }
29
-
30
- public void setKind(DelayUntilNext kind) {
31
- this.kind = kind;
32
- }
33
-
34
- public String getValue() {
35
- return value;
36
- }
37
-
38
- public void setValue(String value) {
39
- this.value = value;
40
- }
41
-
42
- @Override
43
- public boolean equals(Object o) {
44
- if (this == o) return true;
45
- if (!(o instanceof DelayCondition that)) return false;
46
- return (
47
- getKind() == that.getKind() && Objects.equals(getValue(), that.getValue())
48
- );
49
- }
50
-
51
- @Override
52
- public int hashCode() {
53
- return Objects.hash(getKind(), getValue());
54
- }
55
-
56
- @NonNull
57
- @Override
58
- public String toString() {
59
- return (
60
- "DelayCondition{" + "kind=" + kind + ", value='" + value + '\'' + '}'
61
- );
62
- }
14
+ private DelayUntilNext kind;
15
+
16
+ private String value;
17
+
18
+ public DelayCondition(DelayUntilNext kind, String value) {
19
+ this.kind = kind;
20
+ this.value = value;
21
+ }
22
+
23
+ public DelayUntilNext getKind() {
24
+ return kind;
25
+ }
26
+
27
+ public void setKind(DelayUntilNext kind) {
28
+ this.kind = kind;
29
+ }
30
+
31
+ public String getValue() {
32
+ return value;
33
+ }
34
+
35
+ public void setValue(String value) {
36
+ this.value = value;
37
+ }
38
+
39
+ @Override
40
+ public boolean equals(Object o) {
41
+ if (this == o) return true;
42
+ if (!(o instanceof DelayCondition that)) return false;
43
+ return (getKind() == that.getKind() && Objects.equals(getValue(), that.getValue()));
44
+ }
45
+
46
+ @Override
47
+ public int hashCode() {
48
+ return Objects.hash(getKind(), getValue());
49
+ }
50
+
51
+ @NonNull
52
+ @Override
53
+ public String toString() {
54
+ return ("DelayCondition{" + "kind=" + kind + ", value='" + value + '\'' + '}');
55
+ }
63
56
  }
@@ -7,8 +7,8 @@
7
7
  package ee.forgr.capacitor_updater;
8
8
 
9
9
  public enum DelayUntilNext {
10
- background,
11
- kill,
12
- nativeVersion,
13
- date,
10
+ background,
11
+ kill,
12
+ nativeVersion,
13
+ date
14
14
  }