|  |  |  | @ -6,8 +6,7 @@ import android.os.storage.StorageManager | 
		
	
		
			
				|  |  |  |  | import android.os.storage.StorageVolume | 
		
	
		
			
				|  |  |  |  | import java.lang.reflect.InvocationTargetException | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | val USB_KEYWORDS = arrayOf("USB", "U 盘") | 
		
	
		
			
				|  |  |  |  | val NVME_KEYWORDS = arrayOf("新加卷") | 
		
	
		
			
				|  |  |  |  | val NVME_KEYWORDS = arrayOf("yinuo nvme", "YINUO NVME", "YINUO", "NVME") | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | object StorageUtils { | 
		
	
		
			
				|  |  |  |  |     /** | 
		
	
	
		
			
				
					|  |  |  | @ -31,15 +30,21 @@ object StorageUtils { | 
		
	
		
			
				|  |  |  |  |             val getUserLabel = storageVolumeClazz.getMethod("getUserLabel") | 
		
	
		
			
				|  |  |  |  |             for (i in 0 until length) { | 
		
	
		
			
				|  |  |  |  |                 val storageVolumeElement: StorageVolume = result[i] | 
		
	
		
			
				|  |  |  |  |                 // 内部存储 | 
		
	
		
			
				|  |  |  |  |                 if (storageVolumeElement.isPrimary) { | 
		
	
		
			
				|  |  |  |  |                     continue | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |                 val userLabel = getUserLabel.invoke(storageVolumeElement) as String | 
		
	
		
			
				|  |  |  |  |                 val path = getPath.invoke(storageVolumeElement) as String | 
		
	
		
			
				|  |  |  |  |                 if (isUsb) { | 
		
	
		
			
				|  |  |  |  |                     if (USB_KEYWORDS.contains(userLabel)) { | 
		
	
		
			
				|  |  |  |  |                 // nvme | 
		
	
		
			
				|  |  |  |  |                 if (!isUsb) { | 
		
	
		
			
				|  |  |  |  |                     // 大于400GB的也当硬盘看待 | 
		
	
		
			
				|  |  |  |  |                     if (containsNvmeKeys(userLabel) || getSizeInGB(path) > 400) { | 
		
	
		
			
				|  |  |  |  |                         targetpath = path | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                 } else { | 
		
	
		
			
				|  |  |  |  |                     // 大于400GB的也当硬盘看待 | 
		
	
		
			
				|  |  |  |  |                     if (NVME_KEYWORDS.contains(userLabel) || getSizeInGB(path) > 400) { | 
		
	
		
			
				|  |  |  |  |                     // 不是内部存储,也不是硬盘,就当作U盘 | 
		
	
		
			
				|  |  |  |  |                     if (!containsNvmeKeys(userLabel)) { | 
		
	
		
			
				|  |  |  |  |                         targetpath = path | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
	
		
			
				
					|  |  |  | @ -56,6 +61,16 @@ object StorageUtils { | 
		
	
		
			
				|  |  |  |  |         return targetpath | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private fun containsNvmeKeys(label: String): Boolean { | 
		
	
		
			
				|  |  |  |  |         NVME_KEYWORDS.forEach { | 
		
	
		
			
				|  |  |  |  |             if (label.contains(it)) { | 
		
	
		
			
				|  |  |  |  |                 LogUtils.w("label:${label} is nvme") | 
		
	
		
			
				|  |  |  |  |                 return true | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         return false | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private const val BYTE_GB = 1024 * 1024 * 1024f | 
		
	
		
			
				|  |  |  |  |     private fun getSizeInGB(path: String): Int { | 
		
	
		
			
				|  |  |  |  |         val statfs = StatFs(path) | 
		
	
	
		
			
				
					|  |  |  | 
 |