Merge "Update for hidlized hwservicemanager."
This commit is contained in:
@@ -24,8 +24,9 @@
|
|||||||
#include "android_os_HwRemoteBinder.h"
|
#include "android_os_HwRemoteBinder.h"
|
||||||
|
|
||||||
#include <JNIHelp.h>
|
#include <JNIHelp.h>
|
||||||
|
#include <android/hidl/manager/1.0/IServiceManager.h>
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
#include <android_runtime/AndroidRuntime.h>
|
||||||
#include <hidl/IServiceManager.h>
|
#include <hidl/ServiceManagement.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
#include <hwbinder/ProcessState.h>
|
#include <hwbinder/ProcessState.h>
|
||||||
#include <nativehelper/ScopedLocalRef.h>
|
#include <nativehelper/ScopedLocalRef.h>
|
||||||
@@ -220,27 +221,31 @@ static void JHwBinder_native_registerService(
|
|||||||
return; // XXX exception already pending?
|
return; // XXX exception already pending?
|
||||||
}
|
}
|
||||||
|
|
||||||
const hardware::hidl_version kVersion =
|
using android::hidl::manager::V1_0::IServiceManager;
|
||||||
hardware::make_hidl_version(versionMajor, versionMinor);
|
|
||||||
|
const IServiceManager::Version kVersion {
|
||||||
|
.major = static_cast<uint16_t>(versionMajor),
|
||||||
|
.minor = static_cast<uint16_t>(versionMinor),
|
||||||
|
};
|
||||||
|
|
||||||
sp<hardware::IBinder> binder = JHwBinder::GetNativeContext(env, thiz);
|
sp<hardware::IBinder> binder = JHwBinder::GetNativeContext(env, thiz);
|
||||||
|
|
||||||
status_t err = hardware::defaultServiceManager()->addService(
|
bool ok = hardware::defaultServiceManager()->add(
|
||||||
String16(
|
String8(String16(
|
||||||
reinterpret_cast<const char16_t *>(serviceName),
|
reinterpret_cast<const char16_t *>(serviceName),
|
||||||
env->GetStringLength(serviceNameObj)),
|
env->GetStringLength(serviceNameObj))).string(),
|
||||||
binder,
|
binder,
|
||||||
kVersion);
|
kVersion);
|
||||||
|
|
||||||
env->ReleaseStringCritical(serviceNameObj, serviceName);
|
env->ReleaseStringCritical(serviceNameObj, serviceName);
|
||||||
serviceName = NULL;
|
serviceName = NULL;
|
||||||
|
|
||||||
if (err == OK) {
|
if (ok) {
|
||||||
LOG(INFO) << "Starting thread pool.";
|
LOG(INFO) << "Starting thread pool.";
|
||||||
::android::hardware::ProcessState::self()->startThreadPool();
|
::android::hardware::ProcessState::self()->startThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
signalExceptionForError(env, err);
|
signalExceptionForError(env, (ok ? OK : UNKNOWN_ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject JHwBinder_native_getService(
|
static jobject JHwBinder_native_getService(
|
||||||
@@ -268,8 +273,12 @@ static jobject JHwBinder_native_getService(
|
|||||||
return NULL; // XXX exception already pending?
|
return NULL; // XXX exception already pending?
|
||||||
}
|
}
|
||||||
|
|
||||||
const hardware::hidl_version kVersion =
|
using android::hidl::manager::V1_0::IServiceManager;
|
||||||
hardware::make_hidl_version(versionMajor, versionMinor);
|
|
||||||
|
const IServiceManager::Version kVersion {
|
||||||
|
.major = static_cast<uint16_t>(versionMajor),
|
||||||
|
.minor = static_cast<uint16_t>(versionMinor),
|
||||||
|
};
|
||||||
|
|
||||||
LOG(INFO) << "looking for service '"
|
LOG(INFO) << "looking for service '"
|
||||||
<< String8(String16(
|
<< String8(String16(
|
||||||
@@ -277,12 +286,15 @@ static jobject JHwBinder_native_getService(
|
|||||||
env->GetStringLength(serviceNameObj))).string()
|
env->GetStringLength(serviceNameObj))).string()
|
||||||
<< "'";
|
<< "'";
|
||||||
|
|
||||||
sp<hardware::IBinder> service =
|
sp<hardware::IBinder> service;
|
||||||
hardware::defaultServiceManager()->getService(
|
hardware::defaultServiceManager()->get(
|
||||||
String16(
|
String8(String16(
|
||||||
reinterpret_cast<const char16_t *>(serviceName),
|
reinterpret_cast<const char16_t *>(serviceName),
|
||||||
env->GetStringLength(serviceNameObj)),
|
env->GetStringLength(serviceNameObj))).string(),
|
||||||
kVersion);
|
kVersion,
|
||||||
|
[&service](sp<hardware::IBinder> out) {
|
||||||
|
service = out;
|
||||||
|
});
|
||||||
|
|
||||||
env->ReleaseStringCritical(serviceNameObj, serviceName);
|
env->ReleaseStringCritical(serviceNameObj, serviceName);
|
||||||
serviceName = NULL;
|
serviceName = NULL;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <JNIHelp.h>
|
#include <JNIHelp.h>
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
#include <android_runtime/AndroidRuntime.h>
|
||||||
#include <hidl/IServiceManager.h>
|
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
#include <nativehelper/ScopedLocalRef.h>
|
#include <nativehelper/ScopedLocalRef.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user