From efc8b9abdb19a1357fff72e946c4c6977c7a5a65 Mon Sep 17 00:00:00 2001 From: Parkhi Date: Tue, 22 Nov 2016 19:58:38 +0900 Subject: [PATCH] Update Easysetup mediator android sample app - Add validation check logic when received response of findResource. Change-Id: Ib2e9f6bf3534f77e7d6260fca803ccf629df5b2d Signed-off-by: Parkhi Reviewed-on: https://gerrit.iotivity.org/gerrit/14617 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../service/easysetup/EasysetupActivity.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java index 6d46948..0271ae5 100755 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java @@ -403,7 +403,7 @@ public class EasysetupActivity extends Activity return; } - if(ocResource.getHost().contains("coap+tcp")) { + if(ocResource.getHost().contains("+tcp")) { Log.d(TAG, "Recv Found resource event from tcp port," + "ignoring URI : " + ocResource.getUri()); runOnUiThread(new Runnable() { @@ -422,6 +422,23 @@ public class EasysetupActivity extends Activity Log.d(TAG,"URI of the resource: " + resourceUri); Log.d(TAG,"Host address of the resource: " + hostAddress); + mRemoteEnrollee = mEasySetup.createRemoteEnrollee(ocResource); + + if(mRemoteEnrollee == null) { + Log.d(TAG, "Recv Found resource event," + + "ignoring URI : " + ocResource.getUri()); + runOnUiThread(new Runnable() { + @Override + public void run() { + mDiscoverResource.setEnabled(true); + } + }); + return; + } + + isFirstTime = false; + mEnrolleeDeviceID = ocResource.getServerId(); + runOnUiThread(new Runnable() { @Override public void run() { @@ -434,9 +451,6 @@ public class EasysetupActivity extends Activity mProvisionCloudPropProcess.setEnabled(true); } }); - isFirstTime = false; - mRemoteEnrollee = mEasySetup.createRemoteEnrollee(ocResource); - mEnrolleeDeviceID = ocResource.getServerId(); } } } -- 2.7.4