SDL: check that SD card is writable before writing there on fresh install

This commit is contained in:
pelya
2016-05-17 12:36:27 +03:00
parent 723e0524ac
commit 2bc39e57ba
4 changed files with 20 additions and 4 deletions

View File

@@ -441,6 +441,14 @@ class Settings
for( String s: fileList )
if( s.toUpperCase().startsWith(DataDownloader.DOWNLOAD_FLAG_FILENAME.toUpperCase()) )
Globals.DataDir = SdcardAppPath.getPath(p);
try {
new File(Globals.DataDir).mkdirs();
new FileOutputStream( new File(Globals.DataDir, ".nomedia") ).close();
} catch (Exception e) {
Globals.DownloadToSdcard = false; // SD card not writable
Globals.DataDir = p.getFilesDir().getAbsolutePath();
}
}
}
@@ -795,6 +803,14 @@ class Settings
continue;
StatFs stat = new StatFs(path.getPath());
long size = (long)stat.getAvailableBlocks() * stat.getBlockSize() / 1024 / 1024;
try {
path.mkdirs();
new FileOutputStream( new File(path, ".nomedia") ).close();
} catch (Exception e) {
size = -1; // Not writable
}
if( size > maxSize )
{
maxSize = size;

View File

@@ -85,7 +85,7 @@ CompatibilityHacksTextInputEmulatesHwKeyboard=n
# 1 - Simple QWERTY keyboard, no function keys, no arrow keys
# 2 - Commodore 64 keyboard
# 3 - Amiga keyboard
TextInputKeyboard=1
TextInputKeyboard=3
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=n

View File

@@ -7,10 +7,10 @@ AppName="OpenTTD"
AppFullName=org.openttd.sdl
# Application version code (integer)
AppVersionCode=16056
AppVersionCode=16058
# Application user-visible version name (string)
AppVersionName="1.6.0.56"
AppVersionName="1.6.0.58"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu