Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
Is now very stable and runs for days without any problems
Also added a debug mode that can be flashed as another module
  • Loading branch information
xarantolus committed Feb 6, 2021
1 parent 8c367c3 commit b7fafbf
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Since this is a [Go](https://golang.org/) program, compiling the code should be
If that's the case, you can run...
* [`build.sh`](build.sh) to build the program
* [`deploy.sh`](deploy.sh) to build the program and push it to your phone (if it has an `/sbin` directory, you can now use it from the command line)
* [`build-module.sh`](build-module.sh) to package this program in a Magisk Module you can install from Magisk Manager. It will run `backtap` on boot, which is exactly what I wanted.
* [`build-module.sh`](build-module.sh) to package this program in a Magisk Module you can install from Magisk Manager. It will run `backtap` on boot. To build a debug version that creates a log file at `/cache/backtap.log`, you can pass `-debug` to this script as first parameter.

If not, you have to look into what the `GOARCH` environment variable does and then edit `build.sh` to use the correct value for your phone.

Expand Down
32 changes: 30 additions & 2 deletions build-module.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

set -e

# We just build the executable
Expand All @@ -10,8 +12,34 @@ mv backtap module/backtap/system/bin/backtap

cd module/backtap

ZIP_NAME="MagiskModule-backtap.zip"

if [ "$1" == "-debug" ]
then
echo "Building in debug mode"

ZIP_NAME="MagiskModule-backtap-debug.zip"

# Add file to enable debug mode (see service.sh)
touch "DEBUG"
# Read module props file before
FILE_BEFORE=$(<module.prop)

# exit_cleanup resets all of them on exit
exit_cleanup() {
rm -f DEBUG
echo "$FILE_BEFORE" > module.prop
}
trap exit_cleanup EXIT

# Mark version as debug version
sed -i -Ee 's/version=(.*)/version=\1-debug/g' module.prop
fi

# remove the old packed module, if possible
rm -f ../../MagiskModule-backtap.zip
rm -f "../../$ZIP_NAME"

# and create the new one
zip -r ../../MagiskModule-backtap.zip .
zip -r "../../$ZIP_NAME" .


4 changes: 2 additions & 2 deletions module/backtap/module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=backtap
name=backtap
version=v0.16
versionCode=00016
version=v1.0
versionCode=00100
author=xarantolus
description=Enables several gestures when tapping the fingerprint sensor of a Xiaomi Mi Mix 2
17 changes: 14 additions & 3 deletions module/backtap/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# This script runs on boot. Here we can start our service
MODDIR=${0%/*}

echo "Waiting for user to unlock/decrypt phone" > /cache/backtap.log
# Log debug message
if [ -f "$MODDIR/DEBUG" ]; then
echo "Waiting for user to unlock/decrypt phone" > /cache/backtap.log
fi

# Wait until boot & decryption finished
until [ -d /sdcard/Download ]
Expand All @@ -17,8 +20,16 @@ pgrep zygote > /dev/null && {
done
}

# Make backtap executable in case it isn't
BTPATH="/system/bin/backtap"

chmod +x "$BTPATH"

nohup "$BTPATH" -debug >>/cache/backtap.log 2>&1 &

if [ -f "$MODDIR/DEBUG" ]; then
# Start in debug mode and log to cache directory
nohup "$BTPATH" -debug >>/cache/backtap.log 2>&1 &
else
# Start in normal mode
nohup "$BTPATH" &
fi

0 comments on commit b7fafbf

Please sign in to comment.