base-dir proposals + repeat-timout logik
This commit is contained in:
parent
80e36d4bb5
commit
e1f8fce85a
2 changed files with 42 additions and 13 deletions
|
@ -268,20 +268,23 @@ public class BRouterView extends View
|
|||
// add a "last timeout" dummy profile
|
||||
File lastTimeoutFile = new File( modesDir + "/timeoutdata.txt" );
|
||||
long lastTimeoutTime = lastTimeoutFile.lastModified();
|
||||
if ( lastTimeoutTime > 0 && System.currentTimeMillis() - lastTimeoutTime < 300000 )
|
||||
if ( lastTimeoutTime > 0 && System.currentTimeMillis() - lastTimeoutTime < 1800000 )
|
||||
{
|
||||
profiles.add( 0, "<repeat timeout>" );
|
||||
BufferedReader br = new BufferedReader( new FileReader( lastTimeoutFile ) );
|
||||
String repeatProfile = br.readLine();
|
||||
br.close();
|
||||
profiles.add( 0, "<repeat:" + repeatProfile + ">" );
|
||||
}
|
||||
|
||||
if ( !lookupsFound )
|
||||
{
|
||||
throw new IllegalArgumentException( "The profile-directory " + profileDir + " does not contain the lookups.dat file."
|
||||
+ " see www.dr-brenschede.de/brouter for setup instructions." );
|
||||
+ " see brouter.de/brouter for setup instructions." );
|
||||
}
|
||||
if ( profiles.size() == 0 )
|
||||
{
|
||||
throw new IllegalArgumentException( "The profile-directory " + profileDir + " contains no routing profiles (*.brf)."
|
||||
+ " see www.dr-brenschede.de/brouter for setup instructions." );
|
||||
+ " see brouter.de/brouter for setup instructions." );
|
||||
}
|
||||
if ( !RoutingHelper.hasDirectoryAnyDatafiles( segmentDir ) )
|
||||
{
|
||||
|
@ -431,7 +434,7 @@ public class BRouterView extends View
|
|||
public void startProcessing( String profile )
|
||||
{
|
||||
rawTrackPath = null;
|
||||
if ( "<repeat timeout>".equals( profile ) )
|
||||
if ( profile.startsWith( "<repeat" ) )
|
||||
{
|
||||
needsViaSelection = needsNogoSelection = needsWaypointSelection = false;
|
||||
try
|
||||
|
@ -1092,6 +1095,34 @@ public class BRouterView extends View
|
|||
private List<String> getStorageDirectories()
|
||||
{
|
||||
ArrayList<String> res = new ArrayList<String>();
|
||||
|
||||
// check write access on internal sd
|
||||
try
|
||||
{
|
||||
File sd = Environment.getExternalStorageDirectory();
|
||||
File testDir = new File( sd, "brouter" );
|
||||
boolean didExist = testDir.isDirectory();
|
||||
if ( !didExist )
|
||||
{
|
||||
testDir.mkdir();
|
||||
}
|
||||
File testFile = new File( testDir, "test" + System.currentTimeMillis() );
|
||||
testFile.createNewFile();
|
||||
if ( testFile.exists() )
|
||||
{
|
||||
testFile.delete();
|
||||
res.add( sd.getPath() );
|
||||
}
|
||||
if ( !didExist )
|
||||
{
|
||||
testDir.delete();
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -72,6 +72,12 @@ public class BRouterWorker
|
|||
|
||||
waypoints = readPositions(params);
|
||||
|
||||
try
|
||||
{
|
||||
writeTimeoutData( rc );
|
||||
}
|
||||
catch( Exception e ) {}
|
||||
|
||||
RoutingEngine cr = new RoutingEngine( null, null, segmentDir, waypoints, rc );
|
||||
cr.quite = true;
|
||||
cr.doRun( maxRunningTime );
|
||||
|
@ -89,14 +95,6 @@ public class BRouterWorker
|
|||
|
||||
if ( cr.getErrorMessage() != null )
|
||||
{
|
||||
if ( cr.getErrorMessage().indexOf( "timeout" ) >= 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
writeTimeoutData( rc );
|
||||
}
|
||||
catch( Exception e ) {}
|
||||
}
|
||||
return cr.getErrorMessage();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue