我想使用命令行来启动一个 android intent(比如在 Gallery 应用程序中播放视频)。我可以以 root 身份启动 Intent 吗?
我试过了
su -c "am start -a android.intent.action.VIEW -n com.android.gallery3d/.app.MovieActivity -d <some_file>"
它抛出错误
su: exec failed for am start -a android.intent.action.VIEW -n com.android.gallery3d/.app.MovieActivity -d <some_file> Error:No such file or directory
编辑:
这工作正常(在没有 root 权限的情况下播放图库中的视频)。不过,我想以 root 权限运行图库。
am start -a android.intent.action.VIEW -n com.android.gallery3d/.app.MovieActivity -d <some_file>
最佳答案
简单的回答是否定的,您不能以 root 身份启动任何 Android 应用程序或 Intent ,即使您以 root 身份从终端启动它们。这是由于 Android 系统的设计方式所致:即使您使用 su
启动应用程序,实际启动该应用程序的进程也会将该应用程序 fork 到非特权线程中。对于大多数用途,su
二进制文件旨在从已经以非根访问权限启动的应用程序中以编程方式启动;否则,su
二进制文件用于运行 native Linux 程序/命令,而不是 Android 应用。
让 Android 应用程序本身拥有“root”访问权限的唯一方法是安装一个内核,自动授予对每个进程的 root 访问权限(我看到一些便宜的无名品牌设备开箱即用) .这通常是一个非常糟糕的主意,因为意外损坏设备变得非常容易。
真正的问题是您一开始为什么要这样做。如果您确实需要让画廊访问特权文件夹,请考虑安装 busybox并将 protected 目录作为公共(public)目录安装在某处。这将要求您拥有已获得 root 权限的设备。
关于android - 我可以以 root 身份启动 android intent 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18479288/