Magisk-Modules-Repo / NfcScreenOff

Read NFC tags when screen is off. Disable NFC tagging sound.
https://forum.xda-developers.com/apps/magisk/module-nfcscreenoff8-t4034903
48 stars 9 forks source link

Make the module truly systemless #1

Closed androidacy-user closed 4 years ago

androidacy-user commented 4 years ago

There is absolutely no reason you should be directly modifying a system partition with a magisk module, which on some devices isn't even possible (eg EROFS, dynamic partitions, or ext4 dedup).

This could have serious implications for SafetyNet and is much harder to revert if something goes wrong m

If magic mount is for some strange reasons not able to replace the APK, you're doing something wrong.

In your module, copy the APK to $MODDIR/system/app/NfcCi/NfcCi.apk (sorry if the name is incorrect) and magisk will handle it correctly for you! Modifying an APK after post-fs-data stage is also inadvisable.

Have you tested relying solely on magic mount?

I eagerly await your response!

lapwat commented 4 years ago

Great to hear your feedback.

Yes it has been tested with magic mount already.

Sadly, the only way I could make it work was by:

  1. Mounting the original APK
  2. Let NFCService
  3. Replace the original APK with the modded APK
  4. Restart NFCService by killing its process

I was surprised I could do that but I cannot think about a better idea. Are you thinking about implementing security fixes in Magisk that will prevent this behavior?

androidacy-user commented 4 years ago

So do you actually inject the APK into /system or do you just bind mount it at a convenient time? Have you tried letting magisk do the mount, and just restarting the NFC service in service.d scripts?

androidacy-user commented 4 years ago

Have you considered not using the standard module structure so as not to let magisk do the bind mount, but do it yourself in service.sh? After a restart, it'd achieve the same effect, and be truly systemless (and work on more devices therefore)

androidacy-user commented 4 years ago

Eg put the APK in $MODDIR/NfcCi/NfcCi.apk Then on service.sh: mount --bind $MODDIR/NfcCi/ /system/app/NfcCi

Exact syntax may be incorrect but should do the trick.

Let me know if it works!

lapwat commented 4 years ago

I succeeded to use the mount --bind method: https://github.com/Magisk-Modules-Repo/NFCScreenOff/commit/945a22311b0e9e554e67bde58e229f805ca26705

Does it satisfy your requirements?

EDIT: Still does not work if I don't load original APK beforehand...

androidacy-user commented 4 years ago

I succeeded to use the mount --bind method: https://github.com/Magisk-Modules-Repo/NFCScreenOff/commit/945a22311b0e9e554e67bde58e229f805ca26705

Does it satisfy your requirements?

EDIT: Still does not work if I don't load original APK beforehand...

Have you tried inserting like a 10sec delay then bind mounting?

Rn I'm on a device your original wouldn't work - OnePlus 7t, so dynamic partitions + ext4 dedup

lapwat commented 4 years ago

Yes, I have tried those 4 combinations:

On Wed, Apr 22, 2020 at 3:18 PM Alexia notifications@github.com wrote:

I succeeded to use the mount --bind method: 945a223 https://github.com/Magisk-Modules-Repo/NFCScreenOff/commit/945a22311b0e9e554e67bde58e229f805ca26705

Does it satisfy your requirements?

EDIT: Still does not work if I don't load original APK beforehand...

Have you tried inserting like a 10sec delay then bind mounting?

Rn I'm on a device your original wouldn't work - OnePlus 7t, so dynamic partitions + ext4 dedup

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Magisk-Modules-Repo/NFCScreenOff/issues/1#issuecomment-617773897, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV6647I75ZSW2YPPW64CELRN3VEDANCNFSM4KI6A25Q .

lapwat commented 4 years ago

Can we consider that the module is systemless now that I used the mount command ?

androidacy-user commented 4 years ago

If it works 100% without needing to mess with /system ofc it is