Skip to content

Commit 3a9c118

Browse files
committed
android: revert to using relative paths for su
compatibility issues with magisk
1 parent 37313fb commit 3a9c118

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

android/app/src/main/java/me/kavishdevar/librepods/screens/Onboarding.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fun Onboarding(navController: NavController, activityContext: Context) {
111111
kotlinx.coroutines.MainScope().launch {
112112
withContext(Dispatchers.IO) {
113113
try {
114-
val process = Runtime.getRuntime().exec("/system/bin/su -c id")
114+
val process = Runtime.getRuntime().exec("su -c id")
115115
val exitValue = process.waitFor() // no idea why i have this, probably don't need to do this
116116
withContext(Dispatchers.Main) {
117117
rootCheckPassed = (exitValue == 0)

android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
349349

350350
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
351351

352-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "settings", "get", "secure", "bluetooth_address"))
352+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", "settings", "get", "secure", "bluetooth_address"))
353353
val output = process.inputStream.bufferedReader().use { it.readLine() }
354354
localMac = output.trim()
355355

@@ -954,7 +954,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
954954

955955
Log.d("AirPodsParser", "Stem press received: $stemPressType on $bud, cameraActive: $cameraActive, cameraAction: ${config.cameraAction}")
956956
if (cameraActive && config.cameraAction != null && stemPressType == config.cameraAction) {
957-
Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "input keyevent 27"))
957+
Runtime.getRuntime().exec(arrayOf("su", "-c", "input keyevent 27"))
958958
} else {
959959
val action = getActionFor(bud, stemPressType)
960960
Log.d("AirPodsParser", "$bud $stemPressType action: $action")

android/app/src/main/java/me/kavishdevar/librepods/utils/LogCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class LogCollector(private val context: Context) {
201201
private suspend fun executeRootCommand(command: String): String {
202202
return withContext(Dispatchers.IO) {
203203
try {
204-
val process = Runtime.getRuntime().exec("/system/bin/su -c $command")
204+
val process = Runtime.getRuntime().exec("su -c $command")
205205
val reader = BufferedReader(InputStreamReader(process.inputStream))
206206
val output = StringBuilder()
207207
var line: String?

android/app/src/main/java/me/kavishdevar/librepods/utils/RadareOffsetFinder.kt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RadareOffsetFinder(context: Context) {
7474
fun clearHookOffsets(): Boolean {
7575
try {
7676
val process = Runtime.getRuntime().exec(arrayOf(
77-
"/system/bin/su", "-c",
77+
"su", "-c",
7878
"/system/bin/setprop $HOOK_OFFSET_PROP '' && " +
7979
"/system/bin/setprop $CFG_REQ_OFFSET_PROP '' && " +
8080
"/system/bin/setprop $CSM_CONFIG_OFFSET_PROP '' && " +
@@ -98,7 +98,7 @@ class RadareOffsetFinder(context: Context) {
9898
fun clearSdpOffset(): Boolean {
9999
try {
100100
val process = Runtime.getRuntime().exec(arrayOf(
101-
"/system/bin/su", "-c", "/system/bin/setprop $SDP_OFFSET_PROP ''"
101+
"su", "-c", "/system/bin/setprop $SDP_OFFSET_PROP ''"
102102
))
103103
val exitCode = process.waitFor()
104104

@@ -288,14 +288,14 @@ class RadareOffsetFinder(context: Context) {
288288
}
289289

290290
Log.d(TAG, "Removing existing extract directory")
291-
Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
291+
Runtime.getRuntime().exec(arrayOf("su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
292292

293-
Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "mkdir -p $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
293+
Runtime.getRuntime().exec(arrayOf("su", "-c", "mkdir -p $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
294294

295295
Log.d(TAG, "Extracting ${radare2TarballFile.absolutePath} to $EXTRACT_DIR")
296296

297297
val process = Runtime.getRuntime().exec(
298-
arrayOf("/system/bin/su", "-c", "tar xvf ${radare2TarballFile.absolutePath} -C $EXTRACT_DIR")
298+
arrayOf("su", "-c", "tar xvf ${radare2TarballFile.absolutePath} -C $EXTRACT_DIR")
299299
)
300300

301301
val reader = BufferedReader(InputStreamReader(process.inputStream))
@@ -327,7 +327,7 @@ class RadareOffsetFinder(context: Context) {
327327
private suspend fun checkIfAlreadyExtracted(): Boolean = withContext(Dispatchers.IO) {
328328
try {
329329
val checkDirProcess = Runtime.getRuntime().exec(
330-
arrayOf("/system/bin/su", "-c", "[ -d $EXTRACT_DIR/data/local/tmp/aln_unzip ] && echo 'exists'")
330+
arrayOf("su", "-c", "[ -d $EXTRACT_DIR/data/local/tmp/aln_unzip ] && echo 'exists'")
331331
)
332332
val dirExists = BufferedReader(InputStreamReader(checkDirProcess.inputStream)).readLine() == "exists"
333333
checkDirProcess.waitFor()
@@ -338,7 +338,7 @@ class RadareOffsetFinder(context: Context) {
338338
}
339339

340340
val tarProcess = Runtime.getRuntime().exec(
341-
arrayOf("/system/bin/su", "-c", "tar tf ${radare2TarballFile.absolutePath}")
341+
arrayOf("su", "-c", "tar tf ${radare2TarballFile.absolutePath}")
342342
)
343343
val tarFiles = BufferedReader(InputStreamReader(tarProcess.inputStream)).readLines()
344344
.filter { it.isNotEmpty() }
@@ -352,7 +352,7 @@ class RadareOffsetFinder(context: Context) {
352352
}
353353

354354
val findProcess = Runtime.getRuntime().exec(
355-
arrayOf("/system/bin/su", "-c", "find $EXTRACT_DIR/data/local/tmp/aln_unzip -type f | sort")
355+
arrayOf("su", "-c", "find $EXTRACT_DIR/data/local/tmp/aln_unzip -type f | sort")
356356
)
357357
val extractedFiles = BufferedReader(InputStreamReader(findProcess.inputStream)).readLines()
358358
.filter { it.isNotEmpty() }
@@ -370,14 +370,14 @@ class RadareOffsetFinder(context: Context) {
370370

371371
val filePathInExtractDir = "$EXTRACT_DIR/$tarFile"
372372
val fileCheckProcess = Runtime.getRuntime().exec(
373-
arrayOf("/system/bin/su", "-c", "[ -f $filePathInExtractDir ] && echo 'exists'")
373+
arrayOf("su", "-c", "[ -f $filePathInExtractDir ] && echo 'exists'")
374374
)
375375
val fileExists = BufferedReader(InputStreamReader(fileCheckProcess.inputStream)).readLine() == "exists"
376376
fileCheckProcess.waitFor()
377377

378378
if (!fileExists) {
379379
Log.d(TAG, "File $filePathInExtractDir from tarball missing in extract directory")
380-
Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
380+
Runtime.getRuntime().exec(arrayOf("su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
381381
return@withContext false
382382
}
383383
}
@@ -394,13 +394,13 @@ class RadareOffsetFinder(context: Context) {
394394
try {
395395
Log.d(TAG, "Making binaries executable in $RADARE2_BIN_PATH")
396396
val chmod1Result = Runtime.getRuntime().exec(
397-
arrayOf("/system/bin/su", "-c", "chmod -R 755 $RADARE2_BIN_PATH")
397+
arrayOf("su", "-c", "chmod -R 755 $RADARE2_BIN_PATH")
398398
).waitFor()
399399

400400
Log.d(TAG, "Making binaries executable in $BUSYBOX_PATH")
401401

402402
val chmod2Result = Runtime.getRuntime().exec(
403-
arrayOf("/system/bin/su", "-c", "chmod -R 755 $BUSYBOX_PATH")
403+
arrayOf("su", "-c", "chmod -R 755 $BUSYBOX_PATH")
404404
).waitFor()
405405

406406
if (chmod1Result == 0 && chmod2Result == 0) {
@@ -421,8 +421,8 @@ class RadareOffsetFinder(context: Context) {
421421
var offset = 0L
422422

423423
try {
424-
@Suppress("LocalVariableName") val currentLD_LIBRARY_PATH = ProcessBuilder().command("/system/bin/su", "-c", "printenv LD_LIBRARY_PATH").start().inputStream.bufferedReader().readText().trim()
425-
val currentPATH = ProcessBuilder().command("/system/bin/su", "-c", "printenv PATH").start().inputStream.bufferedReader().readText().trim()
424+
@Suppress("LocalVariableName") val currentLD_LIBRARY_PATH = ProcessBuilder().command("su", "-c", "printenv LD_LIBRARY_PATH").start().inputStream.bufferedReader().readText().trim()
425+
val currentPATH = ProcessBuilder().command("su", "-c", "printenv PATH").start().inputStream.bufferedReader().readText().trim()
426426
val envSetup = """
427427
export LD_LIBRARY_PATH="$RADARE2_LIB_PATH:$currentLD_LIBRARY_PATH"
428428
export PATH="$BUSYBOX_PATH:$RADARE2_BIN_PATH:$currentPATH"
@@ -431,7 +431,7 @@ class RadareOffsetFinder(context: Context) {
431431
val command = "$envSetup && $RADARE2_BIN_PATH/rabin2 -q -E $libraryPath | grep fcr_chk_chan"
432432
Log.d(TAG, "Running command: $command")
433433

434-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", command))
434+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))
435435

436436
val reader = BufferedReader(InputStreamReader(process.inputStream))
437437
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
@@ -484,7 +484,7 @@ class RadareOffsetFinder(context: Context) {
484484
val command = "$envSetup && $RADARE2_BIN_PATH/rabin2 -q -E $libraryPath | grep l2cu_process_our_cfg_req"
485485
Log.d(TAG, "Running command: $command")
486486

487-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", command))
487+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))
488488
val reader = BufferedReader(InputStreamReader(process.inputStream))
489489
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
490490

@@ -515,7 +515,7 @@ class RadareOffsetFinder(context: Context) {
515515
if (offset > 0L) {
516516
val hexString = "0x${offset.toString(16)}"
517517
Runtime.getRuntime().exec(arrayOf(
518-
"/system/bin/su", "-c", "/system/bin/setprop $CFG_REQ_OFFSET_PROP $hexString"
518+
"su", "-c", "/system/bin/setprop $CFG_REQ_OFFSET_PROP $hexString"
519519
)).waitFor()
520520
Log.d(TAG, "Saved l2cu_process_our_cfg_req offset: $hexString")
521521
}
@@ -529,7 +529,7 @@ class RadareOffsetFinder(context: Context) {
529529
val command = "$envSetup && $RADARE2_BIN_PATH/rabin2 -q -E $libraryPath | grep l2c_csm_config"
530530
Log.d(TAG, "Running command: $command")
531531

532-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", command))
532+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))
533533
val reader = BufferedReader(InputStreamReader(process.inputStream))
534534
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
535535

@@ -560,7 +560,7 @@ class RadareOffsetFinder(context: Context) {
560560
if (offset > 0L) {
561561
val hexString = "0x${offset.toString(16)}"
562562
Runtime.getRuntime().exec(arrayOf(
563-
"/system/bin/su", "-c", "/system/bin/setprop $CSM_CONFIG_OFFSET_PROP $hexString"
563+
"su", "-c", "/system/bin/setprop $CSM_CONFIG_OFFSET_PROP $hexString"
564564
)).waitFor()
565565
Log.d(TAG, "Saved l2c_csm_config offset: $hexString")
566566
}
@@ -574,7 +574,7 @@ class RadareOffsetFinder(context: Context) {
574574
val command = "$envSetup && $RADARE2_BIN_PATH/rabin2 -q -E $libraryPath | grep l2cu_send_peer_info_req"
575575
Log.d(TAG, "Running command: $command")
576576

577-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", command))
577+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))
578578
val reader = BufferedReader(InputStreamReader(process.inputStream))
579579
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
580580

@@ -605,7 +605,7 @@ class RadareOffsetFinder(context: Context) {
605605
if (offset > 0L) {
606606
val hexString = "0x${offset.toString(16)}"
607607
Runtime.getRuntime().exec(arrayOf(
608-
"/system/bin/su", "-c", "/system/bin/setprop $PEER_INFO_REQ_OFFSET_PROP $hexString"
608+
"su", "-c", "/system/bin/setprop $PEER_INFO_REQ_OFFSET_PROP $hexString"
609609
)).waitFor()
610610
Log.d(TAG, "Saved l2cu_send_peer_info_req offset: $hexString")
611611
}
@@ -619,7 +619,7 @@ class RadareOffsetFinder(context: Context) {
619619
val command = "$envSetup && $RADARE2_BIN_PATH/rabin2 -q -E $libraryPath | grep DmSetLocalDiRecord"
620620
Log.d(TAG, "Running command: $command")
621621

622-
val process = Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", command))
622+
val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))
623623
val reader = BufferedReader(InputStreamReader(process.inputStream))
624624
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
625625

@@ -650,7 +650,7 @@ class RadareOffsetFinder(context: Context) {
650650
if (offset > 0L) {
651651
val hexString = "0x${offset.toString(16)}"
652652
Runtime.getRuntime().exec(arrayOf(
653-
"/system/bin/su", "-c", "/system/bin/setprop $SDP_OFFSET_PROP $hexString"
653+
"su", "-c", "/system/bin/setprop $SDP_OFFSET_PROP $hexString"
654654
)).waitFor()
655655
Log.d(TAG, "Saved DmSetLocalDiRecord offset: $hexString")
656656
}
@@ -665,7 +665,7 @@ class RadareOffsetFinder(context: Context) {
665665
Log.d(TAG, "Saving offset to system property: $hexString")
666666

667667
val process = Runtime.getRuntime().exec(arrayOf(
668-
"/system/bin/su", "-c", "/system/bin/setprop $HOOK_OFFSET_PROP $hexString"
668+
"su", "-c", "/system/bin/setprop $HOOK_OFFSET_PROP $hexString"
669669
))
670670

671671
val exitCode = process.waitFor()
@@ -694,7 +694,7 @@ class RadareOffsetFinder(context: Context) {
694694

695695
private fun cleanupExtractedFiles() {
696696
try {
697-
Runtime.getRuntime().exec(arrayOf("/system/bin/su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
697+
Runtime.getRuntime().exec(arrayOf("su", "-c", "rm -rf $EXTRACT_DIR/data/local/tmp/aln_unzip")).waitFor()
698698
Log.d(TAG, "Cleaned up extracted files at $EXTRACT_DIR/data/local/tmp/aln_unzip")
699699
} catch (e: Exception) {
700700
Log.e(TAG, "Failed to cleanup extracted files", e)
@@ -732,8 +732,8 @@ class RadareOffsetFinder(context: Context) {
732732
return@withContext false
733733
}
734734

735-
@Suppress("LocalVariableName") val currentLD_LIBRARY_PATH = ProcessBuilder().command("/system/bin/su", "-c", "printenv LD_LIBRARY_PATH").start().inputStream.bufferedReader().readText().trim()
736-
val currentPATH = ProcessBuilder().command("/system/bin/su", "-c", "printenv PATH").start().inputStream.bufferedReader().readText().trim()
735+
@Suppress("LocalVariableName") val currentLD_LIBRARY_PATH = ProcessBuilder().command("su", "-c", "printenv LD_LIBRARY_PATH").start().inputStream.bufferedReader().readText().trim()
736+
val currentPATH = ProcessBuilder().command("su", "-c", "printenv PATH").start().inputStream.bufferedReader().readText().trim()
737737
val envSetup = """
738738
export LD_LIBRARY_PATH="$RADARE2_LIB_PATH:$currentLD_LIBRARY_PATH"
739739
export PATH="$BUSYBOX_PATH:$RADARE2_BIN_PATH:$currentPATH"

0 commit comments

Comments
 (0)