Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
39 changes: 7 additions & 32 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ name: Core

on:
workflow_dispatch:
inputs:
post_telegram:
description: 'Post to Telegram'
required: true
type: boolean
push:
branches: [ master ]
tags: [ v* ]
Expand Down Expand Up @@ -86,29 +81,29 @@ jobs:
if: success()
id: prepareArtifact
run: |
zygiskReleaseName=`ls magisk-loader/release/LSPosed-v*-zygisk-release.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskReleaseName=$zygiskReleaseName" >> $GITHUB_OUTPUT
zygiskDebugName=`ls magisk-loader/release/LSPosed-v*-zygisk-debug.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskDebugName=$zygiskDebugName" >> $GITHUB_OUTPUT
unzip magisk-loader/release/LSPosed-v*-zygisk-release.zip -d LSPosed-zygisk-release
unzip magisk-loader/release/LSPosed-v*-zygisk-debug.zip -d LSPosed-zygisk-debug
zygiskReleaseName=`ls zygisk/release/Vector-v*-Release.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskReleaseName=$zygiskReleaseName" >> $GITHUB_OUTPUT
zygiskDebugName=`ls zygisk/release/Vector-v*-Debug.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskDebugName=$zygiskDebugName" >> $GITHUB_OUTPUT
unzip zygisk/release/Vector-v*-Release.zip -d Vector-Release
unzip zygisk/release/Vector-v*-Debug.zip -d Vector-Debug

- name: Upload zygisk release
uses: actions/upload-artifact@v6
with:
name: ${{ steps.prepareArtifact.outputs.zygiskReleaseName }}
path: "./LSPosed-zygisk-release/*"
path: "./Vector-Release/*"

- name: Upload zygisk debug
uses: actions/upload-artifact@v6
with:
name: ${{ steps.prepareArtifact.outputs.zygiskDebugName }}
path: "./LSPosed-zygisk-debug/*"
path: "./Vector-Debug/*"

- name: Upload mappings
uses: actions/upload-artifact@v6
with:
name: mappings
path: |
magisk-loader/build/outputs/mapping
zygisk/build/outputs/mapping
app/build/outputs/mapping

- name: Upload symbols
Expand All @@ -117,23 +112,3 @@ jobs:
name: symbols
path: build/symbols

