mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
. Fixed sdk 1.5 build and made it the default one
. Imported JARs for classes not exposed in teh sdk anymore . Imported src code from Android core for for classes not exposed in the sdk anymore . Updated MessageView implementation of UrlInterceptHandler modified in sdk 1.5 (pls review)
This commit is contained in:
parent
5e28b65c76
commit
f6b4cbc43e
297
build-sdk-1.1.xml
Normal file
297
build-sdk-1.1.xml
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<project name="K9" default="debug">
|
||||||
|
<!-- SDK Locations -->
|
||||||
|
<property environment="env"/>
|
||||||
|
|
||||||
|
<property name="sdk-folder" value="${env.ANDROID_SDK}" />
|
||||||
|
<property name="android-tools" value="${sdk-folder}/tools" />
|
||||||
|
|
||||||
|
<!-- Application Package Name -->
|
||||||
|
<property name="application-package" value="com.fsck.k9" />
|
||||||
|
|
||||||
|
<!-- The intermediates directory -->
|
||||||
|
<!-- Eclipse uses "bin" for its own output, so we do the same. -->
|
||||||
|
<property name="outdir" value="bin" />
|
||||||
|
|
||||||
|
<!-- ************************************************************************************* -->
|
||||||
|
<!-- No user servicable parts below. -->
|
||||||
|
|
||||||
|
|
||||||
|
<property name="android-framework" value="${android-tools}/lib/framework.aidl" />
|
||||||
|
<property name="android-libs" value="${android-tools}/lib/" />
|
||||||
|
|
||||||
|
<!-- Input directories -->
|
||||||
|
<property name="resource-dir" value="res" />
|
||||||
|
<property name="asset-dir" value="assets" />
|
||||||
|
<property name="srcdir" value="src" />
|
||||||
|
<condition property="srcdir-ospath"
|
||||||
|
value="${basedir}\${srcdir}"
|
||||||
|
else="${basedir}/${srcdir}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<property name="external-libs" value="libs" />
|
||||||
|
<condition property="external-libs-ospath"
|
||||||
|
value="${basedir}\${external-libs}"
|
||||||
|
else="${basedir}/${external-libs}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<!-- Output directories -->
|
||||||
|
<property name="outdir-classes" value="${outdir}/classes" />
|
||||||
|
<condition property="outdir-classes-ospath"
|
||||||
|
value="${basedir}\${outdir-classes}"
|
||||||
|
else="${basedir}/${outdir-classes}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<!-- Create R.java in the source directory -->
|
||||||
|
<property name="outdir-r" value="src" />
|
||||||
|
|
||||||
|
<!-- Intermediate files -->
|
||||||
|
<property name="dex-file" value="classes.dex" />
|
||||||
|
<property name="intermediate-dex" value="${outdir}/${dex-file}" />
|
||||||
|
<condition property="intermediate-dex-ospath"
|
||||||
|
value="${basedir}\${intermediate-dex}"
|
||||||
|
else="${basedir}/${intermediate-dex}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<!-- The final package file to generate -->
|
||||||
|
<property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
|
||||||
|
<condition property="resources-package-ospath"
|
||||||
|
value="${basedir}\${resources-package}"
|
||||||
|
else="${basedir}/${resources-package}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
|
||||||
|
<condition property="out-debug-package-ospath"
|
||||||
|
value="${basedir}\${out-debug-package}"
|
||||||
|
else="${basedir}/${out-debug-package}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<property name="out-signed-package" value="${outdir}/${ant.project.name}-signed.apk" />
|
||||||
|
<condition property="out-signed-package-ospath"
|
||||||
|
value="${basedir}\${out-signed-package}"
|
||||||
|
else="${basedir}/${out-signed-package}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
|
||||||
|
<condition property="out-unsigned-package-ospath"
|
||||||
|
value="${basedir}\${out-unsigned-package}"
|
||||||
|
else="${basedir}/${out-unsigned-package}" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<!-- Tools -->
|
||||||
|
<condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
|
||||||
|
<os family="windows"/>
|
||||||
|
</condition>
|
||||||
|
|
||||||
|
<property name="android-jar" value="${sdk-folder}/android.jar" />
|
||||||
|
|
||||||
|
<!-- Rules -->
|
||||||
|
|
||||||
|
<!-- Create the output directories if they don't exist yet. -->
|
||||||
|
<target name="dirs">
|
||||||
|
<echo>Creating output directories if needed...</echo>
|
||||||
|
<mkdir dir="${outdir}" />
|
||||||
|
<mkdir dir="${outdir-classes}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Generate the R.java file for this project's resources. -->
|
||||||
|
<target name="resource-src" depends="dirs">
|
||||||
|
<echo>Generating R.java / Manifest.java from the resources...</echo>
|
||||||
|
<exec executable="${aapt}" failonerror="true">
|
||||||
|
<arg value="package" />
|
||||||
|
<arg value="-m" />
|
||||||
|
<arg value="-J" />
|
||||||
|
<arg value="${outdir-r}" />
|
||||||
|
<arg value="-M" />
|
||||||
|
<arg value="AndroidManifest.xml" />
|
||||||
|
<arg value="-S" />
|
||||||
|
<arg value="${resource-dir}" />
|
||||||
|
<arg value="-I" />
|
||||||
|
<arg value="${android-jar}" />
|
||||||
|
</exec>
|
||||||
|
<copy overwrite="true" file="src/com/fsck/k9/R.java" tofile="src/com/android/email/R.java">
|
||||||
|
<filterset begintoken="package " endtoken=";">
|
||||||
|
<filter token="com.fsck.k9" value="package com.android.email;"/>
|
||||||
|
</filterset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Generate java classes from .aidl files. -->
|
||||||
|
<target name="aidl" depends="dirs">
|
||||||
|
<echo>Compiling aidl files into Java classes...</echo>
|
||||||
|
<apply executable="${aidl}" failonerror="true">
|
||||||
|
<arg value="-p${android-framework}" />
|
||||||
|
<arg value="-I${srcdir}" />
|
||||||
|
<fileset dir="${srcdir}">
|
||||||
|
<include name="**/*.aidl"/>
|
||||||
|
</fileset>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Compile this project's .java files into .class files. -->
|
||||||
|
<target name="compile" depends="dirs, resource-src, aidl">
|
||||||
|
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
|
||||||
|
srcdir="."
|
||||||
|
destdir="${outdir-classes}"
|
||||||
|
bootclasspath="${android-jar}">
|
||||||
|
<classpath>
|
||||||
|
<fileset dir="${android-libs}" includes="*.jar"/>
|
||||||
|
<fileset dir="${external-libs}" includes="*.jar"/>
|
||||||
|
</classpath>
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Convert this project's .class files into .dex files. -->
|
||||||
|
<target name="dex" depends="compile">
|
||||||
|
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
|
||||||
|
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||||
|
<arg value="-JXmx1024m" />
|
||||||
|
<arg value="--dex" />
|
||||||
|
<arg value="--output=${intermediate-dex-ospath}" />
|
||||||
|
<arg path="${outdir-classes-ospath}" />
|
||||||
|
<fileset dir="${external-libs}" includes="*.jar"/>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Put the project's resources into the output package file. -->
|
||||||
|
<target name="package-res-and-assets">
|
||||||
|
<echo>Packaging resources and assets...</echo>
|
||||||
|
<exec executable="${aapt}" failonerror="true">
|
||||||
|
<arg value="package" />
|
||||||
|
<arg value="-f" />
|
||||||
|
<arg value="-M" />
|
||||||
|
<arg value="AndroidManifest.xml" />
|
||||||
|
<arg value="-S" />
|
||||||
|
<arg value="${resource-dir}" />
|
||||||
|
<arg value="-A" />
|
||||||
|
<arg value="${asset-dir}" />
|
||||||
|
<arg value="-I" />
|
||||||
|
<arg value="${android-jar}" />
|
||||||
|
<arg value="-F" />
|
||||||
|
<arg value="${resources-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
|
||||||
|
<target name="package-res-no-assets">
|
||||||
|
<echo>Packaging resources...</echo>
|
||||||
|
<exec executable="${aapt}" failonerror="true">
|
||||||
|
<arg value="package" />
|
||||||
|
<arg value="-f" />
|
||||||
|
<arg value="-M" />
|
||||||
|
<arg value="AndroidManifest.xml" />
|
||||||
|
<arg value="-S" />
|
||||||
|
<arg value="${resource-dir}" />
|
||||||
|
<!-- No assets directory -->
|
||||||
|
<arg value="-I" />
|
||||||
|
<arg value="${android-jar}" />
|
||||||
|
<arg value="-F" />
|
||||||
|
<arg value="${resources-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Invoke the proper target depending on whether or not
|
||||||
|
an assets directory is present. -->
|
||||||
|
<!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
|
||||||
|
only when the assets dir exists. -->
|
||||||
|
<target name="package-res">
|
||||||
|
<available file="${asset-dir}" type="dir"
|
||||||
|
property="res-target" value="and-assets" />
|
||||||
|
<property name="res-target" value="no-assets" />
|
||||||
|
<antcall target="package-res-${res-target}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Package the application and sign it with a debug key.
|
||||||
|
This is the default target when building. It is used for debug. -->
|
||||||
|
<target name="debug" depends="dex, package-res">
|
||||||
|
<echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
|
||||||
|
<exec executable="${apk-builder}" failonerror="true">
|
||||||
|
<arg value="${out-debug-package-ospath}" />
|
||||||
|
<arg value="-z" />
|
||||||
|
<arg value="${resources-package-ospath}" />
|
||||||
|
<arg value="-f" />
|
||||||
|
<arg value="${intermediate-dex-ospath}" />
|
||||||
|
<arg value="-rf" />
|
||||||
|
<arg value="${srcdir-ospath}" />
|
||||||
|
<arg value="-rj" />
|
||||||
|
<arg value="${external-libs-ospath}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Package the application without signing it.
|
||||||
|
This allows for the application to be signed later with an official publishing key. -->
|
||||||
|
<target name="release" depends="dex, package-res">
|
||||||
|
<echo>Packaging ${out-unsigned-package} for release...</echo>
|
||||||
|
<exec executable="${apk-builder}" failonerror="true">
|
||||||
|
<arg value="${out-unsigned-package-ospath}" />
|
||||||
|
<arg value="-u" />
|
||||||
|
<arg value="-z" />
|
||||||
|
<arg value="${resources-package-ospath}" />
|
||||||
|
<arg value="-f" />
|
||||||
|
<arg value="${intermediate-dex-ospath}" />
|
||||||
|
<arg value="-rf" />
|
||||||
|
<arg value="${srcdir-ospath}" />
|
||||||
|
<arg value="-rj" />
|
||||||
|
<arg value="${external-libs-ospath}" />
|
||||||
|
</exec>
|
||||||
|
<echo>Signing ${out-unsigned-package}</echo>
|
||||||
|
<exec executable="jarsigner" failonerror="true">
|
||||||
|
<arg value="-verbose" />
|
||||||
|
<arg value="-storepass" />
|
||||||
|
<arg value="${env.jarpass}" />
|
||||||
|
<arg value="-signedjar" />
|
||||||
|
<arg value="${out-signed-package-ospath}" />
|
||||||
|
<arg value="${out-unsigned-package-ospath}" />
|
||||||
|
|
||||||
|
<arg value="fsckcom" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Install the package on the default emulator -->
|
||||||
|
<target name="install" depends="debug">
|
||||||
|
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="install" />
|
||||||
|
<arg value="${out-debug-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="reinstall" depends="debug">
|
||||||
|
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="install" />
|
||||||
|
<arg value="-r" />
|
||||||
|
<arg value="${out-debug-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Uinstall the package from the default emulator -->
|
||||||
|
<target name="uninstall">
|
||||||
|
<echo>Uninstalling ${application-package} from the default emulator...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="uninstall" />
|
||||||
|
<arg value="${application-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
370
build.xml
370
build.xml
@ -1,117 +1,139 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="K9" default="debug">
|
<project name="K9" default="help">
|
||||||
<!-- SDK Locations -->
|
|
||||||
<property environment="env"/>
|
|
||||||
|
|
||||||
<property name="sdk-folder" value="${env.ANDROID_SDK}" />
|
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||||
<property name="android-tools" value="${sdk-folder}/tools" />
|
It contain the path to the SDK. It should *NOT* be checked in in Version
|
||||||
|
Control Systems. -->
|
||||||
|
<property file="local.properties"/>
|
||||||
|
|
||||||
<!-- Application Package Name -->
|
<!-- The build.properties file can be created by you and is never touched
|
||||||
<property name="application-package" value="com.fsck.k9" />
|
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:
|
||||||
|
|
||||||
<!-- The intermediates directory -->
|
application-package
|
||||||
<!-- Eclipse uses "bin" for its own output, so we do the same. -->
|
the name of your application package as defined in the manifest. Used by the
|
||||||
<property name="outdir" value="bin" />
|
'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
|
||||||
<!-- No user servicable parts below. -->
|
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 name="android-framework" value="${android-tools}/lib/framework.aidl" />
|
-->
|
||||||
<property name="android-libs" value="${android-tools}/lib/" />
|
<property file="build.properties"/>
|
||||||
|
|
||||||
|
<!-- 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"/>
|
||||||
|
|
||||||
|
<setup import="false" />
|
||||||
|
<!-- 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:
|
||||||
|
|
||||||
|
This will ensure that the properties are setup correctly but that your customized
|
||||||
|
targets are used.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This rules file is meant to be imported by the custom Ant task:
|
||||||
|
com.android.ant.AndroidInitTask
|
||||||
|
|
||||||
|
The following properties are put in place by the importing task:
|
||||||
|
android-jar, android-aidl, aapt, aidl, and dx
|
||||||
|
|
||||||
|
Additionnaly, the task sets up the following classpath reference:
|
||||||
|
android.target.classpath
|
||||||
|
This is used by the compiler task as the boot classpath.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Custom tasks -->
|
||||||
|
<taskdef name="aaptexec"
|
||||||
|
classname="com.android.ant.AaptExecLoopTask"
|
||||||
|
classpathref="android.antlibs"/>
|
||||||
|
|
||||||
|
<taskdef name="apkbuilder"
|
||||||
|
classname="com.android.ant.ApkBuilderTask"
|
||||||
|
classpathref="android.antlibs"/>
|
||||||
|
|
||||||
|
<!-- Properties -->
|
||||||
|
|
||||||
|
<property name="android-tools" value="${sdk-location}/tools" />
|
||||||
|
|
||||||
<!-- Input directories -->
|
<!-- Input directories -->
|
||||||
<property name="resource-dir" value="res" />
|
<property name="source-folder" value="src" />
|
||||||
<property name="asset-dir" value="assets" />
|
<property name="gen-folder" value="gen" />
|
||||||
<property name="srcdir" value="src" />
|
<property name="resource-folder" value="res" />
|
||||||
<condition property="srcdir-ospath"
|
<property name="asset-folder" value="assets" />
|
||||||
value="${basedir}\${srcdir}"
|
<property name="source-location" value="${basedir}/${source-folder}" />
|
||||||
else="${basedir}/${srcdir}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="external-libs" value="libs" />
|
<!-- folder for the 3rd party java libraries -->
|
||||||
<condition property="external-libs-ospath"
|
<property name="external-libs-folder" value="libs" />
|
||||||
value="${basedir}\${external-libs}"
|
|
||||||
else="${basedir}/${external-libs}" >
|
<!-- folder for the native libraries -->
|
||||||
<os family="windows"/>
|
<property name="native-libs-folder" value="libs" />
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- Output directories -->
|
<!-- Output directories -->
|
||||||
<property name="outdir-classes" value="${outdir}/classes" />
|
<property name="gen-folder" value="gen" />
|
||||||
<condition property="outdir-classes-ospath"
|
<property name="out-folder" value="bin" />
|
||||||
value="${basedir}\${outdir-classes}"
|
<property name="out-classes" value="${out-folder}/classes" />
|
||||||
else="${basedir}/${outdir-classes}" >
|
<property name="out-classes-location" value="${basedir}/${out-classes}"/>
|
||||||
<os family="windows"/>
|
<!-- out folders for a parent project if this project is an instrumentation project -->
|
||||||
</condition>
|
<property name="main-out-folder" value="../${out-folder}" />
|
||||||
|
<property name="main-out-classes" value="${main-out-folder}/classes"/>
|
||||||
<!-- Create R.java in the source directory -->
|
|
||||||
<property name="outdir-r" value="src" />
|
|
||||||
|
|
||||||
<!-- Intermediate files -->
|
<!-- Intermediate files -->
|
||||||
<property name="dex-file" value="classes.dex" />
|
<property name="dex-file" value="classes.dex" />
|
||||||
<property name="intermediate-dex" value="${outdir}/${dex-file}" />
|
<property name="intermediate-dex" value="${out-folder}/${dex-file}" />
|
||||||
<condition property="intermediate-dex-ospath"
|
<!-- dx does not properly support incorrect / or \ based on the platform
|
||||||
|
and Ant cannot convert them because the parameter is not a valid path.
|
||||||
|
Because of this we have to compute different paths depending on the platform. -->
|
||||||
|
<condition property="intermediate-dex-location"
|
||||||
value="${basedir}\${intermediate-dex}"
|
value="${basedir}\${intermediate-dex}"
|
||||||
else="${basedir}/${intermediate-dex}" >
|
else="${basedir}/${intermediate-dex}" >
|
||||||
<os family="windows"/>
|
<os family="windows"/>
|
||||||
</condition>
|
</condition>
|
||||||
|
|
||||||
<!-- The final package file to generate -->
|
<!-- The final package file to generate -->
|
||||||
<property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
|
<property name="out-debug-package" value="${out-folder}/${ant.project.name}-debug.apk"/>
|
||||||
<condition property="resources-package-ospath"
|
|
||||||
value="${basedir}\${resources-package}"
|
|
||||||
else="${basedir}/${resources-package}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
|
|
||||||
<condition property="out-debug-package-ospath"
|
|
||||||
value="${basedir}\${out-debug-package}"
|
|
||||||
else="${basedir}/${out-debug-package}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="out-signed-package" value="${outdir}/${ant.project.name}-signed.apk" />
|
|
||||||
<condition property="out-signed-package-ospath"
|
|
||||||
value="${basedir}\${out-signed-package}"
|
|
||||||
else="${basedir}/${out-signed-package}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
|
|
||||||
<condition property="out-unsigned-package-ospath"
|
|
||||||
value="${basedir}\${out-unsigned-package}"
|
|
||||||
else="${basedir}/${out-unsigned-package}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- Tools -->
|
<!-- Tools -->
|
||||||
<condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
|
<condition property="exe" value=".exe" else=""><os family="windows"/></condition>
|
||||||
<os family="windows"/>
|
<property name="adb" value="${android-tools}/adb${exe}"/>
|
||||||
</condition>
|
|
||||||
<condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="android-jar" value="${sdk-folder}/android.jar" />
|
<!-- rules -->
|
||||||
|
|
||||||
<!-- Rules -->
|
|
||||||
|
|
||||||
<!-- Create the output directories if they don't exist yet. -->
|
<!-- Create the output directories if they don't exist yet. -->
|
||||||
<target name="dirs">
|
<target name="dirs">
|
||||||
<echo>Creating output directories if needed...</echo>
|
<echo>Creating output directories if needed...</echo>
|
||||||
<mkdir dir="${outdir}" />
|
<mkdir dir="${resource-folder}" />
|
||||||
<mkdir dir="${outdir-classes}" />
|
<mkdir dir="${external-libs-folder}" />
|
||||||
|
<mkdir dir="${gen-folder}" />
|
||||||
|
<mkdir dir="${out-folder}" />
|
||||||
|
<mkdir dir="${out-classes}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Generate the R.java file for this project's resources. -->
|
<!-- Generate the R.java file for this project's resources. -->
|
||||||
@ -121,139 +143,107 @@
|
|||||||
<arg value="package" />
|
<arg value="package" />
|
||||||
<arg value="-m" />
|
<arg value="-m" />
|
||||||
<arg value="-J" />
|
<arg value="-J" />
|
||||||
<arg value="${outdir-r}" />
|
<arg path="${gen-folder}" />
|
||||||
<arg value="-M" />
|
<arg value="-M" />
|
||||||
<arg value="AndroidManifest.xml" />
|
<arg path="AndroidManifest.xml" />
|
||||||
<arg value="-S" />
|
<arg value="-S" />
|
||||||
<arg value="${resource-dir}" />
|
<arg path="${resource-folder}" />
|
||||||
<arg value="-I" />
|
<arg value="-I" />
|
||||||
<arg value="${android-jar}" />
|
<arg path="${android-jar}" />
|
||||||
</exec>
|
</exec>
|
||||||
<copy overwrite="true" file="src/com/fsck/k9/R.java" tofile="src/com/android/email/R.java">
|
<copy overwrite="true" file="gen/com/fsck/k9/R.java" tofile="gen/com/android/email/R.java">
|
||||||
<filterset begintoken="package " endtoken=";">
|
<filterset begintoken="package " endtoken=";">
|
||||||
<filter token="com.fsck.k9" value="package com.android.email;"/>
|
<filter token="com.fsck.k9" value="package com.android.email;"/>
|
||||||
</filterset>
|
</filterset>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Generate java classes from .aidl files. -->
|
<!-- Generate java classes from .aidl files. -->
|
||||||
<target name="aidl" depends="dirs">
|
<target name="aidl" depends="dirs">
|
||||||
<echo>Compiling aidl files into Java classes...</echo>
|
<echo>Compiling aidl files into Java classes...</echo>
|
||||||
<apply executable="${aidl}" failonerror="true">
|
<apply executable="${aidl}" failonerror="true">
|
||||||
<arg value="-p${android-framework}" />
|
<arg value="-p${android-aidl}" />
|
||||||
<arg value="-I${srcdir}" />
|
<arg value="-I${source-folder}" />
|
||||||
<fileset dir="${srcdir}">
|
<arg value="-o${gen-folder}" />
|
||||||
|
<fileset dir="${source-folder}">
|
||||||
<include name="**/*.aidl"/>
|
<include name="**/*.aidl"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</apply>
|
</apply>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Compile this project's .java files into .class files. -->
|
<!-- Compile this project's .java files into .class files. -->
|
||||||
<target name="compile" depends="dirs, resource-src, aidl">
|
<target name="compile" depends="resource-src, aidl">
|
||||||
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
|
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
|
||||||
srcdir="."
|
destdir="${out-classes}"
|
||||||
destdir="${outdir-classes}"
|
bootclasspathref="android.target.classpath">
|
||||||
bootclasspath="${android-jar}">
|
<src path="${source-folder}" />
|
||||||
|
<src path="${gen-folder}" />
|
||||||
<classpath>
|
<classpath>
|
||||||
<fileset dir="${android-libs}" includes="*.jar"/>
|
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
||||||
<fileset dir="${external-libs}" includes="*.jar"/>
|
<fileset dir="${sdk-location}/platforms/android-1.5/" includes="**/*.jar"/>
|
||||||
|
<pathelement path="${main-out-classes}"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Convert this project's .class files into .dex files. -->
|
<!-- Convert this project's .class files into .dex files. -->
|
||||||
<target name="dex" depends="compile">
|
<target name="dex" depends="compile">
|
||||||
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
|
<echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
|
||||||
<apply executable="${dx}" failonerror="true" parallel="true">
|
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||||
<arg value="-JXmx1024m" />
|
<arg value="-JXmx1024m" />
|
||||||
<arg value="--dex" />
|
<arg value="--dex" />
|
||||||
<arg value="--output=${intermediate-dex-ospath}" />
|
<arg value="--output=${intermediate-dex-location}" />
|
||||||
<arg path="${outdir-classes-ospath}" />
|
<arg path="${out-classes-location}" />
|
||||||
<fileset dir="${external-libs}" includes="*.jar"/>
|
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
||||||
</apply>
|
</apply>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Put the project's resources into the output package file. -->
|
<!-- Put the project's resources into the output package file
|
||||||
<target name="package-res-and-assets">
|
This actually can create multiple resource package in case
|
||||||
<echo>Packaging resources and assets...</echo>
|
Some custom apk with specific configuration have been
|
||||||
<exec executable="${aapt}" failonerror="true">
|
declared in default.properties.
|
||||||
<arg value="package" />
|
-->
|
||||||
<arg value="-f" />
|
<target name="package-resources">
|
||||||
<arg value="-M" />
|
<echo>Packaging resources</echo>
|
||||||
<arg value="AndroidManifest.xml" />
|
<aaptexec executable="${aapt}"
|
||||||
<arg value="-S" />
|
command="package"
|
||||||
<arg value="${resource-dir}" />
|
manifest="AndroidManifest.xml"
|
||||||
<arg value="-A" />
|
resources="${resource-folder}"
|
||||||
<arg value="${asset-dir}" />
|
assets="${asset-folder}"
|
||||||
<arg value="-I" />
|
androidjar="${android-jar}"
|
||||||
<arg value="${android-jar}" />
|
outfolder="${out-folder}"
|
||||||
<arg value="-F" />
|
basename="${ant.project.name}" />
|
||||||
<arg value="${resources-package}" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
|
|
||||||
<target name="package-res-no-assets">
|
|
||||||
<echo>Packaging resources...</echo>
|
|
||||||
<exec executable="${aapt}" failonerror="true">
|
|
||||||
<arg value="package" />
|
|
||||||
<arg value="-f" />
|
|
||||||
<arg value="-M" />
|
|
||||||
<arg value="AndroidManifest.xml" />
|
|
||||||
<arg value="-S" />
|
|
||||||
<arg value="${resource-dir}" />
|
|
||||||
<!-- No assets directory -->
|
|
||||||
<arg value="-I" />
|
|
||||||
<arg value="${android-jar}" />
|
|
||||||
<arg value="-F" />
|
|
||||||
<arg value="${resources-package}" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Invoke the proper target depending on whether or not
|
|
||||||
an assets directory is present. -->
|
|
||||||
<!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
|
|
||||||
only when the assets dir exists. -->
|
|
||||||
<target name="package-res">
|
|
||||||
<available file="${asset-dir}" type="dir"
|
|
||||||
property="res-target" value="and-assets" />
|
|
||||||
<property name="res-target" value="no-assets" />
|
|
||||||
<antcall target="package-res-${res-target}" />
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Package the application and sign it with a debug key.
|
<!-- Package the application and sign it with a debug key.
|
||||||
This is the default target when building. It is used for debug. -->
|
This is the default target when building. It is used for debug. -->
|
||||||
<target name="debug" depends="dex, package-res">
|
<target name="debug" depends="dex, package-resources">
|
||||||
<echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
|
<apkbuilder
|
||||||
<exec executable="${apk-builder}" failonerror="true">
|
outfolder="${out-folder}"
|
||||||
<arg value="${out-debug-package-ospath}" />
|
basename="${ant.project.name}"
|
||||||
<arg value="-z" />
|
signed="true"
|
||||||
<arg value="${resources-package-ospath}" />
|
verbose="false">
|
||||||
<arg value="-f" />
|
<file path="${intermediate-dex}" />
|
||||||
<arg value="${intermediate-dex-ospath}" />
|
<sourcefolder path="${source-folder}" />
|
||||||
<arg value="-rf" />
|
<jarfolder path="${external-libs-folder}" />
|
||||||
<arg value="${srcdir-ospath}" />
|
<nativefolder path="${native-libs-folder}" />
|
||||||
<arg value="-rj" />
|
</apkbuilder>
|
||||||
<arg value="${external-libs-ospath}" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Package the application without signing it.
|
<!-- Package the application without signing it.
|
||||||
This allows for the application to be signed later with an official publishing key. -->
|
This allows for the application to be signed later with an official publishing key. -->
|
||||||
<target name="release" depends="dex, package-res">
|
<target name="release" depends="dex, package-resources">
|
||||||
<echo>Packaging ${out-unsigned-package} for release...</echo>
|
<apkbuilder
|
||||||
<exec executable="${apk-builder}" failonerror="true">
|
outfolder="${out-folder}"
|
||||||
<arg value="${out-unsigned-package-ospath}" />
|
basename="${ant.project.name}"
|
||||||
<arg value="-u" />
|
signed="false"
|
||||||
<arg value="-z" />
|
verbose="false">
|
||||||
<arg value="${resources-package-ospath}" />
|
<file path="${intermediate-dex}" />
|
||||||
<arg value="-f" />
|
<sourcefolder path="${source-folder}" />
|
||||||
<arg value="${intermediate-dex-ospath}" />
|
<jarfolder path="${external-libs-folder}" />
|
||||||
<arg value="-rf" />
|
<nativefolder path="${native-libs-folder}" />
|
||||||
<arg value="${srcdir-ospath}" />
|
</apkbuilder>
|
||||||
<arg value="-rj" />
|
|
||||||
<arg value="${external-libs-ospath}" />
|
|
||||||
</exec>
|
|
||||||
<echo>Signing ${out-unsigned-package}</echo>
|
<echo>Signing ${out-unsigned-package}</echo>
|
||||||
<exec executable="jarsigner" failonerror="true">
|
<exec executable="jarsigner" failonerror="true">
|
||||||
<arg value="-verbose" />
|
<arg value="-verbose" />
|
||||||
@ -272,7 +262,7 @@
|
|||||||
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
||||||
<exec executable="${adb}" failonerror="true">
|
<exec executable="${adb}" failonerror="true">
|
||||||
<arg value="install" />
|
<arg value="install" />
|
||||||
<arg value="${out-debug-package}" />
|
<arg path="${out-debug-package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -281,7 +271,7 @@
|
|||||||
<exec executable="${adb}" failonerror="true">
|
<exec executable="${adb}" failonerror="true">
|
||||||
<arg value="install" />
|
<arg value="install" />
|
||||||
<arg value="-r" />
|
<arg value="-r" />
|
||||||
<arg value="${out-debug-package}" />
|
<arg path="${out-debug-package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -290,8 +280,26 @@
|
|||||||
<echo>Uninstalling ${application-package} from the default emulator...</echo>
|
<echo>Uninstalling ${application-package} from the default emulator...</echo>
|
||||||
<exec executable="${adb}" failonerror="true">
|
<exec executable="${adb}" failonerror="true">
|
||||||
<arg value="uninstall" />
|
<arg value="uninstall" />
|
||||||
<arg value="${application-package}" />
|
<arg path="${application-package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="help">
|
||||||
|
<!-- displays starts at col 13
|
||||||
|
|13 80| -->
|
||||||
|
<echo>Android Ant Build. Available targets:</echo>
|
||||||
|
<echo> help: Displays this help.</echo>
|
||||||
|
<echo> debug: Builds the application and sign it with a debug key.</echo>
|
||||||
|
<echo> release: Builds the application. The generated apk file must be</echo>
|
||||||
|
<echo> signed before it is published.</echo>
|
||||||
|
<echo> install: Installs the debug package onto a running emulator or</echo>
|
||||||
|
<echo> device. This can only be used if the application has </echo>
|
||||||
|
<echo> not yet been installed.</echo>
|
||||||
|
<echo> reinstall: Installs the debug package on a running emulator or</echo>
|
||||||
|
<echo> device that already has the application.</echo>
|
||||||
|
<echo> The signatures must match.</echo>
|
||||||
|
<echo> uninstall: uninstall the application from a running emulator or</echo>
|
||||||
|
<echo> device.</echo>
|
||||||
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
BIN
libs/bcprov-jdk15-143.jar
Normal file
BIN
libs/bcprov-jdk15-143.jar
Normal file
Binary file not shown.
BIN
libs/commons-codec-1.3.jar
Normal file
BIN
libs/commons-codec-1.3.jar
Normal file
Binary file not shown.
BIN
libs/commons-logging-1.1.1.jar
Normal file
BIN
libs/commons-logging-1.1.1.jar
Normal file
Binary file not shown.
277
src/android/net/http/DomainNameChecker.java
Normal file
277
src/android/net/http/DomainNameChecker.java
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net.http;
|
||||||
|
|
||||||
|
import org.bouncycastle.asn1.x509.X509Name;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.security.cert.CertificateParsingException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements basic domain-name validation as specified by RFC2818.
|
||||||
|
*
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public class DomainNameChecker {
|
||||||
|
private static Pattern QUICK_IP_PATTERN;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
QUICK_IP_PATTERN = Pattern.compile("^[a-f0-9\\.:]+$");
|
||||||
|
} catch (PatternSyntaxException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int ALT_DNS_NAME = 2;
|
||||||
|
private static final int ALT_IPA_NAME = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the site certificate against the domain name of the site being visited
|
||||||
|
* @param certificate The certificate to check
|
||||||
|
* @param thisDomain The domain name of the site being visited
|
||||||
|
* @return True iff if there is a domain match as specified by RFC2818
|
||||||
|
*/
|
||||||
|
public static boolean match(X509Certificate certificate, String thisDomain) {
|
||||||
|
if (certificate == null || thisDomain == null || thisDomain.length() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
thisDomain = thisDomain.toLowerCase();
|
||||||
|
if (!isIpAddress(thisDomain)) {
|
||||||
|
return matchDns(certificate, thisDomain);
|
||||||
|
} else {
|
||||||
|
return matchIpAddress(certificate, thisDomain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True iff the domain name is specified as an IP address
|
||||||
|
*/
|
||||||
|
private static boolean isIpAddress(String domain) {
|
||||||
|
boolean rval = (domain != null && domain.length() != 0);
|
||||||
|
if (rval) {
|
||||||
|
try {
|
||||||
|
// do a quick-dirty IP match first to avoid DNS lookup
|
||||||
|
rval = QUICK_IP_PATTERN.matcher(domain).matches();
|
||||||
|
if (rval) {
|
||||||
|
rval = domain.equals(
|
||||||
|
InetAddress.getByName(domain).getHostAddress());
|
||||||
|
}
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
String errorMessage = e.getMessage();
|
||||||
|
if (errorMessage == null) {
|
||||||
|
errorMessage = "unknown host exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
HttpLog.v("DomainNameChecker.isIpAddress(): " + errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
rval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the site certificate against the IP domain name of the site being visited
|
||||||
|
* @param certificate The certificate to check
|
||||||
|
* @param thisDomain The DNS domain name of the site being visited
|
||||||
|
* @return True iff if there is a domain match as specified by RFC2818
|
||||||
|
*/
|
||||||
|
private static boolean matchIpAddress(X509Certificate certificate, String thisDomain) {
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
HttpLog.v("DomainNameChecker.matchIpAddress(): this domain: " + thisDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Collection subjectAltNames = certificate.getSubjectAlternativeNames();
|
||||||
|
if (subjectAltNames != null) {
|
||||||
|
Iterator i = subjectAltNames.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
List altNameEntry = (List)(i.next());
|
||||||
|
if (altNameEntry != null && 2 <= altNameEntry.size()) {
|
||||||
|
Integer altNameType = (Integer)(altNameEntry.get(0));
|
||||||
|
if (altNameType != null) {
|
||||||
|
if (altNameType.intValue() == ALT_IPA_NAME) {
|
||||||
|
String altName = (String)(altNameEntry.get(1));
|
||||||
|
if (altName != null) {
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
HttpLog.v("alternative IP: " + altName);
|
||||||
|
}
|
||||||
|
if (thisDomain.equalsIgnoreCase(altName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CertificateParsingException e) {}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the site certificate against the DNS domain name of the site being visited
|
||||||
|
* @param certificate The certificate to check
|
||||||
|
* @param thisDomain The DNS domain name of the site being visited
|
||||||
|
* @return True iff if there is a domain match as specified by RFC2818
|
||||||
|
*/
|
||||||
|
private static boolean matchDns(X509Certificate certificate, String thisDomain) {
|
||||||
|
boolean hasDns = false;
|
||||||
|
try {
|
||||||
|
Collection subjectAltNames = certificate.getSubjectAlternativeNames();
|
||||||
|
if (subjectAltNames != null) {
|
||||||
|
Iterator i = subjectAltNames.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
List altNameEntry = (List)(i.next());
|
||||||
|
if (altNameEntry != null && 2 <= altNameEntry.size()) {
|
||||||
|
Integer altNameType = (Integer)(altNameEntry.get(0));
|
||||||
|
if (altNameType != null) {
|
||||||
|
if (altNameType.intValue() == ALT_DNS_NAME) {
|
||||||
|
hasDns = true;
|
||||||
|
String altName = (String)(altNameEntry.get(1));
|
||||||
|
if (altName != null) {
|
||||||
|
if (matchDns(thisDomain, altName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CertificateParsingException e) {
|
||||||
|
// one way we can get here is if an alternative name starts with
|
||||||
|
// '*' character, which is contrary to one interpretation of the
|
||||||
|
// spec (a valid DNS name must start with a letter); there is no
|
||||||
|
// good way around this, and in order to be compatible we proceed
|
||||||
|
// to check the common name (ie, ignore alternative names)
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
String errorMessage = e.getMessage();
|
||||||
|
if (errorMessage == null) {
|
||||||
|
errorMessage = "failed to parse certificate";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
HttpLog.v("DomainNameChecker.matchDns(): " + errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasDns) {
|
||||||
|
X509Name xName = new X509Name(certificate.getSubjectDN().getName());
|
||||||
|
Vector val = xName.getValues();
|
||||||
|
Vector oid = xName.getOIDs();
|
||||||
|
for (int i = 0; i < oid.size(); i++) {
|
||||||
|
if (oid.elementAt(i).equals(X509Name.CN)) {
|
||||||
|
return matchDns(thisDomain, (String)(val.elementAt(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param thisDomain The domain name of the site being visited
|
||||||
|
* @param thatDomain The domain name from the certificate
|
||||||
|
* @return True iff thisDomain matches thatDomain as specified by RFC2818
|
||||||
|
*/
|
||||||
|
private static boolean matchDns(String thisDomain, String thatDomain) {
|
||||||
|
if (HttpLog.LOGV) {
|
||||||
|
HttpLog.v("DomainNameChecker.matchDns():" +
|
||||||
|
" this domain: " + thisDomain +
|
||||||
|
" that domain: " + thatDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisDomain == null || thisDomain.length() == 0 ||
|
||||||
|
thatDomain == null || thatDomain.length() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
thatDomain = thatDomain.toLowerCase();
|
||||||
|
|
||||||
|
// (a) domain name strings are equal, ignoring case: X matches X
|
||||||
|
boolean rval = thisDomain.equals(thatDomain);
|
||||||
|
if (!rval) {
|
||||||
|
String[] thisDomainTokens = thisDomain.split("\\.");
|
||||||
|
String[] thatDomainTokens = thatDomain.split("\\.");
|
||||||
|
|
||||||
|
int thisDomainTokensNum = thisDomainTokens.length;
|
||||||
|
int thatDomainTokensNum = thatDomainTokens.length;
|
||||||
|
|
||||||
|
// (b) OR thatHost is a '.'-suffix of thisHost: Z.Y.X matches X
|
||||||
|
if (thisDomainTokensNum >= thatDomainTokensNum) {
|
||||||
|
for (int i = thatDomainTokensNum - 1; i >= 0; --i) {
|
||||||
|
rval = thisDomainTokens[i].equals(thatDomainTokens[i]);
|
||||||
|
if (!rval) {
|
||||||
|
// (c) OR we have a special *-match:
|
||||||
|
// Z.Y.X matches *.Y.X but does not match *.X
|
||||||
|
rval = (i == 0 && thisDomainTokensNum == thatDomainTokensNum);
|
||||||
|
if (rval) {
|
||||||
|
rval = thatDomainTokens[0].equals("*");
|
||||||
|
if (!rval) {
|
||||||
|
// (d) OR we have a *-component match:
|
||||||
|
// f*.com matches foo.com but not bar.com
|
||||||
|
rval = domainTokenMatch(
|
||||||
|
thisDomainTokens[0], thatDomainTokens[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param thisDomainToken The domain token from the current domain name
|
||||||
|
* @param thatDomainToken The domain token from the certificate
|
||||||
|
* @return True iff thisDomainToken matches thatDomainToken, using the
|
||||||
|
* wildcard match as specified by RFC2818-3.1. For example, f*.com must
|
||||||
|
* match foo.com but not bar.com
|
||||||
|
*/
|
||||||
|
private static boolean domainTokenMatch(String thisDomainToken, String thatDomainToken) {
|
||||||
|
if (thisDomainToken != null && thatDomainToken != null) {
|
||||||
|
int starIndex = thatDomainToken.indexOf('*');
|
||||||
|
if (starIndex >= 0) {
|
||||||
|
if (thatDomainToken.length() - 1 <= thisDomainToken.length()) {
|
||||||
|
String prefix = thatDomainToken.substring(0, starIndex);
|
||||||
|
String suffix = thatDomainToken.substring(starIndex + 1);
|
||||||
|
|
||||||
|
return thisDomainToken.startsWith(prefix) && thisDomainToken.endsWith(suffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
44
src/android/net/http/HttpLog.java
Normal file
44
src/android/net/http/HttpLog.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* package-level logging flag
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.net.http;
|
||||||
|
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
class HttpLog {
|
||||||
|
private final static String LOGTAG = "http";
|
||||||
|
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
|
static final boolean LOGV = DEBUG ? Config.LOGD : Config.LOGV;
|
||||||
|
|
||||||
|
static void v(String logMe) {
|
||||||
|
Log.v(LOGTAG, SystemClock.uptimeMillis() + " " + Thread.currentThread().getName() + " " + logMe);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void e(String logMe) {
|
||||||
|
Log.e(LOGTAG, logMe);
|
||||||
|
}
|
||||||
|
}
|
204
src/android/text/util/Regex.java
Normal file
204
src/android/text/util/Regex.java
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.text.util;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public class Regex {
|
||||||
|
/**
|
||||||
|
* Regular expression pattern to match all IANA top-level domains.
|
||||||
|
* List accurate as of 2007/06/15. List taken from:
|
||||||
|
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
||||||
|
* This pattern is auto-generated by //device/tools/make-iana-tld-pattern.py
|
||||||
|
*/
|
||||||
|
public static final Pattern TOP_LEVEL_DOMAIN_PATTERN
|
||||||
|
= Pattern.compile(
|
||||||
|
"((aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
|
||||||
|
+ "|(biz|b[abdefghijmnorstvwyz])"
|
||||||
|
+ "|(cat|com|coop|c[acdfghiklmnoruvxyz])"
|
||||||
|
+ "|d[ejkmoz]"
|
||||||
|
+ "|(edu|e[cegrstu])"
|
||||||
|
+ "|f[ijkmor]"
|
||||||
|
+ "|(gov|g[abdefghilmnpqrstuwy])"
|
||||||
|
+ "|h[kmnrtu]"
|
||||||
|
+ "|(info|int|i[delmnoqrst])"
|
||||||
|
+ "|(jobs|j[emop])"
|
||||||
|
+ "|k[eghimnrwyz]"
|
||||||
|
+ "|l[abcikrstuvy]"
|
||||||
|
+ "|(mil|mobi|museum|m[acdghklmnopqrstuvwxyz])"
|
||||||
|
+ "|(name|net|n[acefgilopruz])"
|
||||||
|
+ "|(org|om)"
|
||||||
|
+ "|(pro|p[aefghklmnrstwy])"
|
||||||
|
+ "|qa"
|
||||||
|
+ "|r[eouw]"
|
||||||
|
+ "|s[abcdeghijklmnortuvyz]"
|
||||||
|
+ "|(tel|travel|t[cdfghjklmnoprtvwz])"
|
||||||
|
+ "|u[agkmsyz]"
|
||||||
|
+ "|v[aceginu]"
|
||||||
|
+ "|w[fs]"
|
||||||
|
+ "|y[etu]"
|
||||||
|
+ "|z[amw])");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular expression pattern to match RFC 1738 URLs
|
||||||
|
* List accurate as of 2007/06/15. List taken from:
|
||||||
|
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
||||||
|
* This pattern is auto-generated by //device/tools/make-iana-tld-pattern.py
|
||||||
|
*/
|
||||||
|
public static final Pattern WEB_URL_PATTERN
|
||||||
|
= Pattern.compile(
|
||||||
|
"((?:(http|https|Http|Https):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
|
||||||
|
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
|
||||||
|
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
|
||||||
|
+ "((?:(?:[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}\\.)+" // named host
|
||||||
|
+ "(?:" // plus top level domain
|
||||||
|
+ "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
|
||||||
|
+ "|(?:biz|b[abdefghijmnorstvwyz])"
|
||||||
|
+ "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"
|
||||||
|
+ "|d[ejkmoz]"
|
||||||
|
+ "|(?:edu|e[cegrstu])"
|
||||||
|
+ "|f[ijkmor]"
|
||||||
|
+ "|(?:gov|g[abdefghilmnpqrstuwy])"
|
||||||
|
+ "|h[kmnrtu]"
|
||||||
|
+ "|(?:info|int|i[delmnoqrst])"
|
||||||
|
+ "|(?:jobs|j[emop])"
|
||||||
|
+ "|k[eghimnrwyz]"
|
||||||
|
+ "|l[abcikrstuvy]"
|
||||||
|
+ "|(?:mil|mobi|museum|m[acdghklmnopqrstuvwxyz])"
|
||||||
|
+ "|(?:name|net|n[acefgilopruz])"
|
||||||
|
+ "|(?:org|om)"
|
||||||
|
+ "|(?:pro|p[aefghklmnrstwy])"
|
||||||
|
+ "|qa"
|
||||||
|
+ "|r[eouw]"
|
||||||
|
+ "|s[abcdeghijklmnortuvyz]"
|
||||||
|
+ "|(?:tel|travel|t[cdfghjklmnoprtvwz])"
|
||||||
|
+ "|u[agkmsyz]"
|
||||||
|
+ "|v[aceginu]"
|
||||||
|
+ "|w[fs]"
|
||||||
|
+ "|y[etu]"
|
||||||
|
+ "|z[amw]))"
|
||||||
|
+ "|(?:(?:25[0-5]|2[0-4]" // or ip address
|
||||||
|
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
|
||||||
|
+ "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
|
||||||
|
+ "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
|
||||||
|
+ "|[1-9][0-9]|[0-9])))"
|
||||||
|
+ "(?:\\:\\d{1,5})?)" // plus option port number
|
||||||
|
+ "(\\/(?:(?:[a-zA-Z0-9\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus option query params
|
||||||
|
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
|
||||||
|
+ "(?:\\b|$)"); // and finally, a word boundary or end of
|
||||||
|
// input. This is to stop foo.sure from
|
||||||
|
// matching as foo.su
|
||||||
|
|
||||||
|
public static final Pattern IP_ADDRESS_PATTERN
|
||||||
|
= Pattern.compile(
|
||||||
|
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
|
||||||
|
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
|
||||||
|
+ "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
|
||||||
|
+ "|[1-9][0-9]|[0-9]))");
|
||||||
|
|
||||||
|
public static final Pattern DOMAIN_NAME_PATTERN
|
||||||
|
= Pattern.compile(
|
||||||
|
"(((([a-zA-Z0-9][a-zA-Z0-9\\-]*)*[a-zA-Z0-9]\\.)+"
|
||||||
|
+ TOP_LEVEL_DOMAIN_PATTERN + ")|"
|
||||||
|
+ IP_ADDRESS_PATTERN + ")");
|
||||||
|
|
||||||
|
public static final Pattern EMAIL_ADDRESS_PATTERN
|
||||||
|
= Pattern.compile(
|
||||||
|
"[a-zA-Z0-9\\+\\.\\_\\%\\-]{1,256}" +
|
||||||
|
"\\@" +
|
||||||
|
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
|
||||||
|
"(" +
|
||||||
|
"\\." +
|
||||||
|
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
|
||||||
|
")+"
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This pattern is intended for searching for things that look like they
|
||||||
|
* might be phone numbers in arbitrary text, not for validating whether
|
||||||
|
* something is in fact a phone number. It will miss many things that
|
||||||
|
* are legitimate phone numbers.
|
||||||
|
*
|
||||||
|
* <p> The pattern matches the following:
|
||||||
|
* <ul>
|
||||||
|
* <li>Optionally, a + sign followed immediately by one or more digits. Spaces, dots, or dashes
|
||||||
|
* may follow.
|
||||||
|
* <li>Optionally, sets of digits in parentheses, separated by spaces, dots, or dashes.
|
||||||
|
* <li>A string starting and ending with a digit, containing digits, spaces, dots, and/or dashes.
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public static final Pattern PHONE_PATTERN
|
||||||
|
= Pattern.compile( // sdd = space, dot, or dash
|
||||||
|
"(\\+[0-9]+[\\- \\.]*)?" // +<digits><sdd>*
|
||||||
|
+ "(\\([0-9]+\\)[\\- \\.]*)?" // (<digits>)<sdd>*
|
||||||
|
+ "([0-9][0-9\\- \\.][0-9\\- \\.]+[0-9])"); // <digit><digit|sdd>+<digit>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to take all of the non-null matching groups in a
|
||||||
|
* regex Matcher and return them as a concatenated string.
|
||||||
|
*
|
||||||
|
* @param matcher The Matcher object from which grouped text will
|
||||||
|
* be extracted
|
||||||
|
*
|
||||||
|
* @return A String comprising all of the non-null matched
|
||||||
|
* groups concatenated together
|
||||||
|
*/
|
||||||
|
public static final String concatGroups(Matcher matcher) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
final int numGroups = matcher.groupCount();
|
||||||
|
|
||||||
|
for (int i = 1; i <= numGroups; i++) {
|
||||||
|
String s = matcher.group(i);
|
||||||
|
|
||||||
|
System.err.println("Group(" + i + ") : " + s);
|
||||||
|
|
||||||
|
if (s != null) {
|
||||||
|
b.append(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to return only the digits and plus signs
|
||||||
|
* in the matching string.
|
||||||
|
*
|
||||||
|
* @param matcher The Matcher object from which digits and plus will
|
||||||
|
* be extracted
|
||||||
|
*
|
||||||
|
* @return A String comprising all of the digits and plus in
|
||||||
|
* the match
|
||||||
|
*/
|
||||||
|
public static final String digitsAndPlusOnly(Matcher matcher) {
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
String matchingRegion = matcher.group();
|
||||||
|
|
||||||
|
for (int i = 0, size = matchingRegion.length(); i < size; i++) {
|
||||||
|
char character = matchingRegion.charAt(i);
|
||||||
|
|
||||||
|
if (character == '+' || Character.isDigit(character)) {
|
||||||
|
buffer.append(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -36,11 +36,11 @@ import android.view.View;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.webkit.CacheManager;
|
import android.webkit.CacheManager;
|
||||||
import android.webkit.CacheManager;
|
|
||||||
import android.webkit.UrlInterceptHandler;
|
import android.webkit.UrlInterceptHandler;
|
||||||
// import android.webkit.PluginData; // XXX TODO reenable when we switch to sdk 1.5
|
// import android.webkit.PluginData; // XXX TODO reenable when we switch to sdk 1.5
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.CacheManager.CacheResult;
|
import android.webkit.CacheManager.CacheResult;
|
||||||
|
import android.webkit.PluginData;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -65,6 +65,8 @@ import com.android.email.mail.store.LocalStore.LocalAttachmentBodyPart;
|
|||||||
import com.android.email.mail.store.LocalStore.LocalMessage;
|
import com.android.email.mail.store.LocalStore.LocalMessage;
|
||||||
import com.android.email.mail.store.LocalStore.LocalTextBody;
|
import com.android.email.mail.store.LocalStore.LocalTextBody;
|
||||||
import com.android.email.provider.AttachmentProvider;
|
import com.android.email.provider.AttachmentProvider;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -78,6 +80,7 @@ public class MessageView extends K9Activity
|
|||||||
private static final String EXTRA_NEXT = "com.android.email.MessageView_next";
|
private static final String EXTRA_NEXT = "com.android.email.MessageView_next";
|
||||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, 1, 120000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
|
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, 1, 120000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
|
||||||
|
|
||||||
|
private static final String CID_PREFIX = "http://cid/";
|
||||||
|
|
||||||
private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1;
|
private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1;
|
||||||
|
|
||||||
@ -876,10 +879,9 @@ public class MessageView extends K9Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CacheResult service(String url, Map<String, String> headers) {
|
public CacheResult service(String url, Map<String, String> headers) {
|
||||||
String prefix = "http://cid/";
|
if (url.startsWith(CID_PREFIX) && mMessage != null) {
|
||||||
if (url.startsWith(prefix) && mMessage != null) {
|
|
||||||
try {
|
try {
|
||||||
String contentId = url.substring(prefix.length());
|
String contentId = url.substring(CID_PREFIX.length());
|
||||||
final Part part = MimeUtility.findPartByContentId(mMessage, "<" + contentId + ">");
|
final Part part = MimeUtility.findPartByContentId(mMessage, "<" + contentId + ">");
|
||||||
if (part != null) {
|
if (part != null) {
|
||||||
CacheResult cr = new CacheManager.CacheResult();
|
CacheResult cr = new CacheManager.CacheResult();
|
||||||
@ -895,6 +897,36 @@ public class MessageView extends K9Activity
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PluginData getPluginData(String url, Map<String, String> headers) {
|
||||||
|
if (url.startsWith(CID_PREFIX) && mMessage != null) {
|
||||||
|
try {
|
||||||
|
String contentId = url.substring(CID_PREFIX.length());
|
||||||
|
final Part part = MimeUtility.findPartByContentId(mMessage, "<" + contentId + ">");
|
||||||
|
if (part != null) {
|
||||||
|
Map<String, String[]> splittedHeaders = new HashMap<String, String[]>();
|
||||||
|
for (String headerName : headers.keySet()) {
|
||||||
|
String heaverValue = headers.get(headerName);
|
||||||
|
//There must be a better way to do this split and trim...
|
||||||
|
String[] headerValues = heaverValue.split(",");
|
||||||
|
for (int i=0; i<headerValues.length; i++) {
|
||||||
|
headerValues[i] = headerValues[i].trim();
|
||||||
|
}
|
||||||
|
splittedHeaders.put(headerName, headerValues);
|
||||||
|
}
|
||||||
|
return new PluginData(
|
||||||
|
part.getBody().getInputStream(),
|
||||||
|
part.getSize(),
|
||||||
|
splittedHeaders,
|
||||||
|
HttpURLConnection.HTTP_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private Bitmap getPreviewIcon(Attachment attachment) throws MessagingException {
|
private Bitmap getPreviewIcon(Attachment attachment) throws MessagingException {
|
||||||
try {
|
try {
|
||||||
return BitmapFactory.decodeStream(
|
return BitmapFactory.decodeStream(
|
||||||
|
Loading…
Reference in New Issue
Block a user