@@ -1375,18 +1375,48 @@ private Uri[] blockPrivatePaths(Uri[] resultList) {
1375
1375
String dataData = "/data/data/" + mContext .getPackageName ();
1376
1376
String dataUser = dataData ;
1377
1377
File dataDir = ContextCompat .getDataDir (mContext );
1378
+ String filePath = "" ;
1379
+ try {
1380
+ filePath = new File (path ).getCanonicalPath ();
1381
+ } catch (IOException e ) {
1382
+ Log .e (TAG , "blockPrivatePaths: " , e );
1383
+ return new Uri [0 ];
1384
+ }
1385
+ String externalData = "/sdcard/Android/data/" + mContext .getPackageName ();
1378
1386
if (dataDir != null ) {
1379
1387
dataUser = dataDir .getPath ();
1380
1388
}
1381
- if (!TextUtils .isEmpty (path ) && (path .startsWith (dataData ) || path .startsWith (dataUser ))) {
1382
- return new Uri [0 ];
1389
+ if (!TextUtils .isEmpty (filePath )) {
1390
+ if (filePath .startsWith (dataData ) || filePath .startsWith (dataUser )) {
1391
+ return new Uri [0 ];
1392
+ }
1393
+ if (filePath .toLowerCase ().startsWith (externalData .toLowerCase ())) {
1394
+ return new Uri [0 ];
1395
+ }
1396
+ File [] externalFilesDirs = mContext .getExternalFilesDirs (null );
1397
+ if (checkPath (filePath , externalFilesDirs )) return new Uri [0 ];
1398
+ File [] externalCacheDirs = mContext .getExternalCacheDirs ();
1399
+ if (checkPath (filePath , externalCacheDirs )) return new Uri [0 ];
1400
+ File [] externalMediaDirs = mContext .getExternalMediaDirs ();
1401
+ if (checkPath (filePath , externalMediaDirs )) return new Uri [0 ];
1383
1402
}
1384
1403
}
1385
1404
}
1386
1405
}
1387
1406
return resultList ;
1388
1407
}
1389
1408
1409
+ private boolean checkPath (String path , File [] files ) {
1410
+ if (files != null ) {
1411
+ for (File file : files ) {
1412
+ if (path .toLowerCase ().startsWith (file .getAbsolutePath ().toLowerCase ())) {
1413
+ return true ;
1414
+ }
1415
+ }
1416
+ }
1417
+ return false ;
1418
+ }
1419
+
1390
1420
private void resolveLowApiResult () {
1391
1421
final HybridView hybridView =
1392
1422
getComponent () != null ? getComponent ().getHybridView () : null ;
@@ -1423,6 +1453,16 @@ && getComponent().getCallback() != null) {
1423
1453
mCacheVideoFile = null ;
1424
1454
}
1425
1455
result = tmpResults ;
1456
+ } else {
1457
+ //photo or video sometimes go here
1458
+ if ((mCachePhotoFile == null || !mCachePhotoFile .exists () || mCachePhotoFile .length () == 0 ) && (mCacheVideoFile == null || !mCacheVideoFile .exists () || mCacheVideoFile .length () == 0 )) {
1459
+ //not check photo or video
1460
+ Uri [] results = new Uri []{result };
1461
+ Uri [] resultsAfterCheck = blockPrivatePaths (results );
1462
+ if (resultsAfterCheck .length == 0 ) {
1463
+ result = null ;
1464
+ }
1465
+ }
1426
1466
}
1427
1467
}
1428
1468
if (null != mSingleFileCallback ) {
0 commit comments