Only use $EXTERNAL_STORAGE if it exists and is writable.
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

omapzoom/platform-external-gtest,SlimSaber/android_external_gtest,ThangBK2009/android-source-browsing.platform--external--gtest,SaleJumper/android-source-browsing.platform--external--gtest,bhargavkumar040/android-source-browsing.platform--external--gtest,SlimSaber/android_external_gtest,yinquan529/platform-external-gtest,Pankaj-Sakariya/android-source-browsing.platform--external--gtest,bhargavkumar040/android-source-browsing.platform--external--gtest,PurityROM/platform_external_gtest,SaleJumper/android-source-browsing.platform--external--gtest,yinquan529/platform-external-gtest,Nico60/external_gtest,omapzoom/platform-external-gtest,ThangBK2009/android-source-browsing.platform--external--gtest,bhargavkumar040/android-source-browsing.platform--external--gtest,Nico60/external_gtest,IllusionRom-deprecated/android_platform_external_gtest,SlimSaber/android_external_gtest,IllusionRom-deprecated/android_platform_external_gtest,geekboxzone/lollipop_external_gtest,android-ia/platform_external_gtest,Pankaj-Sakariya/android-source-browsing.platform--external--gtest,Omegaphora/external_gtest,geekboxzone/mmallow_external_gtest,Nico60/external_gtest,PurityROM/platform_external_gtest,Omegaphora/external_gtest,geekboxzone/lollipop_external_gtest,SaleJumper/android-source-browsing.platform--external--gtest,geekboxzone/mmallow_external_gtest,IllusionRom-deprecated/android_platform_external_gtest,Pankaj-Sakariya/android-source-browsing.platform--external--gtest,yinquan529/platform-external-gtest,ThangBK2009/android-source-browsing.platform--external--gtest,android-ia/platform_external_gtest,PurityROM/platform_external_gtest