Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b6768b5 authored by Charlie Wang's avatar Charlie Wang
Browse files

Add addService to pass in allowIsolated flag.

This provides a way for services to add themselves with the
allowIsolated flag set.

Bug: 266943251.
Test: Service can be added with allowIsolated set to true.
Change-Id: I22d518ec8fabd942a7a22ab5baa0b76384ab066c
parent 226a6526
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -37,6 +37,22 @@ __BEGIN_DECLS
__attribute__((warn_unused_result)) binder_exception_t AServiceManager_addService(
        AIBinder* binder, const char* instance) __INTRODUCED_IN(29);

/**
 * This registers the service with the default service manager under this instance name. This does
 * not take ownership of binder.
 *
 * WARNING: when using this API across an APEX boundary, do not use with unstable
 * AIDL services. TODO(b/139325195)
 *
 * \param binder object to register globally with the service manager.
 * \param instance identifier of the service. This will be used to lookup the service.
 * \param allowIsolated allows if this service can be isolated.
 *
 * \return EX_NONE on success.
 */
__attribute__((warn_unused_result)) binder_exception_t AServiceManager_addServiceWithAllowIsolated(
        AIBinder* binder, const char* instance, bool allowIsolated) __INTRODUCED_IN(34);

/**
 * Gets a binder object with this specific instance name. Will return nullptr immediately if the
 * service is not available This also implicitly calls AIBinder_incStrong (so the caller of this
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ LIBBINDER_NDK34 { # introduced=UpsideDownCake
LIBBINDER_NDK_PLATFORM {
  global:
    AParcel_getAllowFds;
    AServiceManager_addServiceWithAllowIsolated;
    extern "C++" {
        AIBinder_fromPlatformBinder*;
        AIBinder_toPlatformBinder*;
+13 −0
Original line number Diff line number Diff line
@@ -41,6 +41,19 @@ binder_exception_t AServiceManager_addService(AIBinder* binder, const char* inst
    status_t exception = sm->addService(String16(instance), binder->getBinder());
    return PruneException(exception);
}

binder_exception_t AServiceManager_addServiceWithAllowIsolated(AIBinder* binder,
                                                               const char* instance,
                                                               bool allowIsolated) {
    if (binder == nullptr || instance == nullptr) {
        return EX_ILLEGAL_ARGUMENT;
    }

    sp<IServiceManager> sm = defaultServiceManager();
    status_t exception = sm->addService(String16(instance), binder->getBinder(), allowIsolated);
    return PruneException(exception);
}

AIBinder* AServiceManager_checkService(const char* instance) {
    if (instance == nullptr) {
        return nullptr;