How to debug NFC implementation for Android?

This question can be decomposed into several smaller tasks. The end result would be to set a breakpoint in the CFC C ++ implementation for the Galaxy Nexus device (Android 4.1) using a debugger such as gdb to check its internal state.

  • Can I replace the Galaxy Nexus device libraries with ones that contain debugging symbols?
  • Is it possible to use gdb to debug an Android device implementation in C / C ++?
  • Is it possible to cross-compile an NFC implementation for Android?
  • Are there any examples of someone trying something like this, maybe with a different library?

Update: Correcting the device and compiling Jellybean went well with some minor bugs. Actually, there are some very nice flags in makefile libnfc that provide extensive output for communication.

However, there is still a debugging problem. To debug libnfc (external / libnfc-nxp), I have to join the process using the library, which is most likely Nfc Manager (packages / apps / Nfc). To debug the application, I have to set the debuggable flag. If I rebuild Nfc Manager, the signature does not match the one already installed on the device, which means that adb install -r <file> will not work. adb uninstall com.android.nfc does not work either. Using a complicated method, just removing apk from /system/app creates an INSTALL_FAILED_SHARED_USER_INCOMPATIBLE error when I try to install a new one. Nfc is no longer working at the moment, and I had to double-check the stock image.

Any other ideas on debugging the libnfc library?

+6
source share
1 answer

In general, the answer is yes. The full implementation of NFC for Android is part of the Android Open Source Project . Answers to specific parts of your question:

  • Yes, you need to unlock the bootloader and start your device to mount the system partition in read / write mode, so you can replace the NFC library.
  • Yes, you should be able to remotely debug using gdb. However, I have never done this.
  • Yes, just download the Android source and compile the corresponding parts of the NFC stack. The relevant parts are in packages/apps/Nfc (NFC manager), external/libnfc-nxp (C library), frameworks/base/core/java/android/nfc (Java NFC API) and vendor/nxp (NFC chip firmware).
  • Yes, see, for example, How to debug an Android application using GDBSERVER? or https://www.google.com/search?q=remote+gdb+android . (This question may also be relevant: Remote debugging with Android emulator )
+10
source

Source: https://habr.com/ru/post/923792/


All Articles