未经root许可如何运行Android系统应用程序? [英] How to run Android system app without root permission?

查看:110
本文介绍了未经root许可如何运行Android系统应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在没有root许可的情况下运行Android系统应用?我可以通过adb执行系统应用程序,例如:

Is there any way to run Android system app without root permission? I can execute system app via adb such as:


adb shell / system / bin / screencap -p /sdcard/screen.png

adb shell /system/bin/screencap -p /sdcard/screen.png

在我自己的应用程序中,我想运行一个不带 su命令的shell命令。有什么办法吗? android如何阻止用户应用执行系统应用?

In my own application, I wanna run a shell command like that without "su" command. Is there any way? How does android prevent user apps to execute system app?

推荐答案

您应该能够在Java代码中运行以下命令:

You should be able to run this command in java code:

Runtime.getRuntime().exec("screencap -p /sdcard/screen.png");

您可以执行一些没有root权限的shell命令。因此,您无需运行 su。我不确定您是否可以执行截屏。当然,您需要在您的应用程序中写入SD_CARD的权限。

There are some shell commands you can execute without having root. So you don't need to run "su". I'm not sure if you can execute screencap. Certainly you need permission to write to the SD_CARD in your app.

android.permission.WRITE_EXTERNAL_STORAGE

但是为什么不使用Android API来制作屏幕截图呢?有关更多信息,请阅读有关stackoverflow的帖子:如何以编程方式在Android中拍摄屏幕截图?

But why you don't use the Android API to make your screenshot? For more information read this post on stackoverflow: How to programmatically take a screenshot in Android?

Android的安全性模型基于用户ID,就像Linux一样。每个应用都有自己的用户ID。因此,您的应用程序的用户ID类似于1001。如果允许您的用户运行命令,则可以,否则将收到错误。

Androids security model bases on user ids, like Linux does. Each app gets his own user id. So your app has a userid like 1001. If your user is allowed to run the command you can, otherwise you will receive an error.

编辑:

您需要root才能截取屏幕截图或成为系统应用程序。拥有READ_FRAME_BUFFER权限,但只有在您是系统应用程序时才能获得它。当应用可以为您的设备截图时,这是一个安全问题。


You need root to take screenshots or be a system application. There is a permission READ_FRAME_BUFFER but you only can obtain it when you are a system application. Its a security problem when an app could take screenshots of your device.

我已经找到了此API http://code.google.com/p/android-screenshot-library/ 承诺无需root即可截取屏幕截图。我没有测试。该库将启动本机服务,然后为您获取屏幕截图。
但是,每次手机启动时都必须运行该服务。这样就获得了系统特权。这不是很舒服...

I've found this API http://code.google.com/p/android-screenshot-library/ which promises to take screenshots without root. I didn't test it. The library starts a native service which then takes the screenshots for you. But you have to run the service each time your phone boots. So it gets the system privileges. That's not really comfortable...

结论:没有一种很好的方法可以在没有root用户的情况下截取屏幕截图...

Conclusion: There is no nice way to take screenshots without root from code...

这篇关于未经root许可如何运行Android系统应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