|
@@ -345,24 +345,24 @@ public class SystemUtil {
|
345
|
345
|
}
|
346
|
346
|
}
|
347
|
347
|
|
348
|
|
- public static boolean isSDCardMounted(Context context) {
|
|
348
|
+ public static boolean isSDCardMounted(Context context,boolean stateFlag) {
|
349
|
349
|
try{
|
350
|
350
|
/* File[] externalFilesDirs = context.getExternalFilesDirs(null);
|
351
|
351
|
return externalFilesDirs.length > 1;*/
|
352
|
352
|
/* String state = Environment.getExternalStorageState();
|
353
|
353
|
return Environment.MEDIA_MOUNTED.equals(state);*/
|
354
|
|
- return IsExistCard(context);
|
|
354
|
+ return IsExistCard(context,stateFlag);
|
355
|
355
|
}catch (Exception e){
|
356
|
356
|
return false;
|
357
|
357
|
}
|
358
|
358
|
}
|
359
|
359
|
|
360
|
360
|
/**
|
361
|
|
- * 判断外置SD/TF卡是否挂载
|
|
361
|
+ * 判断外置SD/TF卡是否挂载 stateFlag表示外部传入的挂载状态,用于处理sd卡被系统禁用时的状态判断情况
|
362
|
362
|
*
|
363
|
363
|
* @return
|
364
|
364
|
*/
|
365
|
|
- public static boolean IsExistCard(Context context) {
|
|
365
|
+ public static boolean IsExistCard(Context context,boolean stateFlag) {
|
366
|
366
|
boolean result = false;
|
367
|
367
|
try {
|
368
|
368
|
StorageManager mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
@@ -383,9 +383,9 @@ public class SystemUtil {
|
383
|
383
|
Object storageVolumeElement = Array.get(obj, i);
|
384
|
384
|
String path = (String) getPath.invoke(storageVolumeElement);
|
385
|
385
|
boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement);
|
386
|
|
- LogUtils.d("sd卡可移动"+removable);
|
387
|
386
|
String state = (String) getState.invoke(storageVolumeElement);
|
388
|
|
- if (removable && state.equals(Environment.MEDIA_MOUNTED)) {
|
|
387
|
+ LogUtils.d("sd卡可移动"+removable+"|||"+state);
|
|
388
|
+ if (removable && (state.equals(Environment.MEDIA_MOUNTED)||stateFlag)) {
|
389
|
389
|
result = true;
|
390
|
390
|
break;
|
391
|
391
|
}
|