Update validation check logic on Android SDK.
authorHeewon Park <h_w.park@samsung.com>
Mon, 29 Aug 2016 06:13:24 +0000 (15:13 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 30 Aug 2016 05:21:46 +0000 (05:21 +0000)
Change-Id: Ia0b2d1f7027ee68343a8de715ece26267a0c4dbf
Signed-off-by: Heewon Park <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10951
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceProp.java
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java

index 6f4d5be..06dda51 100644 (file)
@@ -30,8 +30,8 @@ import org.iotivity.base.OcRepresentation;
  */
 public class CloudProp {
     private static final String TAG = CloudProp.class.getName();
-    protected OcRepresentation mRep;
-    protected String mCloudID;
+    protected OcRepresentation mRep = null;
+    protected String mCloudID = null;
 
     /**
      * Constructor
@@ -63,13 +63,21 @@ public class CloudProp {
      */
     public String getAuthCode()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHCODE))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHCODE);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getAuthCode is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
@@ -78,13 +86,21 @@ public class CloudProp {
      */
     public String getAuthProvider()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHPROVIDER))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getAuthProvider is failed.");
         }
-        return new String("");
+        return null;
     }
 
        /**
@@ -93,13 +109,21 @@ public class CloudProp {
      */
     public String getCiServer()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_CISERVER))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_CISERVER);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getCiServer is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
index 2f42ec6..f8669c4 100644 (file)
@@ -33,7 +33,7 @@ import org.iotivity.base.OcRepresentation;
  */
 public class DeviceProp {
     private static final String TAG = DeviceProp.class.getName();
-    protected OcRepresentation mRep;
+    protected OcRepresentation mRep = null;
 
     /**
      * Constructor
@@ -73,13 +73,21 @@ public class DeviceProp {
      */
     public String getSsid()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if(mRep.hasAttribute(ESConstants.OC_RSRVD_ES_SSID))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_SSID);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getSsid is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
@@ -89,13 +97,21 @@ public class DeviceProp {
      */
     public String getPassword()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if(mRep.hasAttribute(ESConstants.OC_RSRVD_ES_CRED))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_CRED);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getPassword is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
@@ -106,10 +122,18 @@ public class DeviceProp {
      */
     public WIFI_AUTHTYPE getAuthType()
     {
-        try {
+        if(mRep == null)
+        {
+            return WIFI_AUTHTYPE.NONE_AUTH;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHTYPE))
                 return WIFI_AUTHTYPE.fromInt((int)mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHTYPE));
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getAuthType is failed.");
         }
         return WIFI_AUTHTYPE.NONE_AUTH;
@@ -123,10 +147,18 @@ public class DeviceProp {
      */
     public WIFI_ENCTYPE getEncType()
     {
-        try {
+        if(mRep == null)
+        {
+            return WIFI_ENCTYPE.NONE_ENC;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_ENCTYPE))
                 return WIFI_ENCTYPE.fromInt((int)mRep.getValue(ESConstants.OC_RSRVD_ES_ENCTYPE));
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getEncType is failed.");
         }
         return WIFI_ENCTYPE.NONE_ENC;
@@ -139,13 +171,21 @@ public class DeviceProp {
      */
     public String getLanguage()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if(mRep.hasAttribute(ESConstants.OC_RSRVD_ES_LANGUAGE))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_LANGUAGE);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getLanguage is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
@@ -155,13 +195,21 @@ public class DeviceProp {
      */
     public String getCountry()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_COUNTRY))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_COUNTRY);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getCountry is failed.");
         }
-        return new String("");
+        return null;
     }
 
     /**
@@ -171,13 +219,21 @@ public class DeviceProp {
      */
     public String getLocation()
     {
-        try {
+        if(mRep == null)
+        {
+            return null;
+        }
+
+        try
+        {
             if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_LOCATION))
                 return mRep.getValue(ESConstants.OC_RSRVD_ES_LOCATION);
-        } catch (OcException e) {
+        }
+        catch (OcException e)
+        {
             Log.e(TAG, "getLocation is failed.");
         }
-        return new String("");
+        return null;
     }
 
     public OcRepresentation toOCRepresentation()
index d7a8862..7deca03 100755 (executable)
@@ -63,6 +63,11 @@ public class EnrolleeConf
      */
     public String getDeviceName()
     {
+        if(mProvRep == null)
+        {
+            return null;
+        }
+
         List<OcRepresentation> children = mProvRep.getChildren();
 
         for (OcRepresentation child : children) {
@@ -78,8 +83,7 @@ public class EnrolleeConf
                 }
             }
         }
-
-        return new String("");
+        return null;
     }
 
     /**
@@ -89,6 +93,11 @@ public class EnrolleeConf
      */
     public String getModelNumber()
     {
+        if(mProvRep == null)
+        {
+            return null;
+        }
+
         List<OcRepresentation> children = mProvRep.getChildren();
 
         for (OcRepresentation child : children) {
@@ -104,8 +113,7 @@ public class EnrolleeConf
                 }
             }
         }
-
-        return new String("");
+        return null;
     }
 
     /**
@@ -115,6 +123,11 @@ public class EnrolleeConf
      */
     public ArrayList<WIFI_MODE> getWiFiModes()
     {
+        if(mProvRep == null)
+        {
+            return null;
+        }
+
         List<OcRepresentation> children = mProvRep.getChildren();
         ArrayList<WIFI_MODE> modes = new ArrayList<WIFI_MODE>();
         for (OcRepresentation child : children) {
@@ -132,7 +145,6 @@ public class EnrolleeConf
                 }
             }
         }
-
         return modes;
     }
 
@@ -143,6 +155,11 @@ public class EnrolleeConf
      */
     public WIFI_FREQ getWiFiFreq()
     {
+        if(mProvRep == null)
+        {
+            return WIFI_FREQ.WIFI_FREQ_NONE;
+        }
+
         List<OcRepresentation> children = mProvRep.getChildren();
 
         for (OcRepresentation child : children) {
@@ -157,7 +174,7 @@ public class EnrolleeConf
                 }
             }
         }
-        return WIFI_FREQ.WIFI_FREQ_NONE;
+        return null;
     }
 
     /**
@@ -168,6 +185,11 @@ public class EnrolleeConf
      */
     public boolean isCloudAccessible()
     {
+        if(mProvRep == null)
+        {
+            return false;
+        }
+
         List<OcRepresentation> children = mProvRep.getChildren();
 
         for (OcRepresentation child : children) {