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

Commit a08b3bff authored by Florian Mayer's avatar Florian Mayer Committed by Gerrit Code Review
Browse files

Merge "Never send Binder / HIDL txn from atrace."

parents 4d89476b e2811af2
Loading
Loading
Loading
Loading
+0 −81
Original line number Original line Diff line number Diff line
@@ -571,81 +571,6 @@ static bool setPrintTgidEnableIfPresent(bool enable)
    return true;
    return true;
}
}


// Poke all the binder-enabled processes in the system to get them to re-read
// their system properties.
static bool pokeBinderServices()
{
    sp<IServiceManager> sm = defaultServiceManager();
    Vector<String16> services = sm->listServices();
    for (size_t i = 0; i < services.size(); i++) {
        sp<IBinder> obj = sm->checkService(services[i]);
        if (obj != nullptr) {
            Parcel data;
            if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data,
                    nullptr, 0) != OK) {
                if (false) {
                    // XXX: For some reason this fails on tablets trying to
                    // poke the "phone" service.  It's not clear whether some
                    // are expected to fail.
                    String8 svc(services[i]);
                    fprintf(stderr, "error poking binder service %s\n",
                        svc.string());
                    return false;
                }
            }
        }
    }
    return true;
}

// Poke all the HAL processes in the system to get them to re-read
// their system properties.
static void pokeHalServices()
{
    using ::android::hidl::base::V1_0::IBase;
    using ::android::hidl::manager::V1_0::IServiceManager;
    using ::android::hardware::hidl_string;
    using ::android::hardware::Return;

    sp<IServiceManager> sm = ::android::hardware::defaultServiceManager();

    if (sm == nullptr) {
        fprintf(stderr, "failed to get IServiceManager to poke hal services\n");
        return;
    }

    auto listRet = sm->list([&](const auto &interfaces) {
        for (size_t i = 0; i < interfaces.size(); i++) {
            string fqInstanceName = interfaces[i];
            string::size_type n = fqInstanceName.find('/');
            if (n == std::string::npos || interfaces[i].size() == n+1)
                continue;
            hidl_string fqInterfaceName = fqInstanceName.substr(0, n);
            hidl_string instanceName = fqInstanceName.substr(n+1, std::string::npos);
            Return<sp<IBase>> interfaceRet = sm->get(fqInterfaceName, instanceName);
            if (!interfaceRet.isOk()) {
                // ignore
                continue;
            }

            sp<IBase> interface = interfaceRet;
            if (interface == nullptr) {
                // ignore
                continue;
            }

            auto notifyRet = interface->notifySyspropsChanged();
            if (!notifyRet.isOk()) {
                // ignore
            }
        }
    });
    if (!listRet.isOk()) {
        // TODO(b/34242478) fix this when we determine the correct ACL
        //fprintf(stderr, "failed to list services: %s\n", listRet.description().c_str());
    }
}

// Set the trace tags that userland tracing uses, and poke the running
// Set the trace tags that userland tracing uses, and poke the running
// processes to pick up the new value.
// processes to pick up the new value.
static bool setTagsProperty(uint64_t tags)
static bool setTagsProperty(uint64_t tags)
@@ -876,10 +801,6 @@ static bool setUpUserspaceTracing()
    }
    }
    ok &= setAppCmdlineProperty(&packageList[0]);
    ok &= setAppCmdlineProperty(&packageList[0]);
    ok &= setTagsProperty(tags);
    ok &= setTagsProperty(tags);
#if !ATRACE_SHMEM
    ok &= pokeBinderServices();
    pokeHalServices();
#endif
    if (g_tracePdx) {
    if (g_tracePdx) {
        ok &= ServiceUtility::PokeServices();
        ok &= ServiceUtility::PokeServices();
    }
    }
@@ -891,8 +812,6 @@ static void cleanUpUserspaceTracing()
{
{
    setTagsProperty(0);
    setTagsProperty(0);
    clearAppProperties();
    clearAppProperties();
    pokeBinderServices();
    pokeHalServices();


    if (g_tracePdx) {
    if (g_tracePdx) {
        ServiceUtility::PokeServices();
        ServiceUtility::PokeServices();