From 6603b328894b7e0c0411cfcfb708758287ee1e94 Mon Sep 17 00:00:00 2001 From: Cosmin Petrisor Date: Wed, 2 Sep 2015 11:19:41 +0300 Subject: [PATCH] Android: Allow "null" entityHandler to be passed to registerResource in order to use the defaultEntityHandler (see Collections usage) Change-Id: I0e685311c70a297d76a1a7a908a4470610c47b7f Signed-off-by: Cosmin Petrisor Reviewed-on: https://gerrit.iotivity.org/gerrit/2346 Reviewed-by: Tim Kourt Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- android/android_api/base/jni/JniOcPlatform.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/android/android_api/base/jni/JniOcPlatform.cpp b/android/android_api/base/jni/JniOcPlatform.cpp index 8314e9e..4cb6656 100644 --- a/android/android_api/base/jni/JniOcPlatform.cpp +++ b/android/android_api/base/jni/JniOcPlatform.cpp @@ -1011,17 +1011,17 @@ jobject jListener, jint jResourceProperty) { resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); } - if (!jListener) + JniEntityHandler* entityHandler = NULL; + EntityHandler handleEntityCallback = NULL; + if (jListener) { - ThrowOcException(OC_STACK_INVALID_PARAM, "entityHandler cannot be null"); - return nullptr; + entityHandler = new JniEntityHandler(env, jListener); + handleEntityCallback = + [entityHandler](const std::shared_ptr request) -> OCEntityHandlerResult + { + return entityHandler->handleEntity(request); + }; } - JniEntityHandler* entityHandler = new JniEntityHandler(env, jListener); - EntityHandler handleEntityCallback = - [entityHandler](const std::shared_ptr request) -> OCEntityHandlerResult - { - return entityHandler->handleEntity(request); - }; OCResourceHandle resourceHandle; try -- 2.7.4