Last active
March 4, 2024 02:18
-
-
Save devstar0209/8e47cc0fee3cc8153daa19879dce4628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy disk image of android device | |
// example adb command : adb shell su -c "dd if=/dev/block/bootdevice/by-name/system of=/sdcard/system.img" | |
// In this example, replace /dev/block/bootdevice/by-name/system with the specific partition or block you want to image, | |
// and /sdcard/system.img with the desired output file | |
// example adb command: adb pull /dev/block/mmcblk0 mmcblk0.img | |
String[] arrayCommand = {"sh", "-c","dumpsys telephony.registry | grep \"permission\""}; | |
// in kotllin | |
val arrayCommand = arrayOf("su", "-c", "dumpsys", "telephony.registry", "|", "grep", "\"mCi=\"") | |
Runtime r = Runtime.getRuntime(); | |
Process process = r.exec(arrayCommand); | |
String stdoutString = convertInputStreamToString(process.getInputStream()); | |
String stderrString = convertInputStreamToString(process.getErrorStream()); | |
/********/ | |
Process process = Runtime.getRuntime().exec("your command"); | |
BufferedReader bufferedReader = new BufferedReader( | |
new InputStreamReader(process.getInputStream())); | |
/********/ | |
Runtime.getRuntime().exec("settings put system csc_pref_camera_forced_shuttersound_key 0"); | |
/*******/ | |
fun executeExtended(command: String): Int { | |
val process = Runtime.getRuntime().exec(command) | |
commandOutput(process) | |
return process.waitFor() | |
} | |
fun commandOutput(process: Process) { | |
val stdInput = process.inputStream.bufferedReader(Charsets.UTF_8).use { it.readText() } | |
if (stdInput.isNotEmpty()) println(stdInput) | |
val stdError = process.errorStream.bufferedReader(Charsets.UTF_8).use { it.readText() } | |
if (stdError.isNotEmpty()) println(stdError) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment