diff --git a/CMakeLists.txt b/CMakeLists.txt index 8335c14..47acc30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.12) project(RealmeGPSL5Enabler - VERSION "0.0.1" + VERSION "0.0.2" DESCRIPTION "Enable L5/E5a/B2a GPS bands on realme devices." HOMEPAGE_URL "https://github.com/rapperskull/realme_gps_l5_enabler/" LANGUAGES C @@ -26,7 +26,7 @@ target_link_libraries(gnss_patcher nvbk) if(ANDROID) set(MAGISK_LONG_NAME "realme GPS L5 Enabler") - set(MAGISK_VERSION_CODE 1) + set(MAGISK_VERSION_CODE 2) set(MAGISK_UPDATE_JSON "https://raw.githubusercontent.com/rapperskull/realme_gps_l5_enabler/master/update.json") set(MAGISK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/magisk/) diff --git a/README.md b/README.md index 0196308..ad9794e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,16 @@ Magisk module to enable L5/E5a/B2a GPS bands on realme/OPPO/OnePlus devices with Qualcomm Snapdragon processors. It has been tested only on realme GT 2 Pro (RMX3301), but it should work on other devices too if there's hardware support. +## Changelog + +### v0.0.2 + +- Attempt to fix triple-reboot issue + +### v0.0.1 + +- First release + ## How it works At each boot, it extracts the `oplusstanvbk` partition, patches it by changing the `/nv/item_files/gps/cgps/me/gnss_multiband_configuration` property, and saves it in the module's directory. diff --git a/src/magisk/post-fs-data.sh b/src/magisk/post-fs-data.sh index c912803..a4f9851 100644 --- a/src/magisk/post-fs-data.sh +++ b/src/magisk/post-fs-data.sh @@ -14,37 +14,54 @@ exec 2>&1 echo "Slot: ${SLOT}" echo -ls -la "$PATH1" "$PATH2" +ls -laZ "$PATH1" "$PATH2" echo if [ -L "$PATH1" ] || [ -L "$PATH2" ]; then rm -f "$MODFILE" if [ -L "$PATH1" ]; then - orig="$(readlink -fn ${PATH1})" + ORIG="$(readlink -fn "$PATH1")" else - orig="$(readlink -fn ${PATH2})" + ORIG="$(readlink -fn "$PATH2")" fi + DEV="${ORIG}_mod" chmod +x "$PATCHER" echo "Running patcher" - "$PATCHER" -i "$orig" -o "$MODFILE" + "$PATCHER" -i "$ORIG" -o "$MODFILE" ret=$? if [ $ret -ne 0 ]; then echo "Patcher failed!!!" else echo - DEV="$(/system/bin/losetup -sf $MODFILE)" - if [ -z "$DEV" ]; then - echo "ERROR: Cannot create loop device" + # The loop device path must be in the form '/dev/block/sdX...' because mark_boot_successful() + # will ultimately call gpt_get_header() in gpt-utils and it will try to open the device name + # truncated to length 'sizeof("/dev/block/sda") - 1'. This means that if the original partition + # is '/dev/block/sdX00', it will try to open '/dev/block/sdX', so if we just use the next available + # loop device, it will fail opening '/dev/block/loo'. Using the same prefix as the original + # partition will solve the issue, but requires a "hack" to work. + # We first associate our patched file with the next available loop device, then we rename it. + NEXT_LOOP="$(/system/bin/losetup -sf "$MODFILE")" + if [ -z "$NEXT_LOOP" ]; then + echo "ERROR: Cannot create loop device" else - echo "Created loop device" "$DEV" - chcon -v "u:object_r:vendor_custom_ab_block_device:s0" "${DEV}" - if [ -L "$PATH1" ]; then - ln -sfv "${DEV}" "$PATH1" + mv -f "$NEXT_LOOP" "$DEV" + ret=$? + if [ $ret -ne 0 ]; then + echo "ERROR: Cannot rename loop device" + else + chcon -v "u:object_r:vendor_custom_ab_block_device:s0" "$DEV" # Set correct SELinux context + echo "Created loop device" "$DEV" + ls -laZ "$DEV" + echo + # Create symlinks to newly created loop device + if [ -L "$PATH1" ]; then + ln -sfv "$DEV" "$PATH1" + fi + if [ -L "$PATH2" ]; then + ln -sfv "$DEV" "$PATH2" + fi + echo + ls -laZ "$PATH1" "$PATH2" fi - if [ -L "$PATH2" ]; then - ln -sfv "${DEV}" "$PATH2" - fi - echo - ls -la "$PATH1" "$PATH2" fi fi fi diff --git a/update.json b/update.json index 6897d7d..065b047 100644 --- a/update.json +++ b/update.json @@ -1,6 +1,6 @@ { - "version": "0.0.1", - "versionCode": "1", - "zipUrl": "https://github.com/rapperskull/realme_gps_l5_enabler/releases/download/v0.0.1/RealmeGPSL5Enabler-v0.0.1.zip", + "version": "0.0.2", + "versionCode": "2", + "zipUrl": "https://github.com/rapperskull/realme_gps_l5_enabler/releases/download/v0.0.2/RealmeGPSL5Enabler-v0.0.2.zip", "changelog": "https://raw.githubusercontent.com/rapperskull/realme_gps_l5_enabler/master/README.md" }