[Magisk] Jon8RFC:
Unfortunately, it seems like something may have changed with android or play services.

Even after updating the smali directory support, nfcscreenoff stops working after a while on my Pixel 7 Pro.

POST EDIT

@ 2023-06-29T01:03-05:00 :

I'm figuring out some things (I'm very limited in knowledge). I'll share things once I answer a few questions, and hopefully someone will know where to go from there.

POST EDIT

@ 2023-06-30T00:33-05:00 :

So, The NFC scanning when the screen is off eventually stops working after a fresh boot, usually within 10-60 minutes.

I can re-enable NFCScreenOff functionality, when the screen is off, by running either of these sets of commands while the screen is off:

adb shell service call nfc 7 & adb shell service call nfc 8

adb shell svc nfc disable & adb shell svc nfc enable

But once the screen is turned on and then off again, it stops working again.

However, running this:

adb shell service call nfc 17

or in an android terminal:

su service call nfc 17

for some reason allows it to work for a while again, until it randomly stops working again within an hour. When the command is run, only if it's been many minutes since it was last run, "nfc service has stopped responding" pops up.

Before getting to that point, I had already rebooted numerous times and force stopped and cleared data of NFC Service.

I did find that the two nfc services are always, seemingly, still running:

adb shell service list ps | grep nfc

And don't change when stopping nfc manually or by "service call nfc 7" or "svc nfc disable".

So that's what I've found. I don't want NFC running all the time because it does, in fact, drain battery, even without using the module. Maybe Google changed something in an android update, or in play services, in an attempt to improve battery life by tinkering with NFC when the screen is off.

Unless there's a fix, I'll have a Tasker task running "service call nfc 17" every ~10 minutes whenever NFC is on, but there's the info if it's helpful to anyone.

POST EDIT

@ 2023-07-06T03:03-05:00 :

Running "service call nfc 17" seems to occasionally crash the phone. Not always, but after a while, it'll sometimes crash and get stuck in the bootloader and I have to manually reboot.

I've tried updating build tools to 34.0.0, apktool to 2.7.1 (built, since it uses google's smali & baksmali), smali & baksmali to google's latest version, dextools to the updated ThexXTURBOXx version, and it's the same result. The files do seem edited properly, but no different between using old tools or all updated tools. I've had to figure all of this out as I go, so I'm not sure what exactly is NOT working, or if it can even be fixed.

Seems like Android is desperately attempting to reduce battery usage. It works reliably for between 5-15 minutes, then doesn't. NFC works fine with the screen on, but not with the screen off unless the phone is restarted or one of those commands is run while the screen is off to temporarily get it working, or use nfc 17 to reset whatever it resets--the service? I have "require screen unlocked" toggled off, but maybe there is, in fact, something new Android is now doing to check if the screen is on/unlocked or it's pausing the service. There's something beyond what's tweaked for NFCScreenOff, which needs to be accounted for.

POST EDIT

@ 2023-07-06T07:11-05:00 :

It seems like

adb shell service call nfc 7 & adb shell svc nfc enable

is the way to go (nfc disable takes longer, and nfc 8 times out) if I made a more complex/battery draining tasker task run every time the screen turns on or turns off. "nfc enable" doesn't seem to "time out" except if the screen state changes...but that can happen from phone movements. So I may just disable that and see if I can adapt back to using the power button to turn on the screen for face unlock.

I really hope someone has an idea for how to handle this and "fix" it in the patcher.