in src/main/kotlin/com/uber/nanoscope/Nanoscope.kt [224:252]
fun flashDevice(romUrl: String) {
if (Adb.getDeviceHardware() != "angler") {
throw FlashException("Sorry, Nexus 6p is currently the only supported device.")
}
Adb.root()
val md5 = MessageDigest.getInstance("MD5").digest(romUrl.toByteArray())
val key = Base64.encode(md5)
val outDir = File(configDir, "roms/$key")
downloadZipIfNecessary(outDir, romUrl)
val installScript = File(outDir, "install.sh")
if (!installScript.exists()) {
throw FlashException("Invalid ROM. install.sh script does not exist.")
}
installScript.setExecutable(true)
println("Flashing device...")
val status = ProcessBuilder("./install.sh")
.directory(outDir)
.inheritIO()
.start()
.waitFor()
if (status != 0) {
throw FlashException("Flash failed: $status")
}
}