- name: Post to channel
if: ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.ref_type != 'tag' && inputs.post_telegram != 'false' }}
env:
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
DISCUSSION_ID: ${{ secrets.DISCUSSION_ID }}
TOPIC_ID: ${{ secrets.TOPIC_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_URL: ${{ github.event.head_commit.url }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
OUTPUT="magisk-loader/release/"
export riruRelease=$(find $OUTPUT -name "LSPosed-v*-riru-release.zip")
export riruDebug=$(find $OUTPUT -name "LSPosed-v*-riru-debug.zip")
export zygiskRelease=$(find $OUTPUT -name "LSPosed-v*-zygisk-release.zip")
export zygiskDebug=$(find $OUTPUT -name "LSPosed-v*-zygisk-debug.zip")
ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'`
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruDebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskDebug%22%2C%22caption%22:${ESCAPED}%7D%5D" -F riruRelease="@$riruRelease" -F riruDebug="@$riruDebug" -F zygiskRelease="@$zygiskRelease" -F zygiskDebug="@$zygiskDebug"
# curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${DISCUSSION_ID}&message_thread_id=${TOPIC_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruDebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskDebug%22%2C%22caption%22:${ESCAPED}%7D%5D" -F riruRelease="@$riruRelease" -F riruDebug="@$riruDebug" -F zygiskRelease="@$zygiskRelease" -F zygiskDebug="@$zygiskDebug"
fi
116 changes: 74 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2021 - 2022 LSPosed Contributors
*/

import com.android.build.api.dsl.ApplicationDefaultConfig
import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.api.AndroidBasePlugin
import com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask
import java.io.ByteArrayOutputStream
import javax.inject.Inject
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.process.ExecOperations

plugins {
alias(libs.plugins.lsplugin.cmaker)
Expand All @@ -32,43 +18,90 @@ plugins {
alias(libs.plugins.ktfmt)
}

/** A ValueSource that executes 'git rev-list --count' to get the total commit count. */
abstract class GitCommitCountValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:Inject abstract val execOperations: ExecOperations

override fun obtain(): String {
val output = ByteArrayOutputStream()
val result =
execOperations.exec {
commandLine("git", "rev-list", "--count", "refs/remotes/origin/master")
standardOutput = output
isIgnoreExitValue = true
}
// Return the count if successful, otherwise a default of "1".
return if (result.exitValue == 0 && output.toString().isNotBlank()) {
output.toString().trim()
} else {
"1"
}
}
}

/** A ValueSource that executes 'git tag' to get the latest version tag. */
abstract class GitLatestTagValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:Inject abstract val execOperations: ExecOperations

override fun obtain(): String {
val output = ByteArrayOutputStream()
val result =
execOperations.exec {
commandLine("git", "tag", "--list", "--sort=-v:refname")
standardOutput = output
isIgnoreExitValue = true
}
// If successful, parse the first line. Provide a default if no tags are found.
return if (result.exitValue == 0 && output.toString().isNotBlank()) {
output.toString().lineSequence().first().removePrefix("v")
} else {
"1.0"
}
}
}

// This defers the execution of the git commands and allows Gradle to cache the results.
val versionCodeProvider by extra(providers.of(GitCommitCountValueSource::class.java) {})
val versionNameProvider by extra(providers.of(GitLatestTagValueSource::class.java) {})

val repo = jgit.repo()
val commitCount = (repo?.commitCount("refs/remotes/origin/master") ?: 1) + 4200
val latestTag = repo?.latestTag?.removePrefix("v") ?: "1.0"

val injectedPackageName by extra("com.android.shell")
val injectedPackageUid by extra(2000)

val defaultManagerPackageName by extra("org.lsposed.manager")
val verCode by extra(commitCount)
val verName by extra(latestTag)

cmaker {
default {
arguments.addAll(
arrayOf("-DVECTOR_ROOT=${rootDir.absolutePath}", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
)
val flags =
arrayOf(
"-DEXTERNAL_ROOT=${File(rootDir.absolutePath, "external")}",
"-DCORE_ROOT=${File(rootDir.absolutePath, "core/src/main/jni")}",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DINJECTED_UID=$injectedPackageUid",
"-DVERSION_CODE=${verCode}",
"-DVERSION_NAME='\"${verName}\"'",
"-Wno-gnu-string-literal-operator-template",
"-Wno-c++2b-extensions",
)
)
val flags = arrayOf(
"-DINJECTED_AID=$injectedPackageUid",
"-Wno-gnu-string-literal-operator-template",
"-Wno-c++2b-extensions",
)
cFlags.addAll(flags)
cppFlags.addAll(flags)
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
}
buildTypes {
if (it.name == "release") {
arguments += "-DDEBUG_SYMBOLS_PATH=${
arguments +=
"-DDEBUG_SYMBOLS_PATH=${
layout.buildDirectory.dir("symbols").get().asFile.absolutePath
}"
}
}
}

val repo = jgit.repo()
val commitCount = (repo?.commitCount("refs/remotes/origin/master") ?: 1) + 4200
val latestTag = repo?.latestTag?.removePrefix("v") ?: "1.0"

val injectedPackageName by extra("com.android.shell")
val injectedPackageUid by extra(2000)

val defaultManagerPackageName by extra("org.lsposed.manager")
val verCode by extra(commitCount)
val verName by extra(latestTag)
val androidTargetSdkVersion by extra(36)
val androidMinSdkVersion by extra(27)
val androidBuildToolsVersion by extra("36.0.0")
Expand All @@ -77,9 +110,7 @@ val androidCompileNdkVersion by extra("29.0.13113456")
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)

