forked from Dr-TSNG/Hide-My-Applist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3.0.0 Dev: Rewrite backend & Drop Magisk extension
- Loading branch information
Showing
49 changed files
with
865 additions
and
1,134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,152 +1,88 @@ | ||
import com.android.build.api.component.analytics.AnalyticsEnabledApplicationVariant | ||
import com.android.build.api.variant.impl.ApplicationVariantImpl | ||
import com.android.build.gradle.BaseExtension | ||
import com.android.ide.common.signing.KeystoreHelper | ||
import org.jetbrains.kotlin.konan.properties.Properties | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import java.io.PrintStream | ||
|
||
val minSdkVer: Int by rootProject.extra | ||
val targetSdkVer: Int by rootProject.extra | ||
|
||
val appVerName: String by rootProject.extra | ||
val appVerCode: Int by rootProject.extra | ||
val serviceVer: Int by rootProject.extra | ||
val minExtensionVer: Int by rootProject.extra | ||
val minBackupVer: Int by rootProject.extra | ||
|
||
val gitCommitCount: String by rootProject.extra | ||
val gitCommitHash: String by rootProject.extra | ||
|
||
val properties = Properties() | ||
properties.load(project.rootProject.file("local.properties").inputStream()) | ||
import java.util.* | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("com.google.gms.google-services") | ||
id("dev.rikka.tools.refine") | ||
kotlin("android") | ||
} | ||
|
||
android { | ||
compileSdk = targetSdkVer | ||
namespace = "com.tsng.hidemyapplist" | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
defaultConfig { | ||
applicationId = "com.tsng.hidemyapplist" | ||
versionCode = appVerCode | ||
versionName = appVerName | ||
minSdk = minSdkVer | ||
targetSdk = targetSdkVer | ||
|
||
multiDexEnabled = false | ||
if (properties.getProperty("buildWithGitSuffix").toBoolean()) | ||
versionNameSuffix = ".r${gitCommitCount}.${gitCommitHash}" | ||
|
||
buildConfigField("int", "SERVICE_VERSION", serviceVer.toString()) | ||
buildConfigField("int", "MIN_EXTENSION_VERSION", minExtensionVer.toString()) | ||
buildConfigField("int", "MIN_BACKUP_VERSION", minBackupVer.toString()) | ||
} | ||
|
||
signingConfigs.create("config") { | ||
storeFile = file(properties.getProperty("fileDir")) | ||
storePassword = properties.getProperty("storePassword") | ||
keyAlias = properties.getProperty("keyAlias") | ||
keyPassword = properties.getProperty("keyPassword") | ||
} | ||
|
||
buildTypes { | ||
signingConfigs.named("config").get().also { | ||
debug { | ||
signingConfig = it | ||
} | ||
release { | ||
signingConfig = it | ||
isMinifyEnabled = true | ||
isShrinkResources = true | ||
proguardFiles("proguard-rules.pro") | ||
fun afterEval() = android.applicationVariants.forEach { variant -> | ||
val variantCapped = variant.name.capitalize(Locale.ROOT) | ||
val variantLowered = variant.name.toLowerCase(Locale.ROOT) | ||
|
||
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}") | ||
val outSrc = file("$outSrcDir/com/tsng/hidemyapplist/Magic.java") | ||
val signInfoTask = task("generate${variantCapped}SignInfo") { | ||
dependsOn("validateSigning${variantCapped}") | ||
outputs.file(outSrc) | ||
doLast { | ||
val sign = android.buildTypes[variantLowered].signingConfig | ||
outSrc.parentFile.mkdirs() | ||
val certificateInfo = KeystoreHelper.getCertificateInfo( | ||
sign?.storeType, | ||
sign?.storeFile, | ||
sign?.storePassword, | ||
sign?.keyPassword, | ||
sign?.keyAlias | ||
) | ||
PrintStream(outSrc).apply { | ||
println("package com.tsng.hidemyapplist;") | ||
println("public final class Magic {") | ||
print("public static final byte[] magicNumbers = {") | ||
val bytes = certificateInfo.certificate.encoded | ||
print(bytes.joinToString(",") { it.toString() }) | ||
println("};") | ||
println("}") | ||
} | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
variant.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir)) | ||
|
||
val kotlinCompileTask = tasks.findByName("compile${variantCapped}Kotlin") as KotlinCompile | ||
kotlinCompileTask.dependsOn(signInfoTask) | ||
val srcSet = objects.sourceDirectorySet("magic", "magic").srcDir(outSrcDir) | ||
kotlinCompileTask.source(srcSet) | ||
|
||
task<Sync>("build$variantCapped") { | ||
dependsOn("assemble$variantCapped") | ||
from("$buildDir/outputs/apk/$variantLowered") | ||
into("$buildDir/apk/$variantLowered") | ||
rename(".*.apk", "HMA-V${variant.versionName}-${variant.buildType.name}.apk") | ||
} | ||
} | ||
|
||
// This code is forked from LSPosed | ||
// Make a class containing a byte array of signature | ||
androidComponents.onVariants { v -> | ||
val variant: ApplicationVariantImpl = | ||
if (v is ApplicationVariantImpl) v | ||
else (v as AnalyticsEnabledApplicationVariant).delegate as ApplicationVariantImpl | ||
val variantCapped = variant.name.capitalize() | ||
val variantLowered = variant.name.toLowerCase() | ||
|
||
variant.outputs.forEach { | ||
it.outputFileName.set("V${it.versionName.get()}-${variant.buildType}.apk") | ||
} | ||
|
||
afterEvaluate { | ||
val app = rootProject.project(":app").extensions.getByName<BaseExtension>("android") | ||
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}") | ||
val outSrc = file("$outSrcDir/com/tsng/hidemyapplist/Magic.java") | ||
val signInfoTask = tasks.register("generate${variantCapped}SignInfo") { | ||
dependsOn(":app:validateSigning${variantCapped}") | ||
outputs.file(outSrc) | ||
doLast { | ||
val sign = app.buildTypes.named(variantLowered).get().signingConfig | ||
outSrc.parentFile.mkdirs() | ||
val certificateInfo = KeystoreHelper.getCertificateInfo( | ||
sign?.storeType, | ||
sign?.storeFile, | ||
sign?.storePassword, | ||
sign?.keyPassword, | ||
sign?.keyAlias | ||
) | ||
PrintStream(outSrc).apply { | ||
println("package com.tsng.hidemyapplist;") | ||
println("public final class Magic {") | ||
print("public static final byte[] magicNumbers = {") | ||
val bytes = certificateInfo.certificate.encoded | ||
print(bytes.joinToString(",") { it.toString() }) | ||
println("};") | ||
println("}") | ||
} | ||
} | ||
} | ||
variant.variantData.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir)) | ||
|
||
val kotlinCompileTask = | ||
tasks.findByName("compile${variant.name.capitalize()}Kotlin") as? SourceTask | ||
if (kotlinCompileTask != null) { | ||
kotlinCompileTask.dependsOn(signInfoTask) | ||
val srcSet = objects.sourceDirectorySet("magic", "magic").srcDir(outSrcDir) | ||
kotlinCompileTask.source(srcSet) | ||
} | ||
} | ||
afterEvaluate { | ||
afterEval() | ||
} | ||
|
||
dependencies { | ||
implementation("com.drakeet.about:about:2.5.0") | ||
implementation("com.drakeet.multitype:multitype:4.3.0") | ||
implementation("com.scwang.smart:refresh-layout-kernel:2.0.3") | ||
implementation("com.scwang.smart:refresh-header-material:2.0.3") | ||
implementation("com.github.kyuubiran:EzXHelper:0.6.1") | ||
implementation("com.github.topjohnwu.libsu:core:3.1.2") | ||
implementation(projects.common) | ||
runtimeOnly(projects.xposed) | ||
|
||
implementation("com.google.code.gson:gson:2.8.9") | ||
implementation("com.google.android.material:material:1.5.0") | ||
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.3") | ||
implementation("androidx.appcompat:appcompat:1.4.1") | ||
implementation("androidx.preference:preference-ktx:1.2.0") | ||
implementation("androidx.appcompat:appcompat:1.4.2") | ||
implementation("androidx.fragment:fragment-ktx:1.4.1") | ||
implementation("androidx.preference:preference-ktx:1.2.0") | ||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") | ||
implementation("androidx.work:work-runtime-ktx:2.7.1") | ||
implementation("com.google.android.gms:play-services-ads:20.5.0") | ||
implementation("com.google.firebase:firebase-analytics-ktx:20.1.0") | ||
|
||
compileOnly("de.robv.android.xposed:api:82") | ||
compileOnly("de.robv.android.xposed:api:82:sources") | ||
implementation("com.drakeet.about:about:2.5.1") | ||
implementation("com.drakeet.multitype:multitype:4.3.0") | ||
implementation("com.github.topjohnwu.libsu:core:3.1.2") | ||
implementation("com.google.android.material:material:1.6.1") | ||
implementation("com.google.android.gms:play-services-ads:21.0.0") | ||
implementation("com.google.firebase:firebase-analytics-ktx:21.0.0") | ||
implementation("com.squareup.okhttp3:okhttp:4.9.1") | ||
implementation("dev.rikka.hidden:compat:2.3.1") | ||
compileOnly("dev.rikka.hidden:stub:2.3.1") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
com.tsng.hidemyapplist.xposed.XposedEntry | ||
icu.nullptr.hidemyapplist.xposed.XposedEntry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.