From 6bf1d716ec4a8656b6067ee7e42bf4fc77c9212d Mon Sep 17 00:00:00 2001 From: anonimou0 Date: Mon, 10 Oct 2016 22:24:01 -0300 Subject: [PATCH] Fix program to work on 64-bit architecture When calling the root command, on 64-bit architecture, it didn't find the correspondent /system/lib64/ folder, still looking for /system/lib. Now, it checks the architecture and set the folder accordingly. --- .../android/autostarts/ToggleTool.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/elsdoerfer/android/autostarts/ToggleTool.java b/src/com/elsdoerfer/android/autostarts/ToggleTool.java index 7b0b957..6a84d68 100644 --- a/src/com/elsdoerfer/android/autostarts/ToggleTool.java +++ b/src/com/elsdoerfer/android/autostarts/ToggleTool.java @@ -144,7 +144,21 @@ static protected Boolean toggleState(Context context, ComponentInfo component, b // On ICS, it became necessary to set a library path (which is // cleared for suid programs, for obvious reasons). It can't hurt // on older versions. See also https://github.com/ChainsDD/su-binary/issues/6 - final String libs = "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" "; + + String abi = null; //check if the architecture is 32 or 64bits + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + abi = Build.CPU_ABI; + } else { + abi = Build.SUPPORTED_ABIS[0]; + } + final String libs; + if (abi.equals("arm64-v8a") || abi.equals("x86_64") || abi.equals("mips64")) { + libs = "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib64\" "; + } + else { + libs = "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" "; + } + boolean success = false; for (String[] set : new String[][] { { libs+"pm %s '%s/%s'", null }, @@ -227,4 +241,4 @@ private static boolean setADBEnabledState(Context context, ContentResolver cr, b } } } -} \ No newline at end of file +}