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

Commit 8d0c4ed7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Update for hidlized hwservicemanager."

parents f5ad44b6 a813686b
Loading
Loading
Loading
Loading
+29 −17
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@
#include "android_os_HwRemoteBinder.h"

#include <JNIHelp.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android_runtime/AndroidRuntime.h>
#include <hidl/IServiceManager.h>
#include <hidl/ServiceManagement.h>
#include <hidl/Status.h>
#include <hwbinder/ProcessState.h>
#include <nativehelper/ScopedLocalRef.h>
@@ -220,27 +221,31 @@ static void JHwBinder_native_registerService(
        return;  // XXX exception already pending?
    }

    const hardware::hidl_version kVersion =
        hardware::make_hidl_version(versionMajor, versionMinor);
    using android::hidl::manager::V1_0::IServiceManager;

    const IServiceManager::Version kVersion {
        .major = static_cast<uint16_t>(versionMajor),
        .minor = static_cast<uint16_t>(versionMinor),
    };

    sp<hardware::IBinder> binder = JHwBinder::GetNativeContext(env, thiz);

    status_t err = hardware::defaultServiceManager()->addService(
                String16(
    bool ok = hardware::defaultServiceManager()->add(
                String8(String16(
                          reinterpret_cast<const char16_t *>(serviceName),
                    env->GetStringLength(serviceNameObj)),
                          env->GetStringLength(serviceNameObj))).string(),
                binder,
                kVersion);

    env->ReleaseStringCritical(serviceNameObj, serviceName);
    serviceName = NULL;

    if (err == OK) {
    if (ok) {
        LOG(INFO) << "Starting thread pool.";
        ::android::hardware::ProcessState::self()->startThreadPool();
    }

    signalExceptionForError(env, err);
    signalExceptionForError(env, (ok ? OK : UNKNOWN_ERROR));
}

static jobject JHwBinder_native_getService(
@@ -268,8 +273,12 @@ static jobject JHwBinder_native_getService(
        return NULL;  // XXX exception already pending?
    }

    const hardware::hidl_version kVersion =
        hardware::make_hidl_version(versionMajor, versionMinor);
    using android::hidl::manager::V1_0::IServiceManager;

    const IServiceManager::Version kVersion {
        .major = static_cast<uint16_t>(versionMajor),
        .minor = static_cast<uint16_t>(versionMinor),
    };

    LOG(INFO) << "looking for service '"
              << String8(String16(
@@ -277,12 +286,15 @@ static jobject JHwBinder_native_getService(
                          env->GetStringLength(serviceNameObj))).string()
              << "'";

    sp<hardware::IBinder> service =
        hardware::defaultServiceManager()->getService(
                String16(
    sp<hardware::IBinder> service;
    hardware::defaultServiceManager()->get(
            String8(String16(
                      reinterpret_cast<const char16_t *>(serviceName),
                    env->GetStringLength(serviceNameObj)),
                kVersion);
                      env->GetStringLength(serviceNameObj))).string(),
            kVersion,
            [&service](sp<hardware::IBinder> out) {
                service = out;
            });

    env->ReleaseStringCritical(serviceNameObj, serviceName);
    serviceName = NULL;
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include <hidl/IServiceManager.h>
#include <hidl/Status.h>
#include <nativehelper/ScopedLocalRef.h>