yashsingh1/xdaforums huggingface dataset:
[Xperia Z1 Compact Android Development] munjeni:
I'm believing hce things is inside sony framework and apps, and it probably comunicate with hce trought i2c, I realy don't know what we need to do for nfc since I'm never used nfc. Today I have look into sony stock rom lib and I can see libnfc_nci.so which we don't have source for, even hal is seems the same like one which we use curently, I'm believing we have missing something, e.g. I have added this now:

+ frameworks/native/data/etc/android.hardware.nfc.hce.xml:system/etc/permissions/android.hardware.nfc.hce.xml \

+ frameworks/native/data/etc/com.nxp.mifare.xml:system/etc/permissions/com.nxp.mifare.xml \

+ libnfc_ndef \

It was missing. Building now and will see if nfc didn't crash. But it will not work I know since we don't use com.sonymobile.nfc_impl.jar
[Xperia Z1 Compact Android Development] hackintosh5:
Is the kernel currently using github.com/NXPNFCLinux/nxp-pn5xx or nfc-tools/libnfc? Could you build a build (ha) with the alternative lib? It might just work :D

EDIT: why don't you include the jar then? Sorry if silly question
[Xperia Z1 Compact Android Development] munjeni:
Thats not so simple, there is not just jar, there is libs, hal, app. We can't just use that since it was lolipop :) I have look into kernel module in stock rom, its so simple kernel module, have i2c and everything pn544 related in one just one .c file and one .h file. But don't know, maybe new build bring something, if not Ican't promise nfc since I never used nfc and realy no need it. I'm unsure if anybody have it working on custom rom, even z3 guys have it not working?
[Xperia Z1 Compact Android Development] hackintosh5:
So there will be build soon? When?
[Xperia Z1 Compact Android Development] munjeni:
If there is not much diferencie I will not publish new build until I see something better or diferent, need to test it first
[Xperia Z1 Compact Android Development] hahnjo:
I know of that one as I wrote in my initial message. But you wrote that you fixed some bugs that I want to take a look at. As per the GPL you are required to release exactly the kernel source that you used for the build!
[Xperia Z1 Compact Android Development] BokeB:
Calm down :laugh:
[Xperia Z1 Compact Android Development] hackintosh5:
https://android.googlesource.com/pl...oid/nfc/cardemulation/AidRoutingManager.java? Surely you can include this?
[Xperia Z1 Compact Android Development] bardagolkapote:
thank you!

Awesome build man! You gave a new life to my z1 compact.

Im using the 20170907 build. Is usb otg supported? Cant get my otg drive to be read
[Xperia Z1 Compact Android Development] TheCarFierce:
Originally used 20170907 ROM users can directly brush into the 0922 ROM ??
[Xperia Z1 Compact Android Development] munjeni:
Yes, but userdata will get wiped as per every build. I'm doing that just to be sure everybody installed clean rom (for potentionaly less bugs).
[Xperia Z1 Compact Android Development] munjeni:
Allready included! Problem is we need new kernel module (i2c one from intel) to be able to use new android nfc-nxp libraries and hal. Old kernel nfc module from nokia not going to work in our android with nfc hce. Curently I'm need some info about which hardware revision and model is on our z1c! Found some source codes and it is C3 pn544, curently I have no idea which revision z1c have, c1? c2? Or c3? Or something diferent? E.g. PN5441A2ET/C1xxyy . When we found that info we can start researching for the right source code, with guesing we can do nothing, thats waste of time.
[Xperia Z1 Compact Android Development] TheCarFierce:
Is to wipe those
[Xperia Z1 Compact Android Development] munjeni:
Mate, I have no free time to mess with gihub in time when I'm working hard fixing some bugs, I simply have no free time for it, I have life and I am not paid for this. Patience please! Open SuperLamic git and search comments, I allready pastebin some fixes on his git, just read coments! And again patience please, it will get merged soon.
[Xperia Z1 Compact Android Development] munjeni:
Recomended.
[Xperia Z1 Compact Android Development] GrishaGrelvin:
Camera

