Update Easysetup mediator android sample app
authorParkhi <h_w.park@samsung.com>
Tue, 22 Nov 2016 10:58:38 +0000 (19:58 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Thu, 24 Nov 2016 03:36:24 +0000 (03:36 +0000)
 - Add validation check logic when received response of findResource.

Change-Id: Ib2e9f6bf3534f77e7d6260fca803ccf629df5b2d
Signed-off-by: Parkhi <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14617
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java

index 6d46948..0271ae5 100755 (executable)
@@ -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();
                         }
                     }
                 }