Remove ESCloudProvState in Jni and Android
authorJihun Ha <jihun.ha@samsung.com>
Sat, 20 Aug 2016 05:32:01 +0000 (14:32 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 22 Aug 2016 09:05:07 +0000 (09:05 +0000)
Followed by https://gerrit.iotivity.org/gerrit/#/c/10685/,
this change is applied to jni and Android.

Change-Id: I0f716706f65ef4f455a61ccbd9f79ae4854458ed
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10687
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Heewon Park <h_w.park@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudPropProvisioningStatus.java [changed mode: 0644->0755]
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/ESResult.java [changed mode: 0644->0755]
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniCloudPropProvisioningStatusListener.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniDevicePropProvisioningStatusListener.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniEsUtils.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniEsUtils.h
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniJvm.cpp
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java

old mode 100644 (file)
new mode 100755 (executable)
index bd557e4..1b0c7db
@@ -30,7 +30,6 @@ import org.iotivity.service.easysetup.mediator.enums.ESResult;
 public class CloudPropProvisioningStatus
 {
     private ESResult m_result;
-    private ESCloudProvState m_esCloudState;
 
     /**
      * Constructor
@@ -42,10 +41,9 @@ public class CloudPropProvisioningStatus
      *
      * @see ESCloudProvState
      */
-    public CloudPropProvisioningStatus(int result, int state)
+    public CloudPropProvisioningStatus(int result)
     {
         m_result = ESResult.fromInt(result);
-        m_esCloudState = ESCloudProvState.fromInt(state);
     }
 
     /**
@@ -57,16 +55,4 @@ public class CloudPropProvisioningStatus
     {
         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;
-    }
 };
old mode 100644 (file)
new mode 100755 (executable)
index adf8f42..0db25af
@@ -24,17 +24,14 @@ package org.iotivity.service.easysetup.mediator.enums;
  * It defines an result during easy setup process, which is same as one in Easy Setup C++ SDK
  */
 public enum ESResult {
-    ES_ERROR(-1),
+
     ES_OK(0),
-    ES_NETWORKFOUND(1),
-    ES_NETWORKCONNECTED(2),
-    ES_NETWORKNOTCONNECTED(3),
-    ES_RESOURCECREATED(11),
-    ES_RECVREQOFPROVRES(21),
-    ES_RECVREQOFNETRES(22),
-    ES_RECVUPDATEOFPROVRES(23),
-    ES_RECVTRIGGEROFPROVRES(24),
-    ES_UNAUTHORIZED(25);
+    ES_FOUND_ENROLLEE(1),
+    ES_NOT_FOUND_ENROLLEE(11),
+    ES_SEC_OPERATION_IS_NOT_SUPPORTED(20),
+    ES_UNAUTHORIZED_REQ(21),
+    ES_SEC_PROVISION_FAILS(22),
+    ES_ERROR(255);
 
     private int value;
 
index 7708c1f..d68a48a 100755 (executable)
@@ -79,16 +79,14 @@ void JniCloudPropProvisioningStatusListener::onCloudPropProvisioningStatus(std::
     }
 
     ESResult esResult = cloudPropProvisioningStatus->getESResult();
-    ESCloudProvState cloudProvisionState = cloudPropProvisioningStatus->getESCloudState();
 
     //create the java object
     jobject jCloudPropProvisioningStatus = NULL;
     jCloudPropProvisioningStatus = env->NewObject(g_cls_CloudPropProvisioningStatus,
                                                 g_mid_CloudPropProvisioningStatus_ctor,
-                                                (jint)esResult,
-                                                (jint)cloudProvisionState);
+                                                (jint)esResult);
 
-    ES_LOGI("JniCloudPropProvisioningStatus::onCloudPropProvisioningStatus - %d, %d", esResult, cloudProvisionState);
+    ES_LOGI("JniCloudPropProvisioningStatus::onCloudPropProvisioningStatus - %d", esResult);
     if (!jCloudPropProvisioningStatus)
     {
         ES_LOGE("JniCloudPropProvisioningStatus::onCloudPropProvisioningStatus Unable to create the java object");
@@ -99,8 +97,7 @@ void JniCloudPropProvisioningStatusListener::onCloudPropProvisioningStatus(std::
 
     bool needRemoveListener = false;
 
-    if(cloudProvisionState == ES_CLOUD_PROVISIONING_ERROR ||
-            cloudProvisionState == ES_CLOUD_PROVISIONING_SUCCESS )
+    if(esResult == ES_OK)
     {
         needRemoveListener = true;
     }
index c65ce7c..6456a5b 100755 (executable)
@@ -80,14 +80,14 @@ void JniDevicePropProvisioningStatusListener::onDevicePropProvisioningStatusCall
         return;
     }
 
-    int nativeESResult = convertNativeDeviceProvResultToInt(devicePropProvStatusCb->getESResult());
+    ESResult esResult = devicePropProvStatusCb->getESResult();
 
     jobject jDevicePropProvisioningStatus = NULL;
     jDevicePropProvisioningStatus = env->NewObject(g_cls_DevicePropProvisioningStatus,
                                                 g_mid_DevicePropProvisioningStatus_ctor,
-                                                (jint)nativeESResult);
+                                                (jint)esResult);
 
-    ES_LOGI("JniDevicePropProvisioningStatus::onDevicePropProvisioningStatus - %d", nativeESResult);
+    ES_LOGI("JniDevicePropProvisioningStatus::onDevicePropProvisioningStatus - %d", esResult);
     if (!jDevicePropProvisioningStatus)
     {
         ES_LOGE("JniDevicePropProvisioningStatus::onDevicePropProvisioningStatus Unable to create the java object");
index 4ab4da1..106c18e 100755 (executable)
@@ -109,33 +109,4 @@ int convertNativeWifiModeToInt(WIFI_MODE wifiMode)
         case WIFI_MODE::WIFI_11AC:
             return 4;
     }
-}
-
-int convertNativeDeviceProvResultToInt(ESResult nativeResult)
-{
-    switch (nativeResult)
-    {
-        case ESResult::ES_ERROR:
-            return -1;
-        case ESResult::ES_OK:
-            return 0;
-        case ESResult::ES_NETWORKFOUND:
-            return 1;
-        case ESResult::ES_NETWORKCONNECTED:
-            return 2;
-        case ESResult::ES_NETWORKNOTCONNECTED:
-            return 3;
-        case ESResult::ES_RESOURCECREATED:
-            return 11;
-        case ESResult::ES_RECVREQOFPROVRES:
-            return 21;
-        case ESResult::ES_RECVREQOFNETRES:
-            return 22;
-        case ESResult::ES_RECVUPDATEOFPROVRES:
-            return 23;
-        case ESResult::ES_RECVTRIGGEROFPROVRES:
-            return 24;
-        case ESResult::ES_UNAUTHORIZED:
-            return 31;
-    }
 }
\ No newline at end of file
index e966fbd..2ff5076 100755 (executable)
@@ -51,5 +51,4 @@ WIFI_AUTHTYPE getWifiAuthTypeFromInt(int authType);
 WIFI_ENCTYPE getWifiEncTypeFromInt(int encType);
 int convertNativeWifiFreqToInt(WIFI_FREQ wifiFreq);
 int convertNativeWifiModeToInt(WIFI_MODE wifiMode);
-int convertNativeDeviceProvResultToInt(ESResult nativeResult);
 #endif //__JNI_ES_UTILS_H_
index a686730..256c788 100755 (executable)
@@ -152,7 +152,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
     env->DeleteLocalRef(clazz);
 
     g_mid_CloudPropProvisioningStatus_ctor = env->GetMethodID(g_cls_CloudPropProvisioningStatus, "<init>",
-                                "(II)V");
+                                "(I)V");
     if (!g_mid_CloudPropProvisioningStatus_ctor) return JNI_ERR;
 
     // Integer
index 253d166..5105710 100755 (executable)
@@ -633,7 +633,7 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
                                             else if(result.equals(ESResult.ES_ERROR)) {
                                                 mProvisionDevPropState.setText("Failed");
                                             }
-                                            else if(result.equals(ESResult.ES_UNAUTHORIZED)) {
+                                            else if(result.equals(ESResult.ES_UNAUTHORIZED_REQ)) {
                                                 mProvisionDevPropState.setText("Failed. Need SecProv");
                                             }
                                             mStartProvisionDevProp.setEnabled(true);
@@ -687,26 +687,20 @@ public class EasysetupActivity extends Activity implements OcPlatform.OnPresence
                                 @Override
                                 public void onProgress(CloudPropProvisioningStatus cloudProvisioningStatus) {
                                     final ESResult result = cloudProvisioningStatus.getESResult();
-                                    final ESCloudProvState state = cloudProvisioningStatus.getESCloudState();
                                     runOnUiThread(new Runnable() {
                                         @Override
                                         public void run() {
-                                            if(result.equals(ESResult.ES_OK)) {
-                                                if(state.equals(ESCloudProvState.ES_CLOUD_ENROLLEE_FOUND)) {
-                                                    mProvisionCloudPropState.setText("Found Resource");
-                                                }
-                                                else if(state.equals(ESCloudProvState.ES_CLOUD_PROVISIONING_SUCCESS)) {
-                                                    mProvisionCloudPropState.setText("Success");
-                                                }
+                                            if(result.equals(ESResult.ES_FOUND_ENROLLEE)) {
+                                                mProvisionCloudPropState.setText("Found Resource");
+                                            }
+                                            else if(result.equals(ESResult.ES_NOT_FOUND_ENROLLEE)) {
+                                                mProvisionCloudPropState.setText("Not Found Resource");
+                                            }
+                                            else if(result.equals(ESResult.ES_OK)) {
+                                                mProvisionCloudPropState.setText("Cloud Provisioning succeeds");
                                             }
                                             else {
-                                                if(state.equals(ESCloudProvState.ES_CLOUD_ENROLLEE_NOT_FOUND)) {
-                                                    mProvisionCloudPropState.setText("Not Found Resource");
-                                                }
-                                                else if(state.equals(ESCloudProvState.ES_CLOUD_PROVISIONING_ERROR)) {
-                                                    mProvisionCloudPropState.setText("Failed");
-                                                }
-                                                mStartProvisionCloudProp.setEnabled(true);
+                                                mProvisionCloudPropState.setText("Cloud Provisioning fails");
                                             }
                                         }
                                     });