Set boot digest via resetprop (#22)

The stub method `SystemProperties.set` has wrong signature and is unable to set read-only system properties.
This commit is contained in:
JingMatrix
2025-11-28 13:11:54 +01:00
committed by GitHub
parent 22cbe5a9a7
commit 4f608247fe
2 changed files with 18 additions and 7 deletions
@@ -70,7 +70,7 @@ object AndroidDeviceUtils {
} }
/** /**
* Sets the `ro.boot.vbmeta.digest` system property. * Sets the `ro.boot.vbmeta.digest` system property using the `resetprop` command.
* *
* @param bytes The 32-byte digest to set. * @param bytes The 32-byte digest to set.
*/ */
@@ -78,9 +78,24 @@ object AndroidDeviceUtils {
val hex = bytes.toHex() val hex = bytes.toHex()
try { try {
SystemLogger.debug("Setting system property 'ro.boot.vbmeta.digest' to: $hex") SystemLogger.debug("Setting system property 'ro.boot.vbmeta.digest' to: $hex")
SystemProperties.set("ro.boot.vbmeta.digest", hex)
// Construct the command to be executed
val command = arrayOf("resetprop", "ro.boot.vbmeta.digest", hex)
// Execute the command
val process = Runtime.getRuntime().exec(command)
// Wait for the process to complete and check the exit code for errors
val exitCode = process.waitFor()
if (exitCode != 0) {
val errorOutput = process.errorStream.bufferedReader().readText()
SystemLogger.error(
"resetprop command failed with exit code $exitCode: $errorOutput"
)
}
} catch (e: Exception) { } catch (e: Exception) {
SystemLogger.error("Failed to set vbmeta digest property.", e) SystemLogger.error("Failed to set vbmeta digest property by executing resetprop.", e)
} }
} }
@@ -4,8 +4,4 @@ public class SystemProperties {
public static String get(String key, String def) { public static String get(String key, String def) {
throw new UnsupportedOperationException("STUB!"); throw new UnsupportedOperationException("STUB!");
} }
public static String set(String key, String val) {
throw new UnsupportedOperationException("STUB!");
}
} }