diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d592505..4a3f0cc 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -30,7 +30,7 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew assembleRelease + run: ./gradlew copyModuleFilesForRelease - name: Upload CI module zip as artifact zip uses: actions/upload-artifact@v4 diff --git a/.gitmodules b/.gitmodules index 957e430..92949f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "app/src/main/cpp/Dobby"] path = app/src/main/cpp/Dobby - url = https://github.com/chiteroman/Dobby.git + url = https://github.com/JingMatrix/Dobby.git diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3d68810..f5b69f8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,7 @@ +import org.gradle.api.tasks.Exec +import org.gradle.api.tasks.bundling.Zip +import com.android.build.api.variant.ApplicationAndroidComponentsExtension + plugins { alias(libs.plugins.android.application) } @@ -9,9 +13,15 @@ android { buildToolsVersion = "36.0.0" buildFeatures { + buildConfig = true prefab = true } + externalNativeBuild.cmake { + path("src/CMakeLists.txt") + buildStagingDirectory = layout.buildDirectory.get().asFile + } + packaging { jniLibs { excludes += "**/libdobby.so" @@ -27,7 +37,6 @@ android { targetSdk = 35 versionCode = 19100 versionName = "v19.1" - multiDexEnabled = false externalNativeBuild { cmake { @@ -35,28 +44,17 @@ android { "arm64-v8a", "armeabi-v7a" ) - arguments( - "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_STL=none", - "-DCMAKE_BUILD_PARALLEL_LEVEL=${Runtime.getRuntime().availableProcessors()}", - "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON" ) - val commonFlags = setOf( - "-fno-exceptions", - "-fno-rtti", - "-fvisibility=hidden", - "-fvisibility-inlines-hidden", - "-ffunction-sections", - "-fdata-sections", - "-w" + "-fno-exceptions", "-fno-rtti", "-fvisibility=hidden", + "-fvisibility-inlines-hidden", "-ffunction-sections", + "-fdata-sections", "-w" ) - cFlags += "-std=c23" cFlags += commonFlags - cppFlags += "-std=c++26" cppFlags += commonFlags } @@ -64,13 +62,31 @@ android { } buildTypes { - release { + getByName("release") { isMinifyEnabled = true isShrinkResources = true multiDexEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + externalNativeBuild { + cmake { + arguments( + "-DCMAKE_BUILD_TYPE=Release", + "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON", + "-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG", + "-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG", + ) + } + } + } + getByName("debug") { + multiDexEnabled = false + externalNativeBuild { + cmake { + arguments("-DCMAKE_BUILD_TYPE=Debug") + } + } } } @@ -96,47 +112,90 @@ tasks.register("updateModuleProp") { doLast { val versionName = project.android.defaultConfig.versionName val versionCode = project.android.defaultConfig.versionCode - val modulePropFile = project.rootDir.resolve("module/module.prop") - var content = modulePropFile.readText() - content = content.replace(Regex("version=.*"), "version=$versionName") content = content.replace(Regex("versionCode=.*"), "versionCode=$versionCode") - modulePropFile.writeText(content) } } -tasks.register("copyFiles") { - dependsOn("updateModuleProp") +androidComponents.onVariants { variant -> + val variantNameCapped = variant.name.replaceFirstChar { it.uppercase() } + val zipFileName = "PlayIntegrityFix_${project.android.defaultConfig.versionName}-${variant.name}.zip" + val zipFile = project.layout.buildDirectory.file("outputs/zips/$zipFileName").get().asFile + + val copyTask = tasks.register("copyModuleFilesFor$variantNameCapped") { + group = "PIF Packaging" + dependsOn("updateModuleProp", "assemble$variantNameCapped") + + doLast { + val moduleFolder = project.rootDir.resolve("module") + val buildDir = project.layout.buildDirectory.get().asFile + val dexPath = if (variant.isMinifyEnabled) { + "intermediates/dex/${variant.name}/minify${variantNameCapped}WithR8/classes.dex" + } else { + "intermediates/dex/${variant.name}/mergeDex${variantNameCapped}/classes.dex" + } + val soPath = "intermediates/stripped_native_libs/${variant.name}/strip${variantNameCapped}DebugSymbols/out/lib" + buildDir.resolve(dexPath).copyTo(moduleFolder.resolve("classes.dex"), overwrite = true) + buildDir.resolve(soPath).walk().filter { it.isFile && it.extension == "so" }.forEach { soFile -> + soFile.copyTo(moduleFolder.resolve("zygisk/${soFile.parentFile.name}.so"), overwrite = true) + } + } + } - doLast { - val moduleFolder = project.rootDir.resolve("module") - val dexFile = - project.layout.buildDirectory.get().asFile.resolve("intermediates/dex/release/minifyReleaseWithR8/classes.dex") - val soDir = - project.layout.buildDirectory.get().asFile.resolve("intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib") - - dexFile.copyTo(moduleFolder.resolve("classes.dex"), overwrite = true) - - soDir.walk().filter { it.isFile && it.extension == "so" }.forEach { soFile -> - val abiFolder = soFile.parentFile.name - val destination = moduleFolder.resolve("zygisk/$abiFolder.so") - soFile.copyTo(destination, overwrite = true) + val zipTask = tasks.register("zip$variantNameCapped") { + group = "PIF Packaging" + dependsOn(copyTask) + archiveFileName.set(zipFileName) + destinationDirectory.set(project.layout.buildDirectory.dir("outputs/zips").get().asFile) + from(project.rootDir.resolve("module")) + } + + val pushTask = tasks.register("push$variantNameCapped") { + group = "PIF Install" + dependsOn(zipTask) + commandLine("adb", "push", zipFile.absolutePath, "/data/local/tmp") + } + + val installMagiskTask = tasks.register("installMagisk$variantNameCapped") { + group = "PIF Install" + dependsOn(pushTask) + commandLine("adb", "shell", "su", "-c", "magisk --install-module /data/local/tmp/$zipFileName") + } + + val installKsuTask = tasks.register("installKsu$variantNameCapped") { + group = "PIF Install" + dependsOn(pushTask) + doLast { + exec { commandLine("adb", "shell", "su", "-c", "ksud module install /data/local/tmp/$zipFileName") } } } -} -tasks.register("zip") { - dependsOn("copyFiles") + val installApatchTask = tasks.register("installApatch$variantNameCapped") { + group = "PIF Install" + dependsOn(pushTask) + doLast { + exec { commandLine("adb", "shell", "su", "-c", "apd module install /data/local/tmp/$zipFileName") } + } + } - archiveFileName.set("PlayIntegrityFix_${project.android.defaultConfig.versionName}.zip") - destinationDirectory.set(project.rootDir.resolve("out")) + tasks.register("installMagiskAndReboot$variantNameCapped") { + group = "PIF Install & Reboot" + dependsOn(installMagiskTask) + commandLine("adb", "reboot") + } - from(project.rootDir.resolve("module")) -} + tasks.register("installKsuAndReboot$variantNameCapped") { + group = "PIF Install & Reboot" + dependsOn(installKsuTask) + commandLine("adb", "reboot") + } -afterEvaluate { - tasks["assembleRelease"].finalizedBy("updateModuleProp", "copyFiles", "zip") + tasks.register("installApatchAndReboot$variantNameCapped") { + group = "PIF Install & Reboot" + dependsOn(installApatchTask) + commandLine("adb", "reboot") + } } diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 513606e..ef2a63b 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.30.5) project("playintegrityfix") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) link_libraries(log) diff --git a/app/src/main/cpp/Dobby b/app/src/main/cpp/Dobby index e793d10..05a09ac 160000 --- a/app/src/main/cpp/Dobby +++ b/app/src/main/cpp/Dobby @@ -1 +1 @@ -Subproject commit e793d10700ecffac6bc7ce58d218faf31cd68d35 +Subproject commit 05a09ac6807a6bb1726350e40ea4b127c1c79809 diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index a26b14b..1b6b96f 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -5,8 +5,9 @@ #include "dobby.h" #include "json.hpp" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "PIF", __VA_ARGS__) -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "PIF", __VA_ARGS__) +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "zygisk-PIF", __VA_ARGS__) +#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "zygisk-PIF", __VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "zygisk-PIF", __VA_ARGS__) #define DEX_PATH "/data/adb/modules/playintegrityfix/classes.dex" @@ -64,7 +65,11 @@ static ssize_t xwrite(int fd, const void *buffer, size_t count_to_write) { return total_written; } +#ifdef NDEBUG static bool DEBUG = false; +#else +static bool DEBUG = true; +#endif static std::string DEVICE_INITIAL_SDK_INT = "21", SECURITY_PATCH, BUILD_ID; typedef void (*T_Callback)(void *, const char *, const char *, uint32_t); @@ -98,7 +103,7 @@ static void modify_callback(void *cookie, const char *name, const char *value, u } if (strcmp(oldValue, value) == 0) { - if (DEBUG) LOGD("[%s]: %s (unchanged)", name, oldValue); + LOGD("[%s]: %s (unchanged)", name, oldValue); } else { LOGD("[%s]: %s -> %s", name, oldValue, value); } @@ -206,7 +211,10 @@ class PlayIntegrityFix : public zygisk::ModuleBase { if (testSignedRom) { LOGD("--- ROM IS SIGNED WITH TEST KEYS ---"); - spoofSignature = true; + // spoofSignature = true; + if (!spoofSignature) { + LOGW("However, spoofSignature = false"); + } } } @@ -219,7 +227,7 @@ class PlayIntegrityFix : public zygisk::ModuleBase { if (spoofProvider || spoofSignature) { injectDex(); } else { - LOGD("Dex file won't be injected due spoofProvider and spoofSignature are false"); + LOGD("Dex file won't be injected since spoofProvider and spoofSignature are false"); } if (spoofProps) { diff --git a/app/src/main/cpp/zygisk.hpp b/app/src/main/cpp/zygisk.hpp index 7272633..1d22a9d 100644 --- a/app/src/main/cpp/zygisk.hpp +++ b/app/src/main/cpp/zygisk.hpp @@ -15,11 +15,16 @@ // This is the public API for Zygisk modules. // DO NOT MODIFY ANY CODE IN THIS HEADER. +// WARNING: this file may contain changes that are not finalized. +// Always use the following published header for development: +// https://github.com/topjohnwu/zygisk-module-sample/blob/master/module/jni/zygisk.hpp + #pragma once #include +#include -#define ZYGISK_API_VERSION 2 +#define ZYGISK_API_VERSION 5 /* @@ -103,7 +108,6 @@ struct ServerSpecializeArgs; class ModuleBase { public: - // This method is called as soon as the module is loaded into the target process. // A Zygisk API handle will be passed as an argument. virtual void onLoad([[maybe_unused]] Api *api, [[maybe_unused]] JNIEnv *env) {} @@ -142,6 +146,7 @@ struct AppSpecializeArgs { jint &gid; jintArray &gids; jint &runtime_flags; + jobjectArray &rlimits; jint &mount_external; jstring &se_info; jstring &nice_name; @@ -149,12 +154,14 @@ struct AppSpecializeArgs { jstring &app_data_dir; // Optional arguments. Please check whether the pointer is null before de-referencing + jintArray *const fds_to_ignore; jboolean *const is_child_zygote; jboolean *const is_top_app; jobjectArray *const pkg_data_info_list; jobjectArray *const whitelisted_data_info_list; jboolean *const mount_data_dirs; jboolean *const mount_storage_dirs; + jboolean *const mount_sysprop_overrides; AppSpecializeArgs() = delete; }; @@ -172,8 +179,9 @@ struct ServerSpecializeArgs { namespace internal { struct api_table; -template void entry_impl(api_table *, JNIEnv *); -} +template +void entry_impl(api_table *, JNIEnv *); +} // namespace internal // These values are used in Api::setOption(Option) enum Option : int { @@ -204,7 +212,6 @@ enum StateFlag : uint32_t { // All API methods will stop working after post[XXX]Specialize as Zygisk will be unloaded // from the specialized process afterwards. struct Api { - // Connect to a root companion process and get a Unix domain socket for IPC. // // This API only works in the pre[XXX]Specialize methods due to SELinux restrictions. @@ -241,13 +248,22 @@ struct Api { // Returns bitwise-or'd zygisk::StateFlag values. uint32_t getFlags(); + // Exempt the provided file descriptor from being automatically closed. + // + // This API only make sense in preAppSpecialize; calling this method in any other situation + // is either a no-op (returns true) or an error (returns false). + // + // When false is returned, the provided file descriptor will eventually be closed by zygote. + bool exemptFd(int fd); + // Hook JNI native methods for a class // // Lookup all registered JNI native methods and replace it with your own methods. // The original function pointer will be saved in each JNINativeMethod's fnPtr. // If no matching class, method name, or signature is found, that specific JNINativeMethod.fnPtr // will be set to nullptr. - void hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int numMethods); + void hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, + int numMethods); // Hook functions in the PLT (Procedure Linkage Table) of ELFs loaded in memory. // @@ -257,13 +273,10 @@ struct Api { // 56b4346000-56b4347000 r-xp 00002000 fe:00 235 /system/bin/app_process64 // (More details: https://man7.org/linux/man-pages/man5/proc.5.html) // - // For ELFs loaded in memory with pathname matching `regex`, replace function `symbol` with `newFunc`. + // The `dev` and `inode` pair uniquely identifies a file being mapped into memory. + // For matching ELFs loaded in memory, replace function `symbol` with `newFunc`. // If `oldFunc` is not nullptr, the original function pointer will be saved to `oldFunc`. - void pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc); - - // For ELFs loaded in memory with pathname matching `regex`, exclude hooks registered for `symbol`. - // If `symbol` is nullptr, then all symbols will be excluded. - void pltHookExclude(const char *regex, const char *symbol); + void pltHookRegister(dev_t dev, ino_t inode, const char *symbol, void *newFunc, void **oldFunc); // Commit all the hooks that was previously registered. // Returns false if an error occurred. @@ -271,15 +284,16 @@ struct Api { private: internal::api_table *tbl; - template friend void internal::entry_impl(internal::api_table *, JNIEnv *); + template + friend void internal::entry_impl(internal::api_table *, JNIEnv *); }; // Register a class as a Zygisk module -#define REGISTER_ZYGISK_MODULE(clazz) \ -void zygisk_module_entry(zygisk::internal::api_table *table, JNIEnv *env) { \ - zygisk::internal::entry_impl(table, env); \ -} +#define REGISTER_ZYGISK_MODULE(clazz) \ + void zygisk_module_entry(zygisk::internal::api_table *table, JNIEnv *env) { \ + zygisk::internal::entry_impl(table, env); \ + } // Register a root companion request handler function for your module // @@ -291,8 +305,8 @@ void zygisk_module_entry(zygisk::internal::api_table *table, JNIEnv *env) { \ // NOTE: the function can run concurrently on multiple threads. // Be aware of race conditions if you have globally shared resources. -#define REGISTER_ZYGISK_COMPANION(func) \ -void zygisk_companion_entry(int client) { func(client); } +#define REGISTER_ZYGISK_COMPANION(func) \ + void zygisk_companion_entry(int client) { func(client); } /********************************************************* * The following is internal ABI implementation detail. @@ -324,12 +338,12 @@ struct api_table { bool (*registerModule)(api_table *, module_abi *); void (*hookJniNativeMethods)(JNIEnv *, const char *, JNINativeMethod *, int); - void (*pltHookRegister)(const char *, const char *, void *, void **); - void (*pltHookExclude)(const char *, const char *); + void (*pltHookRegister)(dev_t, ino_t, const char *, void *, void **); + bool (*exemptFd)(int); bool (*pltHookCommit)(); - int (*connectCompanion)(void * /* impl */); + int (*connectCompanion)(void * /* impl */); void (*setOption)(void * /* impl */, Option); - int (*getModuleDir)(void * /* impl */); + int (*getModuleDir)(void * /* impl */); uint32_t (*getFlags)(void * /* impl */); }; @@ -344,34 +358,28 @@ void entry_impl(api_table *table, JNIEnv *env) { m->onLoad(&api, env); } -} // namespace internal +} // namespace internal inline int Api::connectCompanion() { return tbl->connectCompanion ? tbl->connectCompanion(tbl->impl) : -1; } -inline int Api::getModuleDir() { - return tbl->getModuleDir ? tbl->getModuleDir(tbl->impl) : -1; -} +inline int Api::getModuleDir() { return tbl->getModuleDir ? tbl->getModuleDir(tbl->impl) : -1; } inline void Api::setOption(Option opt) { if (tbl->setOption) tbl->setOption(tbl->impl, opt); } -inline uint32_t Api::getFlags() { - return tbl->getFlags ? tbl->getFlags(tbl->impl) : 0; -} -inline void Api::hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int numMethods) { +inline uint32_t Api::getFlags() { return tbl->getFlags ? tbl->getFlags(tbl->impl) : 0; } +inline bool Api::exemptFd(int fd) { return tbl->exemptFd != nullptr && tbl->exemptFd(fd); } +inline void Api::hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, + int numMethods) { if (tbl->hookJniNativeMethods) tbl->hookJniNativeMethods(env, className, methods, numMethods); } -inline void Api::pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc) { - if (tbl->pltHookRegister) tbl->pltHookRegister(regex, symbol, newFunc, oldFunc); -} -inline void Api::pltHookExclude(const char *regex, const char *symbol) { - if (tbl->pltHookExclude) tbl->pltHookExclude(regex, symbol); -} -inline bool Api::pltHookCommit() { - return tbl->pltHookCommit != nullptr && tbl->pltHookCommit(); +inline void Api::pltHookRegister(dev_t dev, ino_t inode, const char *symbol, void *newFunc, + void **oldFunc) { + if (tbl->pltHookRegister) tbl->pltHookRegister(dev, inode, symbol, newFunc, oldFunc); } +inline bool Api::pltHookCommit() { return tbl->pltHookCommit != nullptr && tbl->pltHookCommit(); } -} // namespace zygisk +} // namespace zygisk extern "C" { @@ -381,4 +389,5 @@ void zygisk_module_entry(zygisk::internal::api_table *, JNIEnv *); [[gnu::visibility("default"), maybe_unused]] void zygisk_companion_entry(int); -} // extern "C" +} // extern "C" + diff --git a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java index 0a5af36..43551bf 100644 --- a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java +++ b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java @@ -24,7 +24,7 @@ import java.util.Objects; public final class EntryPoint { - public static final String TAG = "PIF"; + public static final String TAG = "zygisk-PIF"; private static final Map map = new HashMap<>(); private static final String signatureData = """ MIIFyTCCA7GgAwIBAgIVALyxxl+zDS9SL68SzOr48309eAZyMA0GCSqGSIb3DQEBCwUAMHQxCzAJ diff --git a/changelog.md b/changelog.md deleted file mode 100644 index 0b12671..0000000 --- a/changelog.md +++ /dev/null @@ -1,9 +0,0 @@ -Telegram channel: -https://t.me/playintegrityfix - -Donations: -https://www.paypal.com/paypalme/chiteroman0 - -# v19.1 - -- Update fingerprint. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9694151..0abdc4b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -agp = "8.8.2" -cxx = "27.0.12077973" +agp = "8.11.1" +cxx = "28.1.13356709" hiddenapibypass = "6.1" [libraries] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cc9cdd9..d4081da 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Sat May 17 15:25:13 CEST 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 4f906e0..23d15a9 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,81 +15,115 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..db3a6ac 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/module/action.sh b/module/action.sh index a7dcb67..5270a15 100644 --- a/module/action.sh +++ b/module/action.sh @@ -68,17 +68,11 @@ download https://developer.android.com/about/versions PIXEL_VERSIONS_HTML BETA_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1) download "$BETA_URL" PIXEL_LATEST_HTML -# Handle Developer Preview vs Beta -if grep -qE 'Developer Preview|tooltip>.*preview program' PIXEL_LATEST_HTML && [ "$FORCE_PREVIEW" = 0 ]; then - # Use the second latest version for beta - BETA_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n2 | tail -n1) - download "$BETA_URL" PIXEL_BETA_HTML -else - mv -f PIXEL_LATEST_HTML PIXEL_BETA_HTML -fi +# Always use the latest available version page +mv -f PIXEL_LATEST_HTML PIXEL_BETA_HTML -# Get OTA information -OTA_URL="https://developer.android.com$(grep -o 'href=".*download-ota.*"' PIXEL_BETA_HTML | cut -d\" -f2 | head -n1)" +# Get OTA information, specifically for the QPR (Quarterly Platform Release) build +OTA_URL="https://developer.android.com$(grep -o 'href=".*download-ota.*"' PIXEL_BETA_HTML | grep 'qpr' | cut -d\" -f2 | head -n1)" download "$OTA_URL" PIXEL_OTA_HTML # Extract device information diff --git a/module/customize.sh b/module/customize.sh index d34f96f..0ae824e 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -70,3 +70,22 @@ fi # give exec perm to action.sh chmod +x "$MODPATH/action.sh" + +## Installation of custom implementation of GMS +if [ -f "/data/local/tmp/GmsCore.apk" ]; then + mkdir -p "$MODPATH/system/product/priv-app/" + mknod "$MODPATH/system/product/priv-app/GmsCore" c 0 0 + mknod "$MODPATH/system/product/priv-app/GoogleOneTimeInitializer" c 0 0 + mknod "$MODPATH/system/product/priv-app/GooglePartnerSetup" c 0 0 + mknod "$MODPATH/system/product/priv-app/GoogleRestore" c 0 0 + mknod "$MODPATH/system/product/priv-app/Messages" c 0 0 + # mknod "$MODPATH/system/product/priv-app/Phonesky" c 0 0 + mknod "$MODPATH/system/product/priv-app/Velvet" c 0 0 + + mkdir -p "$MODPATH/system/system_ext/priv-app/" + mknod "$MODPATH/system/system_ext/priv-app/GoogleServicesFramework" c 0 0 + mknod "$MODPATH/system/system_ext/priv-app/GoogleFeedback" c 0 0 + + mkdir -p "$MODPATH/system/priv-app/GmsCore" + cp "/data/local/tmp/GmsCore.apk" "$MODPATH/system/priv-app/GmsCore" +fi diff --git a/module/module.prop b/module/module.prop index 9c1e7ea..37cdf7a 100644 --- a/module/module.prop +++ b/module/module.prop @@ -2,6 +2,6 @@ id=playintegrityfix name=Play Integrity Fix version=v19.1 versionCode=19100 -author=chiteroman -description=Universal modular fix for Play Integrity (and SafetyNet) on devices running Android 8-15 -updateJson=https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/update.json +author=JingMatrix & chiteroman +description=Spoof bootloader property (Android OS layer only) and Play Integrity verdict +updateJson=https://raw.githubusercontent.com/JingMatrix/PlayIntegrityFix/main/update.json diff --git a/module/pif.json b/module/pif.json index f880fe3..df96838 100644 --- a/module/pif.json +++ b/module/pif.json @@ -1,6 +1,6 @@ { - "FINGERPRINT": "google/oriole_beta/oriole:16/BP22.250325.012/13467521:user/release-keys", + "FINGERPRINT": "google/oriole_beta/oriole:16/BP41.250916.012/14330257:user/release-keys", "MANUFACTURER": "Google", "MODEL": "Pixel 6", - "SECURITY_PATCH": "2025-04-05" -} \ No newline at end of file + "SECURITY_PATCH": "2025-09-05" +} diff --git a/module/service.sh b/module/service.sh index 1b3c1f7..d0f2424 100644 --- a/module/service.sh +++ b/module/service.sh @@ -39,3 +39,4 @@ resetprop_if_diff vendor.boot.vbmeta.device_state locked # Other resetprop_if_diff sys.oem_unlock_allowed 0 +resetprop_if_diff ro.boot.verifiedbooterror diff --git a/update.json b/update.json index a0edb63..6657ffd 100644 --- a/update.json +++ b/update.json @@ -1,6 +1,6 @@ { "version": "v19.1", "versionCode": 19100, - "zipUrl": "https://github.com/chiteroman/PlayIntegrityFix/releases/download/v19.1/PlayIntegrityFix_v19.1.zip", - "changelog": "https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/changelog.md" -} \ No newline at end of file + "zipUrl": "https://github.com/JingMatrix/PlayIntegrityFix/releases/download/v19.1/PlayIntegrityFix_v19.1.zip", + "changelog": "https://raw.githubusercontent.com/JingMatrix/PlayIntegrityFix/main/changelog.md" +}