Notification ProviderService Java API Updation
authornikhil.a <nikhil.a7@samsung.com>
Tue, 9 Aug 2016 07:36:14 +0000 (13:06 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 9 Aug 2016 10:21:56 +0000 (10:21 +0000)
1) Updated the JAVA API's for the NS ProviderService using C++ wrapper
2) Modified the JNI API's for NS ProviderService
3) Added the sample Android application for testing the Java API for Provider.

Change-Id: I1df1509e9f95d5c7df3d6711dadd0889d1997045
Signed-off-by: nikhil.a <nikhil.a7@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10031
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Abitha Shankar <abitha.s@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
28 files changed:
service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/IoTNotification.java [deleted file]
service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSMessage.java [deleted file]
service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSSync.java [deleted file]
service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java [moved from service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSConsumer.java with 54% similarity]
service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java [new file with mode: 0644]
service/notification/android/notification-service/src/main/jni/Android.mk
service/notification/android/notification-service/src/main/jni/notificationProvider.c [deleted file]
service/notification/android/notification-service/src/main/jni/notificationProvider.h [deleted file]
service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp [new file with mode: 0644]
service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.h [new file with mode: 0644]
service/notification/examples/android/NotiProviderExample/.idea/.name [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/compiler.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/copyright/profiles_settings.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/gradle.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/Project_Default.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/profiles_settings.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/misc.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/modules.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/runConfigurations.xml [deleted file]
service/notification/examples/android/NotiProviderExample/.idea/vcs.xml [deleted file]
service/notification/examples/android/NotiProviderExample/app/build.gradle
service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java
service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/NotiListener.java
service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/ProviderProxy.java
service/notification/examples/android/NotiProviderExample/iotivity-armeabi-notification-service-debug/build.gradle [moved from service/notification/examples/android/NotiProviderExample/iotivity-armeabi-notification-service-release/build.gradle with 83% similarity]
service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-debug/build.gradle [new file with mode: 0644]
service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-release/build.gradle [deleted file]
service/notification/examples/android/NotiProviderExample/settings.gradle

diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/IoTNotification.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/IoTNotification.java
deleted file mode 100644 (file)
index a27afbc..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.iotivity.service.ns;
-
-import android.util.Log;
-import org.iotivity.service.ns.NSMessage;
-import org.iotivity.service.ns.NSConsumer;
-import org.iotivity.service.ns.NSSync;
-
-public class IoTNotification
-{
-    public IoTNotification()
-    {
-    }
-
-    static
-    {
-        System.loadLibrary("notification_provider_jni");
-    }
-
-    public native int NSStartProvider(boolean access,
-        NSSubscriptionListner subscriptionListener,
-        NSSynchListner syncListener);
-    public native int NSStopProvider();
-    public native int NSSendNotification(NSMessage message);
-    public native int NSProviderReadCheck(NSMessage message);
-    public native int NSAccept(NSConsumer consumer, boolean accepted);
-
-    public interface NSSubscriptionListner {
-        public void OnNSSubscribedEvent(String consumerId);
-    }
-
-    public interface NSSynchListner {
-       public void OnNSSynchronizedEvent(String messageId, int syncState);
-    }
-}
-
diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSMessage.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSMessage.java
deleted file mode 100644 (file)
index 66e7540..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-//******************************************************************\r
-//\r
-// Copyright 2016 Samsung Electronics All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-package org.iotivity.service.ns;\r
-\r
-import android.util.Log;\r
-\r
-public class NSMessage\r
-{\r
-    String id = null;\r
-    String title = null;\r
-    String body = null;\r
-    String source = null;\r
-\r
-    public NSMessage(String id)\r
-    {\r
-        this.id = id;\r
-    }\r
-\r
-    public String getId()\r
-    {\r
-        return id;\r
-    }\r
-\r
-    public String getTitle()\r
-    {\r
-        return title;\r
-    }\r
-\r
-    public void setTitle(String title)\r
-    {\r
-        this.title = title;\r
-    }\r
-\r
-    public String getBody()\r
-    {\r
-        return body;\r
-    }\r
-\r
-    public void setBody(String body)\r
-    {\r
-        this.body = body;\r
-    }\r
-\r
-    public String getSource()\r
-    {\r
-        return source;\r
-    }\r
-\r
-    public void setSource(String source)\r
-    {\r
-        this.source = source;\r
-    }\r
-}\r
diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSSync.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/NSSync.java
deleted file mode 100644 (file)
index 065ae99..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//******************************************************************\r
-//\r
-// Copyright 2016 Samsung Electronics All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-package org.iotivity.service.ns;\r
-\r
-import android.util.Log;\r
-\r
-public class NSSync {\r
-\r
-    String mMessageId = null;\r
-    String mDeviceId = null;\r
-\r
-    public NSSync(String id) {\r
-        this.mMessageId = id;\r
-    }\r
-\r
-    public String getMessageId() {\r
-        return mMessageId;\r
-    }\r
-\r
-    public String getDeviceId() {\r
-        return mDeviceId;\r
-    }\r
-\r
-    public void setDeviceId(String id) {\r
-        this.mDeviceId = id;\r
-    }\r
-\r
-}\r
@@ -1,46 +1,47 @@
-//******************************************************************\r
-//\r
-// Copyright 2016 Samsung Electronics All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-package org.iotivity.service.ns;\r
-\r
-import android.util.Log;\r
-\r
-public class NSConsumer {\r
-\r
-    String mId = null;\r
-    String mAddress = null;\r
-\r
-    public NSConsumer(String id) {\r
-        this.mId = id;\r
-    }\r
-\r
-    public String getId() {\r
-        return mId;\r
-    }\r
-\r
-    public String getAddress() {\r
-        return mAddress;\r
-    }\r
-\r
-    public void setAddress(String address) {\r
-        this.mAddress = address;\r
-    }\r
-\r
-}\r
+//******************************************************************
+//
+// Copyright 2016 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.service.ns.provider;
+import org.iotivity.service.ns.common.*;
+/**
+  * @class   Consumer
+  * @brief   This class provides implementation of Notification Consumer object.
+  */
+public class Consumer
+{
+    public native int  nativeAcceptSubscription(Consumer consumer, boolean accepted);
+
+    public String mConsumerId;
+
+    public Consumer(final String consumerId)
+    {
+        mConsumerId = consumerId;
+    }
+    public String getConsumerId( )
+    {
+        return mConsumerId;
+    }
+    public int AcceptSubscription(Consumer consumer, boolean accepted) throws NSException
+    {
+        if (consumer != null)
+            return nativeAcceptSubscription(consumer, accepted);
+        return -1;
+    }
+
+}
\ No newline at end of file
diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java
new file mode 100644 (file)
index 0000000..d09133d
--- /dev/null
@@ -0,0 +1,109 @@
+//******************************************************************
+//
+// Copyright 2016 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.service.ns.provider;
+import org.iotivity.service.ns.common.*;
+/**
+  * @class   ProviderService
+  * @brief   This class provides a set of Java APIs for Notification ProviderService.
+  */
+public class ProviderService
+{
+
+    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("notification_provider");
+        System.loadLibrary("notification_provider_wrapper");
+        System.loadLibrary("notification_provider_jni");
+    }
+    public native int  nativeStart(boolean policy,
+                                   OnSubscriptionListener   subscriptionListener,
+                                   OnSyncInfoListener   syncInfoListener);
+    public native int  nativeStop();
+    public native int  nativeSendMessage(Message message);
+    public native void  nativeSendSyncInfo( long messageId , int type);
+    public native int  nativeEnableRemoteService(String servAdd);
+    public native int  nativeDisableRemoteService(String servAdd);
+
+    private static ProviderService instance;
+
+    static
+    {
+        instance = new ProviderService();
+    }
+    public interface OnSubscriptionListener
+    {
+        public void onConsumerSubscribed(Consumer consumer);
+    }
+    public interface OnSyncInfoListener
+    {
+        public void onMessageSynchronized(SyncInfo syncInfo);
+    }
+
+    public static ProviderService getInstance()
+    {
+        return instance;
+    }
+    public int Start(boolean policy,
+                     OnSubscriptionListener  subscriptionListener,
+                     OnSyncInfoListener  syncInfoListener) throws NSException
+    {
+
+    int result = nativeStart(policy, subscriptionListener, syncInfoListener);
+        return result;
+    }
+
+    public int Stop() throws NSException
+    {
+        int result = nativeStop();
+        return result;
+    }
+
+    public int   SendMessage(Message message) throws NSException
+    {
+        int result = nativeSendMessage(message);
+        return result;
+    }
+
+    public void SendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
+    {
+        nativeSendSyncInfo(messageId, syncType.ordinal());
+        return ;
+    }
+
+    public int   EnableRemoteService(String servAdd) throws NSException
+    {
+        int result = nativeEnableRemoteService(servAdd);
+        return result;
+    }
+
+    public int  DisableRemoteService(String servAdd) throws NSException
+    {
+        int result = nativeDisableRemoteService(servAdd);
+        return result;
+    }
+
+}
index fa15363..13a1dfb 100755 (executable)
@@ -51,24 +51,30 @@ LOCAL_SRC_FILES += common/JniNotificationCommon.cpp
 include $(BUILD_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 OIC_LIB_PATH := $(ROOT_PATH)/out/android/$(TARGET_ARCH_ABI)/$(APP_OPTIM)
+LOCAL_MODULE := notification_provider_wrapper
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libnotification_provider_wrapper.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+OIC_LIB_PATH := $(ROOT_PATH)/out/android/$(TARGET_ARCH_ABI)/$(APP_OPTIM)
 LOCAL_MODULE := notification_provider
 LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libnotification_provider.so
 include $(PREBUILT_SHARED_LIBRARY)
 
-
 include $(CLEAR_VARS)
 LOCAL_MODULE := notification_provider_jni
 LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
 LOCAL_LDLIBS := -llog
 
-LOCAL_STATIC_LIBRARIES := ca_interface
-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 += notification_provider
+LOCAL_SHARED_LIBRARIES := ca_interface
+LOCAL_SHARED_LIBRARIES += ca
+LOCAL_SHARED_LIBRARIES += oc_logger_core
+LOCAL_SHARED_LIBRARIES += oc_logger
+LOCAL_SHARED_LIBRARIES += octbstack
+LOCAL_SHARED_LIBRARIES += oc
+LOCAL_SHARED_LIBRARIES += ocstack-jni
+LOCAL_SHARED_LIBRARIES += notification_provider
+LOCAL_SHARED_LIBRARIES += notification_provider_wrapper
 
 OIC_SRC_DIR := ../../../../../..
 
@@ -76,13 +82,18 @@ LOCAL_C_INCLUDES := $(OIC_SRC_DIR)/resource/csdk/stack/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/csdk/logger/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/c_common
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/c_common/oic_string/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/oc_logger/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/include
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/src/common
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/src/provider
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/android/notification-service/src/main/jni/common
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/cpp-wrapper/common
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/notification/cpp-wrapper/provider/inc
 
 LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/extlibs/
 
-LOCAL_SRC_FILES := notificationProvider.c
+LOCAL_SRC_FILES := provider/JniNotificationProvider.cpp
+LOCAL_SRC_FILES += common/JniNotificationCommon.cpp
 
 include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/service/notification/android/notification-service/src/main/jni/notificationProvider.c b/service/notification/android/notification-service/src/main/jni/notificationProvider.c
deleted file mode 100755 (executable)
index b60367e..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-//******************************************************************\r
-//\r
-// Copyright 2016 Samsung Electronics All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-#include <android/log.h>\r
-#include <stdio.h>\r
-#include "notificationProvider.h"\r
-\r
-#define  LOG_TAG   "JNI_NS_INTERFACE"\r
-#define  LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)\r
-#define  LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)\r
-\r
-static JavaVM *g_jvm = NULL;\r
-static jobject g_obj_subscriptionListener = NULL;\r
-static jobject g_obj_syncListener = NULL;\r
-\r
-JNIEXPORT jint JNI_OnLoad(JavaVM *jvm, void *reserved)\r
-{\r
-    LOGI("Initialize NSInterface");\r
-    g_jvm = jvm;\r
-\r
-    return JNI_VERSION_1_6;\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSStartProvider(\r
-        JNIEnv * env, jobject jObj, jboolean jAccess, jobject jSubscriptionListener,\r
-        jobject jSyncListener)\r
-{\r
-    LOGI("NSStartProvider...");\r
-\r
-    if (!jSubscriptionListener || !jSyncListener)\r
-    {\r
-        LOGI("Fail to set listeners");\r
-    }\r
-\r
-    g_obj_subscriptionListener = (jobject) (*env)->NewGlobalRef(env, jSubscriptionListener);\r
-    g_obj_syncListener = (jobject) (*env)->NewGlobalRef(env, jSyncListener);\r
-\r
-    NSProviderConfig config;\r
-    config.subRequestCallback = NSSubscribeRequestCb;\r
-    config.syncInfoCallback = NSSyncCb;\r
-    config.policy = true;\r
-    if (NSStartProvider(config) != NS_OK)\r
-    {\r
-        LOGE("Fail to start NSProvider service");\r
-        return (jint) NS_ERROR;\r
-    }\r
-\r
-    return (jint) NS_OK;\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSStopProvider(\r
-        JNIEnv * env, jobject jObj)\r
-{\r
-    LOGI("NSStopProvider");\r
-\r
-    (*env)->DeleteGlobalRef(env, g_obj_subscriptionListener);\r
-    (*env)->DeleteGlobalRef(env, g_obj_syncListener);\r
-\r
-    if (NSStopProvider() != NS_OK)\r
-    {\r
-        LOGE("Fail to stop NSProvider service");\r
-        return (jint) NS_ERROR;\r
-    }\r
-\r
-    return (jint) NS_OK;\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSSendNotification(\r
-        JNIEnv * env, jobject jObj, jobject jMsg)\r
-{\r
-    LOGI("NSSendNotification");\r
-\r
-    if (!jMsg)\r
-    {\r
-        LOGI("Fail to send notification - Message is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-\r
-    NSMessage * nsMsg = NSGetMessage(env, jMsg);\r
-\r
-    LOGI("JNI TEST - NSSendNotification");\r
-    NSSendNotification(nsMsg);\r
-\r
-    return (jint) NS_OK;\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSProviderReadCheck(\r
-        JNIEnv * env, jobject jObj, jobject jMsg)\r
-{\r
-    LOGI("NSReasCheck");\r
-    return 0;\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSAcceptSubscription(JNIEnv * env,\r
-        jobject jObj, jobject jConsumer, jboolean jAccepted)\r
-{\r
-    if (jAccepted)\r
-    {\r
-        LOGI("Accepted");\r
-        //NSAccept(consumer, true);\r
-    }\r
-    else\r
-    {\r
-        LOGI("Denied");\r
-        //NSAccept(consumer, false);\r
-    }\r
-\r
-    return 0;\r
-}\r
-\r
-void NSSubscribeRequestCb(NSConsumer *consumer)\r
-{\r
-    LOGI("Subscription requested by consumer");\r
-\r
-    JNIEnv * env;\r
-    jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);\r
-    if (JNI_OK != res)\r
-    {\r
-        if (res == JNI_EDETACHED)\r
-        {\r
-            if ((*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL) != JNI_OK)\r
-            {\r
-                LOGE("Failed to get the environment");\r
-                return;\r
-            }\r
-            else\r
-            {\r
-                LOGE("Success to get the environment");\r
-            }\r
-        }\r
-        else\r
-        {\r
-            LOGE("Failed to get the environment using GetEnv()");\r
-            return;\r
-        }\r
-    }\r
-\r
-    LOGI("consumer ID : %s\n", consumer->consumerId);\r
-    jstring consumerId = (*env)->NewStringUTF(env, consumer->consumerId);\r
-\r
-    jclass cls = (*env)->GetObjectClass(env, g_obj_subscriptionListener);\r
-    if (!cls)\r
-    {\r
-        LOGE("Failed to Get ObjectClass");\r
-        return;\r
-    }\r
-    jmethodID mid = (*env)->GetMethodID(env, cls, "OnNSSubscribedEvent", "(Ljava/lang/String;)V");\r
-    if (!mid)\r
-    {\r
-        LOGE("Failed to Get MethodID");\r
-        return;\r
-    }\r
-\r
-    (*env)->CallVoidMethod(env, g_obj_subscriptionListener, mid, consumerId);\r
-\r
-    (*g_jvm)->DetachCurrentThread(g_jvm);\r
-\r
-    NSAcceptSubscription(consumer, true);\r
-\r
-    return;\r
-}\r
-\r
-void NSSyncCb(NSSyncInfo *sync)\r
-{\r
-    LOGI("Sync requested");\r
-\r
-    JNIEnv * env;\r
-    jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);\r
-    if (JNI_OK != res)\r
-    {\r
-        if (JNI_EDETACHED)\r
-        {\r
-            if ((*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL) < 0)\r
-            {\r
-                LOGE("Failed to get the environment");\r
-                return;\r
-            }\r
-            else\r
-            {\r
-                LOGE("Success to get the environment");\r
-            }\r
-        }\r
-        else\r
-        {\r
-            LOGE("Failed to get the environment using GetEnv()");\r
-            return;\r
-        }\r
-    }\r
-\r
-    LOGI("Sync ID : %s\n", sync->messageId);\r
-    LOGI("Sync STATE : %d\n", sync->state);\r
-\r
-    jstring strMessageId = (*env)->NewStringUTF(env, sync->messageId);\r
-\r
-    jclass cls = (*env)->GetObjectClass(env, g_obj_syncListener);\r
-    if (!cls)\r
-    {\r
-        LOGE("Failed to Get ObjectClass");\r
-        return;\r
-    }\r
-    jmethodID mid = (*env)->GetMethodID(env, cls, "OnNSSynchronizedEvent",\r
-            "(Ljava/lang/String;I)V");\r
-    if (!mid)\r
-    {\r
-        LOGE("Failed to Get MethodID");\r
-        return;\r
-    }\r
-\r
-    (*env)->CallVoidMethod(env, g_obj_syncListener, mid, strMessageId, (jint) sync->state);\r
-\r
-    (*g_jvm)->DetachCurrentThread(g_jvm);\r
-\r
-    return;\r
-\r
-}\r
-\r
-NSMessage * NSGetMessage(JNIEnv * env, jobject jMsg)\r
-{\r
-    LOGI("NSGetMessage");\r
-\r
-    jclass cls = (*env)->GetObjectClass(env, jMsg);\r
-\r
-    // Message ID\r
-    jfieldID fid_id = (*env)->GetFieldID(env, cls, "id", "Ljava/lang/String;");\r
-    if (fid_id == NULL)\r
-    {\r
-        LOGE("Error: jfieldID for message id is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    jstring jmsgId = (*env)->GetObjectField(env, jMsg, fid_id);\r
-    const char * messageId = (*env)->GetStringUTFChars(env, jmsgId, NULL);\r
-    if (messageId == NULL)\r
-    {\r
-        LOGE("Error: messageId is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    LOGI("Message ID: %s\n", messageId);\r
-\r
-    // Message Title\r
-    jfieldID fid_title = (*env)->GetFieldID(env, cls, "title", "Ljava/lang/String;");\r
-    if (fid_title == NULL)\r
-    {\r
-        LOGE("Error: jfieldID for message id is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    jstring jmsgTitle = (*env)->GetObjectField(env, jMsg, fid_title);\r
-    const char * messageTitle = (*env)->GetStringUTFChars(env, jmsgTitle, NULL);\r
-    if (messageTitle == NULL)\r
-    {\r
-        LOGE("Error: messageTitle is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    LOGI("Message Title: %s\n", messageTitle);\r
-\r
-    // Message Body\r
-    jfieldID fid_body = (*env)->GetFieldID(env, cls, "body", "Ljava/lang/String;");\r
-    if (fid_body == NULL)\r
-    {\r
-        LOGE("Error: jfieldID for message id is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    jstring jmsgBody = (*env)->GetObjectField(env, jMsg, fid_body);\r
-    const char * messageBody = (*env)->GetStringUTFChars(env, jmsgBody, NULL);\r
-    if (messageBody == NULL)\r
-    {\r
-        LOGE("Error: messageBody is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    LOGI("Message Body: %s\n", messageBody);\r
-\r
-    // Message Source\r
-    jfieldID fid_source = (*env)->GetFieldID(env, cls, "source", "Ljava/lang/String;");\r
-    if (fid_source == NULL)\r
-    {\r
-        LOGE("Error: jfieldID for message source is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    jstring jmsgSource = (*env)->GetObjectField(env, jMsg, fid_source);\r
-    const char * messageSource = (*env)->GetStringUTFChars(env, jmsgSource, NULL);\r
-    if (messageSource == NULL)\r
-    {\r
-        LOGE("Error: messageSource is null");\r
-        return (jint) NS_ERROR;\r
-    }\r
-    LOGI("Message Source: %s\n", messageSource);\r
-\r
-    NSMessage * nsMsg = (NSMessage *) malloc(sizeof(NSMessage));\r
-\r
-    nsMsg->messageId = strdup(messageId);\r
-    nsMsg->title = strdup(messageTitle);\r
-    nsMsg->contentText = strdup(messageBody);\r
-    nsMsg->sourceName = strdup(messageSource);\r
-\r
-    return nsMsg;\r
-\r
-}\r
diff --git a/service/notification/android/notification-service/src/main/jni/notificationProvider.h b/service/notification/android/notification-service/src/main/jni/notificationProvider.h
deleted file mode 100644 (file)
index 93c0ca4..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//******************************************************************\r
-//\r
-// Copyright 2016 Samsung Electronics All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-#include <jni.h>\r
-\r
-#include "NSProviderInterface.h"\r
-#include "NSCommon.h"\r
-\r
-#ifndef NOTIFICATION_JNI_H\r
-#define NOTIFICATION_JNI_H\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSStartProvider(\r
-            JNIEnv *, jobject, jboolean, jobject, jobject);\r
-\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSStopProvider(\r
-            JNIEnv *, jobject);\r
-\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSSendNotification(\r
-            JNIEnv *, jobject, jobject);\r
-\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSProviderReadCheck(\r
-            JNIEnv *, jobject, jobject);\r
-\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_service_notification_IoTNotification_NSAcceptSubscription(JNIEnv *,\r
-            jobject, jobject, jboolean);\r
-\r
-    void NSSubscribeRequestCb(NSConsumer*);\r
-\r
-    void NSSyncCb(NSSyncInfo*);\r
-\r
-    NSMessage * NSGetMessage(JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\r
diff --git a/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp b/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp
new file mode 100644 (file)
index 0000000..595a0d9
--- /dev/null
@@ -0,0 +1,752 @@
+//******************************************************************
+//
+// Copyright 2016 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "JniNotificationProvider.h"
+#include "NSProviderService.h"
+
+static JavaVM *g_jvm = NULL;
+
+static jobject g_obj_subscriptionListener = NULL;
+static jobject g_obj_syncListener = NULL;
+
+jclass g_cls_Message;
+jclass g_cls_Message_Type;
+jclass g_cls_Consumer;
+jclass g_cls_SyncInfo;
+jclass g_cls_SyncType;
+jclass g_cls_MediaContents;
+
+static JNIEnv *GetJNIEnv(jint *ret)
+{
+    JNIEnv *env = NULL;
+
+    *ret = g_jvm->GetEnv((void **) &env, JNI_CURRENT_VERSION);
+    switch (*ret)
+    {
+        case JNI_OK:
+            return env;
+        case JNI_EDETACHED:
+            if (g_jvm->AttachCurrentThread(&env, NULL) != JNI_OK)
+            {
+                LOGE ("Failed to get the environment");
+                return NULL;
+            }
+            else
+            {
+                return env;
+            }
+        case JNI_EVERSION:
+            LOGE ("JNI version is not supported");
+        default:
+            LOGE ("Failed to get the environment");
+            return NULL;
+    }
+}
+
+void onSubscribeListenerCb(OIC::Service::NSConsumer *consumer)
+{
+    LOGI("JNIProviderService_onSubscribeListenerCb - IN");
+
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(&envRet);
+    if (NULL == env) return ;
+
+    jobject jSubscriptionListener = (jobject) env->NewLocalRef(g_obj_subscriptionListener);
+    if (!jSubscriptionListener)
+    {
+        LOGE ("Failed to Get jSubscriptionListener");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    LOGI("consumer ID : %s\n", consumer->getConsumerId().c_str());
+
+    jstring jConsumerId = env->NewStringUTF( consumer->getConsumerId().c_str());
+
+    jclass cls_consumer = (jclass) (env->NewLocalRef(g_cls_Consumer));
+    if (!cls_consumer)
+    {
+        LOGE ("Failed to Get ObjectClass for Consumer");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    jmethodID mid_consumer = env->GetMethodID(
+                                 cls_consumer,
+                                 "<init>",
+                                 "(JLjava/lang/String;Lorg/iotivity/service/ns/provider/Consumer)V");
+    if (!mid_consumer)
+    {
+        LOGE ("Failed to Get MethodID for Consumer<init>");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+    jobject obj_consumer = env->NewObject( cls_consumer, mid_consumer, jConsumerId);
+
+    jclass cls = env->GetObjectClass( jSubscriptionListener);
+    if (!cls)
+    {
+        LOGE("Failed to Get ObjectClass of jSubscriptionListener");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jmethodID mid = env->GetMethodID(
+                        cls,
+                        "onConsumerSubscribed",
+                        "(Lorg/iotivity/service/ns/provider/Consumer;)V");
+    if (!mid)
+    {
+        LOGE("Failed to Get MethodID of onConsumerSubscribed");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    env->CallVoidMethod( jSubscriptionListener, mid, obj_consumer);
+    env->DeleteLocalRef(jSubscriptionListener);
+    env->DeleteLocalRef(cls_consumer);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    LOGI("JNIProviderService_onSubscribeListenerCb - OUT");
+    return;
+}
+
+void onSyncInfoListenerCb(OIC::Service::NSSyncInfo *sync)
+{
+    LOGI("JNIProviderService_onSyncInfoListenerCb - IN");
+
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(&envRet);
+    if (NULL == env) return ;
+
+    jobject jSyncListener = (jobject) env->NewLocalRef(g_obj_syncListener);
+    if (!jSyncListener)
+    {
+        LOGE ("Failed to Get jSyncListener");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    LOGI("Sync ID : %ld\n", (long) sync->getMessageId());
+    LOGI("Sync STATE : %d\n", (int) sync->getState());
+
+    jlong jMessageId = (long)  sync->getMessageId();
+    jstring jProviderId = env->NewStringUTF(sync->getProviderId().c_str());
+    jobject syncType;
+
+    jclass cls_SyncType = (jclass) (env->NewLocalRef(g_cls_SyncType));
+    if (!cls_SyncType)
+    {
+        LOGE ("Failed to Get ObjectClass for SyncType");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+    switch (sync->getState())
+    {
+        case OIC::Service::NSSyncInfo::NSSyncType::NS_SYNC_UNREAD:
+            {
+                static jfieldID fieldID = env->GetStaticFieldID(cls_SyncType,
+                                          "UNREAD", "Lorg/iotivity/service/ns/common/SyncInfo$SyncType;");
+                syncType = env->GetStaticObjectField(cls_SyncType, fieldID);
+            }
+        case OIC::Service::NSSyncInfo::NSSyncType::NS_SYNC_READ :
+            {
+                static jfieldID fieldID = env->GetStaticFieldID(cls_SyncType,
+                                          "READ", "Lorg/iotivity/service/ns/common/SyncInfo$SyncType;");
+                syncType = env->GetStaticObjectField(cls_SyncType, fieldID);
+            }
+        case OIC::Service::NSSyncInfo::NSSyncType::NS_SYNC_DELETED :
+            {
+                static jfieldID fieldID = env->GetStaticFieldID(cls_SyncType,
+                                          "DELETED", "Lorg/iotivity/service/ns/common/SyncInfo$SyncType;");
+                syncType = env->GetStaticObjectField(cls_SyncType, fieldID);
+            }
+
+    }
+
+    jclass cls_SyncInfo = (jclass) (env->NewLocalRef(g_cls_SyncInfo));
+    if (!cls_SyncInfo)
+    {
+        LOGE ("Failed to Get ObjectClass for SyncInfo");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+    jmethodID mid_syncInfo = env->GetMethodID(
+                                 cls_SyncInfo,
+                                 "<init>",
+                                 "(JLjava/lang/String;Lorg/iotivity/service/ns/common/SyncInfo$SyncType)V");
+    if (!mid_syncInfo)
+    {
+        LOGE ("Failed to Get MethodID for SyncInfo");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    jobject obj_syncInfo = env->NewObject( cls_SyncInfo, mid_syncInfo, jMessageId, jProviderId,
+                                           syncType);
+
+    jclass cls = env->GetObjectClass( jSyncListener);
+    if (!cls)
+    {
+        LOGE("Failed to Get ObjectClass");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jmethodID mid = env->GetMethodID( cls, "onMessageSynchronized",
+                                      "(Lorg/iotivity/service/ns/common/SyncInfo)V");
+    if (!mid)
+    {
+        LOGE("Failed to Get MethodID");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    env->CallVoidMethod( jSyncListener, mid, obj_syncInfo);
+
+    env->DeleteLocalRef(jSyncListener);
+    env->DeleteLocalRef(cls_SyncInfo);
+    env->DeleteLocalRef(cls_SyncType);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+
+    LOGI("JNIProviderService: OnSyncInfoListenerCb - OUT");
+    return;
+
+}
+
+OIC::Service::NSMessage *getMessage(JNIEnv *env, jobject jMsg)
+{
+    LOGI("JNIProviderService: getMessage - IN");
+
+    jclass cls = env->GetObjectClass( jMsg);
+
+    // Message type
+    jclass cls_messageType = (jclass) (env->NewLocalRef(g_cls_Message_Type));
+    if (!cls_messageType)
+    {
+        LOGE ("Failed to Get ObjectClass for Message Type");
+        return nullptr;
+    }
+    jmethodID mid = env->GetMethodID(cls_messageType, "ordinal", "()I");
+    jfieldID fid_type = env->GetFieldID( cls, "mType",
+                                         "Lorg/iotivity/service/ns/common/Message$MessageType;");
+    if (fid_type == NULL)
+    {
+        LOGE("Error: jfieldID for message type  is null");
+        return nullptr;
+    }
+    jobject jobj = env->GetObjectField( jMsg, fid_type);
+    if (jobj == NULL)
+    {
+        LOGE("Error: object of field  Message Type is null");
+        return nullptr;
+    }
+    jint jtype = env->CallIntMethod(jobj, mid);
+    OIC::Service::NSMessage::NSMessageType  type = (OIC::Service::NSMessage::NSMessageType) jtype;
+
+    LOGI("Message Type: %ld\n", (long )type);
+
+    // Message Time
+    jfieldID fid_tm = env->GetFieldID( cls, "mTime", "Ljava/lang/String;");
+    if (fid_tm == NULL)
+    {
+        LOGE("Error: jfieldID for message time is null");
+        return nullptr;
+    }
+    jstring jtime = (jstring)env->GetObjectField( jMsg, fid_tm);
+    const char *time = "";
+    if (jtime)
+    {
+        time = env->GetStringUTFChars( jtime, NULL);
+    }
+    else
+    {
+        LOGI("Info: messageTitle is null");
+    }
+    LOGI("Message Time: %s\n", time);
+
+    // Message TTL
+    jfieldID fid_ttl = env->GetFieldID( cls, "mTTL", "J");
+    if (fid_ttl == NULL)
+    {
+        LOGE("Error: jfieldID for message ttl is null");
+        return nullptr;
+    }
+    jlong jttl = (jlong) env->GetObjectField( jMsg, fid_ttl);
+    uint64_t  ttl = jttl;
+
+    LOGI("Message ID: %lld\n", ttl);
+
+    // Message Title
+    jfieldID fid_title = env->GetFieldID( cls, "mTitle", "Ljava/lang/String;");
+    if (fid_title == NULL)
+    {
+        LOGE("Error: jfieldID for message title is null");
+        return nullptr;
+    }
+    jstring jmsgTitle = (jstring)env->GetObjectField( jMsg, fid_title);
+    const char *messageTitle = "";
+    if (jmsgTitle)
+    {
+        messageTitle = env->GetStringUTFChars( jmsgTitle, NULL);
+    }
+    else
+    {
+        LOGI("Info: messageTitle is null");
+    }
+    LOGI("Message Title: %s\n", messageTitle);
+
+    // Message Content Text
+    jfieldID fid_body = env->GetFieldID( cls, "mContentText", "Ljava/lang/String;");
+    if (fid_body == NULL)
+    {
+        LOGE("Error: jfieldID for message context Text is null");
+        return nullptr;
+    }
+    jstring jmsgBody = (jstring)env->GetObjectField( jMsg, fid_body);
+    const char *messageBody = "";
+    if (jmsgBody)
+    {
+        messageBody = env->GetStringUTFChars( jmsgBody, NULL);
+    }
+    else
+    {
+        LOGI("Info: messageBody is null");
+    }
+    LOGI("Message Body: %s\n", messageBody);
+
+    // Message Source
+    jfieldID fid_source = env->GetFieldID( cls, "mSourceName", "Ljava/lang/String;");
+    if (fid_source == NULL)
+    {
+        LOGE("Error: jfieldID for message source is null");
+        return nullptr;
+    }
+    jstring jmsgSource = (jstring)env->GetObjectField( jMsg, fid_source);
+    const char *messageSource = "";
+    if (jmsgSource)
+    {
+        messageSource = env->GetStringUTFChars( jmsgSource, NULL);
+    }
+    else
+    {
+        LOGI("Info: messageSource is null");
+    }
+    LOGI("Message Source: %s\n", messageSource);
+
+    // Message MediaContents
+    jfieldID fid_media = env->GetFieldID( cls, "mMediaContents",
+                                          "Lorg/iotivity/service/ns/common/MediaContents;");
+    if (fid_media == NULL)
+    {
+        LOGE("Error: jfieldID for MediaContents is null");
+        return nullptr;
+    }
+    jobject jmedia = env->GetObjectField( jMsg, fid_media);
+    if (jmedia == NULL)
+    {
+        LOGE("Error: jmedia object of MediaContents inside Message is null");
+        return nullptr;
+    }
+    jclass cls_MediaContents = (jclass) (env->NewLocalRef(g_cls_MediaContents));
+    if (!cls_MediaContents)
+    {
+        LOGE ("Failed to Get ObjectClass for class MediaContents");
+        return nullptr;
+    }
+    jfieldID fid_icon = env->GetFieldID( cls_MediaContents, "mIconImage", "Ljava/lang/String;");
+    if (fid_icon == NULL)
+    {
+        LOGE("Error: jfieldID for iconImage is null");
+        return nullptr;
+    }
+    jstring jiconImage = (jstring)env->GetObjectField( jmedia, fid_icon);
+    const char *iconImage = "";
+    if (jiconImage)
+    {
+        iconImage = env->GetStringUTFChars( jiconImage, NULL);
+    }
+    else
+    {
+        LOGI("Info: iconImage is null");
+    }
+
+    LOGI("iconImage: %s\n", iconImage);
+
+    OIC::Service::NSMediaContents *media = new OIC::Service::NSMediaContents(std::string(iconImage));
+    OIC::Service::NSMessage *nsMsg = OIC::Service::NSProviderService::getInstance()->CreateMessage();
+
+    nsMsg->setType(type);
+    nsMsg->setTime(std::string(time));
+    nsMsg->setTTL(ttl);
+    nsMsg->setTitle(std::string(messageTitle));
+    nsMsg->setContentText(std::string(messageBody));
+    nsMsg->setSourceName(std::string(messageSource));
+    nsMsg->setMediaContents(media);
+
+    env->DeleteLocalRef(cls_messageType);
+    env->DeleteLocalRef(cls_MediaContents);
+
+     if (jtime)
+    {
+        env->ReleaseStringUTFChars(jtime, time);
+    }
+     if (jmsgTitle)
+    {
+        env->ReleaseStringUTFChars(jmsgTitle, messageTitle);
+    }
+     if (jmsgBody)
+    {
+        env->ReleaseStringUTFChars(jmsgBody, messageBody);
+    }
+     if (jmsgSource)
+    {
+        env->ReleaseStringUTFChars(jmsgSource, messageSource);
+    }
+    if (jiconImage)
+    {
+        env->ReleaseStringUTFChars(jiconImage, iconImage);
+    }
+
+    LOGI("JNIProviderService: getMessage - OUT");
+    return nsMsg;
+
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart(
+    JNIEnv *env, jobject jObj, jboolean jPolicy, jobject jSubscriptionListener,
+    jobject jSyncListener)
+{
+    LOGI("JNIProviderService: nativeStart - IN");
+    if (!jSubscriptionListener || !jSyncListener)
+    {
+        LOGE("Fail to set listeners");
+        ThrowNSException(NS_ERROR, "Listener cannot be null");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    if (g_obj_subscriptionListener != NULL)
+    {
+        env->DeleteGlobalRef(g_obj_subscriptionListener);
+    }
+    if (g_obj_syncListener != NULL)
+    {
+        env->DeleteGlobalRef(g_obj_syncListener);
+    }
+
+    g_obj_subscriptionListener = (jobject)  env->NewGlobalRef(jSubscriptionListener);
+    g_obj_syncListener = (jobject)  env->NewGlobalRef(jSyncListener);
+
+    // check access policy
+
+    OIC::Service::NSProviderService::ProviderConfig cfg;
+    cfg.m_subscribeRequestCb =  onSubscribeListenerCb;
+    cfg.m_syncInfoCb =  onSyncInfoListenerCb;
+    cfg.policy = (bool) jPolicy;
+
+    OIC::Service::Result result = OIC::Service::NSProviderService::getInstance()->Start(cfg);
+    if (result != OIC::Service::Result::OK)
+    {
+        LOGE("Fail to start NSProviderService");
+
+    }
+
+    LOGI("JNIProviderService: nativeStart - OUT");
+    return (jint) result;
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop(
+    JNIEnv *env, jobject jObj)
+{
+    LOGI("JNIProviderService: nativeStop - IN");
+
+    OIC::Service::Result result = OIC::Service::NSProviderService::getInstance()->Stop();
+    if (result !=  OIC::Service::Result::OK)
+    {
+        LOGI("Fail to stop NSProvider service");
+        return (jint) result;
+    }
+
+    env->DeleteGlobalRef( g_obj_subscriptionListener);
+    env->DeleteGlobalRef( g_obj_syncListener);
+    g_obj_subscriptionListener = NULL;
+    g_obj_syncListener = NULL;
+
+    LOGI("JNIProviderService: nativeStop - OUT");
+    return (jint) result;
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage(
+    JNIEnv *env, jobject jObj, jobject jMsg)
+{
+    LOGI("JNIProviderService: nativeSendMessage - IN");
+    if (!jMsg)
+    {
+        LOGI("Fail to send notification - Message is null");
+        ThrowNSException(NS_ERROR, "Message cannot be null");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+    OIC::Service::NSMessage *nsMsg = getMessage(env, jMsg);
+    if (nsMsg == nullptr)
+    {
+        ThrowNSException(NS_ERROR, "Message didn't have a field ID ");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    OIC::Service::Result result = OIC::Service::NSProviderService::getInstance()->SendMessage(nsMsg);
+    if (result !=  OIC::Service::Result::OK)
+    {
+        LOGI("Fail to send NSProvider Message");
+    }
+    LOGI("JNIProviderService: nativeSendMessage - OUT");
+    return (jint) result;
+}
+
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendSyncInfo(
+    JNIEnv *env, jobject jObj, jlong messageId , jint syncState)
+{
+    LOGI("JNIProviderService: nativeSendSyncInfo - IN");
+    OIC::Service::NSProviderService::getInstance()->SendSyncInfo( messageId,
+            (OIC::Service::NSSyncInfo::NSSyncType) syncState);
+    LOGI("JNIProviderService: nativeSendSyncInfo - OUT");
+    return;
+}
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeEnableRemoteService(JNIEnv *env,
+        jobject jObj, jstring jstr)
+{
+    LOGI("JNIProviderService: nativeEnableRemoteService - IN");
+    if (!jstr)
+    {
+        ThrowNSException(NS_ERROR, "Server Address Can't be NULL");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    const char *address = env->GetStringUTFChars( jstr, NULL);
+    std::string servAddress(address);
+    OIC::Service::Result result  = OIC::Service::NSProviderService::getInstance()->EnableRemoteService(
+                                       servAddress);
+    if (result !=  OIC::Service::Result::OK)
+    {
+        LOGE("Fail to Enable Remote Service");
+    }
+    env->ReleaseStringUTFChars(jstr, address);
+    LOGI("JNIProviderService: nativeEnableRemoteService - OUT");
+    return (jint) result;
+}
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeDisableRemoteService(JNIEnv *env,
+        jobject jObj, jstring jstr)
+{
+    LOGI("JNIProviderService: nativeDisableRemoteService - IN");
+    if (!jstr)
+    {
+        ThrowNSException(NS_ERROR, "Server Address Can't be NULL");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    const char *address = env->GetStringUTFChars( jstr, NULL);
+    std::string servAddress(address);
+    OIC::Service::Result result  = OIC::Service::NSProviderService::getInstance()->DisableRemoteService(
+                                       servAddress);
+    if (result !=  OIC::Service::Result::OK)
+    {
+        LOGE("Fail to Disable Remote Service");
+    }
+    env->ReleaseStringUTFChars(jstr, address);
+    LOGI("JNIProviderService: nativeDisableRemoteService - OUT");
+    return (jint) result;
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription(
+    JNIEnv *env,
+    jobject jObj, jobject jConsumer, jboolean jAccepted)
+{
+    LOGD("JNIProviderService: nativeAcceptSubscription - IN");
+
+    jclass consumerClass =  env->GetObjectClass( jConsumer);
+    if (!consumerClass)
+    {
+        ThrowNSException(NS_ERROR, "Failed to Get ObjectClass for Consumer");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    // Consumer ID
+    jfieldID fid_id =  env->GetFieldID(consumerClass, "mConsumerId",  "Ljava/lang/String;");
+    if (fid_id == NULL)
+    {
+        LOGE("Error: jfieldID for mConsumerId  is null");
+        ThrowNSException(NS_ERROR, "ConsumerId not found");
+        return (jint) OIC::Service::Result::ERROR;
+    }
+
+    jstring jconId = (jstring)env->GetObjectField( jConsumer, fid_id);
+    const char *conId = "";
+    if (conId)
+    {
+        conId = env->GetStringUTFChars( jconId, NULL);
+    }
+    else
+    {
+        LOGI("Info: Consumer Id  is null");
+    }
+    std::string consumerId(conId);
+    env->ReleaseStringUTFChars(jconId, conId);
+
+    LOGI("Consumer ID: %s\n", consumerId.c_str());
+
+    OIC::Service::NSConsumer *consumer = new OIC::Service::NSConsumer(consumerId);
+    int result =  consumer->acceptSubscription(consumer,  (bool)jAccepted);
+    if (jAccepted)
+    {
+        LOGI("Subscription Accepted");
+    }
+    else
+    {
+        LOGI("Subscription Denied");
+    }
+
+    LOGD("JNIProviderService: nativeAcceptSubscription - OUT");
+    return result;
+}
+
+// JNI OnLoad
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
+{
+    LOGD("ProviderService_JNI_OnLoad");
+    g_jvm = jvm;
+
+    JNIEnv *env;
+    if (jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return JNI_ERR;
+    }
+
+    jclass localMessage = env->FindClass(
+                              "org/iotivity/service/ns/common/Message");
+    if (!localMessage)
+    {
+        LOGE("Failed to get local Message class");
+        return JNI_ERR;
+    }
+    g_cls_Message = (jclass) (env->NewGlobalRef(localMessage));
+    if (!g_cls_Message)
+    {
+        LOGE("Failed to set Global Message reference");
+        return JNI_ERR;
+    }
+
+    jclass localMessageType = env->FindClass(
+                                  "org/iotivity/service/ns/common/Message$MessageType");
+    if (!localMessageType)
+    {
+        LOGE("Failed to get local Message Type class");
+        return JNI_ERR;
+    }
+    g_cls_Message_Type = (jclass) (env->NewGlobalRef(localMessageType));
+    if (!g_cls_Message_Type)
+    {
+        LOGE("Failed to set Global Message Type reference");
+        return JNI_ERR;
+    }
+
+    jclass localConsumer = env->FindClass(
+                               "org/iotivity/service/ns/provider/Consumer");
+    if (!localConsumer)
+    {
+        LOGE("Failed to get local Provider class");
+        return JNI_ERR;
+    }
+    g_cls_Consumer = (jclass) (env->NewGlobalRef(localConsumer));
+    if (!g_cls_Consumer)
+    {
+        LOGE("Failed to set Global Provider reference");
+        return JNI_ERR;
+    }
+
+    jclass localSyncInfo = env->FindClass(
+                               "org/iotivity/service/ns/common/SyncInfo");
+    if (!localSyncInfo)
+    {
+        LOGE("Failed to get local SyncInfo class");
+        return JNI_ERR;
+    }
+    g_cls_SyncInfo = (jclass) (env->NewGlobalRef(localSyncInfo));
+    if (!g_cls_SyncInfo)
+    {
+        LOGE("Failed to set Global SyncInfo reference");
+        return JNI_ERR;
+    }
+
+    jclass localSyncType = env->FindClass(
+                               "org/iotivity/service/ns/common/SyncInfo$SyncType");
+    if (!localSyncType)
+    {
+        LOGE("Failed to get local SyncType enum");
+        return JNI_ERR;
+    }
+    g_cls_SyncType = (jclass) (env->NewGlobalRef(localSyncType));
+    if (!g_cls_SyncType)
+    {
+        LOGE("Failed to set Global SyncType reference");
+        return JNI_ERR;
+    }
+
+    jclass localMediaContents = env->FindClass(
+                                    "org/iotivity/service/ns/common/MediaContents");
+    if (!localMediaContents)
+    {
+        LOGE("Failed to get local MediaContents class");
+        return JNI_ERR;
+    }
+    g_cls_MediaContents = (jclass) (env->NewGlobalRef(localMediaContents));
+    if (!g_cls_MediaContents)
+    {
+        LOGE("Failed to set Global MediaContents reference");
+        return JNI_ERR;
+    }
+
+    env->DeleteLocalRef(localMessage);
+    env->DeleteLocalRef(localMessageType);
+    env->DeleteLocalRef(localConsumer);
+    env->DeleteLocalRef(localSyncInfo);
+    env->DeleteLocalRef(localSyncType);
+    env->DeleteLocalRef(localMediaContents);
+
+    return NSExceptionInit(env);
+}
+
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *jvm, void *reserved)
+{
+    LOGI("ProviderService_JNI_OnUnload");
+    JNIEnv *env;
+
+    if (jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return ;
+    }
+
+    env->DeleteGlobalRef(g_cls_Message);
+    env->DeleteGlobalRef(g_cls_Consumer);
+    env->DeleteGlobalRef(g_cls_SyncInfo);
+    env->DeleteGlobalRef(g_cls_SyncType);
+    env->DeleteGlobalRef(g_cls_MediaContents);
+    env->DeleteGlobalRef(g_cls_Message_Type);
+}
diff --git a/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.h b/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.h
new file mode 100644 (file)
index 0000000..694edfc
--- /dev/null
@@ -0,0 +1,94 @@
+//******************************************************************
+//
+// Copyright 2016 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "JniNotificationCommon.h"
+
+#ifndef JNI_NOTIFICATION_PROVIDER_H
+#define JNI_NOTIFICATION_PROVIDER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeStart
+ * Signature: (ZLorg/iotivity/service/ns/provider/ProviderService/OnSubscriptionListener;Lorg/iotivity/service/ns/provider/ProviderService/OnSyncInfoListener;)I
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart
+(JNIEnv *, jobject, jboolean, jobject, jobject);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeStop
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop
+(JNIEnv *, jobject);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeSendMessage
+ * Signature: (Lorg/iotivity/service/ns/common/Message;)I
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage
+(JNIEnv *, jobject, jobject);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeSendSyncInfo
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendSyncInfo
+(JNIEnv *, jobject, jlong, jint);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeEnableRemoteService
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeEnableRemoteService
+(JNIEnv *, jobject, jstring);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_ProviderService
+ * Method:    nativeDisableRemoteService
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeDisableRemoteService
+(JNIEnv *, jobject, jstring);
+
+/*
+ * Class:     org_iotivity_service_ns_provider_Consumer
+ * Method:    nativeAcceptSubscription
+ * Signature: (Lorg/iotivity/service/ns/provider/Consumer;Z)I
+ */
+JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription
+(JNIEnv *, jobject, jobject, jboolean);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/.name b/service/notification/examples/android/NotiProviderExample/.idea/.name
deleted file mode 100644 (file)
index 28684b4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-NotiProviderExample
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/compiler.xml b/service/notification/examples/android/NotiProviderExample/.idea/compiler.xml
deleted file mode 100644 (file)
index 96cc43e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="CompilerConfiguration">
-    <resourceExtensions />
-    <wildcardResourcePatterns>
-      <entry name="!?*.java" />
-      <entry name="!?*.form" />
-      <entry name="!?*.class" />
-      <entry name="!?*.groovy" />
-      <entry name="!?*.scala" />
-      <entry name="!?*.flex" />
-      <entry name="!?*.kt" />
-      <entry name="!?*.clj" />
-      <entry name="!?*.aj" />
-    </wildcardResourcePatterns>
-    <annotationProcessing>
-      <profile default="true" name="Default" enabled="false">
-        <processorPath useClasspath="true" />
-      </profile>
-    </annotationProcessing>
-  </component>
-</project>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/copyright/profiles_settings.xml b/service/notification/examples/android/NotiProviderExample/.idea/copyright/profiles_settings.xml
deleted file mode 100644 (file)
index e7bedf3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="CopyrightManager">
-  <settings default="" />
-</component>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/gradle.xml b/service/notification/examples/android/NotiProviderExample/.idea/gradle.xml
deleted file mode 100644 (file)
index 5dd336e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="GradleSettings">
-    <option name="linkedExternalProjectsSettings">
-      <GradleProjectSettings>
-        <option name="distributionType" value="DEFAULT_WRAPPED" />
-        <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="gradleJvm" value="1.8" />
-        <option name="modules">
-          <set>
-            <option value="$PROJECT_DIR$" />
-            <option value="$PROJECT_DIR$/app" />
-            <option value="$PROJECT_DIR$/iotivity-armeabi-notification-service-release" />
-            <option value="$PROJECT_DIR$/iotivity-base-armeabi-release" />
-          </set>
-        </option>
-      </GradleProjectSettings>
-    </option>
-  </component>
-</project>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/Project_Default.xml b/service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644 (file)
index a950918..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <profile version="1.0">
-    <option name="myName" value="Project Default" />
-    <inspection_tool class="AndroidLintHandlerLeak" enabled="false" level="WARNING" enabled_by_default="false" />
-  </profile>
-</component>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/profiles_settings.xml b/service/notification/examples/android/NotiProviderExample/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644 (file)
index 3b31283..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <settings>
-    <option name="PROJECT_PROFILE" value="Project Default" />
-    <option name="USE_PROJECT_PROFILE" value="true" />
-    <version value="1.0" />
-  </settings>
-</component>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/misc.xml b/service/notification/examples/android/NotiProviderExample/.idea/misc.xml
deleted file mode 100644 (file)
index 5d19981..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="EntryPointsManager">
-    <entry_points version="2.0" />
-  </component>
-  <component name="NullableNotNullManager">
-    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
-    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
-    <option name="myNullables">
-      <value>
-        <list size="4">
-          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
-          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
-          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
-          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
-        </list>
-      </value>
-    </option>
-    <option name="myNotNulls">
-      <value>
-        <list size="4">
-          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
-          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
-          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
-          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
-        </list>
-      </value>
-    </option>
-  </component>
-  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
-    <OptionsSetting value="true" id="Add" />
-    <OptionsSetting value="true" id="Remove" />
-    <OptionsSetting value="true" id="Checkout" />
-    <OptionsSetting value="true" id="Update" />
-    <OptionsSetting value="true" id="Status" />
-    <OptionsSetting value="true" id="Edit" />
-    <ConfirmationsSetting value="0" id="Add" />
-    <ConfirmationsSetting value="0" id="Remove" />
-  </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
-    <output url="file://$PROJECT_DIR$/build/classes" />
-  </component>
-  <component name="ProjectType">
-    <option name="id" value="Android" />
-  </component>
-</project>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/modules.xml b/service/notification/examples/android/NotiProviderExample/.idea/modules.xml
deleted file mode 100644 (file)
index 20c9fec..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectModuleManager">
-    <modules>
-      <module fileurl="file://$PROJECT_DIR$/NotiProviderExample.iml" filepath="$PROJECT_DIR$/NotiProviderExample.iml" />
-      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
-      <module fileurl="file://$PROJECT_DIR$/iotivity-armeabi-notification-service-debug/iotivity-armeabi-notification-service-debug.iml" filepath="$PROJECT_DIR$/iotivity-armeabi-notification-service-debug/iotivity-armeabi-notification-service-debug.iml" />
-      <module fileurl="file://$PROJECT_DIR$/iotivity-armeabi-notification-service-release/iotivity-armeabi-notification-service-release.iml" filepath="$PROJECT_DIR$/iotivity-armeabi-notification-service-release/iotivity-armeabi-notification-service-release.iml" />
-      <module fileurl="file://$PROJECT_DIR$/iotivity-base-armeabi-debug/iotivity-base-armeabi-debug.iml" filepath="$PROJECT_DIR$/iotivity-base-armeabi-debug/iotivity-base-armeabi-debug.iml" />
-      <module fileurl="file://$PROJECT_DIR$/iotivity-base-armeabi-release/iotivity-base-armeabi-release.iml" filepath="$PROJECT_DIR$/iotivity-base-armeabi-release/iotivity-base-armeabi-release.iml" />
-    </modules>
-  </component>
-</project>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/runConfigurations.xml b/service/notification/examples/android/NotiProviderExample/.idea/runConfigurations.xml
deleted file mode 100644 (file)
index 7f68460..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="RunConfigurationProducerService">
-    <option name="ignoredProducers">
-      <set>
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
-      </set>
-    </option>
-  </component>
-</project>
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/.idea/vcs.xml b/service/notification/examples/android/NotiProviderExample/.idea/vcs.xml
deleted file mode 100644 (file)
index b082f7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="VcsDirectoryMappings">
-    <mapping directory="$PROJECT_DIR$/../../../../../../.." vcs="Git" />
-  </component>
-</project>
\ No newline at end of file
index 79f0bf3..c20792d 100644 (file)
@@ -6,7 +6,7 @@ android {
 \r
     defaultConfig {\r
         applicationId "sample.notification.service.iotivity.org.notificationsample"\r
-        minSdkVersion 23\r
+        minSdkVersion 21\r
         targetSdkVersion 23\r
         versionCode 1\r
         versionName "1.0"\r
@@ -16,6 +16,6 @@ android {
 dependencies {\r
     compile fileTree(include: ['*.jar'], dir: 'libs')\r
     compile 'com.android.support:appcompat-v7:23.0.1'\r
-    compile project(':iotivity-base-armeabi-release')\r
-    compile project(':iotivity-armeabi-notification-service-release')\r
+    compile project(':iotivity-armeabi-notification-service-debug')\r
+    compile project(':iotivity-base-armeabi-debug')\r
 }\r
index fc9998e..b2772bb 100755 (executable)
@@ -1,23 +1,23 @@
 /*\r
- *******************************************************************\r
- *\r
- * Copyright 2015 Intel Corporation.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 package com.sec.notiproviderexample;\r
@@ -25,6 +25,7 @@ package com.sec.notiproviderexample;
 import android.app.Notification;\r
 import android.app.NotificationManager;\r
 import android.content.Intent;\r
+import android.content.SyncInfo;\r
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.os.Message;\r
@@ -36,6 +37,7 @@ import android.widget.EditText;
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 \r
+import org.iotivity.service.ns.common.MediaContents;\r
 public class MainActivity extends AppCompatActivity {\r
 \r
     private final String TAG = "NS_MAIN_ACTIVITY";\r
@@ -157,8 +159,8 @@ public class MainActivity extends AppCompatActivity {
 \r
                         TvLog.setText("Start NS-Provider\n");\r
 \r
-                        boolean access = true; // ptovider controls the acceptance of consumers\r
-                        mProviderProxy.startNotificationServer(access);\r
+                        boolean policy = true; // provider controls the acceptance of consumers\r
+                        mProviderProxy.Start(policy);\r
                         isStarted = true;\r
                     } else {\r
                         Log.e(TAG, "NS Provider Service had already started");\r
@@ -172,7 +174,6 @@ public class MainActivity extends AppCompatActivity {
                         Log.e(TAG, "Fail to request Accept");\r
                         break;\r
                     }\r
-                    mProviderProxy.accept("#consumerid", true);\r
                 }\r
                 break;\r
 \r
@@ -201,6 +202,12 @@ public class MainActivity extends AppCompatActivity {
                     Log.i(TAG, "#" + notiId + " notified ..");\r
                     TvLog.append("Send Notitication(Msg ID: " + notiId + ")\n");\r
                     notiId++;\r
+                    org.iotivity.service.ns.common.Message notiMessage = new org.iotivity.service.ns.common.Message(title,body,"dss");\r
+                    notiMessage.setTTL(10);\r
+                    notiMessage.setTime("12:10");\r
+                    MediaContents media = new MediaContents("daasd");\r
+                    notiMessage.setMediaContents(media);\r
+                    mProviderProxy.SendMessage(notiMessage);\r
                 }\r
                 break;\r
 \r
@@ -210,7 +217,8 @@ public class MainActivity extends AppCompatActivity {
                         Log.e(TAG, "Fail to send sync");\r
                         break;\r
                     }\r
-                    //mProviderProxy.readCheck(LastMessageId);\r
+                    org.iotivity.service.ns.common.SyncInfo.SyncType syncType =  org.iotivity.service.ns.common.SyncInfo.SyncType.READ;\r
+                    mProviderProxy.SendSyncInfo(1,syncType);\r
                 }\r
                 break;\r
 \r
@@ -221,7 +229,7 @@ public class MainActivity extends AppCompatActivity {
                         break;\r
                     }\r
 \r
-                    mProviderProxy.stopNotificationServer();\r
+                    mProviderProxy.Stop();\r
                     isStarted = false;\r
 \r
                     TvLog.append("Stop NS-Provider\n");\r
index 4492799..d68560b 100755 (executable)
@@ -1,32 +1,35 @@
 /*\r
- *******************************************************************\r
- *\r
- * Copyright 2015 Intel Corporation.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 package com.sec.notiproviderexample;\r
 \r
 import android.app.Notification;\r
+import android.content.SyncInfo;\r
 import android.os.Bundle;\r
 import android.service.notification.NotificationListenerService;\r
 import android.service.notification.StatusBarNotification;\r
 import android.util.Log;\r
+import org.iotivity.service.ns.common.MediaContents;\r
+import org.iotivity.service.ns.common.Message;\r
 import java.util.ArrayList;\r
 \r
 public class NotiListener extends NotificationListenerService {\r
@@ -103,8 +106,13 @@ public class NotiListener extends NotificationListenerService {
         Log.i(TAG, "Title : " + title);\r
         Log.i(TAG, "Body : " + body);\r
 \r
+        Message notiMessage = new Message(title,body,source);\r
+        notiMessage.setTTL(10);\r
+        notiMessage.setTime("12:10");\r
+        MediaContents media = new MediaContents("daasd");\r
+        notiMessage.setMediaContents(media);\r
         if (mProviderProxy != null) {\r
-            mProviderProxy.sendNSMessage(id, title, body, source);\r
+            mProviderProxy.SendMessage(notiMessage);\r
         } else {\r
             Log.i(TAG, "providerExample is NULL");\r
         }\r
@@ -126,7 +134,8 @@ public class NotiListener extends NotificationListenerService {
         {\r
             if(mProviderProxy.getMsgMap().get(sbn.getId()) == 2)\r
             {\r
-                mProviderProxy.readCheck(Integer.toString(sbn.getId()));\r
+                org.iotivity.service.ns.common.SyncInfo.SyncType type = org.iotivity.service.ns.common.SyncInfo.SyncType.READ;\r
+                mProviderProxy.SendSyncInfo(1,type);\r
             }\r
         }\r
     }\r
index 9e72f9c..789afe1 100755 (executable)
@@ -1,31 +1,29 @@
 /*\r
- *******************************************************************\r
- *\r
- * Copyright 2015 Intel Corporation.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 package com.sec.notiproviderexample;\r
 \r
-import android.app.NotificationManager;\r
 import android.content.Context;\r
 import android.os.Handler;\r
-import android.os.Message;\r
 import android.util.Log;\r
 import android.widget.Toast;\r
 \r
@@ -35,20 +33,20 @@ import org.iotivity.base.OcResourceHandle;
 import org.iotivity.base.PlatformConfig;\r
 import org.iotivity.base.QualityOfService;\r
 import org.iotivity.base.ServiceType;\r
-import org.iotivity.service.ns.IoTNotification;\r
-import org.iotivity.service.ns.NSConsumer;\r
-import org.iotivity.service.ns.NSMessage;\r
+import org.iotivity.service.ns.provider.*;\r
+import org.iotivity.service.ns.common.*;\r
+\r
 \r
 import java.util.HashMap;\r
 \r
 public class ProviderProxy\r
-        implements IoTNotification.NSSubscriptionListner, IoTNotification.NSSynchListner{\r
+        implements ProviderService.OnSubscriptionListener, ProviderService.OnSyncInfoListener{\r
 \r
     private static final String TAG = "NS_PROVIDER_PROXY";\r
 \r
     private Context mContext = null;\r
     private OcResourceHandle mResourceHandle;   //resource handle\r
-    private IoTNotification ioTNotification = null;\r
+    private ProviderService ioTNotification = null;\r
     private HashMap<String, Integer> msgMap;\r
 \r
     private Handler mHandler = null;\r
@@ -65,7 +63,7 @@ public class ProviderProxy
 \r
         this.msgMap = new HashMap<>();\r
         this.mContext = context;\r
-        ioTNotification = new IoTNotification();\r
+        ioTNotification =  ProviderService.getInstance();\r
     }\r
 \r
     public void setHandler(Handler handler)\r
@@ -94,32 +92,51 @@ public class ProviderProxy
         Log.i(TAG, "Configuration done Successfully");\r
     }\r
 \r
-    public void startNotificationServer(boolean access)\r
+    public void Start(boolean policy)\r
     {\r
+        Log.i(TAG, "Start ProviderService -IN");\r
         configurePlatform();\r
-        ioTNotification.NSStartProvider(access, this, this);\r
-    }\r
+        try{\r
+            int result =  ioTNotification.Start(policy, this, this);\r
+            Log.i(TAG, "Notification Start: " + result);\r
+        }\r
+        catch(Exception e){\r
+\r
+        }\r
 \r
-    public void stopNotificationServer() {\r
+        Log.i(TAG, "Start ProviderService - OUT");\r
+    }\r
 \r
+    public void Stop() {\r
+        Log.i(TAG, "Stop ProviderService - IN");\r
         try {\r
             OcPlatform.stopPresence();\r
         } catch (Exception e) {\r
             Log.e(TAG, "Exception: stopping presence when terminating NS server: " + e);\r
         }\r
+        try{\r
+            int result =  ioTNotification.Stop();\r
+            Log.i(TAG, "Notification Stop: " + result);\r
+        }\r
+        catch(Exception e){\r
+\r
+        }\r
 \r
-        ioTNotification.NSStopProvider();\r
+        Log.i(TAG, "Stop ProviderService - OUT");\r
     }\r
 \r
-    public void sendNSMessage(String id, String title, String body, String source) {\r
+    public void SendMessage(Message notiMessage) {\r
+        Log.i(TAG, "SendMessage ProviderService - IN");\r
+\r
+        try{\r
+            int result =  ioTNotification.SendMessage(notiMessage);\r
+            Log.i(TAG, "Notification Send Message: " + result);\r
+        }\r
+        catch(Exception e){\r
 \r
-        NSMessage notiMessage = new NSMessage(id);\r
-        notiMessage.setTitle(title);\r
-        notiMessage.setBody(body);\r
-        notiMessage.setSource(source);\r
-        msgMap.put(id, SYNC_UNREAD);\r
-        ioTNotification.NSSendNotification(notiMessage);\r
+        }\r
 \r
+        Log.i(TAG, "SendMessage ProviderService - OUT");\r
         mHandler.post(new Runnable() {\r
             @Override\r
             public void run() {\r
@@ -128,56 +145,71 @@ public class ProviderProxy
         });\r
     }\r
 \r
-    public void readCheck(String messageId) {\r
+    public void SendSyncInfo(long messageId, SyncInfo.SyncType syncType) {\r
+        Log.i(TAG, "SendSyncInfo ProviderService - IN");\r
         if(msgMap.containsKey(messageId)) {\r
             if(msgMap.get(messageId) == SYNC_UNREAD)\r
             {\r
-                NSMessage notiMessage = new NSMessage(messageId);\r
-                ioTNotification.NSProviderReadCheck(notiMessage);\r
-                msgMap.put(messageId, SYNC_READ);\r
+                try{\r
+                    ioTNotification.SendSyncInfo(messageId,syncType );\r
+                    Log.i(TAG, "Notification Sync " );\r
+                }\r
+                catch(Exception e) {\r
+\r
+                }\r
+                Log.i(TAG, "SendSyncInfo ProviderService - OUT");\r
+                msgMap.put("ID: "+messageId, SYNC_READ);\r
             }\r
         }\r
     }\r
 \r
-    public void accept(String consumerId, boolean accepted)\r
-    {\r
-        NSConsumer consumer = new NSConsumer(consumerId);\r
-        ioTNotification.NSAccept(consumer, accepted);\r
+    public void EnableRemoteService(String servAdd) {\r
+        Log.i(TAG, "EnableRemoteService ProviderService - IN");\r
+        try{\r
+            int result = ioTNotification.EnableRemoteService(servAdd);\r
+            Log.i(TAG, "Notification EnableRemoteService: "+ result );\r
+        }\r
+        catch(Exception e) {\r
+\r
+        }\r
+        Log.i(TAG, "EnableRemoteService ProviderService - OUT");\r
     }\r
 \r
-    @Override\r
-    public void OnNSSubscribedEvent(String consumerId) {\r
-        Log.i(TAG, "OnNSSubscribedEvent");\r
+    public void DisableRemoteService(String servAdd) {\r
+        Log.i(TAG, "DisableRemoteService ProviderService - IN");\r
+        try{\r
+            int result = ioTNotification.DisableRemoteService(servAdd);\r
+            Log.i(TAG, "Notification DisableRemoteService: "+ result );\r
+        }\r
+        catch(Exception e) {\r
 \r
-        Log.i(TAG, "Consumer: " + consumerId);\r
-        Message msg = mHandler.obtainMessage(MESSAGE_SUBSCRIPTION, consumerId);\r
-        mHandler.sendMessage(msg);\r
+        }\r
+        Log.i(TAG, "DisableRemoteService ProviderService - OUT");\r
     }\r
 \r
-    @Override\r
-    public void OnNSSynchronizedEvent(String messageId, int syncState) {\r
-        Log.i(TAG, "OnNSSynchronizedEvent");\r
-\r
-        Log.i(TAG, "Message Id: " + messageId);\r
-        Log.i(TAG, "Sync state: " + syncState);\r
+    public void AcceptSubscription(Consumer consumer, boolean accepted)\r
+    {\r
+        Log.i(TAG,"AcceptSubscription ProviderService - IN");\r
+        try{\r
+            int result = consumer.AcceptSubscription(consumer, accepted);\r
+            Log.i(TAG, "Notification AcceptSubscription: "+result );\r
+        }\r
+        catch(Exception e) {\r
 \r
-        Message msg = mHandler.obtainMessage(MESSAGE_SYNC, messageId + " / Sync State: " + syncState);\r
-        mHandler.sendMessage(msg);\r
+        }\r
+        Log.i(TAG, "AcceptSubscription ProviderService - OUT");\r
+    }\r
 \r
-        NotificationManager manager = (NotificationManager)mContext\r
-                .getSystemService(Context.NOTIFICATION_SERVICE);\r
+    @Override\r
+    public void onConsumerSubscribed(Consumer consumer) {\r
+        Log.i(TAG, "onConsumerSubscribed - IN");\r
+        AcceptSubscription(consumer, true);\r
+        Log.i(TAG, "onConsumerSubscribed - OUT");\r
+    }\r
 \r
-        if(messageId != null)\r
-            try\r
-            {\r
-                manager.cancel(Integer.valueOf(messageId));\r
-            }\r
-            catch (Exception e)\r
-            {\r
-                Log.e(TAG, "Handle exception for invalid message id" + e);\r
-            }\r
-        else\r
-            Log.i(TAG, "message id is null");\r
+    @Override\r
+    public void onMessageSynchronized(SyncInfo syncInfo) {\r
+        Log.i(TAG, "Received SyncInfo with messageID: "+syncInfo.getMessageId());\r
     }\r
 \r
     public HashMap<String, Integer> getMsgMap() {\r
diff --git a/service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-debug/build.gradle b/service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-debug/build.gradle
new file mode 100644 (file)
index 0000000..305a7ec
--- /dev/null
@@ -0,0 +1,2 @@
+configurations.create("default")
+artifacts.add("default", file('iotivity-base-armeabi-debug.aar'))
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-release/build.gradle b/service/notification/examples/android/NotiProviderExample/iotivity-base-armeabi-release/build.gradle
deleted file mode 100644 (file)
index 44cd131..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-configurations.create("default")
-artifacts.add("default", file('iotivity-base-armeabi-release.aar'))
\ No newline at end of file
index 1d296f6..36fd2b5 100644 (file)
@@ -1 +1 @@
-include ':app', ':iotivity-armeabi-notification-service-release', ':iotivity-base-armeabi-release'\r
+include ':app', ':iotivity-armeabi-notification-service-debug', ':iotivity-base-armeabi-debug'\r