Implementation for Direct Pairing Android Interface API and Sample App.
authorSandeep Sharma <sandeep.s9@samsung.com>
Mon, 23 May 2016 09:33:33 +0000 (15:03 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 24 Jun 2016 08:46:34 +0000 (08:46 +0000)
1. Android Interface API's for direct Pairing feature.
2. Android Sample App for Direct Pairing.

[patch #2]
Commnts fixes.
Add Support for direct Pair provisioning in ProvsioningClient Android sample
app.

[Patch #3]
Build Fix.

[Patch #4]
Review comments addressed.

Change-Id: I09572eb8cb54f7cd122c6eb224ac2abbcb1ec530
Signed-off-by: Sandeep Sharma <sandeep.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8281
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashwini Kumar <k.ashwini@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
53 files changed:
android/android_api/base/jni/Android.mk
android/android_api/base/jni/JniOcDirectPairDevice.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcDirectPairDevice.h [new file with mode: 0644]
android/android_api/base/jni/JniOcPlatform.cpp
android/android_api/base/jni/JniOcPlatform.h
android/android_api/base/jni/JniOcSecureResource.cpp
android/android_api/base/jni/JniOcSecureResource.h
android/android_api/base/jni/JniOcStack.cpp
android/android_api/base/jni/JniOcStack.h
android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDPDevicesFoundListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnDirectPairingListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDirectPairingListener.h [new file with mode: 0644]
android/android_api/base/jni/JniProvisionResultListner.cpp
android/android_api/base/jni/JniProvisionResultListner.h
android/android_api/base/jni/JniSecureUtils.cpp
android/android_api/base/jni/JniSecureUtils.h
android/android_api/base/src/main/java/org/iotivity/base/OcDirectPairDevice.java [new file with mode: 0644]
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcPrmType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcSecureResource.java
android/android_api/base/src/main/java/org/iotivity/base/OicSecPdAcl.java [new file with mode: 0644]
android/examples/DirectPairing/.classpath [new file with mode: 0644]
android/examples/DirectPairing/.project [new file with mode: 0644]
android/examples/DirectPairing/DirectPairing.iml [new file with mode: 0644]
android/examples/DirectPairing/build.gradle [new file with mode: 0644]
android/examples/DirectPairing/project.properties [new file with mode: 0644]
android/examples/DirectPairing/src/main/AndroidManifest.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/assets/oic_svr_db_client_directpairing.dat [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/ExpandableListAdapter.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/Led.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/MainActivity.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/StringConstants.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_down.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_right.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-mdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-xxhdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/activity_main.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/custom_list_view.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/group_indicator.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/list_group.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/list_item.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/menu/main.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-v11/styles.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-v14/styles.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-w820dp/dimens.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/dimens.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/strings.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/styles.xml [new file with mode: 0644]
android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java
android/examples/settings.gradle

index cc43275..a513cb1 100644 (file)
@@ -58,7 +58,7 @@ LOCAL_SRC_FILES :=  JniOcStack.cpp \
                     JniEntityHandler.cpp \\r
                     JniOnResourceFoundListener.cpp \\r
                     JniOnDeviceInfoListener.cpp \\r
-                   JniOnPlatformInfoListener.cpp \\r
+                    JniOnPlatformInfoListener.cpp \\r
                     JniOnPresenceListener.cpp \\r
                     JniOnGetListener.cpp \\r
                     JniOnPutListener.cpp \\r
@@ -74,15 +74,18 @@ LOCAL_SRC_FILES :=  JniOcStack.cpp \
                     JniOcPlatform.cpp \\r
                     JniOcResource.cpp \\r
                     JniOcResourceIdentifier.cpp \\r
-                    JniOcSecurity.cpp\r
+                    JniOcSecurity.cpp \\r
+                    JniOnDPDevicesFoundListener.cpp \\r
+                    JniOnDirectPairingListener.cpp \\r
+                    JniOcDirectPairDevice.cpp\r
 ifeq ($(SECURED), 1)\r
-LOCAL_SRC_FILES +=  JniOcSecureResource.cpp \\r
-                    JniOcProvisioning.cpp \\r
-                    JniSecureUtils.cpp \\r
-                    JniProvisionResultListner.cpp \\r
-                    JniPinCheckListener.cpp \\r
-                    JniDisplayPinListener.cpp\r
-endif\r
+    LOCAL_SRC_FILES +=  JniOcSecureResource.cpp \\r
+                        JniOcProvisioning.cpp \\r
+                        JniSecureUtils.cpp \\r
+                        JniProvisionResultListner.cpp \\r
+                        JniPinCheckListener.cpp \\r
+                        JniDisplayPinListener.cpp\r
+                        endif\r
 \r
 LOCAL_LDLIBS := -llog\r
 LOCAL_STATIC_LIBRARIES := android-oc\r
diff --git a/android/android_api/base/jni/JniOcDirectPairDevice.cpp b/android/android_api/base/jni/JniOcDirectPairDevice.cpp
new file mode 100644 (file)
index 0000000..535bebc
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+* //******************************************************************
+* //
+* // 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 "JniOcDirectPairDevice.h"
+#include "OCDirectPairing.h"
+#include "OCDirectPairing.h"
+using namespace OC;
+namespace PH = std::placeholders;
+
+JniOcDirectPairDevice::JniOcDirectPairDevice(std::shared_ptr<OC::OCDirectPairing> directPairingDevice)
+    : m_sharedDirectPairDevice(directPairingDevice)
+{}
+
+JniOcDirectPairDevice::~JniOcDirectPairDevice()
+{
+    LOGD("~JniOcDirectPairDevice()");
+    m_sharedDirectPairDevice = nullptr;
+}
+
+std::string JniOcDirectPairDevice::getHost()
+{
+   return m_sharedDirectPairDevice->getHost();
+}
+
+std::vector<OCPrm_t> JniOcDirectPairDevice::getPairingMethods()
+{
+
+   return m_sharedDirectPairDevice->getPairingMethods();
+}
+
+OCConnectivityType JniOcDirectPairDevice::connectivityType()
+{
+    return m_sharedDirectPairDevice->getConnType();
+}
+
+JniOcDirectPairDevice* JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(JNIEnv *env, jobject thiz)
+{
+    JniOcDirectPairDevice *dpDev = GetHandle<JniOcDirectPairDevice>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcDirectPairingDevice");
+    }
+    if (!dpDev)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return dpDev;
+}
+std::shared_ptr<OC::OCDirectPairing> JniOcDirectPairDevice::getPtr()
+{
+    return m_sharedDirectPairDevice;
+}
+
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcDirectPairDevice_getHost
+(JNIEnv *env, jobject thiz)
+{
+
+    LOGD("OcDirectPairing_getHost");
+
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device) return nullptr;
+
+    std::string dev  = device->getHost();
+    return env->NewStringUTF(dev.c_str());
+}
+
+JNIEXPORT jintArray JNICALL Java_org_iotivity_base_OcDirectPairDevice_getPairingMethods
+        (JNIEnv *env, jobject thiz)
+{
+
+    LOGD("OcDirectPairing_getPairingMethods");
+
+    std::vector<jint> pairingMethodList;
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device) return nullptr;
+
+    std::vector<OCPrm_t> pairingMethods = device->getPairingMethods();
+    return JniOcDirectPairDevice::JconvertIntVectorToJavaList(env,pairingMethods);
+}
+
+
+jintArray JniOcDirectPairDevice::JconvertIntVectorToJavaList(JNIEnv *env, std::vector<OCPrm_t> &vector)
+{
+
+    jsize len = static_cast<jsize>(vector.size());
+
+    jintArray intArray = env->NewIntArray(len);
+    if (!intArray) return nullptr;
+
+    env->SetIntArrayRegion(intArray, (jsize)0, len, (const jint*)&vector[0]);
+
+    if (env->ExceptionCheck())
+    {
+        LOGE("ArrayIndexOutOfBoundsException in  JconvertIntVectorToJavaList");
+    }
+    return intArray;
+}
+
+/*
+* Class:     org_iotivity_base_OcDirectPairDevice
+* Method:    getConnectivityTypeN
+* Signature: ()I
+*/
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcDirectPairDevice_getConnectivityTypeN
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcDirectPairDevice_getConnectivityType");
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device) return -1;
+
+    OCConnectivityType connectivityType = device->connectivityType();
+    return static_cast<jint>(connectivityType);
+}
diff --git a/android/android_api/base/jni/JniOcDirectPairDevice.h b/android/android_api/base/jni/JniOcDirectPairDevice.h
new file mode 100644 (file)
index 0000000..505bac2
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+* //******************************************************************
+* //
+* // 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 "JniOcStack.h"
+#include "JniOnDPDevicesFoundListener.h"
+#include "OCDirectPairing.h"
+#include <mutex>
+
+#ifndef _Included_org_iotivity_base_OcDirectPairDevice
+#define _Included_org_iotivity_base_OcDirectPairDevice
+
+using namespace OC;
+
+class JniOcDirectPairDevice
+{
+    public:
+        JniOcDirectPairDevice(std::shared_ptr<OCDirectPairing> directPairingDevice);
+        ~JniOcDirectPairDevice();
+
+        static JniOcDirectPairDevice* getJniOcDirectPairDevicePtr(JNIEnv *env, jobject thiz);
+        static jintArray JconvertIntVectorToJavaList(JNIEnv *env, std::vector<OCPrm_t> &vector);
+
+        std::shared_ptr<OCDirectPairing> getPtr();
+        std::string getHost();
+        std::vector<OCPrm_t> getPairingMethods();
+        OCConnectivityType connectivityType();
+
+    private:
+          std::shared_ptr<OCDirectPairing> m_sharedDirectPairDevice;
+};
+
+/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    getDirectPairedDevices
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcDirectPairDevice_getDirectPairedDevices
+        (JNIEnv *, jobject, jobject);
+
+   /*
+    * Class:     org_iotivity_base_OcDirectPairDevice
+    * Method:    getHost
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcDirectPairDevice_getHost
+        (JNIEnv *, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    getPairingMethods
+     * Signature: ()Ljava/util/List;
+     */
+    JNIEXPORT jintArray JNICALL Java_org_iotivity_base_OcDirectPairDevice_getPairingMethods
+        (JNIEnv *, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    doDirectPairing
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+     *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcDirectPairDevice_doDirectPairing
+        (JNIEnv *, jobject, jobject, jint, jstring, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcDirectPairDevice
+    * Method:    getConnectivityTypeN
+    * Signature: ()I
+    */
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcDirectPairDevice_getConnectivityTypeN
+        (JNIEnv *env, jobject thiz);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
index 8987a69..82f693f 100644 (file)
@@ -25,6 +25,7 @@
 #include "JniOcPresenceHandle.h"
 #include "JniOcResourceResponse.h"
 #include "JniOcSecurity.h"
+#include "JniOcDirectPairDevice.h"
 #include "JniUtils.h"
 #include "ocpayload.h"
 
@@ -321,6 +322,148 @@ void RemoveOnPresenceListener(JNIEnv* env, jobject jListener)
     presenceMapLock.unlock();
 }
 
+JniOnDPDevicesFoundListener* AddOnDPDevicesFoundListener(JNIEnv* env, jobject jListener)
+{
+    JniOnDPDevicesFoundListener *onDPDeviceListener = nullptr;
+
+    dpDevicesFoundListenerMapLock.lock();
+
+    for (auto it = onDPDevicesFoundListenerMap.begin(); it !=
+            onDPDevicesFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onDPDeviceListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            onDPDevicesFoundListenerMap.insert(*it);
+            LOGD("onDPDeviceListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!onDPDeviceListener)
+    {
+        onDPDeviceListener = new JniOnDPDevicesFoundListener(env, jListener,
+                RemoveOnDPDevicesFoundListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+        onDPDevicesFoundListenerMap.insert(
+                std::pair<jobject, std::pair<JniOnDPDevicesFoundListener*, int>>(
+                    jgListener,
+                    std::pair<JniOnDPDevicesFoundListener*, int>(onDPDeviceListener, 1)));
+        LOGI("onDPDeviceListener: new listener");
+    }
+    dpDevicesFoundListenerMapLock.unlock();
+    return onDPDeviceListener;
+}
+
+void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener)
+{
+    dpDevicesFoundListenerMapLock.lock();
+    bool isFound = false;
+    for (auto it = onDPDevicesFoundListenerMap.begin(); it !=
+            onDPDevicesFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                onDPDevicesFoundListenerMap.insert(*it);
+                LOGI("onDPDeviceListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnDPDevicesFoundListener* listener = refPair.first;
+                delete listener;
+                onDPDevicesFoundListenerMap.erase(it);
+                LOGI("onDPDeviceListener is removed");
+            }
+            isFound = true;
+            break;
+        }
+    }
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "onDPDeviceListener not found");
+    }
+    dpDevicesFoundListenerMapLock.unlock();
+}
+
+JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener)
+{
+    JniOnDirectPairingListener *onDirectPairingListener = nullptr;
+
+    directPairingListenerMapLock.lock();
+
+    for (auto it = directPairingListenerMap.begin(); it !=
+            directPairingListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onDirectPairingListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            directPairingListenerMap.insert(*it);
+            LOGD("onDirectPairingListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!onDirectPairingListener)
+    {
+        onDirectPairingListener = new JniOnDirectPairingListener(env, jListener,
+                RemoveOnDirectPairingListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+        directPairingListenerMap.insert(
+                std::pair<jobject, std::pair<JniOnDirectPairingListener*, int>>(
+                    jgListener,
+                    std::pair<JniOnDirectPairingListener*, int>(onDirectPairingListener, 1)));
+        LOGI("onDirectPairingListener: new listener");
+    }
+    directPairingListenerMapLock.unlock();
+    return onDirectPairingListener;
+}
+
+void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener)
+{
+    directPairingListenerMapLock.lock();
+    bool isFound = false;
+    for (auto it = directPairingListenerMap.begin(); it !=
+            directPairingListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                directPairingListenerMap.insert(*it);
+                LOGI("onDirectPairingListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnDirectPairingListener* listener = refPair.first;
+                delete listener;
+                directPairingListenerMap.erase(it);
+                LOGI("onDirectPairingListener is removed");
+            }
+            isFound = true;
+            break;
+        }
+    }
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "onDirectPairingListener not found");
+    }
+    directPairingListenerMapLock.unlock();
+}
+
 /*
 * Class:     org_iotivity_base_OcPlatform
 * Method:    configure
@@ -704,6 +847,145 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1(
 }
 
 /*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    findDirectPairingDevices
+ * Signature: (ILorg/iotivity/base/OcPlatform/FindDirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
+  (JNIEnv * env, jclass clazz, jint jTimeout, jobject jListener)
+{
+    LOGD("OcPlatform_findDirectPairingDevices");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDPDevicesFoundListener cannot be null");
+        return;
+    }
+    JniOnDPDevicesFoundListener *onDPDevsFoundListener = AddOnDPDevicesFoundListener(env,
+            jListener);
+
+    GetDirectPairedCallback getDirectPairedCallback =
+        [onDPDevsFoundListener](PairedDevices pairingDevList)
+        {
+            onDPDevsFoundListener->directPairingDevicesCallback(pairingDevList,
+                    DPFunc::FIND_DIRECT_PAIRED_DEV_LIST);
+        };
+
+    try
+    {
+        OCStackResult result = OCPlatform::findDirectPairingDevices(jTimeout,
+                getDirectPairedCallback);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OCPlatform::findDirectPairingDevices has failed");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    getDirectPairedDevices
+ * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
+(JNIEnv *env, jclass jclazz, jobject jListener)
+{
+    LOGD("OcPlatform_getDirectPairedDevices");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "getPairedDevList Callback cannot be null");
+        return;
+    }
+    JniOnDPDevicesFoundListener *onGetPairedDevicesListener = AddOnDPDevicesFoundListener(env,
+            jListener);
+
+    GetDirectPairedCallback getDirectPairedCallback =
+        [onGetPairedDevicesListener](PairedDevices pairedDevList)
+        {
+            onGetPairedDevicesListener->directPairingDevicesCallback(pairedDevList,
+                    DPFunc::GET_PAIRED_DEV_LIST);
+        };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getDirectPairedDevices(getDirectPairedCallback);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcDirectPairDevice_getDirectPairedDevices");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    doDirectPairing
+ * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+ *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
+(JNIEnv *env, jclass clazz, jobject jpeer, jint jprmType, jstring jpin, jobject jListener)
+{
+    LOGD("OcPlatform_doDirectPairing");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "doDirectPairing Callback cannot be null");
+        return;
+    }
+    if (!jpeer)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Peer cannot be null");
+        return;
+    }
+
+    JniOnDirectPairingListener *onDirectPairingListener = AddOnDirectPairingListener(env,
+            jListener);
+
+    DirectPairingCallback DirectPairingCB =
+        [onDirectPairingListener](std::shared_ptr<OCDirectPairing> dpDev, OCStackResult result)
+        {
+            onDirectPairingListener->doDirectPairingCB(dpDev, result);
+        };
+
+    JniOcDirectPairDevice *dev = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env, jpeer);
+
+    if (!dev)
+    {
+        return ;
+    }
+    std::string pin = env->GetStringUTFChars(jpin, 0);
+
+    try
+    {
+        OCStackResult result = OCPlatform::doDirectPairing(dev->getPtr(), (OCPrm_t)jprmType,
+                pin, DirectPairingCB);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcPlatform_oDirectPairing");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
 * Class:     org_iotivity_base_OcPlatform
 * Method:    getDeviceInfo0
 * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V
index c66ad43..a45f059 100644 (file)
@@ -23,6 +23,8 @@
 #include "JniOnResourceFoundListener.h"
 #include "JniOnDeviceInfoListener.h"
 #include "JniOnPlatformInfoListener.h"
+#include "JniOnDPDevicesFoundListener.h"
+#include "JniOnDirectPairingListener.h"
 #include "JniOnPresenceListener.h"
 #include <mutex>
 
@@ -43,15 +45,26 @@ void RemoveOnPlatformInfoListener(JNIEnv* env, jobject jListener);
 JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);
 void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);
 
+JniOnDPDevicesFoundListener* AddOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
+void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
+
+JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener);
+void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener);
+
+
 std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;
 std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;
 std::map<jobject, std::pair<JniOnPlatformInfoListener*, int>> onPlatformInfoListenerMap;
 std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;
+std::map<jobject, std::pair<JniOnDPDevicesFoundListener*, int>> onDPDevicesFoundListenerMap;
+std::map<jobject, std::pair<JniOnDirectPairingListener*, int>> directPairingListenerMap;
 
 std::mutex resourceFoundMapLock;
 std::mutex deviceInfoMapLock;
 std::mutex platformInfoMapLock;
 std::mutex presenceMapLock;
+std::mutex dpDevicesFoundListenerMapLock;
+std::mutex directPairingListenerMapLock;
 
 #ifdef __cplusplus
 extern "C" {
@@ -288,6 +301,30 @@ extern "C" {
     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0
         (JNIEnv *, jclass, jobject);
 
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    findDirectPairingDevices
+     * Signature: (ILorg/iotivity/base/OcPlatform/FindDirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
+        (JNIEnv *, jclass, jint, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    getDirectPairedDevices
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
+        (JNIEnv *, jclass, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    doDirectPairing
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+     *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
+        (JNIEnv *, jclass, jobject, jint, jstring, jobject);
 #ifdef __cplusplus
 }
 #endif
index 77c8dc6..f1cd7f9 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "JniOcSecureResource.h"
 #include "JniSecureUtils.h"
+#include "oic_string.h"
 namespace PH = std::placeholders;
 
 JniOcSecureResource::JniOcSecureResource(std::shared_ptr<OCSecureResource> device)
@@ -240,6 +241,89 @@ OCStackResult JniOcSecureResource::provisionACL(JNIEnv* env, jobject _acl, jobje
     return ret;
 }
 
+OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectArray jpdacls,
+        jobject jListener, std::string pin, std::vector<int> prms, int edp)
+{
+    OCStackResult ret;
+    JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener);
+
+    jsize len = env->GetArrayLength(jpdacls);
+
+    OicSecPconf_t *pconf = nullptr;
+    OicSecPdAcl_t *head = nullptr;
+
+    for (jsize i = 0; i < len; ++i)
+    {
+        OicSecPdAcl_t *pdacl = new OicSecPdAcl_t;
+        if (!pdacl)
+        {
+            return OC_STACK_NO_MEMORY;
+        }
+
+        memset(pdacl, 0, sizeof(OicSecPdAcl_t));
+        pdacl->next = nullptr;
+
+        jobject jpdacl  = env->GetObjectArrayElement(jpdacls, i);
+
+        if (OC_STACK_OK != JniSecureUtils::convertJavaPdACLToOCAcl(env, jpdacl, pdacl))
+        {
+            delete pdacl;
+            return OC_STACK_ERROR;
+        }
+
+        pdacl->next = head;
+        head = pdacl;
+    }
+
+    pconf = new OicSecPconf_t;
+    memset(pconf, 0, sizeof(OicSecPconf_t));
+    pconf->edp = edp;
+    pconf->prmLen = prms.size();
+    pconf->prm = new OicSecPrm_t[pconf->prmLen];
+    pconf->pddevLen = 0;
+
+    for (int i = 0 ; i < prms.size(); i++)
+        pconf->prm[i] = (OicSecPrm_t)prms[i];
+
+    memcpy(pconf->pin.val, pin.c_str(), DP_PIN_LENGTH);
+    pconf->pdacls = head;
+
+    ResultCallBack resultCallback = [head, resultListener, pconf, prms]
+        (PMResultList_t *result, int hasError)
+        {
+            OicSecPdAcl_t *tmp1, *tmp2;
+            tmp1 = head;
+            while (tmp1)
+            {
+                tmp2 = tmp1->next;
+                delete tmp1;
+                tmp1 = tmp2;
+            }
+
+            delete pconf->prm;
+            delete pconf;
+            resultListener->ProvisionResultCallback(result, hasError, ListenerFunc::PROVISIONDIRECTPAIRING);
+        };
+
+    ret = m_sharedSecureResource->provisionDirectPairing(pconf, resultCallback);
+
+    if (ret != OC_STACK_OK)
+    {
+        OicSecPdAcl_t *tmp1, *tmp2;
+        tmp1 = head;
+        while (tmp1)
+        {
+            tmp2 = tmp1->next;
+            delete tmp1;
+            tmp1 = tmp2;
+        }
+
+        delete pconf->prm;
+        delete pconf;
+    }
+    return ret;
+}
+
 OCStackResult JniOcSecureResource::provisionPairwiseDevices(JNIEnv* env, jint type, jint keySize,
         jobject _acl1, jobject _device2, jobject _acl2, jobject jListener)
 {
@@ -543,6 +627,55 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionPairwise
 
 /*
  * Class:     org_iotivity_base_OcSecureResource
+ * Method:    provisionDirectPairing
+ * Signature: (Ljava/lang/String;[Lorg/iotivity/base/OicSecPdAcl;ILorg/iotivity/base/OcSecureResource/ProvisionDirectPairingListener;I)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionDirectPairing
+(JNIEnv *env, jobject thiz, jstring jpin, jobjectArray pdacls, jintArray jprmType,
+    jint jedp, jobject jListener)
+{
+    LOGD("OcSecureResource_provisionDirectPairing");
+    if (!jListener || !pdacls || !jpin || ! jprmType)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Invalid Parameters");
+        return;
+    }
+    std::string pin = env->GetStringUTFChars(jpin, nullptr);
+
+    JniOcSecureResource *secureResource = JniOcSecureResource::getJniOcSecureResourcePtr(env, thiz);
+    if (!secureResource)
+    {
+        return;
+    }
+
+    const jsize len = env->GetArrayLength(jprmType);
+    jint* ints = env->GetIntArrayElements(jprmType, nullptr);
+    std::vector<int> value;
+    for (jsize i = 0; i < len; ++i)
+    {
+        value.push_back(static_cast<int>(ints[i]));
+    }
+    env->ReleaseIntArrayElements(jprmType, ints, JNI_ABORT);
+
+    try
+    {
+        OCStackResult result = secureResource->provisionDirectPairing(env, pdacls, jListener,
+                pin, value, static_cast<int>(jedp));
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcSecureResource_provisionDirectPairing");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+ * Class:     org_iotivity_base_OcSecureResource
  * Method:    getLinkedDevices
  * Signature: ()Ljava/util/List;
  */
index 0b98f75..d071e96 100644 (file)
@@ -55,7 +55,8 @@ class JniOcSecureResource
                 jobject device2, jobject jListener);
         OCStackResult unlinkDevices(JNIEnv* env, jobject device2, jobject jListener);
         OCStackResult removeDevice(JNIEnv* env, jint timeout, jobject jListener);
-
+        OCStackResult provisionDirectPairing(JNIEnv* env, jobjectArray jpdacls,jobject jListener,
+                std::string pin, std::vector<int> prms, int edp);
     private:
 
         std::map<jobject, std::pair<JniProvisionResultListner*, int>> resultMap;
@@ -118,6 +119,14 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionPairwise
 
 /*
  * Class:     org_iotivity_base_OcSecureResource
+ * Method:    provisionDirectPairing
+ * Signature: (Ljava/lang/Object;Lorg/iotivity/base/OcSecureResource/ProvisionDirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionDirectPairing
+  (JNIEnv *, jobject, jstring, jobjectArray, jintArray, jint, jobject);
+
+/*
+ * Class:     org_iotivity_base_OcSecureResource
  * Method:    getLinkedDevices
  * Signature: ()Ljava/util/List;
  */
index c5c3d7d..86e00bb 100644 (file)
@@ -62,6 +62,8 @@ jclass g_cls_OcResourceIdentifier = nullptr;
 jclass g_cls_OcProvisionResult = nullptr;
 jclass g_cls_OcSecureResource = nullptr;
 jclass g_cls_OcOicSecAcl = nullptr;
+jclass g_cls_OcOicSecPdAcl = nullptr;
+jclass g_cls_OcDirectPairDevice = nullptr;
 
 jmethodID g_mid_Integer_ctor = nullptr;
 jmethodID g_mid_Double_ctor = nullptr;
@@ -94,6 +96,8 @@ jmethodID g_mid_OcPresenceStatus_get = nullptr;
 jmethodID g_mid_OcResourceIdentifier_N_ctor = nullptr;
 jmethodID g_mid_OcProvisionResult_ctor = nullptr;
 jmethodID g_mid_OcSecureResource_ctor = nullptr;
+jmethodID g_mid_OcDirectPairDevice_ctor = nullptr;
+jmethodID g_mid_OcDirectPairDevice_dev_ctor = nullptr;
 
 jmethodID g_mid_OcOicSecAcl_get_subject = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_resources_cnt = nullptr;
@@ -103,6 +107,12 @@ jmethodID g_mid_OcOicSecAcl_get_periods_cnt = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_periods = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_recurrences = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_resources_cnt = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_resources = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_permission = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_periods_cnt = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_periods = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_recurrences = nullptr;
 
 jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
     const int line, const int code, const char* message)
@@ -430,6 +440,18 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
     g_mid_OcProvisionResult_ctor = env->GetMethodID(g_cls_OcProvisionResult, "<init>", "(Ljava/lang/String;I)V");
     if (!g_mid_OcProvisionResult_ctor) return JNI_ERR;
 
+    //OcDirectPairDevice
+    clazz = env->FindClass("org/iotivity/base/OcDirectPairDevice");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcDirectPairDevice =  (jclass)env->NewGlobalRef(clazz);
+    //env->DeleteLocalRef(clazz);
+    g_mid_OcDirectPairDevice_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(J)V");
+    if (!g_mid_OcDirectPairDevice_ctor) return JNI_ERR;
+
+    g_mid_OcDirectPairDevice_dev_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(Ljava/lang/String;)V");
+    if (!g_mid_OcDirectPairDevice_dev_ctor) return JNI_ERR;
+    env->DeleteLocalRef(clazz);
+
     //OicSecAcl
     clazz = env->FindClass("org/iotivity/base/OicSecAcl");
     if (!clazz) return JNI_ERR;
@@ -460,6 +482,30 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
     g_mid_OcOicSecAcl_get_rownerID = env->GetMethodID(g_cls_OcOicSecAcl, "getRownerID", "()Ljava/lang/String;");
     if (!g_mid_OcOicSecAcl_get_rownerID) return JNI_ERR;
 
+    //OicSecPdAcl
+    clazz = env->FindClass("org/iotivity/base/OicSecPdAcl");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcOicSecPdAcl =  (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcOicSecPdAcl_get_resources_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResourcesCount", "()I");
+    if (!g_mid_OcOicSecPdAcl_get_resources_cnt) return JNI_ERR;
+
+    g_mid_OcOicSecPdAcl_get_resources = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResources", "(I)Ljava/lang/String;");
+    if (!g_mid_OcOicSecPdAcl_get_resources) return JNI_ERR;
+
+    g_mid_OcOicSecPdAcl_get_permission = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPermission", "()I");
+    if (!g_mid_OcOicSecPdAcl_get_permission) return JNI_ERR;
+
+    g_mid_OcOicSecPdAcl_get_periods_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriodsCount", "()I");
+    if (!g_mid_OcOicSecPdAcl_get_periods_cnt) return JNI_ERR;
+
+    g_mid_OcOicSecPdAcl_get_periods = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriods", "(I)Ljava/lang/String;");
+    if (!g_mid_OcOicSecPdAcl_get_periods) return JNI_ERR;
+
+    g_mid_OcOicSecPdAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecPdAcl, "getRecurrences", "(I)Ljava/lang/String;");
+    if (!g_mid_OcOicSecPdAcl_get_recurrences) return JNI_ERR;
+
     return JNI_CURRENT_VERSION;
 }
 
@@ -509,4 +555,4 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
     env->DeleteGlobalRef(g_cls_OcSecureResource);
     env->DeleteGlobalRef(g_cls_OcProvisionResult);
     env->DeleteGlobalRef(g_cls_OcOicSecAcl);
-}
\ No newline at end of file
+}
index b9f2ccd..bb2de3d 100644 (file)
@@ -82,6 +82,8 @@ extern jclass g_cls_OcResourceIdentifier;
 extern jclass g_cls_OcProvisionResult;
 extern jclass g_cls_OcSecureResource;
 extern jclass g_cls_OcOicSecAcl;
+extern jclass g_cls_OcOicSecPdAcl;
+extern jclass g_cls_OcDirectPairDevice;
 
 extern jmethodID g_mid_Integer_ctor;
 extern jmethodID g_mid_Double_ctor;
@@ -114,6 +116,8 @@ extern jmethodID g_mid_OcPresenceStatus_get;
 extern jmethodID g_mid_OcResourceIdentifier_N_ctor;
 extern jmethodID g_mid_OcProvisionResult_ctor;
 extern jmethodID g_mid_OcSecureResource_ctor;
+extern jmethodID g_mid_OcDirectPairDevice_ctor;
+extern jmethodID g_mid_OcDirectPairDevice_dev_ctor;
 extern jmethodID g_mid_OcOicSecAcl_get_subject;
 extern jmethodID g_mid_OcOicSecAcl_get_resources_cnt;
 extern jmethodID g_mid_OcOicSecAcl_get_resources;
@@ -122,6 +126,12 @@ extern jmethodID g_mid_OcOicSecAcl_get_periods_cnt;
 extern jmethodID g_mid_OcOicSecAcl_get_periods;
 extern jmethodID g_mid_OcOicSecAcl_get_recurrences;
 extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
+extern jmethodID g_mid_OcOicSecPdAcl_get_resources_cnt;
+extern jmethodID g_mid_OcOicSecPdAcl_get_resources;
+extern jmethodID g_mid_OcOicSecPdAcl_get_permission;
+extern jmethodID g_mid_OcOicSecPdAcl_get_periods_cnt;
+extern jmethodID g_mid_OcOicSecPdAcl_get_periods;
+extern jmethodID g_mid_OcOicSecPdAcl_get_recurrences;
 
 typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);
 
diff --git a/android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp b/android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp
new file mode 100644 (file)
index 0000000..5c5d900
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+* //******************************************************************
+* //
+* // 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 "JniOnDPDevicesFoundListener.h"
+#include "JniOcDirectPairDevice.h"
+#include "OCApi.h"
+using namespace OC;
+
+JniOnDPDevicesFoundListener::JniOnDPDevicesFoundListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+jobject JniOnDPDevicesFoundListener::convertdpDevVectorToJavaList(JNIEnv *env, PairedDevices DPdevList)
+{
+    jobject jResultList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
+    if (!jResultList)
+    {
+        return nullptr;
+    }
+
+    for (size_t i = 0; i < DPdevList.size(); ++i)
+    {
+        JniOcDirectPairDevice *device = new JniOcDirectPairDevice(DPdevList.at(i));
+        if (!device)
+        {
+            return nullptr;
+        }
+
+        jstring jStr = env->NewStringUTF(((DPdevList.at(i))->getDeviceID()).c_str());
+        if (!jStr)
+        {
+            return nullptr;
+        }
+        jobject jresult = env->NewObject(g_cls_OcDirectPairDevice,
+                g_mid_OcDirectPairDevice_dev_ctor,jStr);
+        if (!jresult)
+        {
+            return nullptr;
+        }
+
+        SetHandle<JniOcDirectPairDevice>(env, jresult, device);
+
+        env->CallBooleanMethod(jResultList, g_mid_LinkedList_add_object, jresult);
+        if (env->ExceptionCheck())
+        {
+            return nullptr;
+        }
+        env->DeleteLocalRef(jresult);
+        env->DeleteLocalRef(jStr);
+    }
+    return jResultList;
+}
+
+JniOnDPDevicesFoundListener::~JniOnDPDevicesFoundListener()
+{
+    LOGI("~JniOnDPDevicesFoundListener()");
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        m_jwListener = nullptr;
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDPDevicesFoundListener::directPairingDevicesCallback(PairedDevices paringDevicesList, DPFunc func)
+{
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jobject jpairingDevicesList = convertdpDevVectorToJavaList(env, paringDevicesList);
+    std::string calledFunc;
+    switch (func)
+    {
+        case DPFunc::FIND_DIRECT_PAIRED_DEV_LIST:
+            {
+                calledFunc = "onFindDirectPairingListener";
+            }
+            break;
+        case DPFunc::GET_PAIRED_DEV_LIST:
+            {
+                calledFunc = "onGetDirectPairedListener";
+            }
+        default:
+            {
+                checkExAndRemoveListener(env);
+                if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+            }
+            return;
+    }
+
+    jmethodID midL = env->GetMethodID(clsL, calledFunc.c_str(), "(Ljava/util/List;)V");
+
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jpairingDevicesList);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniOnDPDevicesFoundListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniOnDPDevicesFoundListener.h b/android/android_api/base/jni/JniOnDPDevicesFoundListener.h
new file mode 100644 (file)
index 0000000..88acb61
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+* //******************************************************************
+* //
+* // 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 <jni.h>
+#include "OCDirectPairing.h"
+#include "OCApi.h"
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_JniOnDPDevicesFoundListener
+#define _Included_org_iotivity_base_OcPlatform_JniOnDPDevicesFoundListener
+
+enum class DPFunc
+{
+    FIND_DIRECT_PAIRED_DEV_LIST = 1,
+    GET_PAIRED_DEV_LIST,
+};
+
+class JniOnDPDevicesFoundListener
+{
+public:
+    JniOnDPDevicesFoundListener(JNIEnv *env, jobject jListener,
+            RemoveListenerCallback removeListenerCallback);
+    ~JniOnDPDevicesFoundListener();
+
+   jobject convertdpDevVectorToJavaList(JNIEnv *env, OC::PairedDevices DPdevList);
+   void directPairingDevicesCallback(OC::PairedDevices paringDevicesList, DPFunc);
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
diff --git a/android/android_api/base/jni/JniOnDirectPairingListener.cpp b/android/android_api/base/jni/JniOnDirectPairingListener.cpp
new file mode 100644 (file)
index 0000000..f580079
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+* //******************************************************************
+* //
+* // 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 "JniOnDirectPairingListener.h"
+#include "JniOcDirectPairDevice.h"
+#include "OCDirectPairing.h"
+#include "OCApi.h"
+using namespace OC;
+
+JniOnDirectPairingListener::JniOnDirectPairingListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+
+JniOnDirectPairingListener::~JniOnDirectPairingListener()
+{
+    LOGI("~JniOnDirectPairingListener()");
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        m_jwListener = nullptr;
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDirectPairingListener::doDirectPairingCB(std::shared_ptr<OC::OCDirectPairing> dpDev,
+                                                                    OCStackResult result)
+{
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    JniOcDirectPairDevice *device = new JniOcDirectPairDevice(dpDev);
+    if (!device) return;
+
+    jstring jStr = env->NewStringUTF((dpDev->getDeviceID()).c_str());
+    if (!jStr)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    jobject jresult = env->NewObject(g_cls_OcDirectPairDevice, g_mid_OcDirectPairDevice_ctor);
+    if (!jresult)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return ;
+    }
+
+    SetHandle<JniOcDirectPairDevice>(env, jresult, device);
+
+    jint jres = static_cast<jint>(result);
+
+    jmethodID midL = env->GetMethodID(clsL, "onDirectPairingListener", "(Ljava/lang/String;I)V");
+
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jStr, jres);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniOnDirectPairingListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniOnDirectPairingListener.h b/android/android_api/base/jni/JniOnDirectPairingListener.h
new file mode 100644 (file)
index 0000000..8ec2b7e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* //******************************************************************
+* //
+* // 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 <jni.h>
+#include "OCDirectPairing.h"
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_JniOnDirectPairingListener
+#define _Included_org_iotivity_base_OcPlatform_JniOnDirectPairingListener
+
+class JniOnDirectPairingListener
+{
+public:
+    JniOnDirectPairingListener(JNIEnv *env, jobject jListener,
+            RemoveListenerCallback removeListenerCallback);
+    ~JniOnDirectPairingListener();
+
+   void doDirectPairingCB(std::shared_ptr<OC::OCDirectPairing>, OCStackResult);
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
index 6b9fd04..a600e64 100644 (file)
@@ -109,6 +109,11 @@ void JniProvisionResultListner::ProvisionResultCallback(PMResultList_t *result,
             calledFunc = "provisionPairwiseDevicesListener";
         }
         break;
+        case ListenerFunc::PROVISIONDIRECTPAIRING:
+        {
+            calledFunc = "provisionDirectPairingListener";
+        }
+        break;
         default:
         {
             checkExAndRemoveListener(env);
index 6df56d7..8bf5242 100644 (file)
@@ -35,7 +35,8 @@ enum class ListenerFunc
     PROVISIONCREDENTIALS,
     UNLINKDEVICES,
     REMOVEDEVICE,
-    PROVISIONPAIRWISEDEVICES
+    PROVISIONPAIRWISEDEVICES,
+    PROVISIONDIRECTPAIRING
 };
 
 class JniProvisionResultListner
index 24e4f57..8198e49 100644 (file)
@@ -232,3 +232,89 @@ OCStackResult JniSecureUtils::convertJavaACLToOCAcl(JNIEnv *env, jobject in, Oic
 
     return OC_STACK_OK;
 }
+
+OCStackResult JniSecureUtils::convertJavaPdACLToOCAcl(JNIEnv *env, jobject in, OicSecPdAcl_t *pdacl)
+{
+    jstring jData;
+    jvalue args[1];
+
+    jint jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecPdAcl_get_resources_cnt);
+    if (!jCount || env->ExceptionCheck())
+    {
+        return OC_STACK_ERROR;
+    }
+
+    pdacl->resourcesLen = jCount;
+    pdacl->resources = new char*[jCount];
+
+    if (!pdacl->resources)
+    {
+        return OC_STACK_ERROR;
+    }
+    for (jint i = 0; i < jCount; ++i)
+    {
+        args[0].i = i;
+        jData = (jstring) env->CallObjectMethodA(in, g_mid_OcOicSecPdAcl_get_resources, args);
+        if (!jData || env->ExceptionCheck())
+        {
+            return OC_STACK_ERROR;
+        }
+
+        pdacl->resources[i] = (char*) env->GetStringUTFChars(jData, 0);
+    }
+
+    jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecPdAcl_get_permission);
+    if (env->ExceptionCheck())
+    {
+        return OC_STACK_ERROR;
+    }
+
+    pdacl->permission = jCount;
+    jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecPdAcl_get_periods_cnt);
+    if (env->ExceptionCheck())
+    {
+        return OC_STACK_ERROR;
+    }
+
+    pdacl->prdRecrLen = jCount;
+    if (jCount)
+    {
+        pdacl->periods = new char*[jCount];
+        if (!pdacl->periods)
+        {
+            return OC_STACK_ERROR;
+        }
+    }
+    for (jint i = 0; i < jCount; ++i)
+    {
+        args[0].i = i;
+        jData = (jstring) env->CallObjectMethodA(in, g_mid_OcOicSecPdAcl_get_periods, args);
+        if (!jData || env->ExceptionCheck())
+        {
+            return OC_STACK_ERROR;
+        }
+
+        pdacl->periods[i] = (char*) env->GetStringUTFChars(jData, 0);
+    }
+
+    if (jCount)
+    {
+        pdacl->recurrences = new char*[jCount];
+        if (!pdacl->recurrences)
+        {
+            return OC_STACK_ERROR;
+        }
+    }
+    for (jint i = 0; i < jCount; ++i)
+    {
+        args[0].i = i;
+        jData = (jstring) env->CallObjectMethodA(in, g_mid_OcOicSecPdAcl_get_recurrences, args);
+        if (!jData ||  env->ExceptionCheck())
+        {
+            return OC_STACK_ERROR;
+        }
+
+        pdacl->recurrences[i] = (char*) env->GetStringUTFChars(jData, 0);
+    }
+    return OC_STACK_OK;
+}
index c239c44..c7226a5 100644 (file)
@@ -35,4 +35,5 @@ class JniSecureUtils
                 std::vector<std::shared_ptr<OC::OCSecureResource>>& deviceListVector);
         static jobject convertUUIDVectorToJavaStrList(JNIEnv *env, OC::UuidList_t &vector);
         static OCStackResult convertJavaACLToOCAcl(JNIEnv *env, jobject in, OicSecAcl_t *out);
+        static OCStackResult convertJavaPdACLToOCAcl(JNIEnv *env, jobject in, OicSecPdAcl_t *pdacl);
 };
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcDirectPairDevice.java b/android/android_api/base/src/main/java/org/iotivity/base/OcDirectPairDevice.java
new file mode 100644 (file)
index 0000000..aff3238
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base;
+
+import java.util.List;
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+public class OcDirectPairDevice {
+
+
+    private long mNativeHandle;
+    private String mdeviceID;
+    private String mHost;
+
+    private OcDirectPairDevice(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    public OcDirectPairDevice(String deviceID)
+    {
+        this.mdeviceID = deviceID;
+    }
+
+    public String getDevId()
+    {
+        return this.mdeviceID;
+    }
+
+    public native String getHost();
+
+    public List<Integer> getPairingMethodList() {
+        int [] intList = this.getPairingMethods();
+        List<Integer> prmList = new ArrayList<Integer>();
+        for (int i = 0; i < intList.length; i++)
+        {
+            prmList.add(intList[i]);
+        }
+        return  prmList;
+    }
+
+    private native int[] getPairingMethods();
+
+    /**
+     * Method to get the connectivity type of this resource
+     *
+     * @return EnumSet<OcConnectivityType></OcConnectivityType> connectivity type set
+     */
+    public EnumSet<OcConnectivityType> getConnectivityTypeSet() {
+        return OcConnectivityType.convertToEnumSet(
+                this.getConnectivityTypeN()
+        );
+    }
+
+    private native int getConnectivityTypeN();
+
+
+    /**
+     *  Method to get list of all paired devices for a given device.
+     *
+     *  @param GetDirectPairedListener Callback function, which will receive the list of direct paired devices.
+     *  @throws OcException
+     */
+
+    public native void getDirectPairedDevices(GetDirectPairedListener getDirectPairedListener) throws OcException;
+
+    public interface GetDirectPairedListener {
+        public void getDirectPairedListener(List<String> ocPairedDeviceList);
+    }
+
+    /**
+     *  Method to perform direct pairing between two devices.
+     *
+     *  @param DirectPairingListener Callback function, which will be called after
+     *                                      completion of direct pairing.
+     *  @throws OcException
+     */
+    public native void doDirectPairing(OcDirectPairDevice peer,
+            OcPrmType pmSel, String pinNumber,
+            DirectPairingListener directPairingListener) throws OcException;
+
+
+    public interface DirectPairingListener {
+        public void directPairingListener(String devId, int result);
+    }
+
+    @Override
+    public String toString() {
+        return this.mdeviceID;
+    }
+}
index e37838d..fc69e48 100644 (file)
@@ -901,6 +901,81 @@ public final class OcPlatform {
             throws OcException;
 
     /**
+     *  Method to find all devices which are eligible for direct pairing and return the list.
+     *
+     *  @param timeout timeout for discovering direct pair devices.
+     *  @param FindDirectPairingListener Callback function, which will receive the list of direct
+     *                                  pairable devices.
+     *  @throws OcException
+     */
+   public static native void findDirectPairingDevices(int timeout,
+            FindDirectPairingListener onFindDirectPairingListener) throws OcException;
+
+    /**
+     *  Method to get list of all paired devices for a given device.
+     *
+     *  @param GetDirectPairedListener Callback function, which will receive the list of direct
+     *                                 paired devices.
+     *  @throws OcException
+     */
+    public native void getDirectPairedDevices(GetDirectPairedListener onGetDirectPairedListener)
+        throws OcException;
+
+    /**
+     *  Method to perform direct pairing between two devices.
+     *
+     *  @param peer  Target peer
+     *  @param prmType Pairing Method to be used for Pairing
+     *  @param pin pin
+     *  @param DirectPairingListener Callback function, which will be called after
+     *                                      completion of direct pairing.
+     *  @throws OcException
+     */
+    public static void doDirectPairing(
+            OcDirectPairDevice peer,
+            OcPrmType prmType,
+            String pin,
+            DirectPairingListener onDirectPairingListener) throws OcException {
+
+        OcPlatform.doDirectPairing0(
+                peer,
+                prmType.getValue(),
+                pin,
+                onDirectPairingListener
+                );
+    }
+
+    private static native void doDirectPairing0(OcDirectPairDevice peer,
+            int pmSel, String pinNumber, DirectPairingListener onDirectPairingListener)
+    throws OcException;
+
+    /**
+     * An FindDirectPairingListener can be registered via the OcPlatform.findDirectPairingDevices call.
+     * Event listeners are notified asynchronously
+     */
+    public interface FindDirectPairingListener {
+        public void onFindDirectPairingListener(List<OcDirectPairDevice> ocPairedDeviceList);
+    }
+
+    /**
+     * Listerner to Get List of already Direct Paired devices.
+     * An GetDirectPairedListener can be registered via the OcPlatform.getDirectPairedDevices call.
+     * Event listeners are notified asynchronously
+     */
+    public interface GetDirectPairedListener {
+        public void onGetDirectPairedListener(List<OcDirectPairDevice> ocPairedDeviceList);
+    }
+
+    /**
+     * Listner to get result of doDirectPairing.
+     * An DirectPairingListener can be registered via the OcPlatform.doDirectPairing call.
+     * Event listeners are notified asynchronously
+     */
+    public interface DirectPairingListener {
+        public void onDirectPairingListener(String devId, int result);
+    }
+
+    /**
      * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
      * Event listeners are notified asynchronously
      */
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPrmType.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPrmType.java
new file mode 100755 (executable)
index 0000000..2c2b37f
--- /dev/null
@@ -0,0 +1,58 @@
+/*\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
+ * @brief   direct pairing Method Type.\r
+ *              0:  not allowed\r
+ *              1:  pre-configured pin\r
+ *              2:  random pin\r
+ */\r
+package org.iotivity.base;\r
+\r
+public enum OcPrmType {\r
+    DP_INVALID           (-1),\r
+    DP_NOT_ALLOWED       (0),\r
+    DP_PRE_CONFIGURED    (1 << 0),\r
+    DP_RANDOM_PIN        (1 << 1);\r
+\r
+    private int value;\r
+\r
+    private OcPrmType(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+\r
+    public static OcPrmType convertOcPrmType(int value) {\r
+        switch (value)\r
+        {\r
+            case 0:\r
+                return OcPrmType.DP_NOT_ALLOWED;\r
+            case 1:\r
+                return OcPrmType.DP_PRE_CONFIGURED;\r
+            case 2:\r
+                return OcPrmType.DP_RANDOM_PIN;\r
+        }\r
+        return OcPrmType.DP_INVALID;\r
+    }\r
+}\r
index 368eda9..f69b548 100644 (file)
@@ -131,6 +131,46 @@ public class OcSecureResource {
             ProvisionPairwiseDevicesListener provisionPairwiseDevicesListener) throws OcException;
 
     /**
+     *  Method to configure resource for direct pairing
+     *
+     *  @param pin                      pin number
+     *  @param pdacls                   Array of Device Pairing Access Control List
+     *  @param type                     List of supported OcPrmType
+     *  @param edp                      enable (1) / disable (0)
+     *  @param ProvisionDirectPairing   Callback function, which will be called after completion
+     *                                  of Direct Pairing.
+     *  @throws OcException
+     */
+
+    public void doProvisionDirectPairing(String pin, OicSecPdAcl[] pdacls, List<OcPrmType> type,
+            boolean edp , ProvisionDirectPairingListener provisionDirectPairingListener)
+        throws OcException {
+
+            int[] typeArray = new int[type.size()];
+            int i = 0;
+            for (OcPrmType ocPrmType:type) {
+                typeArray[i++] = ocPrmType.getValue();
+            }
+
+            this.provisionDirectPairing(pin, pdacls, typeArray, (edp?1:0),
+                    provisionDirectPairingListener);
+        }
+
+    private native void provisionDirectPairing(String pin, OicSecPdAcl[] pdacls, int[] type,
+            int edp , ProvisionDirectPairingListener provisionDirectPairingListener)
+        throws OcException;
+
+    /**
+     * provisionDirectPairingListener can be registered with doOwnershipTransfer
+     * call.
+     * Listener notified asynchronously.
+     */
+    public interface ProvisionDirectPairingListener {
+        public void provisionDirectPairingListener(List<ProvisionResult> provisionResultList,
+                int hasError);
+    }
+
+    /**
      * doOwnershipTransferListener can be registered with doOwnershipTransfer
      * call.
      * Listener notified asynchronously.
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OicSecPdAcl.java b/android/android_api/base/src/main/java/org/iotivity/base/OicSecPdAcl.java
new file mode 100644 (file)
index 0000000..5768123
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Arrays;
+
+public class OicSecPdAcl implements Serializable {
+
+    private int          mPermission;
+    private List<String> mResources;
+    private List<String> mPeriods;
+    private List<String> mRecurrences;
+
+    public OicSecPdAcl(List<String> recurrences, List<String> periods, int permission,
+            List<String> resources) {
+        this.mRecurrences = recurrences;
+        this.mPeriods = periods;
+        this.mPermission = permission;
+        this.mResources = resources;
+    }
+
+    public List<String> getRecurrences() {
+        return mRecurrences;
+    }
+
+    public void setRecurrences(List<String> recurrences) {
+        this.mRecurrences = recurrences;
+    }
+
+    public List<String> getPeriods() {
+        return mPeriods;
+    }
+
+    public void setPeriods(List<String> periods) {
+        this.mPeriods = periods;
+    }
+
+    public int getPermission() {
+        return this.mPermission;
+    }
+
+    public void setPermission(int permission) {
+        this.mPermission = permission;
+    }
+
+    public List<String> getResources() {
+        return mResources;
+    }
+
+    public void setResources(List<String> resources) {
+        this.mResources = resources;
+    }
+
+    public int getResourcesCount() {
+        return this.mResources.size();
+    }
+
+    public String getResources(int i) {
+        return this.mResources.get(i);
+    }
+
+    public int getPeriodsCount() {
+        return this.mPeriods.size();
+    }
+
+    public String getPeriods(int i) {
+        return this.mPeriods.get(i);
+    }
+
+    public String getRecurrences(int i) {
+        return this.mRecurrences.get(i);
+    }
+}
diff --git a/android/examples/DirectPairing/.classpath b/android/examples/DirectPairing/.classpath
new file mode 100644 (file)
index 0000000..26bdfa6
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="src" path="gen"/>\r
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>\r
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>\r
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>\r
+       <classpathentry kind="output" path="bin/classes"/>\r
+</classpath>\r
diff --git a/android/examples/DirectPairing/.project b/android/examples/DirectPairing/.project
new file mode 100644 (file)
index 0000000..2dadd42
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>Iot</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>com.android.ide.eclipse.adt.ApkBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>com.android.ide.eclipse.adt.AndroidNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/android/examples/DirectPairing/DirectPairing.iml b/android/examples/DirectPairing/DirectPairing.iml
new file mode 100644 (file)
index 0000000..5de258a
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id=":DirectPairing" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":DirectPairing" />
+      </configuration>
+    </facet>
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
+        <option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
+        <afterSyncTasks>
+          <task>generateDebugAndroidTestSources</task>
+          <task>generateDebugSources</task>
+        </afterSyncTasks>
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
+      <excludeFolder url="file://$MODULE_DIR$/build/test-results" />
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" exported="" name="iotivity-base-armeabi-release-" level="project" />
+    <orderEntry type="library" exported="" name="android-android-21" level="project" />
+  </component>
+</module>
diff --git a/android/examples/DirectPairing/build.gradle b/android/examples/DirectPairing/build.gradle
new file mode 100644 (file)
index 0000000..8499e31
--- /dev/null
@@ -0,0 +1,38 @@
+apply plugin: 'com.android.application'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "20.0.0"\r
+\r
+    defaultConfig {\r
+        applicationId "org.iotivity.base.examples.DirectPairing"\r
+        minSdkVersion 21\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+    lintOptions {\r
+        abortOnError false\r
+    }\r
+}\r
+repositories {\r
+    flatDir {\r
+        dirs "../../android_api/base/build/outputs/aar/"\r
+    }\r
+}\r
+\r
+try {\r
+    dependencies {\r
+        compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"\r
+    }\r
+} catch (all) {\r
+    print "${ERROR_MSG}"\r
+    assert all\r
+}\r
+\r
diff --git a/android/examples/DirectPairing/project.properties b/android/examples/DirectPairing/project.properties
new file mode 100644 (file)
index 0000000..8e02666
--- /dev/null
@@ -0,0 +1,15 @@
+# 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-23
+android.library.reference.1=../appcompat_v7
diff --git a/android/examples/DirectPairing/src/main/AndroidManifest.xml b/android/examples/DirectPairing/src/main/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..54ec6b9
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base.examples.DirectPairing"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="19"
+        android:targetSdkVersion="21" />
+       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+       <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
diff --git a/android/examples/DirectPairing/src/main/assets/oic_svr_db_client_directpairing.dat b/android/examples/DirectPairing/src/main/assets/oic_svr_db_client_directpairing.dat
new file mode 100644 (file)
index 0000000..43b7a1c
Binary files /dev/null and b/android/examples/DirectPairing/src/main/assets/oic_svr_db_client_directpairing.dat differ
diff --git a/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/ExpandableListAdapter.java b/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/ExpandableListAdapter.java
new file mode 100644 (file)
index 0000000..377917c
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base.examples.DirectPairing;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseExpandableListAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import org.iotivity.base.examples.DirectPairing.Led;
+
+import java.util.List;
+
+public class ExpandableListAdapter extends BaseExpandableListAdapter {
+    private List<String> mGroupList;
+    private List<Object> mChilditemsList;
+    private Context mContext;
+
+    public ExpandableListAdapter(List<String> groupList, List<Object> childitemsList,
+                                 Context context) {
+        super();
+        this.mContext = context;
+        this.mGroupList = groupList;
+        this.mChilditemsList = childitemsList;
+    }
+
+    @Override
+    public int getGroupCount() {
+        return mGroupList.size();
+    }
+
+    @Override
+    public int getChildrenCount(int groupPosition) {
+        return 1;
+    }
+
+    @Override
+    public Object getGroup(int groupPosition) {
+        return mGroupList.get(groupPosition);
+    }
+
+    @Override
+    public Object getChild(int groupPosition, int childPosition) {
+        return this.mChilditemsList.get(childPosition);
+    }
+
+    @Override
+    public long getGroupId(int groupPosition) {
+        return groupPosition;
+    }
+
+    @Override
+    public long getChildId(int groupPosition, int childPosition) {
+        return childPosition;
+    }
+
+    @Override
+    public boolean hasStableIds() {
+        return false;
+    }
+
+    @Override
+    public View getGroupView(int groupPosition, boolean isExpanded,
+                             View convertView, ViewGroup parent) {
+
+        String data = (String) getGroup(groupPosition);
+        if (convertView == null) {
+            LayoutInflater infalInflater = (LayoutInflater) this.mContext
+                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            convertView = infalInflater.inflate(R.layout.list_group, null);
+        }
+
+        ImageView img = (ImageView) convertView.findViewById(R.id.image);
+        if (isExpanded) {
+            img.setImageResource(R.drawable.arrow_down);
+
+        } else {
+            img.setImageResource(R.drawable.arrow_right);
+        }
+
+        TextView groupText = (TextView) convertView.findViewById(R.id.title);
+        groupText.setText(mGroupList.get(groupPosition));
+
+        return convertView;
+    }
+
+    @Override
+    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
+                             View convertView, ViewGroup parent) {
+        LayoutInflater inflater = (LayoutInflater) mContext
+                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        convertView = inflater.inflate(R.layout.list_item, parent, false);
+
+        Led ledResource = (Led) getChild(groupPosition, childPosition);
+        TextView textItem = (TextView) convertView
+                .findViewById(R.id.textViewItem);
+        TextView textSource = (TextView) convertView
+                .findViewById(R.id.textViewSource);
+        TextView textStatus = (TextView) convertView
+                .findViewById(R.id.textViewStatus);
+        textStatus.setText("URI:" + "/a/led");
+        textItem.setText("State: " + ledResource.getState());
+        textSource.setText("Power: " + ledResource.getPower());
+
+        return convertView;
+
+    }
+
+    @Override
+    public boolean isChildSelectable(int groupPosition, int childPosition) {
+        return true;
+    }
+
+}
diff --git a/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/Led.java b/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/Led.java
new file mode 100644 (file)
index 0000000..f44f97c
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base.examples.DirectPairing;
+
+/**
+ * Led
+ * <p/>
+ * This class is used by simpleclient to create an object and update the values depending
+ * on the server response
+ */
+public class Led {
+    private boolean mState;
+    private int mPower;
+    private String mUri;
+
+    // constructor
+    public Led() {
+        mState = false;
+        mPower = 0;
+        mUri = "";
+    }
+
+    // accessor methods
+    public boolean getState() {
+        return mState;
+    }
+
+    public void setState(boolean state) {
+        mState = state;
+    }
+
+    public int getPower() {
+        return mPower;
+    }
+
+    public void setPower(int power) {
+        mPower = power;
+    }
+
+    public String getUri() {
+        return mUri;
+    }
+
+    public void setUri(String uri) {
+        mUri = uri;
+    }
+}
diff --git a/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/MainActivity.java b/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/MainActivity.java
new file mode 100644 (file)
index 0000000..90c4301
--- /dev/null
@@ -0,0 +1,534 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base.examples.DirectPairing;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.graphics.Color;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Environment;
+import android.preference.PreferenceManager;
+import android.text.InputFilter;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.ExpandableListView;
+import android.widget.ExpandableListView.OnGroupExpandListener;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.Switch;
+import android.widget.Toast;
+
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcDirectPairDevice;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcHeaderOption;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcPrmType;
+import org.iotivity.base.OcProvisioning;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResource;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+import org.iotivity.base.examples.DirectPairing.Led;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+public class MainActivity extends Activity {
+    private static final int BUFFER_SIZE = 1024;
+    private static final String TAG = "DirectPairing: ";
+    private static int selected = -1;
+    private int[] pList;
+    private Button save;
+    private int prmType;
+    private EditText pinText;
+    private Led ledResource;
+    private ListView mListView;
+    private String filePath = "";
+    private OcResource led = null;
+    private Switch discoverButton;
+    private List<String> resourceInterfaces;
+    private ArrayAdapter<String> arrayAdapter;
+    private List<Object> onGetResponseList;
+    private ExpandableListAdapter exlistAdapter;
+    OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {
+        @Override
+        public synchronized void onGetCompleted(List<OcHeaderOption> headerOptionList,
+                                                OcRepresentation ocRepresentation) {
+            onGetResponseList = new ArrayList<Object>();
+            ledResource.setState(ocRepresentation.getValueBool("state"));
+            ledResource.setPower(ocRepresentation.getValueInt("power"));
+            ledResource.setUri(ocRepresentation.getUri());
+            runOnUiThread(new Runnable() {
+                public void run() {
+                    onGetResponseList.add(ledResource);
+                    exlistAdapter.notifyDataSetChanged();
+                }
+            });
+
+            Log.d(TAG, "Got a response from " + ocRepresentation.getUri() +
+                    " " + ocRepresentation.getValueBool("state") + " "
+                    + ocRepresentation.getValueInt("power") + " " +
+                    ocRepresentation.getValueString("name"));
+        }
+
+        @Override
+        public synchronized void onGetFailed(Throwable throwable) {
+            Log.d(TAG, "GET request has failed");
+            Log.e(TAG, throwable.toString());
+        }
+    };
+    private ExpandableListView mPairedListDisplay;
+    private ArrayAdapter<OcDirectPairDevice> adapter;
+    private List<String> pairedList;
+    private List<OcDirectPairDevice> discoveredListObj;
+    OcPlatform.DirectPairingListener doDPListener = new OcPlatform.DirectPairingListener() {
+        @Override
+        public void onDirectPairingListener(String devId, int result) {
+            Log.d(TAG, "Inside getDPListener");
+            if (result == StringConstants.SUCCES_CODE) {
+                pairedList.clear();
+                pairedList.add(devId);
+                onGetResponseList.add(new Led());
+                runOnUiThread(new Runnable() {
+                    public void run() {
+                        mPairedListDisplay.setAdapter(exlistAdapter);
+                        int pos = mListView.getCheckedItemPosition();
+                        if (pos != ListView.INVALID_POSITION && discoveredListObj.size() != 0) {
+                            discoveredListObj.remove(pos);
+                            adapter.notifyDataSetChanged();
+                        }
+                    }
+                });
+                Log.d(TAG, "direct pair successfull for " + devId);
+            } else {
+                Log.d(TAG, "direct pairing failed");
+                runOnUiThread(new Runnable() {
+                    public void run() {
+                        Toast.makeText(getApplicationContext(),
+                                "Direct Pairing Failed", Toast.LENGTH_SHORT).show();
+                    }
+                });
+            }
+            exportCBOR();
+        }
+    };
+    private List<OcDirectPairDevice> discoveredPairableDevices;
+    OcPlatform.FindDirectPairingListener finddirectPairing =
+            new OcPlatform.FindDirectPairingListener() {
+                @Override
+                public void onFindDirectPairingListener(List<OcDirectPairDevice> direcPairingDevice) {
+                    Log.d(TAG, "find direct pairable successfull ");
+                    discoveredListObj.clear();
+                    discoveredPairableDevices =
+                            new ArrayList<OcDirectPairDevice>(direcPairingDevice);
+                    for (int i = 0; i < direcPairingDevice.size(); i++) {
+                        OcDirectPairDevice dpPairDevice = direcPairingDevice.get(i);
+                        Log.d(TAG, "getHost from Find Direct Pairing " + dpPairDevice.getHost());
+                        discoveredListObj.add(dpPairDevice);
+                    }
+
+                    runOnUiThread(new Runnable() {
+                        public void run() {
+                            mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+                            mListView.setAdapter(adapter);
+                            discoverButton.setChecked(false);
+                        }
+                    });
+                }
+            };
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+
+        onGetResponseList = new ArrayList<Object>();
+        discoveredListObj = new ArrayList<OcDirectPairDevice>();
+        pairedList = new ArrayList<String>();
+
+        ledResource = new Led();
+
+        mListView = (ListView) findViewById(R.id.list_view);
+        discoverButton = (Switch) findViewById(R.id.discover);
+        mPairedListDisplay = (ExpandableListView) findViewById(R.id.list_view_paired_list);
+
+
+        filePath = getFilesDir().getPath() + "/"; //  data/data/<package>/files/
+        //copy CBOR file when application runs first time
+        SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
+        boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
+        if (isFirstRun) {
+            copyCborFromAsset();
+            SharedPreferences.Editor editor = wmbPreference.edit();
+            editor.putBoolean("FIRSTRUN", false);
+            editor.commit();
+        }
+
+        initOICStack();
+
+        adapter = new ArrayAdapter<OcDirectPairDevice>(this,
+                android.R.layout.simple_list_item_single_choice,
+                discoveredListObj);
+
+        arrayAdapter = new ArrayAdapter<String>(
+                MainActivity.this,
+                android.R.layout.select_dialog_singlechoice);
+
+        save = (Button) findViewById(R.id.saveDiscovered);
+
+        save.setEnabled(false);
+        save.setBackgroundColor(Color.GRAY);
+
+        resourceInterfaces = new LinkedList<>();
+        resourceInterfaces.add(OcPlatform.DEFAULT_INTERFACE);
+
+        exlistAdapter = new ExpandableListAdapter(pairedList, onGetResponseList,
+                MainActivity.this);
+        mPairedListDisplay.setAdapter(exlistAdapter);
+
+        // to expand only a single group item.
+        mPairedListDisplay.setOnGroupExpandListener(new OnGroupExpandListener() {
+            int previousGroup = -1;
+
+            @Override
+            public void onGroupExpand(int groupPosition) {
+                Log.d(TAG, "Calling GET api on mResource");
+                try {
+                    if (null != led) led.get(new HashMap<String, String>(), onGetListener);
+                } catch (OcException e) {
+                    Log.d(TAG, "Error in GET calls");
+                    Log.e(TAG, e.getMessage());
+                }
+
+                if (groupPosition != previousGroup)
+                    mPairedListDisplay.collapseGroup(previousGroup);
+
+                previousGroup = groupPosition;
+            }
+        });
+
+        save.setOnClickListener(new View.OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+
+                AlertDialog.Builder alertPinDialog =
+                        new AlertDialog.Builder(MainActivity.this);
+                alertPinDialog.setTitle("PIN");
+                alertPinDialog.setMessage("Enter Pin");
+
+                pinText = new EditText(MainActivity.this);
+                int maxLength = 8;
+                InputFilter[] fArray = new InputFilter[1];
+                fArray[0] = new InputFilter.LengthFilter(maxLength);
+                pinText.setFilters(fArray);
+                pinText.setMaxLines(1);
+                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+                        LinearLayout.LayoutParams.MATCH_PARENT,
+                        LinearLayout.LayoutParams.MATCH_PARENT);
+                pinText.setLayoutParams(lp);
+                alertPinDialog.setView(pinText);
+                alertPinDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which) {
+                        selected = -1;
+                        final AlertDialog alertPrmTypeDialog = new AlertDialog.Builder
+                                (MainActivity.this)
+                                .setSingleChoiceItems(arrayAdapter, -1,
+                                        new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialog, int which) {
+                                                selected = which;
+                                                prmType = pList[which];
+                                                Log.d(TAG, " prmType " + prmType);
+                                            }
+                                        })
+                                .setTitle("Select Direct Pair Method")
+                                .setPositiveButton("OK", null)
+                                .setNegativeButton("CANCEL", null)
+                                .create();
+
+                        alertPrmTypeDialog.setOnShowListener(
+                                new DialogInterface.OnShowListener() {
+                                    @Override
+                                    public void onShow(DialogInterface dialog) {
+                                        Button ok =
+                                                alertPrmTypeDialog
+                                                        .getButton(AlertDialog.BUTTON_POSITIVE);
+
+                                        Button cancel =
+                                                alertPrmTypeDialog
+                                                        .getButton(AlertDialog.BUTTON_NEGATIVE);
+
+                                        ok.setOnClickListener(new View.OnClickListener() {
+                                            @Override
+                                            public void onClick(View view) {
+                                                int pos = mListView.getCheckedItemPosition();
+                                                if (selected == -1) {
+                                                    Toast.makeText(getApplicationContext(),
+                                                            "Please Select A Value",
+                                                            Toast.LENGTH_SHORT).show();
+                                                } else if (pos != ListView.INVALID_POSITION) {
+                                                    if (!discoveredListObj.isEmpty()) {
+                                                        try {
+                                                            OcDirectPairDevice peer =
+                                                                    (OcDirectPairDevice)
+                                                                            discoveredListObj.
+                                                                                    get(pos);
+                                                            OcPlatform.doDirectPairing(peer,
+                                                                    OcPrmType.convertOcPrmType(prmType),
+                                                                    pinText.getText().toString(),
+                                                                    doDPListener);
+                                                        } catch (OcException e) {
+                                                            Log.d(TAG, "do Direct Pairing error: "
+                                                                    + e.getMessage());
+                                                            Log.e(TAG, e.getMessage());
+                                                        }
+
+                                                        alertPrmTypeDialog.dismiss();
+                                                    } else {
+                                                        alertPrmTypeDialog.dismiss();
+                                                    }
+                                                }
+                                            }
+                                        });
+
+                                        cancel.setOnClickListener(new View.OnClickListener() {
+                                            @Override
+                                            public void onClick(View view) {
+                                                alertPrmTypeDialog.dismiss();
+                                            }
+                                        });
+                                    }
+                                });
+
+                        alertPrmTypeDialog.show();
+                    }
+                });
+                alertPinDialog.show();
+            }
+        });
+
+        mListView.setOnItemClickListener(new OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView adapt, View view, int position, long itemId) {
+                save.setEnabled(true);
+                save.setBackgroundColor(Color.parseColor("#13AEF4"));
+                OcDirectPairDevice dpPairDevice =
+                        (OcDirectPairDevice) adapt.getItemAtPosition(position);
+                Log.d(TAG, "DevId On List Item Clicked " + dpPairDevice.getDevId());
+                List<Integer> pTypeList = dpPairDevice.getPairingMethodList();
+                pList = new int[pTypeList.size()];
+                       Iterator<Integer> iterator = pTypeList.iterator();
+                       for(int k = 0; k < pList.length; k++){
+                           pList[k]=iterator.next().intValue();
+                       }
+                arrayAdapter.clear();
+                for (int j = 0; j < pList.length; j++) {
+                    Log.d(TAG, " List Item Value " + pList[j]);
+                    OcPrmType prmTy = OcPrmType.convertOcPrmType(pList[j]);
+                    arrayAdapter.add(prmTy.name());
+                }
+            }
+        });
+
+        discoverButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (isChecked) {
+                    save.setEnabled(false);
+                    save.setBackgroundColor(Color.GRAY);
+                    new GetDiscoveredItems().execute();
+                }
+            }
+        });
+
+    }
+
+    /**
+     * Copy svr db CBOR dat file from assets folder to app data files dir
+     */
+    private void copyCborFromAsset() {
+        InputStream inputStream = null;
+        OutputStream outputStream = null;
+        int length;
+        byte[] buffer = new byte[BUFFER_SIZE];
+        try {
+            inputStream = getAssets().open(StringConstants.OIC_CLIENT_CBOR_DB_FILE);
+            File file = new File(filePath);
+            //check files directory exists
+            if (!(file.exists() && file.isDirectory())) {
+                file.mkdirs();
+            }
+            outputStream = new FileOutputStream(filePath +
+                    StringConstants.OIC_CLIENT_CBOR_DB_FILE);
+            while ((length = inputStream.read(buffer)) != -1) {
+                outputStream.write(buffer, 0, length);
+            }
+        } catch (NullPointerException e) {
+            Log.d(TAG, "Null pointer exception " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (FileNotFoundException e) {
+            Log.d(TAG, "CBOR svr db file not found " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (IOException e) {
+            Log.d(TAG, StringConstants.OIC_CLIENT_CBOR_DB_FILE + " file copy failed");
+            Log.e(TAG, e.getMessage());
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+        }
+    }
+
+    void exportCBOR() {
+        try {
+            File sd = Environment.getExternalStorageDirectory();
+            File data = Environment.getDataDirectory();
+            if (sd.canWrite()) {
+                String currentDBPath = "/data/data/" + getPackageName() +
+                        "/files/" + StringConstants.OIC_CLIENT_CBOR_DB_FILE;
+                File currentDB = new File(currentDBPath);
+                File backupDB = new File(sd, StringConstants.OIC_CLIENT_CBOR_DB_FILE);
+                if (currentDB.exists()) {
+                    FileChannel src = new FileInputStream(currentDB).getChannel();
+                    FileChannel dst = new FileOutputStream(backupDB).getChannel();
+                    dst.transferFrom(src, 0, src.size());
+                    src.close();
+                    dst.close();
+                }
+            }
+        } catch (Exception e) {
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * configure OIC platform and call findResource
+     */
+    private void initOICStack() {
+        //create platform config
+        PlatformConfig cfg = new PlatformConfig(this, ServiceType.IN_PROC, ModeType.CLIENT_SERVER,
+                "0.0.0.0", // bind to all available interfaces
+                0,
+                QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_CBOR_DB_FILE);
+        OcPlatform.Configure(cfg);
+        try {
+            /*
+             * Initialize DataBase
+             */
+            String sqlDbPath = getFilesDir().getAbsolutePath().replace("files", "databases") +
+                    File.separator;
+            File file = new File(sqlDbPath);
+            //check files directory exists
+            if (!(file.isDirectory())) {
+                file.mkdirs();
+                Log.d(TAG, "Sql db directory created at " + sqlDbPath);
+            }
+            Log.d(TAG, "Sql db directory exists at " + sqlDbPath);
+            OcProvisioning.provisionInit(sqlDbPath + StringConstants.OIC_SQL_DB_FILE);
+        } catch (OcException e) {
+            Log.d(TAG, "provisionInit error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    class GetDiscoveredItems extends AsyncTask<Void, Void, List<String>> {
+
+        ProgressDialog pDialog;
+
+        @Override
+        protected void onPreExecute() {
+            pDialog = new ProgressDialog(MainActivity.this);
+            pDialog.setMessage("Getting Discovered Items");
+            pDialog.setCancelable(false);
+            pDialog.setCanceledOnTouchOutside(false);
+            pDialog.show();
+        }
+
+        ;
+
+        @Override
+        protected List<String> doInBackground(Void... params) {
+            try {
+                OcPlatform.findDirectPairingDevices(5, finddirectPairing);
+            } catch (OcException e) {
+                Log.e(TAG, e.getMessage());
+            }
+            return null;
+        }
+
+        @Override
+        protected void onPostExecute(List<String> discoveredItems) {
+            pDialog.dismiss();
+            for (Iterator iterator = discoveredListObj.iterator(); iterator.hasNext(); ) {
+                OcDirectPairDevice ledResource = (OcDirectPairDevice) iterator.next();
+                List<String> lightTypes = new LinkedList<>();
+                lightTypes.add("core.led");
+                try {
+                    Log.d(TAG, "Constructing Led Resource");
+                    led = OcPlatform.constructResourceObject(ledResource.getHost(),
+                            "/a/led", ledResource.getConnectivityTypeSet(),
+                            false, //isObservable
+                            lightTypes,
+                            resourceInterfaces);
+                    Log.d(TAG, "Constructed Led Resource");
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+        }
+
+    }
+}
diff --git a/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/StringConstants.java b/android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/StringConstants.java
new file mode 100644 (file)
index 0000000..c793422
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * //******************************************************************
+ * //
+ * // 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.base.examples.DirectPairing;
+
+public interface StringConstants {
+
+    public static final int NUMBER_ZERO = 0;
+    public static final int DISCOVERY_TIMEOUT_10 = 10;
+    public static final int DISCOVERY_TIMEOUT_20 = 20;
+    public static final int SUCCES_CODE = 0;
+    public static final String DEFAULT_ROWNER_ID = "61646d69-6e44-6576-6963-655555494430";
+    public static final String DEFAULT_RESOURCES = "*";
+    public static final String DEFAULT_RECURRENCES = "Daily";
+    public static final String DEFAULT_PERIOD = "12-12-16";
+    public static final int DEFAULT_PERMISSION = 31;
+    public static final String OIC_CLIENT_CBOR_DB_FILE = "oic_svr_db_client_directpairing.dat";
+    public static final String MESSAGE = "message";
+    public static final String OIC_SQL_DB_FILE = "Pdm.db";
+    public static final int CREDENTIAL_TYPE = 1;
+    public static final int OWNER_PSK_LENGTH_128 = 128 / 8;
+}
diff --git a/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_down.png b/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_down.png
new file mode 100644 (file)
index 0000000..2e69816
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_down.png differ
diff --git a/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_right.png b/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_right.png
new file mode 100644 (file)
index 0000000..91667d5
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_right.png differ
diff --git a/android/examples/DirectPairing/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/DirectPairing/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..288b665
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/examples/DirectPairing/src/main/res/drawable-mdpi/ic_launcher.png b/android/examples/DirectPairing/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..6ae570b
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/examples/DirectPairing/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/DirectPairing/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..d4fb7cd
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/android/examples/DirectPairing/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/DirectPairing/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..85a6081
Binary files /dev/null and b/android/examples/DirectPairing/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/android/examples/DirectPairing/src/main/res/layout/activity_main.xml b/android/examples/DirectPairing/src/main/res/layout/activity_main.xml
new file mode 100644 (file)
index 0000000..1ee1a2b
--- /dev/null
@@ -0,0 +1,95 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools"\r
+    android:layout_width="match_parent"\r
+    android:layout_height="match_parent"\r
+    android:orientation="vertical"\r
+    android:paddingBottom="@dimen/activity_vertical_margin"\r
+    android:paddingLeft="@dimen/activity_horizontal_margin"\r
+    android:paddingRight="@dimen/activity_horizontal_margin"\r
+    android:paddingTop="@dimen/activity_vertical_margin"\r
+    tools:context="com.example.iot.MainActivity" >\r
+\r
+    <LinearLayout\r
+        android:layout_width="match_parent"\r
+        android:layout_height="wrap_content"\r
+        android:weightSum="1" >\r
+\r
+        <TextView\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_weight="0.75"\r
+            android:gravity="center"\r
+            android:text="@string/discover_items"\r
+            android:textSize="18sp" />\r
+\r
+        <Switch\r
+            android:id="@+id/discover"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_weight="0.25" />\r
+    </LinearLayout>\r
+\r
+    <View\r
+        android:layout_width="match_parent"\r
+        android:layout_height="2dp"\r
+        android:background="#13AEF4" />\r
+\r
+    <ListView\r
+        android:id="@+id/list_view"\r
+        android:layout_width="match_parent"\r
+        android:layout_height="250dp" />\r
+\r
+    <View\r
+        android:layout_width="match_parent"\r
+        android:layout_height="2dp"\r
+        android:background="#13AEF4" />\r
+\r
+    <RelativeLayout\r
+        android:id="@+id/relLay"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        android:orientation="horizontal"\r
+        android:padding="15dp" >\r
+\r
+        <Button\r
+            android:id="@+id/saveDiscovered"\r
+            android:layout_width="90dp"\r
+            android:layout_height="30dp"\r
+            android:layout_centerInParent="true"\r
+            android:background="#13AEF4"\r
+            android:text="Save"\r
+            android:textColor="#FFFFFF" />\r
+    </RelativeLayout>\r
+\r
+    <View\r
+        android:layout_width="match_parent"\r
+        android:layout_height="2dp"\r
+        android:background="#13AEF4" />\r
+\r
+    <TextView\r
+        android:layout_width="match_parent"\r
+        android:layout_height="wrap_content"\r
+        android:layout_gravity="center_vertical"\r
+        android:paddingLeft="50dp"\r
+        android:text="@string/paired_list"\r
+        android:textSize="18sp" />\r
+\r
+    <View\r
+        android:layout_width="match_parent"\r
+        android:layout_height="2dp"\r
+        android:background="#13AEF4" />\r
+\r
+    <ExpandableListView\r
+        android:id="@+id/list_view_paired_list"\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="200dp"\r
+        android:paddingTop="5dp"\r
+        android:groupIndicator="@null" >\r
+    </ExpandableListView>\r
+\r
+    <View\r
+        android:layout_width="match_parent"\r
+        android:layout_height="2dp"\r
+        android:background="#13AEF4" />\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/android/examples/DirectPairing/src/main/res/layout/custom_list_view.xml b/android/examples/DirectPairing/src/main/res/layout/custom_list_view.xml
new file mode 100644 (file)
index 0000000..74874c5
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:padding="10dp" >
+
+    <TextView
+        android:id="@+id/textView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Discovered Items"
+        android:layout_centerVertical="true"
+         android:layout_gravity="center_vertical"
+        android:textColor="#545454"
+        android:textSize="15sp" />
+
+    <LinearLayout
+         android:id="@+id/linearLay"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_centerVertical="true" >
+
+        <CheckBox
+            android:id="@+id/checkBox"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_gravity="center_vertical"
+            android:layout_marginRight="10dp" />
+    </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/examples/DirectPairing/src/main/res/layout/group_indicator.xml b/android/examples/DirectPairing/src/main/res/layout/group_indicator.xml
new file mode 100644 (file)
index 0000000..95be916
--- /dev/null
@@ -0,0 +1,6 @@
+<selector xmlns:android="http://schemas.android.com/apk/res/android">\r
+         <item android:drawable="@drawable/arrow_right" android:state_empty="true"></item>\r
+            <item android:drawable="@drawable/arrow_down" android:state_expanded="true"></item>\r
+            <item android:drawable="@drawable/arrow_right"></item>\r
+\r
+</selector>
\ No newline at end of file
diff --git a/android/examples/DirectPairing/src/main/res/layout/list_group.xml b/android/examples/DirectPairing/src/main/res/layout/list_group.xml
new file mode 100644 (file)
index 0000000..d4d9218
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="40dp"\r
+    android:background="#ffffff"\r
+    android:orientation="horizontal" >\r
+\r
+    <TextView\r
+        android:id="@+id/title"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="40dp"\r
+        android:layout_weight="0.9"\r
+        android:gravity="center_vertical"\r
+        android:paddingLeft="40dp"\r
+        android:text="Items"\r
+        android:textColor="#040404"\r
+        android:textSize="16sp"\r
+        android:textStyle="bold"\r
+        android:typeface="sans" />\r
+\r
+    <ImageView\r
+        android:id="@+id/image"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="20dp"\r
+        android:layout_gravity="center_vertical"\r
+        android:layout_weight="0.1" />\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/android/examples/DirectPairing/src/main/res/layout/list_item.xml b/android/examples/DirectPairing/src/main/res/layout/list_item.xml
new file mode 100644 (file)
index 0000000..6579c36
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="wrap_content"\r
+    android:orientation="vertical" >\r
+\r
+    <TextView\r
+        android:id="@+id/textViewItem"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content"\r
+        android:gravity="center_vertical"\r
+        android:paddingLeft="50dp"\r
+        android:text="Paired Items"\r
+        android:textColor="#545454"\r
+        android:textSize="15sp" />\r
+\r
+    <TextView\r
+        android:id="@+id/textViewSource"\r
+        android:layout_below="@id/textViewItem"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content"\r
+        android:gravity="center_vertical"\r
+        android:paddingLeft="50dp"\r
+        android:text="Paired Source"\r
+        android:textColor="#545454"\r
+        android:textSize="15sp" />\r
+\r
+    <TextView\r
+        android:id="@+id/textViewStatus"\r
+        android:layout_below="@id/textViewSource"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content"\r
+        android:gravity="center_vertical"\r
+        android:paddingLeft="50dp"\r
+        android:text="Paired Status"\r
+        android:textColor="#545454"\r
+        android:textSize="15sp" />\r
+\r
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/examples/DirectPairing/src/main/res/menu/main.xml b/android/examples/DirectPairing/src/main/res/menu/main.xml
new file mode 100644 (file)
index 0000000..3e5155b
--- /dev/null
@@ -0,0 +1,11 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:app="http://schemas.android.com/apk/res-auto"\r
+    xmlns:tools="http://schemas.android.com/tools"\r
+    tools:context="org.iotivity.base.examples.MainActivity" >\r
+\r
+    <item\r
+        android:id="@+id/action_settings"\r
+        android:orderInCategory="100"\r
+        android:title="@string/action_settings"/>\r
+\r
+</menu>\r
diff --git a/android/examples/DirectPairing/src/main/res/values-v11/styles.xml b/android/examples/DirectPairing/src/main/res/values-v11/styles.xml
new file mode 100644 (file)
index 0000000..0ce1396
--- /dev/null
@@ -0,0 +1,11 @@
+<resources>\r
+\r
+    <!--\r
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.\r
+    -->\r
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">\r
+        <!-- API 11 theme customizations can go here. -->\r
+    </style>\r
+\r
+</resources>\r
diff --git a/android/examples/DirectPairing/src/main/res/values-v14/styles.xml b/android/examples/DirectPairing/src/main/res/values-v14/styles.xml
new file mode 100644 (file)
index 0000000..94dd245
--- /dev/null
@@ -0,0 +1,12 @@
+<resources>\r
+\r
+    <!--\r
+        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.\r
+    -->\r
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">\r
+        <!-- API 14 theme customizations can go here. -->\r
+    </style>\r
+\r
+</resources>\r
diff --git a/android/examples/DirectPairing/src/main/res/values-w820dp/dimens.xml b/android/examples/DirectPairing/src/main/res/values-w820dp/dimens.xml
new file mode 100644 (file)
index 0000000..f9f069f
--- /dev/null
@@ -0,0 +1,10 @@
+<resources>\r
+\r
+    <!--\r
+         Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).\r
+    -->\r
+    <dimen name="activity_horizontal_margin">64dp</dimen>\r
+\r
+</resources>\r
diff --git a/android/examples/DirectPairing/src/main/res/values/dimens.xml b/android/examples/DirectPairing/src/main/res/values/dimens.xml
new file mode 100644 (file)
index 0000000..2e0e2ae
--- /dev/null
@@ -0,0 +1,7 @@
+<resources>\r
+\r
+    <!-- Default screen margins, per the Android Design guidelines. -->\r
+    <dimen name="activity_horizontal_margin">16dp</dimen>\r
+    <dimen name="activity_vertical_margin">16dp</dimen>\r
+\r
+</resources>\r
diff --git a/android/examples/DirectPairing/src/main/res/values/strings.xml b/android/examples/DirectPairing/src/main/res/values/strings.xml
new file mode 100644 (file)
index 0000000..0fe7671
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>\r
+\r
+    <string name="app_name">DirectPairingClient</string>\r
+    <string name="discover_items">Discover Resources</string>
+    <string name="paired_items">Paired Resources</string>
+    <string name="paired_list">Direct Paired Resources</string>\r
+    <string name="action_settings">Settings</string>\r
+\r
+</resources>\r
diff --git a/android/examples/DirectPairing/src/main/res/values/styles.xml b/android/examples/DirectPairing/src/main/res/values/styles.xml
new file mode 100644 (file)
index 0000000..287aa96
--- /dev/null
@@ -0,0 +1,20 @@
+<resources>\r
+\r
+    <!--\r
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\r
+    -->\r
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">\r
+        <!--\r
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.\r
+        -->\r
+    </style>\r
+\r
+    <!-- Application theme. -->\r
+    <style name="AppTheme" parent="AppBaseTheme">\r
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->\r
+    </style>\r
+\r
+</resources>\r
index fbd8eda..db828b5 100644 (file)
@@ -24,6 +24,8 @@ import org.iotivity.base.OcPlatform;
 import org.iotivity.base.OcProvisioning;
 import org.iotivity.base.OcSecureResource;
 import org.iotivity.base.OicSecAcl;
+import org.iotivity.base.OicSecPdAcl;
+import org.iotivity.base.OcPrmType;
 import org.iotivity.base.OxmType;
 import org.iotivity.base.PlatformConfig;
 import org.iotivity.base.ProvisionResult;
@@ -59,6 +61,22 @@ public class ProvisioningClient extends Activity implements
     private List<OcSecureResource> deviceList;
     private List<OcSecureResource> ownedDeviceList;
     private TextView mEventsTextView;
+
+    OcSecureResource.ProvisionDirectPairingListener provisionDPListener =
+            new OcSecureResource.ProvisionDirectPairingListener() {
+                @Override
+                public void provisionDirectPairingListener(List<ProvisionResult> provisionResults,
+                                                           int hasError) {
+                    Log.d(TAG, "Inside provisionDPListener");
+                    ProvisionResult pResult = provisionResults.get(0);
+                    if (hasError == StringConstants.ERROR_CODE) {
+                        logMessage(TAG + "Provision direct pairing Failed for " + pResult.getDevId());
+                    } else {
+                        logMessage(TAG + "Provision direct pairing Successful for " + pResult.getDevId());
+                    }
+                }
+            };
+
     OcSecureResource.ProvisionAclListener provisionAclListener =
             new OcSecureResource.ProvisionAclListener() {
                 @Override
@@ -123,7 +141,7 @@ public class ProvisioningClient extends Activity implements
         mEventsTextView.setMovementMethod(new ScrollingMovementMethod());
         LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
         layout.addView(mEventsTextView, new LinearLayout.LayoutParams(
-                        LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)
+                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)
         );
         filePath = getFilesDir().getPath() + "/"; //  data/data/<package>/files/
         //copy CBOR file when application runs first time
@@ -188,6 +206,32 @@ public class ProvisioningClient extends Activity implements
         }
     }
 
+
+    private void doDPProvisioning() {
+        try {
+            logMessage(TAG + "Provision direct pairing for " + ownedDeviceList.get(0).getDeviceID());
+            newSecureResource = ownedDeviceList.get(0);
+            String pin = "00000000";
+            List<OcPrmType>prmTypes = new ArrayList<OcPrmType>();
+            prmTypes.add(OcPrmType.DP_PRE_CONFIGURED);
+            boolean edp = true;
+            List<String> resources = new ArrayList<String>();
+            List<String> periods = new ArrayList<String>();
+            List<String> recurrences = new ArrayList<String>();
+            resources.add(StringConstants.DEFAULT_RESOURCES);
+            OicSecPdAcl pdAcl = new OicSecPdAcl(recurrences, periods,
+                    StringConstants.DEFAULT_PERMISSION, resources);
+            OicSecPdAcl[] oicSecPdAcls = new OicSecPdAcl[1];
+            oicSecPdAcls[0] = pdAcl;
+            newSecureResource.doProvisionDirectPairing(pin, oicSecPdAcls, prmTypes, edp,
+                    provisionDPListener);
+        } catch (Exception e) {
+            logMessage(TAG + "Direct Pairing Provisioning error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+
     private void doPairwiseProvisioning() {
         try {
             logMessage(TAG + "Pairwise Provisioning b/w " + ownedDeviceList.get(0).getDeviceID()
@@ -544,11 +588,11 @@ public class ProvisioningClient extends Activity implements
                 if (ownedDeviceList.size() > 0) {
                     for (int i = 0; i < ownedDeviceList.size(); i++) {
                         publishProgress(TAG + "Owned Discovered Device " + (i + 1) + "= " +
-                                        ownedDeviceList.get(i).getDeviceID()
-                                        + "\nIP Address= " + ownedDeviceList.get(i).getIpAddr()
-                                        + "\nOwned Status= " + ownedDeviceList.get(i).getOwnedStatus()
-                                        + "\nDevice Status= " + ((ownedDeviceList.get(i).
-                                        getDeviceStatus() == DeviceStatus.ON) ? "ON" : "OFF")
+                                ownedDeviceList.get(i).getDeviceID()
+                                + "\nIP Address= " + ownedDeviceList.get(i).getIpAddr()
+                                + "\nOwned Status= " + ownedDeviceList.get(i).getOwnedStatus()
+                                + "\nDevice Status= " + ((ownedDeviceList.get(i).
+                                getDeviceStatus() == DeviceStatus.ON) ? "ON" : "OFF")
                         );
                     }
                 } else {
@@ -568,6 +612,12 @@ public class ProvisioningClient extends Activity implements
 
         @Override
         protected void onPostExecute(String s) {
+
+
+            if (ownedDeviceList.size() > 0 && "success".equals(s)) {
+                doDPProvisioning();
+            }
+
             if (ownedDeviceList.size() > 1 && "success".equals(s)) {
                 doPairwiseProvisioning();
             }
index cde94ab..3d6612a 100755 (executable)
@@ -1,5 +1,5 @@
 include ':simpleserver', ':simpleclient', ':fridgeserver', ':fridgeclient', ':guiclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver', ':simplebase'
 SECURED=System.getProperty('SECURE')
 if(SECURED== "1"){
-        include ':provisioningclient'
+        include ':provisioningclient', ':DirectPairing'
 }