diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml deleted file mode 100644 index b95b5ba16ff8b8f25cb2bf0236a6d46f896761b5..0000000000000000000000000000000000000000 --- a/android/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="net.i2p.android.router" - android.versionCode="0" - android.versionName="0.0.0" - android:installLocation="preferExternal" - > - <uses-permission android:name="android.permission.INTERNET" /> - - <!-- 3 = 1.5, 2 = 1.1, 1 = 1.0; would probably work with 1 but don't have a 1.0 SDK to test against --> - <!-- 3 required for NDK --> - <uses-sdk android:minSdkVersion="3" /> - - <application android:label="@string/app_name" - android:icon="@drawable/ic_launcher_itoopie" > - <service android:name=".service.RouterService" - android:label="@string/app_name" - android:icon="@drawable/ic_launcher_itoopie" /> - <activity android:name=".activity.MainActivity" - android:label="@string/app_name" - android:icon="@drawable/ic_launcher_itoopie" - android:launchMode="singleTask" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> -</manifest> diff --git a/android/README.txt b/android/README.txt deleted file mode 100644 index ff5b1f2d6fd57ef4965e3662b46f078853522410..0000000000000000000000000000000000000000 --- a/android/README.txt +++ /dev/null @@ -1,58 +0,0 @@ -These instructions are for a recent Android SDK (1.6 or later).. -Should also still work with a 1.5 SDK. -The build file is not compatible with the 1.1 SDK any more. -These instructions were last updated for SDK Tools Version 11 with -SDK Platform-tools Version 5, June 2011. - -#Download the SDK from http://developer.android.com/sdk/index.html -#Unzip the android SDK in ../../ -#So then the android tools will be in ../../android-sdk-linux_86/tools/ -# -# Run the GUI updater, which you must do to get an SDK Platform: -../../android-sdk-linux_86/tools/android & - -# now go to the available packages tab, check the box and click refresh, -# and download an SDK Platform -# Since I2P is configured to run on 1.1 or higher -# (API 2) download that one. Otherwise you must change the -# target in default.properties from android-2 to andriod-x -# where x is the API version. - -# To run the debugger (ddms) you also need to download the -# "Android SDK Platform-Tools" package from the GUI updater. - -# create a file local.properties with the following line (without the leading # of course): -# sdk.dir=/path/to/your/android-sdk-linux_86 -# The old property was sdk-location=/path/to/your/android-sdk-linux_86 -# but it changed in more recent tools. - -# DO NOT create a new project or anything. It's all set up right here for you. - -# Create the android 1.5 (API 3) virtual device -# (don't make a custom hardware profile) -# A AVD created with the 1.5 SDK will not work with the newer tools -../../android-sdk-linux_86/tools/android create avd --name i2p --target 3 - -#then run the emulator: -../../android-sdk-linux_86/tools/emulator -avd i2p & - -# or to talk to a real phone in debug mode: -adb kill-server -sudo adb start-server -adb devices - -#then wait a couple minutes until the emulator is up -#then install the I2P app -ant install - -#then run the debugger -../../android-sdk-linux_86/tools/ddms & - -#to rebuild and reinstall to emulator or phone: -ant reinstall - -# Now click on the I2P icon on your phone! - -#other helpful commands -../../android-sdk-linux_86/platform-tools/adb shell -../../android-sdk-linux_86/platform-tools/adb pull /some/file/on/emulator some-local-dir/ diff --git a/android/build.properties b/android/build.properties deleted file mode 100644 index 181724115d6453de5705a4d1fd7f7f682a345281..0000000000000000000000000000000000000000 --- a/android/build.properties +++ /dev/null @@ -1 +0,0 @@ -application-package=net.i2p.router diff --git a/android/build.xml b/android/build.xml deleted file mode 100644 index 37b241ea8081c3b5e717a41fca062792b9a2fcef..0000000000000000000000000000000000000000 --- a/android/build.xml +++ /dev/null @@ -1,210 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - - Portions copied and modified from Android SDK - - Copyright (c) 2005-2008, The Android Open Source Project - - Apache 2.0 license - - See ../licenses/LICENSE-Apache2.0.txt - --> - -<project name="I2PAndroid" default="help"> - - <!-- The local.properties file is created and updated by the 'android' tool. - It contain the path to the SDK. It should *NOT* be checked in in Version - Control Systems. --> - <property file="local.properties"/> - - <!-- The build.properties file can be created by you and is never touched - by the 'android' tool. This is the place to change some of the default property values - used by the Ant rules. - Here are some properties you may want to change/update: - - 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. - - --> - <property file="build.properties"/> - <!-- set the old name to the new name --> - <property name="sdk-location" value="${sdk.dir}" /> - - <!-- The default.properties file is created and updated by the 'android' tool, as well - as ADT. - This file is an integral part of the build system for your application and - should be checked in in Version Control Systems. --> - <property file="default.properties"/> - - <!-- Custom Android task to deal with the project target, and import the proper rules. - This requires ant 1.6.0 or above. --> - <path id="android.antlibs"> - <pathelement path="${sdk-location}/tools/lib/anttasks.jar" /> - <pathelement path="${sdk-location}/tools/lib/sdklib.jar" /> - <pathelement path="${sdk-location}/tools/lib/androidprefs.jar" /> - <pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" /> - <pathelement path="${sdk-location}/tools/lib/jarutils.jar" /> - </path> - - <taskdef name="setup" - classname="com.android.ant.SetupTask" - classpathref="android.antlibs"/> - - <!-- Execute the Android Setup task that will setup some properties specific to the target, - and import the rules files. - To customize the rules, copy/paste them below the task, and disable import by setting - the import attribute to false: - <setup import="false" /> - - This will ensure that the properties are setup correctly but that your customized - targets are used. - --> - <setup import="true" /> - - <echo>Ignore warning about SDK version</echo> - <!-- - ================================================================================ - New I2P rules - ================================================================================ - --> - - <!-- overrides of those in main_rules.xml --> - - <target name="-pre-build" depends="copy-i2p-resources, incrementBuild" /> - - <target name="-pre-compile" depends="buildrouter" /> - - <target name="-post-compile" depends="hackcleanup, jbigi" /> - - <!-- new rules --> - - <target name="buildrouter" depends="-dirs" > - <!-- build router and core --> - <ant dir=".." target="buildrouter" /> - - <!-- router --> - <copy file="../build/router.jar" todir="${jar.libs.dir}" /> - - <!-- core --> - - <!-- org.bouncycastle.crypto already in android - but we need a little trickery because our HMac is incompatible... - and the libs aren't in the SDK to compile against??? --> - <jar destfile="${jar.libs.dir}/crypto.jar" > - <zipfileset src="../build/i2p.jar" > - <include name="org/bouncycastle/crypto/Digest.class" /> - <include name="org/bouncycastle/crypto/Mac.class" /> - <include name="org/bouncycastle/crypto/digests/GeneralDigest.class" /> - <include name="org/bouncycastle/crypto/digests/MD5Digest.class" /> - </zipfileset > - </jar> - - <!-- lots of unneeded stuff could be deleted here --> - <jar destfile="${jar.libs.dir}/i2p.jar" > - <zipfileset src="../build/i2p.jar" > - <exclude name="net/i2p/util/LogWriter.class" /> - <exclude name="net/i2p/util/SecureDirectory.class" /> - <exclude name="net/i2p/util/SecureFile.class" /> - <exclude name="net/i2p/util/SecureFileOutputStream.class" /> - <exclude name="org/bouncycastle/crypto/Digest.class" /> - <exclude name="org/bouncycastle/crypto/Mac.class" /> - <exclude name="org/bouncycastle/crypto/digests/GeneralDigest.class" /> - <exclude name="org/bouncycastle/crypto/digests/MD5Digest.class" /> - </zipfileset > - </jar> - </target> - - <!-- some resources --> - <target name="copy-i2p-resources" depends="-dirs" > - <copy file="../installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" /> - <copy file="../installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" /> - </target> - - <target name="hackcleanup"> - <delete file="${jar.libs.dir}/crypto.jar" /> - </target> - - <target name="jbigi"> - <exec executable="sh" osfamily="unix" failonerror="true"> - <arg value="-c" /> - <arg value="jni/build.sh" /> - </exec> - <copy file="jni/libjbigi.so" todir="${native.libs.dir}/armeabi" /> - </target> - - <target name="incrementBuild"> - <buildnumber file="scripts/build.number" /> - <exec executable="sh" osfamily="unix" failonerror="true"> - <arg value="-c" /> - <arg value="scripts/setversion.sh" /> - </exec> - <!-- this loads my.version.code and my.version.name --> - <property file="scripts/version.properties" /> - </target> - - <!-- install now does both --> - <target name="reinstall" depends="install" /> - - <target name="distclean" depends="clean"> - <delete dir="${jar.libs.dir}" verbose="${verbose}" /> - <delete file="res/drawable/i2plogo.png" verbose="${verbose}"/> - <delete file="res/raw/blocklist_txt" verbose="${verbose}" /> - <delete dir="jni/build/" verbose="${verbose}" /> - <delete file="jni/libjbigi.so" verbose="${verbose}" /> - <delete file="scripts/build.number" verbose="${verbose}" /> - <delete file="scripts/version.properties" verbose="${verbose}" /> - </target> - - <!-- - ================================================================================ - From here down copied from SDK tools/ant/main_rules.xml from Tools version 11 - and then modified - ================================================================================ - --> - - <!-- not necessary to copy if setup import="true" --> - - - <!-- - override this because the ant task com.android.ant.AaptExecLoopTask has issues: - a) it uses version.code which main_rules sets to "" and - b) it can't set versionName via the aapt task, have to use the aapt command line - --> - - <!-- Puts the project's resources into the output package file - This actually can create multiple resource package in case - Some custom apk with specific configuration have been - declared in default.properties. - --> - <target name="-package-resources"> - <echo>Packaging resources</echo> - <exec executable="${aapt}" failonerror="true" > - <arg value="package" /> - <arg value="--version-code" /> - <arg value="${my.version.code}" /> - <arg value="--version-name" /> - <arg value="${my.version.name}" /> - <arg value="-f" /> - <arg value="-m" /> - <arg value="-M" /> - <arg value="AndroidManifest.xml" /> - <arg value="-I" /> - <arg value="${android.jar}" /> - <arg value="-S" /> - <arg value="${resource.absolute.dir}" /> - <arg value="-J" /> - <arg value="${gen.absolute.dir}" /> - <arg value="-F" /> - <arg value="${out.absolute.dir}/${resource.package.file.name}" /> - </exec> - </target> - -</project> diff --git a/android/default.properties b/android/default.properties deleted file mode 100644 index 0b9250e021cfaac0bcbf8575a75aab1ec81008f8..0000000000000000000000000000000000000000 --- a/android/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# 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-8 diff --git a/android/jni/build.sh b/android/jni/build.sh deleted file mode 100755 index af5d17220ef7ae0abfc3fabee6898e5d31cb0683..0000000000000000000000000000000000000000 --- a/android/jni/build.sh +++ /dev/null @@ -1,83 +0,0 @@ -# -# build GMP and libjbigi.so using the Android tools directly -# - -# uncomment to skip -# exit 0 - -THISDIR=$(realpath $(dirname $(which $0))) -cd $THISDIR -export NDK=$(realpath ../../../android-ndk-r5b/) - -# -# API level, must match that in ../AndroidManifest.xml -# -LEVEL=3 -ARCH=arm -export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/ -export AABI=arm-linux-androideabi-4.4.3 -export SYSTEM=linux-x86 -export BINPREFIX=arm-linux-androideabi- -export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT" - -#echo "CC is $CC" - -JBIGI=$(realpath ../../core/c/jbigi) -GMPVER=4.3.2 -GMP=$JBIGI/gmp-$GMPVER - -if [ ! -d $GMP ] -then - echo "Source dir for GMP version $GMPVER not found in $GMP" - echo "Install it there or change GMPVER and/or GMP in this script" - exit 1 -fi - -LIBFILE=$PWD/libjbigi.so -if [ -f $LIBFILE ] -then - echo "$LIBFILE exists, nothing to do here" - echo "If you wish to force a recompile, delete it" - exit 0 -fi - -mkdir -p build -cd build - -# we must set both build and host, so that the configure -# script will set cross_compile=yes, so that it -# won't attempt to run the a.out files -if [ ! -f config.status ] -then - echo "Configuring GMP..." - $GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1 -fi - -echo "Building GMP..." -make || exit 1 - -export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac)))) -if [ ! -f "$JAVA_HOME/include/jni.h" ]; then - echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'" - echo "Please set JAVA_HOME to a java home that has the JNI" - exit 1 -fi - -COMPILEFLAGS="-fPIC -Wall" -INCLUDES="-I. -I$JBIGI/jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux" -LINKFLAGS="-shared -Wl,-soname,libjbigi.so,--fix-cortex-a8" - -echo "Building jbigi lib that is statically linked to GMP" -STATICLIBS=".libs/libgmp.a" - -echo "Compiling C code..." -rm -f jbigi.o $LIBFILE -echo "$CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c" -$CC -c $COMPILEFLAGS $INCLUDES $JBIGI/jbigi/src/jbigi.c || exit 1 -echo "$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS" -$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS || exit 1 - -ls -l $LIBFILE || exit 1 - - -echo 'Built successfully' diff --git a/android/res/drawable/ic_launcher_itoopie.png b/android/res/drawable/ic_launcher_itoopie.png deleted file mode 100644 index acb8a2bb8e7ef8e67c808dc766a751990f6ddc1f..0000000000000000000000000000000000000000 Binary files a/android/res/drawable/ic_launcher_itoopie.png and /dev/null differ diff --git a/android/res/layout/main.xml b/android/res/layout/main.xml deleted file mode 100644 index d764115276c1b6c135b8093a48d4adcb1ee4d67d..0000000000000000000000000000000000000000 --- a/android/res/layout/main.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - > -<TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Hello World, I2PAndroid" - /> -<ImageView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:src="@drawable/i2plogo" - /> -</LinearLayout> - diff --git a/android/res/raw/logger_config b/android/res/raw/logger_config deleted file mode 100644 index 86651d8807093bf38f118a7f83b4fa8b746e5404..0000000000000000000000000000000000000000 --- a/android/res/raw/logger_config +++ /dev/null @@ -1,8 +0,0 @@ -logger.defaultLevel=INFO -logger.record.net.i2p.router.peerManager.ProfileOrganizer=WARN -logger.record.net.i2p.router.transport=WARN -logger.record.net.i2p.router.transport.FIFOBandwidthRefiller=ERROR -logger.record.net.i2p.stat.Rate=ERROR -logger.record.net.i2p.util.LogManager=WARN -logger.record.net.i2p.util.LogWriter=WARN -logger.record.net.i2p.util.NativeBigInteger=DEBUG diff --git a/android/res/raw/router_config b/android/res/raw/router_config deleted file mode 100644 index 5fa8dcc1013a45fd8d0513f20e101041676a1b3e..0000000000000000000000000000000000000000 --- a/android/res/raw/router_config +++ /dev/null @@ -1,52 +0,0 @@ -# initial router.config -# temp directory -i2p.dir.temp=/data/data/net.i2p.router/files/tmp -i2p.dir.pid=/data/data/net.i2p.router/files/tmp -# save memory -prng.buffers=2 -router.decayingBloomFilterM=20 -stat.full=false -# -# Don't run NTP client, the phone should have a valid time -# -time.disabled=true -# -# no I2CP -# -i2p.dummyClientFacade=true -i2cp.disableInterface=true -# -##### Tunnels -# -router.inboundPool.backupQuantity=0 -router.inboundPool.length=2 -router.inboundPool.lengthVariance=0 -router.inboundPool.quantity=2 -router.outboundPool.backupQuantity=0 -router.outboundPool.length=2 -router.outboundPool.lengthVariance=0 -router.outboundPool.quantity=2 -router.maxParticipatingTunnels=0 -router.sharePercentage=10 -# -##### Transport -# -i2np.bandwidth.inboundKBytesPerSecond=100 -i2np.bandwidth.outboundKBytesPerSecond=30 -# -# NTCP -# -#i2np.ntcp.enable=false -i2np.ntcp.maxConnections=12 -# -# UDP disabled for now -# -i2np.udp.enable=false -i2np.udp.maxConnections=12 -# -# no COMM at all!!! -#i2p.vmCommSystem=true -# -# not on android -i2np.upnp.enable=false -routerconsole.geoip.enable=false diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml deleted file mode 100644 index d1ab96508e6091b8634eb9c74ce5dc8d58ab8692..0000000000000000000000000000000000000000 --- a/android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="app_name">I2P</string> -</resources> diff --git a/android/scripts/setversion.sh b/android/scripts/setversion.sh deleted file mode 100755 index bf4e6b9d817530257f87b10a9de73d65300ae3a8..0000000000000000000000000000000000000000 --- a/android/scripts/setversion.sh +++ /dev/null @@ -1,59 +0,0 @@ -# -# Get the version number and fix up AndroidManifest.xml -# Public domain -# -THISDIR=$(realpath $(dirname $(which $0))) -cd $THISDIR -MANIFEST=../AndroidManifest.xml -TMP=AndroidManifest.xml.tmp - -CORE=`grep 'public final static String VERSION' ../../core/java/src/net/i2p/CoreVersion.java | \ - cut -d '"' -f 2` - -MAJOR=`echo $CORE | cut -d '.' -f 1` -MINOR=`echo $CORE | cut -d '.' -f 2` -RELEASE=`echo $CORE | cut -d '.' -f 3` - -ROUTERBUILD=$((`grep 'public final static long BUILD' ../../router/java/src/net/i2p/router/RouterVersion.java | \ - cut -d '=' -f 2 | \ - cut -d ';' -f 1`)) - -ANDROIDBUILD=`grep 'build.number' build.number | \ - cut -d '=' -f 2` - -SDK=`grep 'android:minSdkVersion' $MANIFEST | \ - cut -d '"' -f 2` - -# don't let build number get too long -VERSIONSTRING="${CORE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 256))-SDK$SDK" - -# -# Android version code is an integer. -# So we have 31 bits. -# MAJOR 4 bits 0-15 -# MINOR 8 bits 0-255 -# RELEASE 8 bits 0-255 -# ROUTERBUILD 8 bits 0-255 -# ANDROIDBUILD 3 bits 0-7 -# -# Note that ANDROIDBUILD is modded % 8, it will wrap, -# beware of that if you release multiple builds using the -# same ROUTERBUILD, or clear it if you update ROUTERBUILD -# -VERSIONINT=$(( \ - (($MAJOR % 16) << 27) + \ - (($MINOR % 256) << 19) + \ - (($RELEASE % 256) << 11) + \ - (($ROUTERBUILD % 256) << 3) + \ - ($ANDROIDBUILD % 8) \ - )) - -echo "Android version: '$VERSIONSTRING' (${VERSIONINT})" -echo "my.version.name=${VERSIONSTRING}" > version.properties -echo "my.version.code=${VERSIONINT}" >> version.properties - -SUBST='s/android.versionCode="[0-9]"/android.versionCode="'${VERSIONINT}'"/' -sed "$SUBST" < $MANIFEST > $TMP -SUBST='s/android.versionName="[^"]*"/android.versionName="'${VERSIONSTRING}'"/' -sed "$SUBST" < $TMP > $MANIFEST -rm -f $TMP diff --git a/android/src/net/i2p/android/router/activity/I2PActivityBase.java b/android/src/net/i2p/android/router/activity/I2PActivityBase.java deleted file mode 100644 index 180f289abe10b8b08edf4c51f1026bc35f3e1b56..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/android/router/activity/I2PActivityBase.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.i2p.android.router.activity; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Intent; -import android.os.Bundle; - -public abstract class I2PActivityBase extends Activity { - protected String _myDir; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - _myDir = getFilesDir().getAbsolutePath(); - } - - @Override - public void onRestart() - { - System.err.println(this + " onRestart called"); - super.onRestart(); - } - - @Override - public void onStart() - { - System.err.println(this + " onStart called"); - super.onStart(); - Intent intent = new Intent(); - intent.setClassName(this, "net.i2p.android.router.service.RouterService"); - System.err.println(this + " calling startService"); - ComponentName name = startService(intent); - System.err.println(this + " got from startService: " + name); - } - - @Override - public void onResume() - { - System.err.println(this + " onResume called"); - super.onResume(); - } - - @Override - public void onPause() - { - System.err.println(this + " onPause called"); - super.onPause(); - } - - @Override - public void onStop() - { - System.err.println(this + " onStop called"); - super.onStop(); - } - - @Override - public void onDestroy() - { - System.err.println(this + "onDestroy called"); - super.onDestroy(); - } -} diff --git a/android/src/net/i2p/android/router/activity/MainActivity.java b/android/src/net/i2p/android/router/activity/MainActivity.java deleted file mode 100644 index d16d49635062699817c05d38876f949df9b30145..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/android/router/activity/MainActivity.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.i2p.android.router.activity; - -import android.os.Bundle; - -import net.i2p.android.router.R; - -public class MainActivity extends I2PActivityBase { - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - } -} diff --git a/android/src/net/i2p/android/router/service/Init.java b/android/src/net/i2p/android/router/service/Init.java deleted file mode 100644 index 8928385e3d0f8eb4d53ee027b8e6e4817c886b04..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/android/router/service/Init.java +++ /dev/null @@ -1,134 +0,0 @@ -package net.i2p.android.router.service; - -import android.content.Context; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.content.res.Resources.NotFoundException; -import android.os.Build; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; - -import net.i2p.android.router.R; -import net.i2p.data.DataHelper; -import net.i2p.router.Router; -import net.i2p.router.RouterContext; -import net.i2p.router.RouterLaunch; -import net.i2p.util.OrderedProperties; -import net.i2p.util.NativeBigInteger; - -class Init { - - private final Context ctx; - private final String myDir; - - public Init(Context c) { - ctx = c; - myDir = c.getFilesDir().getAbsolutePath(); - } - - void debugStuff() { - System.err.println("java.io.tmpdir" + ": " + System.getProperty("java.io.tmpdir")); - System.err.println("java.vendor" + ": " + System.getProperty("java.vendor")); - System.err.println("java.version" + ": " + System.getProperty("java.version")); - System.err.println("os.arch" + ": " + System.getProperty("os.arch")); - System.err.println("os.name" + ": " + System.getProperty("os.name")); - System.err.println("os.version" + ": " + System.getProperty("os.version")); - System.err.println("user.dir" + ": " + System.getProperty("user.dir")); - System.err.println("user.home" + ": " + System.getProperty("user.home")); - System.err.println("user.name" + ": " + System.getProperty("user.name")); - System.err.println("getFilesDir()" + ": " + myDir); - System.err.println("Package" + ": " + ctx.getPackageName()); - System.err.println("Version" + ": " + getOurVersion()); - System.err.println("MODEL" + ": " + Build.MODEL); - System.err.println("DISPLAY" + ": " + Build.DISPLAY); - System.err.println("VERSION" + ": " + Build.VERSION.RELEASE); - System.err.println("SDK" + ": " + Build.VERSION.SDK); - } - - private String getOurVersion() { - PackageManager pm = ctx.getPackageManager(); - String us = ctx.getPackageName(); - try { - PackageInfo pi = pm.getPackageInfo(us, 0); - System.err.println("VersionCode" + ": " + pi.versionCode); - if (pi.versionName != null) - return pi.versionName; - } catch (Exception e) {} - return "??"; - } - - void initialize() { - mergeResourceToFile(R.raw.router_config, "router.config"); - mergeResourceToFile(R.raw.logger_config, "logger.config"); - copyResourceToFile(R.raw.blocklist_txt, "blocklist.txt"); - - // Set up the locations so Router and WorkingDir can find them - System.setProperty("i2p.dir.base", myDir); - System.setProperty("i2p.dir.config", myDir); - System.setProperty("wrapper.logfile", myDir + "/wrapper.log"); - } - - private void copyResourceToFile(int resID, String f) { - InputStream in = null; - FileOutputStream out = null; - - System.err.println("Creating file " + f + " from resource"); - byte buf[] = new byte[4096]; - try { - // Context methods - in = ctx.getResources().openRawResource(resID); - out = ctx.openFileOutput(f, 0); - - int read = 0; - while ( (read = in.read(buf)) != -1) - out.write(buf, 0, read); - - } catch (IOException ioe) { - } catch (Resources.NotFoundException nfe) { - } finally { - if (in != null) try { in.close(); } catch (IOException ioe) {} - if (out != null) try { out.close(); } catch (IOException ioe) {} - } - } - - /** - * Load defaults from resource, - * then add props from file, - * and write back - */ - private void mergeResourceToFile(int resID, String f) { - InputStream in = null; - InputStream fin = null; - - byte buf[] = new byte[4096]; - try { - Properties props = new OrderedProperties(); - in = ctx.getResources().openRawResource(resID); - DataHelper.loadProps(props, in); - - try { - fin = ctx.openFileInput(f); - DataHelper.loadProps(props, fin); - System.err.println("Merging resource into file " + f); - } catch (IOException ioe) { - System.err.println("Creating file " + f + " from resource"); - } finally { - if (fin != null) try { fin.close(); } catch (IOException ioe) {} - } - - DataHelper.storeProps(props, ctx.getFileStreamPath(f)); - } catch (IOException ioe) { - } catch (Resources.NotFoundException nfe) { - } finally { - if (in != null) try { in.close(); } catch (IOException ioe) {} - if (fin != null) try { fin.close(); } catch (IOException ioe) {} - } - } - -} diff --git a/android/src/net/i2p/android/router/service/RouterService.java b/android/src/net/i2p/android/router/service/RouterService.java deleted file mode 100644 index 50d7cf644a268deb4b9283602199cdad11c4fc10..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/android/router/service/RouterService.java +++ /dev/null @@ -1,137 +0,0 @@ -package net.i2p.android.router.service; - -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.IBinder; - -import java.util.List; - -import net.i2p.android.router.R; -import net.i2p.router.Router; -import net.i2p.router.RouterContext; -import net.i2p.router.RouterLaunch; -import net.i2p.util.NativeBigInteger; - -/** - * Runs the router - */ -public class RouterService extends Service { - private RouterContext _context; - private String _myDir; - private int _state; - private Thread _starterThread; - private StatusBar _statusBar; - private final Object _stateLock = new Object(); - - private static final int STATE_INIT = 0; - private static final int STATE_STARTING = 1; - private static final int STATE_RUNNING = 2; - private static final int STATE_STOPPING = 3; - private static final int STATE_STOPPED = 4; - - private static final String MARKER = "************************************** "; - - @Override - public void onCreate() { - System.err.println(this + " onCreate called" + - " Current state is: " + _state); - - _myDir = getFilesDir().getAbsolutePath(); - Init init = new Init(this); - init.debugStuff(); - init.initialize(); - _statusBar = new StatusBar(this); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - System.err.println(this + " onStart called" + - "Current state is: " + _state); - synchronized (_stateLock) { - if (_state != STATE_INIT) - return START_STICKY; - _statusBar.update("I2P is starting up"); - _state = STATE_STARTING; - _starterThread = new Thread(new Starter()); - _starterThread.start(); - } - return START_STICKY; - } - - private class Starter implements Runnable { - public void run() { - System.err.println(MARKER + this + " starter thread"); - NativeBigInteger.main(null); - RouterLaunch.main(null); - synchronized (_stateLock) { - if (_state != STATE_STARTING) - return; - _state = STATE_RUNNING; - List contexts = RouterContext.listContexts(); - if ( (contexts == null) || (contexts.isEmpty()) ) - throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down."); - _statusBar.update("I2P is running"); - _context = (RouterContext)contexts.get(0); - _context.router().setKillVMOnEnd(false); - _context.addShutdownTask(new ShutdownHook()); - _starterThread = null; - } - System.err.println("Router.main finished"); - } - } - - @Override - public IBinder onBind(Intent intent) - { - System.err.println("onBind called" + - "Current state is: " + _state); - return null; - } - - @Override - public void onDestroy() { - System.err.println("onDestroy called" + - "Current state is: " + _state); - synchronized (_stateLock) { - if (_state == STATE_STARTING) - _starterThread.interrupt(); - if (_state == STATE_STARTING || _state == STATE_RUNNING) { - _state = STATE_STOPPING; - // should this be in a thread? - _statusBar.update("I2P is stopping"); - Thread stopperThread = new Thread(new Stopper()); - stopperThread.start(); - } else if (_state != STATE_STOPPING) { - _statusBar.off(this); - } - } - } - - private class Stopper implements Runnable { - public void run() { - System.err.println(MARKER + this + " stopper thread"); - _context.router().shutdown(Router.EXIT_HARD); - _statusBar.off(RouterService.this); - System.err.println("shutdown complete"); - synchronized (_stateLock) { - _state = STATE_STOPPED; - } - } - } - - private class ShutdownHook implements Runnable { - public void run() { - System.err.println(this + " shutdown hook" + - "Current state is: " + _state); - synchronized (_stateLock) { - if (_state == STATE_STARTING || _state == STATE_RUNNING) { - _state = STATE_STOPPED; - _statusBar.off(RouterService.this); - stopSelf(); - } - } - } - } -} diff --git a/android/src/net/i2p/android/router/service/StatusBar.java b/android/src/net/i2p/android/router/service/StatusBar.java deleted file mode 100644 index 08b473fd696324316e0a0b3b3844983090992d67..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/android/router/service/StatusBar.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.i2p.android.router.service; - -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; - -import net.i2p.android.router.R; -import net.i2p.android.router.activity.MainActivity; - -public class StatusBar { - - private final Context ctx; - private final Intent intent; - private final Notification notif; - private final NotificationManager mgr; - - private static final int ID = 1; - - StatusBar(Context cx) { - ctx = cx; - String ns = Context.NOTIFICATION_SERVICE; - mgr = (NotificationManager)ctx.getSystemService(ns); - - int icon = R.drawable.ic_launcher_itoopie; - String text = "Starting I2P"; - long now = System.currentTimeMillis(); - notif = new Notification(icon, text, now); - notif.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR; - intent = new Intent(ctx, MainActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } - - public void update(String details) { - String title = "I2P Status"; - PendingIntent pi = PendingIntent.getActivity(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); - notif.setLatestEventInfo(ctx, title, details, pi); - mgr.notify(ID, notif); - } - - public void off(Context ctx) { - mgr.cancel(ID); - } -} diff --git a/android/src/net/i2p/util/LogWriter.java b/android/src/net/i2p/util/LogWriter.java deleted file mode 100644 index 18ba54c8ed3f7f5a1b1b6d1bb507fa5db8171859..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/util/LogWriter.java +++ /dev/null @@ -1,174 +0,0 @@ -package net.i2p.util; - -/* - * public domain - * - */ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; -import java.util.Queue; - -/** - * bridge to android logging - * - * @author zzz - */ -class LogWriter implements Runnable { - private final static long CONFIG_READ_ITERVAL = 10 * 1000; - private long _lastReadConfig = 0; - private long _numBytesInCurrentFile = 0; - private OutputStream _currentOut; // = System.out - private int _rotationNum = -1; - private String _logFilenamePattern; - private File _currentFile; - private LogManager _manager; - - private boolean _write; - - private LogWriter() { // nop - } - - public LogWriter(LogManager manager) { - _manager = manager; - } - - public void stopWriting() { - _write = false; - } - - public void run() { - _write = true; - try { - while (_write) { - flushRecords(); - rereadConfig(); - } - System.err.println("Done writing"); - } catch (Exception e) { - System.err.println("Error writing the logs: " + e.getMessage()); - e.printStackTrace(); - } - } - - public void flushRecords() { flushRecords(true); } - public void flushRecords(boolean shouldWait) { - try { - // zero copy, drain the manager queue directly - Queue<LogRecord> records = _manager.getQueue(); - if (records == null) return; - 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(); - } finally { - if (shouldWait) { - try { - synchronized (this) { - this.wait(10*1000); - } - } catch (InterruptedException ie) { // nop - } - } - } - } - - public String currentFile() { - return _currentFile != null ? _currentFile.getAbsolutePath() : "uninitialized"; - } - - private void rereadConfig() { - long now = Clock.getInstance().now(); - if (now - _lastReadConfig > CONFIG_READ_ITERVAL) { - _manager.rereadConfig(); - _lastReadConfig = now; - } - } - - private void writeRecord(LogRecord rec) { - if (rec.getThrowable() == null) - log(rec.getPriority(), rec.getSource(), rec.getSourceName(), rec.getThreadName(), rec.getMessage()); - else - log(rec.getPriority(), rec.getSource(), rec.getSourceName(), rec.getThreadName(), rec.getMessage(), rec.getThrowable()); - } - - public void log(int priority, Class src, String name, String threadName, String msg) { - if (src != null) { - String tag = src.getName(); - int dot = tag.lastIndexOf("."); - if (dot >= 0) - tag = tag.substring(dot + 1); - android.util.Log.println(toAndroidLevel(priority), - tag, - '[' + threadName + "] " + msg); - } else if (name != null) - android.util.Log.println(toAndroidLevel(priority), - name, - '[' + threadName + "] " + msg); - else - android.util.Log.println(toAndroidLevel(priority), - threadName, msg); - } - - public void log(int priority, Class src, String name, String threadName, String msg, Throwable t) { - if (src != null) { - String tag = src.getName(); - int dot = tag.lastIndexOf("."); - if (dot >= 0) - tag = tag.substring(dot + 1); - android.util.Log.println(toAndroidLevel(priority), - tag, - '[' + threadName + "] " + msg + - ' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t)); - } else if (name != null) - android.util.Log.println(toAndroidLevel(priority), - name, - '[' + threadName + "] " + msg + - ' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t)); - else - android.util.Log.println(toAndroidLevel(priority), - threadName, - msg + ' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t)); - } - - private static int toAndroidLevel(int level) { - switch (level) { - case Log.DEBUG: - return android.util.Log.DEBUG; - case Log.INFO: - return android.util.Log.INFO; - case Log.WARN: - return android.util.Log.WARN; - case Log.ERROR: - case Log.CRIT: - default: - return android.util.Log.ERROR; - } - } - - private static final String replace(String pattern, int num) { - char c[] = pattern.toCharArray(); - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < c.length; i++) { - if ( (c[i] != '#') && (c[i] != '@') ) - buf.append(c[i]); - else - buf.append(num); - } - return buf.toString(); - } -} diff --git a/android/src/net/i2p/util/SecureDirectory.java b/android/src/net/i2p/util/SecureDirectory.java deleted file mode 100644 index 0c34c91c054caf237279f2d3099a758cfca03c67..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/util/SecureDirectory.java +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index e9362ef946873f6f6875eb0677611a90bd38ef52..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/util/SecureFile.java +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index e45798cf988741fb430fae2f5cf334d4989354b6..0000000000000000000000000000000000000000 --- a/android/src/net/i2p/util/SecureFileOutputStream.java +++ /dev/null @@ -1,53 +0,0 @@ -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) { - } -}