From 3c093548382bb2542c87a67e6e5fa32552c29cb3 Mon Sep 17 00:00:00 2001 From: "Hongkuk, Son" Date: Fri, 29 Sep 2017 16:24:47 +0900 Subject: [PATCH] replace : iotivity -> iotivity-sec Signed-off-by: Hongkuk, Son Change-Id: I5096b7e6faeadd98d5ee48279b24cb9fbdb1f24f --- .gitignore | 4 +- NOTICE.md | 15 +- Readme.scons.txt | 12 +- SConstruct | 11 +- android/android_api/SConscript | 21 +- android/android_api/base/build.gradle | 6 +- android/android_api/base/jni/Android.mk | 24 +- android/android_api/base/jni/JniCaInterface.c | 67 + android/android_api/base/jni/JniCaInterface.h | 8 + .../android_api/base/jni/JniConfirmNumListener.cpp | 76 + .../android_api/base/jni/JniConfirmNumListener.h | 40 + .../base/jni/JniDisplayVerifyNumListener.cpp | 99 + .../base/jni/JniDisplayVerifyNumListener.h | 40 + .../android_api/base/jni/JniKeepAliveListener.cpp | 146 + .../android_api/base/jni/JniKeepAliveListener.h | 42 + android/android_api/base/jni/JniOcPlatform.cpp | 316 +- android/android_api/base/jni/JniOcPlatform.h | 51 +- android/android_api/base/jni/JniOcProvisioning.cpp | 321 +- android/android_api/base/jni/JniOcProvisioning.h | 73 + android/android_api/base/jni/JniOcResource.cpp | 23 + android/android_api/base/jni/JniOcResource.h | 9 + .../android_api/base/jni/JniOcSecureResource.cpp | 4 +- android/android_api/base/jni/JniOcSecurity.cpp | 205 +- android/android_api/base/jni/JniOcSecurity.h | 19 + android/android_api/base/jni/JniUtils.h | 34 + .../org/iotivity/base/MVJustWorksOptionMask.java | 64 + .../main/java/org/iotivity/base/OcPlatform.java | 91 +- .../java/org/iotivity/base/OcProvisioning.java | 109 + .../main/java/org/iotivity/base/OcResource.java | 7 + .../src/main/java/org/iotivity/base/PinType.java | 62 + .../java/org/iotivity/base/PlatformConfig.java | 60 +- .../java/org/iotivity/ca/CaBtPairingInterface.java | 11 +- .../main/java/org/iotivity/ca/CaEdrInterface.java | 11 +- .../src/main/java/org/iotivity/ca/CaInterface.java | 61 +- .../main/java/org/iotivity/ca/CaIpInterface.java | 213 +- .../java/org/iotivity/ca/CaLeClientInterface.java | 144 +- .../java/org/iotivity/ca/CaLeServerInterface.java | 14 +- .../java/org/iotivity/ca/CaTransportFlags.java | 79 + .../src/main/java/org/iotivity/ca/OicCipher.java | 83 +- .../CloudProvisioningClient.java | 0 .../src/main/AndroidManifest.xml | 3 +- .../src/main/assets/oic_svr_db_client_default.dat | Bin 0 -> 859 bytes .../src/main/assets/oic_svr_db_client_enc.dat | Bin 0 -> 859 bytes .../src/main/assets/oic_svr_db_client_plain.dat | Bin 0 -> 859 bytes .../src/main/assets/oic_svr_db_client_rescue.dat | Bin 0 -> 859 bytes .../provisioningclient/ProvisioningClient.java | 165 +- .../provisioningclient/StringConstants.java | 6 +- .../main/res/menu/menu_secure_provision_client.xml | 8 +- android/examples/settings.gradle | 0 .../simplebase/src/main/AndroidManifest.xml | 1 + .../iotivity/base/examples/BluetoothFragment.java | 1 + .../java/org/iotivity/base/examples/Common.java | 16 + .../org/iotivity/base/examples/DrawerFragment.java | 1 + .../iotivity/base/examples/KeepAliveFragment.java | 480 + .../iotivity/base/examples/MessageFragment.java | 11 + .../org/iotivity/base/examples/SimpleBase.java | 4 + .../src/main/res/layout/fragment_keepalive.xml | 156 + .../simplebase/src/main/res/values/strings.xml | 1 + build-da-checkout.sh | 58 + build-im-sc-android.sh | 95 + build-im-sc-android64.sh | 125 + build-im-sc-ios.sh | 126 + build-im-virtual_device-android.sh | 95 + build-vd-tv-es-tizen30.sh | 107 + build-vd-tv-tizen30.sh | 107 + build_common/SConscript | 26 +- build_common/android/SConscript | 21 +- build_common/thread.scons | 2 +- build_common/tizen/SConscript | 3 +- build_common/tizenrt/SConscript | 77 + build_common/tools/UnpackAll.py | 155 +- .../cloud/testrdserver/DiscoveryResourceTest.java | 11 +- .../samples/client/thin_light/thin_room_light.cpp | 4 +- extlibs/boost/SConscript | 2 +- extlibs/libcoap/SConscript | 4 +- extlibs/mbedtls/SConscript | 50 +- extlibs/mbedtls/mbedtls/library/net.c | 586 + extlibs/mbedtls/mbedtls/library/ssl_cli.c | 12 +- extlibs/mbedtls/ocf.patch | 100 +- extlibs/sqlite3/SConscript | 8 +- extlibs/tinycbor/tinycbor/Makefile | 9 +- extlibs/tinycbor/tinycbor/Makefile.configure | 30 - extlibs/tinycbor/tinycbor/Makefile.nmake | 40 - extlibs/tinycbor/tinycbor/VERSION | 2 +- extlibs/tinycbor/tinycbor/src/cbor.h | 6 +- extlibs/tinycbor/tinycbor/src/cborencoder.c | 22 +- .../src/cborencoder_close_container_checked.c | 4 +- extlibs/tinycbor/tinycbor/tools/Makefile | 12 - .../tinycbor/tinycbor/tools/json2cbor/json2cbor.c | 8 +- ...HE_PSK_WITH_AES_128_CBC_SHA_256-cipher-su.patch | 746 - ...anonymous-ecdh-cipher-suite-into-tinydtls.patch | 1164 -- ...upport-in-tinyDTLS-to-support-rehandshake.patch | 172 - ...autoconf-generated-files-in-tinydtls-repo.patch | 256 - ...Fix-in-earlier-rehandhsake-implementation.patch | 174 - ...ng-implementation-about-the-anonymous-cip.patch | 690 - ...-to-pass-PSK-identity-hint-to-application.patch | 73 - ...d-tinyDTLS-test-apps-to-use-identity-hint.patch | 188 - ...t-of-X.509-into-tinyDTLS-external-library.patch | 1960 --- extlibs/tinydtls/Android.mk | 17 - extlibs/tinydtls/LICENSE | 21 - extlibs/tinydtls/Makefile.in | 142 - extlibs/tinydtls/Makefile.tinydtls | 36 - extlibs/tinydtls/README | 26 - extlibs/tinydtls/README_Iotivity | 26 - extlibs/tinydtls/SConscript | 101 - extlibs/tinydtls/aes/Makefile.in | 76 - extlibs/tinydtls/aes/rijndael.c | 1287 -- extlibs/tinydtls/aes/rijndael.h | 67 - extlibs/tinydtls/alert.h | 81 - extlibs/tinydtls/ccm.c | 311 - extlibs/tinydtls/ccm.h | 69 - extlibs/tinydtls/configure.in | 127 - extlibs/tinydtls/crypto.c | 801 - extlibs/tinydtls/crypto.h | 437 - extlibs/tinydtls/debug.c | 439 - extlibs/tinydtls/debug.h | 141 - extlibs/tinydtls/doc/Doxyfile.in | 1551 -- extlibs/tinydtls/doc/DoxygenLayout.xml | 184 - extlibs/tinydtls/doc/Makefile.in | 36 - extlibs/tinydtls/dtls.c | 4982 ------ extlibs/tinydtls/dtls.h | 909 -- extlibs/tinydtls/dtls_config.h | 241 - extlibs/tinydtls/dtls_config.h.in | 221 - extlibs/tinydtls/dtls_hal.h | 211 - extlibs/tinydtls/dtls_time.c | 93 - extlibs/tinydtls/dtls_time.h | 71 - extlibs/tinydtls/ecc/LICENSE.txt | 21 - extlibs/tinydtls/ecc/Makefile.contiki | 7 - extlibs/tinydtls/ecc/Makefile.ecc | 3 - extlibs/tinydtls/ecc/Makefile.in | 93 - extlibs/tinydtls/ecc/README.md | 208 - extlibs/tinydtls/ecc/asm_arm.inc | 1905 --- extlibs/tinydtls/ecc/asm_avr.inc | 16276 ------------------- extlibs/tinydtls/ecc/ecc.c | 2474 --- extlibs/tinydtls/ecc/ecc.h | 311 - extlibs/tinydtls/ecc/test/ecc_test/ecc_test.ino | 115 - extlibs/tinydtls/ecc/test/emk_rules.py | 4 - extlibs/tinydtls/ecc/test/test_ecdh.c | 107 - extlibs/tinydtls/ecc/test/test_ecdsa.c | 79 - extlibs/tinydtls/examples/contiki/Makefile.in | 61 - extlibs/tinydtls/examples/contiki/dtls-client.c | 337 - extlibs/tinydtls/examples/contiki/dtls-server.c | 332 - extlibs/tinydtls/global.h | 157 - extlibs/tinydtls/hmac.c | 173 - extlibs/tinydtls/hmac.h | 154 - extlibs/tinydtls/netq.c | 140 - extlibs/tinydtls/netq.h | 103 - extlibs/tinydtls/numeric.h | 142 - extlibs/tinydtls/peer.c | 90 - extlibs/tinydtls/peer.h | 148 - extlibs/tinydtls/platform-specific/Makefile.in | 27 - .../tinydtls/platform-specific/config-cc2538dk.h | 2 - .../tinydtls/platform-specific/config-econotag.h | 2 - .../platform-specific/config-minimal-net.h | 1 - extlibs/tinydtls/platform-specific/config-sky.h | 3 - .../tinydtls/platform-specific/config-wismote.h | 1 - extlibs/tinydtls/prng.h | 82 - extlibs/tinydtls/session.c | 86 - extlibs/tinydtls/session.h | 93 - extlibs/tinydtls/sha2/Makefile.in | 78 - extlibs/tinydtls/sha2/README | 272 - extlibs/tinydtls/sha2/sha2.c | 1101 -- extlibs/tinydtls/sha2/sha2.h | 215 - extlibs/tinydtls/sha2/sha2prog.c | 132 - extlibs/tinydtls/sha2/sha2speed.c | 174 - extlibs/tinydtls/sha2/sha2test.pl | 358 - extlibs/tinydtls/sha2/testvectors/vector001.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector001.info | 21 - extlibs/tinydtls/sha2/testvectors/vector002.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector002.info | 21 - extlibs/tinydtls/sha2/testvectors/vector003.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector003.info | 22 - extlibs/tinydtls/sha2/testvectors/vector004.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector004.info | 22 - extlibs/tinydtls/sha2/testvectors/vector005.dat | 0 extlibs/tinydtls/sha2/testvectors/vector005.info | 23 - extlibs/tinydtls/sha2/testvectors/vector006.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector006.info | 22 - extlibs/tinydtls/sha2/testvectors/vector007.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector007.info | 22 - extlibs/tinydtls/sha2/testvectors/vector008.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector008.info | 22 - extlibs/tinydtls/sha2/testvectors/vector009.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector009.info | 22 - extlibs/tinydtls/sha2/testvectors/vector010.dat | Bin 320 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector010.info | 22 - extlibs/tinydtls/sha2/testvectors/vector011.dat | Bin 447 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector011.info | 22 - extlibs/tinydtls/sha2/testvectors/vector012.dat | Bin 640 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector012.info | 22 - extlibs/tinydtls/sha2/testvectors/vector013.dat | Bin 2175 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector013.info | 22 - extlibs/tinydtls/sha2/testvectors/vector014.dat | Bin 16384 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector014.info | 22 - extlibs/tinydtls/sha2/testvectors/vector015.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector015.info | 21 - extlibs/tinydtls/sha2/testvectors/vector016.dat | 1 - extlibs/tinydtls/sha2/testvectors/vector016.info | 23 - extlibs/tinydtls/sha2/testvectors/vector017.dat | Bin 12271 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector017.info | 32 - extlibs/tinydtls/sha2/testvectors/vector018.dat | Bin 1079 -> 0 bytes extlibs/tinydtls/sha2/testvectors/vector018.info | 26 - extlibs/tinydtls/state.h | 64 - extlibs/tinydtls/t_list.h | 147 - extlibs/tinydtls/tests/Makefile.in | 84 - extlibs/tinydtls/tests/cbc_aes128-test.c | 60 - extlibs/tinydtls/tests/cbc_aes128-testdata.c | 72 - extlibs/tinydtls/tests/ccm-test.c | 96 - extlibs/tinydtls/tests/ccm-testdata.c | 395 - extlibs/tinydtls/tests/dsrv-test.c | 108 - extlibs/tinydtls/tests/dtls-client.c | 905 -- extlibs/tinydtls/tests/dtls-server.c | 741 - extlibs/tinydtls/tests/netq-test.c | 103 - extlibs/tinydtls/tests/pcap.c | 478 - extlibs/tinydtls/tests/prf-test.c | 31 - extlibs/tinydtls/tests/secure-server.c | 862 - extlibs/tinydtls/tinydtls.h | 63 - extlibs/tinydtls/tinydtls.h.in | 50 - extlibs/tinydtls/uthash.h | 972 -- extlibs/tinydtls/utlist.h | 490 - gbsbuild.sh | 48 +- iotivity.pc.in | 2 +- packaging/iotivity.pc.in | 24 + packaging/iotivity.spec | 156 +- packaging/snapshot_history.txt | 2901 ++++ resource/SConscript | 11 +- resource/c_common/SConscript | 27 +- resource/c_common/ocrandom/src/ocrandom.c | 3 +- resource/c_common/octhread/include/octhread.h | 216 + .../octhread/src/noop/octhread.c} | 67 +- .../octhread/src/posix/octhread.c} | 267 +- resource/c_common/octhread/src/windows/octhread.c | 287 + resource/c_common/platform_features.h | 27 +- resource/c_common/utlist.h | 892 + resource/csdk/SConscript | 11 +- resource/csdk/connectivity/SConscript | 8 +- resource/csdk/connectivity/api/cacommon.h | 60 +- resource/csdk/connectivity/api/cainterface.h | 9 +- .../csdk/connectivity/api/casecurityinterface.h | 128 +- resource/csdk/connectivity/api/cautilinterface.h | 146 +- .../csdk/connectivity/build/android/jni/Android.mk | 9 +- resource/csdk/connectivity/build/tizen/Makefile | 5 +- resource/csdk/connectivity/build/tizen/gbsbuild.sh | 1 - .../build/tizen/packaging/com.oic.ca.spec | 10 +- .../csdk/connectivity/build/tizen/scons/SConscript | 3 + resource/csdk/connectivity/common/SConscript | 9 +- resource/csdk/connectivity/common/inc/camutex.h | 144 - .../csdk/connectivity/common/inc/cathreadpool.h | 21 +- resource/csdk/connectivity/common/inc/uarraylist.h | 12 +- resource/csdk/connectivity/common/inc/uqueue.h | 16 + .../csdk/connectivity/common/src/caremotehandler.c | 5 + .../common/src/cathreadpool_pthreads.c | 164 +- resource/csdk/connectivity/common/src/uarraylist.c | 24 +- resource/csdk/connectivity/common/src/uqueue.c | 55 + .../csdk/connectivity/inc/ca_adapter_net_ssl.h | 27 +- .../csdk/connectivity/inc/caadapterinterface.h | 9 +- resource/csdk/connectivity/inc/caadapternetdtls.h | 6 +- resource/csdk/connectivity/inc/caadapterutils.h | 35 + .../csdk/connectivity/inc/cablockwisetransfer.h | 22 +- resource/csdk/connectivity/inc/caedrinterface.h | 5 +- resource/csdk/connectivity/inc/cafragmentation.h | 40 +- .../csdk/connectivity/inc/cainterfacecontroller.h | 38 +- resource/csdk/connectivity/inc/caipinterface.h | 37 +- resource/csdk/connectivity/inc/caleadapter.h | 2 + resource/csdk/connectivity/inc/caleinterface.h | 18 + resource/csdk/connectivity/inc/camessagehandler.h | 28 +- resource/csdk/connectivity/inc/canfcinterface.h | 5 +- resource/csdk/connectivity/inc/caqueueingthread.h | 31 +- resource/csdk/connectivity/inc/caretransmission.h | 14 +- resource/csdk/connectivity/inc/catcpadapter.h | 15 +- resource/csdk/connectivity/inc/catcpinterface.h | 35 +- .../lib/libcoap-4.1.1/include/coap/address.h | 3 + .../lib/libcoap-4.1.1/include/coap/config.h | 3 + .../lib/libcoap-4.1.1/include/coap/encode.h | 2 +- .../lib/libcoap-4.1.1/include/coap/net.h | 4 + .../csdk/connectivity/lib/libcoap-4.1.1/resource.c | 2 +- resource/csdk/connectivity/src/SConscript | 40 +- .../src/adapter_util/ca_adapter_net_ssl.c | 1573 +- .../connectivity/src/adapter_util/caadapterutils.c | 89 + .../src/adapter_util/cafragmentation.c | 53 +- .../src/bt_edr_adapter/android/caedrclient.c | 40 +- .../src/bt_edr_adapter/android/caedrnwmonitor.c | 2 +- .../src/bt_edr_adapter/android/caedrserver.c | 118 +- .../src/bt_edr_adapter/android/caedrutils.c | 2 + .../connectivity/src/bt_edr_adapter/caedradapter.c | 32 +- .../src/bt_edr_adapter/tizen/caedrclient.c | 100 +- .../src/bt_edr_adapter/tizen/caedrendpoint.c | 27 +- .../src/bt_edr_adapter/tizen/caedrendpoint.h | 4 +- .../src/bt_edr_adapter/tizen/caedrserver.c | 2 +- .../src/bt_le_adapter/android/SConscript | 3 +- .../src/bt_le_adapter/android/caleclient.c | 2720 ++-- .../src/bt_le_adapter/android/caleclient.h | 141 +- .../src/bt_le_adapter/android/calenwmonitor.c | 80 +- .../src/bt_le_adapter/android/caleserver.c | 661 +- .../src/bt_le_adapter/android/caleserver.h | 26 +- .../src/bt_le_adapter/android/calestate.c | 463 + .../src/bt_le_adapter/android/calestate.h | 178 + .../src/bt_le_adapter/android/caleutils.c | 126 +- .../src/bt_le_adapter/android/caleutils.h | 20 +- .../android/org_iotivity_ca_CaLeClientInterface.h | 86 +- .../android/org_iotivity_ca_CaLeServerInterface.h | 58 +- .../connectivity/src/bt_le_adapter/caleadapter.c | 1440 +- .../connectivity/src/bt_le_adapter/ios/SConscript | 15 + .../src/bt_le_adapter/ios/caleclient.h | 509 + .../src/bt_le_adapter/ios/caleclient.m | 2954 ++++ .../src/bt_le_adapter/ios/calenwmonitor.h | 51 + .../src/bt_le_adapter/ios/calenwmonitor.m | 305 + .../src/bt_le_adapter/ios/caleserver.h | 240 + .../src/bt_le_adapter/ios/caleserver.m | 982 ++ .../connectivity/src/bt_le_adapter/ios/caleutils.h | 66 + .../src/bt_le_adapter/linux/caleinterface.c | 117 +- .../connectivity/src/bt_le_adapter/linux/central.c | 20 +- .../src/bt_le_adapter/linux/characteristic.c | 4 +- .../connectivity/src/bt_le_adapter/linux/client.c | 40 +- .../connectivity/src/bt_le_adapter/linux/context.h | 6 +- .../src/bt_le_adapter/linux/peripheral.c | 58 +- .../src/bt_le_adapter/linux/peripheral.h | 4 +- .../connectivity/src/bt_le_adapter/linux/recv.c | 4 +- .../connectivity/src/bt_le_adapter/linux/utils.c | 6 +- .../src/bt_le_adapter/tizen/SConscript | 30 +- .../src/bt_le_adapter/tizen/caleclient.c | 436 +- .../src/bt_le_adapter/tizen/caleclient.h | 30 + .../src/bt_le_adapter/tizen/calenwmonitor.c | 96 +- .../src/bt_le_adapter/tizen/calenwmonitor_vd.c | 334 + .../src/bt_le_adapter/tizen/caleserver.c | 224 +- .../src/bt_le_adapter/tizen/caleserver.h | 54 +- .../src/bt_le_adapter/tizen/caleserver_mcd.c | 1117 ++ .../src/bt_le_adapter/tizen/caleserver_vd.c | 1046 ++ .../csdk/connectivity/src/cablockwisetransfer.c | 266 +- .../csdk/connectivity/src/caconnectivitymanager.c | 36 +- .../csdk/connectivity/src/cainterfacecontroller.c | 133 +- resource/csdk/connectivity/src/camessagehandler.c | 589 +- .../csdk/connectivity/src/canetworkconfigurator.c | 10 - resource/csdk/connectivity/src/caprotocolmessage.c | 26 +- resource/csdk/connectivity/src/caqueueingthread.c | 153 +- resource/csdk/connectivity/src/caretransmission.c | 158 +- .../csdk/connectivity/src/ip_adapter/SConscript | 5 +- .../src/ip_adapter/android/caifaddrs.c | 41 +- .../src/ip_adapter/android/caifaddrs.h | 38 +- .../csdk/connectivity/src/ip_adapter/caipadapter.c | 63 +- .../csdk/connectivity/src/ip_adapter/caipserver.c | 345 +- .../src/ip_adapter/ios/caipnwmonitor.m | 580 + .../src/ip_adapter/linux/caipnwmonitor.c | 33 +- .../src/ip_adapter/tizen/caipnwmonitor.c | 10 +- .../src/nfc_adapter/android/canfcserver.c | 2 +- .../connectivity/src/nfc_adapter/canfcadapter.c | 17 +- .../csdk/connectivity/src/ra_adapter/caraadapter.c | 52 +- .../csdk/connectivity/src/tcp_adapter/SConscript | 2 +- .../src/tcp_adapter/arduino/catcpserver_eth.cpp | 2 +- .../connectivity/src/tcp_adapter/catcpadapter.c | 190 +- .../connectivity/src/tcp_adapter/catcpserver.c | 575 +- resource/csdk/connectivity/test/SConscript | 2 +- .../csdk/connectivity/test/ca_api_unittest.cpp | 8 +- .../csdk/connectivity/test/cablocktransfertest.cpp | 2 +- .../test/{camutex_tests.cpp => octhread_tests.cpp} | 156 +- .../csdk/connectivity/test/ssladapter_test.cpp | 1115 +- resource/csdk/connectivity/util/SConscript | 29 +- .../connectivity/util/inc/caconnectionmanager.h | 118 + .../connectivity/util/inc/camanagerleinterface.h | 61 + .../android/caleautoconnector.c | 56 +- .../android/caleautoconnector.h | 0 .../android/caleconnectionmanager.c | 49 +- .../{ => bt_le_manager}/android/camanagerdevice.c | 83 +- .../{ => bt_le_manager}/android/camanagerdevice.h | 2 +- .../{ => bt_le_manager}/android/camanagerleutil.c | 11 - .../{ => bt_le_manager}/android/camanagerleutil.h | 0 .../bt_le_manager/ios/caleautoconnector.h | 73 + .../bt_le_manager/ios/caleautoconnector.m | 222 + .../bt_le_manager/ios/caleconnectionmanager.m | 413 + .../camanager/bt_le_manager/ios/camanagerdevice.h | 128 + .../camanager/bt_le_manager/ios/camanagerdevice.m | 351 + .../camanager/bt_le_manager/ios/camanagerleutil.h | 103 + .../camanager/bt_le_manager/ios/camanagerleutil.m | 295 + .../tizen/caleconnectionmanager.c | 79 +- .../util/src/camanager/caconnectionmanager.c | 166 + .../util/src/camanager/camanagerutil.c | 28 + .../util/src/camanager/camanagerutil.h | 44 + .../util/src/camanager/camessagearbiter.c | 25 + .../util/src/camanager/camessagearbiter.h | 45 + .../util/src/camanager/capolicymanager.c | 65 + .../util/src/camanager/capolicymanager.h | 71 + .../csdk/connectivity/util/src/cautilinterface.c | 499 +- resource/csdk/logger/SConscript | 22 +- resource/csdk/logger/include/logger.h | 168 +- resource/csdk/logger/include/tizenrt_logger.h | 35 + resource/csdk/logger/include/trace.h | 93 + resource/csdk/logger/src/logger.c | 108 +- resource/csdk/logger/src/trace.c | 222 + resource/csdk/octbstack_product.def | 2 + resource/csdk/octbstack_product_secured.def | 17 +- resource/csdk/resource-directory/SConscript | 6 +- .../csdk/resource-directory/include/rd_client.h | 127 +- .../samples/rd_publishingClient.cpp | 4 +- resource/csdk/resource-directory/src/RDClient.cpp | 4 +- resource/csdk/resource-directory/src/rd_client.c | 55 +- resource/csdk/resource-directory/src/rd_server.c | 2 + .../csdk/resource-directory/unittests/rdtests.cpp | 18 +- resource/csdk/routing/src/routingmanager.c | 4 +- resource/csdk/routing/src/routingutility.c | 30 +- resource/csdk/security/SConscript | 8 +- .../csdk/security/include/internal/aclresource.h | 4 +- .../csdk/security/include/internal/credresource.h | 27 +- .../csdk/security/include/internal/crlresource.h | 2 +- .../csdk/security/include/internal/doxmresource.h | 61 +- .../csdk/security/include/internal/policyengine.h | 4 +- .../csdk/security/include/internal/psinterface.h | 66 +- resource/csdk/security/include/internal/psiutils.h | 72 + .../csdk/security/include/internal/pstatresource.h | 22 + .../include/internal/secureresourcemanager.h | 6 + .../security/include/internal/security_internals.h | 19 - .../security/include/internal/srmresourcestrings.h | 29 +- .../csdk/security/include/internal/svcresource.h | 60 - resource/csdk/security/include/oxmverifycommon.h | 142 + resource/csdk/security/include/pinoxmcommon.h | 32 +- resource/csdk/security/include/pkix_interface.h | 61 + .../security/include/securevirtualresourcetypes.h | 73 +- resource/csdk/security/include/srmutility.h | 53 + resource/csdk/security/provisioning/SConscript | 7 +- .../internal/multipleownershiptransfermanager.h | 17 +- .../provisioning/include/internal/otmcontextlist.h | 9 +- .../include/internal/ownershiptransfermanager.h | 34 +- .../include/internal/provisioningdatabasemanager.h | 9 + .../include/internal/secureresourceprovider.h | 2 +- .../provisioning/include/ocprovisioningmanager.h | 121 +- .../provisioning/include/oxm/oxmjustworks.h | 14 + .../provisioning/include/oxm/oxmmanufacturercert.h | 13 + .../csdk/security/provisioning/include/pmtypes.h | 27 +- .../csdk/security/provisioning/include/pmutility.h | 21 +- .../csdk/security/provisioning/sample/SConscript | 41 +- .../security/provisioning/sample/cloud/cloudAuth.c | 4 + .../provisioning/sample/cloud/cloudCommon.c | 139 +- .../provisioning/sample/cloud/cloudDiscovery.c | 42 +- .../provisioning/sample/cloud/cloudWrapper.c | 38 +- .../provisioning/sample/hw_emul/hw_interface.c | 348 + .../provisioning/sample/hw_emul/hw_interface.h | 93 + .../security/provisioning/sample/hw_emul/ss_emul.c | 366 + .../security/provisioning/sample/hw_emul/ss_emul.h | 119 + .../provisioning/sample/oic_svr_db_client.dat | Bin 859 -> 2361 bytes .../oic_svr_db_randompin_with_empty_deviceid.dat | Bin 978 -> 920 bytes .../oic_svr_db_randompin_with_empty_deviceid.json | 6 - .../sample/oic_svr_db_server_justworks.dat | Bin 977 -> 919 bytes .../sample/oic_svr_db_server_justworks.json | 6 - .../sample/oic_svr_db_server_justworks_default.dat | Bin 0 -> 919 bytes ...c_svr_db_server_justworks_protectedDB_plain.dat | Bin 0 -> 919 bytes .../sample/oic_svr_db_server_mvjustworks.dat | Bin 0 -> 922 bytes .../sample/oic_svr_db_server_mvjustworks.json | 73 + .../sample/oic_svr_db_server_preconfpin.dat | Bin 0 -> 922 bytes .../sample/oic_svr_db_server_preconfpin.json | 73 + .../sample/oic_svr_db_server_randompin.dat | Bin 978 -> 920 bytes .../sample/oic_svr_db_server_randompin.json | 6 - .../provisioning/sample/provisioningclient.c | 526 +- .../csdk/security/provisioning/sample/rootca.crt | 36 +- .../provisioning/sample/sampleserver_justworks.cpp | 37 +- .../sample/sampleserver_justworks_protectedDB.cpp | 528 + .../provisioning/sample/sampleserver_mfg.cpp | 91 +- .../sample/sampleserver_mvjustworks.cpp | 531 + .../sample/sampleserver_preconfpin.cpp | 482 + .../provisioning/sample/sampleserver_randompin.cpp | 24 +- .../security/provisioning/sample/subownerclient.c | 9 +- .../csdk/security/provisioning/src/cloud/aclid.c | 37 +- .../csdk/security/provisioning/src/cloud/csr.c | 14 +- .../provisioning/src/credentialgenerator.c | 2 +- .../src/multipleownershiptransfermanager.c | 321 +- .../provisioning/src/ocprovisioningmanager.c | 163 +- .../security/provisioning/src/otmcontextlist.c | 65 +- .../provisioning/src/ownershiptransfermanager.c | 708 +- .../csdk/security/provisioning/src/oxmjustworks.c | 27 +- .../provisioning/src/oxmmanufacturercert.c | 19 +- .../csdk/security/provisioning/src/oxmpreconfpin.c | 11 +- .../csdk/security/provisioning/src/oxmrandompin.c | 41 +- .../csdk/security/provisioning/src/pmutility.c | 228 +- .../provisioning/src/provisioningdatabasemanager.c | 133 +- .../provisioning/src/secureresourceprovider.c | 238 +- .../csdk/security/provisioning/unittest/SConscript | 7 +- .../security/provisioning/unittest/otmunittest.cpp | 16 +- .../provisioning/unittest/sampleserver1.cpp | 30 +- .../provisioning/unittest/sampleserver2.cpp | 30 +- .../unittest/secureresourceprovider.cpp | 20 +- resource/csdk/security/src/aclresource.c | 78 +- resource/csdk/security/src/credresource.c | 1176 +- resource/csdk/security/src/crlresource.c | 25 +- resource/csdk/security/src/directpairing.c | 19 +- resource/csdk/security/src/doxmresource.c | 844 +- resource/csdk/security/src/dpairingresource.c | 12 +- resource/csdk/security/src/oxmpincommon.c | 44 +- resource/csdk/security/src/oxmverifycommon.c | 170 + resource/csdk/security/src/pbkdf2.c | 180 +- resource/csdk/security/src/pconfresource.c | 13 +- resource/csdk/security/src/pkix_interface.c | 426 +- resource/csdk/security/src/policyengine.c | 43 +- resource/csdk/security/src/psinterface.c | 748 +- resource/csdk/security/src/psiutils.c | 309 + resource/csdk/security/src/pstatresource.c | 89 +- resource/csdk/security/src/resourcemanager.c | 16 +- resource/csdk/security/src/secureresourcemanager.c | 170 +- resource/csdk/security/src/srmresourcestrings.c | 37 +- resource/csdk/security/src/srmutility.c | 161 +- resource/csdk/security/src/svcresource.c | 477 - resource/csdk/security/src/verresource.c | 4 +- resource/csdk/security/tool/SConscript | 90 +- resource/csdk/security/tool/json2cbor.c | 145 +- .../security/tool/svrdbeditor_src/svrdbeditor.c | 333 + .../security/tool/svrdbeditor_src/svrdbeditoracl.c | 812 + .../security/tool/svrdbeditor_src/svrdbeditoracl.h | 31 + .../tool/svrdbeditor_src/svrdbeditorcommon.c | 174 + .../tool/svrdbeditor_src/svrdbeditorcommon.h | 75 + .../tool/svrdbeditor_src/svrdbeditorcred.c | 1364 ++ .../tool/svrdbeditor_src/svrdbeditorcred.h | 31 + .../tool/svrdbeditor_src/svrdbeditordoxm.c | 636 + .../tool/svrdbeditor_src/svrdbeditordoxm.h | 33 + .../tool/svrdbeditor_src/svrdbeditorpstat.c | 490 + .../tool/svrdbeditor_src/svrdbeditorpstat.h | 31 + resource/csdk/security/unittest/SConscript | 7 +- .../csdk/security/unittest/aclresourcetest.cpp | 6 +- .../csdk/security/unittest/credentialresource.cpp | 35 +- .../csdk/security/unittest/crlresourcetest.cpp | 4 +- resource/csdk/security/unittest/doxmresource.cpp | 22 - resource/csdk/security/unittest/psinterface.cpp | 124 + .../security/unittest/securityresourcemanager.cpp | 38 +- resource/csdk/security/unittest/srmtestcommon.cpp | 11 +- resource/csdk/security/unittest/srmutility.cpp | 21 + .../csdk/security/unittest/svcresourcetest.cpp | 90 - resource/csdk/stack/include/internal/occlientcb.h | 2 + resource/csdk/stack/include/internal/ocresource.h | 2 +- .../csdk/stack/include/internal/ocstackinternal.h | 34 +- .../{oickeepalive.h => oickeepaliveinternal.h} | 34 +- resource/csdk/stack/include/ocpayload.h | 6 +- resource/csdk/stack/include/ocstack.h | 158 +- resource/csdk/stack/include/ocstackconfig.h | 8 +- resource/csdk/stack/include/octypes.h | 106 +- resource/csdk/stack/include/oickeepalive.h | 84 + resource/csdk/stack/include/payload_logging.h | 36 +- .../samples/linux/SimpleClientServer/SConscript | 3 - .../samples/linux/SimpleClientServer/occlient.cpp | 27 +- .../linux/SimpleClientServer/occlientbasicops.cpp | 13 +- .../linux/SimpleClientServer/occlientcoll.cpp | 34 +- .../linux/SimpleClientServer/occlientslow.cpp | 13 +- .../SimpleClientServer/ocremoteaccessclient.cpp | 46 +- .../samples/linux/SimpleClientServer/ocserver.cpp | 1 + .../linux/SimpleClientServer/ocservercoll.cpp | 7 +- .../linux/SimpleClientServer/ocserverslow.cpp | 6 +- .../csdk/stack/samples/linux/secure/SConscript | 1 - .../samples/linux/secure/occlientbasicops.cpp | 19 +- .../samples/linux/secure/occlientdirectpairing.cpp | 16 +- .../samples/linux/secure/ocserverbasicops.cpp | 2 +- .../secure/oic_svr_db_client_directpairing.dat | Bin 977 -> 919 bytes .../secure/oic_svr_db_client_directpairing.json | 10 +- .../samples/linux/secure/oic_svr_db_server.dat | Bin 1807 -> 1714 bytes .../samples/linux/secure/oic_svr_db_server.json | 16 +- .../linux/secure/oic_svr_db_server_justworks.dat | Bin 977 -> 919 bytes .../linux/secure/oic_svr_db_server_justworks.json | 8 +- .../samples/tizen/SimpleClientServer/SConscript | 1 + .../samples/tizen/SimpleClientServer/occlient.cpp | 96 +- .../samples/tizen/SimpleClientServer/occlient.h | 1 + .../samples/tizen/SimpleClientServer/ocserver.cpp | 41 +- .../tizen/SimpleClientServer/oic_svr_db_client.dat | Bin 0 -> 1150 bytes .../SimpleClientServer/oic_svr_db_client.json | 89 + .../tizen/SimpleClientServer/oic_svr_db_server.dat | Bin 0 -> 1242 bytes .../SimpleClientServer/oic_svr_db_server.json | 101 + .../tizen/SimpleClientServer/scons/SConscript | 6 +- .../csdk/stack/samples/tizen/build/gbsbuild.sh | 1 - .../samples/tizen/build/packaging/com.oic.ri.spec | 8 +- .../stack/samples/tizen/build/scons/SConscript | 3 + resource/csdk/stack/src/occlientcb.c | 21 +- resource/csdk/stack/src/occollection.c | 17 +- resource/csdk/stack/src/ocobserve.c | 7 +- resource/csdk/stack/src/ocpayload.c | 44 +- resource/csdk/stack/src/ocpayloadconvert.c | 8 + resource/csdk/stack/src/ocpayloadparse.c | 42 +- resource/csdk/stack/src/ocresource.c | 165 +- resource/csdk/stack/src/ocserverrequest.c | 18 +- resource/csdk/stack/src/ocstack.c | 700 +- resource/csdk/stack/src/oicgroup.c | 7 + resource/csdk/stack/src/oickeepalive.c | 786 +- resource/csdk/stack/test/linux/SConscript | 3 +- resource/csdk/stack/test/linux/occlient.c | 5 +- resource/csdk/stack/test/stacktests.cpp | 396 +- resource/examples/SConscript | 4 + resource/examples/directpairingclient.cpp | 2 +- .../examples/oic_svr_db_client_directpairing.dat | Bin 977 -> 919 bytes .../examples/oic_svr_db_client_directpairing.json | 10 +- resource/examples/oic_svr_db_server.dat | Bin 1241 -> 1241 bytes resource/examples/oic_svr_db_server.json | 2 +- resource/examples/rdclient.cpp | 18 +- resource/examples/simpleclient.cpp | 7 +- resource/examples/simpleserver.cpp | 5 +- resource/include/CAManager.h | 105 +- resource/include/IClientWrapper.h | 19 +- resource/include/IServerWrapper.h | 14 + resource/include/InProcClientWrapper.h | 45 +- resource/include/InProcServerWrapper.h | 14 + resource/include/OCApi.h | 117 +- resource/include/OCCloudProvisioning.hpp | 4 + resource/include/OCPlatform.h | 43 +- resource/include/OCPlatform_impl.h | 14 +- resource/include/OCProvisioningManager.hpp | 321 +- resource/include/OCRepresentation.h | 35 +- resource/include/OCResource.h | 41 +- resource/include/OCSerialization.h | 58 +- resource/include/OutOfProcClientWrapper.h | 28 +- resource/include/OutOfProcServerWrapper.h | 10 + resource/include/ResourceInitException.h | 99 +- resource/include/StringConstants.h | 13 + resource/provisioning/SConscript | 6 +- resource/provisioning/examples/SConscript | 14 +- resource/provisioning/examples/cloudClient.cpp | 54 +- resource/provisioning/examples/cloudWrapper.cpp | 90 +- .../examples/oic_svr_db_subowner_client.dat | Bin 0 -> 1027 bytes .../examples/oic_svr_db_subowner_client.json | 85 + .../provisioning/examples/provisioningclient.cpp | 500 +- resource/provisioning/examples/subownerclient.cpp | 394 + .../provisioning/src/OCProvisioningManager.cpp | 770 +- .../provisioning/unittests/OCProvisioningTest.cpp | 123 +- resource/provisioning/unittests/SConscript | 0 resource/src/CAManager.cpp | 100 +- resource/src/InProcClientWrapper.cpp | 354 +- resource/src/InProcServerWrapper.cpp | 116 +- resource/src/OCException.cpp | 18 + resource/src/OCPlatform.cpp | 34 +- resource/src/OCPlatform_impl.cpp | 150 +- resource/src/OCRepresentation.cpp | 16 +- resource/src/OCResource.cpp | 92 +- resource/src/SConscript | 4 + resource/unittests/OCExceptionTest.cpp | 38 +- resource/unittests/OCRepresentationTest.cpp | 5 +- service/SConscript | 23 +- service/coap-http-proxy/include/CoapHttpMap.h | 4 + service/coap-http-proxy/src/CoapHttpHandler.c | 4 + .../coap-http-proxy/unittests/CoAPHttpUnitTest.cpp | 4 + service/coap-http-proxy/unittests/SConscript | 3 +- service/easy-setup/enrollee/SConscript | 20 +- service/easy-setup/enrollee/inc/ESEnrolleeCommon.h | 39 +- service/easy-setup/enrollee/inc/easysetup.h | 11 +- .../easy-setup/enrollee/inc/samsung/sc_easysetup.h | 153 + service/easy-setup/enrollee/src/easysetup.c | 97 +- service/easy-setup/enrollee/src/resourcehandler.c | 761 +- service/easy-setup/enrollee/src/resourcehandler.h | 29 +- .../easy-setup/enrollee/src/samsung/sc_easysetup.c | 579 + .../enrollee/unittests/ESEnrolleeTest.cpp | 63 +- .../enrollee/unittests/ESMediatorSimulator.h | 31 +- service/easy-setup/inc/escommon.h | 139 +- service/easy-setup/mediator/richsdk/SConscript | 21 +- .../service/easysetup/mediator/CloudProp.java | 73 + .../service/easysetup/mediator/ESConstants.java | 23 +- .../service/easysetup/mediator/EasySetup.java | 2 +- .../service/easysetup/mediator/EnrolleeConf.java | 36 +- .../easysetup/mediator/enums/ESErrorCode.java | 6 + .../easysetup/mediator/enums/OAUTH_TOKENTYPE.java | 66 + .../easysetup/mediator/samsung/SCDeviceProp.java | 87 + .../easysetup/mediator/samsung/SCEnrolleeConf.java | 100 + .../EasySetupCore/src/main/jni/Application.mk | 2 +- .../EasySetupCore/src/main/jni/JniEasySetup.cpp | 4 +- .../src/main/jni/JniEsListenerManager.h | 3 +- .../main/jni/JniGetConfigurationStatusListener.cpp | 2 +- .../easy-setup/mediator/richsdk/inc/ESRichCommon.h | 420 +- .../easy-setup/mediator/richsdk/inc/ESSCCommon.h | 913 ++ .../easy-setup/mediator/richsdk/inc/EasySetup.hpp | 4 +- .../mediator/richsdk/inc/RemoteEnrollee.h | 91 +- .../mediator/richsdk/src/CloudResource.cpp | 40 +- .../mediator/richsdk/src/CloudResource.h | 10 +- .../easy-setup/mediator/richsdk/src/EasySetup.cpp | 15 +- .../mediator/richsdk/src/EnrolleeResource.cpp | 167 +- .../mediator/richsdk/src/EnrolleeResource.h | 20 +- .../mediator/richsdk/src/EnrolleeSecurity.cpp | 1088 +- .../mediator/richsdk/src/EnrolleeSecurity.h | 48 +- .../mediator/richsdk/src/RemoteEnrollee.cpp | 384 +- .../richsdk/unittests/ESEnrolleeSimulator.h | 16 +- .../mediator/richsdk/unittests/ESMediatorTest.cpp | 23 +- .../sampleapp/enrollee/linux-samsung/SConscript | 70 + .../enrollee/linux-samsung/oic_svr_db_server.dat | Bin 0 -> 997 bytes .../sampleapp/enrollee/linux-samsung/sc_enrollee.c | 318 + .../easy-setup/sampleapp/enrollee/linux/SConscript | 9 +- .../sampleapp/enrollee/linux/easysetup_x.c | 15 +- .../sampleapp/enrollee/linux/enrolleewifi.c | 66 +- .../sampleapp/enrollee/linux/oic_svr_db_server.dat | Bin 997 -> 977 bytes .../enrollee/linux/oic_svr_db_server_MOT.dat | Bin 0 -> 2180 bytes .../enrollee/tizen-sdb/EnrolleeSample/SConscript | 7 + .../EnrolleeSample/build/tizen/gbsbuild.sh | 3 +- .../tizen-sdb/EnrolleeSample/enrolleewifi.cpp | 48 +- .../tizen-sdb/EnrolleeSample/scons/SConscript | 4 +- .../sampleapp/mediator/android-samsung/.gitignore | 50 + .../android-samsung/EasySetup/EasySetup.iml | 19 + .../android-samsung/EasySetup/EasySetupGradle.iml | 19 + .../mediator/android-samsung/EasySetup/app/app.iml | 98 + .../android-samsung/EasySetup/app/build.gradle | 58 + .../EasySetup/app/proguard-rules.pro | 17 + .../EasySetup/app/src/main/AndroidManifest.xml | 38 + .../app/src/main/assets/oic_svr_db_client.dat | Bin 0 -> 1000 bytes .../app/src/main/assets/oic_svr_db_client.json | 88 + .../service/easysetup/EasysetupActivity.java | 1136 ++ .../iotivity/service/easysetup/LoginActivity.java | 125 + .../app/src/main/res/drawable-hdpi/background.png | Bin 0 -> 60847 bytes .../app/src/main/res/drawable-hdpi/cancel.png | Bin 0 -> 27421 bytes .../app/src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 7658 bytes .../app/src/main/res/drawable-hdpi/icon.png | Bin 0 -> 2486 bytes .../app/src/main/res/layout/activity_login.xml | 15 + .../app/src/main/res/layout/easysetup_main.xml | 882 + .../EasySetup/app/src/main/res/menu/main.xml | 11 + .../EasySetup/app/src/main/res/values/arrays.xml | 17 + .../EasySetup/app/src/main/res/values/dimens.xml | 7 + .../EasySetup/app/src/main/res/values/strings.xml | 23 + .../EasySetup/app/src/main/res/values/styles.xml | 20 + .../android-samsung/EasySetup/build.gradle | 39 + .../android-samsung/EasySetup/gradle.properties | 47 + .../android-samsung/EasySetup/settings.gradle | 21 + .../sampleapp/mediator/android-samsung/SConscript | 78 + .../app/src/main/assets/oic_svr_db_client.dat | Bin 980 -> 859 bytes .../app/src/main/assets/oic_svr_db_client.json | 12 - .../service/easysetup/EasysetupActivity.java | 2 +- .../linux-samsung/richsdk_sample/SConscript | 78 + .../linux-samsung/richsdk_sample/mediator_sc.cpp | 461 + .../richsdk_sample/oic_svr_db_client.dat | Bin 0 -> 3071 bytes .../mediator/linux/richsdk_sample/SConscript | 10 +- .../mediator/linux/richsdk_sample/mediator.cpp | 513 + .../linux/richsdk_sample/oic_svr_db_subclient.dat | Bin 0 -> 1027 bytes .../{mediator_cpp.cpp => submediator.cpp} | 128 +- service/notification/SConscript | 38 +- service/notification/android/SConscript | 2 +- .../iotivity/service/ns/common/MediaContents.java | 30 +- .../org/iotivity/service/ns/common/Message.java | 112 +- .../iotivity/service/ns/common/NSErrorCode.java | 60 +- .../iotivity/service/ns/common/NSException.java | 32 +- .../org/iotivity/service/ns/common/SyncInfo.java | 53 +- .../java/org/iotivity/service/ns/common/Topic.java | 53 +- .../org/iotivity/service/ns/common/TopicsList.java | 41 +- .../service/ns/consumer/ConsumerService.java | 117 +- .../org/iotivity/service/ns/consumer/Provider.java | 250 +- .../org/iotivity/service/ns/provider/Consumer.java | 109 +- .../service/ns/provider/ProviderService.java | 299 +- .../notification-service/src/main/jni/Android.mk | 6 + .../src/main/jni/common/JniNotificationCommon.cpp | 11 +- .../src/main/jni/common/JniNotificationCommon.h | 10 +- .../src/main/jni/common/JniSharedObjectHolder.h | 49 + .../main/jni/consumer/JniNotificationConsumer.cpp | 1023 +- .../main/jni/consumer/JniNotificationConsumer.h | 36 +- .../main/jni/provider/JniNotificationProvider.cpp | 812 +- .../main/jni/provider/JniNotificationProvider.h | 49 +- .../notification/cpp-wrapper/common/NSException.h | 67 + .../cpp-wrapper/common/NSTopicsList.cpp | 59 +- .../notification/cpp-wrapper/common/NSTopicsList.h | 16 +- .../notification/cpp-wrapper/consumer/SConscript | 12 + .../cpp-wrapper/consumer/inc/NSAcceptedProviders.h | 119 + .../cpp-wrapper/consumer/inc/NSConsumerService.h | 46 +- .../cpp-wrapper/consumer/inc/NSProvider.h | 528 +- .../consumer/src/NSAcceptedProviders.cpp | 96 + .../cpp-wrapper/consumer/src/NSConsumerService.cpp | 608 +- .../cpp-wrapper/consumer/src/NSProvider.cpp | 112 +- .../cpp-wrapper/examples/linux/SConscript | 20 +- .../examples/linux/notificationserviceconsumer.cpp | 723 +- .../examples/linux/notificationserviceprovider.cpp | 844 +- .../notification/cpp-wrapper/provider/SConscript | 15 +- .../cpp-wrapper/provider/inc/NSAcceptedConsumers.h | 116 + .../cpp-wrapper/provider/inc/NSConsumer.h | 7 +- .../cpp-wrapper/provider/inc/NSProviderService.h | 45 +- .../provider/src/NSAcceptedConsumers.cpp | 98 + .../cpp-wrapper/provider/src/NSConsumer.cpp | 37 +- .../cpp-wrapper/provider/src/NSProviderService.cpp | 160 +- .../unittest/NSConsumerServiceSimulator.h | 28 +- .../cpp-wrapper/unittest/NSConsumerServiceTest.cpp | 102 +- .../unittest/NSProviderServiceSimulator.h | 58 +- .../cpp-wrapper/unittest/NSProviderServiceTest.cpp | 113 +- .../notification/cpp-wrapper/unittest/SConscript | 2 +- .../android/NotiConsumerExample/SConscript | 6 +- .../android/NotiConsumerExample/app/build.gradle | 5 + .../ns/sample/consumer/ExampleUnitTest.java | 574 + .../ns/sample/consumer/ProviderSimulator.java | 68 + .../app/src/main/AndroidManifest.xml | 4 +- .../com/sec/noticonsumerexample/MainActivity.java | 271 - .../ns/sample/consumer}/ConsumerSample.java | 249 +- .../service/ns/sample/consumer/LoginActivity.java | 116 + .../service/ns/sample/consumer/MainActivity.java | 671 + .../app/src/main/res/layout/activity_login.xml | 16 + .../app/src/main/res/layout/activity_main.xml | 79 +- .../app/src/main/res/layout/dialog_auth.xml | 68 + .../app/src/main/res/layout/dialog_entry.xml | 39 + .../app/src/main/res/layout/dialog_mq.xml | 68 + .../app/src/main/res/values/strings.xml | 9 +- .../android/NotiProviderExample/SConscript | 8 +- .../android/NotiProviderExample/app/build.gradle | 7 +- .../ns/sample/provider/ConsumerSimulator.java | 89 + .../ns/sample/provider/ExampleUnitTest.java | 449 + .../app/src/main/AndroidManifest.xml | 6 +- .../com/sec/notiproviderexample/MainActivity.java | 292 - .../sec/notiproviderexample/ProviderSample.java | 274 - .../service/ns/sample/provider/LoginActivity.java | 117 + .../service/ns/sample/provider/MainActivity.java | 721 + .../service/ns/sample/provider}/NotiListener.java | 297 +- .../service/ns/sample/provider/ProviderSample.java | 267 + .../app/src/main/res/layout/activity_login.xml | 16 + .../app/src/main/res/layout/activity_main.xml | 52 +- .../app/src/main/res/layout/dialog_auth.xml | 68 + .../app/src/main/res/layout/dialog_entry.xml | 39 + .../app/src/main/res/layout/dialog_mq.xml | 68 + .../app/src/main/res/values/strings.xml | 6 + service/notification/examples/linux/SConscript | 20 +- .../examples/linux/notificationconsumer.c | 17 + .../examples/linux/notificationprovider.c | 25 +- service/notification/include/NSCommon.h | 4 +- service/notification/include/NSConsumerInterface.h | 19 +- service/notification/include/NSProviderInterface.h | 11 +- service/notification/src/common/NSConstants.h | 89 +- service/notification/src/common/NSStructs.h | 26 + service/notification/src/common/NSUtil.c | 192 +- service/notification/src/common/NSUtil.h | 3 + .../notification/src/consumer/NSConsumerCommon.c | 362 +- .../notification/src/consumer/NSConsumerCommon.h | 10 +- .../src/consumer/NSConsumerCommunication.c | 262 +- .../src/consumer/NSConsumerDiscovery.c | 213 +- .../src/consumer/NSConsumerInterface.c | 48 +- .../consumer/NSConsumerInternalTaskController.c | 6 +- .../notification/src/consumer/NSConsumerMQPlugin.c | 207 + .../notification/src/consumer/NSConsumerMQPlugin.h | 39 + .../src/consumer/NSConsumerMemoryCache.c | 3 +- .../src/consumer/NSConsumerNetworkEventListener.c | 6 +- .../src/consumer/NSConsumerScheduler.c | 13 +- .../src/provider/NSProviderCallbackResponse.c | 7 +- .../src/provider/NSProviderDiscovery.c | 4 +- .../src/provider/NSProviderInterface.c | 83 +- .../notification/src/provider/NSProviderListener.c | 209 +- .../notification/src/provider/NSProviderListener.h | 8 + .../src/provider/NSProviderMemoryCache.c | 107 +- .../src/provider/NSProviderNotification.c | 98 +- .../notification/src/provider/NSProviderResource.c | 38 +- .../src/provider/NSProviderScheduler.c | 660 +- .../src/provider/NSProviderSubscription.c | 100 +- .../notification/src/provider/NSProviderSystem.c | 55 +- .../notification/src/provider/NSProviderSystem.h | 105 +- .../notification/src/provider/NSProviderTopic.c | 1156 +- .../notification/unittest/NSConsumerSimulator.h | 42 +- .../notification/unittest/NSProviderSimulator.h | 58 +- service/notification/unittest/SConscript | 3 +- .../examples/BMISensorBundle/src/BMISensor.cpp | 12 +- .../HeightSensorApp/src/HeightSensorApp.cpp | 8 +- .../WeightSensorApp/src/WeightSensorApp.cpp | 6 +- .../examples/ContainerSample.cpp | 4 +- .../examples/ContainerSampleClient.cpp | 4 +- .../src/DiscomfortIndexSensor.cpp | 4 +- .../src/DiscomfortIndexSensorResource.cpp | 10 +- .../THSensorApp/src/ThingResourceServer.cpp | 8 +- .../THSensorApp1/src/ThingResourceServer1.cpp | 8 +- .../examples/HueSampleBundle/src/HueConnector.cpp | 8 +- service/resource-container/src/Configuration.cpp | 27 +- .../resource-container/src/RemoteResourceUnit.cpp | 4 +- .../resource-container/src/RemoteResourceUnit.h | 2 +- .../src/ResourceContainerImpl.cpp | 6 +- .../unittests/ResourceContainerTest.cpp | 6 +- service/resource-encapsulation/SConscript | 2 +- .../java/org/iotivity/service/RcsByteString.java | 23 + .../main/java/org/iotivity/service/RcsValue.java | 67 +- .../service/client/RcsRemoteResourceObject.java | 2 +- .../src/main/jni/JniRcsRemoteResourceObject.cpp | 8 +- .../android/service/src/main/jni/JniRcsValue.cpp | 74 + .../service/src/main/jni/util/JNIEnvWrapper.h | 31 +- .../service/src/main/jni/util/JavaClasses.h | 1 + .../sample/client/ResourceClientActivity.java | 2 +- .../examples/linux/NestedAttributesClient.cpp | 5 +- .../examples/linux/NestedAttributesServer.cpp | 6 +- .../examples/linux/SampleResourceClient.cpp | 26 +- .../examples/linux/SampleResourceServer.cpp | 33 +- .../examples/linux/SeparateResponseServer.cpp | 2 +- .../tizen/RESampleClientApp/src/reclient.cpp | 4 +- .../include/RCSRemoteResourceObject.h | 5 +- .../include/RCSResourceAttributes.h | 194 +- .../expiryTimer/unittests/ExpiryTimerTest.cpp | 4 +- .../primitiveResource/include/PrimitiveResource.h | 1 + .../include/PrimitiveResourceImpl.h | 5 + .../include/ResourceAttributesConverter.h | 89 +- .../src/RCSResourceAttributes.cpp | 27 +- .../unittests/PrimitiveResourceTest.cpp | 1 + .../unittests/ResourceAttributesTest.cpp | 42 + .../unittest/ResourceBrokerUnitTest.cpp | 10 +- .../unittest/ResourcePresenceUnitTest.cpp | 2 +- .../src/resourceCache/include/CacheTypes.h | 2 +- .../src/resourceCache/include/DataCache.h | 2 +- .../src/resourceCache/include/ObserveCache.h | 2 +- .../src/resourceCache/src/DataCache.cpp | 17 +- .../src/resourceCache/src/ObserveCache.cpp | 12 +- .../src/resourceCache/src/ResourceCacheManager.cpp | 39 +- .../src/resourceCache/unittests/DataCacheTest.cpp | 3 +- .../resourceCache/unittests/ResourceCacheTest.cpp | 3 +- .../src/resourceClient/RCSDiscoveryManagerImpl.cpp | 7 +- .../src/resourceClient/RCSRemoteResourceObject.cpp | 60 +- .../unittests/ResourceClientTest.cpp | 20 +- service/scene-manager/SConscript | 3 +- .../simulator/ramlparser/raml/IncludeResolver.h | 4 + .../raml/jsonSchemaParser/JsonSchema.cpp | 34 +- .../ramlparser/raml/jsonSchemaParser/JsonSchema.h | 4 + .../ramlparser/raml/jsonSchemaParser/Properties.h | 4 + service/simulator/ramlparser/raml/model/Raml.h | 4 + service/simulator/ramlparser/raml/model/Schema.h | 4 + tools/scons/URLDownload.py | 196 +- tools/scons/UnpackAll.py | 81 +- tools/tizen/.gbs.conf | 113 +- tools/tizen/.gbs.vd.tv.tizen30.conf | 79 + tools/tizen/iotivity-vd-tv-es-tizen30.spec | 360 + tools/tizen/iotivity-vd-tv-tizen30.spec | 361 + tools/tizen/iotivity.spec | 119 +- 897 files changed, 73100 insertions(+), 66870 deletions(-) create mode 100644 android/android_api/base/jni/JniConfirmNumListener.cpp create mode 100644 android/android_api/base/jni/JniConfirmNumListener.h create mode 100644 android/android_api/base/jni/JniDisplayVerifyNumListener.cpp create mode 100644 android/android_api/base/jni/JniDisplayVerifyNumListener.h create mode 100644 android/android_api/base/jni/JniKeepAliveListener.cpp create mode 100644 android/android_api/base/jni/JniKeepAliveListener.h mode change 100644 => 100755 android/android_api/base/jni/JniOcSecurity.cpp mode change 100644 => 100755 android/android_api/base/jni/JniOcSecurity.h create mode 100644 android/android_api/base/src/main/java/org/iotivity/base/MVJustWorksOptionMask.java create mode 100644 android/android_api/base/src/main/java/org/iotivity/base/PinType.java create mode 100644 android/android_api/base/src/main/java/org/iotivity/ca/CaTransportFlags.java mode change 100755 => 100644 android/examples/cloudprovisioningclient/src/main/java/org/iotivity/base/examples/cloudprovisioningclient/CloudProvisioningClient.java create mode 100644 android/examples/provisioningclient/src/main/assets/oic_svr_db_client_default.dat create mode 100644 android/examples/provisioningclient/src/main/assets/oic_svr_db_client_enc.dat create mode 100644 android/examples/provisioningclient/src/main/assets/oic_svr_db_client_plain.dat create mode 100644 android/examples/provisioningclient/src/main/assets/oic_svr_db_client_rescue.dat mode change 100755 => 100644 android/examples/settings.gradle create mode 100644 android/examples/simplebase/src/main/java/org/iotivity/base/examples/KeepAliveFragment.java create mode 100644 android/examples/simplebase/src/main/res/layout/fragment_keepalive.xml create mode 100755 build-da-checkout.sh create mode 100755 build-im-sc-android.sh create mode 100755 build-im-sc-android64.sh create mode 100644 build-im-sc-ios.sh create mode 100755 build-im-virtual_device-android.sh create mode 100644 build-vd-tv-es-tizen30.sh create mode 100755 build-vd-tv-tizen30.sh create mode 100644 build_common/tizenrt/SConscript create mode 100644 extlibs/mbedtls/mbedtls/library/net.c delete mode 100644 extlibs/tinycbor/tinycbor/Makefile.configure delete mode 100644 extlibs/tinycbor/tinycbor/Makefile.nmake delete mode 100644 extlibs/tinycbor/tinycbor/tools/Makefile delete mode 100644 extlibs/tinydtls/0001-Add-TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256-cipher-su.patch delete mode 100644 extlibs/tinydtls/0001-Added-anonymous-ecdh-cipher-suite-into-tinydtls.patch delete mode 100644 extlibs/tinydtls/0001-Added-support-in-tinyDTLS-to-support-rehandshake.patch delete mode 100644 extlibs/tinydtls/0001-Adding-autoconf-generated-files-in-tinydtls-repo.patch delete mode 100644 extlibs/tinydtls/0001-Bug-Fix-in-earlier-rehandhsake-implementation.patch delete mode 100644 extlibs/tinydtls/0001-Fix-the-wrong-implementation-about-the-anonymous-cip.patch delete mode 100644 extlibs/tinydtls/0001-Fixed-issue-to-pass-PSK-identity-hint-to-application.patch delete mode 100644 extlibs/tinydtls/0001-Updated-tinyDTLS-test-apps-to-use-identity-hint.patch delete mode 100644 extlibs/tinydtls/0001-add-support-of-X.509-into-tinyDTLS-external-library.patch delete mode 100644 extlibs/tinydtls/Android.mk delete mode 100644 extlibs/tinydtls/LICENSE delete mode 100644 extlibs/tinydtls/Makefile.in delete mode 100644 extlibs/tinydtls/Makefile.tinydtls delete mode 100644 extlibs/tinydtls/README delete mode 100644 extlibs/tinydtls/README_Iotivity delete mode 100644 extlibs/tinydtls/SConscript delete mode 100644 extlibs/tinydtls/aes/Makefile.in delete mode 100644 extlibs/tinydtls/aes/rijndael.c delete mode 100644 extlibs/tinydtls/aes/rijndael.h delete mode 100644 extlibs/tinydtls/alert.h delete mode 100644 extlibs/tinydtls/ccm.c delete mode 100644 extlibs/tinydtls/ccm.h delete mode 100644 extlibs/tinydtls/configure.in delete mode 100644 extlibs/tinydtls/crypto.c delete mode 100644 extlibs/tinydtls/crypto.h delete mode 100644 extlibs/tinydtls/debug.c delete mode 100644 extlibs/tinydtls/debug.h delete mode 100644 extlibs/tinydtls/doc/Doxyfile.in delete mode 100644 extlibs/tinydtls/doc/DoxygenLayout.xml delete mode 100644 extlibs/tinydtls/doc/Makefile.in delete mode 100644 extlibs/tinydtls/dtls.c delete mode 100644 extlibs/tinydtls/dtls.h delete mode 100644 extlibs/tinydtls/dtls_config.h delete mode 100644 extlibs/tinydtls/dtls_config.h.in delete mode 100644 extlibs/tinydtls/dtls_hal.h delete mode 100644 extlibs/tinydtls/dtls_time.c delete mode 100644 extlibs/tinydtls/dtls_time.h delete mode 100644 extlibs/tinydtls/ecc/LICENSE.txt delete mode 100755 extlibs/tinydtls/ecc/Makefile.contiki delete mode 100755 extlibs/tinydtls/ecc/Makefile.ecc delete mode 100644 extlibs/tinydtls/ecc/Makefile.in delete mode 100644 extlibs/tinydtls/ecc/README.md delete mode 100755 extlibs/tinydtls/ecc/asm_arm.inc delete mode 100755 extlibs/tinydtls/ecc/asm_avr.inc delete mode 100644 extlibs/tinydtls/ecc/ecc.c delete mode 100644 extlibs/tinydtls/ecc/ecc.h delete mode 100755 extlibs/tinydtls/ecc/test/ecc_test/ecc_test.ino delete mode 100755 extlibs/tinydtls/ecc/test/emk_rules.py delete mode 100644 extlibs/tinydtls/ecc/test/test_ecdh.c delete mode 100644 extlibs/tinydtls/ecc/test/test_ecdsa.c delete mode 100644 extlibs/tinydtls/examples/contiki/Makefile.in delete mode 100644 extlibs/tinydtls/examples/contiki/dtls-client.c delete mode 100644 extlibs/tinydtls/examples/contiki/dtls-server.c delete mode 100644 extlibs/tinydtls/global.h delete mode 100644 extlibs/tinydtls/hmac.c delete mode 100644 extlibs/tinydtls/hmac.h delete mode 100644 extlibs/tinydtls/netq.c delete mode 100644 extlibs/tinydtls/netq.h delete mode 100644 extlibs/tinydtls/numeric.h delete mode 100644 extlibs/tinydtls/peer.c delete mode 100644 extlibs/tinydtls/peer.h delete mode 100644 extlibs/tinydtls/platform-specific/Makefile.in delete mode 100644 extlibs/tinydtls/platform-specific/config-cc2538dk.h delete mode 100644 extlibs/tinydtls/platform-specific/config-econotag.h delete mode 100644 extlibs/tinydtls/platform-specific/config-minimal-net.h delete mode 100644 extlibs/tinydtls/platform-specific/config-sky.h delete mode 100644 extlibs/tinydtls/platform-specific/config-wismote.h delete mode 100644 extlibs/tinydtls/prng.h delete mode 100644 extlibs/tinydtls/session.c delete mode 100644 extlibs/tinydtls/session.h delete mode 100644 extlibs/tinydtls/sha2/Makefile.in delete mode 100644 extlibs/tinydtls/sha2/README delete mode 100644 extlibs/tinydtls/sha2/sha2.c delete mode 100644 extlibs/tinydtls/sha2/sha2.h delete mode 100644 extlibs/tinydtls/sha2/sha2prog.c delete mode 100644 extlibs/tinydtls/sha2/sha2speed.c delete mode 100755 extlibs/tinydtls/sha2/sha2test.pl delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector001.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector001.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector002.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector002.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector003.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector003.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector004.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector004.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector005.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector005.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector006.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector006.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector007.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector007.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector008.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector008.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector009.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector009.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector010.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector010.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector011.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector011.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector012.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector012.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector013.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector013.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector014.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector014.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector015.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector015.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector016.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector016.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector017.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector017.info delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector018.dat delete mode 100644 extlibs/tinydtls/sha2/testvectors/vector018.info delete mode 100644 extlibs/tinydtls/state.h delete mode 100644 extlibs/tinydtls/t_list.h delete mode 100644 extlibs/tinydtls/tests/Makefile.in delete mode 100644 extlibs/tinydtls/tests/cbc_aes128-test.c delete mode 100644 extlibs/tinydtls/tests/cbc_aes128-testdata.c delete mode 100644 extlibs/tinydtls/tests/ccm-test.c delete mode 100644 extlibs/tinydtls/tests/ccm-testdata.c delete mode 100644 extlibs/tinydtls/tests/dsrv-test.c delete mode 100644 extlibs/tinydtls/tests/dtls-client.c delete mode 100644 extlibs/tinydtls/tests/dtls-server.c delete mode 100644 extlibs/tinydtls/tests/netq-test.c delete mode 100644 extlibs/tinydtls/tests/pcap.c delete mode 100644 extlibs/tinydtls/tests/prf-test.c delete mode 100644 extlibs/tinydtls/tests/secure-server.c delete mode 100644 extlibs/tinydtls/tinydtls.h delete mode 100644 extlibs/tinydtls/tinydtls.h.in delete mode 100644 extlibs/tinydtls/uthash.h delete mode 100644 extlibs/tinydtls/utlist.h create mode 100644 packaging/iotivity.pc.in mode change 100644 => 100755 packaging/iotivity.spec create mode 100755 packaging/snapshot_history.txt create mode 100644 resource/c_common/octhread/include/octhread.h rename resource/{csdk/connectivity/common/src/camutex_noop.c => c_common/octhread/src/noop/octhread.c} (56%) rename resource/{csdk/connectivity/common/src/camutex_pthreads.c => c_common/octhread/src/posix/octhread.c} (67%) create mode 100644 resource/c_common/octhread/src/windows/octhread.c create mode 100644 resource/c_common/utlist.h delete mode 100644 resource/csdk/connectivity/common/inc/camutex.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/calestate.c create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/calestate.h mode change 100644 => 100755 resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c create mode 100755 resource/csdk/connectivity/src/bt_le_adapter/ios/SConscript create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/caleclient.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/caleclient.m create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/calenwmonitor.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/calenwmonitor.m create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/caleserver.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/caleserver.m create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/ios/caleutils.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor_vd.c create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_mcd.c create mode 100755 resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c mode change 100644 => 100755 resource/csdk/connectivity/src/cainterfacecontroller.c mode change 100644 => 100755 resource/csdk/connectivity/src/camessagehandler.c mode change 100644 => 100755 resource/csdk/connectivity/src/caprotocolmessage.c create mode 100644 resource/csdk/connectivity/src/ip_adapter/ios/caipnwmonitor.m mode change 100755 => 100644 resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c rename resource/csdk/connectivity/test/{camutex_tests.cpp => octhread_tests.cpp} (82%) create mode 100644 resource/csdk/connectivity/util/inc/caconnectionmanager.h rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/caleautoconnector.c (82%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/caleautoconnector.h (100%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/caleconnectionmanager.c (95%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/camanagerdevice.c (85%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/camanagerdevice.h (99%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/camanagerleutil.c (97%) rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/android/camanagerleutil.h (100%) create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/caleautoconnector.h create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/caleautoconnector.m create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/caleconnectionmanager.m create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/camanagerdevice.h create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/camanagerdevice.m create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/camanagerleutil.h create mode 100755 resource/csdk/connectivity/util/src/camanager/bt_le_manager/ios/camanagerleutil.m rename resource/csdk/connectivity/util/src/camanager/{ => bt_le_manager}/tizen/caleconnectionmanager.c (54%) create mode 100644 resource/csdk/connectivity/util/src/camanager/caconnectionmanager.c create mode 100644 resource/csdk/connectivity/util/src/camanager/camanagerutil.c create mode 100644 resource/csdk/connectivity/util/src/camanager/camanagerutil.h create mode 100644 resource/csdk/connectivity/util/src/camanager/camessagearbiter.c create mode 100644 resource/csdk/connectivity/util/src/camanager/camessagearbiter.h create mode 100644 resource/csdk/connectivity/util/src/camanager/capolicymanager.c create mode 100644 resource/csdk/connectivity/util/src/camanager/capolicymanager.h create mode 100644 resource/csdk/logger/include/tizenrt_logger.h create mode 100755 resource/csdk/logger/include/trace.h create mode 100755 resource/csdk/logger/src/trace.c create mode 100644 resource/csdk/security/include/internal/psiutils.h delete mode 100644 resource/csdk/security/include/internal/svcresource.h create mode 100644 resource/csdk/security/include/oxmverifycommon.h create mode 100644 resource/csdk/security/provisioning/sample/hw_emul/hw_interface.c create mode 100644 resource/csdk/security/provisioning/sample/hw_emul/hw_interface.h create mode 100644 resource/csdk/security/provisioning/sample/hw_emul/ss_emul.c create mode 100644 resource/csdk/security/provisioning/sample/hw_emul/ss_emul.h create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks_default.dat create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks_protectedDB_plain.dat create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_mvjustworks.dat create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_mvjustworks.json create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_preconfpin.dat create mode 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_preconfpin.json create mode 100644 resource/csdk/security/provisioning/sample/sampleserver_justworks_protectedDB.cpp create mode 100644 resource/csdk/security/provisioning/sample/sampleserver_mvjustworks.cpp create mode 100644 resource/csdk/security/provisioning/sample/sampleserver_preconfpin.cpp create mode 100644 resource/csdk/security/src/oxmverifycommon.c create mode 100755 resource/csdk/security/src/psiutils.c delete mode 100644 resource/csdk/security/src/svcresource.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditor.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditoracl.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditoracl.h create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorcommon.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorcommon.h create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorcred.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorcred.h create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditordoxm.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditordoxm.h create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorpstat.c create mode 100644 resource/csdk/security/tool/svrdbeditor_src/svrdbeditorpstat.h create mode 100644 resource/csdk/security/unittest/psinterface.cpp delete mode 100644 resource/csdk/security/unittest/svcresourcetest.cpp rename resource/csdk/stack/include/internal/{oickeepalive.h => oickeepaliveinternal.h} (64%) mode change 100755 => 100644 resource/csdk/stack/include/octypes.h create mode 100644 resource/csdk/stack/include/oickeepalive.h create mode 100644 resource/csdk/stack/samples/tizen/SimpleClientServer/oic_svr_db_client.dat create mode 100644 resource/csdk/stack/samples/tizen/SimpleClientServer/oic_svr_db_client.json create mode 100644 resource/csdk/stack/samples/tizen/SimpleClientServer/oic_svr_db_server.dat create mode 100644 resource/csdk/stack/samples/tizen/SimpleClientServer/oic_svr_db_server.json mode change 100644 => 100755 resource/csdk/stack/samples/tizen/build/gbsbuild.sh mode change 100644 => 100755 resource/csdk/stack/src/occlientcb.c mode change 100644 => 100755 resource/csdk/stack/src/ocpayload.c create mode 100644 resource/provisioning/examples/oic_svr_db_subowner_client.dat create mode 100644 resource/provisioning/examples/oic_svr_db_subowner_client.json create mode 100644 resource/provisioning/examples/subownerclient.cpp mode change 100755 => 100644 resource/provisioning/unittests/OCProvisioningTest.cpp mode change 100755 => 100644 resource/provisioning/unittests/SConscript mode change 100644 => 100755 resource/src/OCPlatform_impl.cpp create mode 100755 service/easy-setup/enrollee/inc/samsung/sc_easysetup.h create mode 100755 service/easy-setup/enrollee/src/samsung/sc_easysetup.c mode change 100644 => 100755 service/easy-setup/mediator/richsdk/SConscript create mode 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/enums/OAUTH_TOKENTYPE.java create mode 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/samsung/SCDeviceProp.java create mode 100755 service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/samsung/SCEnrolleeConf.java create mode 100755 service/easy-setup/mediator/richsdk/inc/ESSCCommon.h mode change 100644 => 100755 service/easy-setup/mediator/richsdk/src/CloudResource.h mode change 100644 => 100755 service/easy-setup/mediator/richsdk/src/EnrolleeResource.h create mode 100755 service/easy-setup/sampleapp/enrollee/linux-samsung/SConscript create mode 100644 service/easy-setup/sampleapp/enrollee/linux-samsung/oic_svr_db_server.dat create mode 100755 service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c create mode 100644 service/easy-setup/sampleapp/enrollee/linux/oic_svr_db_server_MOT.dat mode change 100644 => 100755 service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/.gitignore create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/EasySetup.iml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/EasySetupGradle.iml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/app.iml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/build.gradle create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/proguard-rules.pro create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/AndroidManifest.xml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/assets/oic_svr_db_client.dat create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/assets/oic_svr_db_client.json create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/java/org/iotivity/service/easysetup/LoginActivity.java create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/drawable-hdpi/background.png create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/drawable-hdpi/cancel.png create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/drawable-hdpi/ic_launcher.png create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/drawable-hdpi/icon.png create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/layout/activity_login.xml create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/layout/easysetup_main.xml create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/menu/main.xml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/values/arrays.xml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/values/dimens.xml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/values/strings.xml create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/app/src/main/res/values/styles.xml create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/build.gradle create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/gradle.properties create mode 100755 service/easy-setup/sampleapp/mediator/android-samsung/EasySetup/settings.gradle create mode 100644 service/easy-setup/sampleapp/mediator/android-samsung/SConscript create mode 100755 service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/SConscript create mode 100755 service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp create mode 100755 service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/oic_svr_db_client.dat create mode 100755 service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp create mode 100644 service/easy-setup/sampleapp/mediator/linux/richsdk_sample/oic_svr_db_subclient.dat rename service/easy-setup/sampleapp/mediator/linux/richsdk_sample/{mediator_cpp.cpp => submediator.cpp} (78%) mode change 100644 => 100755 service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java mode change 100644 => 100755 service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java create mode 100755 service/notification/android/notification-service/src/main/jni/common/JniSharedObjectHolder.h mode change 100644 => 100755 service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.h create mode 100755 service/notification/cpp-wrapper/common/NSException.h create mode 100755 service/notification/cpp-wrapper/consumer/inc/NSAcceptedProviders.h create mode 100755 service/notification/cpp-wrapper/consumer/src/NSAcceptedProviders.cpp create mode 100755 service/notification/cpp-wrapper/provider/inc/NSAcceptedConsumers.h create mode 100755 service/notification/cpp-wrapper/provider/src/NSAcceptedConsumers.cpp create mode 100755 service/notification/examples/android/NotiConsumerExample/app/src/androidTest/java/org/iotivity/service/ns/sample/consumer/ExampleUnitTest.java create mode 100755 service/notification/examples/android/NotiConsumerExample/app/src/androidTest/java/org/iotivity/service/ns/sample/consumer/ProviderSimulator.java delete mode 100755 service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java rename service/notification/examples/android/NotiConsumerExample/app/src/main/java/{com/sec/noticonsumerexample => org/iotivity/service/ns/sample/consumer}/ConsumerSample.java (52%) create mode 100644 service/notification/examples/android/NotiConsumerExample/app/src/main/java/org/iotivity/service/ns/sample/consumer/LoginActivity.java create mode 100755 service/notification/examples/android/NotiConsumerExample/app/src/main/java/org/iotivity/service/ns/sample/consumer/MainActivity.java create mode 100755 service/notification/examples/android/NotiConsumerExample/app/src/main/res/layout/activity_login.xml create mode 100644 service/notification/examples/android/NotiConsumerExample/app/src/main/res/layout/dialog_auth.xml create mode 100644 service/notification/examples/android/NotiConsumerExample/app/src/main/res/layout/dialog_entry.xml create mode 100644 service/notification/examples/android/NotiConsumerExample/app/src/main/res/layout/dialog_mq.xml create mode 100644 service/notification/examples/android/NotiProviderExample/app/src/androidTest/java/org/iotivity/service/ns/sample/provider/ConsumerSimulator.java create mode 100755 service/notification/examples/android/NotiProviderExample/app/src/androidTest/java/org/iotivity/service/ns/sample/provider/ExampleUnitTest.java mode change 100644 => 100755 service/notification/examples/android/NotiProviderExample/app/src/main/AndroidManifest.xml delete mode 100755 service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java delete mode 100755 service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/ProviderSample.java create mode 100644 service/notification/examples/android/NotiProviderExample/app/src/main/java/org/iotivity/service/ns/sample/provider/LoginActivity.java create mode 100755 service/notification/examples/android/NotiProviderExample/app/src/main/java/org/iotivity/service/ns/sample/provider/MainActivity.java rename service/notification/examples/android/NotiProviderExample/app/src/main/java/{com/sec/notiproviderexample => org/iotivity/service/ns/sample/provider}/NotiListener.java (70%) create mode 100755 service/notification/examples/android/NotiProviderExample/app/src/main/java/org/iotivity/service/ns/sample/provider/ProviderSample.java create mode 100755 service/notification/examples/android/NotiProviderExample/app/src/main/res/layout/activity_login.xml mode change 100644 => 100755 service/notification/examples/android/NotiProviderExample/app/src/main/res/layout/activity_main.xml create mode 100644 service/notification/examples/android/NotiProviderExample/app/src/main/res/layout/dialog_auth.xml create mode 100644 service/notification/examples/android/NotiProviderExample/app/src/main/res/layout/dialog_entry.xml create mode 100644 service/notification/examples/android/NotiProviderExample/app/src/main/res/layout/dialog_mq.xml mode change 100644 => 100755 service/notification/examples/android/NotiProviderExample/app/src/main/res/values/strings.xml create mode 100644 service/notification/src/consumer/NSConsumerMQPlugin.c create mode 100644 service/notification/src/consumer/NSConsumerMQPlugin.h create mode 100644 service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsByteString.java create mode 100755 tools/tizen/.gbs.vd.tv.tizen30.conf create mode 100644 tools/tizen/iotivity-vd-tv-es-tizen30.spec create mode 100644 tools/tizen/iotivity-vd-tv-tizen30.spec mode change 100755 => 100644 tools/tizen/iotivity.spec diff --git a/.gitignore b/.gitignore index fa14905..a6a0722 100644 --- a/.gitignore +++ b/.gitignore @@ -117,7 +117,7 @@ build_common/arduino/extlibs/arduino/arduino-1.5.8 extlibs/tinydtls/dtls-client extlibs/tinydtls/dtls-server extlibs/bluez/bluez -extlibs/mbedtls/mbedtls +# extlibs/mbedtls/mbedtls extlibs/raxmpp/raxmpp extlibs/yaml/yaml @@ -136,7 +136,7 @@ extlibs/yaml/yaml *.memcheck # Ignore generated files -*.dat +# *.dat # Ignore debian generated files debian/files diff --git a/NOTICE.md b/NOTICE.md index 027511d..89c49b3 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -25,13 +25,11 @@ which is open source software, written and copyright by Olaf Bergmann with a BSD and GPLv2 license. The original software is available from http://sourceforge.net/projects/libcoap/ -The DTLS protocol is provided by the tinyDTLS package, -which is open source software, written and copyright by Olaf Bergmann -with an MIT license. The tinyDTLS library relies on algorithms whose -source is under a BSD license. The additional licenses can be viewed at - http://tinydtls.sourceforge.net/ +The TLS/DTLS protocol is provided by the mbedTLS package, +which is open source software, written and copyright by ARM +with an Apache 2.0 license. The original software is available from - http://sourceforge.net/projects/tinydtls/ + https://github.com/ARMmbed/mbedtls This project relies on utilities in the Boost C++library which is open source software with a Boost Software License v1.0. The details of the @@ -50,3 +48,8 @@ which is open source software, written and copyright by Dave Gamble with an MIT license. The original software is available from http://sourceforge.net/projects/cjson/ +The Linked List macro(utlist.h) is provided by the uthash package, +which is open source software, written and copyright by Troy D. Hanson +with an BSD license. +The original software is available from + https://github.com/troydhanson/uthash diff --git a/Readme.scons.txt b/Readme.scons.txt index 57f531e..9b2b590 100644 --- a/Readme.scons.txt +++ b/Readme.scons.txt @@ -31,7 +31,7 @@ message to install tinycbor) ('' is the path to 'iotivity' project. If your device is x86, arm, or arm64, please change 'x86_64' to the proper arch) -3. To build and test IoTivity with Security enabled (required for certification) +3. To build and test IoTivity with Security enabled (required for certification) follow the instructions found in: /resource/csdk/security/README-building-and-running-secure-IoTivity-stack.txt @@ -284,6 +284,16 @@ See run.bat for more example usage parameters * SIMULATOR=true or false (Build with simulator module) * Possible values for are: PUB,SUB,BROKER (Build including Message Queue) -> PUB : publisher, SUB : subscriber, BROKER : MQ broker(not supported yet) + * LOG_LEVEL=DEBUG or INFO or WARNING or ERROR or FATAL + (select log level to print, LOGGING option should be true) + default is debug level with no private log. + ex) LOG_LEVEL=DEBUG : All logs including DEBUG, INFO, WARNING, ERROR, FATAL level is printed. + and private log is disabled. + LOG_LEVEL=INFO : The logs including INFO, WARNING, ERROR, FATAL level is printed. + and private log is disabled. + LOG_LEVEL=WARNING : The logs including WARNING, ERROR, FATAL level is printed. + LOG_LEVEL=ERROR : The logs including ERROR, FATAL level is printed. + LOG_LEVEL=FATAL : FATAL level is printed. Note: 1) for convenience, a script (auto_build.sh) is provided to run possible build diff --git a/SConstruct b/SConstruct index ac76f39..3a69fe5 100644 --- a/SConstruct +++ b/SConstruct @@ -56,17 +56,22 @@ build_dir = env.get('BUILD_DIR') # Build 'resource' sub-project SConscript(build_dir + 'resource/SConscript') -if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt', 'windows']: +if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt', 'windows', 'tizenrt']: SConscript(build_dir + 'examples/OICMiddle/SConscript') # Build 'service' sub-project -SConscript(build_dir + 'service/SConscript') +if target_os not in ['tizenrt']: + SConscript(build_dir + 'service/SConscript') # Build "cloud" sub-project SConscript(build_dir + 'cloud/SConscript') # Build "plugin interface" sub-project -SConscript(build_dir + 'plugins/SConscript') +if target_os not in ['tizenrt']: + SConscript(build_dir + 'plugins/SConscript') + +if target_os == 'tizenrt': + SConscript('../apps' + '/SConscript') # Append targets information to the help information, to see help info, execute command line: # $ scon [options] -h diff --git a/android/android_api/SConscript b/android/android_api/SConscript index 895ebb6..7e79144 100644 --- a/android/android_api/SConscript +++ b/android/android_api/SConscript @@ -54,14 +54,21 @@ else: os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') -if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'): +if ('ALL' in ANDROID_TRANSPORT) or ('BLE' in ANDROID_TRANSPORT): + ANDROID_API_LEVEL = '22' + ANDROID_VER = '5.1' +else: + ANDROID_API_LEVEL = '21' + ANDROID_VER = '5.0.1' + +if not os.path.exists(android_home + '/platforms/android-' + ANDROID_API_LEVEL) or not os.path.exists(android_home + '/build-tools/20.0.0'): print ''' ***************************************** Info ******************************** -* Either 'Android API 21' is not installed or 'Android SDK Build Tools * +* Either 'Android API %s' is not installed or 'Android SDK Build Tools * * 20.0.0' is not installed. The Android SDK Manager will now open. Please * * be sure to deselect all options, then select the following 2 packages: * * 1. Under "Tools" select "Android SDK Build-tools" Revision 20. * -* 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" * +* 2. Under "Android %s (API %s)" select "SDK Platform" * * 3. Continue by selecting "Install 2 Packages" * * * * NOTE: If you have an http proxy, please press ctrl+c now and edit/create * @@ -80,7 +87,7 @@ if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exi ******************************************************************************* ...Opening Android SDK Manager now. Once you are finished, the build will continue. -''' +''' % (ANDROID_API_LEVEL, ANDROID_VER, ANDROID_API_LEVEL) os.system(android_home + '/tools/android') def ensure_libs(target, source, env): @@ -92,10 +99,10 @@ jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' b jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java") -jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s --stacktrace' %(ANDROID_TRANSPORT_EDR, ANDROID_TRANSPORT_BLE, ANDROID_TRANSPORT_NFC, ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED, ANDROID_CLOUD, ANDROID_RD_MODE, ANDROID_MQ_PUB, ANDROID_MQ_SUB, ANDROID_MQ_BROKER, ANDROID_TCP)) -cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java") +#jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s --stacktrace' %(ANDROID_TRANSPORT_EDR, ANDROID_TRANSPORT_BLE, ANDROID_TRANSPORT_NFC, ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED, ANDROID_CLOUD, ANDROID_RD_MODE, ANDROID_MQ_PUB, ANDROID_MQ_SUB, ANDROID_MQ_BROKER, ANDROID_TCP)) +#cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java") # android examples require android api to be built before being invoked -Depends(cmdBuildExamples, cmdBuildApi) +#Depends(cmdBuildExamples, cmdBuildApi) env.AppendUnique(baseAAR = cmdBuildApi) diff --git a/android/android_api/base/build.gradle b/android/android_api/base/build.gradle index e496be0..2d8cbcb 100755 --- a/android/android_api/base/build.gradle +++ b/android/android_api/base/build.gradle @@ -23,7 +23,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 21 + if (WITH_TRANSPORT_BLE == "0") { + compileSdkVersion 21 + }else{ + compileSdkVersion 22 + } buildToolsVersion "20.0.0" archivesBaseName = "iotivity-base" diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk index 59400f2..4210502 100644 --- a/android/android_api/base/jni/Android.mk +++ b/android/android_api/base/jni/Android.mk @@ -3,6 +3,7 @@ TARGET_ARCH_ABI := $(APP_ABI) SECURED := $(SECURE) WITH_CLOUD := $(WITH_CLOUD) WITH_TCP := $(WITH_TCP) +TCP_ADAPTER := $(WITH_TCP) WITH_MQ_PUB := $(WITH_MQ_PUB) WITH_MQ_SUB := $(WITH_MQ_SUB) WITH_MQ_BROKER := $(WITH_MQ_BROKER) @@ -41,6 +42,12 @@ include $(PREBUILT_SHARED_LIBRARY) ifeq ($(SECURED), 1) include $(CLEAR_VARS) OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) +LOCAL_MODULE := libandroid-mbedtls +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libmbedtls.so +include $(PREBUILT_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) LOCAL_MODULE := libandroid-ocprovision LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocprovision.so include $(PREBUILT_SHARED_LIBRARY) @@ -72,9 +79,15 @@ ifeq ($(WITH_CLOUD), 1) endif ifeq ($(WITH_TCP), 1) - LOCAL_CPPFLAGS += -D__WITH_TLS__ + LOCAL_CPPFLAGS += -D__WITH_TLS__ \ + -DWITH_TCP endif +ifeq ($(TCP_ADAPTER), 1) + LOCAL_CPPFLAGS += -DTCP_ADAPTER +endif + + MQ_FLAG = 0 ifeq ($(WITH_MQ_PUB), 1) LOCAL_CFLAGS += -DWITH_MQ -DMQ_PUBLISHER @@ -129,14 +142,17 @@ ifeq ($(SECURED), 1) JniSecureUtils.cpp \ JniProvisionResultListner.cpp \ JniPinCheckListener.cpp \ - JniDisplayPinListener.cpp + JniDisplayPinListener.cpp \ + JniDisplayVerifyNumListener.cpp \ + JniConfirmNumListener.cpp endif ifeq ($(WITH_CLOUD), 1) LOCAL_SRC_FILES += JniOcAccountManager.cpp endif -ifeq ($(WITH_TCP), 1) +ifeq ($(TCP_ADAPTER), 1) + LOCAL_SRC_FILES += JniKeepAliveListener.cpp ifeq ($(SECURED), 1) LOCAL_SRC_FILES += JniOcCloudProvisioning.cpp \ JniOcCloudResultListener.cpp \ @@ -154,6 +170,7 @@ LOCAL_STATIC_LIBRARIES += android_cpp11_compat ifeq ($(SECURED), 1) LOCAL_STATIC_LIBRARIES += android-ocprovision LOCAL_STATIC_LIBRARIES += android-ocpmapi +LOCAL_STATIC_LIBRARIES += android-mbedtls endif LOCAL_SHARED_LIBRARIES += android-rd @@ -173,6 +190,7 @@ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/cjson LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/tinycbor/tinycbor/src +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/mbedtls/mbedtls/include/ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm/ diff --git a/android/android_api/base/jni/JniCaInterface.c b/android/android_api/base/jni/JniCaInterface.c index 8fdedd9..2a7861b 100644 --- a/android/android_api/base/jni/JniCaInterface.c +++ b/android/android_api/base/jni/JniCaInterface.c @@ -356,6 +356,43 @@ Java_org_iotivity_ca_CaInterface_setLeScanIntervalTimeImpl(JNIEnv *env, jclass c CAUtilSetLEScanInterval(intervalTime, workignCount); } +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_stopLeScanImpl(JNIEnv *env, jclass clazz) +{ + LOGI("stopLeScan"); + (void)env; + (void)clazz; + CAUtilStopLEScan(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_startLeAdvertisingImpl(JNIEnv *env, jclass clazz) +{ + LOGI("startLeAdvertising"); + (void)env; + (void)clazz; + CAUtilStartLEAdvertising(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_stopLeAdvertisingImpl(JNIEnv *env, jclass clazz) +{ + LOGI("stopLeAdvertising"); + (void)env; + (void)clazz; + CAUtilStopLEAdvertising(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_setBTConfigureImpl(JNIEnv *env, jclass clazz, jint flag) +{ + LOGI("setConfigureImpl"); + (void)env; + (void)clazz; + CAUtilConfig_t configs = {(CATransportBTFlags_t)flag}; + CAUtilSetBTConfigure(configs); +} + JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl (JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter) { @@ -370,3 +407,33 @@ JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl return ret; } +JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_disconnectTCPSessionImpl + (JNIEnv *env, jclass clazz, jstring address, jint port, jint transportFlags) +{ + LOGI("disconnectTCPSessionImpl"); + (void)env; + (void)clazz; + + if(!address) + { + LOGE("Java address is null"); + return CA_STATUS_INVALID_PARAM; + } + + //convert java string to native string + const char* nativeAddress = (*env)->GetStringUTFChars(env, address, NULL); + if (!nativeAddress) + { + LOGE("Native address is null"); + return CA_STATUS_INVALID_PARAM; + } + + CAResult_t result = CAUtilTCPDisconnectSession(nativeAddress, (int)port, + (CATransportFlags_t)transportFlags); + if (CA_STATUS_OK != result) + { + LOGE("disconnectTCPSessionImpl failed"); + } + return result; +} + diff --git a/android/android_api/base/jni/JniCaInterface.h b/android/android_api/base/jni/JniCaInterface.h index 663aef3..d13b47e 100644 --- a/android/android_api/base/jni/JniCaInterface.h +++ b/android/android_api/base/jni/JniCaInterface.h @@ -136,6 +136,14 @@ extern "C" { JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl (JNIEnv *, jclass, jint, jint); + /* + * Class: org_iotivity_ca_CaInterface + * Method: disconnectTCPSessionImpl + * Signature: (Ljava/lang/String;II)I + */ + JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_disconnectTCPSessionImpl + (JNIEnv *, jclass, jstring, jint, jint); + #ifdef __cplusplus } #endif diff --git a/android/android_api/base/jni/JniConfirmNumListener.cpp b/android/android_api/base/jni/JniConfirmNumListener.cpp new file mode 100644 index 0000000..402f3e1 --- /dev/null +++ b/android/android_api/base/jni/JniConfirmNumListener.cpp @@ -0,0 +1,76 @@ +/* +* //****************************************************************** +* // +* // 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 "JniConfirmNumListener.h" + +JniConfirmNumListener::JniConfirmNumListener(JNIEnv *env, jobject jListener) +{ + m_jgListener = env->NewGlobalRef(jListener); +} + +JniConfirmNumListener::~JniConfirmNumListener() +{ + LOGI("~JniConfirmNumListener()"); + if (m_jgListener) + { + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteGlobalRef(m_jgListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +OCStackResult JniConfirmNumListener::confirmMutualVerifNumCallback() +{ + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) + { + return OC_STACK_ERROR; + } + + jclass clsL = env->GetObjectClass(m_jgListener); + + if (!clsL) + { + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return OC_STACK_ERROR; + } + + jmethodID midL = env->GetMethodID(clsL, "confirmNumListener", "()I"); + if (!midL) + { + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return OC_STACK_ERROR; + } + + OCStackResult result = (OCStackResult) env->CallIntMethod(m_jgListener, midL); + + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + env->ExceptionClear(); + } + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return result; +} diff --git a/android/android_api/base/jni/JniConfirmNumListener.h b/android/android_api/base/jni/JniConfirmNumListener.h new file mode 100644 index 0000000..13b30ec --- /dev/null +++ b/android/android_api/base/jni/JniConfirmNumListener.h @@ -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. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ +#include +#include "JniOcStack.h" +#include "OCProvisioningManager.hpp" + +#ifndef _Included_org_iotivity_base_JniConfirmNumListener +#define _Included_org_iotivity_base_JniConfirmNumListener + +class JniConfirmNumListener +{ + public: + JniConfirmNumListener(JNIEnv *env, jobject jListener); + ~JniConfirmNumListener(); + + OCStackResult confirmMutualVerifNumCallback(); + + private: + jobject m_jgListener; +}; +#endif diff --git a/android/android_api/base/jni/JniDisplayVerifyNumListener.cpp b/android/android_api/base/jni/JniDisplayVerifyNumListener.cpp new file mode 100644 index 0000000..20112d9 --- /dev/null +++ b/android/android_api/base/jni/JniDisplayVerifyNumListener.cpp @@ -0,0 +1,99 @@ +/* +* //****************************************************************** +* // +* // 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 "JniDisplayVerifyNumListener.h" +#include "oic_malloc.h" + +JniDisplayVerifyNumListener::JniDisplayVerifyNumListener(JNIEnv *env, jobject jListener) +{ + m_jgListener = env->NewGlobalRef(jListener); +} + +JniDisplayVerifyNumListener::~JniDisplayVerifyNumListener() +{ + LOGI("~JniDisplayVerifyNumListener()"); + if (m_jgListener) + { + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteGlobalRef(m_jgListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +OCStackResult JniDisplayVerifyNumListener::displayMutualVerifNumCallback(uint8_t verifNum[3]) +{ + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + char *byteArray; + + if (NULL == env) + { + return OC_STACK_ERROR; + } + + jclass clsL = env->GetObjectClass(m_jgListener); + + if (!clsL) + { + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return OC_STACK_ERROR; + } + + jmethodID midL = env->GetMethodID(clsL, "displayNumListener", "(Ljava/lang/String;)I"); + if (!midL) + { + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return OC_STACK_ERROR; + } + + byteArray = (char*)OICCalloc(20, sizeof(char)); + + if (NULL == byteArray) + { + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return OC_STACK_NO_MEMORY; + } + + sprintf(byteArray, "%02X%02X%02X", verifNum[0], verifNum[1], verifNum[2]); + + jstring jStr = env->NewStringUTF(byteArray); + if (!jStr) + { + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return OC_STACK_ERROR; + } + OCStackResult result = (OCStackResult)env->CallIntMethod(m_jgListener, midL, jStr); + + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + env->ExceptionClear(); + } + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + free(byteArray); + return result; +} diff --git a/android/android_api/base/jni/JniDisplayVerifyNumListener.h b/android/android_api/base/jni/JniDisplayVerifyNumListener.h new file mode 100644 index 0000000..ed06859 --- /dev/null +++ b/android/android_api/base/jni/JniDisplayVerifyNumListener.h @@ -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. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ +#include +#include "JniOcStack.h" +#include "OCProvisioningManager.hpp" + +#ifndef _Included_org_iotivity_base_JniDisplayVerifyNumListener +#define _Included_org_iotivity_base_JniDisplayVerifyNumListener + +class JniDisplayVerifyNumListener +{ + public: + JniDisplayVerifyNumListener(JNIEnv *env, jobject jListener); + ~JniDisplayVerifyNumListener(); + + OCStackResult displayMutualVerifNumCallback(uint8_t verfNum[3]); + + private: + jobject m_jgListener; +}; +#endif diff --git a/android/android_api/base/jni/JniKeepAliveListener.cpp b/android/android_api/base/jni/JniKeepAliveListener.cpp new file mode 100644 index 0000000..b875a3e --- /dev/null +++ b/android/android_api/base/jni/JniKeepAliveListener.cpp @@ -0,0 +1,146 @@ +/* +* //****************************************************************** +* // +* // Copyright 2017 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 "JniKeepAliveListener.h" +#include "OCApi.h" +#include "JniOcRepresentation.h" +using namespace OC; + +JniKeepAliveListener::JniKeepAliveListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeListenerCallback = removeListenerCallback; +} + +JniKeepAliveListener::~JniKeepAliveListener() +{ + LOGI("~JniKeepAliveListener()"); + if (m_jwListener) + { + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (nullptr == env) + { + return; + } + env->DeleteWeakGlobalRef(m_jwListener); + m_jwListener = nullptr; + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + } +} + +void JniKeepAliveListener::onKeepAliveListener(const int result, const OC::OCRepresentation& rep) +{ + jint ret = JNI_ERR; + 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; + } + + //create java OCRep + OCRepresentation* nRep = new OCRepresentation(rep); + jlong handle = reinterpret_cast(nRep); + jobject jRep = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + + if (!jRep) + { + delete nRep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + + jint jRet = static_cast(result); + + jmethodID midL = env->GetMethodID(clsL, "onKeepAliveListener", + "(Lorg/iotivity/base/OcRepresentation;I)V"); + + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + env->CallVoidMethod(jListener, midL, jRep, jRet); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete nRep; + } + + checkExAndRemoveListener(env); + + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } +} + +void JniKeepAliveListener::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); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniKeepAliveListener.h b/android/android_api/base/jni/JniKeepAliveListener.h new file mode 100644 index 0000000..e1ab0f4 --- /dev/null +++ b/android/android_api/base/jni/JniKeepAliveListener.h @@ -0,0 +1,42 @@ +/* +* //****************************************************************** +* // +* // Copyright 2017 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 +#include "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcPlatform_PingListener +#define _Included_org_iotivity_base_OcPlatform_PingListener + +class JniKeepAliveListener +{ +public: + JniKeepAliveListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback); + ~JniKeepAliveListener(); + + void onKeepAliveListener(const int result, const OC::OCRepresentation& rep); + +private: + RemoveListenerCallback m_removeListenerCallback; + jweak m_jwListener; + void checkExAndRemoveListener(JNIEnv* env); +}; +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcPlatform.cpp b/android/android_api/base/jni/JniOcPlatform.cpp index 8f76dc8..87d08a2 100644 --- a/android/android_api/base/jni/JniOcPlatform.cpp +++ b/android/android_api/base/jni/JniOcPlatform.cpp @@ -24,6 +24,7 @@ #include "JniOcResourceHandle.h" #include "JniOcPresenceHandle.h" #include "JniOcResourceResponse.h" +#include "JniOcRepresentation.h" #include "JniOcSecurity.h" #include "JniOcDirectPairDevice.h" #include "JniUtils.h" @@ -34,6 +35,8 @@ #include "JniOcAccountManager.h" #endif +#define AES_KEY_SIZE 32 + using namespace OC; JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener) @@ -537,19 +540,92 @@ void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener) directPairingListenerMapLock.unlock(); } +#ifdef TCP_ADAPTER +JniKeepAliveListener* AddKeepAliveListener(JNIEnv* env, jobject jListener) +{ + JniKeepAliveListener *KeepAliveListener = nullptr; + + KeepAliveListenerMapLock.lock(); + + for (auto it = KeepAliveListenerMap.begin(); it != + KeepAliveListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + KeepAliveListener = refPair.first; + refPair.second++; + it->second = refPair; + KeepAliveListenerMap.insert(*it); + LOGD("KeepAliveListener: ref. count incremented"); + break; + } + } + if (!KeepAliveListener) + { + KeepAliveListener = new JniKeepAliveListener(env, jListener, RemoveKeepAliveListener); + jobject jgListener = env->NewGlobalRef(jListener); + KeepAliveListenerMap.insert(std::pair>( + jgListener, + std::pair(KeepAliveListener, 1))); + LOGI("KeepAliveListener: new listener"); + } + KeepAliveListenerMapLock.unlock(); + return KeepAliveListener; +} +#endif +#ifdef TCP_ADAPTER +void RemoveKeepAliveListener(JNIEnv* env, jobject jListener) +{ + KeepAliveListenerMapLock.lock(); + bool isFound = false; + for (auto it = KeepAliveListenerMap.begin(); it != + KeepAliveListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + KeepAliveListenerMap.insert(*it); + LOGI("KeepAliveListener: ref.count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniKeepAliveListener* listener = refPair.first; + delete listener; + KeepAliveListenerMap.erase(it); + LOGI("KeepAliveListener is removed"); + } + isFound = true; + break; + } + } + if (!isFound) + { + ThrowOcException(JNI_EXCEPTION, "KeepAliveListener not found"); + } + KeepAliveListenerMapLock.unlock(); +} +#endif /* * Class: org_iotivity_base_OcPlatform * Method: configure -* Signature: (IILjava/lang/String;II)V +* Signature: (IILjava/lang/String;IILjava/lang/String;I)V */ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure (JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort, - jint jQOS, jstring jDbPath) + jint jQOS, jstring jDbPath, jstring jDbPathDefault , jstring jRescueDBPath, jint jkeySize, +jbyteArray data, jint jTransport) { LOGI("OcPlatform_configure"); std::string ipAddress; - std::string dbfile; + std::string dbfile, defaultPath, rescuePath; + static unsigned char *aesKey = NULL; if (jIpAddress) { ipAddress = env->GetStringUTFChars(jIpAddress, nullptr); @@ -559,6 +635,39 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure dbfile = env->GetStringUTFChars(jDbPath, nullptr); JniOcSecurity::StoreDbPath(dbfile); } + //Either we have both paths or neither of them. + if ((jDbPathDefault && !jRescueDBPath) || (!jDbPathDefault && jRescueDBPath)) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "path cannot be null"); + return; + } + + if (!jDbPathDefault && !jRescueDBPath) + { + LOGI("Secure SVR DB feature not enable!!"); + } + else + { + aesKey = (unsigned char*)calloc(1, sizeof(unsigned char) * AES_KEY_SIZE); + defaultPath = env->GetStringUTFChars(jDbPathDefault, nullptr); + rescuePath = env->GetStringUTFChars(jRescueDBPath, nullptr); + OC::JniOcSecurity::StoreDefault_DbPath(defaultPath, rescuePath, (int)jkeySize); + + jbyte* key = env->GetByteArrayElements(data, 0); + jsize arrayLength = env->GetArrayLength(data); + if(arrayLength != AES_KEY_SIZE) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key size mismatch"); + } + else + { + for(int i=0;i < AES_KEY_SIZE; i++) + { + aesKey[i]=(jbyte)key[i]; + } + } + + } uint16_t port = 0; if (jPort > 0) { @@ -570,10 +679,66 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure JniUtils::getModeType(env, jModeType), ipAddress, port, + JniUtils::getOCTransportAdapter(jTransport), JniUtils::getQOS(env, static_cast(jQOS)), - JniOcSecurity::getOCPersistentStorage() + aesKey, + JniOcSecurity::getOCPersistentStorage(), + JniOcSecurity::getOCPersistentStorageEnc(), + JniOcSecurity::getOCPersistentStorageRescue() }; + OCPlatform::Configure(cfg); + +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: stop +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stop +(JNIEnv *env, jclass clazz) +{ + LOGI("OcPlatform.stop"); + + try { + OCStackResult result = OCPlatform::stop(); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to stop ocplatform"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: start +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_start +(JNIEnv *env, jclass clazz) +{ + LOGI("OcPlatform.start"); + + try { + OCStackResult result = OCPlatform::start(); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to start ocplatform"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } } /* @@ -1473,7 +1638,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( jstring jStr = (jstring)env->GetObjectArrayElement(jDeviceTypes, i); if (!jStr) { - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; ThrowOcException(OC_STACK_INVALID_PARAM, "device type cannot be null"); return; } @@ -1481,7 +1646,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( OCResourcePayloadAddStringLL(&deviceInfo.types, env->GetStringUTFChars(jStr, nullptr)); if (env->ExceptionCheck()) { - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; return; } @@ -1498,7 +1663,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( { OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo); - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; if (OC_STACK_OK != result) { @@ -1619,17 +1784,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0( { OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo); - delete platformInfo.platformID; - delete platformInfo.manufacturerName; - delete platformInfo.manufacturerUrl; - delete platformInfo.modelNumber; - delete platformInfo.dateOfManufacture; - delete platformInfo.platformVersion; - delete platformInfo.operatingSystemVersion; - delete platformInfo.hardwareVersion; - delete platformInfo.firmwareVersion; - delete platformInfo.supportUrl; - delete platformInfo.systemTime; + delete[] platformInfo.platformID; + delete[] platformInfo.manufacturerName; + delete[] platformInfo.manufacturerUrl; + delete[] platformInfo.modelNumber; + delete[] platformInfo.dateOfManufacture; + delete[] platformInfo.platformVersion; + delete[] platformInfo.operatingSystemVersion; + delete[] platformInfo.hardwareVersion; + delete[] platformInfo.firmwareVersion; + delete[] platformInfo.supportUrl; + delete[] platformInfo.systemTime; if (OC_STACK_OK != result) { @@ -2706,3 +2871,118 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId( ThrowOcException(e.code(), e.reason().c_str()); } } + +/* + * Class: org_iotivity_base_OcPlatform + * Method: findKeepAliveResourceImpl + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcPlatform/KeepAliveListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findKeepAliveResourceImpl( + JNIEnv *env, jclass clazz, jstring jHost, jobject jListener) +{ +#ifndef TCP_ADAPTER + ThrowOcException(OC_STACK_ERROR, + "findKeepAliveResource is not supported. (Please build with WITH_TCP=1 option)"); + return; +#else + LOGI("OcPlatform_findKeepAliveResource"); + std::string host; + if (!jHost) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "host cannot be null"); + return; + } + else + { + host = env->GetStringUTFChars(jHost, nullptr); + } + + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onKeepAliveFoundListener cannot be null"); + return; + } + + JniKeepAliveListener *onKeepAliveFoundListener = AddKeepAliveListener(env, jListener); + + KeepAliveCallback KeepAliveCallback = [onKeepAliveFoundListener](const int ret, + const OCRepresentation& rep) + { + onKeepAliveFoundListener->onKeepAliveListener(ret, rep); + }; + + try + { + OCStackResult result = OCPlatform::findKeepAliveResource(host, KeepAliveCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "findKeepAliveResource has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + return; + } +#endif +} + +/* + * Class: org_iotivity_base_OcPlatform + * Method: sendKeepAliveRequestImpl + * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/KeepAliveListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendKeepAliveRequestImpl( + JNIEnv *env, jclass clazz, jstring jHost, jobject jRep, jobject jListener) +{ +#ifndef TCP_ADAPTER + ThrowOcException(OC_STACK_ERROR, + "sendKeepAlive is not supported. (Please build with WITH_TCP=1 option)"); + return; +#else + LOGI("OcPlatform_sendKeepAliveRequest"); + std::string host; + if (!jHost) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "host cannot be null"); + return; + } + else + { + host = env->GetStringUTFChars(jHost, nullptr); + } + + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "keepAliveResponseListener cannot be null"); + return; + }; + + JniKeepAliveListener *KeepAliveResponseListener = AddKeepAliveListener(env, jListener); + + KeepAliveCallback KeepAliveCallback = [KeepAliveResponseListener](const int ret, + const OCRepresentation& rep) + { + KeepAliveResponseListener->onKeepAliveListener(ret, rep); + }; + + try + { + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep); + OCStackResult result = OCPlatform::sendKeepAliveRequest(host, *rep, KeepAliveCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "sendKeepAliveRequest has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + return; + } +#endif +} diff --git a/android/android_api/base/jni/JniOcPlatform.h b/android/android_api/base/jni/JniOcPlatform.h index cff6800..cd8a6ae 100644 --- a/android/android_api/base/jni/JniOcPlatform.h +++ b/android/android_api/base/jni/JniOcPlatform.h @@ -27,7 +27,9 @@ #include "JniOnDirectPairingListener.h" #include "JniOnPresenceListener.h" #include "JniOnObserveListener.h" - +#ifdef TCP_ADAPTER +#include "JniKeepAliveListener.h" +#endif #include #ifndef _Included_org_iotivity_base_OcPlatform @@ -56,6 +58,10 @@ void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener); JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener); void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener); +#ifdef TCP_ADAPTER +JniKeepAliveListener* AddKeepAliveListener(JNIEnv* env, jobject jListener); +void RemoveKeepAliveListener(JNIEnv* env, jobject jListener); +#endif std::map> onResourceFoundListenerMap; std::map> onDeviceInfoListenerMap; std::map> onPlatformInfoListenerMap; @@ -63,7 +69,9 @@ std::map> onPresenceListenerMap; std::map> onObserveListenerMap; std::map> onDPDevicesFoundListenerMap; std::map> directPairingListenerMap; - +#ifdef TCP_ADAPTER +std::map> KeepAliveListenerMap; +#endif std::mutex resourceFoundMapLock; std::mutex deviceInfoMapLock; std::mutex platformInfoMapLock; @@ -71,6 +79,9 @@ std::mutex presenceMapLock; std::mutex observeMapLock; std::mutex dpDevicesFoundListenerMapLock; std::mutex directPairingListenerMapLock; +#ifdef TCP_ADAPTER +std::mutex KeepAliveListenerMapLock; +#endif #ifdef __cplusplus extern "C" { @@ -78,10 +89,27 @@ extern "C" { /* * Class: org_iotivity_base_OcPlatform * Method: configure - * Signature: (IILjava/lang/String;II)V + * Signature: (IILjava/lang/String;IILjava/lang/String;I)V */ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure - (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring); + (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring, jstring, + jstring, jint, jbyteArray, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: stop + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stop + (JNIEnv *, jclass); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: start + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_start + (JNIEnv *, jclass); /* * Class: org_iotivity_base_OcPlatform @@ -389,6 +417,21 @@ extern "C" { JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId( JNIEnv *, jobject, jbyteArray); + /* + * Class: org_iotivity_base_OcPlatform + * Method: findKeepAliveResourceImpl + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcPlatform/KeepAliveListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findKeepAliveResourceImpl( + JNIEnv *, jclass, jstring, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: sendKeepAliveRequestImpl + * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/KeepAliveListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendKeepAliveRequestImpl( + JNIEnv *, jclass, jstring, jobject, jobject); #ifdef __cplusplus } #endif diff --git a/android/android_api/base/jni/JniOcProvisioning.cpp b/android/android_api/base/jni/JniOcProvisioning.cpp index 5fe0b90..e66a873 100644 --- a/android/android_api/base/jni/JniOcProvisioning.cpp +++ b/android/android_api/base/jni/JniOcProvisioning.cpp @@ -23,12 +23,19 @@ #include "JniOcProvisioning.h" #include "JniPinCheckListener.h" #include "JniDisplayPinListener.h" +#include "oic_malloc.h" +#include "aclresource.h" +#include "oxmverifycommon.h" +#include "JniDisplayVerifyNumListener.h" +#include "JniConfirmNumListener.h" using namespace OC; namespace PH = std::placeholders; static JniPinCheckListener *jniPinListener = nullptr; static JniDisplayPinListener *jniDisplayPinListener = nullptr; +static JniDisplayVerifyNumListener *jniDisplayMutualVerifyNumListener = nullptr; +static JniConfirmNumListener *jniConfirmMutualVerifyNumListener = nullptr; void Callback(char *buf, size_t size) { @@ -54,6 +61,38 @@ void displayPinCB(char *pinBuf, size_t pinSize) } } +OCStackResult displayMutualVerifNumCB(uint8_t *verifyNum) +{ + OCStackResult res; + + if (jniDisplayMutualVerifyNumListener) + { + res = jniDisplayMutualVerifyNumListener->displayMutualVerifNumCallback(verifyNum); + } + else + { + res = OC_STACK_ERROR; + LOGE("DisplayMutualVerifyNumListener is null"); + } + return res; +} + +OCStackResult confirmMutualVerifNumCB() +{ + OCStackResult res; + + if (jniConfirmMutualVerifyNumListener) + { + res = jniConfirmMutualVerifyNumListener->confirmMutualVerifNumCallback(); + } + else + { + res = OC_STACK_ERROR; + LOGE("ConfirmMutualVerifyNumListener is null"); + } + return res; +} + /* * Class: org_iotivity_base_OcProvisioning * Method: ownershipTransferCDdata @@ -70,13 +109,8 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_ownershipTransferCB OTMCallbackData_t CBData = {0}; if (OIC_JUST_WORKS == (OicSecOxm_t)OxmType) { - CBData.loadSecretCB = LoadSecretJustWorksCallback; - CBData.createSecureSessionCB = CreateSecureSessionJustWorksCallback; - CBData.createSelectOxmPayloadCB = CreateJustWorksSelectOxmPayload; - CBData.createOwnerTransferPayloadCB = CreateJustWorksOwnerTransferPayload; - - result = OCSecure::setOwnerTransferCallbackData((OicSecOxm_t)OxmType, - &CBData, NULL); + /*NO callback required for JUST_WORKS*/ + result = OCSecure::setInputPinCallback(NULL); } if (OIC_RANDOM_DEVICE_PIN == (OicSecOxm_t)OxmType) { @@ -84,12 +118,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_ownershipTransferCB { delete jniPinListener; jniPinListener = new JniPinCheckListener(env, jListener); - CBData.loadSecretCB = InputPinCodeCallback; - CBData.createSecureSessionCB = CreateSecureSessionRandomPinCallback; - CBData.createSelectOxmPayloadCB = CreatePinBasedSelectOxmPayload; - CBData.createOwnerTransferPayloadCB = CreatePinBasedOwnerTransferPayload; - result = OCSecure::setOwnerTransferCallbackData((OicSecOxm_t)OxmType, - &CBData, Callback); + result = OCSecure::setInputPinCallback(Callback); } else { @@ -256,6 +285,163 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceSt /* * Class: org_iotivity_base_OcProvisioning + * Method: setDisplayNumListener + * Signature: (Lorg/iotivity/base/OcProvisioning/DisplayNumListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayNumListener + (JNIEnv *env, jclass clazz, jobject jListener) +{ + LOGI("OcProvisioning_setDisplayNumListener"); + + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listner can't be null"); + return; + } + delete jniDisplayMutualVerifyNumListener; + jniDisplayMutualVerifyNumListener = new JniDisplayVerifyNumListener(env, jListener); + + try + { + OCStackResult result = OCSecure::registerDisplayNumCallback(displayMutualVerifNumCB); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to set Listner"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return; + } +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: unsetDisplayNumListener + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetDisplayNumListener + (JNIEnv * env, jclass clazz) +{ + LOGI("OcProvisioning_unsetDisplayNumListener"); + + OCStackResult result = OCSecure::deregisterDisplayNumCallback(); + + if (OC_STACK_OK != result) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Failed to unset Listener"); + } + + return result; +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setPinType0 + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setPinType0 + (JNIEnv *env, jclass thiz, jint pinSize, jint pinType) +{ + LOGI("OcProvisioning_setPinType0"); + + OCStackResult result = OC_STACK_ERROR; + try + { + result = OCSecure::setRandomPinPolicy((size_t)pinSize, (OicSecPinType_t)pinType); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to set PinType"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } + return result; +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setConfirmNumListener + * Signature: (Lorg/iotivity/base/OcProvisioning/ConfirmNumListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setConfirmNumListener + (JNIEnv *env, jclass clazz, jobject jListener) +{ + LOGI("OcProvisioning_setConfirmNumListener"); + + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listner can't be null"); + return; + } + delete jniConfirmMutualVerifyNumListener; + jniConfirmMutualVerifyNumListener = new JniConfirmNumListener(env, jListener); + + try + { + OCStackResult result = OCSecure::registerUserConfirmCallback(confirmMutualVerifNumCB); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to set Listner"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return; + } +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: unsetConfirmNumListener + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetConfirmNumListener + (JNIEnv *env, jclass clazz) +{ + LOGI("OcProvisioning_unsetConfirmNumListener"); + + OCStackResult result = OCSecure::deregisterUserConfirmCallback(); + + if (OC_STACK_OK != result) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK, "Failed to unser Listener"); + } + + return result; +} +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setMVJustWorksOptions0 + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setMVJustWorksOptions0 + (JNIEnv *env, jclass clazz, jint options) +{ + LOGI("OcProvisioning_setMVJustWorksOptions0"); + + OCStackResult result = OCSecure::setVerifyOptionMask((VerifyOptionBitmask_t)options); + + if (OC_STACK_OK != result) + { + ThrowOcException(OC_STACK_INVALID_CALLBACK, "setMVJustWorksOptions Failed"); + } + + return result; +} + + +/* + * Class: org_iotivity_base_OcProvisioning * Method: setDisplayPinListener * Signature: (Lorg/iotivity/base/OcProvisioning/DisplayPinListener;)V */ @@ -300,7 +486,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayPinListen #if defined(__WITH_DTLS__) || defined(__WITH_TLS__) jbyte* trustCertChainBytes = env->GetByteArrayElements(trustCertChain, 0); jsize arrayLength = env->GetArrayLength(trustCertChain); - uint16_t credId; + uint16_t credId = -1; unsigned char* trustedCertChar = new unsigned char[arrayLength]; try { @@ -324,3 +510,110 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayPinListen return -1; #endif // __WITH_DTLS__ || __WITH_TLS__ } + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setDeviceIdSeed1 + * Signature: (Lorg/iotivity/base/OcProvisioning/provisionTrustCertChain1;)V + */ + JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setDeviceIdSeed1 +(JNIEnv *env, jobject thiz, jbyteArray seed) +{ + LOGD("OcProvisioning_setDeviceIdSeed1"); +#if defined(__WITH_DTLS__) || defined(__WITH_TLS__) + jbyte* byteSeed = env->GetByteArrayElements(seed, 0); + jsize arrayLength = env->GetArrayLength(seed); + try + { + env->GetByteArrayRegion (seed, 0, arrayLength, byteSeed); + OCStackResult result = OCSecure::setDeviceIdSeed((uint8_t*)byteSeed, arrayLength); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcProvisioning_setDeviceIdSeed"); + return -1; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return 0; +#else + ThrowOcException(OC_STACK_INVALID_PARAM, "WITH_TLS not enabled"); + return -1; +#endif // __WITH_DTLS__ || __WITH_TLS__ +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: saveACL + * Signature: (Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_saveACL + (JNIEnv *env , jclass thiz, jobject jacl) +{ + LOGD("OcProvisioning_saveACL"); + + if (!jacl) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "acl can't be null"); + } + + OicSecAcl_t *acl = (OicSecAcl_t*)OICCalloc(1, sizeof(OicSecAcl_t)); + if (!acl) + { + ThrowOcException(OC_STACK_NO_MEMORY, "acl allocation failed"); + return; + } + + if (OC_STACK_OK != JniSecureUtils::convertJavaACLToOCAcl(env, jacl, acl)) + { + DeleteACLList(acl); + ThrowOcException(OC_STACK_INVALID_PARAM, "Failed to convert Java acl to OC acl"); + return ; + } + + try + { + OCStackResult result = OCSecure::saveACL(acl); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OCSecure::saveACL Failed"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: doSelfOwnershiptransfer + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_doSelfOwnershiptransfer +(JNIEnv *env, jclass thiz) +{ + + LOGD("OcProvisioning_doSelfOwnershiptransfer"); + + try + { + OCStackResult result = OCSecure::configSelfOwnership(); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OCSecure::configSelfOwnership Failed"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + return; + } +} diff --git a/android/android_api/base/jni/JniOcProvisioning.h b/android/android_api/base/jni/JniOcProvisioning.h index 3b8fa0b..72645bd 100644 --- a/android/android_api/base/jni/JniOcProvisioning.h +++ b/android/android_api/base/jni/JniOcProvisioning.h @@ -80,11 +80,52 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayPinListen /* * Class: org_iotivity_base_OcProvisioning + * Method: setDisplayNumListener + * Signature: (Lorg/iotivity/base/OcProvisioning/DisplayNumListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayNumListener + (JNIEnv *, jclass, jobject); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: unsetDisplayNumListener + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetDisplayNumListener + (JNIEnv *, jclass); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setConfirmNumListener + * Signature: (Lorg/iotivity/base/OcProvisioning/ConfirmNumListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setConfirmNumListener + (JNIEnv *, jclass, jobject); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: unsetConfirmNumListener + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetConfirmNumListener + (JNIEnv *, jclass); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setMVJustWorksOptions0 + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setMVJustWorksOptions0 + (JNIEnv *, jclass, jint); + +/* + * Class: org_iotivity_base_OcProvisioning * Method: getDevicestatusLists * Signature: (I)[Lorg/iotivity/base/OcSecureResource; */ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceStatusList1 (JNIEnv *, jclass, jint); + /* * Class: org_iotivity_base_OcProvisioning * Method: saveTrustCertChain1 @@ -92,6 +133,38 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceSt */ JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_saveTrustCertChain1 (JNIEnv *, jobject, jbyteArray, jint); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setPinType0 + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setPinType0 + (JNIEnv *, jclass, jint, jint); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: setDeviceIdSeed1 + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setDeviceIdSeed1 + (JNIEnv *, jobject, jbyteArray); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: saveACL + * Signature: (Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_saveACL + (JNIEnv *, jclass, jobject); + +/* + * Class: org_iotivity_base_OcProvisioning + * Method: doSelfOwnershiptransfer + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_doSelfOwnershiptransfer + (JNIEnv *, jclass); #ifdef __cplusplus } #endif diff --git a/android/android_api/base/jni/JniOcResource.cpp b/android/android_api/base/jni/JniOcResource.cpp index 44f1eb3..9d30ba2 100644 --- a/android/android_api/base/jni/JniOcResource.cpp +++ b/android/android_api/base/jni/JniOcResource.cpp @@ -356,6 +356,11 @@ std::string JniOcResource::sid() const return m_sharedResource->sid(); } +std::string JniOcResource::deviceName() const +{ + return m_sharedResource->deviceName(); +} + JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener) { return this->m_onGetManager.addListener(env, jListener, this); @@ -1705,6 +1710,24 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId /* * Class: org_iotivity_base_OcResource +* Method: getDeviceName +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getDeviceName +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getDeviceName"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) + { + return nullptr; + } + + return env->NewStringUTF(resource->deviceName().c_str()); +} + +/* +* Class: org_iotivity_base_OcResource * Method: dispose * Signature: ()V */ diff --git a/android/android_api/base/jni/JniOcResource.h b/android/android_api/base/jni/JniOcResource.h index 7dfacd3..e05da82 100644 --- a/android/android_api/base/jni/JniOcResource.h +++ b/android/android_api/base/jni/JniOcResource.h @@ -92,6 +92,7 @@ public: std::vector< std::string > getResourceInterfaces(void) const; OCResourceIdentifier uniqueIdentifier() const; std::string sid() const; + std::string deviceName() const; JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener); JniOnPutListener* addOnPutListener(JNIEnv* env, jobject jListener); @@ -374,6 +375,14 @@ extern "C" { /* * Class: org_iotivity_base_OcResource + * Method: getDeviceName + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getDeviceName + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource * Method: dispose * Signature: ()V */ diff --git a/android/android_api/base/jni/JniOcSecureResource.cpp b/android/android_api/base/jni/JniOcSecureResource.cpp index 2c6274b..3e63572 100644 --- a/android/android_api/base/jni/JniOcSecureResource.cpp +++ b/android/android_api/base/jni/JniOcSecureResource.cpp @@ -315,7 +315,7 @@ OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectAr tmp1 = tmp2; } - delete pconf->prm; + delete[] pconf->prm; delete pconf; resultListener->ProvisionResultCallback(result, hasError, ListenerFunc::PROVISIONDIRECTPAIRING); }; @@ -333,7 +333,7 @@ OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectAr tmp1 = tmp2; } - delete pconf->prm; + delete[] pconf->prm; delete pconf; } return ret; diff --git a/android/android_api/base/jni/JniOcSecurity.cpp b/android/android_api/base/jni/JniOcSecurity.cpp old mode 100644 new mode 100755 index 54821ee..0a194dd --- a/android/android_api/base/jni/JniOcSecurity.cpp +++ b/android/android_api/base/jni/JniOcSecurity.cpp @@ -20,6 +20,7 @@ ******************************************************************/ #include "JniOcSecurity.h" #include "JniOcStack.h" +#include "ocstack.h" /* * TODO: Persistant Storage Handling should be done by App. @@ -29,6 +30,8 @@ using namespace std; namespace PH = std::placeholders; namespace OC { + static string s_enc_dbpath, s_rescue_path; + static int AES_KEY_SZ; string& JniOcSecurity::store_path() { @@ -36,11 +39,51 @@ namespace OC { return s_dbPath; } + string& JniOcSecurity::getEncDbPath() + { + return s_enc_dbpath; + } + string& JniOcSecurity::getRescueDbPath() + { + return s_rescue_path; + } + void JniOcSecurity::StoreDbPath(const string &path) { store_path() = path; } + void JniOcSecurity::StoreDefault_DbPath(const string &path, const string &rescue_path, int key_size) + { + s_enc_dbpath = path; + s_rescue_path = rescue_path; + AES_KEY_SZ = key_size; + } + + OCPersistentStorage* JniOcSecurity::getOCPersistentStorageEnc() + { + if (getEncDbPath().empty()) + { + return nullptr; + } + static OCPersistentStorage s_psEnc { &JniOcSecurity::client_open_enc, fread, + fwrite, fclose, unlink, &JniOcSecurity::client_encrypt, + &JniOcSecurity::client_decrypt}; + return &s_psEnc; + } + + OCPersistentStorage* JniOcSecurity::getOCPersistentStorageRescue() + { + if (getRescueDbPath().empty()) + { + return nullptr; + } + static OCPersistentStorage s_psRescue { &JniOcSecurity::client_open_rescue, fread, + fwrite, fclose, unlink, &JniOcSecurity::client_encrypt, + &JniOcSecurity::client_decrypt}; + return &s_psRescue; + } + OCPersistentStorage* JniOcSecurity::getOCPersistentStorage() { if (store_path().empty()) @@ -48,13 +91,173 @@ namespace OC { return nullptr; } static OCPersistentStorage s_ps { &JniOcSecurity::client_open, fread, - fwrite, fclose, unlink }; + fwrite, fclose, &JniOcSecurity::client_unlink, NULL, NULL}; return &s_ps; } + int JniOcSecurity::client_encrypt(const unsigned char *pt, size_t pt_len, + unsigned char **ct, size_t *ct_len) + { + if (OC_STACK_OK != OCEncrypt(pt, pt_len, ct, ct_len)) + return 1; + return 0; + } + + int JniOcSecurity::client_decrypt(const unsigned char *ct, size_t ct_len, + unsigned char **pt, size_t *pt_len) + { + if (OC_STACK_OK != OCDecrypt(ct, ct_len, pt, pt_len)) + return 1; + return 0; + } FILE* JniOcSecurity::client_open(const char *path, const char *mode) { LOGI("Opening SVR Database file '%s' with mode '%s'\n", store_path().c_str(), mode); return fopen(store_path().c_str(), mode); } + + + FILE* JniOcSecurity::client_open_enc(const char *path, const char *mode) + { + LOGI("Opening SVR Database file '%s' with mode '%s'\n", getEncDbPath().c_str(), mode); + return fopen(getEncDbPath().c_str(), mode); + } + + FILE* JniOcSecurity::client_open_rescue(const char *path, const char *mode) + { + LOGI("Opening SVR Database file '%s' with mode '%s'\n", getRescueDbPath().c_str(), mode); + return fopen(getRescueDbPath().c_str(), mode); + } + + int JniOcSecurity::client_unlink(const char *path) + { + LOGI("unlink SVR Database file '%s' \n", store_path().c_str()); + return unlink(store_path().c_str()); + } + + size_t JniOcSecurity::getDBSize(const char *filepath) + { + FILE *fp = fopen(filepath, "rb"); + if (!fp) return 0; + + size_t size = 0; + char buffer[1023]; + if (fp) + { + size_t bytesRead = 0; + do + { + bytesRead = fread(buffer, 1, 1023, fp); //we here read encrypted data + size += bytesRead; + } while (bytesRead); + } + if (fp) fclose(fp); + return size; + } + + OCStackResult JniOcSecurity::ResetDBFile(const char *cred_file) + { + + size_t fileSize = getDBSize(s_rescue_path.c_str()); + unsigned char *data = (unsigned char *)calloc(1, sizeof(unsigned char) * fileSize); + unsigned char *ct = NULL; + size_t ct_len; + + OCPersistentStorage *ps = JniOcSecurity::getOCPersistentStorage(); + + FILE *fp = fopen(s_rescue_path.c_str(), "rb"); + FILE *filep = fopen(cred_file, "wb"); + OCStackResult ret = OC_STACK_OK; + + if (!fp || !filep) + { + LOGE("Failed to open %s\n", s_rescue_path.c_str()); + ret = OC_STACK_ERROR; + goto exit; + } + if (fread(data, 1, fileSize, fp) != fileSize) + { + LOGE("Failed to read %s\n", s_rescue_path.c_str()); + ret = OC_STACK_ERROR; + goto exit; + } + if (OC_STACK_OK != ps->encrypt(data, fileSize, &ct, &ct_len)) + { + LOGE("Encryption Failed %d\n",__LINE__); + } + if (fwrite(ct, 1, ct_len, filep) != ct_len) + { + LOGE("Failed to write encrypted data to %s\n", cred_file); + ret = OC_STACK_ERROR; + goto exit; + } +exit: + if (filep) fclose(filep); + if (fp) fclose(fp); + free(data); + return ret; + } +#if 0 + size_t JniOcSecurity::client_read(void *buffer, size_t size, size_t nmemb, FILE *fp) + { + size_t fileSize = size * nmemb; + size_t pt_len; + unsigned char *pt = NULL; + + OCPersistentStorage *ps = JniOcSecurity::getOCPersistentStorage(); + unsigned char *buf = (unsigned char*)calloc(1, sizeof(unsigned char) * fileSize); + + LOGE("In JniOcSecurity::client_read ps = %p, fileSize = %d\n", ps, fileSize); + + if (fileSize == fread(buf, 1, fileSize, fp)) + { + if (OC_STACK_OK != ps->decrypt(buf, fileSize, &pt, &pt_len)) + { + LOGE( "ps->decrypt() Failed !!"); + fileSize = 0; + goto exit; + } + else + { + memcpy(buffer, pt, pt_len); + fileSize = pt_len; + } + } + else + { + LOGE("Failed fileSize == fread(buf, 1, fileSize, fp)"); + fileSize = 0; + } +exit: + free(buf); + return fileSize; + } + + size_t JniOcSecurity::client_write(const void *buffer, size_t size, + size_t nmemb, FILE *fp) + { + size_t fileSize = size * nmemb; + unsigned char *ct = NULL; + size_t ct_len = 0; + OCPersistentStorage *ps = JniOcSecurity::getOCPersistentStorage(); + + if (0 != ps->encrypt((const unsigned char*)buffer, fileSize, &ct, &ct_len)) + { + LOGE( "ps->encrypt() Failed !!"); + fileSize = 0; + goto exit; + } + + fileSize = ct_len; + if (fileSize != fwrite(ct, 1, fileSize,fp)) + { + LOGE( "fwrite() Failed !!"); + fileSize = 0; + goto exit; + } +exit: + free(ct); + return fileSize; + } +#endif } diff --git a/android/android_api/base/jni/JniOcSecurity.h b/android/android_api/base/jni/JniOcSecurity.h old mode 100644 new mode 100755 index 78293e6..53aa296 --- a/android/android_api/base/jni/JniOcSecurity.h +++ b/android/android_api/base/jni/JniOcSecurity.h @@ -33,11 +33,30 @@ namespace OC class JniOcSecurity { private: + static size_t getDBSize(const char *filepath); + static OCStackResult ResetDBFile(const char *cred_file); + static size_t client_read(void *buffer, size_t size, size_t nmemb, FILE *fp); + + static size_t client_write(const void *buffer, size_t size, + size_t nmemb, FILE *fp); static FILE* client_open(const char*, const char*); + static FILE* client_open_enc(const char*, const char*); + static FILE* client_open_rescue(const char*, const char*); + static int client_unlink(const char *path); + static int client_encrypt(const unsigned char *pt, size_t pt_len, + unsigned char **ct, size_t *ct_len); + static int client_decrypt(const unsigned char *ct, size_t ct_len, + unsigned char **pt, size_t *pt_len); public: static std::string& store_path(void); + static std::string& getEncDbPath(void); + static std::string& getRescueDbPath(void); static void StoreDbPath(const std::string&); + static void StoreDefault_DbPath(const std::string&, const std::string&, int); static OCPersistentStorage* getOCPersistentStorage(void); + static OCPersistentStorage* getOCPersistentStorageEnc(void); + static OCPersistentStorage* getOCPersistentStorageRescue(void); + }; } #endif //__JNIOCSECURITY_H diff --git a/android/android_api/base/jni/JniUtils.h b/android/android_api/base/jni/JniUtils.h index 74e48e6..ebcec3d 100644 --- a/android/android_api/base/jni/JniUtils.h +++ b/android/android_api/base/jni/JniUtils.h @@ -133,6 +133,36 @@ public: }; } + static OCTransportAdapter getOCTransportAdapter(int adapter) + { + int transport = OCTransportAdapter::OC_DEFAULT_ADAPTER; + if (adapter & CT_ADAPTER_IP) + { + transport |= OCTransportAdapter::OC_ADAPTER_IP; + } + + if (adapter & CT_ADAPTER_GATT_BTLE) + { + transport |= OCTransportAdapter::OC_ADAPTER_GATT_BTLE; + } + + if (adapter & CT_ADAPTER_RFCOMM_BTEDR) + { + transport |= OCTransportAdapter::OC_ADAPTER_RFCOMM_BTEDR; + } + + if (adapter & CT_ADAPTER_TCP) + { + transport |= OCTransportAdapter::OC_ADAPTER_TCP; + } + + if (adapter & CT_ADAPTER_NFC) + { + transport |= OCTransportAdapter::OC_ADAPTER_NFC; + } + return (OCTransportAdapter)transport; + } + static std::string stackResultToStr(const int result) { switch (result) @@ -207,6 +237,8 @@ public: case OC_STACK_INVALID_JSON: return "INVALID_JSON"; /** Request is not authorized by Resource Server. */ + case OC_STACK_NOT_ACCEPTABLE: + return "NOT_ACCEPTABLE"; case OC_STACK_UNAUTHORIZED_REQ: return "UNAUTHORIZED_REQ"; /** Error code from PDM */ @@ -216,6 +248,8 @@ public: return "DUPLICATE_UUID"; case OC_STACK_INCONSISTENT_DB: return "INCONSISTENT_DB"; + case OC_STACK_SVR_DB_NOT_EXIST: + return "SVR_DB_NOT_EXIST"; /** Error code from OTM */ case OC_STACK_AUTHENTICATION_FAILURE: return "AUTHENTICATION_FAILURE"; diff --git a/android/android_api/base/src/main/java/org/iotivity/base/MVJustWorksOptionMask.java b/android/android_api/base/src/main/java/org/iotivity/base/MVJustWorksOptionMask.java new file mode 100644 index 0000000..7e111ca --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/MVJustWorksOptionMask.java @@ -0,0 +1,64 @@ +/* + ******************************************************************* + * + * 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.security.InvalidParameterException; +import java.util.EnumSet; + +public enum MVJustWorksOptionMask { + NOT_APPLICABLE (0x0), + DISPLAY_MUTUAL_VERIF_NUM (0x1 << 0), + CONFIRM_MUTUAL_VERIF_NUM (0x1 << 1), + ; + + private int value; + + private MVJustWorksOptionMask(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static EnumSet convertToEnumSet(int value) { + EnumSet typeSet = null; + + for (MVJustWorksOptionMask v : values()) { + if (0 != (value & v.getValue())) { + if (null == typeSet) { + typeSet = EnumSet.of(v); + } else { + typeSet.add(v); + } + } + } + + if (null == typeSet || typeSet.isEmpty()) { + throw new InvalidParameterException("Unexpected MVJustWorksOptionMask value:" + value); + } + + return typeSet; + } + +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java index 89e7fae..954eab2 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java @@ -77,6 +77,8 @@ public final class OcPlatform { private static volatile boolean sIsPlatformInitialized = false; private static QualityOfService sPlatformQualityOfService = QualityOfService.NA; + private static volatile boolean sIsStopPlatform = false; + private OcPlatform() { } @@ -89,6 +91,12 @@ public final class OcPlatform { * @param platformConfig platform configuration */ public synchronized static void Configure(PlatformConfig platformConfig) { + if (sIsStopPlatform) + { + OcPlatform.start(); + sIsStopPlatform = false; + } + if (!sIsPlatformInitialized) { CaInterface.initialize(platformConfig.getActivity(), platformConfig.getContext()); @@ -100,7 +108,12 @@ public final class OcPlatform { platformConfig.getIpAddress(), platformConfig.getPort(), platformConfig.getQualityOfService().getValue(), - platformConfig.getSvrDbPath() + platformConfig.getSvrDbPath(), + platformConfig.getDBDefaultPath(), + platformConfig.getDBRescuePath(), + platformConfig.getKeySize(), + platformConfig.getKey(), + platformConfig.getAvailableTransportType() ); sIsPlatformInitialized = true; @@ -112,7 +125,33 @@ public final class OcPlatform { String ipAddress, int port, int qualityOfService, - String dbPath); + String dbPath, + String dbPathDefault, + String dbRescuePath, + int keySize, + byte[] key, + int transport); + + /** + * API for stop all process of the OcPlatform. + * All of threads and memory will be terminated by this API. + * Iotivity Core can be started again through Configure(PlatformConfig platformConfig) API. + * Both Configure and Shutdown API is filtering for duplicated calling even while processing. + *

+ * Note: This API is for both server and client side. + *

+ */ + public synchronized static void Shutdown() { + if (!sIsStopPlatform) + { + OcPlatform.stop(); + sIsStopPlatform = true; + sIsPlatformInitialized = false; + } + } + + private static native void stop(); + private static native void start(); /** * API for notifying base that resource's attributes have changed. @@ -1122,6 +1161,16 @@ public final class OcPlatform { public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest); } + /** + * Listner to get result of findKeepAliveResource and sendKeepAliveRequest. + * An PingListener can be registered via the OcPlatform.KeepAliveListener and + * OcPlatform.sendKeepAliveRequest call. + * Event listeners are notified asynchronously + */ + public interface KeepAliveListener { + public void onKeepAliveListener(OcRepresentation ocRepresentation, int result); + } + private static void initCheck() { if (!sIsPlatformInitialized) { throw new IllegalStateException("OcPlatform must be configured by making a call to " + @@ -1183,4 +1232,42 @@ public final class OcPlatform { * Method to set DeviceId. */ public static native void setDeviceId(byte[] deviceId) throws OcException; + + /** + * gets OCRepresentation of KeepAlive resource from given host. + * + * @param host Host IP Address of pingResource + * @param onKeepAliveFoundListener Function to callback with result code and OCRepresentation. + * @throws OcException if failure + */ + public static void findKeepAliveResource(String host, + KeepAliveListener onKeepAliveFoundListener) + throws OcException { + OcPlatform.initCheck(); + OcPlatform.findKeepAliveResourceImpl(host, onKeepAliveFoundListener); + } + + private static native void findKeepAliveResourceImpl(String host, + KeepAliveListener onKeepAliveFoundListener) + throws OcException; + + /** + * send KeepAlive request to given host. + * + * @param interval interval time of expected pong response + * @param keepAliveResponseListener handles callback + * @throws OcException if failure + * + */ + public static void sendKeepAliveRequest(String host, OcRepresentation ocRepresentation, + KeepAliveListener keepAliveResponseListener) + throws OcException { + OcPlatform.initCheck(); + OcPlatform.sendKeepAliveRequestImpl(host, ocRepresentation, keepAliveResponseListener); + } + + private static native void sendKeepAliveRequestImpl(String host, + OcRepresentation ocRepresentation, + KeepAliveListener keepAliveResponseListener) + throws OcException; } diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java b/android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java index 8cb282b..395021f 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java @@ -25,6 +25,7 @@ package org.iotivity.base; import java.util.List; import java.util.Arrays; import java.util.Map; +import java.util.EnumSet; /** * OcProvisionig represents functions corresponding to the provisioing of @@ -101,6 +102,68 @@ public class OcProvisioning { } /** + * API to Set callback for displaying verifNum in verified Just-Works. + * + *@param DisplayNumListener callback Listener to be registered for + displaying VerifyNUm. + *@throws OcException + */ + public static native void setDisplayNumListener( + DisplayNumListener displayNumListener) throws OcException; + + public static interface DisplayNumListener { + public int displayNumListener(String verifyNum); + } + + /** + * API to unregister DisplayNumListener Listener + * + *@return 0 on success, 1 on failure + *@throws OcException + */ + public static native int unsetDisplayNumListener() throws OcException; + + /** + * API to Set callback for getting user confirmation in verified + * Just-Works + * + *@param ConfirmNumListener callback Listener to be registered for getting user confirmation. + *@throws OcException + */ + public static native void setConfirmNumListener(ConfirmNumListener + confirmNumListener) throws OcException; + + public static interface ConfirmNumListener { + public int confirmNumListener(); + } + + /** + * API to unregister ConfirmMutualVerifyNum Listener + * + *@return 0 on success, 1 on failure + *@throws OcException + */ + public static native int unsetConfirmNumListener() throws OcException; + + /** + * API to set options for Mutual Verified Just-works + * Default is for both screen PIN display and get user confirmation. + * + */ + public static int setMVJustWorksOptions(EnumSet optionMask) throws OcException { + + int optionMaskInt = 0; + + for (MVJustWorksOptionMask ops : MVJustWorksOptionMask.values()) { + if (optionMask.contains(ops)) + optionMaskInt |= ops.getValue(); + } + return setMVJustWorksOptions0(optionMaskInt); + } + + private static native int setMVJustWorksOptions0(int optionsMask) throws OcException; + + /** * Method to get Array of owned and un-owned devices in the current subnet. * * @param timeout timeout in sec for the API to return. @@ -125,4 +188,50 @@ public class OcProvisioning { } private static native int saveTrustCertChain1(byte[] trustCertChain, int encodingType) throws OcException; + + /** + * Method to save pin type. + * + * @param pinSize Byte Len of Random pin. + * @param pinType Enumset of pin, see PinType for enums + * @throws OcException + */ + public static int setPinType(int pinSize, EnumSet pinType) throws OcException { + + int pinTypeInt = 0; + + for (PinType ops : PinType.values()) { + if (pinType.contains(ops)) + pinTypeInt |= ops.getValue(); + } + return setPinType0(pinSize, pinTypeInt); + } + private static native int setPinType0(int pinSize, int pinType) throws OcException; + + /** + * Method to save the seed value to generate device UUID + * + * @param seed buffer of seed value + * @throws OcException + */ + public static int setDeviceIdSeed(byte[] seed) throws OcException { + return setDeviceIdSeed1(seed); + } + private static native int setDeviceIdSeed1(byte[] seed) + throws OcException; + + /** + * API to save ACL, having multiple ACE's + * + *@param acl object + *@throws OcException + */ + public static native void saveACL(Object acl) throws OcException; + + /** + * API to do self ownership transfer. + * + *@throws OcException + */ + public static native void doSelfOwnershiptransfer() throws OcException; } diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java index f9cc04f..0ea863f 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java @@ -574,6 +574,13 @@ public class OcResource { public native String getServerId(); /** + * Method to get a string representation of the human friendly name defined by the vendor. + * + * @return human friendly name + */ + public native String getDeviceName(); + + /** * An OnGetListener can be registered via the resource get call. * Event listeners are notified asynchronously */ diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PinType.java b/android/android_api/base/src/main/java/org/iotivity/base/PinType.java new file mode 100644 index 0000000..65759fd --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/PinType.java @@ -0,0 +1,62 @@ +/* + ******************************************************************* + * + * 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.security.InvalidParameterException; +import java.util.EnumSet; + +public enum PinType { + NUM_PIN (0x1 << 0), + UPPERCASE_CHAR_PIN (0x1 << 1), + LOWERCASE_CHAR_PIN (0x1 << 2), + ; + + private int value; + + private PinType(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static EnumSet convertToEnumSet(int value) { + EnumSet typeSet = null; + + for (PinType v : values()) { + if (0 != (value & v.getValue())) { + if (null == typeSet) { + typeSet = EnumSet.of(v); + } else { + typeSet.add(v); + } + } + } + + if (null == typeSet || typeSet.isEmpty()) { + throw new InvalidParameterException("Unexpected PinType value:" + value); + } + return typeSet; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java index b41b65c..e02602c 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java @@ -24,7 +24,7 @@ package org.iotivity.base; import android.content.Context; import android.app.Activity; - +import java.util.EnumSet; /** * Data structure to provide the configuration. */ @@ -38,6 +38,11 @@ public class PlatformConfig { private QualityOfService mQualityOfService; private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage. //this is only for 0.9.2 + private String mSvrDbPathDefault; + private String mSvrDbPathRescue; + private int mKeySize; + private byte[] mKey; + private int mTransportType; /** * @param activity app activity * @param context app context @@ -68,8 +73,33 @@ public class PlatformConfig { this.mPort = port; this.mQualityOfService = qualityOfService; this.mSvrDbPath = dbPath; + this.mTransportType = 0; } + public PlatformConfig(Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService, + String dbPath, + String dbPathDefault, + String dbPathRescue, + int keySize, + byte[] key) { + this.mContext = context; + this.mServiceType = serviceType; + this.mModeType = modeType; + this.mIpAddress = ipAddress; + this.mPort = port; + this.mQualityOfService = qualityOfService; + this.mSvrDbPath = dbPath; + this.mSvrDbPathDefault = dbPathDefault; + this.mSvrDbPathRescue = dbPathRescue; + this.mKeySize = keySize; + this.mKey = key; + this.mTransportType = 0; + } /** * @param context app context * @param serviceType indicate IN_PROC or OUT_OF_PROC @@ -170,4 +200,32 @@ public class PlatformConfig { return mActivity; } + public String getDBDefaultPath() { + return mSvrDbPathDefault; + } + + public String getDBRescuePath() { + return mSvrDbPathRescue; + } + + public int getKeySize() + { + return mKeySize; + } + + public byte[] getKey() + { + return mKey; + } + + public void setAvailableTransportType(EnumSet type) { + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (type.contains(connType)) + mTransportType |= connType.getValue(); + } + } + + public int getAvailableTransportType() { + return mTransportType; + } } diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java index e06d574..5811afd 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java @@ -29,12 +29,16 @@ import android.content.IntentFilter; public class CaBtPairingInterface { private static Context mContext; + private static volatile boolean isBtInitialized = false; private CaBtPairingInterface(Context context) { synchronized(CaBtPairingInterface.class) { mContext = context; } - registerIntentFilter(); + if (!isBtInitialized) { + registerIntentFilter(); + isBtInitialized = true; + } } private static IntentFilter registerIntentFilter() { @@ -47,7 +51,10 @@ public class CaBtPairingInterface { } public static void destroyEdrInterface() { - mContext.unregisterReceiver(mReceiver); + if (isBtInitialized) { + mContext.unregisterReceiver(mReceiver); + isBtInitialized = false; + } } private native static void oicEdrStateChangedCallback(int state); diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java index aaf8bc6..067dbf3 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java @@ -30,12 +30,16 @@ import android.util.Log; public class CaEdrInterface { private static Context mContext; + private static volatile boolean isEdrInitialized = false; private CaEdrInterface(Context context) { synchronized(CaEdrInterface.class) { mContext = context; } - registerIntentFilter(); + if (!isEdrInitialized) { + registerIntentFilter(); + isEdrInitialized = true; + } } private static IntentFilter registerIntentFilter() { @@ -48,7 +52,10 @@ public class CaEdrInterface { } public static void destroyEdrInterface() { - mContext.unregisterReceiver(mReceiver); + if (isEdrInitialized) { + mContext.unregisterReceiver(mReceiver); + isEdrInitialized = false; + } } // Network Monitor diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java index 6924eb4..73fec6c 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java @@ -28,6 +28,8 @@ import android.bluetooth.BluetoothDevice; import org.iotivity.base.OcException; import org.iotivity.base.OcConnectivityType; +import java.util.EnumSet; + public class CaInterface { static { System.loadLibrary("connectivity_abstraction"); @@ -186,17 +188,72 @@ public class CaInterface { * @param intervalTime interval time(Seconds). * @param workingCount working count with interval time. */ - public synchronized static void setLeScanIntervalTime(int intervalTime, int workingCount){ CaInterface.setLeScanIntervalTimeImpl(intervalTime, workingCount); } - private static native void setLeScanIntervalTimeImpl(int intervalTime, int workingCount); + /** + * stop BLE scan. + * if you want to start scan, it can be triggered by setLeScanIntervalTime or + * other request API like findResource. + */ + public synchronized static void stopLeScan(){ + CaInterface.stopLeScanImpl(); + } + private static native void stopLeScanImpl(); + + /** + * start BLE Advertising. + */ + public synchronized static void startLeAdvertising(){ + CaInterface.startLeAdvertisingImpl(); + } + private static native void startLeAdvertisingImpl(); + + /** + * stop BLE Advertising. + */ + public synchronized static void stopLeAdvertising(){ + CaInterface.stopLeAdvertisingImpl(); + } + private static native void stopLeAdvertisingImpl(); + + /** + * set BT configure + */ + public synchronized static void setBTConfigure(int flag){ + CaInterface.setBTConfigureImpl(flag); + } + private static native void setBTConfigureImpl(int flag); public synchronized static int setCipherSuite(OicCipher cipher, OcConnectivityType connType){ return CaInterface.setCipherSuiteImpl(cipher.getValue(), connType.getValue()); } private static native int setCipherSuiteImpl(int cipher, int adapter); + /** + * Disconnect TCP session. + * It will disconnect the current TCP session. + * + * @param address host address [IP address]. + * @param port Port number. + * @param transportFlags Set of Transport flags. + * + * @return Result of the API call. + * + * @see CaTransportFlags + */ + public synchronized static int disconnectTCPSession(String address, int port, + EnumSet transportFlags) { + int transPortFlagsInt = 0; + for (CaTransportFlags flag : CaTransportFlags.values()) { + if (transportFlags.contains(flag)) { + transPortFlagsInt |= flag.getValue(); + } + } + + return CaInterface.disconnectTCPSessionImpl(address, port, transPortFlagsInt); + } + private static native int disconnectTCPSessionImpl(String address, int port, int flags); } diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java index a747953..e2da3ec 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java @@ -1,116 +1,97 @@ -/****************************************************************** - * - * Copyright 2014 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.ca; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.net.wifi.WifiManager; -import android.util.Log; - -public class CaIpInterface { - private static Context mContext; - - public enum WifiAPState{ - WIFI_AP_STATE_DISABLING (10), - WIFI_AP_STATE_DISABLED (11), - WIFI_AP_STATE_ENABLING (12), - WIFI_AP_STATE_ENABLED (13), - WIFI_AP_STATE_FAILED (14) - ; // semicolon needed when fields / methods follow - - - private final int apstate; - - WifiAPState(int apstate) - { - this.apstate = apstate; - } - public int getIntValue() { - return this.apstate; - } - } - - private CaIpInterface(Context context) { - synchronized(CaIpInterface.class) { - mContext = context; - } - registerIpStateReceiver(); - } - - private void registerIpStateReceiver() { - IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); - intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); - intentFilter.addAction("android.net.wifi.WIFI_AP_STATE_CHANGED"); - - mContext.registerReceiver(mReceiver, intentFilter); - } - - public static void destroyIpInterface() { - mContext.unregisterReceiver(mReceiver); - } - - private static BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { - ConnectivityManager manager = (ConnectivityManager) - mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); - NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); - - if (mobileInfo != null && mobileInfo.isConnected() || wifiInfo.isConnected()) { - caIpStateEnabled(); - } else { - caIpStateDisabled(); - } - } - - if (intent.getAction().equals("android.net.wifi.WIFI_AP_STATE_CHANGED")) { - if (intent.getIntExtra("wifi_state", - WifiAPState.WIFI_AP_STATE_DISABLED.getIntValue()) - == WifiAPState.WIFI_AP_STATE_DISABLED.getIntValue()) - { - caIpStateDisabled(); - }else if(intent.getIntExtra("wifi_state", - WifiAPState.WIFI_AP_STATE_DISABLED.getIntValue()) - == WifiAPState.WIFI_AP_STATE_ENABLED.getIntValue()) - { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - caIpStateEnabled(); - } - } - } - }; - - private native static void caIpStateEnabled(); - - private native static void caIpStateDisabled(); -} +/****************************************************************** + * + * Copyright 2014 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.ca; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; +import android.util.Log; + +public class CaIpInterface { + private static Context mContext; + private static volatile boolean isIpInitialized = false; + private static String TAG = "OIC_IP_CB_INTERFACE"; + + private CaIpInterface(Context context) { + synchronized(CaIpInterface.class) { + mContext = context; + } + if (!isIpInitialized) { + registerIpStateReceiver(); + isIpInitialized = true; + } + } + + private void registerIpStateReceiver() { + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); + + mContext.registerReceiver(mReceiver, intentFilter); + } + + public static void destroyIpInterface() { + if (isIpInitialized) { + mContext.unregisterReceiver(mReceiver); + isIpInitialized = false; + } + } + + private static BroadcastReceiver mReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + NetworkInfo activeNetwork = ((ConnectivityManager) mContext + .getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); + if (activeNetwork != null) { + Log.d(TAG, "CONNECTIVITY_ACTION - activeNetwork: " + + activeNetwork.getTypeName() + + " isConnected: " + activeNetwork.isConnected()); + caIpStateEnabled(); + } else { + Log.d(TAG, "CONNECTIVITY_ACTION - activeNetwork: NONE"); + caIpStateDisabled(); + } + } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { + NetworkInfo netInfo = (NetworkInfo) intent + .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); + if (ConnectivityManager.TYPE_WIFI == netInfo.getType()) { + NetworkInfo.State netState = netInfo.getState(); + if (NetworkInfo.State.CONNECTED == netState) { + Log.d(TAG, "NETWORK_STATE_CHANGED_ACTION - CONNECTED: TYPE_WIFI"); + caIpStateEnabled(); + } else if (NetworkInfo.State.DISCONNECTED == netState) { + Log.d(TAG, "NETWORK_STATE_CHANGED_ACTION - DISCONNECTED: TYPE_WIFI"); + } + } + } + } + }; + + private native static void caIpStateEnabled(); + + private native static void caIpStateDisabled(); +} diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java index 695359b..fc1db0d 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java @@ -38,25 +38,47 @@ import android.content.Intent; import android.content.IntentFilter; import android.util.Log; +// For using bluetooth.le APIs +import android.bluetooth.le.BluetoothLeScanner; +import android.bluetooth.le.ScanCallback; +import android.bluetooth.le.ScanFilter; +import android.bluetooth.le.ScanResult; +import android.bluetooth.le.ScanSettings; +import android.os.ParcelUuid; +import java.util.Iterator; +import android.os.Build; + public class CaLeClientInterface { private static String SERVICE_UUID = "ADE3D529-C784-4F63-A987-EB69F70EE816"; private static String TAG = "OIC_LE_CB_INTERFACE"; private static Context mContext; + private static volatile boolean isLeClientInitialized = false; + + //For custom uuid ble server + final static String CUSTOM_UUID = "75004209-0000-0000-0000-000000000000"; + final static String CUSTOM_UUID2 = "75004204-0000-0000-0000-000000000000"; + final static int custom_uuid_len1 = 9; + final static int custom_uuid_strlen1 = 4; private CaLeClientInterface(Context context) { - caLeRegisterLeScanCallback(mLeScanCallback); + getLeScanCallback(); caLeRegisterGattCallback(mGattCallback); synchronized(CaLeClientInterface.class) { mContext = context; } - registerIntentFilter(); + if (!isLeClientInitialized) { + registerIntentFilter(); + isLeClientInitialized = true; + } } - - public static void getLeScanCallback() { - caLeRegisterLeScanCallback(mLeScanCallback); +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// caLeRegisterLeScanCallbackForV21(mLeScanCallbackForV21); +// } else { + caLeRegisterLeScanCallback(mLeScanCallback); +// } } public static void getLeGattCallback() { @@ -72,16 +94,36 @@ public class CaLeClientInterface { } public static void destroyLeInterface() { - mContext.unregisterReceiver(mReceiver); + if (isLeClientInitialized) { + mContext.unregisterReceiver(mReceiver); + isLeClientInitialized = false; + } + } + + public static BluetoothGatt connectGattforHidden(BluetoothDevice device, + String address, boolean autoConnect) { + if (isLeClientInitialized) { + BluetoothAdapter mbluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + BluetoothDevice mDevice = mbluetoothAdapter.getRemoteDevice(address); + Log.d(TAG, "connectGattforHidden method : getAddress : " + mDevice.getAddress() + + ", autoconnect : " + autoConnect); + return mDevice.connectGatt(mContext, autoConnect, mGattCallback); + } + return null; } private native static void caLeRegisterLeScanCallback(BluetoothAdapter.LeScanCallback callback); + private native static void caLeRegisterLeScanCallbackForV21(ScanCallback callback); + private native static void caLeRegisterGattCallback(BluetoothGattCallback callback); // BluetoothAdapter.LeScanCallback private native static void caLeScanCallback(BluetoothDevice device); + // scan failed callback for ca layer + private native static void caLeScanFailedCallback(int errorCode); + // BluetoothGattCallback private native static void caLeGattConnectionStateChangeCallback( BluetoothGatt gatt, int status, int newState); @@ -132,36 +174,70 @@ public class CaLeClientInterface { private native static void caManagerLeRemoteRssiCallback(BluetoothGatt gatt, int rssi, int status); - // Callback + private native static void caLeGattMtuChangedCallback(BluetoothGatt gatt, int mtu, + int status); + + // Le Scan Callback which lower than API 21 private static BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { + filteringScanResult(device, scanRecord); + } + }; - try { - List uuids = getUuids(scanRecord); - for (UUID uuid : uuids) { - Log.d(TAG, "UUID : " + uuid.toString()); - if(uuid.toString().contains(SERVICE_UUID.toLowerCase())) { - Log.d(TAG, "we found that has the Device"); - Log.d(TAG, "scanned device address : " + device.getAddress()); - caLeScanCallback(device); - } - } - } catch(UnsatisfiedLinkError e) { + // Le Scan Callback which upper than API 21 + private static ScanCallback mLeScanCallbackForV21 = new ScanCallback() { + @Override + public void onScanResult(int callbackType, ScanResult result) { + super.onScanResult(callbackType, result); + Log.d(TAG, "onScanResult from ScanCallback"); + filteringScanResult(result.getDevice(), result.getScanRecord().getBytes()); + } + @Override + public void onBatchScanResults(List results) { + super.onBatchScanResults(results); + Iterator itr = results.iterator(); + while (itr.hasNext()) { + filteringScanResult(itr.next().getDevice(), + itr.next().getScanRecord().getBytes()); } } + + @Override + public void onScanFailed(int errorCode) { + super.onScanFailed(errorCode); + caLeScanFailedCallback(errorCode); + } }; + private static void filteringScanResult(BluetoothDevice device, byte[] scanRecord) { + try { + List uuids = getUuids(scanRecord); + for (UUID uuid : uuids) { + if(uuid.toString().contains(SERVICE_UUID.toLowerCase())) { + caLeScanCallback(device); + } else if(uuid.toString().contains(CUSTOM_UUID.toLowerCase()) || + uuid.toString().contains(CUSTOM_UUID2.toLowerCase())) { + Log.d(TAG, "we found that has the Device [" + device.getAddress() + + "] which has custom adv"); + caLeScanCallback(device); + } + } + } catch(UnsatisfiedLinkError e) { + e.printStackTrace(); + } + } + private static List getUuids(final byte[] scanRecord) { List uuids = new ArrayList(); int offset = 0; while (offset < (scanRecord.length - 2)) { int len = scanRecord[offset++]; - if (len == 0) + if (len <= 0) break; int type = scanRecord[offset++]; @@ -196,7 +272,28 @@ public class CaLeClientInterface { } break; default: - offset += (len - 1); + if (len >= custom_uuid_len1) { + StringBuffer strbuf1 = new StringBuffer(); + int strcnt = 0; + int backlen = len; + while (backlen > 1) { + String str = String.format("%02x", scanRecord[offset++]); + backlen -= 1; + if (strcnt < custom_uuid_strlen1) { + strbuf1.append(str); + } + else { + break; + } + strcnt++; + } + offset += (backlen - 1); + uuids.add(UUID.fromString(String.format( + "%4s-0000-0000-0000-000000000000", + strbuf1.toString()))); + } else { + offset += (len - 1); + } break; } } @@ -270,6 +367,12 @@ public class CaLeClientInterface { super.onReadRemoteRssi(gatt, rssi, status); caManagerLeRemoteRssiCallback(gatt, rssi, status); } + + @Override + public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { + super.onMtuChanged(gatt, mtu, status); + caLeGattMtuChangedCallback(gatt, mtu, status); + } }; private static final BroadcastReceiver mReceiver = new BroadcastReceiver() { @@ -312,4 +415,3 @@ public class CaLeClientInterface { }; } - diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java index 0a4bb5c..fa71719 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java @@ -62,11 +62,13 @@ public class CaLeServerInterface { BluetoothDevice device, byte[] data); private native static void caLeGattServerCharacteristicWriteRequestCallback( - BluetoothDevice device, byte[] data); + BluetoothDevice device, byte[] data, int id, int offset, byte[] value); private native static void caLeGattServerNotificationSentCallback(BluetoothDevice device, int status); + private native static void caLeGattServerMtuChangedCallback(BluetoothDevice gatt, int mtu); + // AdvertiseCallback private native static void caLeAdvertiseStartSuccessCallback( AdvertiseSettings settingsInEffect); @@ -108,7 +110,8 @@ public class CaLeServerInterface { super.onCharacteristicWriteRequest(device, requestId, characteristic, preparedWrite, responseNeeded, offset, value); - caLeGattServerCharacteristicWriteRequestCallback(device, value); + caLeGattServerCharacteristicWriteRequestCallback(device, value, requestId, + offset, value); } @Override @@ -138,6 +141,13 @@ public class CaLeServerInterface { caLeGattServerNotificationSentCallback(device, status); } + + @Override + public void onMtuChanged(BluetoothDevice device, int mtu) { + super.onMtuChanged(device, mtu); + + caLeGattServerMtuChangedCallback(device, mtu); + } }; private static final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() { diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaTransportFlags.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaTransportFlags.java new file mode 100644 index 0000000..468b344 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaTransportFlags.java @@ -0,0 +1,79 @@ +/* **************************************************************** + * + * Copyright 2017 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.ca; + +import java.util.EnumSet; +import java.security.InvalidParameterException; + +public enum CaTransportFlags { + + CA_DEFAULT_FLAGS(0), + + /** Insecure transport is the default (subject to change) */ + CA_SECURE (1 << 4), // secure the transport path + + /** IPv4 & IPv6 autoselection is the default */ + CA_IPV6 (1 << 5), // IP adapter only + CA_IPV4 (1 << 6), // IP adapter only + + /** Indication that a message was received by multicast. */ + CA_MULTICAST (1 << 7), + + /** Link-Local multicast is the default multicast scope for IPv6. + *These correspond in both value and position to the IPv6 address bits. */ + CA_SCOPE_INTERFACE (0x1), // IPv6 Interface-Local scope + CA_SCOPE_LINK (0x2), // IPv6 Link-Local scope (default) + CA_SCOPE_REALM (0x3), // IPv6 Realm-Local scope + CA_SCOPE_ADMIN (0x4), // IPv6 Admin-Local scope + CA_SCOPE_SITE (0x5), // IPv6 Site-Local scope + CA_SCOPE_ORG (0x8), // IPv6 Organization-Local scope + CA_SCOPE_GLOBAL (0xE), // IPv6 Global scope + ; + private int value; + + private CaTransportFlags(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static EnumSet convertToEnumSet(int value) { + + EnumSet typeSet = null; + for (CaTransportFlags v : values()) { + if (0 != (value & v.getValue())) { + if (null == typeSet) { + typeSet = EnumSet.of(v); + } else { + typeSet.add(v); + } + } + } + + if (null == typeSet || typeSet.isEmpty()) { + throw new InvalidParameterException("Unexpected CaTransportFlag value:" + value); + } + + return typeSet; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/OicCipher.java b/android/android_api/base/src/main/java/org/iotivity/ca/OicCipher.java index 60f9f16..030217f 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/OicCipher.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/OicCipher.java @@ -1,38 +1,45 @@ -/* **************************************************************** - * - * 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.ca; - -public enum OicCipher { - TLS_ECDH_anon_WITH_AES_128_CBC_SHA(0xC018), - TLS_PSK_WITH_AES_128_CCM_8(0xC0A8), - TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8(0xC0AE), - TLS_RSA_WITH_AES_256_CBC_SHA(0x35); - - private int cipher; - - private OicCipher(int cipher) { - this.cipher = cipher; - } - - public int getValue(){ - return cipher; - } -} +/* **************************************************************** + * + * 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.ca; + +public enum OicCipher { + TLS_RSA_WITH_AES_256_CBC_SHA256(0x3D), + TLS_RSA_WITH_AES_128_GCM_SHA256(0x009C), + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256(0xC02B), + TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8(0xC0AE), + TLS_ECDHE_ECDSA_WITH_AES_128_CCM(0xC0AC), + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256(0xC023), + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384(0xC024), + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384(0xC02C), + TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256(0xC037), + TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256(0xC027), + TLS_ECDH_anon_WITH_AES_128_CBC_SHA(0xC018); + + private int cipher; + + private OicCipher(int cipher) { + this.cipher = cipher; + } + + public int getValue(){ + return cipher; + } +} diff --git a/android/examples/cloudprovisioningclient/src/main/java/org/iotivity/base/examples/cloudprovisioningclient/CloudProvisioningClient.java b/android/examples/cloudprovisioningclient/src/main/java/org/iotivity/base/examples/cloudprovisioningclient/CloudProvisioningClient.java old mode 100755 new mode 100644 diff --git a/android/examples/provisioningclient/src/main/AndroidManifest.xml b/android/examples/provisioningclient/src/main/AndroidManifest.xml index 93a375b..1ab6976 100644 --- a/android/examples/provisioningclient/src/main/AndroidManifest.xml +++ b/android/examples/provisioningclient/src/main/AndroidManifest.xml @@ -1,7 +1,8 @@ - + + ~6oC+h z)9!kAv@_$~vW&@>{?8_NQK0?g83SB@mDtb%m~9%tvqxb7bz@xTeZ%Jl^7%*$Hgd1j z*j3^3cu~f_6!}W{Qsl9e%z%7t0eJv$KR!Q! z@_{^)gm5yA2qZ~F(g}&kl#E@LrjyjA$@s}{2|k6Y#+QOe0MWZ>6G2*=3Uyt)nC4l G{r(S9Brwtd literal 0 HcmV?d00001 diff --git a/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_enc.dat b/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_enc.dat new file mode 100644 index 0000000000000000000000000000000000000000..f3cf369efff774700b109b89752429a4cde4615c GIT binary patch literal 859 zcmbVKL2kk@5Cp_ida9Jrio}SY&|71BBb?ZA~6oC+h z)9!kAv@_$~vW&@>{?8_NQK0?g83SB@mDtb%m~9%tvqxb7bz@xTeZ%Jl^7%*$Hgd1j z*j3^3cu~f_6!}W{Qsl9e%z%7t0eJv$KR!Q! z@_{^)gm5yA2qZ~F(g}&kl#E@LrjyjA$@s}{2|k6Y#+QOe0MWZ>6G2*=3Uyt)nC4l G{r(S9Brwtd literal 0 HcmV?d00001 diff --git a/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_plain.dat b/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_plain.dat new file mode 100644 index 0000000000000000000000000000000000000000..f3cf369efff774700b109b89752429a4cde4615c GIT binary patch literal 859 zcmbVKL2kk@5Cp_ida9Jrio}SY&|71BBb?ZA~6oC+h z)9!kAv@_$~vW&@>{?8_NQK0?g83SB@mDtb%m~9%tvqxb7bz@xTeZ%Jl^7%*$Hgd1j z*j3^3cu~f_6!}W{Qsl9e%z%7t0eJv$KR!Q! z@_{^)gm5yA2qZ~F(g}&kl#E@LrjyjA$@s}{2|k6Y#+QOe0MWZ>6G2*=3Uyt)nC4l G{r(S9Brwtd literal 0 HcmV?d00001 diff --git a/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_rescue.dat b/android/examples/provisioningclient/src/main/assets/oic_svr_db_client_rescue.dat new file mode 100644 index 0000000000000000000000000000000000000000..f3cf369efff774700b109b89752429a4cde4615c GIT binary patch literal 859 zcmbVKL2kk@5Cp_ida9Jrio}SY&|71BBb?ZA~6oC+h z)9!kAv@_$~vW&@>{?8_NQK0?g83SB@mDtb%m~9%tvqxb7bz@xTeZ%Jl^7%*$Hgd1j z*j3^3cu~f_6!}W{Qsl9e%z%7t0eJv$KR!Q! z@_{^)gm5yA2qZ~F(g}&kl#E@LrjyjA$@s}{2|k6Y#+QOe0MWZ>6G2*=3Uyt)nC4l G{r(S9Brwtd literal 0 HcmV?d00001 diff --git a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java index 820eddf..0686000 100644 --- a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java +++ b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java @@ -1,6 +1,8 @@ package org.iotivity.base.examples.provisioningclient; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -14,6 +16,10 @@ import android.util.Log; import android.view.Gravity; import android.widget.LinearLayout; import android.widget.TextView; +import android.view.Menu; +import android.view.MenuItem; +import android.os.Environment; +import android.widget.Toast; import org.iotivity.base.CredType; import org.iotivity.base.EncodingType; @@ -23,6 +29,7 @@ import org.iotivity.base.ModeType; import org.iotivity.base.OcException; import org.iotivity.base.OcPlatform; import org.iotivity.base.OcProvisioning; +import org.iotivity.base.MVJustWorksOptionMask; import org.iotivity.base.OcSecureResource; import org.iotivity.base.OicSecAcl; import org.iotivity.base.OicSecAce; @@ -38,6 +45,7 @@ import org.iotivity.base.ServiceType; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -45,6 +53,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import java.nio.channels.FileChannel; import org.iotivity.ca.OicCipher; import org.iotivity.base.OcConnectivityType; @@ -57,6 +66,8 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise private static final String TAG = "Provisioning Client: "; private static final int BUFFER_SIZE = 1024; private int credId=0; + private int verifyVal=1; + private String verifyNumber; int unownedDevCount = StringConstants.NUMBER_ZERO; OcProvisioning.PinCallbackListener pinCallbackListener = new OcProvisioning.PinCallbackListener() { @@ -93,6 +104,72 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise } }; + OcProvisioning.DisplayNumListener displayNumListener = new OcProvisioning.DisplayNumListener() { + @Override + public int displayNumListener(String verifyNum) { + Log.d(TAG, "Inside verifySecretListener "); + logMessage(TAG + "DisplayMutualVerifyNumListener verify Number = " + verifyNum); + verifyNumber = verifyNum; + return 0; + } + }; + + OcProvisioning.ConfirmNumListener confirmNumListener = new OcProvisioning.ConfirmNumListener() { + @Override + public int confirmNumListener() { + Log.d(TAG, "Inside confirmMutualVerifyNumListener "); + final String message = "Is number matches with " + verifyNumber; + final Object lock = new Object(); + runOnUiThread(new Runnable() { + @Override + public void run() { + + AlertDialog.Builder alertDialog = new AlertDialog.Builder(ProvisioningClient.this); + alertDialog.setTitle("Confirm Number"); + alertDialog.setMessage(message); + alertDialog.setCancelable(false); + alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + try { + synchronized (lock) { + verifyVal = 0; + lock.notifyAll(); + } + } catch (Exception e) { + Log.d(TAG, e + ""); + } + } + }); + alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + try { + synchronized (lock) { + lock.notifyAll(); + } + } catch (Exception e) { + Log.d(TAG, e + ""); + } + } + }).show(); + } + }); + synchronized (lock) { + try { + lock.wait(); + } catch (InterruptedException e) { + Log.d(TAG, e + ""); + } + } + Log.d(TAG, "VerifyVal after submit =" + verifyVal); + logMessage(TAG + " confirmMutualVerifyNumListener " + verifyVal); + return verifyVal; + } + }; + OcSecureResource.ProvisionAclListener provisionAclListener = new OcSecureResource.ProvisionAclListener() { @Override @@ -180,7 +257,9 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this); boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true); if (isFirstRun) { - copyCborFromAsset(); + copyCborFromAsset(StringConstants.OIC_CLIENT_CBOR_DB_FILE_PLAIN); + copyCborFromAsset(StringConstants.OIC_CLIENT_CBOR_DB_FILE_ENC); + copyCborFromAsset(StringConstants.OIC_CLIENT_CBOR_DB_FILE_RESCUE); SharedPreferences.Editor editor = wmbPreference.edit(); editor.putBoolean("FIRSTRUN", false); editor.commit(); @@ -196,6 +275,11 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise * configure OIC platform and call findResource */ private void initOICStack() { + byte [] key = {(byte)0xa5, (byte)0x84, (byte)0x99, (byte)0x8d, (byte)0x0d, (byte)0xbd, (byte)0xb1, (byte)0x54, + (byte)0xbb, (byte)0xc5, (byte)0x4f, (byte)0xed, (byte)0x86, (byte)0x9a, (byte)0x66, (byte)0x11, + (byte)0xa5, (byte)0x84, (byte)0x99, (byte)0x8d, (byte)0x0d, (byte)0xbd, (byte)0xb1, (byte)0x54, + (byte)0xbb, (byte)0xc5, (byte)0x4f, (byte)0xed, (byte)0x86, (byte)0x9a, (byte)0x66, (byte)0x11 + }; //create platform config PlatformConfig cfg = new PlatformConfig( this, @@ -203,22 +287,27 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise ModeType.CLIENT_SERVER, "0.0.0.0", // bind to all available interfaces 0, - QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_CBOR_DB_FILE); + QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_CBOR_DB_FILE_PLAIN, + filePath + StringConstants.OIC_CLIENT_CBOR_DB_FILE_ENC, + filePath + StringConstants.OIC_CLIENT_CBOR_DB_FILE_RESCUE, 256, key); OcPlatform.Configure(cfg); //Get deviceId - byte [] deviceIdBytes= OcPlatform.getDeviceId(); - String devId = new String(deviceIdBytes); - Log.d(TAG, "Get Device Id "+devId); + /*byte [] deviceIdBytes= OcPlatform.getDeviceId(); + String devId = new String(deviceIdBytes); + Log.d(TAG, "Get Device Id "+devId); //Set deviceId try { - String setId = "adminDeviceUuid1"; - OcPlatform.setDeviceId(setId.getBytes()); - Log.d(TAG, "Set Device Id done"); + String setId = "adminDeviceUuid1"; + OcPlatform.setDeviceId(setId.getBytes()); + Log.d(TAG, "Set Device Id done"); + setId = "adminDeviceUuid0"; + OcPlatform.setDeviceId(setId.getBytes()); + Log.d(TAG, "Set Device Id Reverted"); } catch (OcException e) { - Log.d(TAG, e.getMessage()); - } + Log.d(TAG, e.getMessage()); + }*/ try { /* @@ -234,6 +323,15 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise } Log.d(TAG, "Sql db directory exists at " + sqlDbPath); OcProvisioning.provisionInit(sqlDbPath + StringConstants.OIC_SQL_DB_FILE); + + try { + OcProvisioning.setMVJustWorksOptions(EnumSet.of(MVJustWorksOptionMask.DISPLAY_MUTUAL_VERIF_NUM, + MVJustWorksOptionMask.CONFIRM_MUTUAL_VERIF_NUM)); + OcProvisioning.setDisplayNumListener(displayNumListener); + OcProvisioning.setConfirmNumListener(confirmNumListener); + } catch (OcException e) { + e.printStackTrace(); + } } catch (OcException e) { logMessage(TAG + "provisionInit error: " + e.getMessage()); Log.e(TAG, e.getMessage()); @@ -412,19 +510,19 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise /** * Copy svr db CBOR dat file from assets folder to app data files dir */ - private void copyCborFromAsset() { + private void copyCborFromAsset(String filep) { InputStream inputStream = null; OutputStream outputStream = null; int length; byte[] buffer = new byte[BUFFER_SIZE]; try { - inputStream = getAssets().open(StringConstants.OIC_CLIENT_CBOR_DB_FILE); + inputStream = getAssets().open(filep); 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); + outputStream = new FileOutputStream(filePath + filep); while ((length = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, length); } @@ -435,7 +533,7 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise logMessage(TAG + "CBOR svr db file not found " + e.getMessage()); Log.e(TAG, e.getMessage()); } catch (IOException e) { - logMessage(TAG + StringConstants.OIC_CLIENT_CBOR_DB_FILE + " file copy failed"); + logMessage(TAG + filep + " file copy failed"); Log.e(TAG, e.getMessage()); } finally { if (inputStream != null) { @@ -796,6 +894,45 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_secure_provision_client, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + + if (id == R.id.export_dat) { + try { + File sd = Environment.getExternalStorageDirectory(); + File data = Environment.getDataDirectory(); + if (sd.canWrite()) { + String currentDBPath = "/data/data/" + getPackageName() + "/files/" + StringConstants.OIC_CLIENT_CBOR_DB_FILE_ENC; + + File currentDB = new File(currentDBPath); + File backupDB = new File(sd, StringConstants.OIC_CLIENT_CBOR_DB_FILE_ENC); + 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) { + Toast.makeText(ProvisioningClient.this, e.getMessage(), Toast.LENGTH_SHORT).show(); + } + + Toast.makeText(ProvisioningClient.this, StringConstants.OIC_CLIENT_CBOR_DB_FILE_ENC + " File export to sdcard", Toast.LENGTH_SHORT).show(); + return true; + } + return super.onOptionsItemSelected(item); + } + /** * to display on Server Message on Client screen */ diff --git a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java index 2ae1017..defe108 100644 --- a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java +++ b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java @@ -29,8 +29,10 @@ public interface StringConstants { public static final String DEFAULT_RECURRENCES_2 = "Weekly"; 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.dat"; - public static final String CRT_FILE = "rootca.crt"; + public static final String OIC_CLIENT_CBOR_DB_FILE_PLAIN = "oic_svr_db_client_plain.dat"; + public static final String OIC_CLIENT_CBOR_DB_FILE_ENC = "oic_svr_db_client_enc.dat"; + public static final String OIC_CLIENT_CBOR_DB_FILE_RESCUE = "oic_svr_db_client_rescue.dat"; + public static final String CRT_FILE = "rootca.crt"; public static final String MESSAGE = "message"; public static final String OIC_SQL_DB_FILE = "Pdm.db"; public static final int CREDENTIAL_TYPE=1; diff --git a/android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml b/android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml index dd57e4d..1a6a274 100644 --- a/android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml +++ b/android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml @@ -1,5 +1,7 @@ - + xmlns:tools="http://schemas.android.com/tools" tools:context=".ProvisioningClient"> + diff --git a/android/examples/settings.gradle b/android/examples/settings.gradle old mode 100755 new mode 100644 diff --git a/android/examples/simplebase/src/main/AndroidManifest.xml b/android/examples/simplebase/src/main/AndroidManifest.xml index 200aca6..54e157b 100644 --- a/android/examples/simplebase/src/main/AndroidManifest.xml +++ b/android/examples/simplebase/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ android:name="android.hardware.bluetooth_le" android:required="true" /> + diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java index 1d21865..21e727e 100644 --- a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java @@ -266,6 +266,7 @@ public class BluetoothFragment extends Fragment implements sb.append("Set Connect with : "); try { final String address = mBluetoothDevices.get(pos).getAddress(); + Common.setLeAddress(address); CaInterface.setAutoConnectionDevice(address); OcPlatform.OnResourceFoundListener resourceFoundListener = new OcPlatform.OnResourceFoundListener() { diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java index 4eef8a1..8382e4b 100644 --- a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java @@ -24,6 +24,7 @@ package org.iotivity.base.examples; import android.content.Context; import android.widget.Toast; +import android.util.Log; import org.iotivity.base.OcPlatform; import org.iotivity.base.ResourceProperty; @@ -39,6 +40,7 @@ import java.util.Locale; */ public class Common { + private static final String TAG = "OIC_SIMPLE_COMMON"; public static final int DATA_SIZE = 3000; public static String HOST = "coap+tcp://192.168.0.1:5683"; public static final String COAP_TCP = "coap+tcp://"; @@ -63,6 +65,8 @@ public class Common { public final static String MQ_DEFAULT_TOPIC_URI = "/oic/ps/cleanroom"; public final static String MQ_BROKER_URI = "/oic/ps"; + private static String mLeAddress = null; + public static String getDateCurrentTimeZone() { StringBuilder sb = new StringBuilder(); try { @@ -82,5 +86,17 @@ public class Common { public static void showToast(Context context, String msg) { Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); } + + public static void setLeAddress(String address) + { + Log.i(TAG, "setLeAddress : " + address.toString()); + mLeAddress = address; + } + + public static String getLeAddress() + { + Log.i(TAG, "getLeAddress : " + mLeAddress); + return mLeAddress; + } } diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java index 6778978..403a9f1 100644 --- a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java @@ -91,6 +91,7 @@ public class DrawerFragment extends Fragment { getString(R.string.title_message), getString(R.string.title_bluetooth), getString(R.string.title_cloud), + getString(R.string.title_keepalive), getString(R.string.title_template), })); mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/KeepAliveFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/KeepAliveFragment.java new file mode 100644 index 0000000..f26a8b9 --- /dev/null +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/KeepAliveFragment.java @@ -0,0 +1,480 @@ +/* + * ****************************************************************** + * + * Copyright 2017 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; + +import android.app.Activity; +import android.app.Fragment; +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.PowerManager; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcHeaderOption; +import org.iotivity.base.OcPlatform; +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.ca.CaInterface; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This class is for Keep Alive between the client and server (or Cloud). + * It can handle Keep Alive mechanism manually. + */ +public class KeepAliveFragment extends Fragment implements + OcResource.OnGetListener, CaInterface.OnConnectionManagerStateListener { + + private static final String TAG = "OIC_SIMPLE_KEEPALIVE"; + private final String EOL = System.getProperties().getProperty("line.separator"); + private final long MILLI_PER_SEC = 1000; + private final long ONE_MINUTE = 60 * MILLI_PER_SEC; + private final long MARGIN_SEC = 10; + private final int KEEPALIVE_MSG = 1; + private final int TIMER_MSG = 2; + private final int OC_STACK_OK = 0; + private final int OC_STACK_RESOURCE_CHANGED = 4; + + private Activity mActivity; + private Context mContext; + private PowerManager.WakeLock mWakeLock; + + private TextView mIntervalView; + private TextView mRemainView; + private TextView mStatusView; + + private TextView mActionLog; + private TextView mResultLog; + + private Button mDiscoveryButton; + private Button mFindButton; + private Button mSendButton; + + private boolean isShowTimer = true; + + private long mStartTime = 0; + private long mEndTime = 0; + private long mRemainTime = -1; + + private int mInterval[] = {2, 4, 8}; + private int mIndex = 0; + + private String mHost = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mActivity = getActivity(); + mContext = mActivity.getBaseContext(); + + initOcPlatform(ModeType.CLIENT); + CaInterface.startManagerService(mContext, this); + + PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); + mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + } + + @Override + public void onDestroy() { + super.onDestroy(); + CaInterface.stopManagerService(); + } + + + // [[ Discovery + View.OnClickListener discoveryButtonListener() { + return new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.i(TAG, "discoveryButtonListener"); + + try { + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY, + EnumSet.of(OcConnectivityType.CT_ADAPTER_IP), + resourceFoundListener, QualityOfService.LOW); + } catch (OcException e) { + e.printStackTrace(); + } + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mActionLog.setText("[Action Log]" + EOL); + mActionLog.append("Discovery Click" + EOL); + + mResultLog.setText("[Result Log]" + EOL); + mResultLog.append("Start Time : "); + mResultLog.append(Common.getDateCurrentTimeZone() + EOL); + mStartTime = System.currentTimeMillis(); + + resetInterval(); + } + }); + } + }; + } + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource ocResource) { + synchronized (mActivity) { + final String resourceUri = ocResource.getUri(); + Log.i(TAG, "onResourceFound : " + resourceUri); + + if (resourceUri.contains(Common.RESOURCE_URI) + && ocResource.getConnectivityTypeSet().contains(OcConnectivityType.CT_ADAPTER_TCP)) { + + mHost = ocResource.getHost(); + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mEndTime = System.currentTimeMillis(); + double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC; + mResultLog.append("Discovery Time : " + + String.format("%.3f", flightTime) + "sec" + EOL); + } + }); + + sendGetToFoundResource(ocResource); + } + } + } + + @Override + public void onFindResourceFailed(Throwable throwable, String uri) { + synchronized (mActivity) { + Log.i(TAG, "findResource request has failed"); + Log.e(TAG, throwable.toString()); + } + } + }; + // ]] Discovery + + + // [[ Find KeepAlive Resource + View.OnClickListener findButtonListener() { + return new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.i(TAG, "findButtonListener"); + + try { + OcPlatform.findKeepAliveResource(mHost, pingResourceFoundListener); + } catch (OcException e) { + e.printStackTrace(); + } + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mActionLog.setText("[Action Log]" + EOL); + mActionLog.append("Find Ping" + EOL); + + resetInterval(); + } + }); + } + }; + } + + OcPlatform.KeepAliveListener pingResourceFoundListener = + new OcPlatform.KeepAliveListener() { + @Override + public void onKeepAliveListener(OcRepresentation ocRepresentation, + final int result) { + synchronized (mActivity) { + Log.i(TAG, "onKeepAliveListener : " + result); + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + if (OC_STACK_OK == result || OC_STACK_RESOURCE_CHANGED == result) { + mSendButton.setEnabled(true); + } + + mResultLog.append("Ping Resource Found Result : " + result + EOL); + } + }); + + } + } + }; + // ]] Find KeepAlive Resource + + + // [[ Send KeepAlive Request + View.OnLongClickListener sendButtonLongListener() { + return new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + Log.i(TAG, "sendButtonLongListener"); + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mActionLog.setText("[Action Log]" + EOL); + mActionLog.append("Send Interval" + EOL); + } + }); + + sendPing(true); + + return true; + } + }; + } + + View.OnClickListener sendButtonListener() { + return new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.i(TAG, "sendButtonListener"); + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mActionLog.setText("[Action Log]" + EOL); + mActionLog.append("Send Ping" + EOL); + } + }); + + mSendButton.setEnabled(false); + sendPing(false); + } + }; + } + + private void sendPing(boolean updateInterval) { + if (updateInterval) { + mResultLog.append("Send Keep Alive Interval with {2, 4, 8}" + EOL); + } else { + mResultLog.append("Send Keep Alive Request with " + mInterval[mIndex] + "min" + EOL); + } + + try { + OcRepresentation rep = new OcRepresentation(); + rep.setValue("in", mInterval[mIndex]); + if (updateInterval) { + rep.setValue("inarray", mInterval); + } + OcPlatform.sendKeepAliveRequest(mHost, rep, keepAliveListener); + } catch (OcException e) { + e.printStackTrace(); + } + mWakeLock.acquire(ONE_MINUTE); + + if (!updateInterval) { + if (isShowTimer) { + mRemainTime = mInterval[mIndex] * ONE_MINUTE / MILLI_PER_SEC - MARGIN_SEC; + showTimer(); + } else { + Message msg = new Message(); + msg.what = KEEPALIVE_MSG; + mHandler.sendMessageDelayed(msg, mInterval[mIndex] * ONE_MINUTE); + } + + if (mInterval.length - 1 > mIndex) { + mIndex++; + } + } + } + + OcPlatform.KeepAliveListener keepAliveListener = + new OcPlatform.KeepAliveListener() { + @Override + public void onKeepAliveListener(OcRepresentation ocRepresentation, + final int result) { + synchronized (mActivity) { + Log.i(TAG, "onKeepAliveListener : " + result); + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + if (OC_STACK_OK != result && OC_STACK_RESOURCE_CHANGED != result) { + resetInterval(); + } + + mResultLog.append("Keep Alive Request Result : " + result + EOL); + } + }); + } + } + }; + + private void showTimer() { + mRemainView.setText("Remain Time : " + mRemainTime + "sec"); + + if (mRemainTime > 0) { + Message msg = new Message(); + msg.what = TIMER_MSG; + mHandler.sendMessageDelayed(msg, MILLI_PER_SEC); + } else if (mRemainTime == 0) { + sendPing(false); + return; + } + + mRemainTime--; + } + + private Handler mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case KEEPALIVE_MSG: + sendPing(false); + break; + case TIMER_MSG: + showTimer(); + break; + default: + return; + } + } + }; + // ]] Send KeepAlive Request + + + // [[ State Changed + @Override + public void onAdapterStateChanged(OcConnectivityType ocConnectivityType, boolean b) { + Log.i(TAG, "onAdapterStateChanged"); + } + + @Override + public void onConnectionStateChanged(OcConnectivityType type, + String address, final boolean connected) { + Log.i(TAG, "onConnectionStateChanged address: " + address); + + if (OcConnectivityType.CT_ADAPTER_TCP == type) { + final String msg = getString(R.string.action_onconnectionstatechanged) + connected; + + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mStatusView.setText("TCP Connected : " + connected); + mFindButton.setEnabled(connected); + mResultLog.append(msg + EOL); + + if (!connected) { + resetInterval(); + } + } + }); + } + } + // ]] State Changed + + + // [[ Get + void sendGetToFoundResource(final OcResource ocResource) { + try { + Log.i(TAG, "sendGetToFoundResource"); + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mResultLog.append("Send get to : " + ocResource.getHost() + EOL); + } + }); + + Map queryParameters = new HashMap(); + queryParameters.put(Common.GET_COMMAND, Common.STATE_GET); + ocResource.get(queryParameters, this, QualityOfService.LOW); + + } catch (OcException e) { + e.printStackTrace(); + } + } + + @Override + public void onGetCompleted(List list, OcRepresentation ocRepresentation) { + Log.i(TAG, "onGetCompleted"); + } + + @Override + public void onGetFailed(Throwable throwable) { + Log.i(TAG, "onGetFailed"); + } + // ]] Get + + private void resetInterval() { + mHandler.removeMessages(TIMER_MSG); + mRemainView.setText("Remain Time : -"); + mSendButton.setEnabled(false); + mIndex = 0; + mRemainTime = -1; + } + + private void initOcPlatform(ModeType type) { + PlatformConfig cfg = new PlatformConfig(mActivity, mContext, + ServiceType.IN_PROC, + type, + Common.IP_ADDRESS, + Common.IP_PORT, + QualityOfService.LOW); + OcPlatform.Configure(cfg); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_keepalive, container, false); + + mIntervalView = (TextView) rootView.findViewById(R.id.interval_view); + mIntervalView.setText("Interval : {2, 4, 8}"); + mRemainView = (TextView) rootView.findViewById(R.id.remain_view); + mStatusView = (TextView) rootView.findViewById(R.id.status_view); + + mActionLog = (TextView) rootView.findViewById(R.id.action_log_view); + mResultLog = (TextView) rootView.findViewById(R.id.result_log_view); + + mDiscoveryButton = (Button) rootView.findViewById(R.id.discovery_button); + mFindButton = (Button) rootView.findViewById(R.id.find_button); + mSendButton = (Button) rootView.findViewById(R.id.send_button); + + mDiscoveryButton.setOnClickListener(discoveryButtonListener()); + mFindButton.setOnClickListener(findButtonListener()); + mSendButton.setOnClickListener(sendButtonListener()); + mSendButton.setOnLongClickListener(sendButtonLongListener()); + + + return rootView; + } +} diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java index 6c11b2e..cc6ed71 100644 --- a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java @@ -169,6 +169,17 @@ public class MessageFragment extends Fragment implements OcResource.OnGetListene OcPlatform.WELL_KNOWN_QUERY, EnumSet.of(OcConnectivityType.CT_ADAPTER_IP), resourceFoundListener, mQos); + } else if (OcConnectivityType.CT_ADAPTER_GATT_BTLE == connectivityType) { + if (null != Common.getLeAddress()) + { + OcPlatform.findResource("", + Common.getLeAddress() + OcPlatform.WELL_KNOWN_QUERY, + EnumSet.of(OcConnectivityType.CT_ADAPTER_GATT_BTLE), + resourceFoundListener, QualityOfService.LOW); + } else { + Common.showToast(mContext, "Please scan ble device"); + Log.e(TAG, "invalid ble device"); + } } else { OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY, diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java index 91360a6..00d1c69 100644 --- a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java +++ b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java @@ -71,6 +71,10 @@ public class SimpleBase extends Activity implements DrawerFragment.DrawerCallbac fragment = new CloudFragment(); break; case 3: + mTitle = getString(R.string.title_keepalive); + fragment = new KeepAliveFragment(); + break; + case 4: mTitle = getString(R.string.title_template); fragment = new TemplateFragment(); break; diff --git a/android/examples/simplebase/src/main/res/layout/fragment_keepalive.xml b/android/examples/simplebase/src/main/res/layout/fragment_keepalive.xml new file mode 100644 index 0000000..92b2a2b --- /dev/null +++ b/android/examples/simplebase/src/main/res/layout/fragment_keepalive.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + +