From 2e5caac8bf7db01098dccf846166dd44b8f4d4af Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 3 Jul 2009 22:13:18 +0000 Subject: [PATCH] - Update to Android 1.5 SDK - Fix RouterContext problem --- android/AndroidManifest.xml | 2 + android/README.txt | 15 +- android/build.xml | 491 +++++++++++---------- android/default.properties | 11 + android/src/net/i2p/router/I2PAndroid.java | 11 +- 5 files changed, 290 insertions(+), 240 deletions(-) create mode 100644 android/default.properties diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index cb63a80c1..de77168d0 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -4,6 +4,8 @@ android:versionCode="1" android:versionName="1.0.0"> + + - - - - - - - + + - - - - - - + + - + - - - - - - + application-package + the name of your application package as defined in the manifest. Used by the + 'uninstall' rule. + source-folder + the name of the source folder. Default is 'src'. + out-folder + the name of the output folder. Default is 'bin'. - - - - + Properties related to the SDK location or the project target should be updated + using the 'android' tool with the 'update' action. - - - - - + This file is an integral part of the build system for your application and + should be checked in in Version Control Systems. - - + --> + - - - - - - + + - - - - - + + + + + + + + - - - - + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - Creating output directories if needed... - - - - - - - - - - - - - - - - - Generating R.java / Manifest.java from the resources... - - - - - - - - - - - - - - - - - Compiling aidl files into Java classes... - - - - - - - - - - - - - - - - - + - + @@ -168,7 +79,7 @@ - + @@ -190,7 +101,7 @@ --> - + @@ -199,104 +110,199 @@ - + - - - Converting compiled files and external libraries into ${outdir}/${dex-file}... - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creating output directories if needed... + + + + + + + + + + Generating R.java / Manifest.java from the resources... + + + + + + + + + + + + + + + + + Compiling aidl files into Java classes... + + + + + + + - - - Packaging resources and assets... - - - - - - - - - - - - - - + + + + + + + + + + + - - - Packaging resources... - - - - - - - - - - - - - + + + + Converting compiled files and external libraries into ${out-folder}/${dex-file}... + + + + + + + + - - - - - - + + + Packaging resources + - - Packaging ${out-debug-package}, and signing it with a debug key... - - - - - - - - - - - + This is the default target when building. It is used for debug. --> + + + + + + + - - Packaging ${out-unsigned-package} for release... - - - - - - - - - - - - - It will need to be signed with jarsigner before being published. + This allows for the application to be signed later with an official publishing key. --> + + + + + + + + All generated packages need to be signed with jarsigner before they are published. @@ -304,7 +310,7 @@ Installing ${out-debug-package} onto default emulator... - + @@ -313,7 +319,7 @@ - + @@ -322,8 +328,25 @@ Uninstalling ${application-package} from the default emulator... - + - + + + + Android Ant Build. Available targets: + help: Displays this help. + debug: Builds the application and sign it with a debug key. + release: Builds the application. The generated apk file must be + signed before it is published. + install: Installs the debug package onto a running emulator or + device. This can only be used if the application has + not yet been installed. + reinstall: Installs the debug package on a running emulator or + device that already has the application. + The signatures must match. + uninstall: uninstall the application from a running emulator or + device. + diff --git a/android/default.properties b/android/default.properties new file mode 100644 index 000000000..eba5c59ff --- /dev/null +++ b/android/default.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-2 diff --git a/android/src/net/i2p/router/I2PAndroid.java b/android/src/net/i2p/router/I2PAndroid.java index 18a6e149a..ed626639c 100644 --- a/android/src/net/i2p/router/I2PAndroid.java +++ b/android/src/net/i2p/router/I2PAndroid.java @@ -10,10 +10,10 @@ import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; +import java.util.List; import net.i2p.router.Router; import net.i2p.router.RouterLaunch; -import net.i2p.router.web.ContextHelper; // import net.i2p.util.NativeBigInteger; public class I2PAndroid extends Activity @@ -66,8 +66,15 @@ public class I2PAndroid extends Activity { System.err.println("onStop called"); super.onStop(); + + // from routerconsole ContextHelper + List contexts = RouterContext.listContexts(); + if ( (contexts == null) || (contexts.size() <= 0) ) + throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down."); + RouterContext ctx = (RouterContext)contexts.get(0); + // shutdown() doesn't return so use shutdownGracefully() - ContextHelper.getContext(null).router().shutdownGracefully(Router.EXIT_HARD); + ctx.router().shutdownGracefully(Router.EXIT_HARD); System.err.println("shutdown complete"); }