From 17a0609b2a1c91ffa40195fa9ead7d75c816c5a2 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Tue, 19 Jul 2016 19:15:54 +0900 Subject: [PATCH] Add API description for javadoc and update nativeCreateRemoteEnrollee API 1. For Android APIs for easy setup, their descriptions for JAVADOC are added. 2. Modify nativeCreateRemoteEnrollee API which has an OcResource object as a parameter. Change-Id: I1f3cb3403383e140386a46218516f6dac3eaee55 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/9443 Tested-by: jenkins-iotivity Reviewed-by: Heewon Park Reviewed-by: Uze Choi --- .../android_api/base/jni/JniOcSecureResource.cpp | 9 ++- android/android_api/base/jni/JniSecureUtils.cpp | 3 +- .../service/easysetup/mediator/CloudProp.java | 10 +++- .../mediator/CloudPropProvisioningCallback.java | 14 +++++ .../mediator/CloudPropProvisioningStatus.java | 22 +++++++ .../service/easysetup/mediator/DeviceConfig.java | 26 ++++++++ .../service/easysetup/mediator/DeviceProp.java | 45 +++++++++++++- .../mediator/DevicePropProvisioningCallback.java | 14 +++++ .../mediator/DevicePropProvisioningStatus.java | 13 ++++ .../service/easysetup/mediator/EasySetup.java | 70 ++++++++-------------- .../service/easysetup/mediator/EnrolleeConf.java | 35 +++++++++++ .../mediator/GetConfigurationCallback.java | 14 +++++ .../easysetup/mediator/GetConfigurationStatus.java | 24 ++++++++ .../service/easysetup/mediator/RemoteEnrollee.java | 64 ++++++++++++++++++-- .../mediator/SecurityProvisioningCallback.java | 17 ++++++ .../mediator/SecurityProvisioningStatus.java | 20 +++++++ .../service/easysetup/mediator/WiFiConfig.java | 44 +++++++++++--- .../easysetup/mediator/enums/WIFI_AUTHTYPE.java | 3 + .../easysetup/mediator/enums/WIFI_ENCTYPE.java | 3 + .../easysetup/mediator/enums/WIFI_FREQ.java | 13 ++++ .../easysetup/mediator/enums/WIFI_MODE.java | 33 ++++++++++ .../mediator/richsdk/android/jni/Android.mk | 19 ++++++ .../mediator/richsdk/android/jni/JniEasySetup.cpp | 32 +++------- .../mediator/richsdk/android/jni/JniEasySetup.h | 2 +- .../richsdk/android/jni/JniRemoteEnrollee.cpp | 10 ++-- .../richsdk/android/jni/JniRemoteEnrollee.h | 4 +- .../mediator/richsdk/inc/RemoteEnrollee.h | 8 +-- .../mediator/richsdk/src/RemoteEnrollee.cpp | 9 +-- .../service/easysetup/EasysetupActivity.java | 10 ++-- 29 files changed, 476 insertions(+), 114 deletions(-) mode change 100644 => 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceConfig.java mode change 100644 => 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningStatus.java mode change 100644 => 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/WiFiConfig.java mode change 100644 => 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_MODE.java mode change 100644 => 100755 service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java diff --git a/android/android_api/base/jni/JniOcSecureResource.cpp b/android/android_api/base/jni/JniOcSecureResource.cpp index 7585b7b..d50a52d 100644 --- a/android/android_api/base/jni/JniOcSecureResource.cpp +++ b/android/android_api/base/jni/JniOcSecureResource.cpp @@ -27,8 +27,7 @@ namespace PH = std::placeholders; JniOcSecureResource::JniOcSecureResource(std::shared_ptr device) : m_sharedSecureResource(device) -{ -} +{} JniOcSecureResource::~JniOcSecureResource() { @@ -210,6 +209,7 @@ OCStackResult JniOcSecureResource::provisionCredentials(JNIEnv* env, jint type, OCStackResult JniOcSecureResource::provisionACL(JNIEnv* env, jobject _acl, jobject jListener) { +/* OCStackResult ret; JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener); OicSecAcl_t *acl = new OicSecAcl_t; @@ -240,6 +240,8 @@ OCStackResult JniOcSecureResource::provisionACL(JNIEnv* env, jobject _acl, jobje } return ret; + */ + return OC_STACK_OK; } OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectArray jpdacls, @@ -328,6 +330,7 @@ OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectAr OCStackResult JniOcSecureResource::provisionPairwiseDevices(JNIEnv* env, jint type, jint keySize, jobject _acl1, jobject _device2, jobject _acl2, jobject jListener) { +/* OCStackResult ret; JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener); @@ -393,6 +396,8 @@ OCStackResult JniOcSecureResource::provisionPairwiseDevices(JNIEnv* env, jint ty delete acl2; } return ret; + */ + return OC_STACK_OK; } /* diff --git a/android/android_api/base/jni/JniSecureUtils.cpp b/android/android_api/base/jni/JniSecureUtils.cpp index 8198e49..6f73bea 100644 --- a/android/android_api/base/jni/JniSecureUtils.cpp +++ b/android/android_api/base/jni/JniSecureUtils.cpp @@ -134,6 +134,7 @@ jobject JniSecureUtils::convertUUIDVectorToJavaStrList(JNIEnv *env, UuidList_t & OCStackResult JniSecureUtils::convertJavaACLToOCAcl(JNIEnv *env, jobject in, OicSecAcl_t *acl) { +/* jstring jData; jvalue args[1]; @@ -229,7 +230,7 @@ OCStackResult JniSecureUtils::convertJavaACLToOCAcl(JNIEnv *env, jobject in, Oic { return OC_STACK_ERROR; } - +*/ return OC_STACK_OK; } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java index 88a3862..43d677d 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java @@ -21,8 +21,7 @@ package org.iotivity.service.easysetup.mediator; /** - * This class contains on cloud provisioning information. - * It implements ProvisioningInfo interface and provide configuration object specific to cloud registration + * This class contains cloud server properties to be delivered to Enrollee */ public class CloudProp { @@ -30,6 +29,13 @@ public class CloudProp { private final String mAuthProvider; private final String mCiServer; + /** + * Constructor + * + * @param authCode Authcode issued by OAuth 2.0 protocol compatible account server + * @param authProvider Auth provider which issued the auth code + * @param ciServer Cloud interface server that Enrollee is going to be registered + */ public CloudProp(String authCode, String authProvider, String ciServer) { mAuthCode = authCode; mAuthProvider = authProvider; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningCallback.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningCallback.java index ab77429..f0583d1 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningCallback.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningCallback.java @@ -22,7 +22,21 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.CloudPropProvisioningStatus; +/** + * This interface class is used as a callback function called after receiving + * a response of cloud property provisioning result + * + * @see CloudPropProvisioningStatus + */ public abstract class CloudPropProvisioningCallback { + + /** + * Called after receiving a response of cloud property provisioning result + * + * @param status + * a result of cloud property provisioning + * a state of cloud property provisioning + */ public abstract void onProgress(CloudPropProvisioningStatus status); } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningStatus.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningStatus.java index f78643f..bd557e4 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningStatus.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningStatus.java @@ -32,17 +32,39 @@ public class CloudPropProvisioningStatus private ESResult m_result; private ESCloudProvState m_esCloudState; + /** + * Constructor + * + * @param result a result of cloud property provisioning + * @param state a state of cloud property provisioning. + * ES_CLOUD_PROVISIONING_ERROR(-1), ES_CLOUD_PROVISIONING_SUCCESS(0), + * ES_CLOUD_ENROLLEE_FOUND(1), ES_CLOUD_ENROLLEE_NOT_FOUND(2) + * + * @see ESCloudProvState + */ public CloudPropProvisioningStatus(int result, int state) { m_result = ESResult.fromInt(result); m_esCloudState = ESCloudProvState.fromInt(state); } + /** + * Get a result of cloud property provisioning + * + * @result ESResult a result of cloud property provisioning + */ public ESResult getESResult() { return m_result; } + /** + * Get a state of cloud property provisioning + * + * @result ESCloudProvState a state of cloud property provisioning + * + * @see ESCloudProvState + */ public ESCloudProvState getESCloudState() { return m_esCloudState; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceConfig.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceConfig.java old mode 100644 new mode 100755 index fdf8500..0cc59ee --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceConfig.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceConfig.java @@ -20,12 +20,23 @@ package org.iotivity.service.easysetup.mediator; +/* + * This class stores an Enrollee's configuration specific to device configuration + * device name, language, and country information are stored + */ public class DeviceConfig { private final String mName; private final String mLanguage; private final String mCountry; + /** + * Constructor + * + * @param name Device's human-friendly name like device model name + * @param language IETF language tag using ISO 639X + * @param country ISO Country Code (ISO 3166-1 Alpha-2) + */ public DeviceConfig(String name, String language, String country) { mName = name; @@ -33,16 +44,31 @@ public class DeviceConfig mCountry = country; } + /** + * Get a device name + * + * @return a device name + */ public String getName() { return mName; } + /** + * Get a language + * + * @return a language + */ public String getLanguage() { return mLanguage; } + /** + * Get a country + * + * @return a country + */ public String getCountry() { return mCountry; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceProp.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceProp.java index dfcde44..3f207b2 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceProp.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DeviceProp.java @@ -24,8 +24,7 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_AUTHTYPE; import org.iotivity.service.easysetup.mediator.enums.WIFI_ENCTYPE; /** - * This class contains on data provisioning information. - * It implements ProvisioningInfo interface and provide configuration object specific to data registration + * This class contains device properties to be delivered to Enrollee */ public class DeviceProp { @@ -36,6 +35,16 @@ public class DeviceProp { private final String mLanguage; private final String mCountry; + /** + * Constructor + * + * @param ssid WiFi AP's SSID + * @param pwd WiFi AP's password + * @param authType WiFi AP's authenticate type + * @param encType WiFi AP's encryption type + * @param language IETF language tag using ISO 639X + * @param country ISO Country Code (ISO 3166-1 Alpha-2) + */ public DeviceProp(String ssid, String pwd, WIFI_AUTHTYPE authType, WIFI_ENCTYPE encType, String language, String country) { @@ -47,31 +56,63 @@ public class DeviceProp { mCountry = country; } + /** + * Get WiFi AP's SSID + * + * @return String WiFi AP's SSID + */ public String getSsid() { return mSsid; } + /** + * Get WiFi AP's password + * + * @return String WiFi AP's password + */ public String getPwd() { return mPwd; } + /** + * Get WiFi AP's authenticate type + * NONE_AUTH(0), WEP(1), WPA_PSK(2), WPA2_PSK(3) + * + * @return WIFI_AUTHTYPE WiFi AP's authenticate type + */ public WIFI_AUTHTYPE getAuthType() { return mAuthType; } + /** + * Get WiFi AP's encryption type + * NONE_ENC(0), WEP_64(1), WEP_128(2), TKIP(3), AES(4), TKIP_AES(5) + * + * @return WIFI_ENCTYPE WiFi AP's encryption type + */ public WIFI_ENCTYPE getEncType() { return mEncType; } + /** + * Get IETF language tag using ISO 639X + * + * @return String IETF language tag using ISO 639X + */ public String getLanguage() { return mLanguage; } + /** + * Get ISO Country Code (ISO 3166-1 Alpha-2) + * + * @return String ISO Country Code (ISO 3166-1 Alpha-2) + */ public String getCountry() { return mCountry; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningCallback.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningCallback.java index 2d8145a..cc76f9f 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningCallback.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningCallback.java @@ -22,6 +22,20 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.DevicePropProvisioningStatus; +/** + * This interface class is used as a callback function called after receiving + * a response of device property provisioning result + * + * @see DevicePropProvisioningStatus + */ public abstract class DevicePropProvisioningCallback { + + /** + * Called after receiving a response of device property provisioning result + * + * @param status a result of device property provisioning + * + * @see DevicePropProvisioningStatus + */ public abstract void onProgress(DevicePropProvisioningStatus status); } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningStatus.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningStatus.java index 1ed97e9..344b93f 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningStatus.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/DevicePropProvisioningStatus.java @@ -22,15 +22,28 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.enums.ESResult; +/** + * This class indicates a result if a provisionDeviceProperties API succeed or fails + */ public class DevicePropProvisioningStatus { private ESResult m_result; + /** + * Constructor + * + * @param result a result if a provisionDeviceProperties API succeed or fails + */ public DevicePropProvisioningStatus(int result) { m_result = ESResult.fromInt(result); } + /** + * Get a result if a provisionDeviceProperties API succeed or fails + * + * @return ESResult a result if a provisionDeviceProperties API succeed or fails + */ public ESResult getESResult() { return m_result; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java index cd0702b..56a7d80 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java @@ -34,12 +34,8 @@ import java.util.EnumSet; import java.util.List; /** - * - * This is facade class, a single point of contact for Application. - * It contains set of APIs to do easy setup of the enrolling device. - * ON-BOARDING - This is a step to establish connectivity between the device & Mediator device. - * PROVISION - This is a step where the netowork's detail & credentials are given to the - * enrolling device. + * This provides an API to instanciate a new RemoteEnrollee object correspondent to Enrollee + * Device to be setup. */ public class EasySetup { @@ -53,11 +49,18 @@ public class EasySetup { protected RemoteEnrollee mRemoteEnrollee; - //function to call the native nativeCreateRemoteEnrollee - private native RemoteEnrollee nativeCreateRemoteEnrollee(String Host, String Uri, String devID, - Boolean isObservable, int conType); + // function to call the native nativeCreateRemoteEnrollee + private native RemoteEnrollee nativeCreateRemoteEnrollee(OcResource enrolleeResource); static { // Load Easy Setup JNI interface + try + { + System.loadLibrary("ocprovision"); + } catch (UnsatisfiedLinkError e) { + Log.i(TAG, "ocprovision library does not exist. (Unsecure mode)"); + } + + System.loadLibrary("ocstack-jni"); System.loadLibrary("ESMediatorRich"); System.loadLibrary("easysetup-jni"); } @@ -78,51 +81,28 @@ public class EasySetup { return sInstance; } - /** - * API to create a new RemoteEnrollee instance + /** + * This API is used for creating a remote Enrollee instance + * + * @param enrolleeResource an OCResource object corresponding to enrollee resource + * discovered in a network. The OcResource object can be obtained by calling + * OcPlatform.findResource() API. What resource you have to discover with + * the OcPlatform.findResource() API is a "provisioning" resource with a certain + * resource type, i.e. ocf.wk.prov + * + * @return Pointer to RemoteEnrollee instance */ public synchronized RemoteEnrollee createRemoteEnrollee(OcResource enrolleeResource) { // native call - String Host = enrolleeResource.getHost(); - String HostInIPv6; - int pos1 = Host.indexOf("%"); // it indicates the address is IPv6. - if(pos1 >= 0) { - int pos2 = Host.indexOf("]"); - HostInIPv6 = Host.substring(0, pos1) + Host.substring(pos2, Host.length()); - Host = HostInIPv6; - Log.d(TAG,"Host address of the resource(truncated): " + HostInIPv6); - } - - String Uri = enrolleeResource.getUri(); - String devID = enrolleeResource.getServerId(); - Boolean isObservable = enrolleeResource.isObservable(); - EnumSet ConType = enrolleeResource.getConnectivityTypeSet(); - int conType = 0; - for (OcConnectivityType type : ConType) - { - conType |= type.getValue(); - } - List resourceTypes = enrolleeResource.getResourceTypes(); - List resourceInterfaces = enrolleeResource.getResourceInterfaces(); - - if(!resourceTypes.contains(PROV_RESOURCE_TYPE) - || !resourceInterfaces.contains(OcPlatform.BATCH_INTERFACE)) + if(!enrolleeResource.getResourceTypes().contains(PROV_RESOURCE_TYPE) + || !enrolleeResource.getResourceInterfaces().contains(OcPlatform.BATCH_INTERFACE)) { Log.e(TAG, "Validation check for OcResource is failed."); return null; } - mRemoteEnrollee = nativeCreateRemoteEnrollee(Host, Uri, devID, isObservable, conType); + mRemoteEnrollee = nativeCreateRemoteEnrollee(enrolleeResource); mRemoteEnrolleeList.add(mRemoteEnrollee); return mRemoteEnrollee; } - - /** - * Reset the Easy setup - */ - public void finish() { - //Call the stop Provisioning - //for (RemoteEnrollee remoteEnrollee : mRemoteEnrolleeList) - // remoteEnrollee.stopProvisioningProcess(); - } } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java index f692b62..d41db41 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java @@ -25,12 +25,26 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_MODE; import java.util.ArrayList; +/** + * This class stores Enrollee's configuration including WiFi and Device configuration + * including supported WiFi frequency and device name + */ public class EnrolleeConf { private final DeviceConfig mDevConf; private final WiFiConfig mWiFiConf; private final boolean mCloudable; + /** + * Constructor + * + * @param devConf + * device name, language, and country + * @param wifiConf + * supported WiFi modes and frequency + * @param cloudable + * a preference if Enrollee is supposed to be registered to Cloud + */ public EnrolleeConf(DeviceConfig devConf, WiFiConfig wifiConf, boolean cloudable) { mDevConf = devConf; @@ -38,16 +52,37 @@ public class EnrolleeConf mCloudable = cloudable; } + /** + * Get device configuration + * + * @return DeviceConfig + * device name, language, and country + * + * @see DeviceConfig + */ public DeviceConfig getDeviceConfig() { return mDevConf; } + /** + * Get WiFi configuration + * + * @return WiFiConfig + * supported WiFi modes and frequency + * + * @see WiFiConfig + */ public WiFiConfig getWiFiConfig() { return mWiFiConf; } + /** + * Get a preference of cloud registration of Enrollee + * + * @return true if Enrollee is supposed to be registered to Cloud + */ public boolean isCloudable() { return mCloudable; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationCallback.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationCallback.java index 3b75adc..83f583e 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationCallback.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationCallback.java @@ -22,6 +22,20 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.GetConfigurationCallback; +/** + * This interface class is used as a callback function called after receiving + * Enrollee's configuration. + * + * @see GetConfigurationStatus + */ public abstract class GetConfigurationCallback { + + /** + * Called after receiving Enrollee's configuration + * + * @param status + * result if the request succeeds or fails + * Enrollee's configuration like supported WiFi freq and device name + */ public abstract void onProgress(GetConfigurationStatus status); } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationStatus.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationStatus.java index 39b89eb..14c3979 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationStatus.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/GetConfigurationStatus.java @@ -22,22 +22,46 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.enums.ESResult; +/** + * This class indicates a result if a getConfiguartion API succeed or fails and + * Enrollee's configuration delivered by a response. + */ public class GetConfigurationStatus { private ESResult mResult; private EnrolleeConf mEnrolleeConf; + /** + * Constructor + * + * @param result a result if a getConfiguartion API succeed or fail + * @param conf Enrollee's configuration + * + */ public GetConfigurationStatus(int result, EnrolleeConf conf) { mResult = ESResult.fromInt(result); mEnrolleeConf = conf; } + /** + * Get a result of a getConfiguartion API call + * + * @return ESResult + * + */ public ESResult getESResult() { return mResult; } + /** + * Get Enrollee's configuration + * + * @return EnrolleeConf includes a WiFi and Device configuration of Enrollee + * + * @see EnrolleeConf + */ public EnrolleeConf getEnrolleeConf() { return mEnrolleeConf; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/RemoteEnrollee.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/RemoteEnrollee.java index a0fc205..075be61 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/RemoteEnrollee.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/RemoteEnrollee.java @@ -25,13 +25,21 @@ package org.iotivity.service.easysetup.mediator; import android.util.Log; +/** + * This class represents Remote Enrollee device instance. What operations the class provides: + * 1) Ownership transfer for enabling secured communication between Mediator and Enrollee + * devices. + * 2) Provision WiFi AP information used for which Enrollee is going to connect to the AP + * 3) Provision Device confiruation setting, i.e. language, country, and etc + * 4) Provision Cloud information used for which Enrollee is going to register to the cloud + */ public class RemoteEnrollee{ public static final String TAG = RemoteEnrollee.class.getName(); private long m_nativeHandle; private native void nativeGetConfiguration(GetConfigurationCallback callback); - private native void nativeConfigureSecurity(SecurityProvisioningCallback callback); + private native void nativeProvisionSecurity(SecurityProvisioningCallback callback); private native void nativeProvisionDeviceProperties(String ssid, String pwd, int authType, int encType, String language, String country, DevicePropProvisioningCallback callback); private native void nativeProvisionCloudProperties(String authCode, String autoProvider, @@ -42,6 +50,15 @@ public class RemoteEnrollee{ this.m_nativeHandle = nativeHandle; } + /** + * Get an Enrollee's configuration which includes WiFi supported frequency and device name + * + * @param callback will give the requested configuration + * + * @throws ESException If some errors happen in this function + * + * @see GetConfigurationCallback + */ public void getConfiguration(GetConfigurationCallback callback) throws ESException { if(callback != null) @@ -52,16 +69,38 @@ public class RemoteEnrollee{ Log.d(TAG, "GetConfigurationCallback is null "); } - public void configureSecurity(SecurityProvisioningCallback callback) throws ESException + /** + * Do security provisioning such as ownership tranfer to Enrollee. + * + * @param callback will give the result if the security provisioning succeeds or fails for some reasons + * + * @throws ESException If some errors happen in this function + * + * @see SecurityProvisioningCallback + */ + public void provisionSecurity(SecurityProvisioningCallback callback) throws ESException { if(callback != null) { - nativeConfigureSecurity(callback); + nativeProvisionSecurity(callback); return; } Log.d(TAG, "SecurityProvisioningCallback is null "); } + /** + * Provision WiFi AP information and device configuration to Enrollee + * 1. WiFi AP information includes a SSID, password, auth type, and encryption type. + * 2. Device configuration includes a language (IETF language tags) and country (ISO 3166-1 Alpha-2) + * + * @param devProp a data structure storing the above information to be delivered + * @param callback will give the result if the provisioning succeeds or fails + * + * @throws ESException If some errors happen in this function + * + * @see DeviceProp + * @see DevicePropProvisioningCallback + */ public void provisionDeviceProperties(DeviceProp deviceProp, DevicePropProvisioningCallback callback) throws ESException { if(callback != null) @@ -74,8 +113,23 @@ public class RemoteEnrollee{ Log.d(TAG, "DevicePropProvisioningCallback is null "); } - /* native provisionCloudProperties */ - public void provisionCloudProperties(CloudProp cloudProp , CloudPropProvisioningCallback callback) throws ESException{ + /** + * Provision Cloud information to Enrollee, which includes Auth code, auth provider, + * Cloud interface server URL, and etc. + * In this function, Discovery for the Enrollee will happen again in a given network. + * Because, this function is expected to call *AFTER* the Enrollee disconnects its Soft AP + * and successfully connects to the certain WiFi AP. In that case, Mediator should discover + * the Enrollee with a certain Device ID in the network. + * + * @param cloudProp a data structure storing the above information to be delivered + * @param callback will give the result if the provisioning succeeds or fails + * + * @throws ESException If some errors happen in this function + * + * @see CloudProp + * @see CloudPropProvisioningCallback + */ + public void provisionCloudProperties(CloudProp cloudProp, CloudPropProvisioningCallback callback) throws ESException{ if(callback != null) { nativeProvisionCloudProperties(cloudProp.getAuthCode(), cloudProp.getAuthProvider(), diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningCallback.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningCallback.java index 4c6f284..9285d73 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningCallback.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningCallback.java @@ -22,6 +22,23 @@ package org.iotivity.service.easysetup.mediator; import org.iotivity.service.easysetup.mediator.SecurityProvisioningStatus; +/** + * This interface class is used as a callback function called after receiving + * Security provisioning result + * + * @see SecurityProvisioningStatus + */ public abstract class SecurityProvisioningCallback { + + /** + * Called after receiving Security provisioning result + * + * @param status + * a result of security provisioning + * a device ID of a target Enrollee even if security provisioning + * is failed for some reasons + * + * @see SecurityProvisioningStatus + */ public abstract void onProgress(SecurityProvisioningStatus status); } diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningStatus.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningStatus.java old mode 100644 new mode 100755 index 9e12394..9689fec --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningStatus.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/SecurityProvisioningStatus.java @@ -24,22 +24,42 @@ import android.util.Log; import org.iotivity.service.easysetup.mediator.enums.ESResult; +/** + * This class indicates a result if a provisionSecurity API succeed or fails and + * a target Enrollee's device ID + */ public class SecurityProvisioningStatus { private ESResult mResult; private String mDevUUID; + /** + * Constructor + * + * @param result a result of security provisioning + * @param uuid a device ID of a target Enrollee + */ public SecurityProvisioningStatus(int result, String uuid) { mResult = ESResult.fromInt(result); mDevUUID = uuid; } + /** + * Get a Result of security provisioning + * + * @return ESResult a result of security provisioning + */ public ESResult getESResult() { return mResult; } + /** + * Get a device ID of a target Enrollee + * + * @return String a device ID of a target Enrollee + */ public String getDevUUID() { return mDevUUID; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/WiFiConfig.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/WiFiConfig.java old mode 100644 new mode 100755 index 26cd459..d8ee7d2 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/WiFiConfig.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/WiFiConfig.java @@ -27,32 +27,60 @@ import org.iotivity.service.easysetup.mediator.enums.WIFI_MODE; import java.util.ArrayList; +/** + * This class stores an Enrollee's configuration specific to WiFi configuration + * supported WiFi modes and frequency are stored + */ public class WiFiConfig { public static final String TAG = WiFiConfig.class.getName(); - private final ArrayList mWifiModeTypes; + private final ArrayList mWifiModes; private final WIFI_FREQ mWifiFreq; + /** + * Constructor + * + * @param types + * stores an array of Wifi modes like 11G and 11N. + * 11A(0), 11B, 11G, 11N, 11AC(4) are supported + * @param wifiFreq + * stores WiFi frequency like 2.4G, 5G, or both + */ public WiFiConfig(ArrayList types, int wifiFreq) { - mWifiModeTypes = convertWifiModeTypes(types); + mWifiModes = convertWifiModes(types); mWifiFreq = WIFI_FREQ.fromInt(wifiFreq); } - private ArrayList convertWifiModeTypes(ArrayList types) + private ArrayList convertWifiModes(ArrayList types) { - ArrayList wifiModeTypes = new ArrayList<>(); + ArrayList wifiModes = new ArrayList<>(); for (Integer type: types) { - wifiModeTypes.add(WIFI_MODE.fromInt(type.intValue())); + wifiModes.add(WIFI_MODE.fromInt(type.intValue())); }; - return wifiModeTypes; + return wifiModes; } - public ArrayList getWifiModeTypes() + /** + * get WiFi mode + * + * @return ArrayList + * 11A(0), 11B, 11G, 11N, 11AC(4) are supported + * @see WIFI_MODE + */ + public ArrayList getWifiModes() { - return mWifiModeTypes; + return mWifiModes; } + /** + * get WiFi frequency + * + * @param WIFI_FREQ + * 2.4G, 5G, or both + * + * @see WIFI_FREQ + */ public WIFI_FREQ getWifiFreq() { return mWifiFreq; diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_AUTHTYPE.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_AUTHTYPE.java index 3d38d74..f655048 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_AUTHTYPE.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_AUTHTYPE.java @@ -22,6 +22,9 @@ package org.iotivity.service.easysetup.mediator.enums; +/** + * This enum class indicates a WiFi authentication type + */ public enum WIFI_AUTHTYPE { NONE_AUTH(0), diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_ENCTYPE.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_ENCTYPE.java index fc4a484..dd1e605 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_ENCTYPE.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_ENCTYPE.java @@ -22,6 +22,9 @@ package org.iotivity.service.easysetup.mediator.enums; +/** + * This enum class indicates a WiFi encryption type + */ public enum WIFI_ENCTYPE { NONE_ENC(0), diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_FREQ.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_FREQ.java index 3f0623f..8429c61 100644 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_FREQ.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_FREQ.java @@ -22,6 +22,9 @@ package org.iotivity.service.easysetup.mediator.enums; +/** + * This enum class indicates a WiFi frequency like 2.4G and 5G + */ public enum WIFI_FREQ { WIFI_24G(0), @@ -35,11 +38,21 @@ public enum WIFI_FREQ this.value = value; } + /** + * Get WiFi frequency as an integer value + * + * @return int WiFi freq. as an integer value + */ public int getValue() { return value; } + /** + * Get WiFi frequency as an integer value + * + * @return WIFI_FREQ enum value corresponding to its integer value + */ public static WIFI_FREQ fromInt(int i) { for (WIFI_FREQ b : WIFI_FREQ.values()) diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_MODE.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_MODE.java old mode 100644 new mode 100755 index 17db62c..f1d9149 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_MODE.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/WIFI_MODE.java @@ -22,12 +22,34 @@ package org.iotivity.service.easysetup.mediator.enums; +/** + * This enum class indicates a WiFi mode like 11A and 11N. + */ public enum WIFI_MODE { + /** + * 801.11A + */ WIFI_11A(0), + + /** + * 801.11B + */ WIFI_11B(1), + + /** + * 801.11G + */ WIFI_11G(2), + + /** + * 801.11N + */ WIFI_11N(3), + + /** + * 801.11AC + */ WIFI_11AC(4); private int value; @@ -37,11 +59,22 @@ public enum WIFI_MODE this.value = value; } + /** + * Get WiFi mode as an integer value + * + * @return int WiFi mode as an integer value + */ public int getValue() { return value; } + /** + * Convert integer to WIFI_MODE enum value + * + * @param i An integer value converting + * @return WIFI_MODE enum value corresponding to its integer value + */ public static WIFI_MODE fromInt(int i) { for (WIFI_MODE b : WIFI_MODE.values()) diff --git a/service/easy-setup/mediator/richsdk/android/jni/Android.mk b/service/easy-setup/mediator/richsdk/android/jni/Android.mk index b14b2c4..214052b 100644 --- a/service/easy-setup/mediator/richsdk/android/jni/Android.mk +++ b/service/easy-setup/mediator/richsdk/android/jni/Android.mk @@ -1,4 +1,5 @@ LOCAL_PATH := $(call my-dir) +SECURED := $(SECURE) include $(CLEAR_VARS) OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug @@ -12,6 +13,20 @@ LOCAL_MODULE := android-easysetup LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libESMediatorRich.so include $(PREBUILT_SHARED_LIBRARY) +ifeq ($(SECURED), 1) +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug +LOCAL_MODULE := android-ocprovision +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocprovision.so +include $(PREBUILT_SHARED_LIBRARY) +endif + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../../.././android/android_api/base/libs/armeabi +LOCAL_MODULE := android-ocstack +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocstack-jni.so +include $(PREBUILT_SHARED_LIBRARY) + include $(CLEAR_VARS) LOCAL_MODULE := easysetup-jni @@ -54,6 +69,10 @@ LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/*.h)) LOCAL_LDLIBS := -llog #LOCAL_SHARED_LIBRARIES += android-connectivity_abstraction +LOCAL_SHARED_LIBRARIES += android-ocstack +ifeq ($(SECURED), 1) +LOCAL_SHARED_LIBRARIES += android-ocprovision +endif LOCAL_SHARED_LIBRARIES += android-oc LOCAL_SHARED_LIBRARIES += android-easysetup diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.cpp b/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.cpp index 99588fd..e7dc496 100755 --- a/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.cpp +++ b/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.cpp @@ -25,6 +25,8 @@ #include "octypes.h" #include "ESRichCommon.h" +#include "JniOcPlatform.h" +#include "JniOcResource.h" #include "JniEasySetup.h" using namespace OC; @@ -35,42 +37,24 @@ extern "C" { #endif JNIEXPORT jobject JNICALL Java_org_iotivity_service_easysetup_mediator_EasySetup_nativeCreateRemoteEnrollee -(JNIEnv *env, jobject thiz , jstring jhost, jstring juri, jstring jdID, jboolean jisObservable, jint jconType) +(JNIEnv *env, jobject thiz, jobject jResource) { LOGI("JniEasySetup::nativeCreateRemoteEnrollee enter"); std::shared_ptr nativeRemoteEnrollee; - std::shared_ptr< OC::OCResource > resource; jobject jRemoteEnrollee; - std::string host; - std::string uri; - std::string devID; - host = env->GetStringUTFChars(jhost, NULL); - uri = env->GetStringUTFChars(juri, NULL); - devID = env->GetStringUTFChars(jdID, NULL); - bool isObservable = jisObservable; - OCConnectivityType conType = static_cast(jconType); - std::vector resourceTypes = {OC_RSRVD_ES_RES_TYPE_PROV}; - std::vector interfaces = {OC_RSRVD_INTERFACE_BATCH}; + JniOcResource* jniOcResource = JniOcResource::getJniOcResourcePtr(env, jResource); - LOGI("host : %s", host.c_str()); - LOGI("uri : %s", uri.c_str()); - try - { - resource = OC::OCPlatform::constructResourceObject(host, - uri, conType, isObservable, resourceTypes, interfaces); - } - catch(ResourceInitException e) + if (!jniOcResource) { - LOGI("constructResourceObject error : %s", e.what()); - return NULL; + LOGE("JniEasySetup::nativeCreateRemoteEnrollee getJniOcResourcePtr returns nullptr."); + return nullptr; } try { - nativeRemoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource); - nativeRemoteEnrollee->setDevID(devID); + nativeRemoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(jniOcResource->getOCResource()); //create the java object jRemoteEnrollee = env->NewObject(g_cls_RemoteEnrollee, g_mid_RemoteEnrollee_ctor); if (!jRemoteEnrollee) diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.h b/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.h index aa50e10..d4e6391 100755 --- a/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.h +++ b/service/easy-setup/mediator/richsdk/android/jni/JniEasySetup.h @@ -51,7 +51,7 @@ extern "C" { */ JNIEXPORT jobject JNICALL Java_org_iotivity_service_easysetup_mediator_EasySetup_nativeCreateRemoteEnrollee -(JNIEnv *env, jobject thiz, jstring host, jstring uri, jstring jdID, jboolean isObservable, jint conType); +(JNIEnv *env, jobject thiz, jobject jResource); #ifdef __cplusplus diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.cpp b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.cpp index 37c8810..d566b51 100755 --- a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.cpp +++ b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.cpp @@ -74,7 +74,7 @@ void JniRemoteEnrollee::getConfiguration(JNIEnv *env, jobject jListener) } } -void JniRemoteEnrollee::configureSecurity(JNIEnv *env, jobject jListener) +void JniRemoteEnrollee::provisionSecurity(JNIEnv *env, jobject jListener) { JniSecurityStatusListener *onSecurityProvStatusReceived = addStatusListener(env, jListener); @@ -87,11 +87,11 @@ void JniRemoteEnrollee::configureSecurity(JNIEnv *env, jobject jListener) try { - m_sharedResource->configureSecurity(secProvStatusCallback); + m_sharedResource->provisionSecurity(secProvStatusCallback); } catch (ESBadRequestException exception) { - LOGE("JNI configureSecurity :: Exception occured"); + LOGE("JNI provisionSecurity :: Exception occured"); //throw the exception to java throwESException( env, exception.what()); } @@ -175,13 +175,13 @@ Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeGetConfigurati } JNIEXPORT void JNICALL -Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeConfigureSecurity +Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeProvisionSecurity (JNIEnv *env, jobject jClass, jobject jListener) { LOGD("nativeStartSecurityProvision Enter"); JniRemoteEnrollee *remoteEnrollee = JniRemoteEnrollee::getJniRemoteEnrollee(env, jClass); - remoteEnrollee->configureSecurity(env, jListener); + remoteEnrollee->provisionSecurity(env, jListener); LOGD("nativeStartSecurityProvision Exit"); } diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h index 0ffe113..bba5d5f 100755 --- a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h +++ b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h @@ -63,7 +63,7 @@ class JniRemoteEnrollee // ***** JNI APIs internally call the APIs of this class ***** // void getConfiguration(JNIEnv *env, jobject jListener); - void configureSecurity(JNIEnv *env, jobject jListener); + void provisionSecurity(JNIEnv *env, jobject jListener); void provisionDeviceProperties(JNIEnv *env, jstring jssid, jstring jpwd, jint jauthType, jint jencType, jstring jlanguage, jstring jcountry, jobject jListener); void provisionCloudProperties(JNIEnv *env, jstring authCode, jstring authProvider, @@ -103,7 +103,7 @@ Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeGetConfigurati * API for starting the Sequrity provisioning process. */ JNIEXPORT void JNICALL -Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeConfigureSecurity +Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeProvisionSecurity (JNIEnv *env, jobject jClass, jobject jListener); /** diff --git a/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h b/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h index 4c0652e..85f5d38 100755 --- a/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h +++ b/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h @@ -87,7 +87,7 @@ namespace OIC * * @see SecurityProvStatusCb */ - void configureSecurity(SecurityProvStatusCb callback); + void provisionSecurity(SecurityProvStatusCb callback); /** * Provision WiFi AP information and device configuration to Enrollee @@ -122,12 +122,6 @@ namespace OIC */ void provisionCloudProperties(const CloudProp& cloudProp, CloudPropProvStatusCb callback); - /** - * Set device ID the target Enrollee has. Note that, if you change the device ID of enrollee, - * unexpected behavior may happen. - */ - void setDevID(const std::string devId); - private: RemoteEnrollee(std::shared_ptr< OC::OCResource > resource); diff --git a/service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp b/service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp index a6491cc..24c9705 100755 --- a/service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp +++ b/service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp @@ -47,6 +47,8 @@ namespace OIC m_secProvisioningDbPathCb = nullptr; m_devicePropProvStatusCb = nullptr; m_cloudPropProvStatusCb = nullptr; + + m_deviceId = resource->sid(); } #ifdef __WITH_DTLS__ @@ -248,7 +250,7 @@ namespace OIC return ES_OK; } - void RemoteEnrollee::configureSecurity(SecurityProvStatusCb callback) + void RemoteEnrollee::provisionSecurity(SecurityProvStatusCb callback) { #ifdef __WITH_DTLS__ m_securityProvStatusCb = callback; @@ -417,10 +419,5 @@ namespace OIC m_cloudResource->registerCloudPropProvisioningStatusCallback(cloudPropProvStatusCb); m_cloudResource->provisionEnrollee(cloudProp); } - - void RemoteEnrollee::setDevID(const std::string devId) - { - m_deviceId = devId; - } } } 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 old mode 100644 new mode 100755 index 91ac88c..0785c3a --- 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 @@ -305,11 +305,14 @@ public class EasysetupActivity extends Activity { //SQLiteDatabase.openOrCreateDatabase(sqlDbPath+ OIC_SQL_DB_FILE, null); OcProvisioning.provisionInit(sqlDbPath + OIC_SQL_DB_FILE); + mSecurityMode.setChecked(true); } catch (OcException e) { logMessage(TAG + "provisionInit error: " + e.getMessage()); Log.e(TAG, e.getMessage()); Toast.makeText(this,"provisionInit error: " + e.getMessage(), Toast.LENGTH_LONG).show(); + mSecurityMode.setChecked(false); + return; } catch (UnsatisfiedLinkError e) { // Note : Easy setup is built with SECURED = 0, but user still selects Security feature @@ -321,7 +324,6 @@ public class EasysetupActivity extends Activity { Toast.LENGTH_LONG).show(); return; } - mSecurityMode.setChecked(false); } OcPlatform.OnResourceFoundListener listener = @@ -430,7 +432,7 @@ public class EasysetupActivity extends Activity { }); try { - mRemoteEnrollee.configureSecurity(new SecurityProvisioningCallback() { + mRemoteEnrollee.provisionSecurity(new SecurityProvisioningCallback() { @Override public void onProgress(final SecurityProvisioningStatus securityProvisioningStatus) { if(securityProvisioningStatus.getESResult() == ESResult.ES_OK) { @@ -501,7 +503,7 @@ public class EasysetupActivity extends Activity { mDevNameText.setText(devConf.getName()); mLanguageText.setText(devConf.getLanguage()); mCountryText.setText(devConf.getCountry()); - setWifiModeTypes(netInfo.getWifiModeTypes()); + setWifiModes(netInfo.getWifiModes()); setWifiFreq(netInfo.getWifiFreq()); if(enrolleeConf.isCloudable()) { @@ -734,7 +736,7 @@ public class EasysetupActivity extends Activity { } - public void setWifiModeTypes(ArrayList types) { + public void setWifiModes(ArrayList types) { String temp = "WIFI - "; for(WIFI_MODE type : types) { -- 2.7.4