in core/src/main/java/com/facebook/testing/screenshot/internal/ScreenshotDirectories.java [100:132]
private File getSdcardDir(String type) {
String externalStorage = System.getenv("EXTERNAL_STORAGE");
if (externalStorage == null) {
throw new RuntimeException(
"No $EXTERNAL_STORAGE has been set on the device, please report this bug!");
}
String sdcardDirectory =
mArguments.containsKey(SDCARD_DIRECTORY)
? mArguments.getString(SDCARD_DIRECTORY)
: DEFAULT_SDCARD_DIRECTORY;
String parent =
String.format("%s/%s/%s/", externalStorage, sdcardDirectory, mContext.getPackageName());
String child = String.format("%s/screenshots-%s", parent, type);
new File(parent).mkdirs();
File dir = new File(child);
dir.mkdir();
if (!dir.exists()) {
throw new RuntimeException(
"Failed to create the directory "
+ dir.getAbsolutePath()
+ " for screenshots. Is your sdcard directory read-only?");
}
setWorldWriteable(dir);
return dir;
}