diff options
| author | 2017-10-25 04:50:46 +0000 | |
|---|---|---|
| committer | 2017-10-31 12:01:23 -0700 | |
| commit | ec5eb7e23d13c70443801d9b8caee5dcec66a951 (patch) | |
| tree | 41134c0cad2942b7677c36cf1e3abe94bbc4f800 | |
| parent | 45183fc5a79f0cf21fb3fa7e35b916fd75821267 (diff) | |
Reland "HIDL Java getService now the same as C++."
Add getService(retry) for Java for C++ feature parity.
Test: hidl_test_java, boot
Bug: 67981006
Change-Id: I4e6711f8c2d7ad0ef6994ce9c480118320e1bde8
| -rw-r--r-- | core/java/android/os/HwBinder.java | 13 | ||||
| -rw-r--r-- | core/jni/android_os_HwBinder.cpp | 8 |
2 files changed, 14 insertions, 7 deletions
diff --git a/core/java/android/os/HwBinder.java b/core/java/android/os/HwBinder.java index 270e63f408a7..5e2a0815b60d 100644 --- a/core/java/android/os/HwBinder.java +++ b/core/java/android/os/HwBinder.java @@ -16,10 +16,10 @@ package android.os; -import java.util.ArrayList; -import java.util.NoSuchElementException; import libcore.util.NativeAllocationRegistry; +import java.util.NoSuchElementException; + /** @hide */ public abstract class HwBinder implements IHwBinder { private static final String TAG = "HwBinder"; @@ -46,9 +46,16 @@ public abstract class HwBinder implements IHwBinder { public native final void registerService(String serviceName) throws RemoteException; - public static native final IHwBinder getService( + public static final IHwBinder getService( String iface, String serviceName) + throws RemoteException, NoSuchElementException { + return getService(iface, serviceName, false /* retry */); + } + public static native final IHwBinder getService( + String iface, + String serviceName, + boolean retry) throws RemoteException, NoSuchElementException; public static native final void configureRpcThreadpool( diff --git a/core/jni/android_os_HwBinder.cpp b/core/jni/android_os_HwBinder.cpp index c4f22eeb8b95..08d952791ef6 100644 --- a/core/jni/android_os_HwBinder.cpp +++ b/core/jni/android_os_HwBinder.cpp @@ -296,7 +296,8 @@ static jobject JHwBinder_native_getService( JNIEnv *env, jclass /* clazzObj */, jstring ifaceNameObj, - jstring serviceNameObj) { + jstring serviceNameObj, + jboolean retry) { using ::android::hidl::base::V1_0::IBase; using ::android::hardware::details::getRawServiceInternal; @@ -319,8 +320,7 @@ static jobject JHwBinder_native_getService( serviceName = str.c_str(); } - // TODO(b/67981006): true /* retry */ - sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, false /* retry */, false /* getStub */); + sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, retry /* retry */, false /* getStub */); sp<hardware::IBinder> service = hardware::toBinder<hidl::base::V1_0::IBase>(ret); if (service == NULL) { @@ -360,7 +360,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", |