feat: add magisk module
This commit is contained in:
parent
2f1f11d1bb
commit
a2c013b14f
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
||||
[submodule "KernelPatch"]
|
||||
path = lib
|
||||
path = apatch/lib
|
||||
url = git@github.com:bmax121/KernelPatch.git
|
||||
|
||||
31
Makefile
31
Makefile
@ -1,27 +1,6 @@
|
||||
ifndef TARGET_COMPILE
|
||||
TARGET_COMPILE = aarch64-none-elf-
|
||||
endif
|
||||
build_magisk:
|
||||
rm -f ./build/MagiskSamsungKBDOverride.zip
|
||||
cd ./magisk && zip -r ../build/MagiskSamsungKBDOverride.zip *
|
||||
|
||||
ifndef KP_DIR
|
||||
KP_DIR = ./lib
|
||||
endif
|
||||
|
||||
CC = $(TARGET_COMPILE)gcc
|
||||
LD = $(TARGET_COMPILE)ld
|
||||
|
||||
INCLUDE_DIRS := . include patch/include linux/include linux/arch/arm64/include linux/tools/arch/arm64/include
|
||||
|
||||
INCLUDE_FLAGS := $(foreach dir,$(INCLUDE_DIRS),-I$(KP_DIR)/kernel/$(dir))
|
||||
|
||||
objs := sam_hid_kbd_rem.c
|
||||
|
||||
all: sam_hid_kbd_rem.kpm
|
||||
|
||||
sam_hid_kbd_rem.kpm: ${objs}
|
||||
${CC} $(CFLAGS) $(INCLUDE_FLAGS) -O2 $^ -r -o $@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf *.kpm
|
||||
find . -name "*.o" | xargs rm -f
|
||||
build_apatch:
|
||||
$(MAKE) -C ./apatch sam_hid_kbd_rem.kpm
|
||||
|
||||
22
README.md
22
README.md
@ -1,21 +1,25 @@
|
||||
# KernelPatch / APatch - Android Generic BT Keyboard Fix
|
||||
# Magisk / KernelPatch / APatch - Android Generic BT Keyboard Fix
|
||||
|
||||
### Description
|
||||
|
||||
This is a [KernelPatch](https://github.com/bmax121/KernelPatch) / [APatch](https://github.com/bmax121/APatch) module used to fix an
|
||||
issue with the Samsung Galaxy Tab S7 on some kernels where a Bluetooth keyboard connects but fails to work.
|
||||
## Description
|
||||
|
||||
The underlying issue is that some cheap keyboards report their USB Vendor ID as `0x04E8` and Product ID as `0x7021`, which is the
|
||||
same as a Samsung Wireless Keyboard. This causes the Samsung HID driver to claim the device, which doesn't support the keyboard properly.
|
||||
|
||||
This patch blocks the Samsung driver from matching these devices and prevents custom quirks from being applied, allowing the generic HID driver to handle them instead.
|
||||
We implement both a KernelPatch / APatch module, as well as a Magisk module. The former is a more comprehensive fix that fully patches
|
||||
out the driver inside the Linux Kernel. The latter is a Magisk module that ignores special drivers while connecting to the device.
|
||||
|
||||
### Installation
|
||||
NOTE: The KernelPatch / APatch module will only work with APatch. The Magisk module will work for both.
|
||||
|
||||
Install the patch by copying the `sam_hid_kbd_rem.kpm` file to your device, opening APatch, and loading/installing the module.
|
||||
### APatch Installation
|
||||
|
||||
Install the patch by copying the `./build/sam_hid_kbd_rem.kpm` file to your device, opening APatch, and loading/installing the module.
|
||||
|
||||
### Magisk Installation
|
||||
|
||||
Install the patch by copying the `./build/MagiskSamsungKBDOverride.zip` file to your device, opening APatch or Magisk, and installing the module.
|
||||
|
||||
### Kernel Patch
|
||||
|
||||
You can also patch the kernel directly by applying the provided patch file `sam_hid_kbd_rem.patch`. At the time of writing this, the patch was
|
||||
You can also patch the kernel directly by applying the provided patch file `kernel.patch`. At the time of writing this, the patch was
|
||||
applied to the [LineageOS/android_kernel_samsung_sm8250](https://github.com/LineageOS/android_kernel_samsung_sm8250/tree/8acbe9760ef02f0d044c0f0ec1bb469fa383fb07)
|
||||
at hash `8acbe9760ef02f0d044c0f0ec1bb469fa383fb07`.
|
||||
|
||||
27
apatch/Makefile
Normal file
27
apatch/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
ifndef TARGET_COMPILE
|
||||
TARGET_COMPILE = aarch64-none-elf-
|
||||
endif
|
||||
|
||||
ifndef KP_DIR
|
||||
KP_DIR = ./lib
|
||||
endif
|
||||
|
||||
CC = $(TARGET_COMPILE)gcc
|
||||
LD = $(TARGET_COMPILE)ld
|
||||
|
||||
INCLUDE_DIRS := . include patch/include linux/include linux/arch/arm64/include linux/tools/arch/arm64/include
|
||||
|
||||
INCLUDE_FLAGS := $(foreach dir,$(INCLUDE_DIRS),-I$(KP_DIR)/kernel/$(dir))
|
||||
|
||||
objs := sam_hid_kbd_rem.c
|
||||
|
||||
all: sam_hid_kbd_rem.kpm
|
||||
|
||||
sam_hid_kbd_rem.kpm: ${objs}
|
||||
${CC} $(CFLAGS) $(INCLUDE_FLAGS) -O2 $^ -r -o ../build/$@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf ../build/*.kpm
|
||||
find . -name "../build/*.o" | xargs rm -f
|
||||
BIN
build/MagiskSamsungKBDOverride.zip
Normal file
BIN
build/MagiskSamsungKBDOverride.zip
Normal file
Binary file not shown.
6
magisk/module.prop
Normal file
6
magisk/module.prop
Normal file
@ -0,0 +1,6 @@
|
||||
id=samsung_kbd_override
|
||||
name=Samsung Keyboard Override
|
||||
version=1.0
|
||||
versionCode=1
|
||||
author=EvanReichard
|
||||
description=Fixes Samsung keyboard driver binding issues
|
||||
32
magisk/service.sh
Executable file
32
magisk/service.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
VENDOR_ID=04E8
|
||||
DEVICE_ID=7021
|
||||
DEV_DIR=/sys/bus/hid/devices/*:$VENDOR_ID:$DEVICE_ID*/
|
||||
IGNORE_PARAM=/sys/module/hid/parameters/ignore_special_drivers
|
||||
LOG="[samsung_kbd_override]"
|
||||
|
||||
# Wait Boot
|
||||
while [ "$(getprop sys.boot_completed)" != "1" ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Loop Service
|
||||
while sleep 1; do
|
||||
if [ ! -d $DEV_DIR ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ ! -d $DEV_DIR/driver ]; then
|
||||
if [ "$(cat $IGNORE_PARAM)" = "0" ]; then
|
||||
echo "$LOG driver unbound -> ignoring special drivers"
|
||||
echo "1" > $IGNORE_PARAM
|
||||
fi
|
||||
else
|
||||
if [ "$(cat $IGNORE_PARAM)" = "1" ]; then
|
||||
echo "$LOG driver bound -> restoring special drivers"
|
||||
echo "0" > $IGNORE_PARAM
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user