[SSM] Add android sample and fix jni issues.
authorjk13 <jihyeok13.kim@samsung.com>
Fri, 30 Jan 2015 07:53:11 +0000 (16:53 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 2 Feb 2015 05:00:42 +0000 (05:00 +0000)
1. Add android sample application
2. Fix jni issues that mismatch of package name
   and Android-L jni callback issue
3. Fix scons script to build for creating SSM so file.

Change-Id: Ief192a96f6d97fd2ac4ad47b3e7d9029d964f2f6
Signed-off-by: jk13 <jihyeok13.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/278
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
25 files changed:
service/soft-sensor-manager/SConscript
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/CoreController.java
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/IQueryEngineEvent.java
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/IReportReceiver.java
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/SSMInterface.java
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.h
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/AndroidManifest.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Android.mk [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Application.mk [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_action_search.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_action_search.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_launcher.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_action_search.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_launcher.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_action_search.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/layout/activity_main.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/menu/activity_main.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v11/styles.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v14/styles.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/strings.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/styles.xml [new file with mode: 0644]
service/soft-sensor-manager/SampleApp/android/SSMTesterApp/src/org/iotivity/service/ssm/sample/MainActivity.java [new file with mode: 0644]

index 8dceeeb..0044431 100644 (file)
@@ -22,14 +22,11 @@ if target_os == 'arduino':
 if target_os not in ['windows', 'winrt']:
        soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-DLINUX'])
        if target_os != 'android':
-               soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-pthread'])
+               soft_sensor_manager_env.AppendUnique(LIBS = ['pthread'])
 
 if target_os == 'android':
        soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       soft_sensor_manager_env.AppendUnique(LIBS = ['gnustl_static', 'compatibility'])
-
-       if not env.get('RELEASE'):
-               soft_sensor_manager_env.AppendUnique(LIBS = ['log'])
+       soft_sensor_manager_env.AppendUnique(LIBS = ['gnustl_static', 'compatibility', 'log'])
 
 #######################################################################
 ## build SSM SDK
@@ -102,12 +99,21 @@ ssm_core_c_src = [
                'SSMCore/src/Common/sqlite3.c'
 ]
 
-libssmcore = ssmcore_env.StaticLibrary(
+
+static_libssmcore = ssmcore_env.StaticLibrary(
+               target = 'SSMCore',
+               source = [ssm_core_cpp_src, ssm_core_c_src]
+               )
+
+ssmcore_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+ssmcore_env.AppendUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger'])
+
+shared_libssmcore = ssmcore_env.SharedLibrary(
                target = 'SSMCore',
                source = [ssm_core_cpp_src, ssm_core_c_src]
                )
 
-ssmcore_env.InstallTarget(libssmcore, 'libSSMCORE')
+ssmcore_env.InstallTarget([shared_libssmcore, static_libssmcore], 'libSSMCORE')
 
 #######################################################################
 ## build SampleApp
index 38ff87c..d0c2e55 100644 (file)
@@ -2,8 +2,6 @@ package org.iotivity.service.ssm;
 
 import java.util.List;
 
-import android.util.Log;
-
 public class CoreController 
 {
        static
@@ -12,22 +10,21 @@ public class CoreController
                {
                        String workingPath = System.getProperty( "user.dir" );
                        
-                       Log.i("SSMTester", "loading ssm lib");
-                       
                        // for android: not complete method
                        if(System.getProperty("os.name").toLowerCase().equals("linux"))
                        {
                                //System.out.println("System load Android library");
-                               System.loadLibrary("SSMCore_Android");
+                           System.loadLibrary("oc_logger");
+                           System.loadLibrary("coap");
+                           System.loadLibrary("octbstack");
+                           System.loadLibrary("oc");
+                           System.loadLibrary("SSMCore");
                        }
                        else
                        {
-                               //System.out.println("System load 32bit library");
-                               workingPath += "/../Outputs/";
+                               //System.out.println("System load 32bit library");                              
                                System.load( workingPath + "SSMCore_Windows.dll");
                        }
-                       
-                       Log.i("SSMTester", "loading done");
                }
                catch(UnsatisfiedLinkError e)
                {
index 3dd46bf..1f3c601 100644 (file)
@@ -1,5 +1,5 @@
 package org.iotivity.service.ssm;
 
-public interface IQueryEngineEvent {
-       public void OnQueryEngineEvent(int cqid, DataReader result);
+public abstract class IQueryEngineEvent {
+       public abstract void OnQueryEngineEvent(int cqid, DataReader result);
 }
\ No newline at end of file
index 9a8aec1..e14adf7 100644 (file)
@@ -1,5 +1,5 @@
 package org.iotivity.service.ssm;
 
-public interface IReportReceiver {
-       public void OnMessageReceived(String tag, String msg);
+public abstract class IReportReceiver {
+       public abstract void OnMessageReceived(String tag, String msg);
 }
index 8169548..914f8c2 100644 (file)
@@ -8,7 +8,7 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 public class SSMInterface {
-       private class QueryEngineEventReceiver implements IQueryEngineEvent
+       private class QueryEngineEventReceiver extends IQueryEngineEvent
        {
         private Lock                                                           mMtxListener = new ReentrantLock();
                private Map<Integer, IQueryEngineEvent>         mMapListener = new HashMap<Integer, IQueryEngineEvent>();
index 9dbb031..5c65d65 100644 (file)
@@ -56,10 +56,8 @@ void ReportMessage(const char *tag, const char *msg)
         env->GetMethodID(g_ClassReportReceiver, "OnMessageReceived",
                          "(Ljava/lang/String;Ljava/lang/String;)V");
 
-    jclass nonVIrtualObject = env->GetObjectClass(g_objReportReceiver);
-
-    env->CallNonvirtualVoidMethod(g_objReportReceiver, nonVIrtualObject, midReportReceiver,
-                                  env->NewStringUTF(tag), env->NewStringUTF(msg));
+    env->CallVoidMethod(g_objReportReceiver, midReportReceiver,
+                        env->NewStringUTF(tag), env->NewStringUTF(msg));
 
     DETACH_CURRENT_THREAD(g_JVM);
 
@@ -109,18 +107,18 @@ class QueryEngineEventReceiver
 
             jmethodID midQueryEngineEvent =
                 env->GetMethodID(g_ClassQueryEngineEvent, "OnQueryEngineEvent",
-                                 "(ILcom/sec/android/ssmcore/DataReader;)V");
+                                 "(ILorg/iotivity/service/ssm/DataReader;)V");
 
-            jclass nonVIrtualObject = env->GetObjectClass(m_objQueryEngineEvent);
+            jclass callbackObject = env->GetObjectClass(m_objQueryEngineEvent);
 
             jmethodID cid_DataReader = env->GetMethodID(g_ClassDataReader, "<init>", "(I)V");
 
             if (cid_DataReader == NULL)
                 return SSM_E_FAIL;
 
-            env->CallNonvirtualVoidMethod(m_objQueryEngineEvent, nonVIrtualObject, midQueryEngineEvent,
-                                          (jint)cqid,
-                                          env->NewObject(g_ClassDataReader, cid_DataReader, (jint)pResult));
+            env->CallVoidMethod(m_objQueryEngineEvent, midQueryEngineEvent,
+                                (jint)cqid,
+                                env->NewObject(g_ClassDataReader, cid_DataReader, (jint)pResult));
 
             DETACH_CURRENT_THREAD(g_JVM);
 
@@ -137,19 +135,19 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
         return JNI_ERR;
 
     g_ClassQueryEngine = (jclass) env->NewGlobalRef(
-                             env->FindClass("com/sec/android/ssmcore/QueryEngine"));
+                             env->FindClass("org/iotivity/service/ssm/QueryEngine"));
 
     g_ClassDataReader = (jclass) env->NewGlobalRef(
-                            env->FindClass("com/sec/android/ssmcore/DataReader"));
+                            env->FindClass("org/iotivity/service/ssm/DataReader"));
 
-    g_ClassModelData = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/ModelData"));
+    g_ClassModelData = (jclass) env->NewGlobalRef(env->FindClass("org/iotivity/service/ssm/ModelData"));
 
     g_ClassQueryEngineEvent = (jclass) env->NewGlobalRef(
-                                  env->FindClass("com/sec/android/ssmcore/IQueryEngineEvent"));
+                                  env->FindClass("org/iotivity/service/ssm/IQueryEngineEvent"));
 
 
     g_ClassReportReceiver = (jclass) env->NewGlobalRef(
-                                env->FindClass("com/sec/android/ssmcore/IReportReceiver"));
+                                env->FindClass("org/iotivity/service/ssm/IReportReceiver"));
 
 
     g_JVM = jvm;
@@ -191,7 +189,7 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *jvm, void *reserved)
         delete g_QueryEngineEventReceiver;
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_InitializeSSMCore
 (JNIEnv *env, jclass clz, jstring jstrXmlDescription)
 {
     SSMRESULT res = SSM_E_FAIL;
@@ -205,28 +203,28 @@ JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSM
         env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "InitializeSSMCore failed");
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StartSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_StartSSMCore
 (JNIEnv *env, jclass clz)
 {
     if (StartSSMCore() != SSM_S_OK)
         env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StartSSMCore failed");
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StopSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_StopSSMCore
 (JNIEnv *env, jclass clz)
 {
     if (StopSSMCore() != SSM_S_OK)
         env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StopSSMCore failed");
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_TerminateSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_TerminateSSMCore
 (JNIEnv *env, jclass clz)
 {
     if (TerminateSSMCore() != SSM_S_OK)
         env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "TerminateSSMCore failed");
 }
 
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQueryEngine
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_CreateQueryEngine
 (JNIEnv *env, jclass clz)
 {
     IQueryEngine        *pQueryEngine = NULL;
@@ -245,7 +243,7 @@ JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQuer
     return env->NewObject(g_ClassQueryEngine, cid_QueryEngine, (jint)pQueryEngine);
 }
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryEngine
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_ReleaseQueryEngine
 (JNIEnv *env, jclass clz, jobject queryEngine)
 {
     IQueryEngine        *pQueryEngine = NULL;
@@ -261,7 +259,7 @@ JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryE
     return ReleaseQueryEngine(pQueryEngine);
 }
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContextQuery
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_ExecuteContextQuery
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery)
 {
     int                 cqid = 0;
@@ -278,7 +276,7 @@ JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContex
     return cqid;
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQueryEvent
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_RegisterQueryEvent
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent)
 {
     IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
@@ -293,7 +291,7 @@ JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQuery
     pQueryEngine->registerQueryEvent(g_QueryEngineEventReceiver);
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQuery
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_KillContextQuery
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid)
 {
     IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
@@ -304,7 +302,7 @@ JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQu
     }
 }
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetDataId
 (JNIEnv *env, jclass clz, jint pDataReaderInstance)
 {
     IModelData *pDataReader = (IModelData *)pDataReaderInstance;
@@ -312,7 +310,7 @@ JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
     return pDataReader->getDataId();
 }
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCount
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyCount
 (JNIEnv *env, jclass clz, jint pIModelDataInstance )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
@@ -320,7 +318,7 @@ JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCo
     return pModelData->getPropertyCount();
 }
 
-JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyName
+JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyName
 (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
@@ -328,7 +326,7 @@ JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropert
     return env->NewStringUTF(pModelData->getPropertyName(propertyIndex).c_str());
 }
 
-JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyValue
+JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyValue
 (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
@@ -336,7 +334,7 @@ JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropert
     return env->NewStringUTF(pModelData->getPropertyValue(propertyIndex).c_str());
 }
 
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffectedModels
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_GetAffectedModels
 (JNIEnv *env, jclass clz, jint pDataReaderInstance)
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
@@ -361,7 +359,7 @@ JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffecte
     return objAffectedModels;
 }
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataCount
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetModelDataCount
 (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName)
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
@@ -378,7 +376,7 @@ JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataC
     return modelCount;
 }
 //return IModelData
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelData
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_GetModelData
 (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex )
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
@@ -399,7 +397,7 @@ JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDa
     return env->NewObject(g_ClassModelData, cid_ModelData, (jint)pModelData);
 }
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterReportReceiver
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_RegisterReportReceiver
 (JNIEnv *env, jclass clz, jobject reportReceiver)
 {
     if (g_objReportReceiver != NULL)
index 4f50e2b..38f51c3 100644 (file)
 extern "C" {
 #endif
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_InitializeSSMCore
 (JNIEnv *env, jclass clz, jstring jstrXmlDescription);
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StartSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_StartSSMCore
 (JNIEnv *env, jclass clz);
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StopSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_StopSSMCore
 (JNIEnv *env, jclass clz);
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_TerminateSSMCore
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_TerminateSSMCore
 (JNIEnv *env, jclass clz);
 
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQueryEngine
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_CreateQueryEngine
 (JNIEnv *env, jclass clz);
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryEngine
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_ReleaseQueryEngine
 (JNIEnv *env, jclass clz, jobject queryEngine);
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContextQuery
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_ExecuteContextQuery
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery);
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQueryEvent
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_RegisterQueryEvent
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent);
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQuery
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_KillContextQuery
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid);
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_Release
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_Release
 (JNIEnv *env, jclass clz, jint pQueryEngineInstance);
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetDataId
 (JNIEnv *env, jclass clz, jint pDataReaderInstance);
 
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffectedModels
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_GetAffectedModels
 (JNIEnv *env, jclass clz, jint pDataReaderInstance);
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataCount
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetModelDataCount
 (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName);
 
-JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelData
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_GetModelData
 (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex );
 
-JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCount
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyCount
 (JNIEnv *env, jclass clz, jint pIModelDataInstance );
 
-JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyName
+JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyName
 (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
 
-JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyValue
+JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_GetPropertyValue
 (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
 
-JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterReportReceiver
+JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_RegisterReportReceiver
 (JNIEnv *env, jclass clz, jobject reportReceiver );
 
 #ifdef __cplusplus
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/AndroidManifest.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..56e20ee
--- /dev/null
@@ -0,0 +1,45 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.service.ssm"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
+    
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
+       <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
+       <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+       <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+       <uses-permission android:name="android.permission.CALL_PHONE" />  
+       <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
+       <uses-permission android:name="android.permission.READ_CONTACTS"/> 
+       <uses-permission android:name="android.permission.INTERNET"/>
+       <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+       <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 
+       <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
+       <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
+       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>    
+       <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+       <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
+       <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
+       <uses-permission android:name="android.permission.READ_CALENDAR" />
+    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
+
+    <application android:label="@string/app_name"
+        android:icon="@drawable/ic_launcher"
+        android:theme="@style/AppTheme"
+        android:allowBackup="true" 
+        android:debuggable="true">
+       
+               <activity
+            android:name="org.iotivity.service.ssm.sample.MainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>            
+    </application>
+
+</manifest>
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Android.mk b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Android.mk
new file mode 100644 (file)
index 0000000..3910a38
--- /dev/null
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := coap
+LOCAL_SRC_FILES := ../libs/libcoap.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := oc_logger
+LOCAL_SRC_FILES := ../libs/liboc_logger.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := octbstack
+LOCAL_SRC_FILES := ../libs/liboctbstack.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := oc
+LOCAL_SRC_FILES := ../libs/liboc.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := SSMCore
+LOCAL_SRC_FILES := ../libs/libSSMCore.so
+include $(PREBUILT_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Application.mk b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/jni/Application.mk
new file mode 100644 (file)
index 0000000..6fd7a1c
--- /dev/null
@@ -0,0 +1,2 @@
+APP_STL:=gnustl_static
+NDK_TOOLCHAIN_VERSION := 4.9
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_action_search.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_action_search.png
new file mode 100644 (file)
index 0000000..67de12d
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_action_search.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_launcher.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..a301d57
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-hdpi/ic_launcher.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_action_search.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_action_search.png
new file mode 100644 (file)
index 0000000..67de12d
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_action_search.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_launcher.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..2c2a58b
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-ldpi/ic_launcher.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_action_search.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_action_search.png
new file mode 100644 (file)
index 0000000..67de12d
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_action_search.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_launcher.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..f91f736
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-mdpi/ic_launcher.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_action_search.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_action_search.png
new file mode 100644 (file)
index 0000000..67de12d
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_action_search.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_launcher.png b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..96095ec
Binary files /dev/null and b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/layout/activity_main.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/layout/activity_main.xml
new file mode 100644 (file)
index 0000000..fa54a1b
--- /dev/null
@@ -0,0 +1,184 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:paddingBottom="5dp"
+    android:paddingLeft="10dp"
+    android:paddingRight="10dp"
+    android:paddingTop="10dp" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+
+        <EditText
+            android:id="@+id/editQuery"
+            android:layout_width="wrap_content"
+            android:layout_height="110dp"
+            android:layout_weight="0.92"
+            android:ems="9"
+            android:inputType="textMultiLine"
+            android:text=""
+            android:textSize="15sp" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_weight="0.92"
+            android:orientation="vertical" >
+
+            <Button
+                android:id="@+id/btnRegisterQuery"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="Register"
+                android:textSize="18sp" />
+
+            <Button
+                android:id="@+id/btClear"
+                style="?android:attr/buttonStyleSmall"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="CLEAR"
+                android:textSize="18sp" />
+                    
+        </LinearLayout>
+
+    </LinearLayout>
+
+       <LinearLayout
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
+               android:orientation="vertical"
+               android:paddingTop="10dp" >
+
+               <TextView
+                   android:id="@+id/textView"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="Example Queries"
+                   android:textSize="15sp"
+                   android:textStyle="bold" />
+          
+               <LinearLayout
+                       android:layout_width="match_parent"
+                       android:layout_height="wrap_content" >
+
+               <Button
+                   android:id="@+id/btFullDevice"
+                   style="?android:attr/buttonStyleSmall"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="Search Devices"
+                   android:textSize="17sp" />
+       
+                <Button
+                    android:id="@+id/btDiscomfortIndex"
+                    style="?android:attr/buttonStyleSmall"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="DiscomfortIndex"
+                    android:textSize="17sp" />
+
+               </LinearLayout>
+               
+       </LinearLayout>
+
+       <LinearLayout
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
+               android:orientation="vertical"
+               android:paddingTop="10dp" >
+
+               <TextView
+                   android:id="@+id/textView2"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="Unregister Query"
+                   android:textSize="15sp"
+                   android:textStyle="bold" />
+               
+               <LinearLayout
+                   android:layout_width="match_parent"
+                   android:layout_height="wrap_content" >
+               
+                   <Button
+                       android:id="@+id/btMinus"
+                       style="?android:attr/buttonStyleSmall"
+                       android:layout_width="wrap_content"
+                       android:layout_height="wrap_content"
+                       android:text=" - "
+                       android:textSize="18sp" />
+               
+                   <EditText
+                       android:id="@+id/editUnregisterQuery"
+                       android:layout_width="90dp"
+                       android:layout_height="wrap_content"
+                       android:text="0"
+                       android:textSize="18sp" />
+                               
+                   <Button
+                       android:id="@+id/btPlus"
+                       style="?android:attr/buttonStyleSmall"
+                       android:layout_width="wrap_content"
+                       android:layout_height="wrap_content"
+                       android:text=" + "
+                       android:textSize="18sp" />
+               
+                   <Button
+                       android:id="@+id/btnUnregisterQuery"
+                       android:layout_width="wrap_content"
+                       android:layout_height="wrap_content"
+                       android:text="UnRegister"
+                       android:textSize="18sp" />
+               
+               </LinearLayout>
+
+       </LinearLayout>
+
+       <Space
+               android:layout_width="match_parent"
+               android:layout_height="10dp" />
+
+       <LinearLayout
+           android:layout_width="match_parent"
+           android:layout_height="5dp"
+           android:orientation="vertical"
+           android:background="#111111" >
+       </LinearLayout>
+
+       <Space
+           android:layout_width="match_parent"
+           android:layout_height="5dp" />
+      
+       <LinearLayout
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:orientation="vertical"
+           android:paddingTop="0dp" >
+
+               <Button
+                   android:id="@+id/btLogClear"
+                   android:layout_width="match_parent"
+                   android:layout_height="wrap_content"
+                   android:text="CLEAR LOG"
+                   android:textSize="18sp" />
+
+               <ScrollView
+                   android:id="@+id/sclLog"
+                   android:layout_width="match_parent"
+                   android:layout_height="match_parent" >
+                       
+                       <TextView
+                           android:id="@+id/txtLog"
+                           android:layout_width="match_parent"
+                           android:layout_height="match_parent"
+                           android:layout_alignParentBottom="true"
+                           android:layout_alignParentLeft="true"
+                           android:textSize="15sp" />
+          
+               </ScrollView>
+       
+       </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/menu/activity_main.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/menu/activity_main.xml
new file mode 100644 (file)
index 0000000..cfc10fd
--- /dev/null
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/menu_settings"
+        android:title="@string/menu_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never" />
+</menu>
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v11/styles.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v11/styles.xml
new file mode 100644 (file)
index 0000000..d408cbc
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>
+
+    <style name="AppTheme" parent="android:Theme.Holo.Light" />
+
+</resources>
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v14/styles.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values-v14/styles.xml
new file mode 100644 (file)
index 0000000..1c089a7
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>
+
+    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
+
+</resources>
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/strings.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/strings.xml
new file mode 100644 (file)
index 0000000..b96a3ca
--- /dev/null
@@ -0,0 +1,7 @@
+<resources>
+
+    <string name="app_name">SSM Sample App</string>    
+    <string name="menu_settings">Settings</string>
+    <string name="title_activity_main">MainActivity</string>
+
+</resources>
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/styles.xml b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/res/values/styles.xml
new file mode 100644 (file)
index 0000000..4dba0d0
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>
+
+    <style name="AppTheme" parent="android:Theme.Light" />
+
+</resources>
\ No newline at end of file
diff --git a/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/src/org/iotivity/service/ssm/sample/MainActivity.java b/service/soft-sensor-manager/SampleApp/android/SSMTesterApp/src/org/iotivity/service/ssm/sample/MainActivity.java
new file mode 100644 (file)
index 0000000..dbb3c10
--- /dev/null
@@ -0,0 +1,283 @@
+package org.iotivity.service.ssm.sample;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import org.iotivity.service.ssm.*;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.content.res.AssetManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+//import android.view.Menu;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+public class MainActivity extends Activity {
+       
+       private SSMInterface SoftSensorManager = null;
+       private List<Integer>   mRunningQueries = new ArrayList<Integer>();
+               
+       private IQueryEngineEvent mQueryEngineEventListener = new IQueryEngineEvent()
+       {
+               @Override
+               public void OnQueryEngineEvent(int cqid, DataReader result)
+               {
+                       Log.i("[SSM]", "event received! cqid=" + cqid);
+                       PrintLog("Event from cqid " + cqid + " has received");
+                                               
+                       List<String> models = result.GetAffectedModels();
+                       
+                       for(String modelName : models)
+                       {
+                               PrintLog("Model: " + modelName);
+                               int dataCount = result.GetModelDataCount(modelName);
+                               for(int i=0; i < dataCount; i++)
+                               {
+                                       ModelData modelData = 
+                                                       result.GetModelData(modelName, i);
+                                       for(int j=0; j < modelData.GetPropertyCount(); j++)
+                                       {
+                                               PrintLog("Name: " + modelData.GetPropertyName(j) + 
+                                                               " Value: " + modelData.GetPropertyValue(j));
+                                       }
+                               }
+                       }
+               }
+       };
+       
+       void PrintLog(String log)
+       {
+               Message msg = new Message();
+               Bundle data = new Bundle();
+               data.putString("Log", log);
+               msg.setData(data);
+               logHandler.sendMessage(msg);
+       }
+       
+       private Handler logHandler = new Handler()
+       {
+               @Override
+               public void handleMessage(Message msg)
+               {
+                       tvLog.append(msg.getData().getString("Log") + "\n");
+                       svLog.fullScroll(ScrollView.FOCUS_DOWN);
+               }
+       };
+       
+       private TextView        tvLog = null;
+       private ScrollView      svLog = null;
+       private EditText        edtQuery = null;
+       private EditText        edtUnregisterQuery = null;
+    
+    View.OnClickListener clickHandler = new View.OnClickListener() {
+               
+               public void onClick(View v)
+               {
+                       switch(v.getId())
+                       {
+                       case R.id.btnRegisterQuery:
+                               int cqid = SoftSensorManager.registerQuery(edtQuery.getText().toString(), mQueryEngineEventListener);
+                               mRunningQueries.add(cqid);
+                               PrintLog(edtQuery.getText().toString() + " has executed, cqid=" + cqid);
+                               break;
+                               
+                       case R.id.btnUnregisterQuery:
+                               Iterator<Integer> it = mRunningQueries.iterator();
+                               while(it.hasNext())
+                               {
+                                       if(it.next() == Integer.parseInt(edtUnregisterQuery.getText().toString()))
+                                       {
+                                               SoftSensorManager.unregisterQuery(Integer.parseInt(edtUnregisterQuery.getText().toString()));
+                                               PrintLog("Unregister Query has executed, cqid=" + Integer.parseInt(edtUnregisterQuery.getText().toString()));
+                                               it.remove();
+                                       }
+                               }
+                               break;
+                               
+                       case R.id.btPlus:
+                               int queryNum = Integer.parseInt(edtUnregisterQuery.getText().toString()) + 1;
+                               edtUnregisterQuery.setText(queryNum + "");
+                               break;
+                               
+                       case R.id.btMinus:
+                               queryNum = Integer.parseInt(edtUnregisterQuery.getText().toString()) - 1;
+                               edtUnregisterQuery.setText(queryNum + "");
+                               break;
+                       }
+               }
+       };
+       
+        View.OnClickListener textAddHandler = new View.OnClickListener() {
+                       
+                       public void onClick(View v)
+                       {
+                               switch(v.getId())
+                               {
+                               case R.id.btClear :
+                                       edtQuery.setText("");
+                                       break;
+                               
+                               case R.id.btLogClear :
+                                       tvLog.setText("");
+                                       break;
+                               
+                               case R.id.btFullDevice:
+                                       edtQuery.setText("subscribe Device if Device.dataId != 0");
+                                       break;
+                               
+                               case R.id.btDiscomfortIndex:
+                                       edtQuery.setText("subscribe Device.DiscomfortIndexSensor if Device.DiscomfortIndexSensor.discomfortIndex > 0");
+                                       break;
+                               }
+                       }
+               };
+               
+    @Override
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        
+        tvLog = (TextView)findViewById(R.id.txtLog);
+        svLog = (ScrollView)findViewById(R.id.sclLog);
+        edtQuery = (EditText)findViewById(R.id.editQuery);
+        edtUnregisterQuery = (EditText)findViewById(R.id.editUnregisterQuery);
+        
+        findViewById(R.id.btnRegisterQuery).setOnClickListener(clickHandler);     
+        findViewById(R.id.btnUnregisterQuery).setOnClickListener(clickHandler);      
+        findViewById(R.id.btFullDevice).setOnClickListener(textAddHandler);       
+        findViewById(R.id.btDiscomfortIndex).setOnClickListener(textAddHandler);
+        findViewById(R.id.btPlus).setOnClickListener(clickHandler);        
+        findViewById(R.id.btMinus).setOnClickListener(clickHandler);
+        findViewById(R.id.btClear).setOnClickListener(textAddHandler);
+        findViewById(R.id.btLogClear).setOnClickListener(textAddHandler);
+        
+               copyFiles("lib");
+        
+        SoftSensorManager = new SSMInterface();
+        
+        String initConfig = "<SSMCore>" +
+                       "<Device>" +
+                               "<UDN>"+getUUID()+"</UDN>" +
+                               "<Name>MyMobile</Name>" +
+                               "<Type>Mobile</Type>" +
+                               "</Device>" +
+                               "<Config>" +
+                               "<SoftSensorRepository>/data/data/" +  getPackageName() + "/files/</SoftSensorRepository>" +
+                               "<SoftSensorDescription>/data/data/" + getPackageName() + "/files/SoftSensorDescription.xml</SoftSensorDescription>" + 
+                               "</Config>" +
+                               "</SSMCore>";
+        
+        try 
+        {
+                       SoftSensorManager.startSSMCore(initConfig);
+               } 
+        catch (Exception e) 
+        {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+    }
+      
+    @Override
+    protected void onDestroy()
+    {
+       SoftSensorManager.stopSSMCore();
+       
+       super.onDestroy();
+    }
+    
+       private String getUUID() 
+       {
+               String  PREF_UNIQUE_ID = "PREF_UNIQUE_ID";
+               SharedPreferences sharedPrefs = getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE);
+               String uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
+           
+               if (uniqueID == null) 
+               {
+              uniqueID = UUID.randomUUID().toString();
+              Editor editor = sharedPrefs.edit();
+              editor.putString(PREF_UNIQUE_ID, uniqueID);
+              editor.commit();
+           }
+           
+               return uniqueID;
+       }
+               
+       private void copyFiles(String path)
+    {           
+               AssetManager assetManager = getAssets();
+           String assets[] = null;
+           
+           try 
+           {
+               assets = assetManager.list(path);
+               
+               if (assets.length == 0) 
+               {                       
+                   copyFile(path);
+               } 
+               else 
+               {
+                   String fullPath = "/data/data/" + this.getClass().getPackage().toString() + "/" + path;
+                   File dir = new File(fullPath);
+                   
+                   if (!dir.exists())
+                       dir.mkdir();
+                   for (int i = 0; i < assets.length; ++i) 
+                   {
+                       copyFiles(path + "/" + assets[i]);
+                   }
+               }
+           }
+           catch (IOException ex) 
+           {   
+               Log.e("tag", "I/O Exception", ex);
+           }
+       }
+           
+       private void copyFile(String filename) 
+       {
+           AssetManager assetManager = getAssets();
+           InputStream in = null;
+           OutputStream out = null;
+           
+           try 
+           {
+               in = assetManager.open(filename);
+               out = openFileOutput(filename.split("/")[1], Context.MODE_PRIVATE);
+              
+               byte[] buffer = new byte[1024];
+               int read;
+
+               while ((read = in.read(buffer)) != -1) 
+               {
+                   out.write(buffer, 0, read);
+               }
+               
+               in.close();
+               in = null;
+               out.flush();
+               out.close();
+               out = null;
+           }
+           catch (Exception e)
+           {
+               Log.e("tag", e.getMessage());
+           }
+       }
+}