external-nfc-api icon indicating copy to clipboard operation
external-nfc-api copied to clipboard

Android-x86 integration

Open dadreamer opened this issue 6 years ago • 10 comments

Hello, Thomas!

Have you tried to integrate External NFC Reader Service into any Android-x86 build to get NFC working "out-of-box"? I have ACR1281U-C1 reader and I'd like to use it under VirtualBox guest w/ all the capabilities including HCE. Do you have some guide or instructions for how anyone could build Android-x86 from the sources along with your service? Or maybe you're planning to release one?

dadreamer avatar Jan 29 '18 08:01 dadreamer

I think, I could donate for this project to start up working on it. And if you're interested in it, ofc.

dadreamer avatar Feb 24 '18 12:02 dadreamer

I've not tried Android-x86 so far. You want an app / service which provides native NFC Android-x86?

skjolber avatar Apr 06 '18 19:04 skjolber

You want an app / service which provides native NFC Android-x86?

Yes, I imagined External NFC Reader Service running on Android-x86 instead of a built-in Nfcservice (NfcNci) and capable to process NFC-related requests from any third party app, that could be installed onto Android-x86 system. As I'm working in VirtualBox, I can pass-through an external USB reader from the host into Android-x86 guest. It's working pretty well and I'm able to use your tools to configure the reader and test it out. But when I run some app, that requires NFC or HCE, it states that NFC service is disabled and refuses to work. When I activate Nfcservice in a custom build, the app says that NFC reader is turned off. My plan was to "redirect" those requests into your service somehow or replace Nfcservice with External NFC Reader Service completely. That leads to complete or partial rewrite of Nfcservice code and maybe to tweaking your service as you said earlier. If you're going to take a closer look at it, here's the thread on Android-x86 forums with some info about the native service activation.

dadreamer avatar Apr 07 '18 15:04 dadreamer

Yeah the main problem is the native NFC service, one needs root permission to replace it. This line on NfcAdapter.getDefaultAdapter():

NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);

must result in our service somehow. I guess the best would be to support multiple implementations, i.e. making the service lookup above configurable at build- or runtime; perhaps per application even.

skjolber avatar Apr 09 '18 16:04 skjolber

one needs root permission to replace it

AFAIK, a year ago or so a common Android-x86 target was not rooted "out-of-box". I don't know, how it goes now, but you may switch to CM targets, which should be pre-rooted. Well, there are various workarounds to root an already built images, e.g. this one, but I think, we don't need it. Of course, you may add Superuser/SuperSU support to the build specs and make the rooted build. But try CM first. There's Bliss-x86 also, which is 100% rooted, has GApps support etc. I tried to build it in the past and it works just fine. When building, select -eng or -userdebug variant (eng is even better, because it is an engineering build and has all the debugging tools to see the most logs about errors and warnings).

I guess the best would be to support multiple implementations, i.e. making the service lookup above configurable at build- or runtime; perhaps per application even.

I'm unsure for how to "replace" native NFC service with External NFC Reader Service at the run-time (even with root rights). But when you make a custom build, you're able to alter any files there, so that should not be a big problem. And it might be accomplished in a number of ways: as a tweaked service + custom system image (iso) or maybe as an app package (like The Open GApps Project) + instructions for the end users for how to include it in the build or something else. (I don't know, which way is prefferable here, given that your service is paid-based, so the resulting iso should be also.)

dadreamer avatar Apr 10 '18 15:04 dadreamer

Just had some free time and tried both android-x86_64-7.1-r1.iso and cm-x86_64-13.0-r1.iso. It appears, that superuser access and GApps are built-in now. That's awesome, I think. In CM you need to activate Developer Settings to reach to root access settings, but in common Android even this is not necessary. Still don't know how it goes when speaking about custom builds, but try to check that later.

dadreamer avatar Apr 18 '18 17:04 dadreamer

Tonight I've got my custom build done (it took several days 'cause I was using VM to compile). I chose Oreo 64-bit branch as it's the recent version. Now I see that Superuser app and its binaries are already integrated into the build, so any app can gain root access. GApps are not integrated though, so it has to be done by the maker.

Can I help with this somehow else?..

dadreamer avatar Apr 30 '18 21:04 dadreamer

@dadreamer I guess now you have some more to go on, I've open-sourced the rest of the project.

skjolber avatar Oct 03 '19 22:10 skjolber

Thanks! Although I have these sources for a while and still work on the task from time to time. Does that also mean that the GPlay apps will be free-of-charge? I expect some more developers would participate into this adaptation now.

dadreamer avatar Oct 04 '19 06:10 dadreamer

@dadreamer well yes, its all open source - apache 2.0. The play store app itself is among the code.

skjolber avatar Oct 04 '19 10:10 skjolber