I use this batch file I made to keep things simple and quick:
https://github.com/Jon8RFC/nfcscreenoffpatcher/blob/master/container_setup.bat
You can do steps 1-2, then use the batch file.
- Install Docker, update WSL if instructed
- 🟥 do NOT click on restart when Docker prompts--close applications and use the start menu to restart! 🟥
- Download and unzip this repo
- Run in cmd
docker build --no-cache "C:\nfcscreenoffpatcher-master" -t patcher/patcher:latest
(builds, names, tags the image) - Run in cmd
docker run -p 8000:8000 --name patcher patcher/patcher
(binds the port, creates & starts the container) - Stop the container in Docker (unsure if it gracefully closes from cmd)
- Run in cmd
docker builder prune
(cleans up remnants/junk from any vestigial or failed builds) - Start the container in Docker whenever you want it
- (optional) Run in cmd
docker update --restart always patcher
(starts the container when you run docker)
- (optional) Run in cmd
File locations of WSL and Docker configs:
"C:\Users\%USERNAME%\.wslconfig"
"C:\Users\%USERNAME%\AppData\Roaming\Docker\settings.json"
You'd create .wslconfig yourself, maybe with:
[wsl2]
memory=4GB
processors=8
#swap=0 #swap memory max, defaults to 25% of memory size on Windows rounded up to the nearest GB
Edit the customize.sh file's PATCH_URL to your computer's IP running the Docker patcher, such as: http://192.168.1.30:8000
I like apktool and notepad++, but you can use dex2jar and something like JD-GUI (github) for a different and conglomerated viewing of the decompiled apk.
- Run in cmd
apktool d NfcNci.apk
, then edit files in text viewer - Run in cmd
d2j-dex2jar.bat -f -o NfcNci.jar NfcNci.apk
, then open in JD-GUI
⠀⠀ ⠀⠀ ⠀⠀
Start Lapwat's NfcScreenOffPie readme from 2019-11-15:
- adb
- apktool
- smali / baksmali v2.3+
- zip / unzip
- zipalign
- jarsigner
Enable ADB on phone in developper options.
# copy original sources
$ adb pull /system/app/NfcNci/NfcNci.apk
$ adb pull /system/framework/framework-res.apk
# create a backup for recovery
$ cp NfcNci.apk NfcNci_bak.apk
# decompile
$ apktool d -f NfcNci.apk -o NfcNci/
This is the part where you reverse engineer the source code of the app by modifying smali files.
For NfcNci, apply those changes.
Files to edit are located at:
- NfcNci/smali/com/android/nfc/NfcService.smali
- NfcNci/smali/com/android/nfc/ScreenStateHelper.smali
# load framework
$ apktool if framework-res.apk
# compile
$ apktool b -f NfcNci/ -o NfcNci_mod.apk
# sign
$ keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
$ jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore -storepass android NfcNci_mod.apk androiddebugkey
# align
zipalign -v 4 NfcNci_mod.apk NfcNci_align.apk
adb push NfcNci_align.apk /sdcard/
adb shell
# android shell
su
cd /system/app/NfcNci
busybox mount -o remount,rw $PWD
cp /sdcard/NfcNci_align.apk NfcNci.apk
chmod 644 NfcNci.apk
You can restore the original APK file at any time with those commands.
adb push NfcNci_bak.apk /sdcard/
adb shell
# android shell
su
cd /system/app/NfcNci
busybox mount -o remount,rw $PWD
cp /sdcard/NfcNci_bak.apk NfcNci.apk
chmod 644 NfcNci.apk
Java versions of smali files for reverse engineering
Big up to Lasse Hyldahl Jensen for his version for Android N
Understanding the signing process