Changeset 173343e


Ignore:
Timestamp:
Jun 4, 2011 12:29:02 AM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
885d549
Parents:
c3bcb8d
Message:

Android:

  • More efficient build of i2p.jar and crypto.jar
  • More build fixes
  • Merge package configuration resource with configuration file on device if it exists
  • Add launcher icon, resized from installer/resources/eepsite.help/help/lib/itoopie.png
  • Start of a libjbigi build script
  • Increase min API to 3 so we can use JNI
Location:
android
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • android/AndroidManifest.xml

    rc3bcb8d r173343e  
    66    <uses-permission android:name="android.permission.INTERNET" />
    77    <!-- 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 -->
    8     <uses-sdk android:minSdkVersion="2" />
     8    <!-- 3 required for NDK -->
     9    <uses-sdk android:minSdkVersion="3" />
    910    <application android:label="@string/app_name">
    1011        <activity android:name="I2PAndroid"
    1112                  android:label="@string/app_name"
     13                  android:icon="@drawable/ic_launcher_itoopie"
    1214                  android:launchMode="singleTask" >
    1315            <intent-filter>
  • android/README.txt

    rc3bcb8d r173343e  
    2929# DO NOT create a new project or anything. It's all set up right here for you.
    3030
    31 # Create the android 1.1 (API 2) virtual device
     31# Create the android 1.5 (API 3) virtual device
    3232# (don't make a custom hardware profile)
    3333# A AVD created with the 1.5 SDK will not work with the newer tools
    34 ../../android-sdk-linux_86/tools/android create avd --name i2p --target 2
     34../../android-sdk-linux_86/tools/android create avd --name i2p --target 3
    3535
    3636#then run the emulator:
     
    3838
    3939#then wait a couple minutes until the emulator is up
    40 #then install the I2P app (ONE TIME ONLY)
     40#then install the I2P app
    4141ant install
    4242
     
    4848
    4949# Now click on the I2P icon on your phone!
     50
     51#other helpful commands
     52../../android-sdk-linux_86/tools/adb shell
  • android/build.xml

    rc3bcb8d r173343e  
    8484
    8585        <!-- core -->
    86         <mkdir dir="tmp" />
    87         <unjar src="../build/i2p.jar" dest="tmp/" />
    88         <delete file="tmp/net/i2p/util/LogWriter.class" />
    89         <delete file="tmp/net/i2p/util/SecureDirectory.class" />
    90         <delete file="tmp/net/i2p/util/SecureFile.class" />
    91         <delete file="tmp/net/i2p/util/SecureFileOutputStream.class" />
     86
    9287        <!-- org.bouncycastle.crypto already in android
    9388             but we need a little trickery because our HMac is incompatible...
    9489             and the libs aren't in the SDK to compile against??? -->
    9590        <jar destfile="${jar.libs.dir}/crypto.jar" >
    96             <fileset dir="tmp/" >
     91            <zipfileset src="../build/i2p.jar" >
    9792                <include name="org/bouncycastle/crypto/Digest.class" />
    9893                <include name="org/bouncycastle/crypto/Mac.class" />
    9994                <include name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
    10095                <include name="org/bouncycastle/crypto/digests/MD5Digest.class" />
    101             </fileset>
     96            </zipfileset >
    10297        </jar>
    103         <delete>
    104             <fileset dir="tmp/" >
    105                 <include name="org/bouncycastle/crypto/Digest.class" />
    106                 <include name="org/bouncycastle/crypto/Mac.class" />
    107                 <include name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
    108                 <include name="org/bouncycastle/crypto/digests/MD5Digest.class" />
    109             </fileset>
    110         </delete>
    111 <!--
    112         <delete dir="tmp/org/bouncycastle/" />
    113         <delete file="tmp/net/i2p/crypto/HMACGenerator.class" />
    114 -->
    115         <delete file="tmp/org/bouncycastle/" />
     98
    11699        <!-- lots of unneeded stuff could be deleted here -->
    117         <jar destfile="${jar.libs.dir}/i2p.jar" basedir="tmp/" />
    118         <delete dir="tmp/" />
    119 
    120         <!-- some resources -->
    121         <mkdir dir="res/drawable/" />
     100        <jar destfile="${jar.libs.dir}/i2p.jar" >
     101            <zipfileset src="../build/i2p.jar" >
     102                <exclude name="net/i2p/util/LogWriter.class" />
     103                <exclude name="net/i2p/util/SecureDirectory.class" />
     104                <exclude name="net/i2p/util/SecureFile.class" />
     105                <exclude name="net/i2p/util/SecureFileOutputStream.class" />
     106                <exclude name="org/bouncycastle/crypto/Digest.class" />
     107                <exclude name="org/bouncycastle/crypto/Mac.class" />
     108                <exclude name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
     109                <exclude name="org/bouncycastle/crypto/digests/MD5Digest.class" />
     110            </zipfileset >
     111        </jar>
     112    </target>
     113
     114    <!-- some resources -->
     115    <target name="copy-i2p-resources" depends="-dirs" >
    122116        <copy file="../installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" />
    123117        <copy file="../installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" />
     
    128122    </target>
    129123
     124    <target name="jbigi">
     125        <exec executable="sh" osfamily="unix" failonerror="true">
     126            <arg value="-c" />
     127            <arg value="jni/build.sh" />
     128        </exec>
     129        <copy file="jni/libjbigi.so" todir="${native.libs.dir}/armeabi" />
     130        <exec executable="chmod" osfamily="unix" failonerror="true">
     131            <arg value="+x" />
     132            <arg value="${native.libs.dir}/armeabi/libjbigi.so" />
     133        </exec>
     134    </target>
     135
    130136    <!-- install now does both -->
    131137    <target name="reinstall" depends="install" />
     
    133139    <target name="distclean" depends="clean">
    134140        <delete dir="${jar.libs.dir}" verbose="${verbose}" />
    135         <delete dir="tmp/" verbose="${verbose}" />
    136141        <delete file="res/drawable/i2plogo.png" verbose="${verbose}"/>
    137142        <delete file="res/raw/blocklist_txt" verbose="${verbose}" />
     143        <delete dir="jni/build/" verbose="${verbose}" />
     144        <delete file="jni/libjbigi.so" verbose="${verbose}" />
    138145    </target>
    139146
     
    440447    <!-- empty default pre-build target. Create a similar target in
    441448         your build.xml and it'll be called instead of this one. -->
    442     <target name="-pre-build"/>
     449    <!-- I2P add depends -->
     450    <target name="-pre-build" depends="copy-i2p-resources" />
    443451
    444452    <!-- Generates the R.java file for this project's resources. -->
     
    523531                        source="${java.source}" target="${java.target}"
    524532                        debug="true" extdirs=""
     533                        includeantruntime="false"
    525534                        destdir="${out.classes.absolute.dir}"
    526535                        bootclasspathref="android.target.classpath"
     
    545554         your build.xml and it'll be called instead of this one. -->
    546555    <!-- I2P add depends -->
    547     <target name="-post-compile" depends="hackcleanup" />
     556    <target name="-post-compile" depends="hackcleanup, jbigi" />
    548557
    549558    <!-- Obfuscate target
  • android/default.properties

    rc3bcb8d r173343e  
    99
    1010# Project target.
    11 target=android-2
     11target=android-3
  • android/res/raw/logger_config

    rc3bcb8d r173343e  
    11logger.defaultLevel=INFO
    2 logger.record.net.i2p.util.LogWriter=WARN
    32logger.record.net.i2p.router.peerManager.ProfileOrganizer=WARN
    43logger.record.net.i2p.router.transport=WARN
    54logger.record.net.i2p.router.transport.FIFOBandwidthRefiller=ERROR
    65logger.record.net.i2p.stat.Rate=ERROR
     6logger.record.net.i2p.util.LogManager=WARN
     7logger.record.net.i2p.util.LogWriter=WARN
     8logger.record.net.i2p.util.NativeBigInteger=DEBUG
  • android/src/net/i2p/router/I2PAndroid.java

    rc3bcb8d r173343e  
    1212import java.io.IOException;
    1313import java.util.List;
     14import java.util.Properties;
    1415
     16import net.i2p.data.DataHelper;
    1517import net.i2p.router.Router;
    1618import net.i2p.router.RouterLaunch;
    17 // import net.i2p.util.NativeBigInteger;
     19import net.i2p.util.OrderedProperties;
    1820
    1921public class I2PAndroid extends Activity
    2022{
    2123    static Context _context;
    22     private static final String DIR = "/data/data/net.i2p.router/files";
     24    private String DIR = "/data/data/net.i2p.router/files";
    2325
    2426    /** Called when the activity is first created. */
     
    3032
    3133        _context = this;  // Activity extends Context
     34        DIR = getFilesDir().getAbsolutePath();
    3235        debugStuff();
    3336        initialize();
     
    100103        System.err.println("user.home" + ": " + System.getProperty("user.home"));
    101104        System.err.println("user.name" + ": " + System.getProperty("user.name"));
     105        System.err.println("getFilesDir()" + ": " + DIR);
    102106    }
    103107
    104108    private void initialize() {
    105         // Until we can edit the router.config on the device,
    106         // copy it from the resource every time.
    107         // File f = new I2PFile("router.config");
    108         // if (!f.exists()) {
    109             copyResourceToFile(R.raw.router_config, "router.config");
    110             copyResourceToFile(R.raw.logger_config, "logger.config");
    111             copyResourceToFile(R.raw.blocklist_txt, "blocklist.txt");
    112         // }
     109        mergeResourceToFile(R.raw.router_config, "router.config");
     110        mergeResourceToFile(R.raw.logger_config, "logger.config");
     111        copyResourceToFile(R.raw.blocklist_txt, "blocklist.txt");
    113112
    114113        // Set up the locations so Router and WorkingDir can find them
     
    141140    }
    142141   
     142    /**
     143     *  Load defaults from resource,
     144     *  then add props from file,
     145     *  and write back
     146     */
     147    private void mergeResourceToFile(int resID, String f) {
     148        InputStream in = null;
     149        InputStream fin = null;
     150
     151        byte buf[] = new byte[4096];
     152        try {
     153            Properties props = new OrderedProperties();
     154            // Context methods
     155            in = getResources().openRawResource(resID);
     156            DataHelper.loadProps(props,  in);
     157           
     158            try {
     159                fin = openFileInput(f);
     160                DataHelper.loadProps(props,  fin);
     161                System.err.println("Merging resource into file " + f);
     162            } catch (IOException ioe) {
     163                System.err.println("Creating file " + f + " from resource");
     164            } finally {
     165                try { fin.close(); } catch (IOException ioe) {}
     166            }
     167
     168            DataHelper.storeProps(props, getFileStreamPath(f));
     169        } catch (IOException ioe) {
     170        } catch (Resources.NotFoundException nfe) {
     171        } finally {
     172            if (in != null) try { in.close(); } catch (IOException ioe) {}
     173            if (fin != null) try { fin.close(); } catch (IOException ioe) {}
     174        }
     175    }
     176   
    143177}
Note: See TracChangeset for help on using the changeset viewer.