diff options
author | junkyu han <junkyu.han@samsung.com> | 2018-04-19 09:46:53 +0900 |
---|---|---|
committer | junkyu han <junkyu.han@samsung.com> | 2018-04-21 19:32:08 +0900 |
commit | 266f849895e6c4fe0b948f399a323cf901641c14 (patch) | |
tree | 83902f030e89530e4f620c0907497208b582cb84 | |
parent | 97cf0c8ae69768cb43168c232f7d1f97e7ce127d (diff) | |
download | ttsd-worker-system-266f849895e6c4fe0b948f399a323cf901641c14.tar.gz ttsd-worker-system-266f849895e6c4fe0b948f399a323cf901641c14.tar.bz2 ttsd-worker-system-266f849895e6c4fe0b948f399a323cf901641c14.zip |
Initial code from tizen-things-daemon
Change-Id: I21b4f2a1b4e5d17e04cd3413c49f98cef4ad5cfc
-rw-r--r-- | CMakeLists.txt | 33 | ||||
-rw-r--r-- | LICENSE.Flora | 206 | ||||
-rw-r--r-- | NOTICE | 3 | ||||
-rw-r--r-- | include/controller.h | 255 | ||||
-rw-r--r-- | include/log.h | 98 | ||||
-rw-r--r-- | packaging/ttsd-worker-system.spec | 65 | ||||
-rw-r--r-- | src/controller.c | 250 | ||||
-rw-r--r-- | ttsd-worker-system.manifest | 6 | ||||
-rw-r--r-- | ttsd-worker-system.xml | 11 |
9 files changed, 927 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9086d3f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(CMAKE_VERBOSE_MAKEFILE 0) +SET(SYSINFO ttsd-worker-system) + +INCLUDE(FindPkgConfig) +pkg_check_modules(SYSINFO_PKGS REQUIRED + capi-appfw-service-application + libtzplatform-config + libthings-service + capi-system-info +) + +FOREACH (flag ${SYSINFO_PKGS_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +FILE(GLOB SYSINFO_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/${SYSINFO}.xml ${CMAKE_BINARY_DIR}/${SYSINFO}.xml) + +ADD_EXECUTABLE(${SYSINFO} ${SYSINFO_SOURCE}) +TARGET_LINK_LIBRARIES(${SYSINFO} ${SYSINFO_PKGS_LDFLAGS} -lm) + +# Install +INSTALL(TARGETS ${SYSINFO} DESTINATION ${INSTALL_PKG_DIR}) +INSTALL(FILES ${CMAKE_BINARY_DIR}/${SYSINFO}.xml DESTINATION /usr/share/packages) diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..4a0af40 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + 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. + @@ -0,0 +1,3 @@ +Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1.1. +Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions. diff --git a/include/controller.h b/include/controller.h new file mode 100644 index 0000000..02ceec4 --- /dev/null +++ b/include/controller.h @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Contact: Junkyu Han <junkyu.han@samsung.com> + * + * Licensed under the Flora License, Version 1.1 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TTSD_WORKER_SYSTEM_CONTROLLER_H__ +#define __TTSD_WORKER_SYSTEM_CONTROLLER_H__ + +#define INFO_KEY_MAX 213 + +typedef struct __info_s { + char *key; + int type; +} info_s; + +typedef enum { + KEY_TYPE_INT = 0, + KEY_TYPE_BOOL = 1, + KEY_TYPE_STRING = 2, +} KEY_TYPE; + +info_s sys_info[INFO_KEY_MAX] = { + { "http://tizen.org/feature/account", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/account.sync", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/app_history", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/battery", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/camera", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/camera.back", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/camera.back.flash", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/camera.front", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/camera.front.flash", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/consumer_ir", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/contextual_trigger", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/database.encryption", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/download", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/fido.uaf", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/fmradio", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/graphics.acceleration", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/humanactivitymonitor", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/input.keyboard", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/input.keyboard.layout", KEY_TYPE_STRING }, + { "http://tizen.org/feature/input.rotating_bezel", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/iot.ocf", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/led", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location.batch", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location.geofence", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location.gps", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location.gps.satellite", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/location.wps", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/maps", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/media.audio_recording", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/media.image_capture", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/media.video_recording", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/microphone", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/multimedia.transcoder", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/multi_point_touch.pinch_zoom", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/multi_point_touch.point_count", KEY_TYPE_INT }, + { "http://tizen.org/feature/network.bluetooth", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.audio.call", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.audio.controller", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.audio.media", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.health", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.hid", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.le", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.opp", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.bluetooth.phonebook.client", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.ethernet", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.internet", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.mtp", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.net_proxy", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc.card_emulation", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc.card_emulation.hce", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc.p2p", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc.reserved_push", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.nfc.tag", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.push", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.secure_element", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.secure_element.ese", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.secure_element.uicc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.service_discovery.dnssd", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.service_discovery.ssdp", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.mms", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.cdma", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.edge", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.gprs", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.gsm", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.hsdpa", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.hspa", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.hsupa", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.lte", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.service.umts", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.sms", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.telephony.sms.cbs", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.tethering", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.tethering.bluetooth", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.tethering.usb", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.tethering.wifi", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.vpn", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.wifi", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.wifi.direct", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.wifi.direct.display", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.wifi.direct.service_discovery", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/network.wifi.tdls", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/oauth2", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.3dc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.atc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.etc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.ptc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.pvrtc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.texture_format.utc", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.version.1_1", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.version.2_0", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.version.3_0", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.version.3_1", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/opengles.version.3_2", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.api.version", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.core.cpu.arch", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.core.cpu.arch.armv6", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.cpu.arch.armv7", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.cpu.arch.x86", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.cpu.frequency", KEY_TYPE_INT }, + { "http://tizen.org/feature/platform.core.fpu.arch", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.core.fpu.arch.sse2", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.fpu.arch.sse3", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.fpu.arch.ssse3", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.fpu.arch.vfpv2", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.core.fpu.arch.vfpv3", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.native.api.version", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.native.osp_compatible", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/platform.version", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.version.name", KEY_TYPE_STRING }, + { "http://tizen.org/feature/platform.web.api.version", KEY_TYPE_STRING }, + { "http://tizen.org/feature/profile", KEY_TYPE_STRING }, + { "http://tizen.org/feature/screen", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.always_on.high_color", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.always_on.low_bit_color", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.auto_rotation", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.bpp", KEY_TYPE_INT }, + { "http://tizen.org/feature/screen.coordinate_system.size.large", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.coordinate_system.size.normal", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.dpi", KEY_TYPE_INT }, + { "http://tizen.org/feature/screen.height", KEY_TYPE_INT }, + { "http://tizen.org/feature/screen.output.hdmi", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.output.rca", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.shape.circle", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.shape.rectangle", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.all", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.large", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.240.400", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.320.320", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.320.480", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.360.480", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.480.800", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.540.960", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.600.1024", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.720.1280", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.size.normal.720.1280", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/screen.width", KEY_TYPE_INT }, + { "http://tizen.org/feature/sensor.accelerometer", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.accelerometer.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.activity_recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.barometer", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.barometer.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.geomagnetic_rotation_vector", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gesture_recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gravity", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gyroscope", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gyroscope_rotation_vector", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gyroscope.uncalibrated", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.gyroscope.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.heart_rate_monitor", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.heart_rate_monitor.led_green", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.heart_rate_monitor.led_ir", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.heart_rate_monitor.led_red", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.humidity", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.linear_acceleration", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.magnetometer", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.magnetometer.uncalibrated", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.magnetometer.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.pedometer", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.photometer", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.photometer.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.proximity", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.proximity.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.rotation_vector", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.significant_motion", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.sleep_monitor", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.stress_monitor", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.temperature", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.tiltmeter", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.tiltmeter.wakeup", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.ultraviolet", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sensor.wrist_up", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/shell.appwidget", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/sip.voip", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/speech.control", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/speech.recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/speech.synthesis", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/systemsetting", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/systemsetting.home_screen", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/systemsetting.incoming_call", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/systemsetting.lock_screen", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/systemsetting.notification_email", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/usb.accessory", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/usb.host", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.barcode_detection", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.barcode_generation", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.face_recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.image_recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.qrcode_generation", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/vision.qrcode_recognition", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/web.ime", KEY_TYPE_BOOL }, + { "http://tizen.org/feature/web.service", KEY_TYPE_BOOL }, + { "http://tizen.org/system/build.date", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.id", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.string", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.time", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.type", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.variant", KEY_TYPE_STRING }, + { "http://tizen.org/system/build.release", KEY_TYPE_STRING }, + { "http://tizen.org/system/manufacturer", KEY_TYPE_STRING }, + { "http://tizen.org/system/model_name", KEY_TYPE_STRING }, + { "http://tizen.org/system/platform.communication_processor", KEY_TYPE_STRING }, + { "http://tizen.org/system/platform.name", KEY_TYPE_STRING }, + { "http://tizen.org/system/platform.processor", KEY_TYPE_STRING }, + { "http://tizen.org/system/sound.media.volume.resolution.max", KEY_TYPE_INT }, + { "http://tizen.org/system/sound.notification.volume.resolution.max", KEY_TYPE_INT }, + { "http://tizen.org/system/sound.ringtone.volume.resolution.max", KEY_TYPE_INT }, + { "http://tizen.org/system/sound.system.volume.resolution.max", KEY_TYPE_INT }, + { "http://tizen.org/system/tizenid", KEY_TYPE_STRING }, +}; + +// { "http://tizen.org/feature/screen.size.normal.360.360", KEY_TYPE_BOOL }, /* Not work on RPI3 Image */ +// { "http://tizen.org/feature/opengles.texture_format", KEY_TYPE_STRING }, /* Not work on RPI3 Image */ +// { "http://tizen.org/feature/network.bluetooth.hid.device", KEY_TYPE_BOOL }, /* Not work on RPI3 Image */ + +#endif /* __TTSD_WORKER_SYSTEM_CONTROLLER_H__ */ diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..3a922c4 --- /dev/null +++ b/include/log.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Flora License, Version 1.1 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TTSD_WORKER_SYTEM_LOG_H__ +#define __TTSD_WORKER_SYTEM_LOG_H__ + +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TTSD_SYSTEM" + +#if !defined(_V) +#define _V(fmt, arg...) dlog_print(DLOG_VERBOSE, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg) +#endif + +#if !defined(_D) +#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg) +#endif + +#if !defined(_I) +#define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg) +#endif + +#if !defined(_W) +#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg) +#endif + +#if !defined(_E) +#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg) +#endif + +#define retvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + _E(fmt, ##arg); \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return val; \ + } \ +} while (0) + +#define retv_if(expr, val) do { \ + if (expr) { \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ +} while (0) + +#define retm_if(expr, fmt, arg...) do { \ + if (expr) { \ + _E(fmt, ##arg); \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) + +#define ret_if(expr) do { \ + if (expr) { \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) + +#define goto_if(expr, val) do { \ + if (expr) { \ + _E("(%s) -> goto", #expr); \ + goto val; \ + } \ +} while (0) + +#define break_if(expr) { \ + if (expr) { \ + _E("(%s) -> break", #expr); \ + break; \ + } \ +} + +#define continue_if(expr) { \ + if (expr) { \ + _E("(%s) -> continue", #expr); \ + continue; \ + } \ +} + +#endif /* __TTSD_WORKER_SYSTEM_LOG_H__ */ diff --git a/packaging/ttsd-worker-system.spec b/packaging/ttsd-worker-system.spec new file mode 100644 index 0000000..e49636e --- /dev/null +++ b/packaging/ttsd-worker-system.spec @@ -0,0 +1,65 @@ +Name: ttsd-worker-system +%define alias %{name} +Summary: Tizen Things Service System Information +Group: Applications/Core Applications +Version: 0.0.1 +Release: 1 +License: Flora-1.1 +Provides: %{name} = %{version}-%{release} +Source0: %{name}-%{version}.tar.gz + +BuildRequires: cmake +BuildRequires: hash-signer + +BuildRequires: pkgconfig(capi-appfw-service-application) +BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(libthings-service) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(dlog) + +%description +Tizen Things Service System Information + +%prep +%setup -q + +%build + +%ifarch %{arm} +export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET" +export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_TARGET" +export FFLAGS="$FFLAGS -DTIZEN_BUILD_TARGET" +%else +export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR" +export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR" +export FFLAGS="$FFLAGS -DTIZEN_BUILD_EMULATOR" +%endif + +%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias} +%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES} + +cmake . -DINSTALL_PKG_DIR=%{_pkg_dir}/bin \ + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%define tizen_sign 1 +%define tizen_sign_base %{_pkg_dir} +%define tizen_sign_level platform +%define tizen_author_sign 1 +%define tizen_dist_sign 1 + +%post +/sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%manifest %{name}.manifest +%license LICENSE.Flora NOTICE +%defattr(-,root,root,-) +%{_pkg_dir}/* +%{_sys_packages_dir}/%{alias}.xml diff --git a/src/controller.c b/src/controller.c new file mode 100644 index 0000000..a47c66b --- /dev/null +++ b/src/controller.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Contact: Junkyu Han <junkyu.han@samsung.com> + * + * Licensed under the Flora License, Version 1.1 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 <service_app.h> +#include <system_info.h> +#include <stdlib.h> +#include <stdio.h> +#include <ttsd-worker-lib.h> + +#include "log.h" +#include "controller.h" + +typedef struct app_data_s { + FILE *file; +} app_data; + +static int __get_system_info(void *data); +static int __get_system_info_int(char *key, FILE *file); +static int __get_system_info_bool(char *key, FILE *file); +static int __get_system_info_string(char *key, FILE *file); +static int __initialize_file_logging(FILE **file); +static void __finalize_file_logging(FILE **file); +static char *__check_error_reason(int ret, char *reason); + +static void __make_and_send_data(void) +{ + _D("Make & Send Data"); + int ret = -1; + char *data = "jjoggoba is a bad boy"; + + ret = ttsd_worker_submit_report(data); + if (ret < 0) + _E("Failed send operation"); +} + +static bool service_app_create(void *data) +{ + __make_and_send_data(); + + return true; +} + +static void service_app_terminate(void *data) +{ + app_data *ad = (app_data *)data; + + free(ad); +} + +static void service_app_control(app_control_h app_control, void *data) +{ + /* APP_CONTROL */ + app_data *ad = data; + + if (__get_system_info(ad) < 0) { + _E("Failed to get system information"); + } + + service_app_exit(); +} + +static void service_app_lang_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LANGUAGE_CHANGED*/ +} + +static void service_app_region_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_REGION_FORMAT_CHANGED*/ +} + +static void service_app_low_battery(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_BATTERY*/ +} + +static void service_app_low_memory(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_MEMORY*/ +} + +int main(int argc, char* argv[]) +{ + app_data *ad = NULL; + int ret = 0; + service_app_lifecycle_callback_s event_callback; + app_event_handler_h handlers[5] = {NULL, }; + + ad = calloc(1, sizeof(app_data)); + retv_if(!ad, -1); + + event_callback.create = service_app_create; + event_callback.terminate = service_app_terminate; + event_callback.app_control = service_app_control; + + service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad); + + ret = service_app_main(argc, argv, &event_callback, ad); + + return ret; +} + +static int __get_system_info_int(char *key, FILE *file) +{ + int ret = SYSTEM_INFO_ERROR_NONE; + char *reason = NULL; + int val = -1; + + ret = system_info_get_platform_int(key, &val); + if (ret != SYSTEM_INFO_ERROR_NONE) { + _E("Failed to get System Info [%s] -- [%s]", key, __check_error_reason(ret, reason)); + return -1; + } else { + _D("[%s] : [%d]", key, val); + fprintf(file, "[%s] : [%d]\n", key, val); + } + + return 0; +} + +static int __get_system_info_bool(char *key, FILE *file) +{ + int ret = SYSTEM_INFO_ERROR_NONE; + char *reason = NULL; + bool val = false; + + ret = system_info_get_platform_bool(key, &val); + if (ret != SYSTEM_INFO_ERROR_NONE) { + _E("Failed to get System Info [%s] -- [%s]", key, __check_error_reason(ret, reason)); + return -1; + } else { + _D("[%s] : [%s]", key, val ? "TRUE" : "FALSE"); + fprintf(file, "[%s] : [%s]\n", key, val ? "TRUE" : "FALSE"); + } + + return 0; +} + +static int __get_system_info_string(char *key, FILE *file) +{ + int ret = SYSTEM_INFO_ERROR_NONE; + char *reason = NULL; + char *val = NULL; + + ret = system_info_get_platform_string(key, &val); + if (ret != SYSTEM_INFO_ERROR_NONE) { + _E("Failed to get System Info [%s] -- [%s]", key, __check_error_reason(ret, reason)); + } else { + _D("[%s] : [%s]", key, val); + fprintf(file, "[%s] : [%s]\n", key, val); + } + + free(val); + + return 0; +} + +static int __initialize_file_logging(FILE **file) +{ + if((*(file) = fopen("/tmp/info.txt", "w+")) == NULL) { + _E("Failed to open log file"); + return -1; + } + + return 0; +} + +static void __finalize_file_logging(FILE **file) +{ + fclose(*(file)); +} + +static int __get_system_info(void *data) +{ + _D("Get SYSTEM INFORMATION"); + int i; + int ret = -1; + app_data *ad = data; + + if (__initialize_file_logging(&(ad->file)) < 0) + return -1; + + for (i = 0; i < INFO_KEY_MAX && sys_info[i].key != NULL; i++) { + switch (sys_info[i].type) + { + case KEY_TYPE_INT: + ret = __get_system_info_int(sys_info[i].key, ad->file); + break; + case KEY_TYPE_BOOL: + ret = __get_system_info_bool(sys_info[i].key, ad->file); + break; + case KEY_TYPE_STRING: + ret = __get_system_info_string(sys_info[i].key, ad->file); + break; + default: + _E("Strange key type"); + break; + } + + if (ret < 0) + break; + } + + __finalize_file_logging(&(ad->file)); + + return 0; +} + +static char *__check_error_reason(int ret, char *reason) +{ + switch (ret) + { + case SYSTEM_INFO_ERROR_INVALID_PARAMETER: + reason = "Invalid Parameter"; + break; + case SYSTEM_INFO_ERROR_IO_ERROR: + reason = "IO Error"; + break; + case SYSTEM_INFO_ERROR_PERMISSION_DENIED: + reason = "Permission Denied"; + break; + case SYSTEM_INFO_ERROR_NOT_SUPPORTED: + reason = "Not Supported"; + break; + default: + reason = "Failure caused some other reaseon"; + break; + } + + return reason; +} + diff --git a/ttsd-worker-system.manifest b/ttsd-worker-system.manifest new file mode 100644 index 0000000..ca37499 --- /dev/null +++ b/ttsd-worker-system.manifest @@ -0,0 +1,6 @@ +<manifest> + <request> + <domain name="_" /> + </request> +</manifest> + diff --git a/ttsd-worker-system.xml b/ttsd-worker-system.xml new file mode 100644 index 0000000..e4dcb5c --- /dev/null +++ b/ttsd-worker-system.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="ttsd-worker-system" version="0.0.1"> + <profile name="mobile"/> + <author email="junkyu.han@samsung.com" href="www.samsung.com">Junkyu Han</author> + <service-application appid="ttsd-worker-system" exec="/usr/apps/ttsd-worker-system/bin/ttsd-worker-system" multiple="false" nodisplay="true" taskmanage="false" type="capp"> + <label>ttsd-worker-system</label> + </service-application> + <privileges> + </privileges> +</manifest> + |