--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ResourceHosting</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.iotivity.ResourceHosting"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="21" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ </application>
+
+</manifest>
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ca
+LOCAL_SRC_FILES := ../libs/libconnectivity_abstraction.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ca_i
+LOCAL_SRC_FILES := ../libs/libca-interface.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := oc_logger_core
+LOCAL_SRC_FILES := ../libs/liboc_logger_core.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 := ocstack-jni
+LOCAL_SRC_FILES := ../libs/libocstack-jni.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := NotificationManager
+LOCAL_SRC_FILES := ../libs/libNotificationManager.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ResourceHosing_JNI
+LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
+
+LOCAL_STATIC_LIBRARIES = ca_i
+LOCAL_STATIC_LIBRARIES += ca
+LOCAL_STATIC_LIBRARIES += oc_logger_core
+LOCAL_STATIC_LIBRARIES += oc_logger
+LOCAL_STATIC_LIBRARIES += octbstack
+LOCAL_STATIC_LIBRARIES += oc
+LOCAL_STATIC_LIBRARIES += ocstack-jni
+LOCAL_STATIC_LIBRARIES += NotificationManager
+
+LOCAL_C_INCLUDES := ../../../../../../resource/csdk/stack/include/
+LOCAL_C_INCLUDES += ../../../../../../resource/csdk/logger/include/
+LOCAL_C_INCLUDES += ../../../../../../resource/include/
+LOCAL_C_INCLUDES += ../../../../../../resource/oc_logger/include/
+LOCAL_C_INCLUDES += ../../../../../../extlibs/boost/boost_1_58_0/
+LOCAL_C_INCLUDES += ../../../../NotificationManager/include/
+
+
+LOCAL_SRC_FILES := ResourceHosing_JNI.cpp
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+APP_STL:=gnustl_shared
+NDK_TOOLCHAIN_VERSION := 4.9
--- /dev/null
+
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+extern "C" {
+#include "hosting.h"
+}
+#include "ResourceHosing_JNI.h"
+#include "OCAndroid.h"
+
+using namespace std;
+
+atomic_bool threadRun;
+thread ocProcessThread;
+/*
+ * To execute OCProcess when threadRun value is only true
+ */
+void ocProcessFunc()
+{
+ while (threadRun)
+ {
+
+ if (OCProcess() != OC_STACK_OK)
+ {
+ return ;
+ }
+
+ sleep(2);
+ }
+}
+
+/*
+ * for Hosting Device Side
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStart
+(JNIEnv *env, jobject obj)
+{
+ jint result = 0;
+ if(threadRun==true)
+ {
+ result = (jint)HOSTING_THREAD_ERROR;
+ return result;
+ }
+ else
+ {
+ result = (jint)OICStartCoordinate();
+
+ threadRun = true;
+ ocProcessThread = thread(ocProcessFunc);
+ return result;
+ }
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStop
+(JNIEnv *env, jobject obj)
+{
+ jint result = 0;
+ //terminate Thread
+ if (ocProcessThread.joinable())
+ {
+ threadRun = false;
+ ocProcessThread.join();
+ }
+ else
+ {
+ result = (jint)HOSTING_THREAD_ERROR;
+ return result;
+ }
+ result = (jint)OICStopCoordinate();
+
+ return result;
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingInit
+(JNIEnv *env, jobject obj,jstring j_addr)
+{
+ const char* addr = env->GetStringUTFChars(j_addr,NULL);
+
+ if (NULL == j_addr)
+ return (jint)OCSTACK_ERROR;
+
+ if(OCInit(addr,USE_RANDOM_PORT,OC_CLIENT_SERVER)!=OC_STACK_OK)
+ {
+ return (jint)OCSTACK_ERROR;
+ }
+
+ env->ReleaseStringUTFChars(j_addr,addr);
+ return (jint)OCSTACK_OK;
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
+(JNIEnv *env, jobject obj)
+{
+ if (OCStop() != OC_STACK_OK)
+ {
+ return (jint)OCSTACK_ERROR;
+ }
+ //terminate Thread
+ if (ocProcessThread.joinable())
+ {
+ threadRun = false;
+ ocProcessThread.join();
+ }
+ else
+ {
+ return (jint)HOSTING_THREAD_ERROR;
+ }
+
+ return (jint)OCSTACK_OK;
+}
--- /dev/null
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+
+#ifndef RESOURCEHOSTING_JNI_H_
+#define RESOURCEHOSTING_JNI_H_
+
+#include <jni.h>
+#include <thread>
+#include <atomic>
+#include <unistd.h>
+
+#define TAG "OIC-JNI"
+
+#define JNI_CURRENT_VERSION JNI_VERSION_1_6
+#define OCSTACK_OK 0
+#define OCSTACK_ERROR 255
+#define HOSTING_THREAD_ERROR -2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Class: org_iotivity_service_resourcehosting_ResourceHosting
+ * Method: OICCoordinatorStart
+ * Signature: ()V
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStart
+(JNIEnv *, jobject);
+/*
+ * @Class: org_iotivity_service_resourcehosting_ResourceHosting
+ * @Method: OICCoordinatorStop
+ * @Signature: ()V
+ */
+
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStop
+(JNIEnv *, jobject);
+/*
+ * Class: org_iotivity_service_resourcehosting_ResourceHosting
+ * Method: ResourceHostingInit
+ * Signature: ()V
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingInit
+(JNIEnv *env, jobject obj,jstring j_addr);
+/*
+ * Class: org_iotivity_service_resourcehosting_ResourceHosting
+ * Method: ResourceHostingTerminate
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
+(JNIEnv *env, jobject obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RESOURCEHOSTING_JNI_H_ */
--- /dev/null
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-22
--- /dev/null
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+package org.iotivity.ResourceHosting;
+import java.lang.System;
+import java.lang.String;;
+/**
+ * To execute resource hosting function for android sample application .
+ *
+ * @author Copyright 2015 Samsung Electronics All Rights Reserved.
+ * @see className class : ResourceHosting</br>
+ *
+ */
+
+public class ResourceHosting {
+
+ /**
+ * jni function - OicCorrdinatorstart() method.
+ *
+ * @see Class class :
+ * org_iotivity_resourcehosting_ResourceHosting</br>
+ * @see Method method : OICCoordinatorStart</br>
+ * @see Signature signature : ()V</br>
+ */
+ public native int OICCoordinatorStart();
+
+ /**
+ * jni function - OICCoordinatorStop() method.
+ *
+ * @see Class class :
+ * org_iotivity_resourcehosting_ResourceHosting</br>
+ * @see Method method : OICCoordinatorStop</br>
+ * @see signature signature : ()V</br>
+ */
+ public native int OICCoordinatorStop();
+
+ /**
+ * jni function - ResourceHostingInit() method in order to execute
+ * OICCoordinatorStart() method.
+ *
+ * @see Class class :
+ * org_iotivity_resourcehosting_ResourceHosting</br>
+ * @see Method method : ResourceHostingInit</br>
+ * @param addr
+ * ipAddress
+ * @see signature signature : (Ljava/lang/String;)V</br>
+ */
+ public native int ResourceHostingInit(String addr);
+
+ /**
+ * jni function - ResourceHostingTerminate() method in order to terminate
+ * resource hosting
+ *
+ * @see Class class :
+ * org_iotivity_resourcehosting_ResourceHosting</br>
+ * @see Method method : ResourceHostingTerminate</br>
+ * @see signature signature : ()V</br>
+ */
+ public native int ResourceHostingTerminate();
+
+ static {
+ System.loadLibrary("connectivity_abstraction");
+ System.loadLibrary("ca-interface");
+ System.loadLibrary("oc_logger_core");
+ System.loadLibrary("oc_logger");
+ System.loadLibrary("octbstack");
+ System.loadLibrary("oc");
+ System.loadLibrary("ocstack-jni");
+ System.loadLibrary("NotificationManager");
+ System.loadLibrary("ResourceHosing_JNI");
+ }
+}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-extern "C" {
-#include "hosting.h"
-}
-#include "resourceCoordinator_JNI.h"
-#include "android_cpp11_compat.h"
-
-using namespace std;
-
-atomic_bool threadRun;
-thread ocProcessThread;
-/*
- * To execute OCProcess when threadRun value is only true
- */
-void ocProcessFunc()
-{
- while (threadRun)
- {
-
- if (OCProcess() != OC_STACK_OK)
- {
- //OCProcess ERROR
- }
-
- sleep(2);
- }
-}
-/*
- * To callback log message from C++ to Java for android
- */
-void messageCallback(JNIEnv *env, jobject obj, const char *c_str)
-{
- jstring jstr = (env)->NewStringUTF(c_str);
- jclass cls = env->GetObjectClass(obj);
- jmethodID cbMessage = env->GetMethodID(cls, "cbMessage", "(Ljava/lang/String;)V");
- env->CallVoidMethod(obj,cbMessage, jstr);
-}
-/*
- * for Hosting Device Side
- */
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_OICCoordinatorStart
-(JNIEnv *env, jobject obj)
-{
- jint result = 0;
- if(threadRun==true)
- {
-
- messageCallback(env,obj,"OICCoordinatorStart already executed");
- result = (jint)HOSTING_THREAD_ERROR;
- return result;
- }
- else
- {
- messageCallback(env,obj,"OICCoordinatorStart");
- result = (jint)OICStartCoordinate();
- string str = "OICStartCoordinate result : ";
- string result_str = std::to_string(result);
- str += result_str;
- messageCallback(env,obj,str.c_str());
- threadRun = true;
- ocProcessThread = thread(ocProcessFunc);
- return result;
- }
-}
-
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_OICCoordinatorStop
-(JNIEnv *env, jobject obj)
-{
- messageCallback(env,obj,"OICCoordinatorStop");
- jint result = 0;
- //terminate Thread
- if (ocProcessThread.joinable())
- {
- threadRun = false;
- ocProcessThread.join();
- }
- else
- {
- messageCallback(env,obj,"OICCoordinatorStop already terminated");
- result = (jint)HOSTING_THREAD_ERROR;
- return result;
- }
- result = (jint)OICStopCoordinate();
- string str = "OICStopCoordinate result : ";
- string result_str = std::to_string(result);
- str += result_str;
- messageCallback(env,obj,str.c_str());
- return result;
-}
-
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_ResourceHostingInit
-(JNIEnv *env, jobject obj,jstring j_addr)
-{
- messageCallback(env,obj,"ResourceHostingInit");
- const char* addr = env->GetStringUTFChars(j_addr,NULL);
-
- if (NULL == j_addr)
- return (jint)OCSTACK_ERROR;
-
- if(OCInit(addr,USE_RANDOM_PORT,OC_CLIENT_SERVER)!=OC_STACK_OK)
- {
- messageCallback(env,obj,"OCStack init Error");
- return (jint)OCSTACK_ERROR;
- }
-
- env->ReleaseStringUTFChars(j_addr,addr);
- return (jint)OCSTACK_OK;
-}
-
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_ResourceHostingTerminate
-(JNIEnv *env, jobject obj)
-{
- messageCallback(env,obj,"ResourceHostingTerminate");
- if (OCStop() != OC_STACK_OK)
- {
-
- messageCallback(env,obj,"OCStack stop error");
- return (jint)OCSTACK_ERROR;
- }
- //terminate Thread
- if (ocProcessThread.joinable())
- {
- threadRun = false;
- ocProcessThread.join();
- }
- else
- {
- messageCallback(env,obj,"The thread may be not running.");
- return (jint)HOSTING_THREAD_ERROR;
- }
-
- return (jint)OCSTACK_OK;
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-
-#ifndef RESOURCECOORDINATOR_JNI_H_
-#define RESOURCECOORDINATOR_JNI_H_
-
-#include <jni.h>
-#include <thread>
-#include <atomic>
-#include <unistd.h>
-
-#define TAG "OIC-JNI"
-
-#define JNI_CURRENT_VERSION JNI_VERSION_1_6
-#define OCSTACK_OK 0
-#define OCSTACK_ERROR 255
-#define HOSTING_THREAD_ERROR -2
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Class: org_iotivity_service_resourcehostingsampleapp_ResourceHosting
- * Method: OICCoordinatorStart
- * Signature: ()V
- */
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_OICCoordinatorStart
-(JNIEnv *, jobject);
-/*
- * @Class: org_iotivity_service_resourcehostingsampleapp_ResourceHosting
- * @Method: OICCoordinatorStop
- * @Signature: ()V
- */
-
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_OICCoordinatorStop
-(JNIEnv *, jobject);
-/*
- * Class: org_iotivity_service_resourcehostingsampleapp_ResourceHosting
- * Method: ResourceHostingInit
- * Signature: ()V
- */
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_ResourceHostingInit
-(JNIEnv *env, jobject obj,jstring j_addr);
-/*
- * Class: org_iotivity_service_resourcehostingsampleapp_ResourceHosting
- * Method: ResourceHostingTerminate
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT jint JNICALL Java_com_example_resourcehostingsampleapp_ResourceHosting_ResourceHostingTerminate
-(JNIEnv *env, jobject obj);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RESOURCECOORDINATOR_JNI_H_ */
NOTI_SRC_DIR + 'requestHandler.c',
NOTI_SRC_DIR + 'virtualResource.c']
-if target_os == 'android':
- notimgr_src.append(NOTI_SRC_DIR + 'resourceCoordinator_JNI.cpp')
-
if target_os in ['tizen','android'] :
notificationsdk = notimgr_env.SharedLibrary('NotificationManager', notimgr_src)
else :
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry exported="true" kind="lib" path="C:/Users/jay.sharma/Desktop/master_19_may/iotivity/android/android_api/base/build/intermediates/bundles/release/classes.jar"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ResourceHosting</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.resourcehostingsampleapp"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="19" />
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.INTERNET_ACCESS" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.GET_TASKS"/>
- <uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
- <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name="com.example.resourcehostingsampleapp.ResourceHosting"
- 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>
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := ca
-LOCAL_SRC_FILES := ../libs/libconnectivity_abstraction.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := oc_logger_core
-LOCAL_SRC_FILES := ../libs/liboc_logger_core.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 := libNotificationManager
-LOCAL_SRC_FILES := ../libs/libNotificationManager.so
-include $(PREBUILT_SHARED_LIBRARY)
+++ /dev/null
-APP_STL:=gnustl_shared
-NDK_TOOLCHAIN_VERSION := 4.9
+++ /dev/null
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19
+++ /dev/null
-<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" >
-
- <Button
- android:id="@+id/btnStartHosting"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="startHosting"
- android:textSize="18sp" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/btnStopHosting"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="StopHosting"
- android:textSize="18sp" />
- </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
+++ /dev/null
-<resources>
-
- <!--
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- <!-- API 11 theme customizations can go here. -->
- </style>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!--
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
- <!-- API 14 theme customizations can go here. -->
- </style>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">ResourceHostingSampleApp</string>
- <string name="hello_world">Hello world!</string>
-
-</resources>
+++ /dev/null
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Light">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
-</resources>
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-package com.example.resourcehostingsampleapp;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-
-import org.iotivity.base.ModeType;
-import org.iotivity.base.OcPlatform;
-import org.iotivity.base.OcResourceHandle;
-import org.iotivity.base.PlatformConfig;
-import org.iotivity.base.QualityOfService;
-import org.iotivity.base.ServiceType;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-/**
- * To execute resource hosting function for android sample application .
- * @author Copyright 2015 Samsung Electronics All Rights Reserved.
- * @see className class : ResourceHosting</br>
- *
- */
-
-public class ResourceHosting extends Activity implements OnClickListener
-{
- private final int OCSTACK_OK = 0;
- private final int OCSTACK_ERROR = 255;
- private final int RESOURCEHOSTING_DO_NOT_THREADRUNNING = -2;
-
- private final String TAG = "NMResourceHosting : " + this.getClass().getSimpleName();
- private TextView mLogTextView;
- private String mLog = "";
- /**
- * To initialize UI Function Setting.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onCreate</br>
- */
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mLogTextView = (TextView) findViewById(R.id.txtLog);
- findViewById(R.id.btnStartHosting).setOnClickListener(this);
- findViewById(R.id.btnStopHosting).setOnClickListener(this);
- findViewById(R.id.btLogClear).setOnClickListener(this);
-
- PlatformConfig platformConfigObj;
-
- platformConfigObj = new PlatformConfig(this,ServiceType.IN_PROC,
- ModeType.CLIENT_SERVER, "0.0.0.0", 0, QualityOfService.LOW);
-
- Log.i(TAG, "Before Calling Configure of ocPlatform");
- OcPlatform.Configure(platformConfigObj);
- Log.i(TAG, "Configuration done Successfully");
- }
-
- /**
- * To execute initOICStack for running Resource hosting.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onStart</br>
- */
- @Override
- protected void onStart()
- {
- super.onStart();
- }
-
- /**
- * To terminate Resource hosting.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onStop</br>
- */
- @Override
- protected void onStop()
- {
- super.onStop();
- }
-
- protected void onResume()
- {
- super.onResume();
- }
-
- /**
- * To execute initOICStack for running Resource hosting.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onRestart</br>
- */
- @Override
- protected void onRestart()
- {
- super.onRestart();
- }
-
- /**
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onDestroy</br>
- */
- protected void onDestroy()
- {
- super.onDestroy();
- int result;
- result = OICCoordinatorStop();
- Log.d(TAG, "OICCoordinatorStop() : "+ result);
- }
-
- /**
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : onClick</br>
- * @param v view to choice
- */
- public void onClick(View v)
- {
- int getId = v.getId();
-
- switch (getId)
- {
- case R.id.btnStartHosting:
- try
- {
- int result;
- result = OICCoordinatorStart();
- Log.d(TAG, "OICCoordinatorStart : " + result);
- }
- catch (Exception e)
- {
- Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
- Log.d(TAG, e.getMessage() + result);
- }
- break;
- case R.id.btnStopHosting:
- int result;
- result = OICCoordinatorStop();
- Log.d(TAG, "OICCoordinatorStop : "+ result);
- break;
- case R.id.btLogClear:
- clearLog();
- default:
- break;
- }
- }
-
- /**
- * all clear log view
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : clearLog</br>
- */
- private void clearLog()
- {
- mLog = "";
- mLogTextView.setText(mLog);
- Log.i(TAG, "Log textbox is cleared");
- }
-
- /**
- * recieve the callback log message.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : cbMessage</br>
- * @param msg callback log message
- */
- public void cbMessage(String msg)
- {
- mLog += msg + "\n";
- mLogTextView.setText(mLog);
- Log.i(TAG, msg);
- }
-
- /**
- * jni function - OicCorrdinatorstart() method.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : OICCoordinatorStart</br>
- * @see Signature signature : ()V</br>
- */
- public native int OICCoordinatorStart();
-
- /**
- * jni function - OICCoordinatorStop() method.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : OICCoordinatorStop</br>
- * @see signature signature : ()V</br>
- */
- public native int OICCoordinatorStop();
-
- /**
- * jni function - ResourceHostingInit() method in order to execute OICCoordinatorStart() method.
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : ResourceHostingInit</br>
- * @param addr ipAddress
- * @see signature signature : (Ljava/lang/String;)V</br>
- */
- public native int ResourceHostingInit(String addr);
-
- /**
- * jni function - ResourceHostingTerminate() method in order to terminate resource hosting
- * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
- * @see Method method : ResourceHostingTerminate</br>
- * @see signature signature : ()V</br>
- */
- public native int ResourceHostingTerminate();
-
- static
- {
- System.loadLibrary("gnustl_shared");
- System.loadLibrary("oc_logger");
- System.loadLibrary("connectivity_abstraction");
- System.loadLibrary("ca-interface");
- System.loadLibrary("octbstack");
- System.loadLibrary("oc");
- System.loadLibrary("ocstack-jni");
- System.loadLibrary("NotificationManager");
- }
-}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.resourcehostingsampleapp"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="19" />
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.INTERNET_ACCESS" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.GET_TASKS"/>
+ <uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
+ <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.resourcehostingsampleapp.ResourceHostingSampleApp"
+ 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>
--- /dev/null
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
--- /dev/null
+<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" >
+
+ <Button
+ android:id="@+id/btnStartHosting"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="startHosting"
+ android:textSize="18sp" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <Button
+ android:id="@+id/btnStopHosting"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="StopHosting"
+ android:textSize="18sp" />
+ </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
--- /dev/null
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
--- /dev/null
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">ResourceHostingSampleApp</string>
+ <string name="hello_world">Hello world!</string>
+
+</resources>
--- /dev/null
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
--- /dev/null
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+package com.example.resourcehostingsampleapp;
+
+import java.lang.reflect.Method;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+import org.iotivity.ResourceHosting.ResourceHosting;
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcResourceHandle;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * To execute resource hosting function for android sample application .
+ * @author Copyright 2015 Samsung Electronics All Rights Reserved.
+ * @see className class : ResourceHosting</br>
+ *
+ */
+
+public class ResourceHostingSampleApp extends Activity implements OnClickListener
+{
+ private final int OCSTACK_OK = 0;
+ private final int OCSTACK_ERROR = 255;
+ private final int RESOURCEHOSTING_DO_NOT_THREADRUNNING = -2;
+
+ private String TAG = "ResourceHosting";
+ private OcResourceHandle mResourceHandle;
+ private String mIpAddress;
+ private TextView mLogTextView;
+ private String mLog = "";
+ private ResourceHosting resourceHosting;
+ /**
+ * To initialize UI Function Setting.
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onCreate</br>
+ */
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ mLogTextView = (TextView) findViewById(R.id.txtLog);
+ findViewById(R.id.btnStartHosting).setOnClickListener(this);
+ findViewById(R.id.btnStopHosting).setOnClickListener(this);
+ findViewById(R.id.btLogClear).setOnClickListener(this);
+
+ PlatformConfig platformConfigObj;
+ resourceHosting = new ResourceHosting();
+ platformConfigObj = new PlatformConfig(this,ServiceType.IN_PROC,
+ ModeType.CLIENT_SERVER, "0.0.0.0", 0, QualityOfService.LOW);
+
+ Log.i(TAG, "Before Calling Configure of ocPlatform");
+ OcPlatform.Configure(platformConfigObj);
+ Log.i(TAG, "Configuration done Successfully");
+ }
+
+ /**
+ * To execute initOICStack for running Resource hosting.
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onStart</br>
+ */
+ @Override
+ protected void onStart()
+ {
+ super.onStart();
+ initOICStack();
+ }
+
+ /**
+ * To terminate Resource hosting.
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onStop</br>
+ */
+ @Override
+ protected void onStop()
+ {
+ super.onStop();
+ int result;
+ result = resourceHosting.ResourceHostingTerminate();
+ Log.d(TAG, "ResourceHostingTerminate : "+ result);
+ }
+
+ protected void onResume()
+ {
+ super.onResume();
+ }
+
+ /**
+ * To execute initOICStack for running Resource hosting.
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onRestart</br>
+ */
+ @Override
+ protected void onRestart()
+ {
+ super.onRestart();
+ initOICStack();
+ }
+
+ /**
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onDestroy</br>
+ */
+ protected void onDestroy()
+ {
+ super.onDestroy();
+ }
+
+ /**
+ * get IpAddress and execute resourceHostingInit() method.
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : initOICStack</br>
+ */
+ private void initOICStack()
+ {
+ try
+ {
+ mIpAddress = getIpAddress();
+ int result = 0;
+ result = resourceHosting.ResourceHostingInit(mIpAddress);
+ Log.d(TAG, "ResourceHostingInit : " + result);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : getIpAddress</br>
+ */
+ private String getIpAddress()
+ {
+ try
+ {
+ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
+ en.hasMoreElements();)
+ {
+ NetworkInterface intf = (NetworkInterface) en.nextElement();
+ for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
+ {
+ InetAddress inetAddress = (InetAddress) enumIpAddr.nextElement();
+ if (!inetAddress.isLoopbackAddress())
+ {
+ if (inetAddress instanceof Inet4Address)
+ return inetAddress.getHostAddress().toString();
+ }
+ }
+ }
+ }
+ catch (SocketException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * @see Class class : com_example_resourcehostingsampleapp_ResourceHosting</br>
+ * @see Method method : onClick</br>
+ * @param v view to choice
+ */
+ public void onClick(View v)
+ {
+ int getId = v.getId();
+
+ switch (getId)
+ {
+ case R.id.btnStartHosting:
+ try
+ {
+ int result;
+ result = resourceHosting.OICCoordinatorStart();
+ Log.d(TAG, "OICCoordinatorStart : " + result);
+ }
+ catch (Exception e)
+ {
+ Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
+ }
+ break;
+ case R.id.btnStopHosting:
+ int result;
+ result = resourceHosting.OICCoordinatorStop();
+ Log.d(TAG, "OICCoordinatorStop : "+ result);
+ break;
+ case R.id.btLogClear:
+ default:
+ break;
+ }
+ }
+
+}