### Run per-UID isolation E2E gate Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Read-only gate that checks per-UID hiding. Run only after MediaProvider and relevant applications are already running. Adjust package names, entries and expectations to actual configured rules; example expectations are not universal defaults. ```sh python3 app/src/main/cpp/tests/run_uid_isolation_e2e.py --serial SERIAL \ --case 'com.termux:MT2=hidden,NP=visible,Android=visible' \ --case 'com.github.metacubex.clash.meta:MT2=visible,NP=visible,Android=visible' \ --case 'io.github.xiaotong6666.fusehide:MT2=hidden,xinhao=hidden,NP=visible,Android=visible' \ --case 'com.termux:MT2=hidden,NP=visible' ``` -------------------------------- ### Include Directories and Library Linking Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Configures include paths and links the necessary system libraries. ```cmake target_include_directories( fusehide PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} third_party/xz-embedded ) find_library(log-lib log) find_library(dl-lib dl) target_link_libraries(fusehide ${log-lib} ${dl-lib}) ``` -------------------------------- ### Run the Android callback lifetime review script Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Build with -DFUSEHIDE_CALLBACK_LIFETIME_TEST=ON and compile the real libfusehide.so from the same checkout. The dynamic section must contain FLAGS_1: NODELETE. Run this command with the path to the .so, the review binary, the gate binary, and the device serial. ```sh bash app/src/main/cpp/tests/run_android_callback_lifetime_review.sh \ /path/to/libfusehide.so \ /tmp/fusehide-native-review/fusehide_callback_lifetime_review \ /tmp/fusehide-native-review/fusehide_callback_gate_review DEVICE_SERIAL ``` -------------------------------- ### Format code Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Gradle task to run project formatting. ```bash ./gradlew format ``` -------------------------------- ### Clone repository with submodules Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Initial clone command to ensure all submodules are included. ```bash git clone --recurse-submodules https://github.com/XiaoTong6666/FuseHide.git cd FuseHide ``` -------------------------------- ### Run native review executables on device Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Push the two binaries to /data/local/tmp/ and run each in its own process on native ARM64 or ARM64-translated Android devices. The --rollback flag exercises the linker monitor's rollback path. ```sh ./fusehide_native_hook_review ./fusehide_linker_review ./fusehide_linker_review --rollback ``` -------------------------------- ### Compiler and Linker Options Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Sets C++20 standard, visibility, and basic compiler/linker flags for the library. ```cmake target_compile_features(fusehide PRIVATE cxx_std_20) target_compile_options( fusehide PRIVATE -Wall -Wextra -Werror -fvisibility=hidden $<$:-fno-exceptions> $<$:-fno-rtti> ) target_link_options( fusehide PRIVATE -Wl,--as-needed ) ``` -------------------------------- ### Run automated native review wrapper Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Runs the automated wrapper that checks every mode's exit status and the result=PASS marker. Pass the built binaries and the device serial. ```sh bash app/src/main/cpp/tests/run_android_native_review.sh \ /tmp/fusehide-native-review/fusehide_native_hook_review \ /tmp/fusehide-native-review/fusehide_linker_review DEVICE_SERIAL ``` -------------------------------- ### Configure linker review test Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Optionally builds the isolated Android do_dlopen smoke test executable. ```cmake option(FUSEHIDE_LINKER_REVIEW_TEST "Build isolated Android do_dlopen smoke test" OFF) if(FUSEHIDE_LINKER_REVIEW_TEST AND ANDROID) add_executable(fusehide_linker_review tests/linker_monitor_test.cpp zygisk/dlopen_monitor.cpp zygisk/native_hook_adapter.cpp fusehide/elf/elf_utils.cpp third_party/xz-embedded/xz_dec_stream.c third_party/xz-embedded/xz_dec_lzma2.c third_party/xz-embedded/xz_crc32.c ) target_compile_features(fusehide_linker_review PRIVATE cxx_std_20) target_compile_definitions(fusehide_linker_review PRIVATE FUSEHIDE_LINKER_REVIEW_TEST=1) target_include_directories(fusehide_linker_review PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} third_party/Dobby/include third_party/xz-embedded zygisk/include ) target_link_libraries(fusehide_linker_review PRIVATE dobby log dl) target_link_options(fusehide_linker_review PRIVATE -Wl,--wrap=DobbyCodePatch) endif() ``` -------------------------------- ### Run MediaProvider E2E gate Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Runs the real MediaProvider verification gate. The zygisk-v3 variant requires evidence from the same actual MediaProvider PID for the v3 handshake, post-init and FUSE hook summary. The optional --restart flag only force-stops MediaProvider and triggers a FUSE lookup. ```sh bash app/src/main/cpp/tests/run_media_provider_e2e.sh SERIAL lsposed bash app/src/main/cpp/tests/run_media_provider_e2e.sh SERIAL zygisk-v3 ``` -------------------------------- ### Useful Gradle tasks Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Commonly used Gradle tasks for zipping, pushing, and flashing the project. ```bash ./gradlew zipDebug ./gradlew zipRelease ./gradlew pushDebug ./gradlew pushRelease ./gradlew flashDebug ./gradlew flashRelease ./gradlew flashWithMagiskRelease ./gradlew flashWithKsudRelease ./gradlew flashAndRebootRelease ./gradlew flashWithMagiskAndRebootRelease ./gradlew flashWithKsudAndRebootRelease ``` -------------------------------- ### Project Directory Layout Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md The project structure organized by source code, native implementations, and build modules. ```text app/ src/main/java/io/github/xiaotong6666/fusehide/ config/ runtime configuration and IPC debug/ probe/debug helpers status/ injected-process status handling ui/ Compose application UI xposed/ LSPosed and injected Java entry points src/main/cpp/ fusehide/ core FUSE hook/policy/runtime implementation zygisk/ standalone Zygisk injection backend third_party/Dobby/ native hook dependency baselineprofile/ Android baseline-profile module uihelper/ UI helper git submodule template/module/ Zygisk/root-module template scripts/ packaging/build helper scripts docs/ architecture and reverse-engineering notes MediaProvider/ local AOSP MediaProvider reference tree; not part of the Gradle build ``` -------------------------------- ### Build debug and release artifacts Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Gradle command to compile both debug and release versions of the project. ```bash ./gradlew assembleDebug assembleRelease ``` -------------------------------- ### CMake project configuration for fusehide Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Initializes the project, defines the shared library, and specifies the source files to be compiled. ```cmake cmake_minimum_required(VERSION 3.22.1) project(fusehide) add_library( fusehide SHARED fusehide.cpp fusehide/core/runtime_state.cpp fusehide/elf/elf_utils.cpp fusehide/filters/dirent_filter.cpp fusehide/filters/reply_buf_filter.cpp fusehide/hooks/fuse_wrappers.cpp fusehide/hooks/hook_install.cpp fusehide/jni/jni_entry.cpp fusehide/policy/path_policy.cpp fusehide/policy/unicode_policy.cpp third_party/xz-embedded/xz_dec_stream.c third_party/xz-embedded/xz_dec_lzma2.c third_party/xz-embedded/xz_crc32.c ) ``` -------------------------------- ### System State Properties Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md System properties that describe the device's storage environment. ```text ro.fuse.bpf.is_running persist.sys.vold_app_data_isolation_enabled external_storage.sdcardfs.enabled ``` -------------------------------- ### Run Callback Lifetime Review Script Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Executes the test suite for verifying callback lifetime, including scenarios like NODELETE enforcement, race conditions, and late callback calls. ```sh bash app/src/main/cpp/tests/run_android_callback_lifetime_review.sh \ /path/to/libfusehide.so \ /path/to/fusehide_callback_lifetime_review \ /path/to/fusehide_callback_gate_review DEVICE_SERIAL ``` -------------------------------- ### Build native review executables with CMake Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Configure and build the fusehide_native_hook_review and fusehide_linker_review targets using the Android NDK toolchain. Requires ANDROID_NDK_HOME and enables the FUSEHIDE_NATIVE_HOOK_REVIEW_TEST and FUSEHIDE_LINKER_REVIEW_TEST options. ```sh cmake -S app/src/main/cpp -B /tmp/fusehide-native-review -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \ -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-31 \ -DCMAKE_BUILD_TYPE=Debug \ -DFUSEHIDE_NATIVE_HOOK_REVIEW_TEST=ON \ -DFUSEHIDE_LINKER_REVIEW_TEST=ON cmake --build /tmp/fusehide-native-review --target \ fusehide_native_hook_review fusehide_linker_review ``` -------------------------------- ### Configure Dobby dependency Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Configures the Dobby library to be built statically for Zygisk and adds the subdirectory. ```cmake set(DOBBY_GENERATE_SHARED OFF CACHE BOOL "Build Dobby statically for Zygisk" FORCE) if(ANDROID_ABI STREQUAL "arm64-v8a") set(NearBranch ON CACHE BOOL "Require available ARM64 near trampoline backend" FORCE) endif() add_subdirectory(third_party/Dobby) ``` -------------------------------- ### Build isolated callback tests Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/tests/NATIVE_HOOK_REVIEW.md Commands to configure and build the native callback lifetime and gate review executables using CMake. ```sh cmake -S app/src/main/cpp -B /tmp/fusehide-native-review -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \ -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-31 \ -DFUSEHIDE_CALLBACK_LIFETIME_TEST=ON cmake --build /tmp/fusehide-native-review --target fusehide \ fusehide_callback_lifetime_review fusehide_callback_gate_review ``` -------------------------------- ### Update submodules Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Command to initialize and update submodules if the repository was cloned without them. ```bash git submodule update --init --recursive ``` -------------------------------- ### Configure callback lifetime tests Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Optionally builds executables for reviewing native module callback lifetimes and gates. ```cmake option(FUSEHIDE_CALLBACK_LIFETIME_TEST "Build native module callback lifetime review" OFF) if(FUSEHIDE_CALLBACK_LIFETIME_TEST AND ANDROID) add_executable(fusehide_callback_lifetime_review tests/native_callback_lifetime_test.cpp zygisk/native_hook_adapter.cpp ) target_compile_features(fusehide_callback_lifetime_review PRIVATE cxx_std_20) target_include_directories(fusehide_callback_lifetime_review PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) target_link_libraries(fusehide_callback_lifetime_review PRIVATE dobby dl log) add_executable(fusehide_callback_gate_review tests/native_callback_gate_test.cpp ) target_compile_features(fusehide_callback_gate_review PRIVATE cxx_std_20) target_include_directories(fusehide_callback_gate_review PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) endif() ``` -------------------------------- ### Configure zygisk build properties Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Sets C++ standard, compiler options, include directories, and link libraries for the zygisk target. ```cmake target_compile_features(zygisk PRIVATE cxx_std_20) target_compile_options( zygisk PRIVATE -Wall -Wextra -Werror -fvisibility=hidden $<$:-fno-exceptions> $<$:-fno-rtti> ) target_include_directories( zygisk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} third_party/Dobby/include third_party/xz-embedded zygisk/include ) target_link_libraries(zygisk dobby ${log-lib} ${dl-lib}) target_link_options(zygisk PRIVATE -Wl,-z,max-page-size=16384) ``` -------------------------------- ### Configure native hook review test Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Optionally builds the standalone native v2 ownership regression test executable. ```cmake option(FUSEHIDE_NATIVE_HOOK_REVIEW_TEST "Build standalone native v2 ownership regression" OFF) if(FUSEHIDE_NATIVE_HOOK_REVIEW_TEST) add_executable(fusehide_native_hook_review tests/native_hook_adapter_test.cpp zygisk/native_hook_adapter.cpp ) target_compile_features(fusehide_native_hook_review PRIVATE cxx_std_20) target_include_directories(fusehide_native_hook_review PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} third_party/Dobby/include ) target_link_libraries(fusehide_native_hook_review PRIVATE dobby dl) if(ANDROID) target_link_libraries(fusehide_native_hook_review PRIVATE log) endif() target_link_options(fusehide_native_hook_review PRIVATE -Wl,--wrap=DobbyCodePatch) endif() ``` -------------------------------- ### Configure fusehide link options Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Sets linker options for the fusehide target to ensure the module remains mapped in memory. ```cmake target_link_options(fusehide PRIVATE -Wl,-z,max-page-size=16384 -Wl,-z,nodelete) ``` -------------------------------- ### Capture Logs with ADB Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Commands to filter and view FuseHide logs using the Android Debug Bridge. ```bash adb logcat -v time | grep -i FuseHide ``` ```bash adb logcat -s FuseHide ``` -------------------------------- ### Release Build Optimizations Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Applies aggressive size optimization and stripping flags when the build type is not Debug. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") target_compile_options(fusehide PRIVATE -Oz -flto=full -ffunction-sections -fdata-sections $<$:-fno-unwind-tables> $<$:-fno-asynchronous-unwind-tables> -fno-ident -fno-math-errno -fomit-frame-pointer ) target_link_options(fusehide PRIVATE -flto=full -Wl,--gc-sections -Wl,--icf=all -Wl,--exclude-libs,ALL -Wl,-s -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-Bsymbolic ) endif() ``` -------------------------------- ### Derive version code Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md Command to determine the version code based on the git commit history. ```bash git rev-list --count HEAD ``` -------------------------------- ### Zygisk module archive path Source: https://github.com/xiaotong6666/fusehide/blob/main/README.md The directory where signed Zygisk module archives are generated. ```text app/build/zygisk/ ``` -------------------------------- ### Define zygisk library Source: https://github.com/xiaotong6666/fusehide/blob/main/app/src/main/cpp/CMakeLists.txt Defines the main zygisk shared library and its source files. ```cmake add_library( zygisk SHARED zygisk/module.cpp zygisk/dex_loader.cpp zygisk/dlopen_monitor.cpp zygisk/native_hook_adapter.cpp fusehide/elf/elf_utils.cpp third_party/xz-embedded/xz_dec_stream.c third_party/xz-embedded/xz_dec_lzma2.c third_party/xz-embedded/xz_crc32.c ) ```