| 
					
				 | 
			
			
				@@ -74,6 +74,20 @@ public final class UriUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static File uri2File(final Uri uri) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (uri == null) return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         File file = uri2FileReal(uri); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//           大于等安卓11的版本可能会存在选择的文件没有权限,需要申请所有文件权限才行。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            targetSdkVersion >= 29 ,安卓Q的沙盒机制限制,会出现读写问题。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            当targetSdkVersion = 29,通过设置requestLegacyExternalStorage=“true”,还能解决。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            当targetSdkVersion = 30后,需要申请所有文件权限才能获取到写入权限 Environment.isExternalStorageManager()。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                跳转设置所有文件权限页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                Intent intent2 = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                intent2.setData(Uri.parse("package:" + Utils.getApp().getPackageName())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                startActivityForResult(intent2, 1024); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (file != null && !Environment.isExternalStorageManager()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Log.i("UriUtils","Environment.isExternalStorageManager():"+Environment.isExternalStorageManager()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return copyUri2Cache(uri); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (file != null) return file; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return copyUri2Cache(uri); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |