diff --git a/root-module/META-INF/com/google/android/update-binary b/root-module/META-INF/com/google/android/update-binary index 28b48e5..ea4889e 100644 --- a/root-module/META-INF/com/google/android/update-binary +++ b/root-module/META-INF/com/google/android/update-binary @@ -30,4 +30,4 @@ mount /data 2>/dev/null [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk install_module -exit 0 +exit 0 \ No newline at end of file diff --git a/root-module/META-INF/com/google/android/update-script b/root-module/META-INF/com/google/android/updater-script similarity index 100% rename from root-module/META-INF/com/google/android/update-script rename to root-module/META-INF/com/google/android/updater-script diff --git a/root-module/customize.sh b/root-module/customize.sh index 0111076..ac698b8 100644 --- a/root-module/customize.sh +++ b/root-module/customize.sh @@ -2,15 +2,51 @@ API_URL="https://aln.kavishdevar.me/api" TEMP_DIR="$TMPDIR/aln_patch" +UNZIP_DIR="/data/local/tmp/aln_unzip" PATCHED_FILE_NAME="" SOURCE_FILE="" LIBRARY_NAME="" APEX_DIR=false mkdir -p "$TEMP_DIR" +mkdir -p "$UNZIP_DIR" -CURL_CMD=$(command -v curl || echo "$MODPATH/system/bin/curl") -export LD_LIBRARY_PATH="$MODPATH/system/lib64:$LD_LIBRARY_PATH" +# Manually extract the $ZIPFILE to a temporary directory +ui_print "Extracting $ZIPFILE to $UNZIP_DIR" +unzip -o "$ZIPFILE" -d "$UNZIP_DIR" > /dev/null 2>&1 +if [ $? -ne 0 ]; then + ui_print "Failed to unzip $ZIPFILE" + abort "Failed to unzip $ZIPFILE" +fi + +ui_print "Extracted module files to $UNZIP_DIR" + +# Determine architecture +IS64BIT=false +if [ "$(uname -m)" = "aarch64" ]; then + IS64BIT=true +fi + +if [ "$IS64BIT" = true ]; then + export LD_LIBRARY_PATH="$UNZIP_DIR/libcurl-android/libs/arm64-v8a" + export PATH="$UNZIP_DIR/libcurl-android/bin/arm64-v8a:$PATH" + export CURL_CMD="$UNZIP_DIR/libcurl-android/bin/arm64-v8a/curl" + ln -s "$UNZIP_DIR/libcurl-android/libs/arm64-v8a/libz.so" "$UNZIP_DIR/libcurl-android/libs/arm64-v8a/libz.so.1" +else + export LD_LIBRARY_PATH="$UNZIP_DIR/libcurl-android/libs/armeabi-v7a" + export PATH="$UNZIP_DIR/libcurl-android/bin/armeabi-v7a:$PATH" + export CURL_CMD="$UNZIP_DIR/libcurl-android/bin/armeabi-v7a/curl" + ln -s "$UNZIP_DIR/libcurl-android/libs/armeabi-v7a/libz.so" "$UNZIP_DIR/libcurl-android/libs/armeabi-v7a/libz.so.1" +fi + +set_perm "$CURL_CMD" 0 0 755 + +if [ -f "$CURL_CMD" ]; then + ui_print "curl binary found." +else + ui_print "curl binary not found. Exiting." + abort "curl binary not found." +fi if [ -f "/apex/com.android.btservices/lib64/libbluetooth_jni.so" ]; then SOURCE_FILE="/apex/com.android.btservices/lib64/libbluetooth_jni.so" @@ -41,11 +77,9 @@ ui_print "Uploading $LIBRARY_NAME to the API for patching..." ui_print "If you're concerned about privacy, review the source code of the API at https://github.com/kavishdevar/aln/blob/main/root-module-manual/server.py" PATCHED_FILE_NAME="patched_$LIBRARY_NAME" -$CURL_CMD -s -X POST "$API_URL" \ - -F "file=@$SOURCE_FILE" \ - -F "library_name=$LIBRARY_NAME" \ - -o "$TEMP_DIR/$PATCHED_FILE_NAME" \ - -D "$TEMP_DIR/headers.txt" +ui_print "calling command $CURL_CMD --verbose -k -X POST $API_URL -F file=@$SOURCE_FILE -F library_name=$LIBRARY_NAME -o $TEMP_DIR/$PATCHED_FILE_NAME" + +$CURL_CMD --verbose -k -X POST $API_URL -F file=@"$SOURCE_FILE" -F library_name="$LIBRARY_NAME" -o "$TEMP_DIR/$PATCHED_FILE_NAME" > "$TEMP_DIR/headers.txt" 2>&1 if [ -f "$TEMP_DIR/$PATCHED_FILE_NAME" ]; then ui_print "Received patched file from the API." @@ -87,10 +121,7 @@ EOF ui_print "Created post-data-fs.sh script for apex library handling." fi else - ERROR_MESSAGE=$(grep -oP '(?<="error": ")[^"]+' "$TEMP_DIR/headers.txt") - ui_print "API Error: $ERROR_MESSAGE" + ui_print "Failed to receive patched file from the API." rm -rf "$TEMP_DIR" abort "Failed to patch the library." -fi - -rm -rf "$TEMP_DIR" \ No newline at end of file +fi \ No newline at end of file diff --git a/root-module/libcurl-android/bin/arm64-v8a/curl b/root-module/libcurl-android/bin/arm64-v8a/curl new file mode 100644 index 0000000..b70bd5b Binary files /dev/null and b/root-module/libcurl-android/bin/arm64-v8a/curl differ diff --git a/root-module/libcurl-android/bin/arm64-v8a/curl-config b/root-module/libcurl-android/bin/arm64-v8a/curl-config new file mode 100644 index 0000000..4457af0 --- /dev/null +++ b/root-module/libcurl-android/bin/arm64-v8a/curl-config @@ -0,0 +1,196 @@ +#! /bin/sh +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2001 - 2022, Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# SPDX-License-Identifier: curl +# +########################################################################### + +prefix="/app/libcurl-android/jni/build/curl/arm64-v8a" +exec_prefix=${prefix} +includedir=${prefix}/include +cppflag_curl_staticlib= + +usage() +{ + cat <&2 + exit 1 + fi + ;; + + --configure) + echo " '--host=aarch64-linux-android' '--prefix=/app/libcurl-android/jni/build/curl/arm64-v8a' '--with-ssl=/app/libcurl-android/jni/build/openssl/arm64-v8a' '--with-zlib=/app/libcurl-android/jni/build/zlib/arm64-v8a' '--enable-static' '--enable-shared' '--disable-verbose' '--enable-threaded-resolver' '--enable-ipv6' 'host_alias=aarch64-linux-android' 'CC=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang' 'CFLAGS=--sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=armv8-a -fPIC' 'LDFLAGS=-L/app/libcurl-android/jni/build/openssl/arm64-v8a/lib -L/app/libcurl-android/jni/build/zlib/arm64-v8a/lib' 'LIBS=-lssl -lcrypto -lc++ -lz' 'CPPFLAGS=-I/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" + ;; + + *) + echo "unknown option: $1" + usage 1 + ;; + esac + shift +done + +exit 0 diff --git a/root-module/libcurl-android/bin/arm64-v8a/openssl b/root-module/libcurl-android/bin/arm64-v8a/openssl new file mode 100644 index 0000000..eb2846a Binary files /dev/null and b/root-module/libcurl-android/bin/arm64-v8a/openssl differ diff --git a/root-module/libcurl-android/bin/armeabi-v7a/curl b/root-module/libcurl-android/bin/armeabi-v7a/curl new file mode 100644 index 0000000..eda6f28 Binary files /dev/null and b/root-module/libcurl-android/bin/armeabi-v7a/curl differ diff --git a/root-module/libcurl-android/bin/armeabi-v7a/curl-config b/root-module/libcurl-android/bin/armeabi-v7a/curl-config new file mode 100644 index 0000000..31dd7cd --- /dev/null +++ b/root-module/libcurl-android/bin/armeabi-v7a/curl-config @@ -0,0 +1,196 @@ +#! /bin/sh +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2001 - 2022, Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# SPDX-License-Identifier: curl +# +########################################################################### + +prefix="/app/libcurl-android/jni/build/curl/armeabi-v7a" +exec_prefix=${prefix} +includedir=${prefix}/include +cppflag_curl_staticlib= + +usage() +{ + cat <&2 + exit 1 + fi + ;; + + --configure) + echo " '--host=armv7a-linux-androideabi' '--prefix=/app/libcurl-android/jni/build/curl/armeabi-v7a' '--with-ssl=/app/libcurl-android/jni/build/openssl/armeabi-v7a' '--with-zlib=/app/libcurl-android/jni/build/zlib/armeabi-v7a' '--enable-static' '--enable-shared' '--disable-verbose' '--enable-threaded-resolver' '--enable-ipv6' 'host_alias=armv7a-linux-androideabi' 'CC=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang' 'CFLAGS=--sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fPIC' 'LDFLAGS=-L/app/libcurl-android/jni/build/openssl/armeabi-v7a/lib -L/app/libcurl-android/jni/build/zlib/armeabi-v7a/lib' 'LIBS=-lssl -lcrypto -lc++ -lz' 'CPPFLAGS=-I/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include --sysroot=/app/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" + ;; + + *) + echo "unknown option: $1" + usage 1 + ;; + esac + shift +done + +exit 0 diff --git a/root-module/libcurl-android/bin/armeabi-v7a/openssl b/root-module/libcurl-android/bin/armeabi-v7a/openssl new file mode 100644 index 0000000..f956a40 Binary files /dev/null and b/root-module/libcurl-android/bin/armeabi-v7a/openssl differ