@capgo/capacitor-updater 3.0.10 → 3.1.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.
|
@@ -47,7 +47,7 @@ public class CapacitorUpdater {
|
|
|
47
47
|
public String statsUrl = "";
|
|
48
48
|
public String appId = "";
|
|
49
49
|
public String deviceID = "";
|
|
50
|
-
private String pluginVersion = "3.0
|
|
50
|
+
private String pluginVersion = "3.1.0";
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
private FilenameFilter filter = new FilenameFilter() {
|
|
@@ -59,6 +59,7 @@ public class CapacitorUpdater {
|
|
|
59
59
|
};
|
|
60
60
|
private final CapacitorUpdaterPlugin plugin;
|
|
61
61
|
private String versionBuild = "";
|
|
62
|
+
private String versionCode = "";
|
|
62
63
|
private String TAG = "Capacitor-updater";
|
|
63
64
|
private Context context;
|
|
64
65
|
private String basePathHot = "versions";
|
|
@@ -86,6 +87,7 @@ public class CapacitorUpdater {
|
|
|
86
87
|
this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
|
|
87
88
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
|
88
89
|
this.versionBuild = pInfo.versionName;
|
|
90
|
+
this.versionCode = Integer.toString(pInfo.versionCode);
|
|
89
91
|
}
|
|
90
92
|
public CapacitorUpdater (Context context, CapacitorUpdaterPlugin plugin) throws PackageManager.NameNotFoundException {
|
|
91
93
|
this.context = context;
|
|
@@ -95,6 +97,7 @@ public class CapacitorUpdater {
|
|
|
95
97
|
this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
|
|
96
98
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
|
97
99
|
this.versionBuild = pInfo.versionName;
|
|
100
|
+
this.versionCode = Integer.toString(pInfo.versionCode);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
private Boolean unzip(String source, String dest) {
|
|
@@ -114,7 +117,7 @@ public class CapacitorUpdater {
|
|
|
114
117
|
int buffLength = 8192;
|
|
115
118
|
byte[] buffer = new byte[buffLength];
|
|
116
119
|
long totalLength = zipFile.length();
|
|
117
|
-
long
|
|
120
|
+
long readLength = buffLength;
|
|
118
121
|
int percent = 0;
|
|
119
122
|
this.plugin.notifyDownload(75);
|
|
120
123
|
while ((ze = zis.getNextEntry()) != null) {
|
|
@@ -131,19 +134,19 @@ public class CapacitorUpdater {
|
|
|
131
134
|
dir.getAbsolutePath());
|
|
132
135
|
if (ze.isDirectory())
|
|
133
136
|
continue;
|
|
134
|
-
FileOutputStream
|
|
137
|
+
FileOutputStream fileOut = new FileOutputStream(file);
|
|
135
138
|
try {
|
|
136
139
|
while ((count = zis.read(buffer)) != -1)
|
|
137
|
-
|
|
140
|
+
fileOut.write(buffer, 0, count);
|
|
138
141
|
} finally {
|
|
139
|
-
|
|
142
|
+
fileOut.close();
|
|
140
143
|
}
|
|
141
|
-
int newPercent = (int)((
|
|
144
|
+
int newPercent = (int)((readLength * 100) / totalLength);
|
|
142
145
|
if (totalLength > 1 && newPercent != percent) {
|
|
143
146
|
percent = newPercent;
|
|
144
147
|
this.plugin.notifyDownload(calcTotalPercent((int)percent, 75, 90));
|
|
145
148
|
}
|
|
146
|
-
|
|
149
|
+
readLength += ze.getCompressedSize();
|
|
147
150
|
}
|
|
148
151
|
} catch (Exception e) {
|
|
149
152
|
Log.i(TAG, "unzip error", e);
|
|
@@ -194,17 +197,17 @@ public class CapacitorUpdater {
|
|
|
194
197
|
downFile.getParentFile().mkdirs();
|
|
195
198
|
downFile.createNewFile();
|
|
196
199
|
FileOutputStream fos = new FileOutputStream(downFile);
|
|
197
|
-
int
|
|
200
|
+
int readLength = buffLength;
|
|
198
201
|
int percent = 0;
|
|
199
202
|
this.plugin.notifyDownload(10);
|
|
200
203
|
while ((length = dis.read(buffer))>0) {
|
|
201
204
|
fos.write(buffer, 0, length);
|
|
202
|
-
int newPercent = (int)((
|
|
205
|
+
int newPercent = (int)((readLength * 100) / totalLength);
|
|
203
206
|
if (totalLength > 1 && newPercent != percent) {
|
|
204
207
|
percent = newPercent;
|
|
205
208
|
this.plugin.notifyDownload(calcTotalPercent(percent, 10, 70));
|
|
206
209
|
}
|
|
207
|
-
|
|
210
|
+
readLength += length;
|
|
208
211
|
}
|
|
209
212
|
} catch (Exception e) {
|
|
210
213
|
Log.e(TAG, "downloadFile error", e);
|
|
@@ -297,6 +300,7 @@ public class CapacitorUpdater {
|
|
|
297
300
|
String deviceID = this.deviceID;
|
|
298
301
|
String appId = this.appId;
|
|
299
302
|
String versionBuild = this.versionBuild;
|
|
303
|
+
String versionCode = this.versionCode;
|
|
300
304
|
String pluginVersion = this.pluginVersion;
|
|
301
305
|
String versionName = getVersionName().equals("") ? "builtin" : getVersionName();
|
|
302
306
|
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
|
|
@@ -323,6 +327,7 @@ public class CapacitorUpdater {
|
|
|
323
327
|
params.put("cap_device_id", deviceID);
|
|
324
328
|
params.put("cap_app_id", appId);
|
|
325
329
|
params.put("cap_version_build", versionBuild);
|
|
330
|
+
params.put("cap_version_code", versionCode);
|
|
326
331
|
params.put("cap_version_name", versionName);
|
|
327
332
|
params.put("cap_plugin_version", pluginVersion);
|
|
328
333
|
return params;
|
|
@@ -361,6 +366,7 @@ public class CapacitorUpdater {
|
|
|
361
366
|
json.put("version_name", version);
|
|
362
367
|
json.put("device_id", this.deviceID);
|
|
363
368
|
json.put("version_build", this.versionBuild);
|
|
369
|
+
json.put("version_code", this.versionCode);
|
|
364
370
|
json.put("plugin_version", this.pluginVersion);
|
|
365
371
|
json.put("app_id", this.appId);
|
|
366
372
|
jsonString = json.toString();
|
|
@@ -37,8 +37,9 @@ extension Bundle {
|
|
|
37
37
|
public var appId = ""
|
|
38
38
|
public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
39
39
|
public var notifyDownload: (Int) -> Void = { _ in }
|
|
40
|
-
public var pluginVersion = "3.0
|
|
40
|
+
public var pluginVersion = "3.1.0"
|
|
41
41
|
private var versionBuild = Bundle.main.releaseVersionNumber ?? ""
|
|
42
|
+
private var versionCode = Bundle.main.buildVersionNumber ?? ""
|
|
42
43
|
private var lastPathHot = ""
|
|
43
44
|
private var lastPathPersist = ""
|
|
44
45
|
private let basePathHot = "versions"
|
|
@@ -112,6 +113,7 @@ extension Bundle {
|
|
|
112
113
|
"cap_device_id": self.deviceID,
|
|
113
114
|
"cap_app_id": self.appId,
|
|
114
115
|
"cap_version_build": self.versionBuild,
|
|
116
|
+
"cap_version_code": self.versionCode,
|
|
115
117
|
"cap_plugin_version": self.pluginVersion,
|
|
116
118
|
"cap_version_name": UserDefaults.standard.string(forKey: "versionName") ?? "builtin"
|
|
117
119
|
]
|
|
@@ -253,6 +255,7 @@ extension Bundle {
|
|
|
253
255
|
"device_id": self.deviceID,
|
|
254
256
|
"version_name": version,
|
|
255
257
|
"version_build": self.versionBuild,
|
|
258
|
+
"version_code": self.versionCode,
|
|
256
259
|
"plugin_version": self.pluginVersion,
|
|
257
260
|
"app_id": self.appId
|
|
258
261
|
]
|