diff --git a/android/README.txt b/android/README.txt index 67b8aa30f..70774a279 100644 --- a/android/README.txt +++ b/android/README.txt @@ -28,7 +28,7 @@ ant debug ../../android-sdk-linux_86/tools/emulator -avd i2p & #then wait a couple minutes until the emulator is up -#then install the I2P app +#then install the I2P app (ONE TIME ONLY) ant install #then run the debugger diff --git a/android/build.properties b/android/build.properties new file mode 100644 index 000000000..181724115 --- /dev/null +++ b/android/build.properties @@ -0,0 +1 @@ +application-package=net.i2p.router diff --git a/android/build.xml b/android/build.xml index 94356fcf4..6869bce6b 100644 --- a/android/build.xml +++ b/android/build.xml @@ -76,6 +76,9 @@ + + + @@ -237,6 +240,7 @@ @@ -280,6 +284,12 @@ + - + Uninstalling ${application-package} from the default emulator... - + diff --git a/android/src/net/i2p/router/I2PAndroid.java b/android/src/net/i2p/router/I2PAndroid.java index 88d522dd6..262493ec3 100644 --- a/android/src/net/i2p/router/I2PAndroid.java +++ b/android/src/net/i2p/router/I2PAndroid.java @@ -46,6 +46,7 @@ public class I2PAndroid extends Activity { System.err.println("onStart called"); super.onStart(); +// net.i2p.crypto.DSAEngine.main(null); RouterLaunch.main(null); System.err.println("Router.main finished"); } diff --git a/android/src/net/i2p/util/LogWriter.java b/android/src/net/i2p/util/LogWriter.java index 0babfab37..18ba54c8e 100644 --- a/android/src/net/i2p/util/LogWriter.java +++ b/android/src/net/i2p/util/LogWriter.java @@ -10,6 +10,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.List; +import java.util.Queue; /** * bridge to android logging @@ -56,11 +57,21 @@ class LogWriter implements Runnable { public void flushRecords() { flushRecords(true); } public void flushRecords(boolean shouldWait) { try { - List records = _manager._removeAll(); + // zero copy, drain the manager queue directly + Queue records = _manager.getQueue(); if (records == null) return; - for (int i = 0; i < records.size(); i++) { - LogRecord rec = (LogRecord) records.get(i); - writeRecord(rec); + if (!records.isEmpty()) { + LogRecord rec; + while ((rec = records.poll()) != null) { + writeRecord(rec); + } + try { + if (_currentOut != null) + _currentOut.flush(); + } catch (IOException ioe) { + //if (++_diskFullMessageCount < MAX_DISKFULL_MESSAGES) + System.err.println("Error writing the router log - disk full? " + ioe); + } } } catch (Throwable t) { t.printStackTrace(); diff --git a/android/src/net/i2p/util/SecureDirectory.java b/android/src/net/i2p/util/SecureDirectory.java new file mode 100644 index 000000000..0c34c91c0 --- /dev/null +++ b/android/src/net/i2p/util/SecureDirectory.java @@ -0,0 +1,22 @@ +package net.i2p.util; + +import java.io.File; + +/** + * setXXX() not available until API level 9 (Platform Version 2.3) + * @since 0.8.7 + */ +public class SecureDirectory extends File { + + public SecureDirectory(String pathname) { + super(pathname); + } + + public SecureDirectory(String parent, String child) { + super(parent, child); + } + + public SecureDirectory(File parent, String child) { + super(parent, child); + } +} diff --git a/android/src/net/i2p/util/SecureFile.java b/android/src/net/i2p/util/SecureFile.java new file mode 100644 index 000000000..e9362ef94 --- /dev/null +++ b/android/src/net/i2p/util/SecureFile.java @@ -0,0 +1,22 @@ +package net.i2p.util; + +import java.io.File; + +/** + * setXXX() not available until API level 9 (Platform Version 2.3) + * @since 0.8.7 + */ +public class SecureFile extends SecureDirectory { + + public SecureFile(String pathname) { + super(pathname); + } + + public SecureFile(String parent, String child) { + super(parent, child); + } + + public SecureFile(File parent, String child) { + super(parent, child); + } +} diff --git a/android/src/net/i2p/util/SecureFileOutputStream.java b/android/src/net/i2p/util/SecureFileOutputStream.java new file mode 100644 index 000000000..e45798cf9 --- /dev/null +++ b/android/src/net/i2p/util/SecureFileOutputStream.java @@ -0,0 +1,53 @@ +package net.i2p.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; + +import net.i2p.I2PAppContext; + +/** + * setXXX() not available until API level 9 (Platform Version 2.3) + * @since 0.8.7 + */ +public class SecureFileOutputStream extends FileOutputStream { + + /** + * super() + */ + public SecureFileOutputStream(String file) throws FileNotFoundException { + super(file); + } + + /** + * super() + */ + public SecureFileOutputStream(String file, boolean append) throws FileNotFoundException { + super(file, append); + } + + /** + * super() + */ + public SecureFileOutputStream(File file) throws FileNotFoundException { + super(file); + } + + /** + * super() + */ + public SecureFileOutputStream(File file, boolean append) throws FileNotFoundException { + super(file, append); + } + + /** @return false */ + static boolean canSetPerms() { + return false; + } + + /** + * noop + */ + public static void setPerms(File f) { + } +}