Closed thuantran closed 9 years ago
Can you provide The code you are using and logs from adb with RootTools.debug = true?
Here's the code I use roottools to run command
public static String shellExec(String workingDir, Integer timeout,
String... commands) {
if (Looper.myLooper() == Looper.getMainLooper()) {
Logcat.e("Warning execute commands on main thread\n"
+ Arrays.toString(commands));
}
try {
if (workingDir != null) {
String[] tmp = new String[commands.length + 1];
tmp[0] = "cd \"" + workingDir + "\"";
System.arraycopy(commands, 0, tmp, 1, commands.length);
commands = tmp;
}
final StringBuilder sb = new StringBuilder(4096);
CommandCapture cc = new CommandCapture(0, timeout == null ? 5000
: timeout, commands) {
@Override
public void commandOutput(int id, String line) {
sb.append("\n").append(line);
}
};
RootTools.getShell(true, ShellContext.UNTRUSTED_APP).add(cc);
synchronized (cc) {
try {
cc.wait();
} catch (InterruptedException e) {
}
}
return sb.length() > 0 ? sb.substring(1) : "";
} catch (Exception e) {
Logcat.e("Error execute command\n" + Arrays.toString(commands), e);
return "";
}
}
And here's the relavant adb log:
11-14 11:20:11.230: D/TricksterMOD(15823): Result 0
11-14 11:20:11.323: D/OpenGLRenderer(15823): Render dirty regions requested: true
11-14 11:20:11.328: D/Atlas(15823): Validating map...
11-14 11:20:11.335: D/TricksterMOD(15823): Start checking status
11-14 11:20:11.349: D/TricksterMOD(15823): Result 0
11-14 11:20:11.364: D/RootTools v3.5(15823): Checking for Root access
11-14 11:20:11.365: D/RootTools v3.5(15823): CommandHandler not created
11-14 11:20:11.365: D/RootTools v3.5(15823): Starting Root Shell!
11-14 11:20:11.366: D/RootTools v3.5(15823): Starting shell: su
11-14 11:20:11.366: D/RootTools v3.5(15823): Context: normal
11-14 11:20:11.366: D/RootTools v3.5(15823): Timeout: 0
11-14 11:20:11.394: I/Adreno-EGL(15823):
uid=0(root) gid=0(root) context=u:r:init:s0
Is there any news on this Stericson?
Hi Thuantran,
I'm planning to look at this today. I'm sorry, I've been swamped with work...
Hey guys,
I think I fixed the issue, looks like it was a problem with ProcessBuilder.
Can you guys try this version out?
https://drive.google.com/file/d/0B5Amguus3csDQW1zV04waEhXNkE/view?usp=sharing
Also, I noticed a bug that may have been slowing the shell down, so I addressed that as well which may or may not speed up the shell (depending on use)
Sorry but I can't use the jar, it throws out this error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...while parsing com/stericson/RootTools/BuildConfig.class
[2014-11-27 09:49:06 - Trickster MOD] Dx 1 error; aborting
I've updated the jar, can you use it now?
https://drive.google.com/file/d/0B5Amguus3csDQW1zV04waEhXNkE/view?usp=sharing
Still the same problem even in Android Studio as I moved my projects over. I also tried your new RootShell same issue with the jar. I will report this issue there and will double check this SELinux with plain library source until you have this fixed.
The context switching issue seems to be fixed in RootShell for me, thanks.
I don't know why but you've "blow out" your code in RootShell project so in the mean time I will report stuffs regarding the jar issue here until further notice.
Thanks!
yea, sorry about that. I was working on it...I'm horrible at commit messages.
I've pushed everything back in. So you should see all of the code.
Hi there,
I'm using the current latest stable version of roottools and I can't switch context using this code:
RootTools.getShell(true, ShellContext.UNTRUSTED_APP).add(cc);
Regardless what ShellContext constant I use, I still only get the normal init context as the output of id is like this: uid=0(root) gid=0(root) context=u:r:init:s0
I tested this on Nexus 5 with CFAR and latest SuperSU with LPX21O.