Gracefully handle case where /sdcard is removed or otherwise unavailable

This commit is contained in:
Aaron Culliney 2015-09-13 10:01:44 -07:00
parent dada329a8b
commit 55f04d4f68

View File

@ -108,7 +108,9 @@ public class Apple2DisksMenu implements Apple2MenuView {
sDataDir = pi.applicationInfo.dataDir; sDataDir = pi.applicationInfo.dataDir;
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "" + e); Log.e(TAG, "" + e);
System.exit(1); if (sDataDir == null) {
sDataDir = "/data/local/tmp";
}
} }
return sDataDir; return sDataDir;
@ -141,7 +143,6 @@ public class Apple2DisksMenu implements Apple2MenuView {
} }
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "problem copying resources : " + e); Log.e(TAG, "problem copying resources : " + e);
System.exit(1);
} }
} }
@ -338,6 +339,14 @@ public class Apple2DisksMenu implements Apple2MenuView {
} }
}); });
// This appears to happen in cases where the external files directory String is valid, but is not actually mounted
// We could probably check for more media "states" in the setup above ... but this defensive coding probably should
// remain here after any refactoring =)
if (files == null) {
dismiss();
return;
}
Arrays.sort(files); Arrays.sort(files);
getExternalStorageDirectory(); getExternalStorageDirectory();