@capacitor/android 3.5.1 → 3.6.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.
- package/CHANGELOG.md +12 -0
- package/capacitor/src/main/java/com/getcapacitor/AppUUID.java +65 -0
- package/capacitor/src/main/java/com/getcapacitor/ProcessedRoute.java +28 -0
- package/capacitor/src/main/java/com/getcapacitor/RouteProcessor.java +1 -1
- package/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +11 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **android:** update support for Portals for Capacitor to include Live Updates ([#5660](https://github.com/ionic-team/capacitor/issues/5660)) ([62f0a5e](https://github.com/ionic-team/capacitor/commit/62f0a5eaa40776aad79dbf8f8c0900037d3cc97e))
|
|
12
|
+
* **iOS, Android:** add AppUUID Lib for plugins ([#5690](https://github.com/ionic-team/capacitor/issues/5690)) ([05e76cf](https://github.com/ionic-team/capacitor/commit/05e76cf526a44e07fa75f9482fa2223a13918638))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
package com.getcapacitor;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.SharedPreferences;
|
|
5
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
6
|
+
import java.nio.charset.StandardCharsets;
|
|
7
|
+
import java.security.MessageDigest;
|
|
8
|
+
import java.security.NoSuchAlgorithmException;
|
|
9
|
+
import java.util.Objects;
|
|
10
|
+
import java.util.UUID;
|
|
11
|
+
|
|
12
|
+
public final class AppUUID {
|
|
13
|
+
|
|
14
|
+
private static final String KEY = "CapacitorAppUUID";
|
|
15
|
+
|
|
16
|
+
public static String getAppUUID(AppCompatActivity activity) throws Exception {
|
|
17
|
+
assertAppUUID(activity);
|
|
18
|
+
return readUUID(activity);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static void regenerateAppUUID(AppCompatActivity activity) throws Exception {
|
|
22
|
+
try {
|
|
23
|
+
String uuid = generateUUID();
|
|
24
|
+
writeUUID(activity, uuid);
|
|
25
|
+
} catch (NoSuchAlgorithmException ex) {
|
|
26
|
+
throw new Exception("Capacitor App UUID could not be generated.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static void assertAppUUID(AppCompatActivity activity) throws Exception {
|
|
31
|
+
String uuid = readUUID(activity);
|
|
32
|
+
if (uuid.equals("")) {
|
|
33
|
+
regenerateAppUUID(activity);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static String generateUUID() throws NoSuchAlgorithmException {
|
|
38
|
+
MessageDigest salt = MessageDigest.getInstance("SHA-256");
|
|
39
|
+
salt.update(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
|
|
40
|
+
return bytesToHex(salt.digest());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static String readUUID(AppCompatActivity activity) {
|
|
44
|
+
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
|
45
|
+
return sharedPref.getString(KEY, "");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static void writeUUID(AppCompatActivity activity, String uuid) {
|
|
49
|
+
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
|
50
|
+
SharedPreferences.Editor editor = sharedPref.edit();
|
|
51
|
+
editor.putString(KEY, uuid);
|
|
52
|
+
editor.apply();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private static String bytesToHex(byte[] bytes) {
|
|
56
|
+
byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
|
|
57
|
+
byte[] hexChars = new byte[bytes.length * 2];
|
|
58
|
+
for (int j = 0; j < bytes.length; j++) {
|
|
59
|
+
int v = bytes[j] & 0xFF;
|
|
60
|
+
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
|
|
61
|
+
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
|
|
62
|
+
}
|
|
63
|
+
return new String(hexChars, StandardCharsets.UTF_8);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.getcapacitor;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An data class used in conjunction with RouteProcessor.
|
|
5
|
+
*
|
|
6
|
+
* @see com.getcapacitor.RouteProcessor
|
|
7
|
+
*/
|
|
8
|
+
public class ProcessedRoute {
|
|
9
|
+
|
|
10
|
+
private String path;
|
|
11
|
+
private boolean isAsset;
|
|
12
|
+
|
|
13
|
+
public String getPath() {
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public void setPath(String path) {
|
|
18
|
+
this.path = path;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public boolean isAsset() {
|
|
22
|
+
return isAsset;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public void setAsset(boolean asset) {
|
|
26
|
+
isAsset = asset;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -256,7 +256,9 @@ public class WebViewLocalServer {
|
|
|
256
256
|
try {
|
|
257
257
|
String startPath = this.basePath + "/index.html";
|
|
258
258
|
if (bridge.getRouteProcessor() != null) {
|
|
259
|
-
|
|
259
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process(this.basePath, "/index.html");
|
|
260
|
+
startPath = processedRoute.getPath();
|
|
261
|
+
isAsset = processedRoute.isAsset();
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
if (isAsset) {
|
|
@@ -474,16 +476,21 @@ public class WebViewLocalServer {
|
|
|
474
476
|
// Pass path to routeProcessor if present
|
|
475
477
|
RouteProcessor routeProcessor = bridge.getRouteProcessor();
|
|
476
478
|
if (routeProcessor != null) {
|
|
477
|
-
|
|
479
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process("", path);
|
|
480
|
+
path = processedRoute.getPath();
|
|
481
|
+
isAsset = processedRoute.isAsset();
|
|
478
482
|
}
|
|
479
483
|
|
|
480
484
|
try {
|
|
481
485
|
if (path.startsWith(capacitorContentStart)) {
|
|
482
486
|
stream = protocolHandler.openContentUrl(url);
|
|
483
|
-
} else if (path.startsWith(capacitorFileStart)
|
|
484
|
-
|
|
487
|
+
} else if (path.startsWith(capacitorFileStart)) {
|
|
488
|
+
stream = protocolHandler.openFile(path);
|
|
489
|
+
} else if (!isAsset) {
|
|
490
|
+
if (routeProcessor == null) {
|
|
485
491
|
path = basePath + url.getPath();
|
|
486
492
|
}
|
|
493
|
+
|
|
487
494
|
stream = protocolHandler.openFile(path);
|
|
488
495
|
} else {
|
|
489
496
|
stream = protocolHandler.openAsset(assetPath + path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"verify": "./gradlew clean lint build test -b capacitor/build.gradle"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@capacitor/core": "^3.
|
|
25
|
+
"@capacitor/core": "^3.6.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1e06a199a44bb5321f0fb48b5fbca961cc1dbb50"
|
|
31
31
|
}
|