From d1c4e3382b79a417cfd625b8208719c4c5b1b51b Mon Sep 17 00:00:00 2001 From: Jay Sharma Date: Tue, 22 Mar 2016 12:41:53 +0530 Subject: [PATCH] [Easy-Setup] Updated Mediator Java SDK. - Added NULL check. Change-Id: I72c8e64dc72559e254a4fd30dd363673127715f5 Signed-off-by: Jay Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/6165 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka (cherry picked from commit dcf0f77d36ec6aec16dcff466d75dd178eba8526) Reviewed-on: https://gerrit.iotivity.org/gerrit/6197 Reviewed-by: Uze Choi --- .../service/easysetup/mediator/EasySetupService.java | 9 +++++++++ .../service/easysetup/mediator/EnrolleeDeviceFactory.java | 15 ++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java index cdf60d5..128dc14 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java @@ -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"); diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeDeviceFactory.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeDeviceFactory.java index 9f62ca1..bcf8219 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeDeviceFactory.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeDeviceFactory.java @@ -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); } - } -- 2.7.4