Adding system services

273 views
Skip to first unread message

David Herges

unread,
Sep 23, 2011, 12:09:13 PM9/23/11
to android-...@googlegroups.com
Hi,

I tried to add a custom system service by declaring .aidl files, writing a client implementation in ContextImpl, etc. pp. I followed the example of PackageManagerService and added everything to the platform. In SystemServer.java, line 175, run() added:

ServiceManager.addService(Context.PERMISSION_SERVICE, new PermissionManagerService(context));


However, it keeps crashing when I start the emulator:

09-23 15:51:09.501: INFO/SystemServer(77): Permission Manager
09-23 15:51:09.560: ERROR/ServiceManager(27): add_service('permission',0x11) uid=1000 - ALREADY REGISTERED
09-23 15:51:09.660: ERROR/System(77): Failure starting core service
09-23 15:51:09.660: ERROR/System(77): java.lang.SecurityException
09-23 15:51:09.660: ERROR/System(77):     at android.os.BinderProxy.transact(Native Method)
09-23 15:51:09.660: ERROR/System(77):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
09-23 15:51:09.660: ERROR/System(77):     at android.os.ServiceManager.addService(ServiceManager.java:72)
09-23 15:51:09.660: ERROR/System(77):     at com.android.server.ServerThread.run(SystemServer.java:175)

I cannot find the implementation of the SystemServer. And I can't see that there is any other service registered with the name "permission"?! Any suggestions?

I need the service to run in such a way that I can redirect some permission checks from PackageManagerService to my customised service. But also applications should be able to query my custom service directly (so I cannot rely on the existing PackageManager). Basically, I could add everything to the interface of PackageManagerService but that's going to result in a large large java class (and I want to keep my source code separated from the existing one if possible).

Bye, David

David Herges

unread,
Sep 26, 2011, 1:10:40 PM9/26/11
to android-...@googlegroups.com
I changed the value of Context.PERMISSIOM_SERVICE to another than 'permission' and now everything work's fine. Don't really know why, but I take it anyways... ;)

ekwang

unread,
Sep 28, 2011, 12:59:27 PM9/28/11
to android-...@googlegroups.com
Hi.

Did you check running service like below?

#service list

If you see "permission" on that list, it is already registered by other.

Lee.

David Herges

unread,
Sep 29, 2011, 6:01:06 AM9/29/11
to android-...@googlegroups.com
Yep, thanks! It lists this one:

30 permission: [android.os.IPermissionController]


No problem at all. I just register my service with another key.
Reply all
Reply to author
Forward
0 new messages