Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
147 changes: 103 additions & 44 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
Expand All @@ -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"
Expand All @@ -27,50 +37,56 @@ android {
targetSdk = 35
versionCode = 19100
versionName = "v19.1"
multiDexEnabled = false

externalNativeBuild {
cmake {
abiFilters(
"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
}
}
}

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")
}
}
}
}

Expand All @@ -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>("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<Exec>("push$variantNameCapped") {
group = "PIF Install"
dependsOn(zipTask)
commandLine("adb", "push", zipFile.absolutePath, "/data/local/tmp")
}

val installMagiskTask = tasks.register<Exec>("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>("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<Exec>("installMagiskAndReboot$variantNameCapped") {
group = "PIF Install & Reboot"
dependsOn(installMagiskTask)
commandLine("adb", "reboot")
}

from(project.rootDir.resolve("module"))
}
tasks.register<Exec>("installKsuAndReboot$variantNameCapped") {
group = "PIF Install & Reboot"
dependsOn(installKsuTask)
commandLine("adb", "reboot")
}

afterEvaluate {
tasks["assembleRelease"].finalizedBy("updateModuleProp", "copyFiles", "zip")
tasks.register<Exec>("installApatchAndReboot$variantNameCapped") {
group = "PIF Install & Reboot"
dependsOn(installApatchTask)
commandLine("adb", "reboot")
}
}
1 change: 1 addition & 0 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.30.5)

project("playintegrityfix")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

link_libraries(log)

Expand Down
18 changes: 13 additions & 5 deletions app/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
}
}
}

Expand All @@ -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) {
Expand Down
Loading