This post is part of the Infineon Blockchain Starter Kit road test.
Blockchain - outside of the bitcoin context - is new to me.
Follow along with me on this path to learn the technology....
Let's dive into the example Android App "coinfinity". Look at the sources. And set up a debug session with a pysical Android smartphone. |
I'm documenting the steps I used to run the demo application, with support for breakpoints, watching variables and stepping-through-source-code.
For many apps, you can use a software telephone emulator. I couldn't find one that supports NFC development.
Running the debug session on a real phone with NFC works. That's the way I'll go here.
Install Android Studio
I'm using the latest version available from the Android Developers area.
I've used the full install, for my OS (Windows 10 - 64 Bit).
I made a change in the configuration after the install, to choose a good place to store virtual Android emulators:
File -> Settings -> Appearance & Behavior -> System Settings -> Android SDK -> Android SDK Location -> Edit
The install takes some time. meanwhile, you can:
Enable Developer Mode on your Android Phone
You'll never find how to do that by scrolling through the telephone settings. It's hidden.
I followed these instructions: Run apps on a hardware device.
Once you have unlocked developer access, go to Developer Options in the Settings app and enable USB debugging.
If the Stay Awake option is available, it's good to set it during the debug activities.
Get the Example App Sources
The GitHub url is https://github.com/Infineon/BlockchainSecurity2Go-Android .
There are several options. You can download it as a ZIP file from GitHub, clone it with GIT or use the Android Studio menus to fetch the project from GitHib.
That last option is the simplest.
VCS -> Checkout from Version Control -> Git.
Then enter the URL, and click Clone.
This will download project and source files and prepare the Android Image.
If you use one of the other options, you can open the project from the location where you downloaded / cloned the repository via File -> Open ...
The result is the same. Android opens your project. And it's ready to run.
That can be a first test: try to load the app to your phone and run it:
This will load and run the application. Not in Debug, but in Run mode.
But there's a first interesting bonus: you can see the application log in Android Studio: the first evidence of the traffic caused by tapping a Security 2Go card on an NFC device.
Debug a Real World Activity: Read one of the Public Keys of a Card
Now the real thing. Let's put a breakpoint on the part of the source where the app uses the NFC module to read one of the keys.
The public key is read in class co.coinfinity.infineonandroidapp.infineon.NfcUtils.
There, in the method readPublicKeyFromCard(), set a breakpoint on the following line:
// send apdu GetKeyInfoResponseApdu resp = (GetKeyInfoResponseApdu) tranceive(card, apdu, "GET KEY INFO");
Then, instead of using the Run button, click on the Android Robot icon. That's the Debug button.
Your telephone will pop up a message that it's waiting for the debug connection, then starts the app.
Select the Key Index you want to read in the app (default is Key 1.
Then tap and leave one of the cards from the Security 2Go kit on your phone. The breakpoint is reached.
Use the Step icon to execute the tranceive() call.
You can now inspect the value returned by the call.
All exciting stuff !
Top Comments