tasks.register("Delete", Delete::class) {
delete(rootProject.layout.buildDirectory)
}
tasks.register("Delete", Delete::class) { delete(rootProject.layout.buildDirectory) }

subprojects {
plugins.withType(AndroidBasePlugin::class.java) {
Expand Down Expand Up @@ -127,6 +158,7 @@ tasks.register<KtfmtFormatTask>("format") {
source = project.fileTree(rootDir)
include("*.gradle.kts", "*/build.gradle.kts")
dependsOn(":xposed:ktfmtFormat")
dependsOn(":zygisk:ktfmtFormat")
}

ktfmt { kotlinLangStyle() }
7 changes: 0 additions & 7 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ android {
}
}

copy {
from("src/main/jni/template/") {
expand("VERSION_CODE" to "$verCode", "VERSION_NAME" to verName)
}
into("src/main/jni/src/")
}

dependencies {
api(projects.xposed)
implementation(projects.external.apache)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/android/content/res/XResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package android.content.res;

import static org.lsposed.lspd.nativebridge.ResourcesHook.rewriteXmlReferencesNative;
import static org.matrix.vector.nativebridge.ResourcesHook.rewriteXmlReferencesNative;
import static de.robv.android.xposed.XposedHelpers.decrementMethodDepth;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.getBooleanField;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/de/robv/android/xposed/XposedBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import org.lsposed.lspd.impl.LSPosedBridge;
import org.lsposed.lspd.impl.LSPosedHookCallback;
import org.lsposed.lspd.nativebridge.HookBridge;
import org.lsposed.lspd.nativebridge.ResourcesHook;
import org.matrix.vector.nativebridge.HookBridge;
import org.matrix.vector.nativebridge.ResourcesHook;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Executable;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/de/robv/android/xposed/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

import org.lsposed.lspd.impl.LSPosedContext;
import org.lsposed.lspd.models.PreLoadedApk;
import org.lsposed.lspd.nativebridge.NativeAPI;
import org.lsposed.lspd.nativebridge.ResourcesHook;
import org.matrix.vector.nativebridge.NativeAPI;
import org.matrix.vector.nativebridge.ResourcesHook;
import org.lsposed.lspd.util.LspModuleClassLoader;
import org.lsposed.lspd.util.Utils.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_BOOT_IMAGE_MIUI_RES;
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_SYSTEM_SERVER;

import org.lsposed.lspd.nativebridge.HookBridge;
import org.matrix.vector.nativebridge.HookBridge;
import org.lsposed.lspd.util.Hookers;
import org.lsposed.lspd.util.Utils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.os.Build;

import org.lsposed.lspd.impl.LSPosedBridge;
import org.lsposed.lspd.nativebridge.HookBridge;
import org.matrix.vector.nativebridge.HookBridge;

import io.github.libxposed.api.XposedInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import androidx.annotation.NonNull;

import org.lsposed.lspd.nativebridge.HookBridge;
import org.matrix.vector.nativebridge.HookBridge;
import org.lsposed.lspd.util.Utils.Log;

import java.lang.reflect.Executable;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/lsposed/lspd/impl/LSPosedContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import org.lsposed.lspd.core.BuildConfig;
import org.lsposed.lspd.models.Module;
import org.lsposed.lspd.nativebridge.HookBridge;
import org.lsposed.lspd.nativebridge.NativeAPI;
import org.matrix.vector.nativebridge.HookBridge;
import org.matrix.vector.nativebridge.NativeAPI;
import org.lsposed.lspd.service.ILSPInjectedModuleService;
import org.lsposed.lspd.util.LspModuleClassLoader;
import org.lsposed.lspd.util.Utils.Log;
Expand Down
26 changes: 0 additions & 26 deletions core/src/main/jni/CMakeLists.txt

This file was deleted.

Loading