Skip to content

Commit

Permalink
🧱 Add SmartTapHCE service
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamparter committed Jul 14, 2024
1 parent 388092f commit a50b26c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@
android:supportsRtl="true"
android:theme="@style/Theme.SmartTap"
tools:targetApi="31">
<service
android:name=".SmartTapHCE"
android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
</intent-filter>
<meta-data
android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="@xml/apduservice" />
</service>
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.SmartTap">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
18 changes: 18 additions & 0 deletions app/src/main/java/dev/riverside/credit/SmartTapHCE.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.riverside.credit

import android.nfc.cardemulation.HostApduService
import android.os.Bundle

class SmartTapHCE : HostApduService() {
override fun processCommandApdu(commandApdu: ByteArray, extras: Bundle): ByteArray {
// TODO: Handle the APDU command here
// (return a response APDU according to the commandApdu received)
return byteArrayOf()
}

override fun onDeactivated(reason: Int) {
// TODO: Handle deactivation here
// (this method will be called whenever the NFC link is deactivated or lost)
}
}

2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@
libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus
vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim.
</string>
<string name="service_name">Smart Tap</string>
<string name="aid_group_description">Lorem Ipsum</string>
</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/xml/apduservice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/service_name"
android:requireDeviceUnlock="false">
<aid-group
android:description="@string/aid_group_description"
android:category="payment">
<aid-filter android:name="F0010203040506" />
</aid-group>
</host-apdu-service>

0 comments on commit a50b26c

Please sign in to comment.