summaryrefslogtreecommitdiff
path: root/android/src/org/rockbox
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 15:45:22 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 15:45:22 +0000
commitfe6faf2e2c6e410f8b96ee470cf0ce21f745f56d (patch)
treeb52ac243c593f4f89552890119bd61d0bd627c5b /android/src/org/rockbox
parent8196f21a9486783943f9d2f81dbf4eaa1c82df32 (diff)
Android port: generate initial config when none is present with dynamically
generated values depending on your environment. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29560 a1c6a512-1295-4272-9138-f99709370657
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);