[Easy-Setup] Updated Mediator Java SDK.
authorJay Sharma <jay.sharma@samsung.com>
Tue, 22 Mar 2016 07:11:53 +0000 (12:41 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 23 Mar 2016 05:16:49 +0000 (05:16 +0000)
- Added NULL check.

Change-Id: I72c8e64dc72559e254a4fd30dd363673127715f5
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6165
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/EasySetupService.java
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeDeviceFactory.java

index cdf60d5..128dc14 100755 (executable)
@@ -104,6 +104,10 @@ public class EasySetupService {
 
     public synchronized void startSetup(final EnrolleeDevice enrolledevice) throws IOException,ESException {
 
+        if (null == enrolledevice) {
+            throw new ESException("enrolledevice is NULL");
+        }
+
         mEnrolleeDeviceList.add(enrolledevice);
 
         // Starts the provisioning directly if the device is already on boarded on the network.
@@ -172,6 +176,11 @@ public class EasySetupService {
      * @param enrolleedevice Device to be enrolled in network
      */
     public synchronized void stopSetup(EnrolleeDevice enrolleedevice) throws ESException {
+
+        if (null == enrolleedevice) {
+            throw new ESException("enrolledevice is NULL");
+        }
+
         if (mEnrolleeDeviceList.contains(enrolleedevice)) {
             if (enrolleedevice.mState == EnrolleeState.DEVICE_ON_BOARDING_STATE) {
                 Log.i(TAG, "stopOnBoardingProcess for enrolleedevice");
index 9f62ca1..bcf8219 100644 (file)
@@ -53,12 +53,14 @@ public class EnrolleeDeviceFactory {
      * @return Instance of the Enrollee device created natively.
      */
 
-    public EnrolleeDevice newEnrolleeDevice(ProvisioningConfig provConfig, OnBoardingConfig onboardingConfig) {
+    public EnrolleeDevice newEnrolleeDevice(ProvisioningConfig provConfig, OnBoardingConfig onboardingConfig) throws IllegalArgumentException {
 
-        if (onboardingConfig.getConnType() != OnBoardingConfig.ConnType.WiFi) {
+        if (null == provConfig  || null == onboardingConfig) {
+            throw new IllegalArgumentException("provConfig/onboardingConfig is NULL");
+        }
+        else if (onboardingConfig.getConnType() != OnBoardingConfig.ConnType.WiFi) {
             throw new IllegalArgumentException("OnBoarding configuration is not supported");
         }
-
         return new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
     }
 
@@ -69,8 +71,11 @@ public class EnrolleeDeviceFactory {
      * @param provConfig       Contains details about the network to which Enrollee device is going to connect.
      * @return Instance of the Enrollee device created natively.
      */
-    public EnrolleeDevice newEnrolleeDevice(ProvisioningConfig provConfig){
+    public EnrolleeDevice newEnrolleeDevice(ProvisioningConfig provConfig) throws IllegalArgumentException {
+
+        if (null == provConfig) {
+            throw new IllegalArgumentException("provConfig is NULL");
+        }
         return new EnrolleeDeviceWiFiOnboarding(mContext, new IpOnBoardingConnection(true), provConfig);
     }
-
 }