How to run Android system app without root permission?

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

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

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

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?

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.

EDIT:
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.

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...

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


Is there any way to run android system app without root permission?

It have to be NO, but some times, some functions which are not for public use still can be used. I've seen examples using java reflection.

I can execute system app via adb such as: ...

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?

I think, no.

The thing is adb shell and user app have different security levels based on User and Group IDs (UID and GID).

More info: http://android-dls.com/wiki/index.php?title=Android_UIDs_and_GIDs

Besides, there are limitations via app permissions and hiden & internal classes, procedures, etc which made for internal use.

P.S.: About screenshots. On android market (google play) there are few apps which provide screenshots without ROOT access. So, it's possible. Although, since Android 4.0 screenshots are available "from box".

Tags:

Shell

Android

Adb