6
W/PackageManager(61): Not granting permission android.permission.SET_ACTIVITY_WATCHER to package 

This is one such example of a permission that will not be granted to applications without being signed using the platform signature. With that said I would like to know how any application running on a rooted device (with /system/bin/su and SuperUser.apk) can be granted any of these permissions.

Process p = Runtime.getRuntime().exec("su");
p.waitFor();

Doing this prompts the super user dialog with "accept" or "reject," but SecurityExceptions are still thrown.

Tom
  • 6,947
  • 7
  • 46
  • 76

2 Answers2

2

You can declare your app to run as a system app by setting the sharedUserId as follows in the AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="[your package name]"
        android:sharedUserId="android.uid.system">

More details can be found here: How to sign Android app with system signature?

Community
  • 1
  • 1
spatulamania
  • 6,613
  • 2
  • 30
  • 26
  • 2
    Could I compile this application and run it on any rooted device and safely distribute it on the Android Market? I am not making a custom ROM, just an app for rooted devices. – Tom Oct 10 '11 at 02:40
  • No. You cannot distribute apps with system level access on the Android Market. – spatulamania Oct 10 '11 at 02:49
  • 1
    Then that is not what I am looking for. I am looking for a way to obtain such permissions on a rooted device not one running my own firmware. As far as distribution goes, look at SetCPU or the number of screenshot apps, they use such permissions without an issue. – Tom Oct 10 '11 at 12:57
  • 1
    It is insufficient. You still need to sign your apk with the platform key. – accuya Apr 13 '12 at 15:00
  • 1
    This will not work without actually signing the APK with the platform key, resulting in a failed install with an error from PackageManager: "E/PackageManager(164): Package org.snappet.launcher has no signatures that match those in shared user android.uid.system; ignoring!" – Paul Lammertsma Dec 19 '12 at 13:35
1

you need to copy your apk file to '/system/apps'. It can be done programatically. you can do this only if you have root permissions. once copied, reboot the device(reboot can also be done programatically if you have root) and you'll be granted all permissions mentioned in your manifest file. You can also distribute this on market.

PC.
  • 6,870
  • 5
  • 36
  • 71
  • 1
    Yeah I had this thought but there are some permissions still that are ONLY given to applications signed with the platform signature. Placing your app in/system/app gives you some of them, but not all. It also requires a reboot, which is kind of awkward, and means that you app cannot be uninstalled without an app like Root Explorer. – Tom Jul 03 '12 at 12:35
  • 1
    i've been using this technique since quite a while and never came across any permission that was not granted. What i do is provide a setting in my menu to "root/unroot the application". so when the user clicks on use-root-privileges, i display a popup saying the application will be copied to system folder and the device will be rebooted - Continue/Cancel. Similar for unroot also. Works great with me, no complaints yet. – PC. Jul 04 '12 at 03:32
  • I'm sure it could be done well, but the reboot and the inability to easily uninstall is just too much for me. For starters, would you also have to copy over all of your shared preferences files, cache, etc? That, and I'm still weary that permissions not in Manifest.permission like STATUS_BAR_SERVICE wouldn't be granted because they are designated as signature-level not system-level. – Tom Jul 04 '12 at 03:41