From 1419b85b676338d4daacf8b899bd917709409bec Mon Sep 17 00:00:00 2001 From: Adrian Stabiszewski Date: Fri, 8 Nov 2013 10:27:37 +0100 Subject: [PATCH] initial --- .classpath | 9 ++++ .gitignore | 3 ++ .project | 33 ++++++++++++++ .settings/org.eclipse.jdt.core.prefs | 11 +++++ AndroidManifest.xml | 43 ++++++++++++++++++ proguard-project.txt | 20 ++++++++ project.properties | 14 ++++++ res/drawable-mdpi/ic_launcher.png | Bin 0 -> 3777 bytes res/layout/activity_main.xml | 16 +++++++ res/values/dimens.xml | 7 +++ res/values/strings.xml | 10 ++++ res/values/styles.xml | 20 ++++++++ res/xml/apduservice.xml | 12 +++++ src/de/grundid/hcedemo/MainActivity.java | 13 ++++++ src/de/grundid/hcedemo/MyHostApduService.java | 39 ++++++++++++++++ 15 files changed, 250 insertions(+) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 AndroidManifest.xml create mode 100644 proguard-project.txt create mode 100644 project.properties create mode 100644 res/drawable-mdpi/ic_launcher.png create mode 100644 res/layout/activity_main.xml create mode 100644 res/values/dimens.xml create mode 100644 res/values/strings.xml create mode 100644 res/values/styles.xml create mode 100644 res/xml/apduservice.xml create mode 100644 src/de/grundid/hcedemo/MainActivity.java create mode 100644 src/de/grundid/hcedemo/MyHostApduService.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..7bc01d9 --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e1a8202 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin +gen +target diff --git a/.project b/.project new file mode 100644 index 0000000..8b8abe4 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + host-card-emulation-sample + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8000cd6 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..ed82d43 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/proguard-project.txt b/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..4ab1256 --- /dev/null +++ b/project.properties @@ -0,0 +1,14 @@ +# 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 edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..6ae570b4db4da165fada0650079061cb56aa8793 GIT binary patch literal 3777 zcmV;y4nFaTP)<5O4m2Hnvj*wc>ks?G z2G34C@E_ZLZKgG#r9IGlue=QUde;x0&cEf}-^JJmm+rK2tvlk-Rei)^T;Dlp|J|h@ z^m+gPwY2+#Jp|DwyKZ{cr#D)vv<3?RYtkmp$A#M_scJjzTH4xNh5}{7UZcq4B{H*L zAbrC#D0V!CY|}%?3-2R&-YsP7u%Pze_gYZ0)AsviO2LRhr%`gXg-+>Ct8*6~gsguK z#ocE}dD{&cL$1D$Nahk|Gw0#KoMAkBPxj3Dsk7U=vbNLla&#_VG^p9{qm1aoZlq4X z^Cs&0V~Cl@NMI=QP@|Gq(}0&K#8vp=Jm%rVTTdK%=7x@k&di334&4O8uk5(sqd^Q_ zOZx$2J`a)j^giNo8q0Qj^e(~C7xVD# zBMhtX326_pU@IUwD0ag^9a#=8X??`t?%Wdb?IN60 zFU5H#fIN^s2jJ9e3jX;b?0@8i_S^2*cGVr<-K)a(^8r}3&jQ&SjUUMBc)a)44{XT~ zKlMpG`6^Vs@6j}zdy)c%>BZfb9XR-87LGiduL=0*b8mD$U4(;==VR}EFYLPIfh||3 zVcW$8=vDXN$A_m-+HT1LV5F7&O24xA)DN34P8+uS&iwD&Z+kG?ZaSg;#ynhn(2U*J z7o+`-JNDe0iH`fTu;=b9%D4zSZ+fEb+6-*E=!SLQIb-b!2XtJJqGfL^@-~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@C-IFEC35cE8XDk!zmX^g+n5;Y^E!#yej1?&-!I4 z*7HL{U55VF4Vm_IpYfm03*qrZemoxgSt^x&P}~w2oLp(ECMgBm2W%DCBg%Eu?1ZCOGtXt46rC#51~p{aY#0c z`aGt9nm3n+@Jucu(`^teae7Gt>w0my z;V&Ln!n%O8UVy%9OsOf&5Lax5m^@RWkO0AQV|HnW#zhVNjC5 z&QD@+Hdsah<~Spv&<&Cz7l@0TATD-5La7szST==8DxV7Zs{bJOfUMjT(h?8E<+;)F z!Txoy+^oY-%AX;UzQ^EytyJMjQ?gy>e-5`rU&AY8B9^Q)L6}^K6uFI2=56;OsRLQ@nJU84FF?X+ZtcpuQhaRJtXG zD#wv5j=}th(WK?Nm^^zVY^Qx)p{04H1a1Eam)SPchpC-reSv9~ID z7K0BUr^!7&reGoynL827)AeXt>rs#sFm=wD@_tQ^l)HO)28`%k7(JSHS2WS3T=>T6 zVPTl%AOoP_((0%B#uRYWQ3QY;PNAthc*p87(-(~w_s@@*G!OGdG2?n@Z;MccKEjmj zCWXg%N1Cl3@FMN^ww3wT!Rl3Nx>pqNmCoPihHyw&svtvB z==>~sl?Ri&TGShnW^;H!%-D(l5HGuff;fK;5F6Qtr8xR6OL27eUe15#ClL1K1%cH| ruJZJht7Zygm5zVW`osRPe+>Ii)X|D+8y7?e00000NkvXXu0mjf#L-I; literal 0 HcmV?d00001 diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml new file mode 100644 index 0000000..168c9b8 --- /dev/null +++ b/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..4c4b8fc --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,10 @@ + + + + HceDemo + Settings + Ignore this activity + aiddescription + servicedesc + + diff --git a/res/values/styles.xml b/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/res/xml/apduservice.xml b/res/xml/apduservice.xml new file mode 100644 index 0000000..f4bb6fe --- /dev/null +++ b/res/xml/apduservice.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/src/de/grundid/hcedemo/MainActivity.java b/src/de/grundid/hcedemo/MainActivity.java new file mode 100644 index 0000000..ab684c5 --- /dev/null +++ b/src/de/grundid/hcedemo/MainActivity.java @@ -0,0 +1,13 @@ +package de.grundid.hcedemo; + +import android.app.Activity; +import android.os.Bundle; + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } +} diff --git a/src/de/grundid/hcedemo/MyHostApduService.java b/src/de/grundid/hcedemo/MyHostApduService.java new file mode 100644 index 0000000..a348926 --- /dev/null +++ b/src/de/grundid/hcedemo/MyHostApduService.java @@ -0,0 +1,39 @@ +package de.grundid.hcedemo; + +import android.nfc.cardemulation.HostApduService; +import android.os.Bundle; +import android.util.Log; + +public class MyHostApduService extends HostApduService { + + private int messageCounter = 0; + + @Override + public byte[] processCommandApdu(byte[] apdu, Bundle extras) { + if (selectAidApdu(apdu)) { + Log.i("HCEDEMO", "Application selected"); + return getWelcomeMessage(); + } + else { + Log.i("HCEDEMO", "Received: " + new String(apdu)); + return getNextMessage(); + } + } + + private byte[] getWelcomeMessage() { + return "Hello Desktop!".getBytes(); + } + + private byte[] getNextMessage() { + return ("Message from android: " + messageCounter++).getBytes(); + } + + private boolean selectAidApdu(byte[] apdu) { + return apdu.length >= 2 && apdu[0] == (byte)0 && apdu[1] == (byte)0xa4; + } + + @Override + public void onDeactivated(int reason) { + Log.i("HCEDEMO", "Deactivated: " + reason); + } +} \ No newline at end of file