forked from LSPosed/LSPosed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
125 lines (110 loc) · 3.86 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* 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 LSPosed Contributors
*/
import com.android.build.api.dsl.ApplicationExtension
import com.android.ide.common.signing.KeystoreHelper
import java.io.PrintStream
plugins {
alias(libs.plugins.agp.app)
alias(libs.plugins.lsplugin.resopt)
}
val daemonName = "LSPosed"
val injectedPackageName: String by rootProject.extra
val injectedPackageUid: Int by rootProject.extra
val agpVersion: String by project
val defaultManagerPackageName: String by rootProject.extra
android {
buildFeatures {
prefab = true
buildConfig = true
}
defaultConfig {
applicationId = "org.lsposed.daemon"
buildConfigField(
"String",
"DEFAULT_MANAGER_PACKAGE_NAME",
""""$defaultManagerPackageName""""
)
buildConfigField("String", "MANAGER_INJECTED_PKG_NAME", """"$injectedPackageName"""")
buildConfigField("int", "MANAGER_INJECTED_UID", """$injectedPackageUid""")
}
buildTypes {
all {
externalNativeBuild {
cmake {
arguments += "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=true"
}
}
}
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles("proguard-rules.pro")
}
}
externalNativeBuild {
cmake {
path("src/main/jni/CMakeLists.txt")
}
}
namespace = "org.lsposed.daemon"
}
android.applicationVariants.all {
val variantCapped = name.replaceFirstChar { it.uppercase() }
val variantLowered = name.lowercase()
val outSrcDir =
layout.buildDirectory.dir("generated/source/signInfo/${variantLowered}").get()
val signInfoTask = tasks.register("generate${variantCapped}SignInfo") {
dependsOn(":app:validateSigning${variantCapped}")
val sign = rootProject.project(":app").extensions
.getByType(ApplicationExtension::class.java)
.buildTypes.named(variantLowered).get().signingConfig
val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java")
outputs.file(outSrc)
doLast {
outSrc.parentFile.mkdirs()
val certificateInfo = KeystoreHelper.getCertificateInfo(
sign?.storeType,
sign?.storeFile,
sign?.storePassword,
sign?.keyPassword,
sign?.keyAlias
)
PrintStream(outSrc).print(
"""
|package org.lsposed.lspd.util;
|public final class SignInfo {
| public static final byte[] CERTIFICATE = {${
certificateInfo.certificate.encoded.joinToString(",")
}};
|}""".trimMargin()
)
}
}
registerJavaGeneratingTask(signInfoTask, outSrcDir.asFile)
}
dependencies {
implementation(libs.libxposed.`interface`)
implementation(libs.agp.apksig)
implementation(libs.commons.lang3)
implementation(projects.hiddenapi.bridge)
implementation(projects.services.daemonService)
implementation(projects.services.managerService)
compileOnly(libs.androidx.annotation)
compileOnly(projects.hiddenapi.stubs)
}