HIDL Java getService now the same as C++.

getService: wait for service if it is declared in the manifest
tryGetService: only return if the service is immediately available

Bug: 67981006
Test: hidl_test_java
Change-Id: I4485b84f0fde98851cf5f64d198a8c5410795c8c
This commit is contained in:
Steven Moreland
2017-10-23 00:09:33 -07:00
parent d5d697b023
commit c1f00f8cd8
2 changed files with 6 additions and 5 deletions

View File

@@ -48,7 +48,8 @@ public abstract class HwBinder implements IHwBinder {
public static native final IHwBinder getService(
String iface,
String serviceName)
String serviceName,
boolean isTry)
throws RemoteException, NoSuchElementException;
public static native final void configureRpcThreadpool(

View File

@@ -303,7 +303,8 @@ static jobject JHwBinder_native_getService(
JNIEnv *env,
jclass /* clazzObj */,
jstring ifaceNameObj,
jstring serviceNameObj) {
jstring serviceNameObj,
jboolean isTry) {
using ::android::hidl::base::V1_0::IBase;
using ::android::hardware::details::getRawServiceInternal;
@@ -331,8 +332,7 @@ static jobject JHwBinder_native_getService(
std::string serviceName(serviceNameCStr);
env->ReleaseStringUTFChars(serviceNameObj, serviceNameCStr);
// TODO(b/67981006): true /* retry */
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, false /* retry */, false /* getStub */);
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, !isTry /* retry */, false /* getStub */);
sp<hardware::IBinder> service = hardware::toBinder<hidl::base::V1_0::IBase>(ret);
if (service == NULL) {
@@ -371,7 +371,7 @@ static JNINativeMethod gMethods[] = {
{ "registerService", "(Ljava/lang/String;)V",
(void *)JHwBinder_native_registerService },
{ "getService", "(Ljava/lang/String;Ljava/lang/String;)L" PACKAGE_PATH "/IHwBinder;",
{ "getService", "(Ljava/lang/String;Ljava/lang/String;Z)L" PACKAGE_PATH "/IHwBinder;",
(void *)JHwBinder_native_getService },
{ "configureRpcThreadpool", "(JZ)V",