如何获取Su执行命令的内容?

时间:2014-11-05 04:52:51

标签: android robotium uiautomator

当我执行命令时,例如am start -W -n com.xxx.xxx/.xxActivity 我可以看到内容。 Starting: Intent { cmp=com.xxx.xxx/.xxActivity } Status: ok Activity: com.xxx.xxx/.xxActivity ThisTime: 52 TotalTime: 71 Complete

但是当我用su执行命令时,例如su -c "am start -W -n com.xxx.xxx/.xxActivity" 没有什么可输出的,我如何用su?

获得输出

1 个答案:

答案 0 :(得分:0)

如果正常运行,标准Android su可按预期工作:

 $ su 0 am start -W -n com.android.settings/.Settings
Starting: Intent { cmp=com.android.settings/.Settings }
Warning: Activity not started, its current task has been brought to the front
Status: ok
Activity: com.android.settings/.Settings
ThisTime: 0
TotalTime: 0
Complete

以下是su.c代码的摘录:

/*
 * SU can be given a specific command to exec. UID _must_ be
 * specified for this (ie argc => 3).
 *
 * Usage:
 *   su 1000
 *   su 1000 ls -l
 *  or
 *   su [uid[,gid[,group1]...] [cmd]]
 *  E.g.
 *  su 1000,shell,net_bw_acct,net_bw_stats id
 * will return
 *  uid=1000(system) gid=2000(shell) groups=3006(net_bw_stats),3007(net_bw_acct)
 */