I have working stock Sony camera 2.0. From this thread

https://xdaforums.com/crossdevice-dev/sony-themes-apps/port-stock-camera-nougat-roms-t3628791, how to add screenshot?
[Xperia Z1 Compact Android Development] munjeni:
Sorry but my goal is having clean LineageOS without mods. My goal is to fix all remaining bugs and waste a less time with not important things. Curent task is:

1. do something with nfc (curently need info about which chip, model and revision we have on amami)

2. fix 3g/lte random switches

Everybody with info or idea is welcome.
[Xperia Z1 Compact Android Development] munjeni:
I have got stock ril working in our rom (with all dependency stock libs), but the same bug exist! So problem might be framework?
[Xperia Z1 Compact Android Development] hackintosh5:
Well done getting it working!:laugh::good:

Have you tried the NFC debug mode setting from the bacon thread?
[Xperia Z1 Compact Android Development] munjeni:
https://xdaforums.com/showpost.php?p=73956095&postcount=436
[Xperia Z1 Compact Android Development] hackintosh5:
Oh, the link error. I thought you meant the lack of hce. Have you tried the stock NfcService?

---------- Post added at 05:06 PM ---------- Previous post was at 05:03 PM ----------

In my opinion, guessing is not a waste of time. We might get it right!

---------- Post added at 05:07 PM ---------- Previous post was at 05:06 PM ----------

In my opinion, guessing is not a waste of time. We might get it right!
[Xperia Z1 Compact Android Development] munjeni:
We can't get it right in case we gues! See https://github.com/opnfv/kvmfornfv/blob/master/kernel/drivers/nfc/pn544/Kconfig first option. We curently have and use that nfc from first option which is legacy curently. Modern platform didn't use that old nokia nfc implementation.

this is which we use:

config NFC_PN544
tristate
select CRC_CCITT
---help---
NXP PN544 core driver.
[COLOR="Red"]This is a driver based on the HCI NFC kernel layers and
will thus not work with NXP libnfc library[/COLOR].

But we curently using libnfc-nxp source from external/libnfc-nxp which is confusing at the start.

We need this https://github.com/NXPNFCLinux/nxpnfc_android_nougat , look into end of that page, it describes what is need, there is patches, kernel module, android hal, android lib, device tree... etc, so all in one place. But thats for NFC controllers (PN7120, PN7150), I didn't found curently anything for legacy pn544, its like we can't get it working anyway. Didn't tried stock rom nfc since curently I have no idea at least which chip and revision of the chip we have on amami. We can't use nfc things from totaly diferent nfc controler, no chance that it will work, thats waste of time. Thats why we need to know for sure what chip and chip revision we have, thats a first thing which we need to know.
[Xperia Z1 Compact Android Development] munjeni:
Option is to decompile stockrom nfc apk, nfc framework, we can use online decopilers like http://www.javadecompilers.com/apk , it decompiles that and give us source code, so at the start we need to analyse these decompiled things and look what sony does on it. Seccond step is using stock rom libs and hal. I allready compared stock rom hall and didn't found big diferencie, its almost the same. About libnfc,so, libnfc-jni.so and some more probably we can use with some help of libshims. Again, to get it working first thing which we need is to decompile framework and apk from stock rom and compare with curent rom source code, but I have no free time messing with nfc since I never used it, realy no need it, No body got it working starting from z1 to z3, I' believing we can't get it working too.
[Xperia Z1 Compact Android Development] munjeni:
And one more thing, we don't have new nfc fw, questionable is how can we get new hals on an old fw! Where we can get new fw for an old pn544? And how can we search for fw when we have no idea which chip we have. :) Here is some more explanations https://xdaforums.com/showthread.php?t=2573842&page=10
[Xperia Z1 Compact Android Development] munjeni:
Eh found now in stock rom inside /system/vendor/firmware file caled libpn_fw_c3.so so thats indication that we have pn544 C3 version? :) Can you tell me, does D5503_14.4.A.0.108 stock rom have working hce?
[Xperia Z1 Compact Android Development] dmgZero:
There is information that different phones have the NFS chips from different vendors. Here is the program. It shows the vendor. There you can go to the section "About".

Anybody can upload here this information to compare?
[Xperia Z1 Compact Android Development] r100:
Something is off with the mobile radio. Before I encountered the erratic LTE/3G switching in my home country. Right now I'm abroad and using the latest ROM, but it's just not able to connect to any network whatsoever.. I enabled the roaming option, but it still does not connect. If I manually search for networks, the first time it shows the available providers, but can't connect (that's the error message). If I manually search a second time it shows this message again and doesn't display any available provider anymore. Only after a reboot it's able to search for providers again.

Hope this helps in any way, I'm back on stock ROM for now.
[Xperia Z1 Compact Android Development] munjeni:
Yes, our ril definitelly have problem! Hope we figure out. Did anybody ask in honami thread if z1 have the same problem? Or maybe in z3? I'm believing z1 to z3 have the same isue?

I'm back to stock rom too, need to find some more info about nfc. Acording to this https://xdaforums.com/showpost.php?p=71002181&postcount=183 in case we realy have c3 revision, than our nfc is PN544 C3 (PN65O) --------> firmware 1.41 ??
[Xperia Z1 Compact Android Development] munjeni:
One more info from stock rom .108 :

I/NfcService( 1670): Enabling NFC
D/SonySWEffect( 494): Unsupported frame count 240
D/NFCJNI ( 1670): Start Initialization
W/linker ( 1670): libpn544_fw_c3.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/NFCJNI ( 1670): NFC capabilities: HAL = a050000, FW = b10125, HW = 620003, Model = 1, HCI = 1, Full_FW = 1, Rev = 37, FW Update Info = 0
D/NFCJNI ( 1670): phLibNfc_SE_GetSecureElementList()
D/NFCJNI ( 1670):
D/NFCJNI ( 1670): > Number of Secure Element(s) : 0
D/NFCJNI ( 1670): phLibNfc_Mgt_MultiEmulation_Config returned 0x000d[NFCSTATUS_PENDING]
I/NFCJNI ( 1670): NFC Initialized
D/NdefPushServer( 1670): start, thread = null
D/NdefPushServer( 1670): starting new server thread
D/NdefPushServer( 1670): about create LLCP service socket
D/NdefPushServer( 1670): created LLCP service socket
D/NdefPushServer( 1670): about to accept
I/SmartcardService( 2444): NFC Adapter is ON. Checking access rules for updates.
I/SmartcardService( 2444): Handle msg: what=2 nbTries=5
I/SmartcardService( 2444): Initializing Access Control
D/ExtendedUtils( 494): extended extractor not needed, return default
D/ExtendedUtils( 494): extended extractor not needed, return default
D/ExtendedUtils( 494): extended extractor not needed, return default
D/NfcService( 1670): NFC-C ON

NFC SmardCard info 2.1.2.15.170

android version: kitkat 4.4.4 - api 19

nfc features: nfc hw: yes

nfc controler: nxp

mifare support: yes

p2p protocol: snep

hce support: yes - android.hardware.nfc.hce

==========================================

Todo: from ril things in stock rom

Prefered network mode on stock rom: wcdma only, gsm only, wcdma prefered/gsm, lte prefered/wcdma/gsm , thats diferent than prevered network mode in los. Need more research for this on stock framework and stock settings app.
[Xperia Z1 Compact Android Development] hackintosh5:
I can confirm hce works on latest (lollipop 21) stock recently upgraded to this ROM
[Xperia Z1 Compact Android Development] dmgZero:
I Installed D5503_14.4.A.0.108.

It seems that everything works.

If earlier(on Nougat) in AndroidPay wrote that payments through the NFC are not supported.

On stock .108 there is no such message. Now - shopping guide.:)

BTW in Nougat was:

nfc controler: Broadcom

:confused:
[Xperia Z1 Compact Android Development] munjeni:
Yes, I'm on stock rom too and everything works, Didn't tried stock rom nfc libs on los, first thing which I will do soon is to decompile (smali) all framework and apps on my ubuntu and grep all for all string ocourance of NFC, Nfc, nfc and collect list of the files contain that strings. If somebody want to help and have free time for that please do that!
[Xperia Z1 Compact Android Development] munjeni:
On stock rom, when I set prefered network mode to lte prefered/wcdma/gsm (last option) I'm getting excatly the same random switches like we have now in los!

Also if I set wcdm,a only the same!

So guys I think we don't have bug in los on ril. Even I didn't noticed any mobile network problem in los even when icon randomly switches from lte to 3g!
[Xperia Z1 Compact Android Development] r100:
Small update on the roaming issue: using your rom with the 'stock' kernel (so basically the second newest version of the rom) the problem is gone. It immediately connected to the best foreign provider. For the mobile data I needed to manually set the APN, but now it works just fine.
[Xperia Z1 Compact Android Development] hahnjo:
https://www.xda-developers.com/xda-developers-and-the-gpl/
[Xperia Z1 Compact Android Development] hackintosh5:
Don't decompile the KitKat, decompile the lollipop, there is more chance of it working easier as it is newer!
[Xperia Z1 Compact Android Development] zlata:
What is wrong with you?
[Xperia Z1 Compact Android Development] munjeni:
[MENTION=4565411]hahnjo[/MENTION] , updated first post per your reguest. I'm thinked to give you direct link to changeset but I will not, If you need it open link and search, all is on git! Android changes will stay closed source as every tool from me, only my friends can see closed source.
[Xperia Z1 Compact Android Development] munjeni:
Yes sure, if it will realy need I will try lolipop blobs, but I'm planing just to compare stock nfc with one which we use.
[Xperia Z1 Compact Android Development] munjeni:
Can you tell me which version is ok, you mean lineage-14.1-20170922-munjeni-amami.zip one with Lineage kernel?
[Xperia Z1 Compact Android Development] munjeni:
Yes yes yes! I have decompiled nfc.apk from stock rom and also com.sonymobile.nfc_impl.jar, found this:

public class NfcDiagTest extends NfcDiagTestBase {
private static final boolean ANTENNA_SELF_TEST_ENABLED = false;
private static final int BB_LIMIT_TIME = 100;
private static final String NFC_SWP_NO_FAILURE = "00";
private static final String NFC_SWP_PMUVCC = "01";
private static final String [COLOR="Red"]PN65O_VARIANT[/COLOR]_CHIPSET_KEY = "B1";
private boolean mIsChipHW[COLOR="Red"]PN65O[/COLOR] = ANTENNA_SELF_TEST_ENABLED;

Acording to that info, in most case we have pn544 C3 revision, and variant pn650. Lets search google! :) All finds is welcome!
[Xperia Z1 Compact Android Development] munjeni:
Acording to this link https://elinux.org/NFC_driver_notes

Devices that use the NXP PN65

HTC One (and One X, One X+, and One XL)[5]

Nexus 7 Tablet

Samsung Galaxy S III[6]

Sony Xperia Z[7]

So seems it confirms that we need NXP PN65
[Xperia Z1 Compact Android Development] munjeni:
I'm researching whole day figuring out what we need to enable hce, nothing found. Only this post which explains everything about our old nxp https://xdaforums.com/showpost.php?p=64326467&postcount=179

So google dropped hce for old nxp stack, thats clear. What we can do? Option is getting commit in aosp tree when it was dropped! I am search whole day and didn't found that commit. If we even found it it would be so hard reverting whole things which google implemented for AID routing.

We have 3 options. 1. to revert google commits (soo hard). 2. To use nci things from https://github.com/CyanogenMod/android_packages_apps_Nfc (to get idea compare folder nci and folder nxp, not a much big diferencie, only need some hardcoding) 3. To somehow reuse cm9 patch.

