mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Support building on case insensitive filesystems
Fix #4643, close #4641
This commit is contained in:
parent
ca99808fd2
commit
714feeb9a7
@ -10,10 +10,12 @@ import javax.crypto.Cipher
|
|||||||
import javax.crypto.CipherOutputStream
|
import javax.crypto.CipherOutputStream
|
||||||
import javax.crypto.spec.IvParameterSpec
|
import javax.crypto.spec.IvParameterSpec
|
||||||
import javax.crypto.spec.SecretKeySpec
|
import javax.crypto.spec.SecretKeySpec
|
||||||
|
import kotlin.random.asKotlinRandom
|
||||||
|
|
||||||
// Set non-zero value here to fix the random seed to create reproducible builds
|
// Set non-zero value here to fix the random seed for reproducible builds
|
||||||
const val RAND_SEED = 0
|
const val RAND_SEED = 0
|
||||||
private lateinit var RANDOM: Random
|
private lateinit var RANDOM: Random
|
||||||
|
private val kRANDOM get() = RANDOM.asKotlinRandom()
|
||||||
|
|
||||||
private val c1 = mutableListOf<String>()
|
private val c1 = mutableListOf<String>()
|
||||||
private val c2 = mutableListOf<String>()
|
private val c2 = mutableListOf<String>()
|
||||||
@ -195,15 +197,19 @@ fun genStubManifest(srcDir: File, outDir: File): String {
|
|||||||
names.addAll(c3.subList(0, 10))
|
names.addAll(c3.subList(0, 10))
|
||||||
names.shuffle(RANDOM)
|
names.shuffle(RANDOM)
|
||||||
|
|
||||||
|
// Decapitalize as older Android versions do not allow capitalized package names
|
||||||
|
// Distinct by lower case to support case insensitive file systems
|
||||||
|
val pkgNames = names.map { it.decapitalize(Locale.ROOT) }
|
||||||
|
.distinctBy { it.toLowerCase(Locale.ROOT) }
|
||||||
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
fun genCmpName(): String {
|
fun genCmpName() = "${pkgNames[idx++]}.${names.random(kRANDOM)}"
|
||||||
val name = "${names[idx++]}.${names[idx++]}"
|
|
||||||
return name[0].toLowerCase() + name.substring(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun genClass(clzName: String, type: String) {
|
fun genClass(clzName: String, type: String) {
|
||||||
val (pkg, name) = clzName.split('.')
|
val (pkg, name) = clzName.split('.')
|
||||||
PrintStream(File(mainPkgDir, "$name.java")).use {
|
val pkgDir = File(outDir, pkg)
|
||||||
|
pkgDir.mkdir()
|
||||||
|
PrintStream(File(pkgDir, "$name.java")).use {
|
||||||
it.println("package $pkg;")
|
it.println("package $pkg;")
|
||||||
it.println("public class $name extends com.topjohnwu.magisk.$type {}")
|
it.println("public class $name extends com.topjohnwu.magisk.$type {}")
|
||||||
}
|
}
|
||||||
@ -254,7 +260,7 @@ fun genEncryptedResources(res: File, outDir: File) {
|
|||||||
it.delete()
|
it.delete()
|
||||||
txt
|
txt
|
||||||
}
|
}
|
||||||
File(mainPkgDir, "A.java").writeText(r.replace("class R", "class A"))
|
File(mainPkgDir, "R2.java").writeText(r.replace("class R", "class R2"))
|
||||||
|
|
||||||
// Generate iv and key
|
// Generate iv and key
|
||||||
val iv = ByteArray(16)
|
val iv = ByteArray(16)
|
||||||
|
@ -4,10 +4,10 @@ import static android.R.string.no;
|
|||||||
import static android.R.string.ok;
|
import static android.R.string.ok;
|
||||||
import static android.R.string.yes;
|
import static android.R.string.yes;
|
||||||
import static com.topjohnwu.magisk.DelegateApplication.dynLoad;
|
import static com.topjohnwu.magisk.DelegateApplication.dynLoad;
|
||||||
import static com.topjohnwu.magisk.A.string.dling;
|
import static com.topjohnwu.magisk.R2.string.dling;
|
||||||
import static com.topjohnwu.magisk.A.string.no_internet_msg;
|
import static com.topjohnwu.magisk.R2.string.no_internet_msg;
|
||||||
import static com.topjohnwu.magisk.A.string.relaunch_app;
|
import static com.topjohnwu.magisk.R2.string.relaunch_app;
|
||||||
import static com.topjohnwu.magisk.A.string.upgrade_msg;
|
import static com.topjohnwu.magisk.R2.string.upgrade_msg;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user