Skip to content

Commit

Permalink
Update USBMounter.kt
Browse files Browse the repository at this point in the history
Add code for unmounting image when in BACKEND_TYPE.CONFIGFS mode
  • Loading branch information
rareranger authored Jan 28, 2022
1 parent 59af015 commit 92f2aef
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions app/src/main/java/org/ktech/ps4jailbreak/USBMounter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,24 @@ class USBMounter {
onLogMessage(msg)
}
} else if (backendType == BACKEND_TYPE.CONFIGFS) {
val msg = "Reboot Device to reset USB for normal usage."
toast(msg, true)
onLogMessage(msg)
val usb = "/config/usb_gadget/g1"
try {
val exitCode = Shell.Pool.SU.run(arrayOf(
//GET UDC from somewhere first
//Disable USB
"echo -n '' > $usb/UDC",
//Remove UDC configuration
"rm $usb/configs/b.1/f1/mass_storage.0",
//Restore normal state
"setprop sys.usb.config mtp"
))
onLogMessage("Operation exited with code: $exitCode...")
} catch (e: Shell.ShellDiedException) {
val msg = "Device not rooted or SU missing."
Log.e("ERROR", msg)
toast(msg, true)
onLogMessage(msg)
}
}
}

Expand Down

0 comments on commit 92f2aef

Please sign in to comment.