pub unsafe extern "C" fn AServiceManager_registerForServiceNotifications(
    instance: *const c_char,
    onRegister: AServiceManager_onRegister,
    cookie: *mut c_void,
) -> *mut AServiceManager_NotificationRegistration
Expand description

Get notifications when a service is registered. If the service is already registered, you will immediately get a notification.

WARNING: it is strongly recommended to use AServiceManager_waitForService API instead. That API will wait synchronously, which is what you usually want in cases, including using some feature or during boot up. There is a history of bugs where waiting for notifications like this races with service startup. Also, when this API is used, a service bug will result in silent failure (rather than a debuggable deadlock). Furthermore, there is a history of this API being used to know when a service is up as a proxy for whethre that service should be started. This should only be used if you are intending to get ahold of the service as a client. For lazy services, whether a service is registered should not be used as a proxy for when it should be registered, which is only known by the real client.

WARNING: if you use this API, you must also ensure that you check missing services are started and crash otherwise. If service failures are ignored, the system rots.

\param instance name of service to wait for notifications about \param onRegister callback for when service is registered \param cookie data associated with this callback

\return the token for this registration. Deleting this token will unregister.