workaround for startup crash when reading free space fails
This commit is contained in:
parent
9d5ecb93ad
commit
61ce13ca33
3 changed files with 17 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="19"
|
||||
android:versionCode="20"
|
||||
android:versionName="1.4.8" package="btools.routingapp">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".BRouterActivity"
|
||||
|
|
|
@ -203,8 +203,13 @@ public class BInstallerView extends View
|
|||
scanExistingFiles( secondary );
|
||||
}
|
||||
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
availableSize = (long)stat.getAvailableBlocks()*stat.getBlockSize();
|
||||
availableSize = -1;
|
||||
try
|
||||
{
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
availableSize = (long)stat.getAvailableBlocks()*stat.getBlockSize();
|
||||
}
|
||||
catch (Exception e) { /* ignore */ }
|
||||
}
|
||||
|
||||
private void scanExistingFiles( File dir )
|
||||
|
@ -361,7 +366,7 @@ public class BInstallerView extends View
|
|||
|
||||
|
||||
String totmb = ((totalSize + mb-1)/mb) + " MB";
|
||||
String freemb = ((availableSize + mb-1)/mb) + " MB";
|
||||
String freemb = availableSize >= 0 ? ((availableSize + mb-1)/mb) + " MB" : "?";
|
||||
canvas.drawText( "Selected segments=" + rd5Tiles, 10, 25, paint );
|
||||
canvas.drawText( "Size=" + totmb + " Free=" + freemb , 10, 45, paint );
|
||||
|
||||
|
@ -591,7 +596,7 @@ float tx, ty;
|
|||
// might be -1: server did not report the length
|
||||
int fileLength = connection.getContentLength();
|
||||
currentDownloadSize = fileLength;
|
||||
if ( fileLength > availableSize ) return "not enough space on sd-card";
|
||||
if ( availableSize >= 0 && fileLength > availableSize ) return "not enough space on sd-card";
|
||||
|
||||
// download the file
|
||||
input = connection.getInputStream();
|
||||
|
|
|
@ -467,17 +467,18 @@ public class BRouterActivity extends Activity implements OnInitListener
|
|||
ArrayList<Long> dirFreeSizes = new ArrayList<Long>();
|
||||
for ( String d : items )
|
||||
{
|
||||
long size = 0L;
|
||||
try
|
||||
{
|
||||
StatFs stat = new StatFs( d );
|
||||
long size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
|
||||
int idx = 0;
|
||||
while (idx < availableBasedirs.size() && dirFreeSizes.get( idx ).longValue() > size)
|
||||
idx++;
|
||||
availableBasedirs.add( idx, d );
|
||||
dirFreeSizes.add( idx, Long.valueOf( size ) );
|
||||
size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
|
||||
}
|
||||
catch (Exception e) { /* ignore */ }
|
||||
int idx = 0;
|
||||
while (idx < availableBasedirs.size() && dirFreeSizes.get( idx ).longValue() > size)
|
||||
idx++;
|
||||
availableBasedirs.add( idx, d );
|
||||
dirFreeSizes.add( idx, Long.valueOf( size ) );
|
||||
}
|
||||
|
||||
basedirOptions = new String[items.size() + 1];
|
||||
|
|
Loading…
Reference in a new issue