I have tried something, if I add android.hardware.nfc.hce.xml to the /system/etc/permissions hce is not working because of the missing libnfc_nci_jni which is from nci stack , more idea you can get looking into this https://github.com/CyanogenMod/android_packages_apps_Nfc , there is two stacks, nci and nxp, we are on nxp now and I think we can't use nci on our old nxp nfc , this describes situation completelly developers.com/showpost.php?p=64326467&postcount=179 . I think hacking is need like it was done here:

On an old cm9 there was 2 patches for hce on nxp stack:

- https://github.com/CyanogenMod/andr...mmit/d41edfd794d4d0fedd91d561114308f0d5f83878

- https://github.com/CyanogenMod/andr...mmit/34f13082c2e78d1770e98b4ed61f446beeb03d88

I have no free time for nfc sorry. Will try to fix fm stereo mode, thats priority by now, if somebody have free time for nfc hce it would be great having it too.

Edit:

And oh we can't use stock nfc things, it not going to work apsolutly.
[Xperia Z1 Compact Android Development] hackintosh5:
What about with stock kernel?

EDIT: what about stock nfc half on stock kernel?
[Xperia Z1 Compact Android Development] munjeni:
Kernel is no problem! Problem is described in a post above! Problem is booth! For me its so hard getting things, simple have no free time for it, and to be honest I not use nfc so realy no need it. Previous post is updated!
[Xperia Z1 Compact Android Development] r100:
Roaming works on 20170907, but not on 20170922.

Don't forget to spend your valuable free time on something else, or this ROM might become a headache eventually :highfive:
[Xperia Z1 Compact Android Development] chris2017@xda:
Thanks for testing roaming, r100. On my Z1 Compact*, automatic roaming is not the problem, but manually choosing a (foreign) network provider. I live close to the Swiss border and connecting to the Swiss network without noticing results in 1.5 EUR/min roaming fees :(

I am happy to test and upload logs if this issue affects more people.

* tested: lineage-14.1-20170907-munjeni-amami, lineage-14.1-20170922-munjeni-amami, aicp nightly builts.

On ParanoidAndroid 6.03 and a self compiled AOSP ROM manual roaming worked but camera was a disaster.
[Xperia Z1 Compact Android Development] munjeni:
Can it be some missing/wrong overlay value? Can you decompile framewrok-res from working aosp rom and from curent rom and do some more research in res?
[Xperia Z1 Compact Android Development] munjeni:
Some progress on hce :) Still not working but it didn't crash anymore. This is a diff:

diff --git a/src/com/android/nfc/cardemulation/AidRoutingManager.java b/src/com/android/nfc/cardemulation/AidRoutingManager.java
index 96225b7..de67704 100644
--- a/src/com/android/nfc/cardemulation/AidRoutingManager.java
+++ b/src/com/android/nfc/cardemulation/AidRoutingManager.java
@@ -68,16 +68,16 @@ public class AidRoutingManager {
// Easy look-up what the route is for a certain AID
HashMap<String, Integer> mRouteForAid = new HashMap<String, Integer>();

- private native int doGetDefaultRouteDestination();
- private native int doGetDefaultOffHostRouteDestination();
- private native int doGetAidMatchingMode();
+ //private native int doGetDefaultRouteDestination();
+ //private native int doGetDefaultOffHostRouteDestination();
+ //private native int doGetAidMatchingMode();

public AidRoutingManager() {
- mDefaultRoute = doGetDefaultRouteDestination();
+ mDefaultRoute = 0;
if (DBG) Log.d(TAG, "mDefaultRoute=0x" + Integer.toHexString(mDefaultRoute));
- mDefaultOffHostRoute = doGetDefaultOffHostRouteDestination();
+ mDefaultOffHostRoute = 2;
if (DBG) Log.d(TAG, "mDefaultOffHostRoute=0x" + Integer.toHexString(mDefaultOffHostRoute));
- mAidMatchingSupport = doGetAidMatchingMode();
+ mAidMatchingSupport = 20;
if (DBG) Log.d(TAG, "mAidMatchingSupport=0x" + Integer.toHexString(mAidMatchingSupport));
}

the similar way we can fix the rest by implementing some things from nci stack into our nxp stack, if you have idea how let me know!
[Xperia Z1 Compact Android Development] chris2017@xda:
Unfortunately, I am not a programmer. I have simply followed the simple "AOSP compile your own rom instructions" without understanding anything. Sorry for not being of any help at all.
[Xperia Z1 Compact Android Development] munjeni:
Can you please give me framewrok-res.apk from the working rom?
[Xperia Z1 Compact Android Development] hackintosh5:
Which is which in the diff???
[Xperia Z1 Compact Android Development] munjeni:
What you mean? Didn't understand your question...
[Xperia Z1 Compact Android Development] chris2017@xda:
Roaming issue: manual selection of network operator does not work in roaming

Description of issue:

SIM card: Austrian provider: bob.at

After installing lineage-14.1-201709xx-munjeni-amami, and first boot, the SIM card registers automatically with vodafone.de (German network operator).

Then, I select Settings -> … More -> Cellular networks -> Network operators -> and press the manual search icon.

Phone will search for network operators for ~1min. Then, a list of available network operators is displayed.

When I try to select any other network operator (in the attached log file: telekom.de), I get an error message: “Can’t connect to this network right now. Try again later”.

The same will happen with my German SIM card when I try to register on a Swiss network.

Remark: With Sony ROM Build number : 14.6.A.1.236, I can select any network operator, Swiss or German, with my Austrian SIM card without problem.

In the log file, a “Fatal signal 11 (SIGSEGV), code 1” error appears after SET_NETWORK_SELECTION_MANUAL.

For orientation in the log files: approx times of search / network operator selection.

LINEAGE: start searching (19:53:30) -> display network operator list (19:54:45) -> Select network operator (19:55:00)
[Xperia Z1 Compact Android Development] hackintosh5:
Have you tested a MiFare tag? Was not working in last build, so if yes then real progress made!

---------- Post added at 07:16 PM ---------- Previous post was at 07:14 PM ----------

Sigsegv sometimes occurs when you use binaries designed for a different kernel version. I learnt this the hard way:laugh:
[Xperia Z1 Compact Android Development] munjeni:
If thats not working in latest build it not worked in any other. I didn't done any changes on nfc until today.
[Xperia Z1 Compact Android Development] munjeni:
Thats great that you provided more details and log, thanks alot! Can you please give me /data/tombstones/tombstone_08 file?
[Xperia Z1 Compact Android Development] hackintosh5:
Diff is between stock and los, but which one is a/system... And which is b/...

---------- Post added at 07:47 PM ---------- Previous post was at 07:46 PM ----------

Yes, but after today does mifare tag work?
[Xperia Z1 Compact Android Development] chris2017@xda:
Thanks for looking into the problem, Munjeni!

I hope that's the correct file. Unfortunately, I tried to gather more info with the AOSP ROM, so I had to flash back your ROM and get the tombstone file.
[Xperia Z1 Compact Android Development] munjeni:
Didn't tried mifare, I dont use nfc and I have no idea what mifare is :)

Diff is not related to stock rom, diff is related to los changes I done to get fix for crash when I enable hce feature.
[Xperia Z1 Compact Android Development] munjeni:
I found some posts in xda related to same problem and it was fixed with this commit review.cyanogenmod.org/#/c/25898/ , curently I am unable to open that link, don't know why
[Xperia Z1 Compact Android Development] chris2017@xda:
looks like the cyanogenmod server is not up anymore. The review should be available in:

https://archive.org/details/CyanogenWeb24121601

I'll try to download it and post the info, ok?
[Xperia Z1 Compact Android Development] sugnuf:
That commit (and all repositories) was exported to los, after cm bankruptcy: https://review.lineageos.org/#/c/21957/.
[Xperia Z1 Compact Android Development] munjeni:
Wau thanks alot! How did you found that commit? I'm tried everything, in cache ...etc on google and found nothing related to review.cyanogenmod.org/378068 :) Yes that commit you gaved is excatly for manual network selection, I remembered that many years ago when I used that commit for the first time to fix manual selection :)