libgbinder icon indicating copy to clipboard operation
libgbinder copied to clipboard

How to run servicemanager in non android OS

Open ya1gaurav opened this issue 3 years ago • 2 comments

In case of android, servicemanager run as separate service during boot. In case of non android OS, how to run service manager using libgbinder?

ya1gaurav avatar Feb 01 '22 10:02 ya1gaurav

If no one is running a service manager for you, you would have to do it yourself. Unit tests contain a few very primitive implementations of various servicemanager binder APIs, like this one for example. Those would give you a very rough idea how it could be done with libgbinder. It's not that hard, really, especially the early simple servicemanager APIs like the one called "aidl" in libgbinder.

Writing a real servicemanager (e.g. the one accessible via zero handle) would require a few changes in libgbinder, at least to provide an equivalent of ProcessState::becomeContextManager and keep an internal reference to the local servicemanager object (no more than one per binder device). AFAICT becoming the context manager is a one-way thing, i.e. there's no way to stop being the context manager.

I can imagine a function like gbinder_local_object_become_context_manager() being added to libgbinder API if that's really going to be useful to somebody.

monich avatar Feb 01 '22 12:02 monich

If no one is running a service manager for you, you would have to do it yourself. Unit tests contain a few very primitive implementations of various servicemanager binder APIs, like this one for example. Those would give you a very rough idea how it could be done with libgbinder. It's not that hard, really, especially the early simple servicemanager APIs like the one called "aidl" in libgbinder.

Writing a real servicemanager (e.g. the one accessible via zero handle) would require a few changes in libgbinder, at least to provide an equivalent of ProcessState::becomeContextManager and keep an internal reference to the local servicemanager object (no more than one per binder device). AFAICT becoming the context manager is a one-way thing, i.e. there's no way to stop being the context manager.

I can imagine a function like gbinder_local_object_become_context_manager() being added to libgbinder API if that's really going to be useful to somebody.

This would be helpful. A service (systemd service daemon) could be created which will become context manager & the service could be launched on bootup.

ya1gaurav avatar Feb 02 '22 05:02 ya1gaurav