Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the result of stream read contains some special character? #17

Open
jxgxldl opened this issue Oct 12, 2021 · 1 comment
Open

the result of stream read contains some special character? #17

jxgxldl opened this issue Oct 12, 2021 · 1 comment

Comments

@jxgxldl
Copy link

jxgxldl commented Oct 12, 2021

there are example code in order to get os version of device as belows: use cmd: getprop ro.build.version.release
AdbStream stream = adb.open("shell:");
stream.write("getprop ro.build.version.release" +'\n');

when stream read
String bufStr = new String(stream.read(), StandardCharsets.UTF_8);
//...

the output of bufStr contains some special character: like ^@, / $...

does any wrong when I use adblib?

@mirfatif
Copy link

mirfatif commented Dec 29, 2021

It's a problem with Android's default shell. It mixes its prompt string with the output of executed command. ^@ is the null character and / $ is the shell prompt we see on an interactive shell.

So either run like adb.open("shell:exec sh -T-") with a hope that the newly forked shell will completely daemonise. Or if you intend to run only a single command, run it directly in the non-interactive way like adb.open("shell:exec getprop ro.build.version.release").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants