librootjava icon indicating copy to clipboard operation
librootjava copied to clipboard

Bind system service as root?

Open Mygod opened this issue 4 years ago • 3 comments

When I attempt to bind it I encountered the exception:

            throw new SecurityException(
                    "Unable to find app for caller " + caller
                    + " (pid=" + Binder.getCallingPid()
                    + ") when binding service " + service);

Mygod avatar Jun 16 '20 22:06 Mygod

Many service check if your app is registered by PID. As you're not actually running an app, that doesn't work. Some services can be reached via reflection (see Reflection.java in librootjava sources). For some services you can get to the base AIDL, get the Binder object from ServiceManager (again reflection).

It can be very tricky to get things to work this way, but I usually manage to get what I need. It usually requires diving into Android source code to figure out exactly what you need, though, and some things just aren't possible. Even if you the service object, specific interface calls may still trigger the error you quoted.

Chainfire avatar Jun 17 '20 15:06 Chainfire

Thank you! I saw that you used ActivityManagerNative to send broadcast. I will look into that later.

Mygod avatar Jun 17 '20 17:06 Mygod

~It looks like this class is deprecated now and soon to be removed according to doc. The method broadcastIntent is already removed in master. :(~ Never mind sorry!

Still hits the same exception. :/

Mygod avatar Jun 17 '20 17:06 Mygod