Only use $EXTERNAL_STORAGE if it exists and is writable.

Also fail with a clear error if we can't create a temporary file,
rather than blindly carrying on and crashing in fseeko much later.

The emulator has $EXTERNAL_STORAGE set to a directory that's only
usable if you manually supply a valid sdcard image.

Bug: 8013987
Change-Id: I51ffc1a5525273752f67a9356ccd272a4507613a
1 file changed