8

我想知道我们如何从android应用程序获得root权限?安卓市场有应用吗?

我尝试了下面的代码行来列出文件,但什么也没发生

Process process = Runtime.getRuntime().exec(new String[] { "su", "-", "root"});

我试图在我的清单文件中授予 TEST_FACTORY 权限,但出现错误“允许系统应用程序”

如何制作我的应用系统应用程序?

我想要帮助开始使用这些东西(如果可能的话,制作应用程序以获得 root 权限)非常感谢任何帮助。提前致谢 :)

4

2 回答 2

5

这里有一个很好的答案 - ANDROID: How to get root access in an Android application?

“据我所知,您只能使用 root 权限运行命令行命令。您可以使用我制作的这个通用类,它在您的代码中包装了 root 访问权限:http: //muzikant-android.blogspot.com/2011/ 02/how-to-get-root-access-and-execute.html "

于 2014-02-06T07:28:03.053 回答
4

首先:请注意,您只能使用 su 执行 shell 命令(= 您只能以 root 身份使用 shell 命令,而不是 java 代码)。

第二:不确定这是否适用于所有 su 应用程序,但这是su我手机上的帮助信息:

Usage: su [options] [--] [-] [LOGIN] [--] [args...]

Options:  
  --daemon                      start the su daemon agent  
  -c, --command COMMAND         pass COMMAND to the invoked shell  
  -h, --help                    display this help message and exit  
  -, -l, --login                pretend the shell to be a login shell  
  -m, -p,  
  --preserve-environment        do not change environment variables  
  -s, --shell SHELL             use SHELL instead of the default /system/bin/sh  
  -u                            display the multiuser mode and exit  
  -v, --version                 display version number and exit  
  -V                            display version code and exit,  
                                this is used almost exclusively by Superuser.apk  

这意味着:您必须运行su -c something (或su -c something - root, 但root无论如何都是默认设置)。基本上这在大多数 Linux 系统上等于 su,除了守护进程,因为在常规 Linux 系统上没有守护进程和 su 调用。

如果其他 su 命令的行为不同(这是可能的),打开一个流到 shell,执行su,评估它的返回代码,然后继续执行其他命令,最后执行会更安全exit

于 2014-02-06T07:27:13.603 回答