FORUMS
Remove All Ads from XDA

[DEV GUIDE][2016.12.22] How-To SU

11,217 posts
Thanks Meter: 85,983
 
By Chainfire, XDA Ad-Free Senior Moderator / Senior Recognized Developer - Where is my shirt? on 29th October 2012, 08:38 PM
Post Reply Email Thread
18th May 2013, 07:38 PM |#21  
Member
Thanks Meter: 55
 
More
Quote:
Originally Posted by Chainfire

Yes, it's all about best practises when calling the su binary - it should work with all superuser apps.

At Supporting multiple icons in your app you mention you plan to write a blog post about changing application theme and locale at runtime. Do you still plan to publish it ? I am very interested in those techniques.
 
 
21st May 2013, 05:43 PM |#22  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 85,983
 
Donate to Me
More
Quote:
Originally Posted by mcnamaragio

At Supporting multiple icons in your app you mention you plan to write a blog post about changing application theme and locale at runtime. Do you still plan to publish it ? I am very interested in those techniques.

If I ever have the time for it
9th June 2013, 12:02 PM |#23  
Junior Member
Thanks Meter: 0
 
More
Thumbs up
Hello,

I have a problem. I am trying to manage streams of a single background process instance returned by Runtime.getRuntime().exec("su") throughout my app. After writing a command, say "mount -o rw,remount /system" to the output stream, a confusing blocking error of the input stream arises when I want to read that stream, even in a worker thread, and in which condition there turns out to be some unexpected results.

Is there any advice or example for me to avoid it?
3rd October 2013, 04:35 PM |#24  
windflyer's Avatar
Junior Member
Flag Wuhan
Thanks Meter: 0
 
More
I am curious why you said "ProcessBuilder does not work consistently across all Android versions", any evidence or reference?

Thanks.
3rd October 2013, 05:08 PM |#25  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 85,983
 
Donate to Me
More
Quote:
Originally Posted by windflyer

I am curious why you said "ProcessBuilder does not work consistently across all Android versions", any evidence or reference?

This is from memory, but what I recall is passing a line of commands both quoted as well as unquoted as a single argument to PB ("su", "-c", "...commands...") didn't consistently arrive as a single parameter to the su binary, depending on (now ancient) Android versions. This is from very long ago though, I'm not even sure I'm remembering it right.
4th October 2013, 06:12 AM |#26  
windflyer's Avatar
Junior Member
Flag Wuhan
Thanks Meter: 0
 
More
Quote:
Originally Posted by Chainfire

This is from memory, but what I recall is passing a line of commands both quoted as well as unquoted as a single argument to PB ("su", "-c", "...commands...") didn't consistently arrive as a single parameter to the su binary, depending on (now ancient) Android versions. This is from very long ago though, I'm not even sure I'm remembering it right.

Thanks for you reply. Actually, I have not met any open-source android apps that use ProcessBuilder yet.
22nd October 2013, 08:43 AM |#27  
OnCommandResultListener bevor all OnSTDOUTLineListener liOnCommandResultLnes are send
Hi
I will use ping with libsuperuser. I use this code.
Code:
shShell = new Shell.Builder().useSH()
	 .setWantSTDERR(true)
	 .setOnSTDERRLineListener(new StreamGobbler.OnLineListener() {
		 @Override
		 public void onLine(String line) {
			 //Error
		 }
	 })
	 .setOnSTDOUTLineListener(new StreamGobbler.OnLineListener() {
		 @Override
		 public void onLine(String line) {
			 //Line
		 }
	 })
	 .open(new Shell.OnCommandResultListener() {
		 @Override
		 public void onCommandResult(int commandCode, int exitCode, List<String> output) {
			 //Finish
		 }
	 });

shShell.addCommand("/system/bin/ping -c 3 google.com");
But, OnCommandResultListener call bevor all lines are sended. In the output list ar this:
-BOC-
uid=10154(u0_a154) gid=10154(u0_a154) groups=1028(sdcard_r),3003(inet)

Not the output from ping. How can I determine whether the ping is done?
22nd October 2013, 10:07 AM |#28  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 85,983
 
Donate to Me
More
Quote:
Originally Posted by GENiALi

Not the output from ping. How can I determine whether the ping is done?

Attach the OnCommandResultListener to the addCommand call instead
22nd October 2013, 10:17 AM |#29  
Quote:
Originally Posted by Chainfire

Attach the OnCommandResultListener to the addCommand call instead

I have.
I will a output line for line AND an info when ping is finished.
OnCommandResultListener must call AFTER send the last line in setOnSTDOUTLineListener.
How do this.

setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Last line
OnCommandResultListener -> all lines

Not this.
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Line
OnCommandResultListener -> all lines
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Line
setOnSTDOUTLineListener-> Last line
22nd October 2013, 11:33 AM |#30  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 85,983
 
Donate to Me
More
No guarantees are made regarding the order the callbacks are being called. These are not normally called together and may be handled by different threads directly, or posted to handlers.
22nd October 2013, 12:22 PM |#31  
Quote:
Originally Posted by Chainfire

No guarantees are made regarding the order the callbacks are being called. These are not normally called together and may be handled by different threads directly, or posted to handlers.

ok, i search another solution.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes