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 0000000..6ae570b Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ 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