Skip to content

Commit

Permalink
feat(ManifestPatcher): remove vmSafeMode attribute
Browse files Browse the repository at this point in the history
Unnecessary since GrapheneOS didn't enable aggressive AOT until recently (which was already API >= 29) and is that branch covered by another workaround.
  • Loading branch information
rushiiMachine committed Jan 23, 2025
1 parent 5af13c9 commit 543360e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package com.aliucord.manager.patcher.util

import android.Manifest
import android.os.Build
import com.aliucord.manager.util.isGrapheneOS
import pxb.android.axml.*

object ManifestPatcher {
Expand Down Expand Up @@ -100,14 +99,12 @@ object ManifestPatcher {
) {
private var addDebuggable = debuggable
private var addLegacyStorage = true
private var addVmSafeMode = true
private var addUseEmbeddedDex = true
private var addExtractNativeLibs = true

override fun attr(ns: String?, name: String, resourceId: Int, type: Int, value: Any?) {
if (name == NETWORK_SECURITY_CONFIG) return
if (name == REQUEST_LEGACY_EXTERNAL_STORAGE) addLegacyStorage = false
if (name == VM_SAFE_MODE) addVmSafeMode = false
if (name == USE_EMBEDDED_DEX) addUseEmbeddedDex = false
if (name == EXTRACT_NATIVE_LIBS) addExtractNativeLibs = false
if (name == DEBUGGABLE) addDebuggable = false
Expand Down Expand Up @@ -153,10 +150,6 @@ object ManifestPatcher {
if (Build.VERSION.SDK_INT >= 29 && addUseEmbeddedDex) {
super.attr(ANDROID_NAMESPACE, USE_EMBEDDED_DEX, android.R.attr.useEmbeddedDex, TYPE_INT_BOOLEAN, 1)
}
// GrapheneOS also forces AOT, disable it in a worse way if below API 29
else if (isGrapheneOS() && addVmSafeMode) {
super.attr(ANDROID_NAMESPACE, VM_SAFE_MODE, android.R.attr.vmSafeMode, TYPE_INT_BOOLEAN, 1)
}

if (addExtractNativeLibs) super.attr(
ANDROID_NAMESPACE,
Expand All @@ -179,24 +172,6 @@ object ManifestPatcher {
return writer.toByteArray()
}

fun renamePackage(
manifestBytes: ByteArray,
packageName: String,
): ByteArray {
val reader = AxmlReader(manifestBytes)
val writer = AxmlWriter()

reader.accept(
object : AxmlVisitor(writer) {
override fun child(ns: String?, name: String?): ReplaceAttrsVisitor {
return ReplaceAttrsVisitor(super.child(ns, name), mapOf("package" to packageName))
}
}
)

return writer.toByteArray()
}

private open class ReplaceAttrsVisitor(
nv: NodeVisitor,
private val attrs: Map<String, Any>,
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/kotlin/com/aliucord/manager/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ fun isMiui(): Boolean {
?.isNotEmpty() ?: false
}


/**
* Checks whether this device is possibly running GrapheneOS.
*/
fun isGrapheneOS(): Boolean {
return Build.USER == "grapheneos" || Build.HOST == "grapheneos"
}

/**
* Gets a system property from build.prop
*/
Expand Down

0 comments on commit 543360e

Please sign in to comment.