Skip to content

Commit

Permalink
port vido and yggx
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Jul 29, 2024
1 parent 3600924 commit 396369d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
80 changes: 80 additions & 0 deletions app/src/main/java/org/andbootmgr/app/DeviceInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,84 @@ object HardcodedDeviceInfoFactory {
}
}

private fun getYggdrasilx(): DeviceInfo {
return object : DeviceInfo {
override val codename: String = "yggdrasilx"
override val blBlock: String = "/dev/block/by-name/lk"
override val bdev: String = "/dev/block/mmcblk1"
override val pbdev: String = bdev + "p"
override val metaonsd: Boolean = true
override val postInstallScript: Boolean = true
override val havedtbo: Boolean = false
override fun isInstalled(logic: DeviceLogic): Boolean {
return SuFile.open(bdev).exists() && run {
val meta: SDUtils.SDPartitionMeta? =
SDUtils.generateMeta(bdev, pbdev)
meta?.let { (meta.countPartitions() > 0) && (meta.dumpPartition(0).type == SDUtils.PartitionType.RESERVED) } == true
}
}
@SuppressLint("PrivateApi")
override fun isBooted(logic: DeviceLogic): Boolean {
var hasABM = false
try {
val c = Class.forName("android.os.SystemProperties")
val getBoolean: Method = c.getMethod(
"getBoolean",
String::class.java,
Boolean::class.javaPrimitiveType
)
hasABM = getBoolean.invoke(c, "ro.boot.has_dualboot", false) as Boolean
|| getBoolean.invoke(c, "ro.boot.hasdualboot", false) as Boolean
} catch (e: Exception) {
e.printStackTrace()
}
return hasABM
}
override fun isCorrupt(logic: DeviceLogic): Boolean {
return !SuFile.open(logic.abmDb, "db.conf").exists()
}
}
}

private fun getVidofnir(): DeviceInfo {
return object : DeviceInfo {
override val codename: String = "vidofnir"
override val blBlock: String = "/dev/block/by-name/lk"
override val bdev: String = "/dev/block/mmcblk0"
override val pbdev: String = bdev + "p"
override val metaonsd: Boolean = true
override val postInstallScript: Boolean = false
override val havedtbo: Boolean = false
override fun isInstalled(logic: DeviceLogic): Boolean {
return SuFile.open(bdev).exists() && run {
val meta: SDUtils.SDPartitionMeta? =
SDUtils.generateMeta(bdev, pbdev)
meta?.let { (meta.countPartitions() > 0) && (meta.dumpPartition(0).type == SDUtils.PartitionType.RESERVED) } == true
}
}
@SuppressLint("PrivateApi")
override fun isBooted(logic: DeviceLogic): Boolean {
var hasABM = false
try {
val c = Class.forName("android.os.SystemProperties")
val getBoolean: Method = c.getMethod(
"getBoolean",
String::class.java,
Boolean::class.javaPrimitiveType
)
hasABM = getBoolean.invoke(c, "ro.boot.hasdualboot", false) as Boolean
} catch (e: Exception) {
e.printStackTrace()
}
return hasABM
}

override fun isCorrupt(logic: DeviceLogic): Boolean {
return !SuFile.open(logic.abmDb, "db.conf").exists()
}
}
}

private fun getVayu(): DeviceInfo {
return object : DeviceInfo {
override val codename: String = "vayu"
Expand Down Expand Up @@ -137,8 +215,10 @@ object HardcodedDeviceInfoFactory {
fun get(codename: String): DeviceInfo? {
return when (codename) {
"yggdrasil" -> getYggdrasil()
"yggdrasilx" -> getYggdrasilx()
"cedric" -> getCedric()
"mimameid" -> getMimameid()
"vidofnir" -> getVidofnir()
"vayu" -> getVayu()
else -> null
}
Expand Down

0 comments on commit 396369d

Please sign in to comment.