Proper app relaunch for stub

This commit is contained in:
topjohnwu
2022-02-02 04:44:22 -08:00
parent f4cf5dc0cd
commit c1fc3f373c
5 changed files with 68 additions and 26 deletions

View File

@ -77,7 +77,8 @@ fun genStubManifest(srcDir: File, outDir: File): String {
class Component(
val real: String,
val stub: String,
val xml: String
val xml: String,
val genClass: Boolean = false
)
outDir.deleteRecursively()
@ -92,13 +93,26 @@ fun genStubManifest(srcDir: File, outDir: File): String {
cmpList.add(Component(
"androidx.core.app.CoreComponentFactory",
"DelegateComponentFactory",
""
"",
true
))
cmpList.add(Component(
"com.topjohnwu.magisk.core.App",
"DelegateApplication",
""
"",
true
))
cmpList.add(Component(
"PHOENIX",
"PhoenixActivity",
"""
|<activity
| android:name="%s"
| android:process=":%s"
| android:exported="false" />""".ind(2),
true
))
cmpList.add(Component(
@ -236,12 +250,12 @@ fun genStubManifest(srcDir: File, outDir: File): String {
maps.append("|internalMap.put(\"$name\", com.topjohnwu.magisk.${gen.stub}.class);".ind(2))
maps.append('\n')
}
if (gen.stub.startsWith("Delegate")) {
if (gen.genClass) {
genClass(name, gen.stub)
}
}
if (gen.xml.isNotEmpty()) {
cmps.add(gen.xml.format(name))
cmps.add(gen.xml.format(name, names.random(kRANDOM)))
}
}