diff --git a/android/build.xml b/android/build.xml index 9b09ecee6e1407a5997261630afebf4231eaae72..4be56043ad44436064a2ead7734304bd19c33c55 100644 --- a/android/build.xml +++ b/android/build.xml @@ -129,6 +129,14 @@ <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> + </target> + <!-- install now does both --> <target name="reinstall" depends="install" /> @@ -138,6 +146,7 @@ <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}" /> </target> <!-- @@ -443,7 +452,7 @@ <!-- empty default pre-build target. Create a similar target in your build.xml and it'll be called instead of this one. --> <!-- I2P add depends --> - <target name="-pre-build" depends="copy-i2p-resources" /> + <target name="-pre-build" depends="copy-i2p-resources, incrementBuild" /> <!-- Generates the R.java file for this project's resources. --> <target name="-resource-src" depends="-dirs"> diff --git a/android/res/raw/router_config b/android/res/raw/router_config index ab95944842da7f96ef0bb2b8f5399f5b24c2e216..227cd06e1a42cede283a6c5a71d640a47193474b 100644 --- a/android/res/raw/router_config +++ b/android/res/raw/router_config @@ -7,9 +7,14 @@ 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 # ##### Transport # diff --git a/android/scripts/setversion.sh b/android/scripts/setversion.sh new file mode 100755 index 0000000000000000000000000000000000000000..4833d95ac75aabb5648144a4daaa5f0dc502e510 --- /dev/null +++ b/android/scripts/setversion.sh @@ -0,0 +1,57 @@ +# +# 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})" + +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/router/I2PAndroid.java b/android/src/net/i2p/router/I2PAndroid.java index f48c94efce11adff2347ce62380ad58f46c79f41..3c9c92bef36f1a7dcf673a3144f4aa1af9d80f06 100644 --- a/android/src/net/i2p/router/I2PAndroid.java +++ b/android/src/net/i2p/router/I2PAndroid.java @@ -2,6 +2,8 @@ package net.i2p.router; import android.app.Activity; 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.Bundle; @@ -103,6 +105,20 @@ public class I2PAndroid extends Activity System.err.println("user.home" + ": " + System.getProperty("user.home")); System.err.println("user.name" + ": " + System.getProperty("user.name")); System.err.println("getFilesDir()" + ": " + DIR); + System.err.println("Package" + ": " + getPackageName()); + System.err.println("Version" + ": " + getOurVersion()); + } + + private String getOurVersion() { + PackageManager pm = getPackageManager(); + String us = 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 "??"; } private void initialize() {