@capacitor/android 9.0.0-nightly-20260211T152431.0 → 9.0.0-rc.1
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/capacitor/build.gradle +14 -17
- package/capacitor/proguard-rules.pro +10 -10
- package/capacitor/src/main/assets/native-bridge.js +22 -22
- package/capacitor/src/main/java/com/getcapacitor/AndroidProtocolHandler.java +129 -2
- package/capacitor/src/main/java/com/getcapacitor/Bridge.java +154 -269
- package/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java +10 -4
- package/capacitor/src/main/java/com/getcapacitor/BridgeWebChromeClient.java +3 -2
- package/capacitor/src/main/java/com/getcapacitor/CapConfig.java +0 -119
- package/capacitor/src/main/java/com/getcapacitor/CordovaBridgeConfig.java +6 -0
- package/capacitor/src/main/java/com/getcapacitor/FileUtils.java +1 -1
- package/capacitor/src/main/java/com/getcapacitor/MessageHandler.java +11 -46
- package/capacitor/src/main/java/com/getcapacitor/Plugin.java +63 -249
- package/capacitor/src/main/java/com/getcapacitor/PluginCall.java +0 -43
- package/capacitor/src/main/java/com/getcapacitor/PluginConfig.java +11 -0
- package/capacitor/src/main/java/com/getcapacitor/PluginHandle.java +9 -29
- package/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +138 -31
- package/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java +3 -3
- package/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java +170 -96
- package/capacitor/src/main/java/com/getcapacitor/plugin/util/CapacitorHttpUrlConnection.java +61 -16
- package/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java +21 -6
- package/capacitor/src/main/java/com/getcapacitor/util/InternalUtils.java +10 -4
- package/capacitor/src/main/java/com/getcapacitor/util/JSONUtils.java +20 -0
- package/capacitor/src/main/resources/META-INF/com/capacitorjs/core/verification.properties +3 -0
- package/capacitor-cordova/build.gradle +44 -0
- package/capacitor-cordova/proguard-rules.pro +4 -0
- package/capacitor-cordova/src/main/AndroidManifest.xml +3 -0
- package/capacitor-cordova/src/main/java/com/getcapacitor/cordova/CordovaPlugin.java +145 -0
- package/{capacitor → capacitor-cordova}/src/main/java/com/getcapacitor/cordova/MockCordovaInterfaceImpl.java +1 -1
- package/{capacitor → capacitor-cordova}/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java +16 -11
- package/capacitor-cordova/src/main/res/raw/capacitor_cordova_keep.xml +1 -0
- package/package.json +7 -4
- package/capacitor/src/main/java/com/getcapacitor/NativePlugin.java +0 -37
- /package/{capacitor → capacitor-cordova}/src/main/java/com/getcapacitor/cordova/CapacitorCordovaCookieManager.java +0 -0
package/capacitor/build.gradle
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
androidxActivityVersion =
|
|
3
|
-
androidxAppCompatVersion =
|
|
4
|
-
androidxCoordinatorLayoutVersion =
|
|
5
|
-
androidxCoreVersion =
|
|
6
|
-
androidxFragmentVersion =
|
|
7
|
-
androidxWebkitVersion =
|
|
8
|
-
junitVersion =
|
|
9
|
-
androidxJunitVersion =
|
|
10
|
-
androidxEspressoCoreVersion =
|
|
11
|
-
cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '14.0.1'
|
|
2
|
+
androidxActivityVersion = rootProject.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.13.0'
|
|
3
|
+
androidxAppCompatVersion = rootProject.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.8.0'
|
|
4
|
+
androidxCoordinatorLayoutVersion = rootProject.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.3.0'
|
|
5
|
+
androidxCoreVersion = rootProject.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.19.1'
|
|
6
|
+
androidxFragmentVersion = rootProject.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.9.1'
|
|
7
|
+
androidxWebkitVersion = rootProject.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.17.1'
|
|
8
|
+
junitVersion = rootProject.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
9
|
+
androidxJunitVersion = rootProject.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
10
|
+
androidxEspressoCoreVersion = rootProject.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
|
|
@@ -21,10 +20,10 @@ buildscript {
|
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
dependencies {
|
|
24
|
-
classpath 'com.android.tools.build:gradle:
|
|
23
|
+
classpath 'com.android.tools.build:gradle:9.4.1'
|
|
25
24
|
|
|
26
25
|
if (System.getenv("CAP_PUBLISH") == "true") {
|
|
27
|
-
classpath 'io.github.gradle-nexus:publish-plugin:
|
|
26
|
+
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -41,10 +40,9 @@ if (System.getenv("CAP_PUBLISH") == "true") {
|
|
|
41
40
|
|
|
42
41
|
android {
|
|
43
42
|
namespace = "com.getcapacitor.android"
|
|
44
|
-
compileSdk =
|
|
43
|
+
compileSdk = rootProject.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 37
|
|
45
44
|
defaultConfig {
|
|
46
|
-
minSdkVersion
|
|
47
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
45
|
+
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
|
|
48
46
|
versionCode 1
|
|
49
47
|
versionName "1.0"
|
|
50
48
|
consumerProguardFiles 'proguard-rules.pro'
|
|
@@ -87,8 +85,7 @@ dependencies {
|
|
|
87
85
|
testImplementation "junit:junit:$junitVersion"
|
|
88
86
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
89
87
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
90
|
-
|
|
91
|
-
testImplementation 'org.json:json:20250517'
|
|
88
|
+
testImplementation 'org.json:json:20250517'
|
|
92
89
|
testImplementation 'org.mockito:mockito-core:5.20.0'
|
|
93
90
|
}
|
|
94
91
|
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
-keep public class * extends com.getcapacitor.Plugin { *; }
|
|
17
17
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
18
|
+
# The annotation types are read at runtime via reflection. If they are not kept, R8 full mode
|
|
19
|
+
# treats them as never instantiated and optimizes the annotation cached in PluginHandle to null,
|
|
20
|
+
# even with -keepattributes *Annotation*.
|
|
21
|
+
-keep @interface com.getcapacitor.annotation.** { *; }
|
|
22
|
+
-keep @interface com.getcapacitor.PluginMethod { *; }
|
|
23
23
|
|
|
24
|
-
#
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
24
|
+
# Callback methods are found by reflection, including on non-public base classes.
|
|
25
|
+
-keepclassmembers class * extends com.getcapacitor.Plugin {
|
|
26
|
+
@com.getcapacitor.annotation.ActivityCallback <methods>;
|
|
27
|
+
@com.getcapacitor.annotation.PermissionCallback <methods>;
|
|
28
|
+
}
|
|
@@ -314,6 +314,7 @@ var nativeBridge = (function (exports) {
|
|
|
314
314
|
win.Ionic.WebView = IonicWebView;
|
|
315
315
|
};
|
|
316
316
|
const initLogger = (win, cap) => {
|
|
317
|
+
var _a, _b;
|
|
317
318
|
const BRIDGED_CONSOLE_METHODS = ['debug', 'error', 'info', 'log', 'trace', 'warn'];
|
|
318
319
|
const createLogFromNative = (c) => (result) => {
|
|
319
320
|
if (isFullConsole(c)) {
|
|
@@ -367,12 +368,6 @@ var nativeBridge = (function (exports) {
|
|
|
367
368
|
}
|
|
368
369
|
};
|
|
369
370
|
const platform = getPlatformId(win);
|
|
370
|
-
if (platform == 'android' && typeof win.CapacitorSystemBarsAndroidInterface !== 'undefined') {
|
|
371
|
-
// add DOM ready listener for System Bars
|
|
372
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
373
|
-
win.CapacitorSystemBarsAndroidInterface.onDOMReady();
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
371
|
if (platform == 'android' || platform == 'ios') {
|
|
377
372
|
// patch document.cookie on Android/iOS
|
|
378
373
|
win.CapacitorCookiesDescriptor =
|
|
@@ -381,13 +376,7 @@ var nativeBridge = (function (exports) {
|
|
|
381
376
|
let doPatchCookies = false;
|
|
382
377
|
// check if capacitor cookies is disabled before patching
|
|
383
378
|
if (platform === 'ios') {
|
|
384
|
-
|
|
385
|
-
// https://stackoverflow.com/questions/29249132/wkwebview-complex-communication-between-javascript-native-code/49474323#49474323
|
|
386
|
-
const payload = {
|
|
387
|
-
type: 'CapacitorCookies.isEnabled',
|
|
388
|
-
};
|
|
389
|
-
const isCookiesEnabled = prompt(JSON.stringify(payload));
|
|
390
|
-
if (isCookiesEnabled === 'true') {
|
|
379
|
+
if (((_a = win.CapacitorNativeConfig) === null || _a === void 0 ? void 0 : _a.cookiesEnabled) === true) {
|
|
391
380
|
doPatchCookies = true;
|
|
392
381
|
}
|
|
393
382
|
}
|
|
@@ -454,13 +443,7 @@ var nativeBridge = (function (exports) {
|
|
|
454
443
|
let doPatchHttp = false;
|
|
455
444
|
// check if capacitor http is disabled before patching
|
|
456
445
|
if (platform === 'ios') {
|
|
457
|
-
|
|
458
|
-
// https://stackoverflow.com/questions/29249132/wkwebview-complex-communication-between-javascript-native-code/49474323#49474323
|
|
459
|
-
const payload = {
|
|
460
|
-
type: 'CapacitorHttp',
|
|
461
|
-
};
|
|
462
|
-
const isHttpEnabled = prompt(JSON.stringify(payload));
|
|
463
|
-
if (isHttpEnabled === 'true') {
|
|
446
|
+
if (((_b = win.CapacitorNativeConfig) === null || _b === void 0 ? void 0 : _b.httpEnabled) === true) {
|
|
464
447
|
doPatchHttp = true;
|
|
465
448
|
}
|
|
466
449
|
}
|
|
@@ -505,6 +488,10 @@ var nativeBridge = (function (exports) {
|
|
|
505
488
|
if (typeof resource === 'string') {
|
|
506
489
|
return await win.CapacitorWebFetch(createProxyUrl(resource, win), options);
|
|
507
490
|
}
|
|
491
|
+
else if (resource instanceof URL) {
|
|
492
|
+
const modifiedURL = new URL(createProxyUrl(resource.toString(), win));
|
|
493
|
+
return await win.CapacitorWebFetch(modifiedURL, options);
|
|
494
|
+
}
|
|
508
495
|
else if (resource instanceof Request) {
|
|
509
496
|
const modifiedRequest = new Request(createProxyUrl(resource.url, win), resource);
|
|
510
497
|
return await win.CapacitorWebFetch(modifiedRequest, options);
|
|
@@ -895,11 +882,24 @@ var nativeBridge = (function (exports) {
|
|
|
895
882
|
try {
|
|
896
883
|
if (typeof postToNative === 'function') {
|
|
897
884
|
let callbackId = '-1';
|
|
898
|
-
|
|
885
|
+
// native never answers removeListener nor sends `save: false` for a removed listener,
|
|
886
|
+
// so release those callbacks here, otherwise everything they capture is never freed
|
|
887
|
+
if (methodName === 'removeListener') {
|
|
888
|
+
callbacks.delete(options === null || options === void 0 ? void 0 : options.callbackId);
|
|
889
|
+
}
|
|
890
|
+
else if (methodName === 'removeAllListeners') {
|
|
891
|
+
callbacks.forEach((stored, id) => {
|
|
892
|
+
if (stored.pluginName === pluginName && stored.methodName === 'addListener') {
|
|
893
|
+
callbacks.delete(id);
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
if (methodName !== 'removeListener' &&
|
|
898
|
+
storedCallback &&
|
|
899
899
|
(typeof storedCallback.callback === 'function' || typeof storedCallback.resolve === 'function')) {
|
|
900
900
|
// store the call for later lookup
|
|
901
901
|
callbackId = String(++callbackIdCount);
|
|
902
|
-
callbacks.set(callbackId, storedCallback);
|
|
902
|
+
callbacks.set(callbackId, Object.assign(Object.assign({}, storedCallback), { pluginName, methodName }));
|
|
903
903
|
}
|
|
904
904
|
const callData = {
|
|
905
905
|
callbackId: callbackId,
|
|
@@ -7,16 +7,20 @@ package com.getcapacitor;
|
|
|
7
7
|
import android.content.Context;
|
|
8
8
|
import android.content.res.AssetManager;
|
|
9
9
|
import android.net.Uri;
|
|
10
|
+
import android.os.Environment;
|
|
10
11
|
import android.util.TypedValue;
|
|
11
12
|
import java.io.File;
|
|
12
13
|
import java.io.FileInputStream;
|
|
14
|
+
import java.io.FileNotFoundException;
|
|
13
15
|
import java.io.IOException;
|
|
14
16
|
import java.io.InputStream;
|
|
17
|
+
import java.util.ArrayList;
|
|
15
18
|
import java.util.List;
|
|
16
19
|
|
|
17
20
|
public class AndroidProtocolHandler {
|
|
18
21
|
|
|
19
22
|
private Context context;
|
|
23
|
+
private List<File> appStorageRoots;
|
|
20
24
|
|
|
21
25
|
public AndroidProtocolHandler(Context context) {
|
|
22
26
|
this.context = context;
|
|
@@ -57,7 +61,8 @@ public class AndroidProtocolHandler {
|
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
private static int getFieldId(Context context, String assetType, String assetName)
|
|
60
|
-
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
|
|
64
|
+
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
|
|
65
|
+
{
|
|
61
66
|
Class<?> d = context.getClassLoader().loadClass(context.getPackageName() + ".R$" + assetType);
|
|
62
67
|
java.lang.reflect.Field field = d.getField(assetName);
|
|
63
68
|
return field.getInt(null);
|
|
@@ -69,6 +74,125 @@ public class AndroidProtocolHandler {
|
|
|
69
74
|
return new FileInputStream(localFile);
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Opens a file served from the base path the app is hosted from (see {@code setServerBasePath}).
|
|
79
|
+
* The request path is decoded by {@link Uri#getPath()}, so an encoded slash ({@code %2F}) can carry
|
|
80
|
+
* {@code ..} segments that the browser did not resolve. The resolved file must therefore sit inside
|
|
81
|
+
* the base path, or the request would read any file the app can read.
|
|
82
|
+
*
|
|
83
|
+
* @param basePath the directory the app is hosted from
|
|
84
|
+
* @param filePath the base path followed by the request path
|
|
85
|
+
* @throws FileNotFoundException if the resolved file is outside of the base path
|
|
86
|
+
*/
|
|
87
|
+
public InputStream openBasePathFile(String basePath, String filePath) throws IOException {
|
|
88
|
+
String base = new File(basePath).getCanonicalPath();
|
|
89
|
+
File file = new File(filePath).getCanonicalFile();
|
|
90
|
+
String resolved = file.getPath();
|
|
91
|
+
if (!resolved.equals(base) && !resolved.startsWith(base.endsWith(File.separator) ? base : base + File.separator)) {
|
|
92
|
+
throw new FileNotFoundException("File is outside of the base path: " + filePath);
|
|
93
|
+
}
|
|
94
|
+
return new FileInputStream(file);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Opens a file whose location was chosen by a {@link RouteProcessor}. The processor may map requests
|
|
99
|
+
* outside the base path on purpose, so containment is not checked here. The request path is decoded
|
|
100
|
+
* by {@link Uri#getPath()}, so an encoded slash ({@code %2F}) can still carry {@code ..} segments that
|
|
101
|
+
* the browser did not resolve and that a processor would pass on; such requests are refused.
|
|
102
|
+
*
|
|
103
|
+
* @param requestPath the decoded request path
|
|
104
|
+
* @param processedPath the file path returned by the route processor
|
|
105
|
+
* @throws FileNotFoundException if the request path contains a parent-directory segment
|
|
106
|
+
*/
|
|
107
|
+
public InputStream openRoutedFile(String requestPath, String processedPath) throws IOException {
|
|
108
|
+
for (String segment : requestPath.split("/")) {
|
|
109
|
+
if (segment.equals("..")) {
|
|
110
|
+
throw new FileNotFoundException("Parent-directory segment in request path: " + requestPath);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return openFile(processedPath);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Opens a file requested through the {@link Bridge#CAPACITOR_FILE_START} proxy route.
|
|
118
|
+
* Unlike {@link #openFile(String)}, the resolved path must sit inside the app's own storage or
|
|
119
|
+
* shared/external storage, so the route cannot expose app-private data (shared_prefs, databases)
|
|
120
|
+
* or system files such as /proc or /etc.
|
|
121
|
+
*
|
|
122
|
+
* @param filePath the request path, starting with {@link Bridge#CAPACITOR_FILE_START}
|
|
123
|
+
* @throws IOException if the file cannot be opened or its location is not allowed
|
|
124
|
+
*/
|
|
125
|
+
public InputStream openProxiedFile(String filePath) throws IOException {
|
|
126
|
+
String realPath = filePath.startsWith(Bridge.CAPACITOR_FILE_START)
|
|
127
|
+
? filePath.substring(Bridge.CAPACITOR_FILE_START.length())
|
|
128
|
+
: filePath;
|
|
129
|
+
// Canonicalizing resolves ".." segments and symlinks; open the resolved file so the checked path is the read one.
|
|
130
|
+
File canonicalFile = new File(realPath).getCanonicalFile();
|
|
131
|
+
if (!isInAllowedLocation(canonicalFile)) {
|
|
132
|
+
throw new IOException("Path is outside the locations served by the file proxy: " + realPath);
|
|
133
|
+
}
|
|
134
|
+
return new FileInputStream(canonicalFile);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private boolean isInAllowedLocation(File canonicalFile) throws IOException {
|
|
138
|
+
String path = canonicalFile.getPath();
|
|
139
|
+
for (File root : getAllowedRoots()) {
|
|
140
|
+
String rootPath = root.getCanonicalPath();
|
|
141
|
+
if (path.equals(rootPath) || path.startsWith(rootPath + File.separator)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@SuppressWarnings("deprecation")
|
|
149
|
+
/**
|
|
150
|
+
* The app's files and cache directories (Filesystem Data/Library/Cache, Camera temporary images). They do not
|
|
151
|
+
* change while the app runs, unlike the external storage roots, so they are looked up once.
|
|
152
|
+
*/
|
|
153
|
+
private List<File> getAppStorageRoots() {
|
|
154
|
+
List<File> roots = appStorageRoots;
|
|
155
|
+
if (roots == null) {
|
|
156
|
+
roots = new ArrayList<>();
|
|
157
|
+
addIfNotNull(roots, context.getFilesDir());
|
|
158
|
+
addIfNotNull(roots, context.getCacheDir());
|
|
159
|
+
appStorageRoots = roots;
|
|
160
|
+
}
|
|
161
|
+
return roots;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private List<File> getAllowedRoots() {
|
|
165
|
+
List<File> roots = new ArrayList<>(getAppStorageRoots());
|
|
166
|
+
// Primary shared storage (Filesystem Documents/ExternalStorage, gallery and media picks)
|
|
167
|
+
addIfNotNull(roots, Environment.getExternalStorageDirectory());
|
|
168
|
+
// App-specific external dirs, and the root of every other volume (e.g. SD cards) they live on
|
|
169
|
+
List<File> externalDirs = new ArrayList<>();
|
|
170
|
+
for (File dir : context.getExternalFilesDirs(null)) {
|
|
171
|
+
externalDirs.add(dir);
|
|
172
|
+
}
|
|
173
|
+
for (File dir : context.getExternalCacheDirs()) {
|
|
174
|
+
externalDirs.add(dir);
|
|
175
|
+
}
|
|
176
|
+
for (File dir : externalDirs) {
|
|
177
|
+
if (dir == null) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
roots.add(dir);
|
|
181
|
+
String dirPath = dir.getPath();
|
|
182
|
+
int androidDirIndex = dirPath.indexOf("/Android/");
|
|
183
|
+
if (androidDirIndex > 0) {
|
|
184
|
+
roots.add(new File(dirPath.substring(0, androidDirIndex)));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return roots;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private static void addIfNotNull(List<File> roots, File dir) {
|
|
191
|
+
if (dir != null) {
|
|
192
|
+
roots.add(dir);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
72
196
|
public InputStream openContentUrl(Uri uri) throws IOException {
|
|
73
197
|
Integer port = uri.getPort();
|
|
74
198
|
String baseUrl = uri.getScheme() + "://" + uri.getHost();
|
|
@@ -80,7 +204,10 @@ public class AndroidProtocolHandler {
|
|
|
80
204
|
InputStream stream = null;
|
|
81
205
|
try {
|
|
82
206
|
stream = context.getContentResolver().openInputStream(Uri.parse(realPath));
|
|
83
|
-
} catch (
|
|
207
|
+
} catch (RuntimeException e) {
|
|
208
|
+
// The target provider runs in this process and may throw unchecked exceptions for a malformed or
|
|
209
|
+
// unknown path (e.g. FileProvider throws IllegalArgumentException, older versions
|
|
210
|
+
// StringIndexOutOfBoundsException). Left uncaught they crash the app, so report "not found" instead.
|
|
84
211
|
Logger.error("Unable to open content URL: " + uri, e);
|
|
85
212
|
}
|
|
86
213
|
return stream;
|