summaryrefslogtreecommitdiffstats
path: root/android/src/org/rockbox
diff options
context:
space:
mode:
Diffstat (limited to 'android/src/org/rockbox')
-rw-r--r--android/src/org/rockbox/RockboxService.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index fb7c0437fc..c474044c0b 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -24,7 +24,9 @@ package org.rockbox;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Timer;
import java.util.TimerTask;
@@ -41,6 +43,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
+import android.os.Environment;
import android.os.IBinder;
import android.os.ResultReceiver;
import android.util.Log;
@@ -245,6 +248,26 @@ public class RockboxService extends Service
}
}
+ /* Generate default config if none exists yet */
+ File rockboxConfig = new File(Environment.getExternalStorageDirectory(), "rockbox/config.cfg");
+ if (!rockboxConfig.exists()) {
+ File rbDir = new File(rockboxConfig.getParent());
+ if (!rbDir.exists())
+ rbDir.mkdirs();
+
+ OutputStreamWriter strm;
+ try {
+ strm = new OutputStreamWriter(new FileOutputStream(rockboxConfig));
+ strm.write("# config generated by RockboxService\n");
+ strm.write("start directory: " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "\n");
+ strm.write("lang: /.rockbox/langs/" + getString(R.string.rockbox_language_file) + "\n");
+ strm.close();
+ } catch(Exception e) {
+ LOG("Exception when writing default config", e);
+ }
+ }
+
+ /* Start native code */
if (resultReceiver != null)
resultReceiver.send(RESULT_INVOKING_MAIN, null);