summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-09-08 21:39:57 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-09-08 21:39:57 +0900
commit5cea387de7e517476d31b915642c232347ca7a3d (patch)
tree2a8e04371cbdea4e94501158b8c5bc057cb1105a
parente83d82d8fb86b69691855e362056332354b29afa (diff)
downloadstarter-5cea387de7e517476d31b915642c232347ca7a3d.tar.gz
starter-5cea387de7e517476d31b915642c232347ca7a3d.tar.bz2
starter-5cea387de7e517476d31b915642c232347ca7a3d.zip
-rw-r--r--.gitattributes4
-rwxr-xr-xCMakeLists.txt155
-rwxr-xr-xLICENSE255
-rwxr-xr-xNOTICE2
-rwxr-xr-xboot-mgr/CMakeLists.txt42
-rwxr-xr-xboot-mgr/starter.c273
-rwxr-xr-xdebian/changelog479
-rwxr-xr-xdebian/compat1
-rwxr-xr-xdebian/control19
-rwxr-xr-xdebian/rules112
-rwxr-xr-xdebian/starter.install.in4
-rwxr-xr-xdebian/starter.postinst12
-rwxr-xr-xinclude/clock-mgr.h26
-rwxr-xr-xinclude/dbus-util.h33
-rwxr-xr-xinclude/dbus-util_w.h34
-rwxr-xr-xinclude/direct-access.h33
-rwxr-xr-xinclude/hourly_alert.h24
-rwxr-xr-xinclude/hw_key.h (renamed from lock-mgr/include/lock-daemon.h)14
-rwxr-xr-xinclude/hw_key_w.h20
-rwxr-xr-xinclude/lock-daemon-lite.h25
-rwxr-xr-xinclude/lock-daemon.h25
-rwxr-xr-xinclude/lockd-bt.h28
-rwxr-xr-xinclude/lockd-debug.h85
-rwxr-xr-xinclude/lockd-process-mgr.h52
-rwxr-xr-xinclude/lockd-window-mgr.h (renamed from lock-mgr/include/lockd-window-mgr.h)23
-rwxr-xr-xinclude/menu_daemon.h48
-rw-r--r--include/pkg_event.h44
-rwxr-xr-xinclude/starter-util.h34
-rwxr-xr-xinclude/starter-vconf.h8
-rw-r--r--[-rwxr-xr-x]include/starter.h (renamed from boot-mgr/starter.h)9
-rwxr-xr-xinclude/starter_w.h62
-rwxr-xr-xinclude/util.h116
-rw-r--r--[-rwxr-xr-x]include/x11.h (renamed from boot-mgr/x11.h)7
-rwxr-xr-xlock-mgr/CMakeLists.txt48
-rwxr-xr-xlock-mgr/include/lockd-debug.h62
-rwxr-xr-xlock-mgr/include/lockd-process-mgr.h29
-rwxr-xr-xlock-mgr/src/lock-daemon.c272
-rwxr-xr-xlock-mgr/src/lockd-process-mgr.c146
-rwxr-xr-xlock-mgr/src/lockd-window-mgr.c270
-rwxr-xr-xpackaging/starter.service14
-rwxr-xr-xpackaging/starter.spec136
-rwxr-xr-xpackaging/wait-lock.service14
-rwxr-xr-xpo/CMakeLists.txt24
-rw-r--r--po/az.po6
-rw-r--r--po/bg.po6
-rw-r--r--po/ca.po6
-rw-r--r--po/cs.po6
-rw-r--r--po/da.po6
-rw-r--r--po/de.po6
-rw-r--r--po/el_GR.po6
-rw-r--r--po/en.po6
-rw-r--r--po/en_US.po6
-rw-r--r--po/es_ES.po6
-rw-r--r--po/es_US.po6
-rw-r--r--po/et.po6
-rw-r--r--po/eu.po6
-rw-r--r--po/fi.po6
-rw-r--r--po/fr.po6
-rw-r--r--po/fr_CA.po6
-rw-r--r--po/gl.po6
-rw-r--r--po/hr.po6
-rw-r--r--po/hu.po6
-rw-r--r--po/hy.po6
-rw-r--r--po/is.po6
-rw-r--r--po/it_IT.po6
-rw-r--r--po/ka.po6
-rw-r--r--po/kk.po6
-rw-r--r--po/ko_KR.po6
-rw-r--r--po/lt.po6
-rw-r--r--po/lv.po6
-rw-r--r--po/mn_MN.po6
-rw-r--r--po/nb.po6
-rw-r--r--po/nl.po6
-rw-r--r--po/pl.po6
-rw-r--r--po/pt_BR.po6
-rw-r--r--po/pt_PT.po6
-rw-r--r--po/ro.po6
-rw-r--r--po/ru_RU.po6
-rw-r--r--po/sk.po6
-rw-r--r--po/sl.po6
-rw-r--r--po/sr.po6
-rw-r--r--po/sv.po6
-rw-r--r--po/tr_TR.po6
-rw-r--r--po/uk.po6
-rw-r--r--po/uz.po6
-rwxr-xr-xrd3starter17
-rw-r--r--[-rwxr-xr-x]rd4starter12
-rwxr-xr-xsrc/clock-mgr.c807
-rwxr-xr-xsrc/dbus-util.c225
-rwxr-xr-xsrc/dbus-util_w.c745
-rwxr-xr-xsrc/direct-access.c476
-rwxr-xr-xsrc/hourly_alert.c273
-rwxr-xr-xsrc/hw_key.c1600
-rwxr-xr-xsrc/hw_key_w.c1480
-rwxr-xr-xsrc/lock-daemon-lite.c2185
-rwxr-xr-xsrc/lock-daemon.c2125
-rwxr-xr-xsrc/lockd-bt.c227
-rwxr-xr-xsrc/lockd-debug.c (renamed from lock-mgr/src/lockd-debug.c)16
-rwxr-xr-xsrc/lockd-process-mgr.c414
-rwxr-xr-xsrc/lockd-window-mgr.c807
-rwxr-xr-xsrc/menu_daemon.c813
-rwxr-xr-xsrc/pkg_event.c310
-rwxr-xr-xsrc/starter.c594
-rwxr-xr-xsrc/starter_w.c668
-rwxr-xr-xsrc/x11.c (renamed from boot-mgr/x11.c)33
-rw-r--r--[-rwxr-xr-x]starter3
-rwxr-xr-xstarter.init.sh2
-rwxr-xr-xstarter.manifest36
-rwxr-xr-xtest/get_entry.c92
-rwxr-xr-xtest/get_theme.c59
-rwxr-xr-xtest/set_theme.c65
111 files changed, 15555 insertions, 1904 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..64322df
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+.gitattributes export-ignore
+.gitignore export-ignore
+debian export-ignore
+#packaging export-ignore
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd66ffc..141f44a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,19 +1,157 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(starter C)
-SET(VENDOR "org.tizen")
+SET(VENDOR "samsung")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "com.${VENDOR}.${PACKAGE}")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(BINDIR "${PREFIX}/bin")
SET(DATADIR "${PREFIX}/share")
-SET(LOCALEDIR "${DATADIR}/locale")
+SET(RESDIR "${PREFIX}/res")
+SET(LOCALEDIR "${PREFIX}/share/locale")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-SET(LOCK_MGR lock-mgr)
-SET(BOOT_MGR boot-mgr)
+IF("${STARTER_FEATURE_LITE}" STREQUAL "ENABLE")
+MESSAGE("######################################## LITE")
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ ail
+ aul
+ capi-system-media-key
+ db-util
+ dlog
+ ecore
+ ecore-evas
+ ecore-input
+ ecore-x
+ edbus
+ eet
+ eina
+ elementary
+ evas
+ syspopup-caller
+ utilX
+ vconf
+ x11
+ xcomposite
+ xext
+ appcore-efl
+ glib-2.0
+ ui-gadget-1
+ bundle
+ capi-appfw-application
+ capi-appfw-app-manager
+ capi-network-bluetooth
+ feedback
+ alarm-service
+ pkgmgr-info
+ deviced
+ edbus
+ dbus-1
+ dbus-glib-1
+ tts
+ capi-message-port
+)
+ELSE()
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ ail
+ aul
+ capi-system-media-key
+ db-util
+ dlog
+ ecore
+ ecore-evas
+ ecore-input
+ ecore-x
+ edbus
+ eet
+ eina
+ elementary
+ evas
+ syspopup-caller
+ utilX
+ vconf
+ x11
+ xcomposite
+ xext
+ appcore-efl
+ glib-2.0
+ ui-gadget-1
+ bundle
+ capi-appfw-application
+ capi-appfw-app-manager
+ capi-network-bluetooth
+ feedback
+ alarm-service
+ pkgmgr-info
+ deviced
+ edbus
+ dbus-1
+ dbus-glib-1
+)
+ENDIF()
-ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${LOCK_MGR})
-ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${BOOT_MGR})
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS_PROFILING "-O0 -g -pg -fPIE")
+SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -std=c++0x -g -pg -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++0x -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -fPIE")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g -fPIE")
+SET(CMAKE_C_FLAGS_CCOV "-O2 -g --coverage -fPIE")
+SET(CMAKE_CXX_FLAGS_CCOV "-O2 -std=c++0x -g --coverage -fPIE")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${PREFIX}/lib -pie")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-D_GNU_SOURCE")
+
+IF("${STARTER_FEATURE_LITE}" STREQUAL "ENABLE")
+MESSAGE("######################################## LITE")
+ADD_EXECUTABLE(${PROJECT_NAME}
+ src/hw_key.c
+ src/pkg_event.c
+ src/menu_daemon.c
+ src/starter.c
+ src/x11.c
+ src/lock-daemon-lite.c
+ src/lockd-debug.c
+ src/lockd-process-mgr.c
+ src/lockd-window-mgr.c
+ src/lockd-bt.c
+ src/direct-access.c
+ src/dbus-util.c
+)
+ELSE()
+ADD_EXECUTABLE(${PROJECT_NAME}
+ src/starter_w.c
+ src/hw_key_w.c
+ src/hourly_alert.c
+ src/dbus-util_w.c
+ src/clock-mgr.c
+)
+ENDIF()
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
INSTALL(FILES ${CMAKE_SOURCE_DIR}/rd4starter DESTINATION /etc/init.d
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
@@ -21,7 +159,6 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/rd4starter DESTINATION /etc/init.d
INSTALL(FILES ${CMAKE_SOURCE_DIR}/rd3starter DESTINATION /etc/init.d
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/starter.init.sh DESTINATION /etc/opt/init
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
#INSTALL to /etc/init.d
+
+ADD_SUBDIRECTORY(po)
diff --git a/LICENSE b/LICENSE
index 7ccb5b5..a06208b 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,75 +1,204 @@
-Flora License
-
-Version 1.0, May, 2012
-
-http://www.tizenopensource.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 Compatibility Definition Document and passes the Compatibility Test Suite 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.
-
-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 (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ 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.
+
+ 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,
+ 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 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 in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) 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
+
+ (d) 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.
+
+ 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 Apache License to your work.
+
+ To apply the Apache 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.0 (the "License");
+ 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.tizenopensource.org/license
+ 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.
+
diff --git a/NOTICE b/NOTICE
index ded3804..b2e5019 100755
--- a/NOTICE
+++ b/NOTICE
@@ -1 +1 @@
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. \ No newline at end of file
+Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
diff --git a/boot-mgr/CMakeLists.txt b/boot-mgr/CMakeLists.txt
deleted file mode 100755
index 6dfcd8b..0000000
--- a/boot-mgr/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(starter C)
-
-SET(SRCS starter.c x11.c)
-
-SET(CMAKE_BINARY_LOCK_DAEMON_DIR "${CMAKE_BINARY_DIR}/${LOCK_MGR}")
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${LOCK_MGR}/include)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED elementary vconf x11 heynoti aul ecore evas ecore-evas x11 dlog ecore-x utilX ecore-input)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${PREFIX}/lib -pie")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
- MESSAGE("add -DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
-ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
-ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} -L${CMAKE_BINARY_LOCK_DAEMON_DIR} -llock-daemon ${pkgs_LDFLAGS})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
diff --git a/boot-mgr/starter.c b/boot-mgr/starter.c
deleted file mode 100755
index 98148a9..0000000
--- a/boot-mgr/starter.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 <Elementary.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <poll.h>
-
-#include <aul.h>
-#include <vconf.h>
-#include <heynoti.h>
-#include <signal.h>
-
-
-#include "starter.h"
-#include "x11.h"
-#include "lock-daemon.h"
-#include "lockd-debug.h"
-
-#define DEFAULT_THEME "tizen"
-
-#define HIB_CAPTURING "/opt/etc/.hib_capturing"
-#define STR_STARTER_READY "/tmp/hibernation/starter_ready"
-
-static void lock_menu_screen(void)
-{
- vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 0);
-}
-
-static void unlock_menu_screen(void)
-{
- int r;
- int show_menu;
-
- show_menu = 0;
- r = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &show_menu);
- if (r || !show_menu) {
- vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 1);
- }
-}
-
-static void _set_elm_theme(void)
-{
- char *vstr;
- char *theme;
- Elm_Theme *th = NULL;
- vstr = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
- if (vstr == NULL)
- theme = DEFAULT_THEME;
- else
- theme = vstr;
-
- th = elm_theme_new();
- _DBG("theme vconf[%s]\n set[%s]\n", vstr, theme);
- elm_theme_set(th, theme);
-
- if (vstr)
- free(vstr);
-}
-static int _launch_pwlock(void)
-{
- int r;
-
- _DBG("%s", __func__);
-
- r = aul_launch_app("org.tizen.pwlock", NULL);
- if (r < 0) {
- _ERR("PWLock launch error: error(%d)", r);
- if (r == AUL_R_ETIMEOUT) {
- _DBG("Launch pwlock is failed for AUL_R_ETIMEOUT, again launch pwlock");
- r = aul_launch_app("org.tizen.pwlock", NULL);
- if (r < 0) {
- _ERR("2'nd PWLock launch error: error(%d)", r);
- return -1;
- } else {
- _DBG("Launch pwlock");
- return 0;
- }
- } else {
- return -1;
- }
- } else {
- _DBG("Launch pwlock");
- return 0;
- }
-
-}
-
-static void hib_leave(void *data)
-{
- struct appdata *ad = data;
- if (ad == NULL) {
- fprintf(stderr, "Invalid argument: appdata is NULL\n");
- return;
- }
-
- _DBG("%s", __func__);
- _set_elm_theme();
- start_lock_daemon();
- if (_launch_pwlock() < 0) {
- _ERR("launch pwlock error");
- }
-}
-
-static int add_noti(struct appdata *ad)
-{
- int fd;
- int r;
- _DBG("%s %d\n", __func__, __LINE__);
-
- if (ad == NULL) {
- fprintf(stderr, "Invalid argument: appdata is NULL\n");
- return -1;
- }
-
- fd = heynoti_init();
- if (fd == -1) {
- _ERR("Noti init error");
- return -1;
- }
- ad->noti = fd;
-
- r = heynoti_subscribe(fd, "HIBERNATION_PRELEAVE", hib_leave, ad);
- if (r == -1) {
- _ERR("Noti subs error");
- return -1;
- }
-
- r = heynoti_attach_handler(fd);
- if (r == -1) {
- _ERR("Noti attach error");
- return -1;
- }
-
- _DBG("Waiting for hib leave");
- _DBG("%s %d\n", __func__, __LINE__);
-
- return 0;
-}
-
-static void _signal_handler(int signum, siginfo_t *info, void *unused)
-{
- _DBG("_signal_handler : Terminated...");
- elm_exit();
-}
-static void _heynoti_event_power_off(void *data)
-{
- _DBG("_heynoti_event_power_off : Terminated...");
- elm_exit();
-}
-
-static int _init(struct appdata *ad)
-{
- int fd;
- int r;
- int fd1;
-
- struct sigaction act;
- act.sa_sigaction = _signal_handler;
- act.sa_flags = SA_SIGINFO;
-
- int ret = sigemptyset(&act.sa_mask);
- if (ret < 0) {
- _ERR("Failed to sigemptyset[%s]", strerror(errno));
- }
- ret = sigaddset(&act.sa_mask, SIGTERM);
- if (ret < 0) {
- _ERR("Failed to sigaddset[%s]", strerror(errno));
- }
- ret = sigaction(SIGTERM, &act, NULL);
- if (ret < 0) {
- _ERR("Failed to sigaction[%s]", strerror(errno));
- }
-
- memset(ad, 0, sizeof(struct appdata));
-
- ad->noti = -1;
- gettimeofday(&ad->tv_start, NULL);
-
- lock_menu_screen();
- _set_elm_theme();
-
- _DBG("%s %d\n", __func__, __LINE__);
-
- fd = open(HIB_CAPTURING, O_RDONLY);
- _DBG("fd = %d\n", fd);
- if (fd == -1) {
- _DBG("fd = %d\n", fd);
- start_lock_daemon();
- if (_launch_pwlock() < 0) {
- _ERR("launch pwlock error");
- }
- r = 0;
- } else {
- close(fd);
- r = add_noti(ad);
- }
-
- fd1 = open(STR_STARTER_READY, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd1 > 0) {
- _DBG("Hibernation ready.\n");
- close(fd1);
- }
-
- return r;
-}
-
-static void _fini(struct appdata *ad)
-{
- struct timeval tv, res;
-
- if (ad == NULL) {
- fprintf(stderr, "Invalid argument: appdata is NULL\n");
- return;
- }
- if (ad->noti != -1)
- heynoti_close(ad->noti);
-
- unlock_menu_screen();
-
- gettimeofday(&tv, NULL);
- timersub(&tv, &ad->tv_start, &res);
- _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
-}
-
-int main(int argc, char *argv[])
-{
- struct appdata ad;
-
- int heyfd = heynoti_init();
- if (heyfd < 0) {
- _ERR("Failed to heynoti_init[%d]", heyfd);
- }
-
- int ret = heynoti_subscribe(heyfd, "power_off_start", _heynoti_event_power_off, NULL);
- if (ret < 0) {
- _ERR("Failed to heynoti_subscribe[%d]", ret);
- }
- ret = heynoti_attach_handler(heyfd);
- if (ret < 0) {
- _ERR("Failed to heynoti_attach_handler[%d]", ret);
- }
-
- elm_init(argc, argv);
-
- _init(&ad);
-
- elm_run();
-
- _fini(&ad);
-
- elm_shutdown();
-
- return 0;
-}
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100755
index 3bd1544..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,479 +0,0 @@
-starter (0.4.6-2) unstable; urgency=low
-
- * temporal release for Orangey
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.6-2
-
- -- youngsub ko <ys4610.ko@samsung.com> Fri, 01 Jun 2012 14:02:49 +0900
-
-starter (0.4.6-1) unstable; urgency=low
-
- * Changing vconf key-path according to naming policy
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.6-1
-
- -- youngsub ko <ys4610.ko@samsung.com> Thu, 31 May 2012 19:25:22 +0900
-
-starter (0.4.5-1) unstable; urgency=low
-
- * apply livebox lockscreen to default setting
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.5-1
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Thu, 24 May 2012 21:03:29 +0900
-
-starter (0.4.4-1) unstable; urgency=low
-
- * new vconf policy was applied
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.4-1
-
- -- youngsub ko <ys4610.ko@samsung.com> Thu, 24 May 2012 16:20:20 +0900
-
-starter (0.4.3-2) unstable; urgency=low
-
- * Removed "/usr/share/*" files from debian/redhat packages
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.3-2
-
- -- youngsub ko <ys4610.ko@samsung.com> Mon, 14 May 2012 10:39:32 +0900
-
-starter (0.4.3-1) unstable; urgency=low
-
- * remove set elm entry
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.3-1
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 18 Apr 2012 11:20:12 +0900
-
-starter (0.4.2-1) unstable; urgency=low
-
- * apply phone lock launching interface
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.2-1
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Sat, 07 Apr 2012 23:30:39 +0900
-
-starter (0.4.1-1) unstable; urgency=low
-
- * Add cancel button in password view
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.1-1
-
- -- Mi-Ju Lee <miju52.lee@samsung.com> Wed, 21 Mar 2012 21:12:34 +0900
-
-starter (0.4.0-1) unstable; urgency=low
-
- * Change desktop file for TIZEN
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.4.0-1
-
- -- Mi-Ju Lee <miju52.lee@samsung.com> Thu, 15 Mar 2012 19:28:01 +0900
-
-starter (0.3-51) unstable; urgency=low
-
- * apply efl migration
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-51
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 14 Mar 2012 14:21:15 +0900
-
-starter (0.3-50) unstable; urgency=low
-
- * apply efl deprecation
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-50
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Fri, 02 Mar 2012 16:32:50 +0900
-
-starter (0.3-49) unstable; urgency=low
-
- * block set scale window
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-49
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 29 Feb 2012 19:17:53 +0900
-
-starter (0.3-48) unstable; urgency=low
-
- * block set window scale
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-48
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 29 Feb 2012 18:42:54 +0900
-
-starter (0.3-47) unstable; urgency=low
-
- * fix launch lock screen
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-47
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Tue, 28 Feb 2012 14:56:18 +0900
-
-starter (0.3-46) unstable; urgency=low
-
- * apply input window
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-46
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 22 Feb 2012 14:21:08 +0900
-
-starter (0.3-45) unstable; urgency=low
-
- * apply efl migration
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-45
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Thu, 16 Feb 2012 20:32:05 +0900
-
-starter (0.3-44) unstable; urgency=low
-
- * fix xwindow
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-44
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Mon, 02 Jan 2012 18:03:13 +0900
-
-starter (0.3-43) unstable; urgency=low
-
- * set lock class name
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-43
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Mon, 02 Jan 2012 17:40:25 +0900
-
-starter (0.3-42) unstable; urgency=low
-
- * set lock alpha
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-42
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 28 Dec 2011 14:26:23 +0900
-
-starter (0.3-41) unstable; urgency=low
-
- * fix lock state
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-41
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Mon, 26 Dec 2011 17:27:15 +0900
-
-starter (0.3-40) unstable; urgency=low
-
- * remove tizen subfolder
- * Git: slp/pkgs/s/starter
- * Tag: starter_0.3-40
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Mon, 19 Dec 2011 14:03:33 +0900
-
-starter (0.3-39) unstable; urgency=low
-
- * fix phone lock operation
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-39
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Fri, 09 Dec 2011 21:04:27 +0900
-
-starter (0.3-38) unstable; urgency=low
-
- * fix homekey operation
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-38
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Thu, 08 Dec 2011 13:47:04 +0900
-
-starter (0.3-37) unstable; urgency=low
-
- * fix set property for phone lock
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-37
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Tue, 06 Dec 2011 16:51:07 +0900
-
-starter (0.3-36) unstable; urgency=low
-
- * apply reset lock screen when lcd is off
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-36
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Fri, 02 Dec 2011 22:59:26 +0900
-
-starter (0.3-35) unstable; urgency=low
-
- * fix selecting lockscreen
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-35
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Wed, 30 Nov 2011 14:12:12 +0900
-
-starter (0.3-34) unstable; urgency=low
-
- * fix setting lockscreen
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-34
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Tue, 29 Nov 2011 09:48:02 +0900
-
-starter (0.3-33) unstable; urgency=low
-
- * remove lockd_launch_first_lockscreen
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-33
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Sat, 26 Nov 2011 16:47:48 +0900
-
-starter (0.3-32) unstable; urgency=low
-
- * fix launching phone lock app
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-32
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Sat, 26 Nov 2011 14:03:48 +0900
-
-starter (0.3-31) unstable; urgency=low
-
- * apply open lock screen
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-31
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Mon, 21 Nov 2011 21:41:09 +0900
-
-starter (0.3-30) unstable; urgency=low
-
- * apply tapi changes
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-30
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Thu, 29 Sep 2011 17:38:08 +0900
-
-starter (0.3-29) unstable; urgency=low
-
- * fix prevent problem
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-29
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Sat, 20 Aug 2011 19:32:57 +0900
-
-starter (0.3-28) unstable; urgency=low
-
- * fix aul launch error
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-28
-
- -- Seungtaek Chung <seungtaek.chung@samsung.com> Fri, 01 Jul 2011 17:29:44 +0900
-
-starter (0.3-27) unstable; urgency=low
-
- * added plock variable to identify menu screen showing time.
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-27
-
- -- jeesun kim <iamjs.kim@samsung.com> Thu, 12 May 2011 09:00:00 +0900
-
-starter (0.3-26) unstable; urgency=low
-
- * modified log error when get vconf failed
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-26
-
- -- jeesun kim <iamjs.kim@samsung.com> Mon, 2 May 2011 09:00:00 +0900
-
-starter (0.3-25) unstable; urgency=low
-
- * added debug message
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-25
-
- -- jeesun kim <iamjs.kim@samsung.com> Fri, 22 Apr 2011 18:00:00 +0900
-
-starter (0.3-24) unstable; urgency=low
-
- * skipped "memory/startapps/sequence" set 1 when first boot
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-24
-
- -- jeesun kim <iamjs.kim@samsung.com> Wed, 14 Apr 2011 10:00:00 +0900
-
-starter (0.3-23) unstable; urgency=low
-
- * removed deb from pwlock, added inhouse right in sequence
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-23
-
- -- jeesun kim <iamjs.kim@samsung.com> Wed, 14 Apr 2011 10:00:00 +0900
-
-starter (0.3-22) unstable; urgency=low
-
- * commmented wm_ready in postinst file and tossed this to isf team.
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-22
-
- -- jeesun kim <iamjs.kim@samsung.com> Wed, 16 Mar 2011 09:36:31 +0900
-
-starter (0.3-21) unstable; urgency=low
-
- * set starter text rd3 and rd4
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-21
-
- -- Jeesun kim <iamjs.kim@samsung.com> Thu, 03 Mar 2011 14:44:37 +0900
-
-starter (0.3-20) unstable; urgency=low
-
- * applied wm_ready (req from boot script)
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-20
-
- -- Jeesun kim <iamjs.kim@samsung.com> Wed, 23 Feb 2011 13:56:09 +0900
-
-starter (0.3-19) unstable; urgency=low
-
- * added x11 package in control
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-19
-
- -- Jeesun kim <iamjs.kim@samsung.com> Thu, 10 Feb 2011 17:44:47 +0900
-
-starter (0.3-18) unstable; urgency=low
-
- * path change /opt/apps/deb.com.samsung.pwlock/bin/pwlock
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-18
-
- -- Jeesun kim <iamjs.kim@samsung.com> Thu, 27 Jan 2011 17:19:13 +0900
-
-starter (0.3-17) unstable; urgency=low
-
- * added theme set step when hibnation
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-17
-
- -- Jeesun kim <iamjs.kim@samsung.com> Thu, 13 Jan 2011 11:41:14 +0900
-
-starter (0.3-16) unstable; urgency=low
-
- * modified action when SIM doesn't exist
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-16
-
- -- Jeesun kim <iamjs.kim@samsung.com> Thu, 06 Jan 2011 14:13:54 +0900
-
-starter (0.3-15) unstable; urgency=low
-
- * set else statement when tapi state is none
- * Git: 165.213.180.234:slp/pkgs/s/starter
- * Tag: starter_0.3-15
-
- -- Jeesun kim <iamjs.kim@samsung.com> Mon, 13 Dec 2010 11:29:39 +0900
-
-starter (0.3-14) unstable; urgency=low
-
- * added dbg package
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-14
-
- -- Jeesun kim <iamjs.kim@samsung.com> Tue, 30 Nov 2010 11:10:22 +0900
-
-starter (0.3-13) unstable; urgency=low
-
- * hibernation set : starter_ready set 1
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-13
-
- -- Jeesun kim <iamjs.kim@samsung.com> Tue, 23 Nov 2010 17:37:15 +0900
-
-starter (0.3-12) unstable; urgency=low
-
- * set hib check_ready
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-12
-
- -- Jeesun kim <iamjs.kim@samsung.com> Fri, 12 Nov 2010 09:26:05 +0900
-
-starter (0.3-11) unstable; urgency=low
-
- * Add hib leave
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-11
-
- -- Suchang Woo <suchang.woo@samsung.com> Mon, 25 Oct 2010 19:05:00 +0900
-
-starter (0.3-10) unstable; urgency=low
-
- * Remove startup script
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-10
-
- -- Suchang Woo <suchang.woo@samsung.com> Wed, 20 Oct 2010 15:52:53 +0900
-
-starter (0.3-9) unstable; urgency=low
-
- * Reset timeout every transition
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-9
-
- -- Suchang Woo <suchang.woo@samsung.com> Tue, 12 Oct 2010 17:16:38 +0900
-
-starter (0.3-8) unstable; urgency=low
-
- * Increase SIM check timeout
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-8
-
- -- Suchang Woo <suchang.woo@samsung.com> Thu, 07 Oct 2010 17:49:26 +0900
-
-starter (0.3-7) unstable; urgency=low
-
- * Wait for TAPI ready
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-7
-
- -- Suchang Woo <suchang.woo@samsung.com> Thu, 07 Oct 2010 11:36:40 +0900
-
-starter (0.3-6) unstable; urgency=low
-
- * Do not check first boot
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-6
-
- -- Suchang Woo <suchang.woo@samsung.com> Mon, 04 Oct 2010 19:35:37 +0900
-
-starter (0.3-5) unstable; urgency=low
-
- * add entry setting
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-5
-
- -- Suchang Woo <suchang.woo@samsung.com> Fri, 01 Oct 2010 20:49:01 +0900
-
-starter (0.3-4) unstable; urgency=low
-
- * quit after pwlock launching
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-4
-
- -- Suchang Woo <suchang.woo@samsung.com> Fri, 01 Oct 2010 17:31:51 +0900
-
-starter (0.3-3) unstable; urgency=low
-
- * modify for language selection
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-3
-
- -- Suchang Woo <suchang.woo@samsung.com> Tue, 28 Sep 2010 20:19:54 +0900
-
-starter (0.3-2) unstable; urgency=low
-
- * unlock menu screen even if exited with error
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-2
-
- -- Suchang Woo <suchang.woo@samsung.com> Wed, 15 Sep 2010 15:06:18 +0900
-
-starter (0.3-1) unstable; urgency=low
-
- * Rewrite the code
- * Git: 165.213.180.234:/git/slp/pkgs/starter
- * Tag: starter_0.3-1
-
- -- Suchang Woo <suchang.woo@samsung.com> Fri, 23 Apr 2010 20:30:14 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100755
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100755
index ae2c243..0000000
--- a/debian/control
+++ /dev/null
@@ -1,19 +0,0 @@
-Source: starter
-Section: devel
-Priority: extra
-Maintainer: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
-Build-Depends: debhelper (>= 5), libappcore-efl-dev, libglib2.0-dev, libslp-tapi-dev, libslp-setting-dev, libheynoti-dev, libaul-1-dev, libx11-dev, libelm-dev, libefreet-dev, dlog-dev, libecore-dev, libsvi-dev, libslp-utilx-dev, libail-0-dev, libui-gadget-dev
-Standards-Version: 3.7.2
-
-Package: starter
-Section: admin
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: starter
-
-Package: starter-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: starter (unstripped)
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 6bf3469..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS ?= -Wall -g
-LDFLAGS ?=
-PREFIX ?= /usr
-DATADIR ?= /usr/share
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
- mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
-
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- cat $$f > $${f%.in}; \
- sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
- sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
- done
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- rm -rf $(CMAKE_BUILD_DIR)
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wavplayer.
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
-# dh_installchangelogs
-# dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip --dbg-package=starter-dbg
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/starter.install.in b/debian/starter.install.in
deleted file mode 100755
index 464e764..0000000
--- a/debian/starter.install.in
+++ /dev/null
@@ -1,4 +0,0 @@
-@PREFIX@/bin/*
-@PREFIX@/lib/*
-/etc/init.d/*
-/opt/ug/*
diff --git a/debian/starter.postinst b/debian/starter.postinst
deleted file mode 100755
index b4e7f9d..0000000
--- a/debian/starter.postinst
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-vconftool set -t int "memory/starter/sequence" 0 -i -u 5000 -g 5000
-
-vconftool set -t string file/private/lockscreen/pkgname "org.tizen.draglock" -u 5000 -g 5000
-
-vconftool -i set -t int memory/idle_lock/state "0" -u 5000 -g 5000
-
-ln -sf /etc/init.d/rd4starter /etc/rc.d/rc4.d/S81starter
-ln -sf /etc/init.d/rd3starter /etc/rc.d/rc3.d/S43starter
-
-sync
diff --git a/include/clock-mgr.h b/include/clock-mgr.h
new file mode 100755
index 0000000..2b32512
--- /dev/null
+++ b/include/clock-mgr.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CLOCK_MGR_H__
+#define __CLOCK_MGR_H__
+
+void init_clock_mgr(void *data);
+void fini_clock_mgr(void *data);
+void clock_mgr_set_reserved_apps_status(void *data);
+
+#endif
+/* __CLOCK_MGR_H__*/
+
diff --git a/include/dbus-util.h b/include/dbus-util.h
new file mode 100755
index 0000000..3b20715
--- /dev/null
+++ b/include/dbus-util.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DBUS_UTIL_H__
+#define __DBUS_UTIL_H__
+
+#include <E_DBus.h>
+
+#define OOM_ADJ_VALUE_HOMESCREEN 0
+
+#ifdef FEATURE_LITE
+#define OOM_ADJ_VALUE_DEFAULT 200
+#else
+#define OOM_ADJ_VALUE_DEFAULT 0
+#endif
+
+void starter_dbus_home_raise_signal_send(void);
+int starter_dbus_set_oomadj(int pid, int oom_adj_value);
+
+#endif //__DBUS_UTIL_H__
diff --git a/include/dbus-util_w.h b/include/dbus-util_w.h
new file mode 100755
index 0000000..5a279c8
--- /dev/null
+++ b/include/dbus-util_w.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DBUS_H__
+#define __DBUS_H__
+
+#include <E_DBus.h>
+
+int request_Poweroff(void);
+int request_dbus_cpu_booster(void);
+int init_dbus_ALPM_signal(void *data);
+int init_dbus_COOL_DOWN_MODE_signal(void *data);
+int get_dbus_cool_down_mode(void *data);
+int init_dbus_NIKE_RUNNING_STATUS_signal(void *data);
+int init_dbus_ALPM_clock_state_signal(void *data);
+void starter_dbus_alpm_clock_signal_send(void *data);
+DBusConnection *starter_dbus_connection_get(void);
+
+
+#endif //__DBUS_H__
+
diff --git a/include/direct-access.h b/include/direct-access.h
new file mode 100755
index 0000000..a4f4067
--- /dev/null
+++ b/include/direct-access.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DIRECT_ACCESS_H__
+#define __DIRECT_ACCESS_H__
+
+#include <E_DBus.h>
+
+DBusMessage *invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[]);
+
+DBusMessage *invoke_dbus_method(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[]);
+
+int launch_direct_access(int access_val);
+
+#endif //__DIRECT_ACCESS_H__
+
diff --git a/include/hourly_alert.h b/include/hourly_alert.h
new file mode 100755
index 0000000..1e8ee11
--- /dev/null
+++ b/include/hourly_alert.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HOURLY_ALERT_H__
+#define __HOURLY_ALERT_H__
+
+
+void init_hourly_alert(void *data);
+void fini_hourly_alert(void *data);
+
+#endif /* __HOURLY_ALERT_H__ */
diff --git a/lock-mgr/include/lock-daemon.h b/include/hw_key.h
index 5fe3b93..ec02f61 100755
--- a/lock-mgr/include/lock-daemon.h
+++ b/include/hw_key.h
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-#ifndef __LOCK_DAEMON_H__
-#define __LOCK_DAEMON_H__
+extern void destroy_key_window(void);
+extern void create_key_window(void);
-int start_lock_daemon();
-
-#endif /* __LOCK_DAEMON_H__ */
+// End of a file
diff --git a/include/hw_key_w.h b/include/hw_key_w.h
new file mode 100755
index 0000000..13f9062
--- /dev/null
+++ b/include/hw_key_w.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+extern void destroy_key_window(void);
+extern void create_key_window(char *home_pkgname, void *data);
+
+// End of a file
diff --git a/include/lock-daemon-lite.h b/include/lock-daemon-lite.h
new file mode 100755
index 0000000..d1367a3
--- /dev/null
+++ b/include/lock-daemon-lite.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOCK_DAEMON_LITE_H__
+#define __LOCK_DAEMON_LITE_H__
+
+int start_lock_daemon_lite(int launch_lock, int is_first_boot);
+int lockd_get_lock_type(void);
+int lockd_get_hall_status(void);
+int lockd_get_lock_state(void);
+
+#endif /* __LOCK_DAEMON_LITE_H__ */
diff --git a/include/lock-daemon.h b/include/lock-daemon.h
new file mode 100755
index 0000000..d43f3e6
--- /dev/null
+++ b/include/lock-daemon.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOCK_DAEMON_H__
+#define __LOCK_DAEMON_H__
+
+int start_lock_daemon(int launch_lock, int is_first_boot);
+int lockd_get_lock_type(void);
+int lockd_get_hall_status(void);
+int lockd_get_lock_state(void);
+
+#endif /* __LOCK_DAEMON_H__ */
diff --git a/include/lockd-bt.h b/include/lockd-bt.h
new file mode 100755
index 0000000..33a9369
--- /dev/null
+++ b/include/lockd-bt.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOCKD_BT_H__
+#define __LOCKD_BT_H__
+
+int lockd_start_bt_monitor(void);
+
+void lockd_stop_bt_monitor(void);
+
+void lockd_change_security_auto_lock(int is_connected);
+
+int lockd_get_auto_lock_security(void);
+
+#endif /* __LOCKD_BT_H__ */
diff --git a/include/lockd-debug.h b/include/lockd-debug.h
new file mode 100755
index 0000000..4c24a23
--- /dev/null
+++ b/include/lockd-debug.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOCKD_DEBUG_H__
+#define __LOCKD_DEBUG_H__
+
+#include <stdio.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "STARTER"
+
+#define ENABLE_LOG_SYSTEM
+
+#ifdef ENABLE_LOG_SYSTEM
+#define STARTER_ERR(fmt, arg...) LOGE("["LOG_TAG"%s:%d:E] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_DBG(fmt, arg...) LOGD("["LOG_TAG"%s:%d:D] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_WARN(fmt, arg...) LOGW("["LOG_TAG"%s:%d:W] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_SECURE_ERR(fmt, arg...) SECURE_LOGE("["LOG_TAG"%s:%d:E] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_SECURE_DBG(fmt, arg...) SECURE_LOGD("["LOG_TAG"%s:%d:D] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_SECURE_WARN(fmt, arg...) SECURE_LOGW("["LOG_TAG"%s:%d:W] "fmt, __FILE__, __LINE__, ##arg)
+#else
+#define STARTER_ERR(fmt, arg...)
+#define STARTER_DBG(fmt, arg...)
+#define STARTER_WARN(fmt, arg...)
+#define STARTER_SECURE_ERR(fmt, arg...)
+#define STARTER_SECURE_DBG(fmt, arg...)
+#define STARTER_SECURE_WARN(fmt, arg...)
+#endif
+
+#ifdef ENABLE_LOG_SYSTEM
+#define _ERR(fmt, arg...) do { STARTER_ERR(fmt, ##arg); } while (0)
+#define _DBG(fmt, arg...) do { STARTER_DBG(fmt, ##arg); } while (0)
+#define _WARN(fmt, arg...) do { STARTER_WARN(fmt, ##arg); } while (0)
+
+#define _SECURE_ERR(fmt, arg...) do { STARTER_SECURE_ERR(fmt, ##arg); } while (0)
+#define _SECURE_DBG(fmt, arg...) do { STARTER_SECURE_DBG(fmt, ##arg); } while (0)
+#define _SECURE_WARN(fmt, arg...) do { STARTER_SECURE_WARN(fmt, ##arg); } while (0)
+
+#define LOCKD_ERR(fmt, arg...) _ERR(fmt, ##arg)
+#define LOCKD_DBG(fmt, arg...) _DBG(fmt, ##arg)
+#define LOCKD_WARN(fmt, arg...) _WARN(fmt, ##arg)
+#define LOCKD_SECURE_ERR(fmt, arg...) _SECURE_ERR(fmt, ##arg)
+#define LOCKD_SECURE_DBG(fmt, arg...) _SECURE_DBG(fmt, ##arg)
+#define LOCKD_SECURE_WARN(fmt, arg...) _SECURE_WARN(fmt, ##arg)
+#else
+#define _ERR(...)
+#define _DBG(...)
+#define _WARN(...)
+#define _SECURE_ERR(...)
+#define _SECURE_DBG(...)
+#define _SECURE_WARN(...)
+
+#define LOCKD_ERR(...)
+#define LOCKD_DBG(...)
+#define LOCKD_WARN(...)
+#define LOCKD_SECURE_ERR(...)
+#define LOCKD_SECURE_DBG(...)
+#define LOCKD_SECURE_WARN(...)
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#endif /* __LOCKD_DEBUG_H__ */
diff --git a/include/lockd-process-mgr.h b/include/lockd-process-mgr.h
new file mode 100755
index 0000000..f7429da
--- /dev/null
+++ b/include/lockd-process-mgr.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOCKD_PROCESS_MGR_H__
+#define __LOCKD_PROCESS_MGR_H__
+
+void lockd_process_mgr_init(void);
+
+int lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *),
+ int lock_type);
+
+int lockd_process_mgr_restart_lock(int lock_type);
+
+int lockd_process_mgr_start_recovery_lock(void);
+
+int lockd_process_mgr_start_back_to_app_lock(void);
+
+int lockd_process_mgr_start_ready_lock(void);
+
+int lockd_process_mgr_start_phone_lock(void);
+
+int lockd_process_mgr_start_normal_lock(void *data, int (*dead_cb) (int, void *));
+
+void lockd_process_mgr_terminate_lock_app(int lock_app_pid,
+ int state);
+
+void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid);
+
+void lockd_process_mgr_kill_lock_app(int lock_app_pid);
+
+int lockd_process_mgr_check_lock(int pid);
+
+int lockd_process_mgr_check_call(int pid);
+
+int lockd_process_mgr_check_home(int pid);
+
+int lockd_process_mgr_set_lockscreen_priority(int pid);
+int lockd_process_mgr_set_pwlock_priority(int pid);
+#endif /* __LOCKD_PROCESS_MGR_H__ */
diff --git a/lock-mgr/include/lockd-window-mgr.h b/include/lockd-window-mgr.h
index 5bf8a5b..cbb1a98 100755
--- a/lock-mgr/include/lockd-window-mgr.h
+++ b/include/lockd-window-mgr.h
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -19,15 +19,23 @@
typedef struct _lockw_data lockw_data;
-void
+int
+lockd_window_mgr_get_focus_win_pid(void);
+
+Eina_Bool
lockd_window_set_window_property(lockw_data * data, int lock_app_pid,
void *event);
-void
+Eina_Bool
lockd_window_set_window_effect(lockw_data * data, int lock_app_pid,
void *event);
void
+lockd_window_set_scroll_property(lockw_data * data, int lock_type);
+
+void lockd_window_set_phonelock_pid(lockw_data * data, int phone_lock_pid);
+
+void
lockd_window_mgr_ready_lock(void *data, lockw_data * lockw,
Eina_Bool(*create_cb) (void *, int, void *),
Eina_Bool(*show_cb) (void *, int, void *));
@@ -36,4 +44,9 @@ void lockd_window_mgr_finish_lock(lockw_data * lockw);
lockw_data *lockd_window_init(void);
+void lockd_create_ug_window(void *data);
+
+void lockd_destroy_ug_window(void *data);
+
+void lockd_show_phonelock_alpha_ug(void *data);
#endif /* __LOCKD_WINDOW_MGR_H__ */
diff --git a/include/menu_daemon.h b/include/menu_daemon.h
new file mode 100755
index 0000000..5972da5
--- /dev/null
+++ b/include/menu_daemon.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <bundle.h>
+#include <sys/types.h>
+#include <stdbool.h>
+
+extern void menu_daemon_init(void *data);
+extern void menu_daemon_fini(void);
+
+extern int menu_daemon_open_app(const char *pkgname);
+extern int menu_daemon_launch_app(const char *pkgname, bundle *b);
+extern void menu_daemon_launch_app_tray(void);
+
+extern bool menu_daemon_is_homescreen(pid_t pid);
+extern int menu_daemon_is_safe_mode(void);
+extern int menu_daemon_get_cradle_status(void);
+extern const char *menu_daemon_get_svoice_pkg_name(void);
+
+extern int menu_daemon_check_dead_signal(int pid);
+
+extern char *menu_daemon_get_selected_pkgname(void);
+extern int menu_daemon_open_homescreen(const char *pkgname);
+
+#if 0
+extern int menu_daemon_get_pm_key_ignore(int ignore_key);
+extern void menu_daemon_set_pm_key_ignore(int ignore_key, int value);
+#endif
+
+extern int menu_daemon_get_volume_pid(void);
+
+extern int menu_daemon_launch_search(void);
+
+
+// End of a file
diff --git a/include/pkg_event.h b/include/pkg_event.h
new file mode 100644
index 0000000..c7ee8b6
--- /dev/null
+++ b/include/pkg_event.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NOTIFIER_H__
+#define __NOTIFIER_H__
+#include <stdbool.h>
+
+#if !defined(PUBLIC)
+#define PUBLIC __attribute__((visibility("default"))) /**<All other from outside modules can access this typed API */
+#endif
+
+#if !defined(PROTECTED)
+#define PROTECTED __attribute__((visibility("hidden"))) /**<All other from outside modules can not access this directly */
+#endif
+
+#if !defined(PRIVATE)
+#define PRIVATE __attribute__((visibility("internal"))) /**<Does not export APIs to the other. only can be accessed in this module */
+#endif
+
+
+struct desktop_notifier {
+ int number;
+ int ifd;
+ Ecore_Fd_Handler *handler;
+};
+
+
+PRIVATE void pkg_event_init(void);
+PRIVATE void pkg_event_fini(void);
+
+#endif
diff --git a/include/starter-util.h b/include/starter-util.h
new file mode 100755
index 0000000..41999f6
--- /dev/null
+++ b/include/starter-util.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __STARTER_UTIL_H__
+#define __STARTER_UTIL_H__
+
+#include <stdio.h>
+#include <sys/time.h>
+
+#if 0
+#define WRITE_FILE_LOG(fmt, arg...) do { \
+ FILE *fp;\
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ fp = fopen("/var/log/boottime", "a+");\
+ if (NULL == fp) break;\
+ fprintf(fp, "%u%09u : "fmt"\n", (int) tv.tv_sec, (int) tv.tv_usec, ##arg); \
+ fclose(fp);\
+} while (0)
+#endif
+#endif /* __STARTER_UTIL_H__ */
diff --git a/include/starter-vconf.h b/include/starter-vconf.h
index b0db772..2d51f0c 100755
--- a/include/starter-vconf.h
+++ b/include/starter-vconf.h
@@ -1,9 +1,5 @@
/*
- * starter
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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.
@@ -16,12 +12,12 @@
* 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 __STARTER_VCONF_H__
#define __STARTER_VCONF_H__
#define VCONF_PRIVATE_LOCKSCREEN_PKGNAME "file/private/lockscreen/pkgname"
+#define VCONF_PRIVATE_LOCKSCREEN_DEFAULT_PKGNAME "file/private/lockscreen/default_pkgname"
#endif /* __STARTER_VCONF_H__ */
diff --git a/boot-mgr/starter.h b/include/starter.h
index d6e9a74..4ce9124 100755..100644
--- a/boot-mgr/starter.h
+++ b/include/starter.h
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -20,8 +20,7 @@
#include <sys/time.h>
struct appdata {
- struct timeval tv_start;
- int noti;
+ struct timeval tv_start; /* start time */
};
#endif /* __STARTER_H__ */
diff --git a/include/starter_w.h b/include/starter_w.h
new file mode 100755
index 0000000..102a00b
--- /dev/null
+++ b/include/starter_w.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __STARTER_W_H__
+#define __STARTER_W_H__
+
+#include <sys/time.h>
+#include <aul.h>
+#include <alarm.h>
+
+struct appdata {
+ struct timeval tv_start; /* start time */
+ int launcher_pid;
+ alarm_id_t alarm_id; /* -1 : None, others : set alarm */
+ int bt_connected;
+ char *home_pkgname;
+ int first_boot;
+ int cool_down_mode;
+ int wake_up_setting;
+ int pid_ALPM_clock;
+ int ambient_mode;
+ int retry_cnt;
+ int nike_running_status;
+ int ALPM_clock_state;
+ int reserved_apps_local_port_id;
+ Eina_List *reserved_apps_list;
+ int lcd_status;
+ char *reserved_popup_app_id;
+
+ int pid_clock_viewer;
+};
+
+typedef enum {
+ STARTER_RESERVED_APPS_SHEALTH = 0,
+ STARTER_RESERVED_APPS_NIKE = 1,
+ STARTER_RESERVED_APPS_HERE = 2,
+ STARTER_RESERVED_APPS_MAX = 3,
+} starter_reservd_apps_type;
+
+#define W_HOME_PKGNAME "org.tizen.w-home"
+#define W_LAUNCHER_PKGNAME "com.samsung.w-launcher-app"
+
+#define W_CLOCK_VIEWER_PKGNAME "org.tizen.w-clock-viewer"
+
+
+int w_open_app(char *pkgname);
+int w_launch_app(char *pkgname, bundle *b);
+
+#endif /* __STARTER_H__ */
diff --git a/include/util.h b/include/util.h
new file mode 100755
index 0000000..5972926
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MENU_DAEMON_UTIL_H__
+#define __MENU_DAEMON_UTIL_H__
+#include <dlog.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#define APP_TRAY_PKG_NAME "com.samsung.app-tray"
+#define MENU_SCREEN_PKG_NAME "org.tizen.menu-screen"
+#define PROVIDER_PKG_NAME "com.samsung.data-provider-master"
+#define SVOICE_PKG_NAME "com.samsung.svoice"
+#define CLUSTER_HOME_PKG_NAME "com.samsung.cluster-home"
+#define EASY_HOME_PKG_NAME "com.samsung.easy-home"
+#define EASY_APPS_PKG_NAME "com.samsung.easy-apps"
+#define HOMESCREEN_PKG_NAME "org.tizen.homescreen"
+#define TASKMGR_PKG_NAME "org.tizen.task-mgr"
+#define DEFAULT_TASKMGR_PKG_NAME "com.samsung.taskmgr"
+#define CONF_PATH_NUMBER 1024
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "STARTER"
+#endif
+
+/* Log */
+#if !defined(_W)
+#define _W(fmt, arg...) LOGW("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_D)
+#define _D(fmt, arg...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_SECURE_W)
+#define _SECURE_W(fmt, arg...) SECURE_LOGW("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_SECURE_D)
+#define _SECURE_D(fmt, arg...) SECURE_LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_SECURE_E)
+#define _SECURE_E(fmt, arg...) SECURE_LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#define retv_if(expr, val) do { \
+ if(expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} 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; \
+ } \
+}
+
+#define PRINT_TIME(str) do { \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ _D("[%s:%d] %s TIME=%u.%u", __func__, __LINE__, str, (int)tv.tv_sec, (int)tv.tv_usec); \
+} while (0)
+
+#define _F(fmt, arg...) do { \
+ FILE *fp;\
+ fp = fopen("/var/log/starter.log", "a+");\
+ if (NULL == fp) break;\
+ fprintf(fp, "[%s:%d] "fmt"\n", __func__, __LINE__, ##arg); \
+ fclose(fp);\
+} while (0)
+
+
+
+#endif /* __MENU_DAEMON_UTIL_H__ */
diff --git a/boot-mgr/x11.h b/include/x11.h
index f32e141..ef0bbc5 100755..100644
--- a/boot-mgr/x11.h
+++ b/include/x11.h
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -19,5 +19,6 @@
void prop_string_set(const char *name, const char *value);
void prop_int_set(const char *name, unsigned int val);
+void set_window_scale(void);
#endif /* __STARTER_X11_H__ */
diff --git a/lock-mgr/CMakeLists.txt b/lock-mgr/CMakeLists.txt
deleted file mode 100755
index 197ad11..0000000
--- a/lock-mgr/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(lock-daemon C)
-
-SET(PREFIX "/usr")
-SET(EXEC_PREFIX "${PREFIX}/bin")
-SET(LIBDIR "${PREFIX}/lib")
-SET(CONFDIR "/etc")
-SET(VERSION 0.1.0)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs_lock_daemon REQUIRED
- elementary
- appcore-efl
- heynoti
- aul
- vconf
- ecore
- evas
- ecore-evas
- eet
- x11
- dlog
- ecore-x
- utilX
- ecore-input
- glib-2.0
- bundle
- capi-appfw-application
-)
-FOREACH (flag ${pkgs_lock_daemon_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-ADD_DEFINITIONS("-D_GNU_SOURCE")
-ADD_DEFINITIONS(${EXTRA_CFLAGS})
-ADD_LIBRARY(${PROJECT_NAME} SHARED
- src/lock-daemon.c
- src/lockd-debug.c
- src/lockd-process-mgr.c
- src/lockd-window-mgr.c
-)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_lock_daemon_LDFLAGS})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
-
-# End of a file
diff --git a/lock-mgr/include/lockd-debug.h b/lock-mgr/include/lockd-debug.h
deleted file mode 100755
index e017667..0000000
--- a/lock-mgr/include/lockd-debug.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 __LOCKD_DEBUG_H__
-#define __LOCKD_DEBUG_H__
-
-#include <stdio.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "starter"
-
-#define ENABLE_LOG_SYSTEM
-
-void lockd_log_t(char *fmt, ...);
-
-#ifdef ENABLE_LOG_SYSTEM
-#define STARTER_ERR(fmt, arg...) LOGE("["LOG_TAG"%s:%d:E] "fmt, __FILE__, __LINE__, ##arg)
-#define STARTER_DBG(fmt, arg...) LOGD("["LOG_TAG"%s:%d:D] "fmt, __FILE__, __LINE__, ##arg)
-#else
-#define STARTER_ERR(fmt, arg...)
-#define STARTER_DBG(fmt, arg...)
-#endif
-
-#ifdef ENABLE_LOG_SYSTEM
-#define _ERR(fmt, arg...) do { STARTER_ERR(fmt, ##arg); lockd_log_t("["LOG_TAG":%d:E] "fmt, __LINE__, ##arg); } while (0)
-#define _DBG(fmt, arg...) do { STARTER_DBG(fmt, ##arg); lockd_log_t("["LOG_TAG":%d:D] "fmt, __LINE__, ##arg); } while (0)
-
-#define LOCKD_ERR(fmt, arg...) _ERR(fmt, ##arg)
-#define LOCKD_DBG(fmt, arg...) _DBG(fmt, ##arg)
-#else
-#define _ERR(...)
-#define _DBG(...)
-
-#define LOCKD_ERR(...)
-#define LOCKD_ERR(...)
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#endif /* __LOCKD_DEBUG_H__ */
diff --git a/lock-mgr/include/lockd-process-mgr.h b/lock-mgr/include/lockd-process-mgr.h
deleted file mode 100755
index e15d817..0000000
--- a/lock-mgr/include/lockd-process-mgr.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 __LOCKD_PROCESS_MGR_H__
-#define __LOCKD_PROCESS_MGR_H__
-
-int lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *));
-
-int lockd_process_mgr_restart_lock(void);
-
-void lockd_process_mgr_terminate_lock_app(int lock_app_pid,
- int state);
-
-int lockd_process_mgr_check_lock(int pid);
-
-#endif /* __LOCKD_PROCESS_MGR_H__ */
diff --git a/lock-mgr/src/lock-daemon.c b/lock-mgr/src/lock-daemon.c
deleted file mode 100755
index 7dba048..0000000
--- a/lock-mgr/src/lock-daemon.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 <Elementary.h>
-
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/un.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <errno.h>
-
-#include "lockd-debug.h"
-#include "lock-daemon.h"
-#include "lockd-process-mgr.h"
-#include "lockd-window-mgr.h"
-
-struct lockd_data {
- int lock_app_pid;
- lockw_data *lockw;
-};
-
-#define LAUNCH_INTERVAL 100*1000
-
-static void lockd_launch_lockscreen(struct lockd_data *lockd);
-static void lockd_launch_app_lockscreen(struct lockd_data *lockd);
-
-static void lockd_unlock_lockscreen(struct lockd_data *lockd);
-
-static void _lockd_notify_pm_state_cb(keynode_t * node, void *data)
-{
- LOCKD_DBG("PM state Notification!!");
-
- struct lockd_data *lockd = (struct lockd_data *)data;
- int val = -1;
-
- if (lockd == NULL) {
- LOCKD_ERR("lockd is NULL");
- return;
- }
-
- if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
- LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
- return;
- }
-
- if (val == VCONFKEY_PM_STATE_LCDOFF) {
- lockd_launch_app_lockscreen(lockd);
- }
-}
-
-static void
-_lockd_notify_lock_state_cb(keynode_t * node, void *data)
-{
- LOCKD_DBG("lock state changed!!");
-
- struct lockd_data *lockd = (struct lockd_data *)data;
- int val = -1;
-
- if (lockd == NULL) {
- LOCKD_ERR("lockd is NULL");
- return;
- }
-
- if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
- LOCKD_ERR("Cannot get VCONFKEY_IDLE_LOCK_STATE");
- return;
- }
-
- if (val == VCONFKEY_IDLE_UNLOCK) {
- LOCKD_DBG("unlocked..!!");
- if (lockd->lock_app_pid != 0) {
- LOCKD_DBG("terminate lock app..!!");
- lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
- }
- }
-}
-
-static int lockd_app_dead_cb(int pid, void *data)
-{
- LOCKD_DBG("app dead cb call! (pid : %d)", pid);
-
- struct lockd_data *lockd = (struct lockd_data *)data;
-
- if (pid == lockd->lock_app_pid ) {
- LOCKD_DBG("lock app(pid:%d) is destroyed.", pid);
- lockd_unlock_lockscreen(lockd);
- }
- return 0;
-}
-
-static Eina_Bool lockd_app_create_cb(void *data, int type, void *event)
-{
- struct lockd_data *lockd = (struct lockd_data *)data;
-
- if (lockd == NULL) {
- return EINA_TRUE;
- }
- LOCKD_DBG("%s, %d", __func__, __LINE__);
- lockd_window_set_window_effect(lockd->lockw, lockd->lock_app_pid,
- event);
- lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
- event);
- return EINA_FALSE;
-}
-
-static Eina_Bool lockd_app_show_cb(void *data, int type, void *event)
-{
- struct lockd_data *lockd = (struct lockd_data *)data;
-
- if (lockd == NULL) {
- return EINA_TRUE;
- }
- LOCKD_DBG("%s, %d", __func__, __LINE__);
- lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
- event);
-
- return EINA_FALSE;
-}
-
-static void lockd_launch_app_lockscreen(struct lockd_data *lockd)
-{
- LOCKD_DBG("launch app lock screen");
-
- int call_state = -1, phlock_state = -1;
- int r = 0;
-
- if (lockd_process_mgr_check_lock(lockd->lock_app_pid) == TRUE) {
- LOCKD_DBG("Lock Screen App is already running.");
- r = lockd_process_mgr_restart_lock();
- if (r < 0) {
- LOCKD_DBG("Restarting Lock Screen App is fail [%d].", r);
- usleep(LAUNCH_INTERVAL);
- } else {
- LOCKD_DBG("Restarting Lock Screen App, pid[%d].", r);
- return;
- }
- }
-
- vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
- if (call_state != VCONFKEY_CALL_OFF) {
- LOCKD_DBG
- ("Current call state(%d) does not allow to launch lock screen.",
- call_state);
- return;
- }
-
- lockd->lock_app_pid =
- lockd_process_mgr_start_lock(lockd, lockd_app_dead_cb);
- if (lockd->lock_app_pid < 0)
- return;
-
- vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_LOCK);
- lockd_window_mgr_ready_lock(lockd, lockd->lockw, lockd_app_create_cb,
- lockd_app_show_cb);
-}
-
-static void lockd_launch_lockscreen(struct lockd_data *lockd)
-{
- LOCKD_DBG("launch lock screen");
-
- int call_state = -1;
- int r = 0;
-
- if (lockd_process_mgr_check_lock(lockd->lock_app_pid) == TRUE) {
- LOCKD_DBG("Lock Screen App is already running.");
- r = lockd_process_mgr_restart_lock();
- if (r < 0) {
- LOCKD_DBG("Restarting Lock Screen App is fail [%d].", r);
- } else {
- LOCKD_DBG("Restarting Lock Screen App, pid[%d].", r);
- return;
- }
- }
-
- vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
- if (call_state != VCONFKEY_CALL_OFF) {
- LOCKD_DBG
- ("Current call state(%d) does not allow to launch lock screen.",
- call_state);
- return;
- }
-
- lockd_window_mgr_ready_lock(lockd, lockd->lockw, lockd_app_create_cb,
- lockd_app_show_cb);
-
- lockd->lock_app_pid =
- lockd_process_mgr_start_lock(lockd, lockd_app_dead_cb);
-
- vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_LOCK);
-}
-
-static void lockd_unlock_lockscreen(struct lockd_data *lockd)
-{
- LOCKD_DBG("unlock lock screen");
- lockd->lock_app_pid = 0;
-
- lockd_window_mgr_finish_lock(lockd->lockw);
-
- vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
-}
-
-static void lockd_init_vconf(struct lockd_data *lockd)
-{
- int val = -1;
-
- if (vconf_notify_key_changed
- (VCONFKEY_PM_STATE, _lockd_notify_pm_state_cb, lockd) != 0) {
- LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY_PM_STATE");
- }
-
- if (vconf_notify_key_changed
- (VCONFKEY_IDLE_LOCK_STATE,
- _lockd_notify_lock_state_cb,
- lockd) != 0) {
- LOCKD_ERR
- ("[Error] vconf notify : lock state");
- }
-}
-
-static void lockd_start_lock_daemon(void *data)
-{
- struct lockd_data *lockd = NULL;
- int r = 0;
-
- lockd = (struct lockd_data *)data;
-
- if (!lockd) {
- return;
- }
-
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-
- lockd_init_vconf(lockd);
-
- lockd->lockw = lockd_window_init();
-
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-}
-
-int start_lock_daemon()
-{
- struct lockd_data *lockd = NULL;
- int val = -1;
-
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-
- lockd = (struct lockd_data *)malloc(sizeof(struct lockd_data));
- memset(lockd, 0x0, sizeof(struct lockd_data));
- lockd_start_lock_daemon(lockd);
-
- return 0;
-}
diff --git a/lock-mgr/src/lockd-process-mgr.c b/lock-mgr/src/lockd-process-mgr.c
deleted file mode 100755
index 179fced..0000000
--- a/lock-mgr/src/lockd-process-mgr.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 <vconf.h>
-#include <vconf-keys.h>
-
-#include <aul.h>
-
-#include "lockd-debug.h"
-#include "lockd-process-mgr.h"
-#include "starter-vconf.h"
-
-#define LOCKD_DEFAULT_PKG_NAME "org.tizen.draglock"
-#define LOCKD_DEFAULT_LOCKSCREEN "org.tizen.draglock"
-#define RETRY_MAXCOUNT 30
-#define RELAUNCH_INTERVAL 100*1000
-
-static char *_lockd_process_mgr_get_pkgname(void)
-{
- char *pkgname = NULL;
-
- pkgname = vconf_get_str(VCONF_PRIVATE_LOCKSCREEN_PKGNAME);
-
- LOCKD_DBG("pkg name is %s", pkgname);
-
- if (pkgname == NULL) {
- return LOCKD_DEFAULT_PKG_NAME;
- }
-
- return pkgname;
-}
-
-int lockd_process_mgr_restart_lock(void)
-{
- char *lock_app_path = NULL;
- int pid;
- bundle *b = NULL;
-
- lock_app_path = _lockd_process_mgr_get_pkgname();
-
- b = bundle_create();
-
- bundle_add(b, "mode", "normal");
-
- pid = aul_launch_app(lock_app_path, b);
-
- LOCKD_DBG("Reset : aul_launch_app(%s, NULL), pid = %d", lock_app_path,
- pid);
-
- if (b)
- bundle_free(b);
-
- return pid;
-}
-
-int
-lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *))
-{
- char *lock_app_path = NULL;
- int pid;
- bundle *b = NULL;
-
- lock_app_path = _lockd_process_mgr_get_pkgname();
-
- b = bundle_create();
-
- bundle_add(b, "mode", "normal");
-
- int i;
- for (i=0; i<RETRY_MAXCOUNT; i++)
- {
- pid = aul_launch_app(lock_app_path, b);
-
- LOCKD_DBG("aul_launch_app(%s, NULL), pid = %d", lock_app_path, pid);
-
- if (pid == AUL_R_ECOMM) {
- LOCKD_DBG("Relaunch lock application [%d]times", i);
- usleep(RELAUNCH_INTERVAL);
- } else if (pid == AUL_R_ERROR) {
- LOCKD_DBG("launch[%s] is failed, launch default lock screen", lock_app_path);
- pid = aul_launch_app(LOCKD_DEFAULT_LOCKSCREEN, b);
- if (pid >0) {
- aul_listen_app_dead_signal(dead_cb, data);
- if (b)
- bundle_free(b);
- return pid;
- }
- } else {
- /* set listen and dead signal */
- aul_listen_app_dead_signal(dead_cb, data);
- if (b)
- bundle_free(b);
- return pid;
- }
- }
- LOCKD_DBG("Relaunch lock application failed..!!");
- return pid;
-}
-
-void
-lockd_process_mgr_terminate_lock_app(int lock_app_pid, int state)
-{
- LOCKD_DBG
- ("lockd_process_mgr_terminate_lock_app, state:%d\n",
- state);
-
- if (state == 1) {
- if (lock_app_pid != 0) {
- LOCKD_DBG("Terminate Lock app(pid : %d)", lock_app_pid);
- aul_terminate_pid(lock_app_pid);
- }
- }
-}
-
-int lockd_process_mgr_check_lock(int pid)
-{
- char buf[128];
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-
- if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
- LOCKD_DBG("no such pkg by pid %d\n", pid);
- } else {
- LOCKD_DBG("app pkgname = %s, pid = %d\n", buf, pid);
- if (aul_app_is_running(buf) == TRUE) {
- LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
- return TRUE;
- } else {
- LOCKD_DBG("[pid = %d] is exist but %s is not running\n",
- pid, buf);
- }
- }
- return FALSE;
-}
diff --git a/lock-mgr/src/lockd-window-mgr.c b/lock-mgr/src/lockd-window-mgr.c
deleted file mode 100755
index cdf5e74..0000000
--- a/lock-mgr/src/lockd-window-mgr.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.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 <Elementary.h>
-#include <Ecore_X.h>
-#include <utilX.h>
-#include <vconf.h>
-#include <bundle.h>
-#include <appcore-efl.h>
-#include <app.h>
-
-#include "lockd-debug.h"
-#include "lockd-window-mgr.h"
-
-#define PACKAGE "starter"
-
-struct _lockw_data {
- Ecore_X_Window input_x_window;
-
- Evas_Object *main_win;
- Evas_Object *main_layout;
-
- Ecore_X_Window lock_x_window;
-
- Ecore_Event_Handler *h_keydown;
- Ecore_Event_Handler *h_wincreate;
- Ecore_Event_Handler *h_winshow;
-
-};
-
-static Eina_Bool _lockd_window_key_down_cb(void *data, int type, void *event)
-{
- LOCKD_DBG("Key Down CB.");
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static int
-_lockd_window_check_validate_rect(Ecore_X_Display * dpy, Ecore_X_Window window)
-{
- Ecore_X_Window root;
- Ecore_X_Window child;
-
- int rel_x = 0;
- int rel_y = 0;
- int abs_x = 0;
- int abs_y = 0;
-
- unsigned int width = 0;
- unsigned int height = 0;
- unsigned int border = 0;
- unsigned int depth = 0;
-
- Eina_Bool ret = FALSE;
-
- root = ecore_x_window_root_first_get();
-
- if (XGetGeometry
- (dpy, window, &root, &rel_x, &rel_y, &width, &height, &border,
- &depth)) {
- if (XTranslateCoordinates
- (dpy, window, root, 0, 0, &abs_x, &abs_y, &child)) {
- if ((abs_x - border) >= 480 || (abs_y - border) >= 800
- || (width + abs_x) <= 0 || (height + abs_y) <= 0) {
- ret = FALSE;
- } else {
- ret = TRUE;
- }
- }
- }
-
- return ret;
-}
-
-static Window get_user_created_window(Window win)
-{
- Atom type_ret = 0;
- int ret, size_ret = 0;
- unsigned long num_ret = 0, bytes = 0;
- unsigned char *prop_ret = NULL;
- unsigned int xid;
- Atom prop_user_created_win;
-
- prop_user_created_win =
- XInternAtom(ecore_x_display_get(), "_E_USER_CREATED_WINDOW", False);
-
- ret =
- XGetWindowProperty(ecore_x_display_get(), win,
- prop_user_created_win, 0L, 1L, False, 0,
- &type_ret, &size_ret, &num_ret, &bytes,
- &prop_ret);
-
- if (ret != Success) {
- if (prop_ret)
- XFree((void *)prop_ret);
- return win;
- } else if (!prop_ret) {
- return win;
- }
-
- memcpy(&xid, prop_ret, sizeof(unsigned int));
- XFree((void *)prop_ret);
-
- return xid;
-
-}
-
-void
-lockd_window_set_window_property(lockw_data * data, int lock_app_pid,
- void *event)
-{
- Ecore_X_Event_Window_Create *e = event;
- Ecore_X_Window user_window = 0;
- lockw_data *lockw = (lockw_data *) data;
- int pid = 0;
-
- if (!lockw) {
- return;
- }
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-
- user_window = get_user_created_window((Window) (e->win));
-
- ecore_x_netwm_pid_get(user_window, &pid);
-
- LOCKD_DBG("Check PID(%d) window. (lock_app_pid : %d)\n", pid,
- lock_app_pid);
-
- if (lock_app_pid == pid) {
- if (_lockd_window_check_validate_rect
- (ecore_x_display_get(), user_window) == TRUE) {
- lockw->lock_x_window = user_window;
- LOCKD_DBG
- ("This is lock application. Set window property. win id : %x",
- user_window);
-
- ecore_x_icccm_name_class_set(user_window, "LOCK_SCREEN",
- "LOCK_SCREEN");
-
- ecore_x_netwm_window_type_set(user_window,
- ECORE_X_WINDOW_TYPE_NOTIFICATION);
-
- utilx_set_system_notification_level(ecore_x_display_get
- (), user_window,
- UTILX_NOTIFICATION_LEVEL_NORMAL);
-
- utilx_set_window_opaque_state(ecore_x_display_get(),
- user_window,
- UTILX_OPAQUE_STATE_ON);
- }
- }
-}
-
-void
-lockd_window_set_window_effect(lockw_data * data, int lock_app_pid, void *event)
-{
- Ecore_X_Event_Window_Create *e = event;
- Ecore_X_Window user_window = 0;
- int pid = 0;
-
- user_window = get_user_created_window((Window) (e->win));
- ecore_x_netwm_pid_get(user_window, &pid);
-
- LOCKD_DBG("%s, %d", __func__, __LINE__);
-
- LOCKD_DBG("PID(%d) window created. (lock_app_pid : %d)\n", pid,
- lock_app_pid);
-
- if (lock_app_pid == pid) {
- if (_lockd_window_check_validate_rect
- (ecore_x_display_get(), user_window) == TRUE) {
- LOCKD_DBG
- ("This is lock application. Disable window effect. win id : %x\n",
- user_window);
-
- utilx_set_window_effect_state(ecore_x_display_get(),
- user_window, 0);
- }
- }
-}
-
-void
-lockd_window_mgr_ready_lock(void *data, lockw_data * lockw,
- Eina_Bool(*create_cb) (void *, int, void *),
- Eina_Bool(*show_cb) (void *, int, void *))
-{
- Ecore_X_Window xwin;
-
- if (lockw == NULL) {
- LOCKD_ERR("lockw is NULL.");
- return;
- }
-
- lockw->h_wincreate =
- ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE, create_cb,
- data);
- lockw->h_winshow =
- ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, show_cb, data);
-
- xwin = lockw->input_x_window;
- utilx_grab_key(ecore_x_display_get(), xwin, KEY_SELECT, EXCLUSIVE_GRAB);
-
- lockw->h_keydown =
- ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
- _lockd_window_key_down_cb, NULL);
-}
-
-void lockd_window_mgr_finish_lock(lockw_data * lockw)
-{
- Ecore_X_Window xwin;
-
- if (lockw == NULL) {
- LOCKD_ERR("lockw is NULL.");
- return;
- }
- if (lockw->h_wincreate != NULL) {
- ecore_event_handler_del(lockw->h_wincreate);
- lockw->h_wincreate = NULL;
- }
- if (lockw->h_winshow != NULL) {
- ecore_event_handler_del(lockw->h_winshow);
- lockw->h_winshow = NULL;
- }
-
- xwin = lockw->input_x_window;
- utilx_ungrab_key(ecore_x_display_get(), xwin, KEY_SELECT);
-
- if (lockw->h_keydown != NULL) {
- ecore_event_handler_del(lockw->h_keydown);
- lockw->h_keydown = NULL;
- }
-}
-
-lockw_data *lockd_window_init(void)
-{
- lockw_data *lockw = NULL;
- Ecore_X_Window input_x_window;
- Ecore_X_Window root_window;
- long pid;
-
- lockw = (lockw_data *) malloc(sizeof(lockw_data));
- memset(lockw, 0x0, sizeof(lockw_data));
-
- pid = getpid();
-
- input_x_window = ecore_x_window_input_new(0, 0, 0, 1, 1);
- ecore_x_icccm_title_set(input_x_window, "lock-daemon-input-window");
- ecore_x_netwm_name_set(input_x_window, "lock-daemon-input-window");
- ecore_x_netwm_pid_set(input_x_window, pid);
- LOCKD_DBG("Created input window : %p", input_x_window);
- lockw->input_x_window = input_x_window;
-
- root_window = ecore_x_window_root_first_get();
- ecore_x_window_client_sniff(root_window);
-
- return lockw;
-}
diff --git a/packaging/starter.service b/packaging/starter.service
new file mode 100755
index 0000000..78fe1b9
--- /dev/null
+++ b/packaging/starter.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Start the "starter" program
+After=wm_ready.service ac.service system-server.service launchpad-preload.service
+
+
+[Service]
+Type=forking
+ExecStart=/etc/init.d/rd3starter
+Restart=always
+RestartSec=0
+KillSignal=SIGKILL
+
+[Install]
+WantedBy=tizen-system.target
diff --git a/packaging/starter.spec b/packaging/starter.spec
index ab4196b..2510b38 100755
--- a/packaging/starter.spec
+++ b/packaging/starter.spec
@@ -1,24 +1,60 @@
+#sbs-git:slp/pkgs/s/starter starter 0.3 f75832f2c50c8930cf1a6bfcffbac648bcde87d9
Name: starter
Summary: starter
-Version: 0.4.11
+Version: 0.5.52
Release: 1
Group: TO_BE/FILLED_IN
-License: Flora Software License
+License: Apache-2.0
Source0: starter-%{version}.tar.gz
-Requires(post): /usr/bin/vconftool
+Source1: starter.service
+Source2: wait-lock.service
BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(tapi)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(ail)
+BuildRequires: pkgconfig(appcore-efl)
BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
+BuildRequires: pkgconfig(capi-system-media-key)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+
+%if "%{?tizen_profile_name}" == "mobile"
+BuildRequires: tts
+BuildRequires: tts-devel
+BuildRequires: pkgconfig(capi-message-port)
+%endif
+
+BuildRequires: pkgconfig(feedback)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(edbus)
+BuildRequires: pkgconfig(eet)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(ui-gadget-1)
BuildRequires: pkgconfig(utilX)
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(xcomposite)
+BuildRequires: pkgconfig(xext)
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(deviced)
+BuildRequires: pkgconfig(edbus)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: model-build-features
+BuildRequires: cmake
+BuildRequires: edje-bin
+BuildRequires: gettext
+BuildRequires: gettext-tools
+Requires(post): /usr/bin/vconftool
+Requires: sys-assert
%description
Description: Starter
@@ -27,15 +63,37 @@ Description: Starter
%prep
%setup -q
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-
%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
-make -j1
+%if "%{?tizen_profile_name}" == "mobile"
+echo "tizen_profile_name is 'mobile'"
+%define STARTER_FEATURE_LITE "ENABLE"
+export CFLAGS="$CFLAGS -DFEATURE_LITE"
+export CXXFLAGS="$CXXFLAGS -DFEATURE_LITE"
+%endif
+
+cmake . -DSTARTER_FEATURE_LITE=%{STARTER_FEATURE_LITE} -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make
+make -j1
%install
rm -rf %{buildroot}
%make_install
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/starter.service
+ln -s ../starter.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/starter.service
+mkdir -p %{buildroot}%{_libdir}/systemd/system/tizen-system.target.wants
+install -m 0644 %SOURCE2 %{buildroot}%{_libdir}/systemd/system/wait-lock.service
+ln -s ../wait-lock.service %{buildroot}%{_libdir}/systemd/system/tizen-system.target.wants/
+mkdir -p %{buildroot}/usr/share/license
+cp -f LICENSE %{buildroot}/usr/share/license/%{name}
+mkdir -p %{buildroot}/opt/data/home-daemon
%post
change_file_executable()
@@ -46,22 +104,54 @@ change_file_executable()
fi
}
-vconftool set -t int "memory/starter/sequence" 0 -i -u 5000 -g 5000
-vconftool set -t string file/private/lockscreen/pkgname "org.tizen.draglock" -u 5000 -g 5000
-vconftool -i set -t int memory/idle_lock/state "0" -u 5000 -g 5000
+GOPTION="-u 5000 -f"
+SOPTION="-s system::vconf_inhouse"
+POPTION="-s starter_private::vconf"
+LOPTION="-s system::vconf_setting"
+
+vconftool set -t string file/private/lockscreen/pkgname "org.tizen.lockscreen" $GOPTION $POPTION
+vconftool set -t string file/private/lockscreen/default_pkgname "org.tizen.lockscreen" $GOPTION $POPTION
+
+vconftool set -t int memory/idle_lock/state "0" -i $GOPTION $LOPTION
+vconftool set -t bool memory/lockscreen/phone_lock_verification 0 -i $GOPTION $SOPTION
+
+vconftool set -t int memory/idle-screen/safemode "0" -i $GOPTION $SOPTION
+
+vconftool set -t int "memory/starter/sequence" 0 -i $GOPTION $SOPTION
+vconftool set -t int "memory/starter/use_volume_key" 0 -i $GOPTION $SOPTION
+vconftool set -t int db/starter/missed_call "0" -i -u 5000 -f $SOPTION
+vconftool set -t int db/starter/unread_message "0" -i -u 5000 -f $SOPTION
+
+vconftool set -t string db/svoice/package_name "com.samsung.svoice" -i -u 5000 -f -s svoice::vconf
+
+vconftool set -t string memory/idle-screen/focused_package "" -i $GOPTION $POPTION
+vconftool set -t int memory/idle-screen/is_idle_screen_launched 0 -i $GOPTION $POPTION
+
+vconftool set -t bool memory/lockscreen/sview_state 0 -i $GOPTION $SOPTION
+
+vconftool set -t int memory/lockscreen/security_auto_lock 1 -i $GOPTION $SOPTION
+
+vconftool set -t int file/private/lockscreen/bt_out -70 $GOPTION $POPTION
+vconftool set -t int file/private/lockscreen/bt_in -60 $GOPTION $POPTION
-ln -sf /etc/init.d/rd4starter /etc/rc.d/rc4.d/S81starter
-ln -sf /etc/init.d/rd3starter /etc/rc.d/rc3.d/S43starter
+mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -s %{_libdir}/systemd/system/wait-lock.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
-change_file_executable /etc/opt/init/starter.init.sh
-/etc/opt/init/starter.init.sh
+#ln -sf /etc/init.d/rd4starter /etc/rc.d/rc4.d/S81starter
+#ln -sf /etc/init.d/rd4starter /etc/rc.d/rc3.d/S81starter
sync
%files
+%manifest starter.manifest
%defattr(-,root,root,-)
-/etc/opt/init/starter.init.sh
%{_sysconfdir}/init.d/rd4starter
%{_sysconfdir}/init.d/rd3starter
%{_bindir}/starter
-%{_libdir}/liblock-daemon.so
+%{_libdir}/systemd/system/starter.service
+%{_libdir}/systemd/system/multi-user.target.wants/starter.service
+%{_libdir}/systemd/system/wait-lock.service
+%{_libdir}/systemd/system/tizen-system.target.wants/wait-lock.service
+/usr/share/license/%{name}
+/opt/data/home-daemon
+/usr/share/locale/*/LC_MESSAGES/*
diff --git a/packaging/wait-lock.service b/packaging/wait-lock.service
new file mode 100755
index 0000000..1147161
--- /dev/null
+++ b/packaging/wait-lock.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=wait lockscreen
+After=tizen-boot.target boot-animation.service
+Requires=tizen-boot.target
+Before=tizen-system.target
+ConditionPathExists=|/tmp/.passwordlock
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c 'while [ -e /tmp/.passwordlock ]; do sleep 0.5 ; done'
+TimeoutSec=7s
+
+[Install]
+WantedBy=tizen-system.target
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
new file mode 100755
index 0000000..51ec894
--- /dev/null
+++ b/po/CMakeLists.txt
@@ -0,0 +1,24 @@
+# for i18n
+
+SET(POFILES az.po bg.po ca.po cs.po da.po de.po el_GR.po en.po en_US.po es_ES.po et.po eu.po fi.po fr_CA.po fr.po gl.po hr.po hu.po hy.po is.po it_IT.po ka.po kk.po ko_KR.po lt.po lv.po mn_MN.po nb.po nl.po pl.po pt_BR.po pt_PT.po ro.po ru_RU.po sk.po sl.po sr.po sv.po tr_TR.po uk.po uz.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+ SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+ MESSAGE("PO: ${pofile}")
+ GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+ GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+ SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${moFile}
+ COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+ DEPENDS ${absPofile}
+ )
+ INSTALL(FILES ${moFile}
+ DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
diff --git a/po/az.po b/po/az.po
new file mode 100644
index 0000000..f9ef67f
--- /dev/null
+++ b/po/az.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekran oxuyucusu aktivdir."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekran oxuyucusu qeyri-aktivdir."
+
diff --git a/po/bg.po b/po/bg.po
new file mode 100644
index 0000000..2128e0a
--- /dev/null
+++ b/po/bg.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Екранният четец е активиран."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Екранният четец е деактивиран."
+
diff --git a/po/ca.po b/po/ca.po
new file mode 100644
index 0000000..e41dbf4
--- /dev/null
+++ b/po/ca.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lector de pantalla habilitat."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lector de pantalla deshabilitat."
+
diff --git a/po/cs.po b/po/cs.po
new file mode 100644
index 0000000..f2a093b
--- /dev/null
+++ b/po/cs.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Čtečka displeje byla zapnuta."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Čtečka displeje byla vypnuta."
+
diff --git a/po/da.po b/po/da.po
new file mode 100644
index 0000000..04b2a51
--- /dev/null
+++ b/po/da.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Skærmlæser aktiveret."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Skærmlæser deaktiveret."
+
diff --git a/po/de.po b/po/de.po
new file mode 100644
index 0000000..516f1da
--- /dev/null
+++ b/po/de.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Bildschirmleseprogramm aktiviert."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Bildschirmleseprogramm deaktiviert."
+
diff --git a/po/el_GR.po b/po/el_GR.po
new file mode 100644
index 0000000..00f22d6
--- /dev/null
+++ b/po/el_GR.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Η εφαρμογή ανάγνωσης οθόνης ενεργοποιήθηκε."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Η εφαρμογή ανάγνωσης οθόνης απενεργοποιήθηκε."
+
diff --git a/po/en.po b/po/en.po
new file mode 100644
index 0000000..41ba44d
--- /dev/null
+++ b/po/en.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Screen reader enabled."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Screen reader disabled."
+
diff --git a/po/en_US.po b/po/en_US.po
new file mode 100644
index 0000000..2a2607e
--- /dev/null
+++ b/po/en_US.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Screen reader turned on."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Screen reader turned off."
+
diff --git a/po/es_ES.po b/po/es_ES.po
new file mode 100644
index 0000000..7dd881f
--- /dev/null
+++ b/po/es_ES.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lector de pantalla activado."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lector de pantalla desactivado."
+
diff --git a/po/es_US.po b/po/es_US.po
new file mode 100644
index 0000000..7dd881f
--- /dev/null
+++ b/po/es_US.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lector de pantalla activado."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lector de pantalla desactivado."
+
diff --git a/po/et.po b/po/et.po
new file mode 100644
index 0000000..7319504
--- /dev/null
+++ b/po/et.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekraanilugeja on aktiveeritud."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekraanilugeja on desaktiveeritud."
+
diff --git a/po/eu.po b/po/eu.po
new file mode 100644
index 0000000..c8955fa
--- /dev/null
+++ b/po/eu.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Pantaila irakurgailua gaituta."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Pantaila irakurgailua ezgaituta."
+
diff --git a/po/fi.po b/po/fi.po
new file mode 100644
index 0000000..7a43509
--- /dev/null
+++ b/po/fi.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Näytönlukija on käytössä."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Näytönlukija on poistettu käytöstä."
+
diff --git a/po/fr.po b/po/fr.po
new file mode 100644
index 0000000..7efde4d
--- /dev/null
+++ b/po/fr.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lecteur d'écran activé."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lecteur d'écran désactivé."
+
diff --git a/po/fr_CA.po b/po/fr_CA.po
new file mode 100644
index 0000000..7efde4d
--- /dev/null
+++ b/po/fr_CA.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lecteur d'écran activé."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lecteur d'écran désactivé."
+
diff --git a/po/gl.po b/po/gl.po
new file mode 100644
index 0000000..7dd881f
--- /dev/null
+++ b/po/gl.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lector de pantalla activado."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lector de pantalla desactivado."
+
diff --git a/po/hr.po b/po/hr.po
new file mode 100644
index 0000000..b4081ad
--- /dev/null
+++ b/po/hr.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Isključen čitač zaslona."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Uključen čitač zaslona."
+
diff --git a/po/hu.po b/po/hu.po
new file mode 100644
index 0000000..c6dad99
--- /dev/null
+++ b/po/hu.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Képernyőolvasó engedélyezve."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Képernyőolvasó letiltva."
+
diff --git a/po/hy.po b/po/hy.po
new file mode 100644
index 0000000..df2b103
--- /dev/null
+++ b/po/hy.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Էկրանի ընթերցողը՝ միաց:"
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Էկրանի ընթերցողը՝ անջատ:"
+
diff --git a/po/is.po b/po/is.po
new file mode 100644
index 0000000..3618b8c
--- /dev/null
+++ b/po/is.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Kveikt á skjálesara."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Slökkt á skjálesara."
+
diff --git a/po/it_IT.po b/po/it_IT.po
new file mode 100644
index 0000000..46b8a59
--- /dev/null
+++ b/po/it_IT.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Lettura dello schermo attivata."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Lettura dello schermo disattivata."
+
diff --git a/po/ka.po b/po/ka.po
new file mode 100644
index 0000000..3ff5ebf
--- /dev/null
+++ b/po/ka.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "ეკრანის წამკითხველი ჩართულია."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "ეკრანის წამკითხველი გამორთულია."
+
diff --git a/po/kk.po b/po/kk.po
new file mode 100644
index 0000000..f307ec9
--- /dev/null
+++ b/po/kk.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Экран оқу құралы қосылды."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Экран оқу құралы өшірілді."
+
diff --git a/po/ko_KR.po b/po/ko_KR.po
new file mode 100644
index 0000000..42cb3ff
--- /dev/null
+++ b/po/ko_KR.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "스크린 리더를 실행하였습니다."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "스크린 리더를 해제하였습니다."
+
diff --git a/po/lt.po b/po/lt.po
new file mode 100644
index 0000000..9b58a9a
--- /dev/null
+++ b/po/lt.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekrano skaitytuvas įjungtas."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekrano skaitytuvas išjungtas."
+
diff --git a/po/lv.po b/po/lv.po
new file mode 100644
index 0000000..d3215f7
--- /dev/null
+++ b/po/lv.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekrāna lasītājs ir aktivizēts."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekrāna lasītājs ir deaktivizēts."
+
diff --git a/po/mn_MN.po b/po/mn_MN.po
new file mode 100644
index 0000000..52ca19a
--- /dev/null
+++ b/po/mn_MN.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Дэлгэцийн уншигчийг идэвхжүүлсэн."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Дэлгэцийн уншигчийг идэвхгүй болгосон."
+
diff --git a/po/nb.po b/po/nb.po
new file mode 100644
index 0000000..a942a8c
--- /dev/null
+++ b/po/nb.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Skjermleser aktivert."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Skjermleser deaktivert."
+
diff --git a/po/nl.po b/po/nl.po
new file mode 100644
index 0000000..8d1f208
--- /dev/null
+++ b/po/nl.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Schermlezer ingeschakeld."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Schermlezer uitgeschakeld."
+
diff --git a/po/pl.po b/po/pl.po
new file mode 100644
index 0000000..68bd811
--- /dev/null
+++ b/po/pl.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Czytnik ekranu włączony."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Czytnik ekranu wyłączony."
+
diff --git a/po/pt_BR.po b/po/pt_BR.po
new file mode 100644
index 0000000..fd10756
--- /dev/null
+++ b/po/pt_BR.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Leitor de tela ativado."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Leitor de tela desativado."
+
diff --git a/po/pt_PT.po b/po/pt_PT.po
new file mode 100644
index 0000000..6e8c871
--- /dev/null
+++ b/po/pt_PT.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Leitor de ecrã activado."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Leitor de ecrã desactivado."
+
diff --git a/po/ro.po b/po/ro.po
new file mode 100644
index 0000000..a499c01
--- /dev/null
+++ b/po/ro.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Cititor de ecran activat."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Cititor de ecran dezactivat."
+
diff --git a/po/ru_RU.po b/po/ru_RU.po
new file mode 100644
index 0000000..9048cf9
--- /dev/null
+++ b/po/ru_RU.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Чтение с экрана включено."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Чтение с экрана отключено."
+
diff --git a/po/sk.po b/po/sk.po
new file mode 100644
index 0000000..870138a
--- /dev/null
+++ b/po/sk.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Čítačka obrazovky je zapnutá."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Čítačka obrazovky je vypnutá."
+
diff --git a/po/sl.po b/po/sl.po
new file mode 100644
index 0000000..bea56e7
--- /dev/null
+++ b/po/sl.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Bralnik zaslona je omogočen."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Bralnik zaslona je onemogočen."
+
diff --git a/po/sr.po b/po/sr.po
new file mode 100644
index 0000000..68c4406
--- /dev/null
+++ b/po/sr.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Čitač ekrana je omogućen."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Čitač ekrana je onemogućen."
+
diff --git a/po/sv.po b/po/sv.po
new file mode 100644
index 0000000..9c12889
--- /dev/null
+++ b/po/sv.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Skärmläsare aktiverad."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Skärmläsare inaktiverad."
+
diff --git a/po/tr_TR.po b/po/tr_TR.po
new file mode 100644
index 0000000..10a566a
--- /dev/null
+++ b/po/tr_TR.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekran okuyucusu etkinleştirildi."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekran okuyucusu devre dışı bırakıldı."
+
diff --git a/po/uk.po b/po/uk.po
new file mode 100644
index 0000000..db1dd24
--- /dev/null
+++ b/po/uk.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Програму читання з екрана увімкнено."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Програму читання з екрана вимкнено."
+
diff --git a/po/uz.po b/po/uz.po
new file mode 100644
index 0000000..37a0168
--- /dev/null
+++ b/po/uz.po
@@ -0,0 +1,6 @@
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"
+msgstr "Ekranni o‘qish vositasi yoqildi."
+
+msgid "IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"
+msgstr "Ekranni o‘qish vositasi o‘chirildi."
+
diff --git a/rd3starter b/rd3starter
index 745eafa..aced30e 100755
--- a/rd3starter
+++ b/rd3starter
@@ -6,5 +6,22 @@
# sleep 0.1
#done
+while [ ! -f /tmp/amd_ready ];
+do
+ /bin/sleep 0.1
+done
+
+vconf_set_safemode()
+{
+ if [ -f /opt/etc/.safeboot ]
+ then
+ /usr/bin/vconftool set -t int memory/idle-screen/safemode "1" -f
+ else
+ /usr/bin/vconftool set -t int memory/idle-screen/safemode "0" -f
+ fi
+}
+vconf_set_safemode
+
+echo -e "<2>[${_G}menu-daemon start${C_}]" > /dev/kmsg
/usr/bin/starter &
diff --git a/rd4starter b/rd4starter
index 60f35e6..409c90c 100755..100644
--- a/rd4starter
+++ b/rd4starter
@@ -1,4 +1,14 @@
#!/bin/sh
+vconf_set_safemode()
+{
+ if [ -f /opt/etc/.safeboot ]
+ then
+ /usr/bin/vconftool set -t int memory/idle-screen/safemode "1" -i -f
+ else
+ /usr/bin/vconftool set -t int memory/idle-screen/safemode "0" -i -f
+ fi
+}
+vconf_set_safemode
+echo -e "<2>[${_G}menu-daemon start${C_}]" > /dev/kmsg
/usr/bin/starter &
-
diff --git a/src/clock-mgr.c b/src/clock-mgr.c
new file mode 100755
index 0000000..01d147d
--- /dev/null
+++ b/src/clock-mgr.c
@@ -0,0 +1,807 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <ail.h>
+#include <bundle.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <vconf.h>
+#include <dd-display.h>
+#if 0 // Disable temporarily for TIZEN 2.3 build
+#include <message_port.h>
+#endif
+
+#include "starter_w.h"
+#include "dbus-util_w.h"
+#include "util.h"
+
+
+#define APP_CONTROL_OPERATION_MAIN_KEY "__APP_SVC_OP_TYPE__"
+#define APP_CONTROL_OPERATION_MAIN_VALUE "http://tizen.org/appcontrol/operation/main"
+#define APP_CONTROL_OPERATION_DEFAULT_VALUE "http://tizen.org/appcontrol/operation/default"
+
+
+#ifndef VCONFKEY_SHEALTH_VIEW_TYPE_STR
+#define VCONFKEY_SHEALTH_VIEW_TYPE_STR "memory/shealth/view_type"
+#endif
+
+#ifndef VCONFKEY_HERE_TBT_STATUS_INT
+#define VCONFKEY_HERE_TBT_STATUS_INT "memory/private/navigation/guidance"
+#endif
+
+#ifndef VCONFKEY_STARTER_RESERVED_APPS_STATUS
+#define VCONFKEY_STARTER_RESERVED_APPS_STATUS "memory/starter/reserved_apps_status" /* 2 digits for reserved apps & popup
+ * 10 : popup
+ * 01 : apps
+ * */
+#endif
+
+#ifndef VCONFKEY_SETTING_SIMPLE_CLOCK_MODE
+#define VCONFKEY_SETTING_SIMPLE_CLOCK_MODE "db/setting/simpleclock_mode"
+#endif
+
+
+
+#define W_LOCKSCREEN_PKGNAME "com.samsung.w-lockscreen"
+
+#define W_ALPM_CLOCK_PKGNAME "com.samsung.alpm-clock-manager"
+#define ALPM_CLOCK_OP "ALPM_CLOCK_OP"
+#define ALPM_CLOCK_SHOW "alpm_clock_show"
+#define ALPM_CLOCK_HIDE "alpm_clock_hide"
+
+#define HOME_OPERATION_KEY "home_op"
+#define POWERKEY_VALUE "powerkey"
+
+#define PM_UNLOCK_TIMER_SEC 0.3
+
+#define RESERVED_DISPLAY_MESSAGE_PORT_ID "Home.Reserved.Display"
+#define RESERVED_DISPLAY_MESSAGE_KEY_STATE "state"
+#define RESERVED_DISPLAY_MESSAGE_STATE_SHOW "show"
+#define RESERVED_DISPLAY_MESSAGE_STATE_HIDE "hide"
+#define RESERVED_DISPLAY_MESSAGE_STATE_POPUP_SHOW "popup_show"
+#define RESERVED_DISPLAY_MESSAGE_STATE_POPUP_HIDE "popup_hide"
+
+#define SHEALTH_SLEEP_PKGNAME "com.samsung.shealth.sleep"
+
+static int _check_reserved_popup_status(void *data)
+{
+ int val = 0;
+ int tmp = 0;
+ struct appdata *ad = (struct appdata *)data;
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return -1;
+ }
+
+ vconf_get_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, &val);
+
+ _W("Current reserved apps status : %x", val);
+
+ tmp = val;
+ tmp = tmp & 0x10;
+ if(tmp == 0x10){
+ if(aul_app_is_running(ad->reserved_popup_app_id) == 1){
+ return TRUE;
+ }
+ else{
+ _E("%s is not running now.", ad->reserved_popup_app_id);
+ ad->reserved_popup_app_id = NULL;
+ val = val ^ 0x10;
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ return FALSE;
+ }
+ }
+ else{
+ return FALSE;
+ }
+
+}
+
+static int _check_reserved_apps_status(void *data)
+{
+ int val = 0;
+ struct appdata *ad = (struct appdata *)data;
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return -1;
+ }
+
+ vconf_get_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, &val);
+
+ _W("Current reserved apps status : %x", val);
+
+ if(val > 0){
+ val = TRUE;
+ }
+ else{
+ val = FALSE;
+ }
+
+ return val;
+}
+
+static void reserved_apps_message_received_cb(int local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_port, bundle* msg)
+{
+ ret_if(remote_app_id == NULL);
+ ret_if(msg == NULL);
+ struct appdata *ad = starter_get_app_data();
+ Eina_List *l = NULL;
+ char *state = NULL;
+ char *data = NULL;
+ char *appid = NULL;
+ int count = 0;
+ int i = 0;
+ int val = 0;
+ int tmp = 0;
+
+ vconf_get_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, &val);
+ _W("current reserved apps status : %x", val);
+
+ state = bundle_get_val(msg, RESERVED_DISPLAY_MESSAGE_KEY_STATE);
+ _W("appid [%s], msg value[%s]", remote_app_id, state);
+ if (strncmp(state, RESERVED_DISPLAY_MESSAGE_STATE_SHOW, strlen(state)) == 0) {
+ //reserved app is start
+ EINA_LIST_FOREACH(ad->reserved_apps_list, l, data){
+ if(strncmp(data, remote_app_id, strlen(data)) == 0){
+ _W("%s is already in the list", data);
+ ad->reserved_apps_list = eina_list_remove_list(ad->reserved_apps_list, l);
+ break;
+ }
+ }
+ appid = strdup(remote_app_id);
+ ad->reserved_apps_list = eina_list_append(ad->reserved_apps_list, appid);
+ val = val | 0x01;
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else if (strncmp(state, RESERVED_DISPLAY_MESSAGE_STATE_HIDE, strlen(state)) == 0){
+ //reserved app is stop
+ EINA_LIST_FOREACH(ad->reserved_apps_list, l, data){
+ if(strncmp(data, remote_app_id, strlen(data)) == 0){
+ ad->reserved_apps_list = eina_list_remove_list(ad->reserved_apps_list, l);
+ break;
+ }
+ }
+ count = eina_list_count(ad->reserved_apps_list);
+ if(count == 0){
+ _W("there is no reserved app.");
+ tmp = val;
+ val = tmp & 0x01;
+ if(val == 0x01){
+ tmp = tmp ^ 0x01;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, tmp);
+ _W("now reserved apps status %x", tmp);
+ }
+ }
+ else if (strncmp(state, RESERVED_DISPLAY_MESSAGE_STATE_POPUP_SHOW, strlen(state)) == 0){
+ //reserved popup is show
+ ad->reserved_popup_app_id = strdup(remote_app_id);
+ val = val | 0x0010;
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else if (strncmp(state, RESERVED_DISPLAY_MESSAGE_STATE_POPUP_HIDE, strlen(state)) == 0){
+ //reserved popup is hide
+ if(ad->reserved_popup_app_id == NULL){
+ _E("there is no reserved popup already");
+ }
+ else{
+ if(strncmp(ad->reserved_popup_app_id, remote_app_id, strlen(ad->reserved_popup_app_id)) == 0){
+ ad->reserved_popup_app_id = NULL;
+ tmp = val;
+ val = tmp & 0x10;
+ if(val == 0x10){
+ tmp = tmp ^ 0x10;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, tmp);
+ _W("now reserved apps status %x", tmp);
+ }
+ }
+ }
+ else{
+ // no info
+ }
+ EINA_LIST_REVERSE_FOREACH(ad->reserved_apps_list, l, data){
+ _W("%d. %s", i++, data);
+ }
+}
+#if 0
+static void _shealth_view_type_changed_cb(keynode_t* node, void *data)
+{
+ char *val = NULL;
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("%s, %d", __func__, __LINE__);
+
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return;
+ }
+
+ if (node) {
+ val = vconf_keynode_get_str(node);
+ } else {
+ val = vconf_get_str(VCONFKEY_SHEALTH_VIEW_TYPE_STR);
+ }
+
+ clock_mgr_set_reserved_apps_status(val, STARTER_RESERVED_APPS_SHEALTH, ad);
+}
+
+static void _here_navigation_status_changed_cb(keynode_t* node, void *data)
+{
+ int val = NULL;
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("%s, %d", __func__, __LINE__);
+
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return;
+ }
+
+ if (node) {
+ val = vconf_keynode_get_int(node);
+ } else {
+ vconf_get_int(VCONFKEY_HERE_TBT_STATUS_INT, &val);
+ }
+
+ clock_mgr_set_reserved_apps_status(val, STARTER_RESERVED_APPS_HERE, ad);
+}
+
+void clock_mgr_set_reserved_apps_status(void *info, int type, void *data){
+ char *str_info = NULL;
+ int int_info = NULL;
+ int val = 0;
+ int tmp = 0;
+ struct appdata *ad = (struct appdata *)data;
+ _D("%s, %d", __func__, __LINE__);
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return;
+ }
+
+ vconf_get_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, &val);
+ _W("current reserved apps status : %x", val);
+
+ switch(type){
+ case STARTER_RESERVED_APPS_SHEALTH:{
+ str_info = (char *)info;
+ _W("Shealth status is changed (%s)", str_info);
+ if (strncmp(str_info, "exercise", strlen(str_info)) == 0){
+ val = val | 0x1000;
+ if(val >= 0x1100){
+ val = val ^ 0x0100;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else if (strncmp(str_info, "sleep", strlen(str_info)) == 0){
+ val = val | 0x0100;
+ if(val >= 0x1100){
+ val = val ^ 0x1000;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else{
+ tmp = val;
+ val = tmp & 0x1000;
+ if(val == 0x1000){
+ tmp = tmp ^ 0x1000;
+ }
+ val = tmp & 0x0100;
+ if(val == 0x0100){
+ tmp = tmp ^ 0x0100;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, tmp);
+ _W("now reserved apps status %x", tmp);
+ }
+ break;
+ }
+ case STARTER_RESERVED_APPS_NIKE:{
+ int_info = (int)info;
+ _W("Nike status is changed (%d)", int_info);
+ if(int_info == 1){
+ val = val | 0x0010;
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else{
+ tmp = val;
+ val = tmp & 0x0010;
+ if(val == 0x0010){
+ tmp = tmp ^ 0x0010;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, tmp);
+ _W("now reserved apps status %x", tmp);
+ }
+ break;
+ }
+ case STARTER_RESERVED_APPS_HERE:{
+ int_info = (int)info;
+ _W("Here status is changed (%d)", int_info);
+ if(int_info == 1){
+ val = val | 0x0001;
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, val);
+ _W("now reserved apps status %x", val);
+ }
+ else{
+ tmp = val;
+ val = tmp & 0x0001;
+ if(val == 0x0001){
+ tmp = tmp ^ 0x0001;
+ }
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, tmp);
+ _W("now reserved apps status %x", tmp);
+ }
+ break;
+ }
+ default:{
+ _E("Unknown reserved app.");
+ break;
+ }
+ }
+ return 0;
+}
+#endif
+
+static void _wake_up_setting_changed_cb(keynode_t* node, void *data)
+{
+ int val = 0;
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("%s, %d", __func__, __LINE__);
+
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return;
+ }
+
+ if(vconf_get_int(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, &val) < 0) {
+ _E("Failed to get VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING");
+ val = 1;
+ }
+ ad->wake_up_setting = val;
+ _W("wake_up_setting is changed to [%d]", ad->wake_up_setting);
+}
+
+static void _ambient_mode_setting_changed_cb(keynode_t* node, void *data)
+{
+ int ambient_mode = 0;
+ struct appdata *ad = (struct appdata *)data;
+ ret_if(!ad);
+
+ ambient_mode = vconf_keynode_get_bool(node);
+ _D("ambient mode : %d", ambient_mode);
+
+ if (ambient_mode) {
+ _D("launch w-clock-viewer");
+ ad->pid_clock_viewer = w_launch_app(W_CLOCK_VIEWER_PKGNAME, NULL);
+ } else {
+ _D("kill w-clock-viewer(%d)", ad->pid_clock_viewer);
+ if (ad->pid_clock_viewer > 0) {
+ aul_kill_pid(ad->pid_clock_viewer);
+ ad->pid_clock_viewer = 0;
+ }
+ }
+
+ ad->ambient_mode = ambient_mode;
+ _W("ambient_mode_setting is changed to [%d]", ad->ambient_mode);
+}
+
+
+static Eina_Bool _w_lcdoff_idler_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("%s, %d", __func__, __LINE__);
+
+ w_open_app(ad->home_pkgname);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _w_launch_pm_unlock_idler_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("%s, %d", __func__, __LINE__);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _pm_unlock_timer_cb(void *data){
+ _D("%s, %d", __func__, __LINE__);
+ ecore_idler_add(_w_launch_pm_unlock_idler_cb, data);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static void _notify_pm_lcdoff_cb(keynode_t * node, void *data)
+{
+
+ int ret = -1;
+ int setup_wizard_state = -1;
+ bundle *b = NULL;
+ int lock_type = 0;
+ int tutorial_state = -1;
+ Eina_List *l = NULL;
+ char *info = NULL;
+ int count = 0;
+ int lcdoff_source = vconf_keynode_get_int(node);
+ struct appdata *ad = (struct appdata *)data;
+
+
+ if (ad == NULL) {
+ _E("ad is NULL");
+ return;
+ }
+
+ if (lcdoff_source < 0) {
+ _E("Cannot get VCONFKEY, error (%d)", lcdoff_source);
+ return;
+ }
+
+ _W("LCD OFF by lcd off source[%d], wake_up_setting[%d], ALPM_clock_state[%d]", lcdoff_source, ad->wake_up_setting, ad->ALPM_clock_state);
+
+#if 0
+ if(csc_feature_get_bool(CSC_FEATURE_DEF_BOOL_HOME_LAUNCH_LOCK_WHEN_LCD_ON) == CSC_FEATURE_BOOL_TRUE){
+ _E("CHC bin.");
+ vconf_get_int(VCONFKEY_SETAPPL_PRIVACY_LOCK_TYPE_INT, &lock_type);
+ if(lock_type == 1){
+ int r = 0;
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ _E("CHC bin & lock type is %d", lock_type);
+ r = w_launch_app(W_LOCKSCREEN_PKGNAME, NULL);
+
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ }
+ }
+#endif
+
+ if (vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &setup_wizard_state) < 0) {
+ _E("Failed to get [%s]", VCONFKEY_SETUP_WIZARD_STATE);
+ } else {
+ if (setup_wizard_state == VCONFKEY_SETUP_WIZARD_LOCK) {
+ _E("don't react for lcd off, setup wizard state is [%d]", setup_wizard_state);
+ return;
+ }
+ }
+
+
+
+#if 0
+ if (_check_reserved_apps_status(ad)) {
+ _E("_check_running_heath = > don't react for lcd off except ALPM");
+ if (ad->ambient_mode == 1) {
+ //Step1. Launch ALPM clock
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return;
+ }
+ //bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+ bundle_add(b, ALPM_CLOCK_OP, ALPM_CLOCK_SHOW);
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ ad->pid_ALPM_clock = 0;
+ ret = w_launch_app(W_ALPM_CLOCK_PKGNAME, b);
+ if (ret >= 0) {
+ ad->pid_ALPM_clock =ret;
+ _SECURE_D("[%s] is launched, pid=[%d]", W_ALPM_CLOCK_PKGNAME, ad->pid_ALPM_clock );
+ }
+ if(b){
+ bundle_free(b);
+ }
+ //Step2. Do not raise Homescreen
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ }
+ return;
+ }
+
+
+ if (ad->wake_up_setting == SETTING_WAKE_UP_GESTURE_CLOCK) {
+ //Step1. Launch ALPM clock
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return;
+ }
+ //bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+ bundle_add(b, ALPM_CLOCK_OP, ALPM_CLOCK_SHOW);
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ ad->pid_ALPM_clock = 0;
+ ret = w_launch_app(W_ALPM_CLOCK_PKGNAME, b);
+ if (ret >= 0) {
+ ad->pid_ALPM_clock =ret;
+ _SECURE_D("[%s] is launched, pid=[%d]", W_ALPM_CLOCK_PKGNAME, ad->pid_ALPM_clock );
+ }
+ if(b) {
+ bundle_free(b);
+ }
+
+ if(vconf_get_int("db/private/com.samsung.w-home/tutorial", &tutorial_state) < 0) {
+ _E("Failed to get tutorial status");
+
+ }
+ if(!tutorial_state) {
+ //Step2. Raise Homescreen
+ w_open_app(ad->home_pkgname);
+ }
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ } else if (ad->ambient_mode == 1) {
+
+ //Step1. Launch ALPM clock
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return;
+ }
+ //bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+ bundle_add(b, ALPM_CLOCK_OP, ALPM_CLOCK_SHOW);
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ ad->pid_ALPM_clock = 0;
+ ret = w_launch_app(W_ALPM_CLOCK_PKGNAME, b);
+ if (ret >= 0) {
+ ad->pid_ALPM_clock =ret;
+ _SECURE_D("[%s] is launched, pid=[%d]", W_ALPM_CLOCK_PKGNAME, ad->pid_ALPM_clock );
+ }
+ if(b) {
+ bundle_free(b);
+ }
+ //Step2. Do not raise Homescreen
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ }
+
+
+#else
+ if(_check_reserved_popup_status(ad)){
+ _W("reserved popup is on top. do nothing");
+ if((ad->ambient_mode == 1) && (ad->ALPM_clock_state == 0)){
+ starter_dbus_alpm_clock_signal_send(ad);
+ }
+ return;
+ }
+
+ if (_check_reserved_apps_status(ad)) {
+ _W("reserved app is running now. raise it.");
+
+ EINA_LIST_FOREACH(ad->reserved_apps_list, l, info){
+ if(strncmp(info, SHEALTH_SLEEP_PKGNAME, strlen(info)) == 0){
+ _W("%s is in the list. check running state", info);
+ if(aul_app_is_running(info) == 1){
+ _W("%s is now running. raise it.", info);
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ w_open_app(info);
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ return;
+ }
+ else{
+ _W("%s is not running now", info);
+ ad->reserved_apps_list = eina_list_remove_list(ad->reserved_apps_list, l);
+ break;
+ }
+ }
+ }
+
+ EINA_LIST_REVERSE_FOREACH(ad->reserved_apps_list, l, info){
+ if(aul_app_is_running(info) == 1){
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ w_open_app(info);
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+ break;
+ }
+ else{
+ _W("%s is not running now", info);
+ ad->reserved_apps_list = eina_list_remove_list(ad->reserved_apps_list, l);
+ continue;
+ }
+ }
+ count = eina_list_count(ad->reserved_apps_list);
+ if(count == 0){
+ _W("there is no reserved app.");
+ vconf_set_int(VCONFKEY_STARTER_RESERVED_APPS_STATUS, 0);
+ }
+ }
+
+ if ((ad->ambient_mode == 1) && (ad->ALPM_clock_state == 0)) {
+#if 0
+ //Step1. Launch ALPM clock
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return;
+ }
+ //bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+ bundle_add(b, ALPM_CLOCK_OP, ALPM_CLOCK_SHOW);
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ ad->pid_ALPM_clock = 0;
+ ret = w_launch_app(W_ALPM_CLOCK_PKGNAME, b);
+ if (ret >= 0) {
+ ad->pid_ALPM_clock =ret;
+ _SECURE_D("[%s] is launched, pid=[%d]", W_ALPM_CLOCK_PKGNAME, ad->pid_ALPM_clock );
+ }
+ if(b){
+ bundle_free(b);
+ }
+ //Step2. Do not raise Homescreen
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+#endif
+ starter_dbus_alpm_clock_signal_send(ad);
+ } else {
+ int val = 0;
+ if(vconf_get_bool(VCONFKEY_SETTING_SIMPLE_CLOCK_MODE, &val) < 0) {
+ _E("Failed to get VCONFKEY_SETTING_SIMPLE_CLOCK_MODE");
+ }
+
+
+ // Not yet fix the setting concept.
+ //if ((_check_reserved_apps_status(ad) == FALSE) && (val == TRUE) && (ad->wake_up_setting == SETTING_WAKE_UP_GESTURE_CLOCK)) {
+ if ((_check_reserved_apps_status(ad) == FALSE) && (ad->wake_up_setting == SETTING_WAKE_UP_GESTURE_CLOCK) && (ad->ALPM_clock_state == 0)) {
+ //_W("Not reserved apss status AND wake_up_setting is CLOCK AND simple clock setting is [%d] => show simple clock..!!", val);
+ _W("Not reserved apss status AND wake_up_setting is CLOCK => show simple clock..!!");
+#if 0
+ //Step1. Launch ALPM clock
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return;
+ }
+ //bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+ bundle_add(b, ALPM_CLOCK_OP, ALPM_CLOCK_SHOW);
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ ad->pid_ALPM_clock = 0;
+ ret = w_launch_app(W_ALPM_CLOCK_PKGNAME, b);
+ if (ret >= 0) {
+ ad->pid_ALPM_clock =ret;
+ _SECURE_D("[%s] is launched, pid=[%d]", W_ALPM_CLOCK_PKGNAME, ad->pid_ALPM_clock );
+ }
+ if(b){
+ bundle_free(b);
+ }
+ //Step2. Do not raise Homescreen
+ ecore_timer_add(PM_UNLOCK_TIMER_SEC, _pm_unlock_timer_cb, ad);
+#endif
+ starter_dbus_alpm_clock_signal_send(ad);
+ }
+ }
+#endif
+}
+
+
+void init_clock_mgr(void *data)
+{
+ int status = -1;
+ int ret = -1;
+ int val = -1;
+ int reserved_apps_msg_port_id = 0;
+ struct appdata *ad = (struct appdata *)data;
+
+ _W("init_clock_mgr.!!");
+#if 0
+ //register message port for reserved apps
+ if ((reserved_apps_msg_port_id = message_port_register_local_port(RESERVED_DISPLAY_MESSAGE_PORT_ID, reserved_apps_message_received_cb)) <= 0) {
+ _E("Failed to register reserved_apps message port cb");
+ }
+ _E("port_id:%d", reserved_apps_msg_port_id);
+ ad->reserved_apps_local_port_id = reserved_apps_msg_port_id;
+#endif
+ if(init_dbus_ALPM_clock_state_signal(ad) < 0) {
+ _E("Failed to init_dbus_ALPM_clock_state_signal");
+ }
+
+ //register wake up gesture setting changed.
+ if(vconf_get_int(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, &val) < 0) {
+ _E("Failed to get VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING");
+ val = 1;
+ }
+ ad->wake_up_setting = val;
+ _W("wake_up_setting : %d", ad->wake_up_setting);
+
+ if (vconf_notify_key_changed(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, _wake_up_setting_changed_cb, ad) < 0) {
+ _E("Failed to add the callback for VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING changed");
+ }
+
+ //register ambient mode changed.
+ if(vconf_get_bool(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, &val) < 0) {
+ _E("Failed to get VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL");
+ val = 0;
+ }
+ ad->ambient_mode = val;
+ _W("ambient_mode : %d", ad->ambient_mode);
+
+ if (vconf_notify_key_changed(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, _ambient_mode_setting_changed_cb, ad) < 0) {
+ _E("Failed to add the callback for VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL changed");
+ }
+
+ if (vconf_notify_key_changed(VCONFKEY_PM_LCDOFF_SOURCE, _notify_pm_lcdoff_cb, ad) != 0) {
+ _E("Fail vconf_notify_key_changed : VCONFKEY_PM_LCDOFF_SOURCE");
+ }
+
+#if 0
+ if (vconf_notify_key_changed(VCONFKEY_SHEALTH_VIEW_TYPE_STR, _shealth_view_type_changed_cb, ad) < 0) {
+ _E("Failed to add the callback for VCONFKEY_SHEALTH_VIEW_TYPE_STR changed");
+ }
+
+ if (vconf_notify_key_changed(VCONFKEY_HERE_TBT_STATUS_INT, _here_navigation_status_changed_cb, ad) < 0) {
+ _E("Failed to add the callback for VCONFKEY_HERE_TBT_STATUS_INT changed");
+ }
+#endif
+}
+
+
+
+void fini_clock_mgr(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ if(vconf_ignore_key_changed(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, _wake_up_setting_changed_cb) < 0) {
+ _E("Failed to ignore the VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING");
+ }
+
+ if(vconf_ignore_key_changed(VCONFKEY_PM_LCDOFF_SOURCE, _notify_pm_lcdoff_cb) < 0) {
+ _E("Failed to ignore the VCONFKEY_PM_LCDOFF_SOURCE");
+ }
+
+ if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, _ambient_mode_setting_changed_cb) < 0) {
+ _E("Failed to ignore the VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL");
+ }
+
+#if 0
+ if(vconf_ignore_key_changed(VCONFKEY_SHEALTH_VIEW_TYPE_STR, _shealth_view_type_changed_cb) < 0) {
+ _E("Failed to ignore the VCONFKEY_SHEALTH_VIEW_TYPE_STR");
+ }
+
+ if(vconf_ignore_key_changed(VCONFKEY_HERE_TBT_STATUS_INT, _here_navigation_status_changed_cb) < 0) {
+ _E("Failed to ignore the VCONFKEY_HERE_TBT_STATUS_INT");
+ }
+#endif
+
+#if 0 // Disable temporarily for TIZEN 2.3 build
+ if (ad->reserved_apps_local_port_id >= 0) {
+ if (message_port_unregister_local_port(ad->reserved_apps_local_port_id) != MESSAGE_PORT_ERROR_NONE) {
+ _E("Failed to unregister reserved apps message port cb");
+ }
+ }
+#endif
+
+}
+
+
+
+// End of a file
diff --git a/src/dbus-util.c b/src/dbus-util.c
new file mode 100755
index 0000000..ba47cbf
--- /dev/null
+++ b/src/dbus-util.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <E_DBus.h>
+#include <dbus/dbus-glib.h>
+
+#include "starter.h"
+#include "starter-util.h"
+#include "util.h"
+
+#define DBUS_HOME_BUS_NAME "org.tizen.coreapps.home"
+#define DBUS_HOME_RAISE_PATH "/Org/Tizen/Coreapps/home/raise"
+#define DBUS_HOME_RAISE_INTERFACE DBUS_HOME_BUS_NAME".raise"
+#define DBUS_HOME_RAISE_MEMBER "homeraise"
+
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+
+#define DEVICED_PATH DEVICED_OBJECT_PATH"/Process"
+#define DEVICED_INTERFACE DEVICED_INTERFACE_NAME".Process"
+
+#define DEVICED_SET_METHOD "oomadj_set"
+
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+static struct _info {
+ DBusConnection *connection;
+} s_info = {
+ .connection = NULL,
+};
+
+static DBusConnection *_dbus_connection_get(void) {
+ if (s_info.connection == NULL) {
+ _W("no connection for dbus. get dbus connection");
+ DBusError derror;
+ DBusConnection *connection = NULL;
+
+ dbus_error_init(&derror);
+ connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &derror);
+ if (connection == NULL) {
+ _E("Failed to get dbus connection:%s", derror.message);
+ dbus_error_free(&derror);
+ return NULL;
+ }
+ dbus_connection_setup_with_g_main(connection, NULL);
+ dbus_error_free(&derror);
+
+ s_info.connection = connection;
+ }
+
+ return s_info.connection;
+}
+
+static int _append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static int _invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r, ret;
+
+ DBusConnection *conn = NULL;
+
+ conn = (DBusConnection *)_dbus_connection_get();
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return -1;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return -EBADMSG;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ dbus_message_unref(msg);
+ return -EBADMSG;
+ }
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+ dbus_message_unref(msg);
+ if (!reply) {
+ _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+ dbus_error_free(&err);
+ return -EBADMSG;
+ }
+
+ return reply;
+}
+
+static int _dbus_message_send(const char *path, const char *interface, const char *member)
+{
+ int ret = 0;
+ DBusMessage *msg = NULL;
+ DBusConnection *conn = NULL;
+
+ conn = (DBusConnection *)_dbus_connection_get();
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return -1;
+ }
+
+ msg = dbus_message_new_signal(path, interface, member);
+ if (!msg) {
+ _E("dbus_message_new_signal(%s:%s-%s)", path, interface, member);
+ return -1;
+ }
+
+ ret = dbus_connection_send(conn, msg, NULL); //async call
+ dbus_message_unref(msg);
+ if (ret != TRUE) {
+ _E("dbus_connection_send error(%s:%s-%s)", path, interface, member);
+ return -ECOMM;
+ }
+ _D("dbus_connection_send, ret=%d", ret);
+ return 0;
+}
+
+void starter_dbus_home_raise_signal_send(void)
+{
+ int ret = 0;
+
+ ret = _dbus_message_send(
+ DBUS_HOME_RAISE_PATH,
+ DBUS_HOME_RAISE_INTERFACE,
+ DBUS_HOME_RAISE_MEMBER);
+ _E("Sending HOME RAISE signal, result:%d", ret);
+}
+
+int starter_dbus_set_oomadj(int pid, int oom_adj_value)
+{
+ if(pid <= 0){
+ _E("Pid is invalid");
+ return -1;
+ }
+ DBusError err;
+ DBusMessage *msg;
+ char *pa[4];
+ char buf1[16];
+ char buf2[16];
+ int ret, val;
+
+ snprintf(buf1, sizeof(buf1), "%d", pid);
+ snprintf(buf2, sizeof(buf2), "%d", oom_adj_value);
+
+ pa[0] = DEVICED_SET_METHOD;
+ pa[1] = "2";
+ pa[2] = buf1;
+ pa[3] = buf2;
+
+ msg = _invoke_dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH, DEVICED_INTERFACE, DEVICED_SET_METHOD, "siss", pa);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %d", DEVICED_INTERFACE, pa[0], val);
+ return val;
+}
diff --git a/src/dbus-util_w.c b/src/dbus-util_w.c
new file mode 100755
index 0000000..751adf2
--- /dev/null
+++ b/src/dbus-util_w.c
@@ -0,0 +1,745 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Ecore.h>
+#include <dd-display.h>
+#include <aul.h>
+
+#include "starter_w.h"
+#include "dbus-util_w.h"
+#include "util.h"
+
+
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+
+#define POWEROFF_BUS_NAME "org.tizen.system.popup"
+#define POWEROFF_OBJECT_PATH "/Org/Tizen/System/Popup/Poweroff"
+#define POWEROFF_INTERFACE_NAME POWEROFF_BUS_NAME".Poweroff"
+#define METHOD_POWEROFF_NAME "PopupLaunch"
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define DISPLAY_OBJECT_PATH DEVICED_OBJECT_PATH"/Display"
+#define DEVICED_INTERFACE_DISPLAY DEVICED_INTERFACE_NAME".display"
+#define MEMBER_ALPM_ON "ALPMOn"
+#define MEMBER_ALPM_OFF "ALPMOff"
+#define MEMBER_LCD_ON "LCDOn"
+#define MEMBER_LCD_OFF "LCDOff"
+#define LCD_ON_BY_GESTURE "gesture"
+
+
+#define CPU_BOOSTER_OBJECT_PATH DEVICED_OBJECT_PATH"/PmQos"
+#define CPU_BOOSTER_INTERFACE DEVICED_BUS_NAME".PmQos"
+#define METHOD_CPU_BOOSTER "AppLaunchHome"
+#define DBUS_CPU_BOOSTER_SEC 200
+
+#define COOL_DOWN_MODE_PATH DEVICED_OBJECT_PATH"/SysNoti"
+#define COOL_DOWN_MODE_INTERFACE DEVICED_BUS_NAME".SysNoti"
+#define SIGNAL_COOL_DOWN_MODE "CoolDownChanged"
+#define METHOD_COOL_DOWN_MODE "GetCoolDownStatus"
+#define COOL_DOWN_MODE_RELEASE "Release"
+#define COOL_DOWN_MODE_LIMITACTION "LimitAction"
+
+#define NIKE_RUNNING_STATUS_PATH "/Com/Nike/Nrunning/RunningMgr"
+#define NIKE_RUNNING_STATUS_INTERFACE "com.nike.nrunning.runningmgr"
+#define NIKE_RUNNING_STATUS_SIGNAL "RunningStatus"
+#define NIKE_RUNNING_STATUS_START "start"
+#define NIKE_RUNNING_STATUS_END "end"
+
+#define DBUS_ALPM_CLOCK_PATH "/Org/Tizen/System/AlpmMgr"
+#define DBUS_ALPM_CLOCK_INTERFACE "org.tizen.system.alpmmgr"
+#define DBUS_ALPM_CLOCK_MEMBER_STATUS "ALPMStatus"
+#define ALPM_CLOCK_SHOW "show"
+
+#define DBUS_STARTER_ALPMCLOCK_PATH "/Org/Tizen/Coreapps/starter"
+#define DBUS_STARTER_ALPMCLOCK_INTERFACE "org.tizen.coreapps.starter.alpmclock"
+#define DBUS_STARTER_ALPMCLOCK_MEMBER "show"
+
+
+static struct _info {
+ DBusConnection *connection;
+} s_info = {
+ .connection = NULL,
+};
+
+static int pid_ALPM_clock = 0;
+
+static int _append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+DBusConnection *starter_dbus_connection_get(void) {
+ if (s_info.connection == NULL) {
+ _W("no connection for dbus. get dbus connection");
+ DBusError derror;
+ DBusConnection *connection = NULL;
+
+ dbus_error_init(&derror);
+ connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &derror);
+ if (connection == NULL) {
+ _E("Failed to get dbus connection:%s", derror.message);
+ dbus_error_free(&derror);
+ return NULL;
+ }
+ dbus_connection_setup_with_g_main(connection, NULL);
+ dbus_error_free(&derror);
+
+ s_info.connection = connection;
+ }
+
+ return s_info.connection;
+}
+
+static int _dbus_message_send(const char *path, const char *interface, const char *member)
+{
+ int ret = 0;
+ DBusMessage *msg = NULL;
+ DBusConnection *conn = NULL;
+
+ conn = (DBusConnection *)starter_dbus_connection_get();
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return -1;
+ }
+ _E("dbus_message_new_signal(%s:%s-%s)", path, interface, member);
+
+ msg = dbus_message_new_signal(path, interface, member);
+ if (!msg) {
+ _E("dbus_message_new_signal(%s:%s-%s)", path, interface, member);
+ return -1;
+ }
+
+ ret = dbus_connection_send(conn, msg, NULL); //async call
+ dbus_message_unref(msg);
+ if (ret != TRUE) {
+ _E("dbus_connection_send error(%s:%s-%s)", path, interface, member);
+ return -ECOMM;
+ }
+ _D("dbus_connection_send, ret=%d", ret);
+ return 0;
+}
+
+void starter_dbus_alpm_clock_signal_send(void *data)
+{
+ int ret = 0;
+
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return;
+ }
+#if 0
+ if(ad->lcd_status == 1){
+ _W("LCD is already on. Do not send alpm clock show msg.");
+ return;
+ }
+#endif
+
+ ret = _dbus_message_send(
+ DBUS_STARTER_ALPMCLOCK_PATH,
+ DBUS_STARTER_ALPMCLOCK_INTERFACE,
+ DBUS_STARTER_ALPMCLOCK_MEMBER);
+ _E("Sending alpmclock show signal, result:%d", ret);
+}
+
+
+DBusMessage *_invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+
+ if (!reply) {
+ _E("dbus_connection_send error(No reply)");
+ }
+
+ if (dbus_error_is_set(&err)) {
+ _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ return reply;
+}
+
+DBusMessage *_invoke_dbus_method_async(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ r = dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ if (r != TRUE) {
+ _E("dbus_connection_send error(%s:%s:%s-%s)", dest, path, interface, method);
+ return -ECOMM;
+ }
+ _D("dbus_connection_send, ret=%d", r);
+ return NULL;
+}
+
+int get_dbus_cool_down_mode(void *data)
+{
+ _D();
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return -1;
+ }
+ DBusError err;
+ DBusMessage *msg;
+ int ret = 0;
+ char *str = NULL;
+ int ret_val = 0;
+
+ msg = _invoke_dbus_method_sync(DEVICED_BUS_NAME, COOL_DOWN_MODE_PATH, COOL_DOWN_MODE_INTERFACE,
+ METHOD_COOL_DOWN_MODE, NULL, NULL);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %s", COOL_DOWN_MODE_INTERFACE, METHOD_COOL_DOWN_MODE, str);
+
+ if(!strncmp(str, COOL_DOWN_MODE_RELEASE, strlen(COOL_DOWN_MODE_RELEASE))){
+ _D("%s", COOL_DOWN_MODE_RELEASE);
+ ad->cool_down_mode = 0;
+ return ret_val;
+ }
+ if(!strncmp(str, COOL_DOWN_MODE_LIMITACTION, strlen(COOL_DOWN_MODE_LIMITACTION))){
+ _D("%s", COOL_DOWN_MODE_LIMITACTION);
+ ad->cool_down_mode = 1;
+ return ret_val;
+ }
+}
+
+int request_dbus_cpu_booster(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+ char *arr[1];
+ char val[32];
+
+ snprintf(val, sizeof(val), "%d", DBUS_CPU_BOOSTER_SEC);
+ arr[0] = val;
+
+ msg = _invoke_dbus_method_async(DEVICED_BUS_NAME, CPU_BOOSTER_OBJECT_PATH, CPU_BOOSTER_INTERFACE,
+ METHOD_CPU_BOOSTER, "i", arr);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %d", CPU_BOOSTER_INTERFACE, METHOD_CPU_BOOSTER, ret_val);
+ return ret_val;
+}
+
+
+int request_Poweroff(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+
+ msg = _invoke_dbus_method_async(POWEROFF_BUS_NAME, POWEROFF_OBJECT_PATH, POWEROFF_INTERFACE_NAME,
+ METHOD_POWEROFF_NAME, NULL, NULL);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %d", POWEROFF_INTERFACE_NAME, METHOD_POWEROFF_NAME, ret_val);
+ return ret_val;
+}
+
+
+#define W_CLOCK_ALPM_PKGNAME "com.samsung.idle-clock-alpm"
+static void _on_ALPM_changed_receive(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ char *str;
+ int response;
+ int r;
+ int alpm_on = 0;
+ int alpm_off = 0;
+
+ _D("ALPM signal is received");
+
+ alpm_on = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_ALPM_ON);
+ alpm_off = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_ALPM_OFF);
+
+ if (alpm_on) {
+ pid_ALPM_clock = w_launch_app(W_CLOCK_ALPM_PKGNAME, NULL);
+ _D("Launch ALPM clock[%s], pid[%d]", W_CLOCK_ALPM_PKGNAME, pid_ALPM_clock);
+ } else if (alpm_off) {
+#if 1
+ aul_terminate_pid(pid_ALPM_clock);
+#else
+ if (!pid_ALPM_clock) {
+ aul_terminate_pid(pid_ALPM_clock);
+ _D("Terminate ALPM clock pid[%d]", pid_ALPM_clock);
+ pid_ALPM_clock = 0;
+ } else {
+ _E(" ALPM clock pid is 0");
+ }
+#endif
+ } else {
+ _E("%s dbus_message_is_signal error", DEVICED_INTERFACE_DISPLAY);
+ }
+}
+
+
+int init_dbus_ALPM_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+ int r;
+
+ g_type_init();
+ e_dbus_init();
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ _E("e_dbus_bus_get error");
+ return -1;
+ }
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DISPLAY_OBJECT_PATH,
+ DEVICED_INTERFACE_DISPLAY, MEMBER_ALPM_ON,
+ _on_ALPM_changed_receive, NULL);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DISPLAY_OBJECT_PATH,
+ DEVICED_INTERFACE_DISPLAY, MEMBER_ALPM_OFF,
+ _on_ALPM_changed_receive, NULL);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+}
+
+static void _on_COOL_DOWN_MODE_changed_receive(void *data, DBusMessage *msg)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return;
+ }
+ DBusError err;
+ const char *str = NULL;
+ int response;
+ int r;
+ int mode_release = 0;
+ int mode_limitaction = 0;
+
+ _W("COOL DOWN MODE signal is received");
+ dbus_error_init(&err);
+
+ r = dbus_message_is_signal(msg, COOL_DOWN_MODE_INTERFACE, SIGNAL_COOL_DOWN_MODE);
+
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+ if (!r) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ return;
+ }
+
+ _D("received siganl : %s", str);
+
+ if (!strncmp(str, COOL_DOWN_MODE_RELEASE, strlen(COOL_DOWN_MODE_RELEASE))) {
+ _W("%s", COOL_DOWN_MODE_RELEASE);
+ ad->cool_down_mode = 0;
+ } else if (!strncmp(str, COOL_DOWN_MODE_LIMITACTION, strlen(COOL_DOWN_MODE_LIMITACTION))) {
+ _W("%s", COOL_DOWN_MODE_LIMITACTION);
+ ad->cool_down_mode = 1;
+ } else {
+ _E("%s dbus_message_is_signal error", SIGNAL_COOL_DOWN_MODE);
+ }
+}
+
+int init_dbus_COOL_DOWN_MODE_signal(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return -1;
+ }
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+ int r;
+
+ g_type_init();
+ e_dbus_init();
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ _E("e_dbus_bus_get error");
+ return -1;
+ }
+
+ handler = e_dbus_signal_handler_add(conn, NULL, COOL_DOWN_MODE_PATH,
+ COOL_DOWN_MODE_INTERFACE, SIGNAL_COOL_DOWN_MODE,
+ _on_COOL_DOWN_MODE_changed_receive, ad);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+}
+#if 0
+static void _on_NIKE_RUNNING_STATUS_changed_receive(void *data, DBusMessage *msg)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return;
+ }
+ DBusError err;
+ const char *str = NULL;
+ int response;
+ int r;
+ int mode_release = 0;
+ int mode_limitaction = 0;
+
+ _W("NIKE RUNNING STATUS signal is received");
+ dbus_error_init(&err);
+
+ r = dbus_message_is_signal(msg, NIKE_RUNNING_STATUS_INTERFACE, NIKE_RUNNING_STATUS_SIGNAL);
+
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+ if (!r) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ return;
+ }
+
+ _W("received siganl : %s", str);
+
+ if (!strncmp(str, NIKE_RUNNING_STATUS_START, strlen(NIKE_RUNNING_STATUS_START))) {
+ _W("%s", NIKE_RUNNING_STATUS_START);
+ ad->nike_running_status = 1;
+ } else if (!strncmp(str, NIKE_RUNNING_STATUS_END, strlen(NIKE_RUNNING_STATUS_END))) {
+ _W("%s", NIKE_RUNNING_STATUS_END);
+ ad->nike_running_status = 0;
+ } else {
+ _E("%s dbus_message_is_signal error", NIKE_RUNNING_STATUS_SIGNAL);
+ }
+ clock_mgr_set_reserved_apps_status(ad->nike_running_status, STARTER_RESERVED_APPS_NIKE, ad);
+}
+
+int init_dbus_NIKE_RUNNING_STATUS_signal(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return -1;
+ }
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+ int r;
+
+ g_type_init();
+ e_dbus_init();
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ _E("e_dbus_bus_get error");
+ return -1;
+ }
+
+ handler = e_dbus_signal_handler_add(conn, NULL, NIKE_RUNNING_STATUS_PATH,
+ NIKE_RUNNING_STATUS_INTERFACE, NIKE_RUNNING_STATUS_SIGNAL,
+ _on_NIKE_RUNNING_STATUS_changed_receive, ad);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+}
+#endif
+
+static void _on_lcd_changed_receive(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ const char *str = NULL;
+ int response;
+ int r;
+ int lcd_on = 0;
+ int lcd_off = 0;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("LCD signal is received");
+
+ lcd_on = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_ON);
+ lcd_off = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_OFF);
+
+
+ if (lcd_on) {
+#if 0
+ dbus_error_init(&err);
+
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+
+ if (!r) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ return;
+ }
+
+ _W("%s, %d, str=[%s]", __func__, __LINE__, str);
+
+ if (!strncmp(str, LCD_ON_BY_GESTURE, strlen(LCD_ON_BY_GESTURE))) {
+ _W("LCD ON by [%s], do not terminate ALPM clock", LCD_ON_BY_GESTURE);
+ } else {
+ if (ad->pid_ALPM_clock > 0) {
+ _W("LCD ON by [%s], terminate ALPM clock pid[%d]", str, ad->pid_ALPM_clock);
+ aul_terminate_pid(ad->pid_ALPM_clock);
+ ad->pid_ALPM_clock = 0;
+ }
+ }
+#endif
+ _W("LCD on");
+ ad->lcd_status = 1;
+ }
+ else if(lcd_off){
+ _W("LCD off");
+ ad->lcd_status = 0;
+ } else {
+ _E("%s dbus_message_is_signal error", DEVICED_INTERFACE_DISPLAY);
+ }
+}
+
+
+int init_dbus_lcd_on_off_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+ int r;
+
+ g_type_init();
+ e_dbus_init();
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ _E("e_dbus_bus_get error");
+ return -1;
+ }
+
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DISPLAY_OBJECT_PATH,
+ DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_ON,
+ _on_lcd_changed_receive, data);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DISPLAY_OBJECT_PATH,
+ DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_OFF,
+ _on_lcd_changed_receive, data);
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+}
+
+
+
+static void _on_ALPM_clock_state_changed_receive(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ const char *str = NULL;
+ int response;
+ int r;
+ int lcd_on = 0;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ _D("ALPM clock state is received");
+
+ lcd_on = dbus_message_is_signal(msg, DBUS_ALPM_CLOCK_INTERFACE, DBUS_ALPM_CLOCK_MEMBER_STATUS);
+
+
+ if (lcd_on) {
+ dbus_error_init(&err);
+
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+
+ if (!r) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ return;
+ }
+
+ _D("%s, %d, str=[%s]", __func__, __LINE__, str);
+ if (!strncmp(str, ALPM_CLOCK_SHOW, strlen(ALPM_CLOCK_SHOW))) {
+ _W("ALPM clock state is [%s]", ALPM_CLOCK_SHOW);
+ ad->ALPM_clock_state = 1;
+ } else {
+ ad->ALPM_clock_state = 0;
+ }
+ } else {
+ _E("%s dbus_message_is_signal error", DBUS_ALPM_CLOCK_INTERFACE);
+ }
+}
+
+int init_dbus_ALPM_clock_state_signal(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return -1;
+ }
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+ int r;
+
+ g_type_init();
+ e_dbus_init();
+
+ ad->ALPM_clock_state = 0;
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ _E("e_dbus_bus_get error");
+ return -1;
+ }
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DBUS_ALPM_CLOCK_PATH,
+ DBUS_ALPM_CLOCK_INTERFACE, DBUS_ALPM_CLOCK_MEMBER_STATUS,
+ _on_ALPM_clock_state_changed_receive, ad);
+
+ if (handler == NULL) {
+ _E("e_dbus_signal_handler_add error");
+ return -1;
+ }
+
+ return 1;
+}
+
+
diff --git a/src/direct-access.c b/src/direct-access.c
new file mode 100755
index 0000000..bfeaa84
--- /dev/null
+++ b/src/direct-access.c
@@ -0,0 +1,476 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <stdio.h>
+#include <Ecore.h>
+#include <dd-display.h>
+#include <dd-led.h>
+#include <aul.h>
+#include <vconf.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <feedback.h>
+#include<Elementary.h>
+#ifndef FEATURE_LITE
+#include <tts.h>
+#endif
+
+#include "starter.h"
+#include "util.h"
+#include "direct-access.h"
+
+#define _(str) dgettext("starter", str)
+
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+
+#define ALWAYS_ASK_BUS_NAME "org.tizen.system.popup"
+#define ALWAYS_ASK_OBJECT_PATH "/Org/Tizen/System/Popup/System"
+#define ALWAYS_ASK_INTERFACE_NAME ALWAYS_ASK_BUS_NAME".System"
+#define METHOD_ALWAYS_ASK_NAME "AccessibilityPopupLaunch"
+#define ALWAYS_ASK_PARAM_1 "_SYSPOPUP_CONTENT_"
+#define ALWAYS_ASK_PARAM_2 "accessibility"
+
+#ifndef FEATURE_LITE
+static tts_h tts;
+#endif
+static int tts_status;
+
+static int _append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+
+DBusMessage *invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+ if (!reply) {
+ _E("dbus_connection_send error(No reply)");
+ }
+
+ if (dbus_error_is_set(&err)) {
+ _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ return reply;
+}
+
+
+DBusMessage *invoke_dbus_method(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ r = dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ if (r != TRUE) {
+ _E("dbus_connection_send error(%s:%s:%s-%s)", dest, path, interface, method);
+ return -ECOMM;
+ }
+ _D("dbus_connection_send, ret=%d", r);
+ return NULL;
+}
+
+
+
+
+
+
+
+
+static void _set_assistive_light(void)
+{
+ int max, state, ret;
+
+ max = led_get_max_brightness();
+ if (max < 0)
+ max = 1;
+
+ state = led_get_brightness();
+ if (state > 0) {
+ ret = led_set_brightness_with_noti(0, true);
+ if (ret == 0)
+ vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, 0);
+ } else {
+ ret = led_set_brightness_with_noti(max, true);
+ if (ret == 0)
+ vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, 1);
+ }
+
+ if(feedback_initialize() == FEEDBACK_ERROR_NONE)
+ {
+ _D("make vibration effect");
+ feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TAP);
+ feedback_deinitialize();
+ }
+}
+
+
+
+#define LIVE_SETTING_APP "com.samsung.live-setting-app"
+static int _launch_live_setting_app(void)
+{
+ bundle *b;
+ int ret;
+
+ b = bundle_create();
+ if (!b) {
+ _E("Failed to create bundle");
+ return -ENOMEM;
+ }
+
+ ret = bundle_add(b, "popup", "zoom");
+ if (ret < 0) {
+ _E("Failed to add parameters to bundle");
+ goto out;
+ }
+
+ ret = aul_launch_app(LIVE_SETTING_APP, b);
+ if (ret < 0)
+ _E("Failed to launch app(%s)", LIVE_SETTING_APP);
+
+out:
+ bundle_free(b);
+ return ret;
+}
+
+static bool _is_aircommand_on(void)
+{
+ int state;
+ if (vconf_get_bool(VCONFKEY_AIRCOMMAND_ENABLED, &state) == 0
+ && state == 1)
+ return true;
+ return false;
+}
+
+#define PROP_ZOOM "_E_ACC_ENABLE_ZOOM_UI_"
+static void _set_zoom(void)
+{
+ int ret;
+ unsigned int value;
+ Ecore_X_Window rootWin;
+ Ecore_X_Atom atomZoomUI;
+
+ rootWin = ecore_x_window_root_first_get();
+ atomZoomUI = ecore_x_atom_get(PROP_ZOOM);
+
+ ret = ecore_x_window_prop_card32_get(rootWin, atomZoomUI, &value, 1);
+ if (ret == 1 && value == 1)
+ value = 0;
+ else
+ value = 1;
+
+ ecore_x_window_prop_card32_set(rootWin, atomZoomUI, &value, 1);
+ ecore_x_flush();
+
+ vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_ZOOM, value);
+}
+
+
+
+#define PROP_HIGH_CONTRAST "_E_ACC_ENABLE_HIGH_CONTRAST_"
+static void _set_contrast(void)
+{
+ int ret;
+ unsigned int value;
+ Ecore_X_Window rootWin;
+ Ecore_X_Atom atomHighContrast;
+
+ rootWin = ecore_x_window_root_first_get();
+ atomHighContrast = ecore_x_atom_get(PROP_HIGH_CONTRAST);
+
+ ret = ecore_x_window_prop_card32_get(rootWin, atomHighContrast, &value, 1);
+ if (ret == 1 && value == 1)
+ value = 0;
+ else
+ value = 1;
+
+ ecore_x_window_prop_card32_set(rootWin, atomHighContrast, &value, 1);
+ ecore_x_flush();
+
+ vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, value);
+}
+#ifndef FEATURE_LITE
+void utterance_completed_callback(tts_h tts, int utt_id, void* user_data){
+ _D("");
+ int ret = 0;
+ int u_id = 0;
+ ret = tts_stop(tts);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to stop(%d)", ret);
+ return;
+ }
+ ret = tts_unprepare(tts);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to unprepare(%d)", ret);
+ return;
+ }
+ if(tts){
+ ret = tts_destroy(tts);
+ tts = NULL;
+ }
+ return;
+}
+
+void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* data){
+ int ret = 0;
+ int u_id = 0;
+ bindtextdomain("starter", "/usr/share/locale");
+ appcore_set_i18n();
+ if(TTS_STATE_CREATED == previous && current == TTS_STATE_READY){
+ if(tts_status){
+ ret = tts_add_text(tts, _("IDS_TPLATFORM_BODY_SCREEN_READER_ENABLED_T_TTS"), NULL, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &u_id);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to add text(%d)", ret);
+ return;
+ }
+ }
+ else{
+ ret = tts_add_text(tts, _("IDS_TPLATFORM_BODY_SCREEN_READER_DISABLED_T_TTS"), NULL, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &u_id);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to add text(%d)", ret);
+ return;
+ }
+ }
+ ret = tts_play(tts);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to play(%d)", ret);
+ return;
+ }
+ }
+}
+
+static void _starter_tts_play(void){
+ int ret = 0;
+ int u_id = 0;
+
+ ret = tts_create(&tts);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to get handle(%d)", ret);
+ return;
+ }
+ ret = tts_set_state_changed_cb(tts, _tts_state_changed_cb, NULL);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to set state changed cb(%d)", ret);
+ return;
+ }
+ ret = tts_set_mode(tts, TTS_MODE_NOTIFICATION);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to set mode(%d)", ret);
+ return;
+ }
+ ret = tts_set_utterance_completed_cb(tts, utterance_completed_callback, NULL);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to prepare(%d)", ret);
+ return;
+ }
+ ret = tts_prepare(tts);
+ if(ret != TTS_ERROR_NONE){
+ _E("fail to prepare(%d)", ret);
+ return;
+ }
+ return;
+}
+#endif
+static int _set_accessibility_tts(void)
+{
+ if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_status) < 0) {
+ _E("FAIL: vconf_get_bool()");
+ return -1;
+ }
+
+ if (tts_status == FALSE)
+ tts_status = TRUE;
+ else
+ tts_status = FALSE;
+ if (vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, tts_status) < 0) {
+ _E("FAIL: vconf_set_bool()");
+ return -1;
+ }
+#ifndef FEATURE_LITE
+ _starter_tts_play();
+#endif
+ return 0;
+}
+
+
+
+static int _launch_always_ask(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+ char *arr[2];
+ char val[32];
+
+ arr[0] = ALWAYS_ASK_PARAM_1;
+ arr[1] = ALWAYS_ASK_PARAM_2;
+
+ msg = invoke_dbus_method(ALWAYS_ASK_BUS_NAME, ALWAYS_ASK_OBJECT_PATH, ALWAYS_ASK_INTERFACE_NAME,
+ METHOD_ALWAYS_ASK_NAME, "ss", arr);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %d", ALWAYS_ASK_INTERFACE_NAME, METHOD_ALWAYS_ASK_NAME, ret_val);
+ return ret_val;
+}
+
+
+
+int launch_direct_access(int access_val)
+{
+ int ret = 0;
+ _D("launch_direct_access [%d]", access_val);
+
+ /* Direct Access Operation */
+ switch (access_val) {
+ case SETTING_POWERKEY_SHORTCUT_ALWAYS_ASK:
+ if (!_launch_always_ask())
+ ret = -1;
+ break;
+ case SETTING_POWERKEY_SHORTCUT_SCREEN_READER_TTS:
+ if (!_set_accessibility_tts())
+ ret = -1;
+ break;
+ case SETTING_POWERKEY_SHORTCUT_NEGATIVE_COLOURS:
+ _set_contrast();
+ break;
+ case SETTING_POWERKEY_SHORTCUT_ZOOM:
+ if (_is_aircommand_on()) {
+ ret = -1;
+ if (_launch_live_setting_app() < 0)
+ _E("Failed to launch (%s)", LIVE_SETTING_APP);
+ return ret;
+ }
+ _set_zoom();
+ break;
+ case SETTING_POWERKEY_SHORTCUT_ASSISTIVE_LIGHT:
+ _set_assistive_light();
+ break;
+ case SETTING_POWERKEY_SHORTCUT_SHOT_READER:
+
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ return ret;
+}
+
diff --git a/src/hourly_alert.c b/src/hourly_alert.c
new file mode 100755
index 0000000..8fe4daa
--- /dev/null
+++ b/src/hourly_alert.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <poll.h>
+#include <errno.h>
+#include <string.h>
+
+#include <vconf.h>
+#include <signal.h>
+#include <app.h>
+#include <alarm.h>
+#include <feedback.h>
+
+#include "starter_w.h"
+#include "starter-util.h"
+#include "lockd-debug.h"
+
+#include "util.h"
+
+static int __alarm_delete_cb(alarm_id_t id, void * user_param)
+{
+ int ret = ALARMMGR_RESULT_SUCCESS;
+
+ ret = alarmmgr_remove_alarm(id);
+ if(ret != ALARMMGR_RESULT_SUCCESS) {
+ _ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+
+ return 0;
+}
+
+static void _alarm_unset(void *data)
+{
+ int ret = ALARMMGR_RESULT_SUCCESS;
+
+ struct appdata *ad = data;
+ ret_if(ad == NULL);
+
+ if(ad->alarm_id != -1){
+ _DBG("try to delete alarm_id(%d)", ad->alarm_id);
+ ret = alarmmgr_remove_alarm(ad->alarm_id);
+ if(ret != ALARMMGR_RESULT_SUCCESS) {
+ ret = alarmmgr_enum_alarm_ids(__alarm_delete_cb, NULL);
+ if(ret != ALARMMGR_RESULT_SUCCESS) {
+ _ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+ }
+ ad->alarm_id = -1;
+ }
+}
+
+static int _alarm_set(void *data)
+{
+ int ret = ALARMMGR_RESULT_SUCCESS;
+ time_t current_time;
+ struct tm current_tm;
+ alarm_entry_t *alarm_info = NULL;
+ alarm_id_t alarm_id;
+ alarm_date_t alarm_time;
+ struct appdata *ad = data;
+ retv_if(ad == NULL, -1);
+
+ /* delete before registering alarm ids */
+ _alarm_unset(ad);
+
+ time(&current_time);
+
+ /* alarm revision */
+ current_time += 3600; // +1 hour
+
+ localtime_r(&current_time, &current_tm);
+
+ alarm_info = alarmmgr_create_alarm();
+ if(alarm_info == NULL) {
+ _ERR("alarmmgr_create_alarm() is failed\n");
+ return -1;
+ }
+
+ alarm_time.year = current_tm.tm_year;
+ alarm_time.month = current_tm.tm_mon;
+ alarm_time.day = current_tm.tm_mday;
+ alarm_time.hour = current_tm.tm_hour;
+ alarm_time.min = 0;
+ alarm_time.sec = 0;
+
+ //alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+ ret = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_REPEAT, 60*60);
+ if(ret != ALARMMGR_RESULT_SUCCESS) {
+ _ERR("alarmmgr_set_repeat_mode() failed");
+ alarmmgr_free_alarm(alarm_info) ;
+ return -1;
+ }
+ alarmmgr_set_time(alarm_info, alarm_time);
+ alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
+
+ ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
+ if(ret != ALARMMGR_RESULT_SUCCESS) {
+ _ERR("alarmmgr_add_alarm_with_localtime() failed");
+ alarmmgr_free_alarm(alarm_info) ;
+ return -1;
+ }
+
+ ad->alarm_id = alarm_id;
+ alarmmgr_free_alarm(alarm_info);
+
+ return 0;
+}
+
+static int __alarm_cb(alarm_id_t alarm_id, void *data)
+{
+ _DBG("hourly_alert alarm callback called");
+
+ feedback_initialize();
+ feedback_play(FEEDBACK_PATTERN_HOURLY_ALERT);
+ feedback_deinitialize();
+
+ return 0;
+}
+
+static int _alarm_init(void *data)
+{
+ int ret = 0;
+
+ struct appdata *ad = data;
+ retv_if(ad == NULL, -1);
+
+ g_type_init();
+ ret = alarmmgr_init("starter");
+ retv_if(ret<0, -1);
+
+ ret = alarmmgr_set_cb(__alarm_cb, data);
+ retv_if(ret<0, -1);
+
+ ad->alarm_id = -1;
+
+ return 0;
+}
+
+static void _alarm_fini(void *data)
+{
+ _alarm_unset(data);
+ alarmmgr_fini();
+}
+
+static Eina_Bool _register_hourly_alert_alarm(struct appdata *ad)
+{
+ int ret = 0;
+
+ if(!ad) {
+ _ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ //alarmmgr_fini();
+
+ ret = _alarm_init(ad);
+ if(ret<0) {
+ _ERR("_alarm_init() failed");
+ return EINA_FALSE;
+ }
+
+ _alarm_set(ad);
+
+ return EINA_TRUE;
+
+}
+
+static int _unregister_hourly_alert_alarm(struct appdata *ad)
+{
+ _alarm_fini(ad);
+
+ return 0;
+}
+
+
+static void _hourly_alert_changed_cb(keynode_t* node, void *data)
+{
+ int hourly_alert = -1;
+ struct appdata *ad = (struct appdata *)data;
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ if (node) {
+ hourly_alert = vconf_keynode_get_bool(node);
+ } else {
+ if (vconf_get_int(VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, &hourly_alert) < 0) {
+ _ERR("Failed to get %s", VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL);
+ return;
+ }
+ }
+
+ if (hourly_alert == TRUE) {
+ _ERR("hourly_alert is set");
+ _register_hourly_alert_alarm(ad);
+ } else {
+ _ERR("hourly_alert is unset");
+ _unregister_hourly_alert_alarm(ad);
+ }
+
+}
+
+static void _hourly_system_time_changed_cb(keynode_t *node, void *data)
+{
+ struct appdata *ad = data;
+ ret_if(ad == NULL);
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ /* unset existing alarms and set new alarm */
+ _alarm_set(ad);
+}
+
+void init_hourly_alert(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ int hourly_alert = -1;
+ int ret = 0;
+
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, &hourly_alert);
+ if (ret < 0){
+ _ERR("can't get vconfkey value of [%s], ret=[%d]", VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, ret);
+ hourly_alert = FALSE;
+ } else if (hourly_alert == TRUE) {
+ _DBG("[%s] value is [%d], hourly_alert is set..!!", VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, hourly_alert);
+ if (_register_hourly_alert_alarm(ad) == EINA_FALSE) {
+ _ERR("_register_hourly_alert_alarm is failed..!!");
+ }
+ }
+
+ if (vconf_notify_key_changed(VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, _hourly_alert_changed_cb, ad) < 0) {
+ _ERR("Failed to add the callback for %s changed", VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL);
+ }
+ /* for time revision */
+ if (vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, _hourly_system_time_changed_cb, ad) < 0) {
+ _ERR("Failed to add the callback for %s changed", VCONFKEY_SYSTEM_TIME_CHANGED);
+ }
+}
+
+void fini_hourly_alert(void *data)
+{
+ int ret = 0;
+ struct appdata *ad = data;
+ ret_if(ad == NULL);
+
+ //_unregister_hourly_alert_alarm(data);
+
+ ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_HOURLY_ALERT_BOOL, _hourly_alert_changed_cb);
+ if(ret != 0) {
+ _E("vconf_ignore failed");
+ }
+}
+
diff --git a/src/hw_key.c b/src/hw_key.c
new file mode 100755
index 0000000..6ddd9e0
--- /dev/null
+++ b/src/hw_key.c
@@ -0,0 +1,1600 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <ail.h>
+#include <bundle.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <dd-deviced.h>
+#include <syspopup_caller.h>
+#include <utilX.h>
+#include <vconf.h>
+#include <system/media_key.h>
+#include <aul.h>
+#include <feedback.h>
+
+#include "direct-access.h"
+#include "hw_key.h"
+#include "lock-daemon.h"
+#include "menu_daemon.h"
+#include "util.h"
+#include "dbus-util.h"
+
+#define _DEF_BEZEL_AIR_COMMAND 0
+
+#define CAMERA_PKG_NAME "com.samsung.camera-app"
+#define CALLLOG_PKG_NAME "com.samsung.calllog"
+#define SVOICE_PKG_NAME "com.samsung.svoice"
+#define MUSIC_PLAYER_PKG_NAME "com.samsung.music-player"
+#define MUSIC_PLAYER_LITE_PKG_NAME "com.samsung.music-player-lite"
+
+#ifdef FEATURE_LITE
+#define SAFETY_ASSURANCE_PKG_NAME "com.samsung.emergency-message-lite"
+#else
+#define SAFETY_ASSURANCE_PKG_NAME "com.samsung.emergency-message"
+#endif
+
+#define WEBPAGE_PKG_NAME "com.samsung.browser"
+#define MAIL_PKG_NAME "com.samsung.email"
+#define DIALER_PKG_NAME "com.samsung.phone"
+#define STR_ATOM_XKEY_COMPOSITION "_XKEY_COMPOSITION"
+#define STR_ATOM_KEYROUTER_NOTIWINDOW "_KEYROUTER_NOTIWINDOW"
+
+#define SERVICE_OPERATION_MAIN_KEY "__APP_SVC_OP_TYPE__"
+#define SERVICE_OPERATION_MAIN_VALUE "http://tizen.org/appcontrol/operation/main"
+
+#define SVOICE_LAUNCH_BUNDLE_KEY "domain"
+#define SVOICE_LAUNCH_BUNDLE_VALUE "earjack"
+#define SVOICE_LAUNCH_BUNDLE_HOMEKEY_VALUE "home_key"
+
+#define _VCONF_QUICK_COMMADN_NAME "db/aircommand/enabled"
+#define _VCONF_QUICK_COMMADN_FLOATING "db/aircommand/floating"
+#define HALL_COVERED_STATUS 0
+
+#define POWERKEY_TIMER_SEC 0.700
+#define POWERKEY_TIMER_MSEC 700
+#define POWERKEY_CODE "XF86PowerOff"
+
+#define LONG_PRESS_TIMER_SEC 0.4
+#define HOMEKEY_TIMER_SEC 0.2
+#define UNLOCK_TIMER_SEC 0.8
+#define CANCEL_KEY_TIMER_SEC 0.3
+
+static struct {
+ Ecore_X_Window win;
+ Ecore_Event_Handler *key_up;
+ Ecore_Event_Handler *key_down;
+ Ecore_Event_Handler *client_msg_hd;
+ Ecore_Event_Handler *two_finger_double_tap;
+ Ecore_Event_Handler *two_finger_long_tap;
+ Ecore_Event_Handler *bezel_gesture;
+ Ecore_Timer *long_press_timer;
+ Ecore_Timer *single_timer;
+ Ecore_Timer *homekey_timer;
+ Ecore_Timer *media_long_press;
+ Ecore_Timer *client_msg_timer;
+ Ecore_Timer *cancel_key_timer;
+ Eina_Bool cancel;
+ Eina_Bool is_cancel;
+ Eina_Bool ignore_home_key;
+ Eina_Bool enable_safety_assurance;
+ Ecore_X_Window keyrouter_notiwindow;
+ int homekey_count;
+ int powerkey_count;
+ unsigned int powerkey_time_stamp;
+} key_info = {
+ .win = 0x0,
+ .key_up = NULL,
+ .key_down = NULL,
+ .client_msg_hd = NULL,
+ .long_press_timer = NULL,
+ .single_timer = NULL,
+ .homekey_timer = NULL,
+ .media_long_press = NULL,
+ .client_msg_timer = NULL,
+ .cancel_key_timer = NULL,
+ .cancel = EINA_FALSE,
+ .is_cancel = EINA_FALSE,
+ .ignore_home_key = EINA_FALSE,
+ .enable_safety_assurance = EINA_FALSE,
+ .keyrouter_notiwindow = 0x0,
+ .two_finger_double_tap = NULL,
+ .two_finger_long_tap = NULL,
+ .homekey_count = 0,
+ .powerkey_count = 0,
+ .powerkey_time_stamp = 0,
+};
+
+static Ecore_Timer *gtimer_launch = NULL;
+static bool gbenter_idle = false;
+static bool gbinit_floatwin = false;
+static int gbRegisterDuobleTap = 0;
+
+
+
+static Eina_Bool _launch_taskmgr_cb(void* data)
+{
+ int val = -1;
+ _D("Launch TASKMGR");
+
+ key_info.long_press_timer = NULL;
+
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY for lock state");
+ }
+ if (val == VCONFKEY_IDLE_LOCK) {
+ _E("lock state, ignore home key long press..!!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _E("scover is closed, ignore home key long press..!!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ bundle *b;
+ b = bundle_create();
+ retv_if(NULL == b, ECORE_CALLBACK_CANCEL);
+ bundle_add(b, "HIDE_LAUNCH", "0");
+
+ int ret = menu_daemon_launch_app(menu_daemon_get_taskmgr_pkgname(), b);
+ goto_if(0 > ret, OUT);
+
+ if(ret > 0){
+ if(starter_dbus_set_oomadj(ret, OOM_ADJ_VALUE_DEFAULT) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+
+OUT:
+ bundle_free(b);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+#define DESKDOCK_PKG_NAME "com.samsung.desk-dock"
+static Eina_Bool _launch_by_home_key(void *data)
+{
+ int lock_state = (int) data;
+ int ret = 0;
+ _D("lock_state : %d ", lock_state);
+
+ key_info.single_timer = NULL;
+
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _D("scover is closed, ignore home key..!!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (lockd_get_lock_state() > VCONFKEY_IDLE_UNLOCK) {
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ int cradle_status = menu_daemon_get_cradle_status();
+ if (0 < cradle_status) {
+ int ret;
+ _SECURE_D("Cradle is enabled to [%d], we'll launch the desk dock[%s]", cradle_status, DESKDOCK_PKG_NAME);
+ ret = menu_daemon_open_app(DESKDOCK_PKG_NAME);
+ if (ret < 0) {
+ _SECURE_E("cannot launch package %s(err:%d)", DESKDOCK_PKG_NAME, ret);
+ }
+ }
+
+ ret = menu_daemon_open_homescreen(NULL);
+
+ if(ret > 0){
+ starter_dbus_home_raise_signal_send();
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+inline static Eina_Bool _launch_svoice(void)
+{
+ const char *pkg_name = NULL;
+ bundle *b = NULL;
+ int val;
+
+ pkg_name = menu_daemon_get_svoice_pkg_name();
+ retv_if(NULL == pkg_name, EINA_FALSE);
+
+#if 1
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (val == SETTING_PSMODE_EMERGENCY) {
+ _D("Emergency mode, ignore svoice key..!!");
+ return EINA_FALSE;
+ }
+#endif
+
+ if (vconf_get_int(VCONFKEY_SVOICE_OPEN_VIA_HOME_KEY, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+
+ if (val != 1) {
+ _D("Launch nothing");
+ return EINA_FALSE;
+ }
+
+#if 1
+ if (!strcmp(pkg_name, SVOICE_PKG_NAME)) {
+ b = bundle_create();
+ retv_if(!b, EINA_FALSE);
+
+ bundle_add(b, SVOICE_LAUNCH_BUNDLE_KEY, SVOICE_LAUNCH_BUNDLE_HOMEKEY_VALUE);
+ bundle_add(b, SERVICE_OPERATION_MAIN_KEY, SERVICE_OPERATION_MAIN_VALUE);
+ }
+
+ if (menu_daemon_launch_app(pkg_name, b) < 0)
+ _SECURE_E("Failed to launch %s", pkg_name);
+
+ if (b != NULL)
+ bundle_free(b);
+#else
+ if (menu_daemon_open_app(pkg_name) < 0)
+ _SECURE_E("Failed to open %s", pkg_name);
+#endif
+ return EINA_TRUE;
+}
+
+
+
+static void _launch_safety_assurance(void)
+{
+ _SECURE_D("Launch %s", SAFETY_ASSURANCE_PKG_NAME);
+ if (menu_daemon_open_app(SAFETY_ASSURANCE_PKG_NAME) < 0) {
+ _SECURE_E("Cannot open %s", SAFETY_ASSURANCE_PKG_NAME);
+ }
+}
+
+
+static Eina_Bool _launch_svoice_cb(void* data)
+{
+ key_info.media_long_press = NULL;
+
+ int val = -1;
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (val == SETTING_PSMODE_EMERGENCY) {
+ _D("Emergency mode, ignore KEY_MEDIA key..!!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (vconf_get_int(VCONFKEY_SVOICE_OPEN_VIA_EARPHONE_KEY, &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (1 == val) {
+ _D("Launch SVOICE");
+#if 1
+ bundle *b;
+ b = bundle_create();
+ retv_if(!b, ECORE_CALLBACK_CANCEL);
+
+ bundle_add(b, SVOICE_LAUNCH_BUNDLE_KEY, SVOICE_LAUNCH_BUNDLE_VALUE);
+ bundle_add(b, SERVICE_OPERATION_MAIN_KEY, SERVICE_OPERATION_MAIN_VALUE);
+ if (menu_daemon_launch_app(SVOICE_PKG_NAME, b) < 0)
+ _SECURE_E("Failed to launch %s", SVOICE_PKG_NAME);
+ bundle_free(b);
+#else
+ if (menu_daemon_open_app(SVOICE_PKG_NAME) < 0)
+ _SECURE_E("Failed to open %s", SVOICE_PKG_NAME);
+#endif
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+#if 0
+static Eina_Bool _client_msg_timer_cb(void* data)
+{
+ _D("_client_msg_timer_cb, safety assurance is enable");
+
+ key_info.enable_safety_assurance = EINA_TRUE;
+ _D("Launch SafetyAssurance");
+ _launch_safety_assurance();
+ key_info.client_msg_timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+#endif
+
+
+
+static Eina_Bool _set_unlock(void *data)
+{
+ _D("_set_unlock");
+ vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+inline static int _release_home_key(int lock_state)
+{
+ int val = -1;
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (val != SETTING_PSMODE_EMERGENCY) {
+ retv_if(NULL == key_info.long_press_timer, EXIT_SUCCESS);
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ }
+
+ if (NULL == key_info.single_timer) {
+ key_info.single_timer = ecore_timer_add(0.3, _launch_by_home_key, (void *) lock_state);
+ return EXIT_SUCCESS;
+ }
+ ecore_timer_del(key_info.single_timer);
+ key_info.single_timer = NULL;
+
+ if(EINA_TRUE == _launch_svoice()) {
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ ecore_timer_add(0.8, _set_unlock, NULL);
+ }
+ }
+ return EXIT_SUCCESS;
+}
+
+
+
+inline static void _release_multimedia_key(const char *value)
+{
+ ret_if(NULL == value);
+
+ _D("Multimedia key is released with %s", value);
+
+ bundle *b;
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return;
+ }
+ bundle_add(b, "multimedia_key", value);
+
+ int ret;
+#ifdef FEATURE_LITE
+ ret = menu_daemon_launch_app(MUSIC_PLAYER_LITE_PKG_NAME, b);
+#else
+ ret = menu_daemon_launch_app(MUSIC_PLAYER_PKG_NAME, b);
+#endif
+ if (ret < 0)
+ _E("Failed to launch the running apps, ret : %d", ret);
+
+ bundle_free(b);
+}
+
+
+static Eina_Bool _homekey_timer_cb(void *data)
+{
+ int direct_access_val = -1;
+ int lock_state = (int) data;
+
+ _W("%s, homekey count[%d], lock state[%d]", __func__, key_info.homekey_count, lock_state);
+ key_info.homekey_timer = NULL;
+
+
+ /* Check Direct Access */
+ if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_POWER_KEY_HOLD, &direct_access_val) < 0) {
+ _E("Cannot get VCONFKEY_SETAPPL_ACCESSIBILITY_POWER_KEY_HOLD");
+ direct_access_val = SETTING_POWERKEY_SHORTCUT_OFF;
+ }
+
+
+ if (SETTING_POWERKEY_SHORTCUT_OFF == direct_access_val) {
+ /* Direct Access OFF */
+ if(key_info.homekey_count%2 == 0) {
+ /* double press operation */
+ key_info.homekey_count = 0; //initialize powerkey count
+ if(EINA_TRUE == _launch_svoice()) {
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ ecore_timer_add(UNLOCK_TIMER_SEC, _set_unlock, NULL);
+ }
+ }
+ return ECORE_CALLBACK_CANCEL;
+ }
+ } else {
+ /* Direct Access ON */
+ if(key_info.homekey_count == 2) {
+ /* double press operation*/
+ key_info.homekey_count = 0; //initialize powerkey count
+ if(EINA_TRUE == _launch_svoice()) {
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ ecore_timer_add(UNLOCK_TIMER_SEC, _set_unlock, NULL);
+ }
+ }
+ return ECORE_CALLBACK_CANCEL;
+ } else if(key_info.homekey_count >= 3) {
+ _W("Launch Direct Access : %d", direct_access_val);
+ key_info.homekey_count = 0; //initialize powerkey count
+#ifdef FEATURE_LITE
+ _E("Not supported in Lite feature");
+#else
+ if (launch_direct_access(direct_access_val) < 0) {
+ _E("Fail Launch Direct Access..!!");
+ }
+#endif
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
+
+ /* Single homekey operation */
+ key_info.homekey_count = 0; //initialize powerkey count
+ _launch_by_home_key(data);
+ return ECORE_CALLBACK_CANCEL;
+
+}
+
+
+static Eina_Bool _key_release_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Up *ev = event;
+ int val = -1;
+ int lock_state = -1;
+
+ if (!ev) {
+ _D("_key_release_cb : Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_release_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_release_cb : %s Released", ev->keyname);
+ }
+
+ /* Safety Assistance */
+ if (!strcmp(ev->keyname, POWERKEY_CODE)) {
+ //double current_timestamp = ecore_loop_time_get();
+ unsigned int current_timestamp = ev->timestamp;
+ _D("current_timestamp[%d] previous_timestamp[%d]", current_timestamp, key_info.powerkey_time_stamp);
+
+ if ((current_timestamp - key_info.powerkey_time_stamp) > POWERKEY_TIMER_MSEC) {
+ key_info.powerkey_count = 0;
+ }
+ key_info.powerkey_count++;
+ if (key_info.powerkey_count >= 3) {
+ _launch_safety_assurance();
+ key_info.powerkey_count = 0;
+ }
+ _D("powerkey count:%d", key_info.powerkey_count);
+ key_info.powerkey_time_stamp = current_timestamp;
+ } else {
+ key_info.powerkey_count = 0;
+ }
+
+
+ if (!strcmp(ev->keyname, KEY_END)) {
+ } else if (!strcmp(ev->keyname, KEY_CONFIG)) {
+ } else if (!strcmp(ev->keyname, KEY_SEND)) {
+ } else if (!strcmp(ev->keyname, KEY_HOME)) {
+ _W("Home Key is released");
+
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+ if ((lock_state == VCONFKEY_IDLE_LOCK) && (lockd_get_lock_type() == 1)) {
+ _D("phone lock state, ignore home key..!!");
+ key_info.homekey_count = 0; //initialize homekey count
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _D("scover is closed, ignore home key..!!");
+ key_info.homekey_count = 0; //initialize homekey count
+ return ECORE_CALLBACK_RENEW;
+ }
+#if 0
+ _release_home_key(val);
+#else
+ // Check homekey timer
+ if(key_info.homekey_timer) {
+ ecore_timer_del(key_info.homekey_timer);
+ key_info.homekey_timer = NULL;
+ _D("delete homekey timer");
+ }
+
+ // Cancel key operation
+ if (EINA_TRUE == key_info.cancel) {
+ _D("Cancel key is activated");
+ key_info.cancel = EINA_FALSE;
+ key_info.homekey_count = 0; //initialize homekey count
+ return ECORE_CALLBACK_RENEW;
+ }
+ else{
+ ecore_timer_del(key_info.cancel_key_timer);
+ key_info.cancel_key_timer = NULL;
+ key_info.is_cancel = EINA_FALSE;
+ syspopup_destroy_all();
+ _D("delete cancelkey timer");
+ }
+
+#if 0
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (val != SETTING_PSMODE_EMERGENCY) {
+ // Check long press timer
+ if(key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ _D("delete long press timer");
+ } else {
+ key_info.homekey_count = 0; //initialize homekey count
+ return ECORE_CALLBACK_RENEW;
+ }
+ }
+#else
+ // Check long press timer
+ if(key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ _D("delete long press timer");
+ } else {
+ key_info.homekey_count = 0; //initialize homekey count
+ return ECORE_CALLBACK_RENEW;
+ }
+#endif
+ key_info.homekey_timer = ecore_timer_add(HOMEKEY_TIMER_SEC, _homekey_timer_cb, (void *) lock_state);
+ return ECORE_CALLBACK_RENEW;
+#endif
+ } else if (!strcmp(ev->keyname, KEY_PAUSE)) {
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("CANCEL Key is released");
+ key_info.cancel = EINA_FALSE;
+ } else if (!strcmp(ev->keyname, KEY_MEDIA)) {
+ if (key_info.media_long_press) { // Short press
+ ecore_timer_del(key_info.media_long_press);
+ key_info.media_long_press = NULL;
+
+ _release_multimedia_key("KEY_PLAYCD");
+ }
+ } else if (!strcmp(ev->keyname, KEY_APPS)) {
+ _D("App tray key is released");
+ menu_daemon_launch_app_tray();
+ } else if (!strcmp(ev->keyname, KEY_TASKSWITCH)) {
+ _D("Task switch key is released");
+ _launch_taskmgr_cb(NULL);
+ } else if (!strcmp(ev->keyname, KEY_WEBPAGE)) {
+ _D("Web page key is released");
+ if (menu_daemon_open_app(WEBPAGE_PKG_NAME) < 0)
+ _E("Failed to launch the web page");
+ } else if (!strcmp(ev->keyname, KEY_MAIL)) {
+ _D("Mail key is released");
+ if (menu_daemon_open_app(MAIL_PKG_NAME) < 0)
+ _E("Failed to launch the mail");
+ } else if (!strcmp(ev->keyname, KEY_CONNECT)) {
+ _D("Connect key is released");
+ if (menu_daemon_open_app(DIALER_PKG_NAME) < 0)
+ _E("Failed to launch the dialer");
+ } else if (!strcmp(ev->keyname, KEY_SEARCH)) {
+ _D("Search key is released");
+#if 0
+ if (menu_daemon_open_app(SEARCH_PKG_NAME) < 0)
+ _E("Failed to launch the search");
+#else
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+ if (val == VCONFKEY_IDLE_LOCK) {
+ _D("lock state, ignore search key..!!");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _D("scover is closed, ignore search key..!!");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (menu_daemon_launch_search() < 0)
+ _E("Failed to launch the search");
+#endif
+ } else if (!strcmp(ev->keyname, KEY_VOICE)) {
+ _D("Voice key is released");
+ if (EINA_FALSE == _launch_svoice())
+ _E("Failed to launch the svoice");
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool _destroy_syspopup_cb(void* data)
+{
+ _D("timer for cancel key operation");
+ key_info.cancel_key_timer = NULL;
+ if(key_info.is_cancel == EINA_TRUE){
+ _W("cancel key is activated. Do not destroy syspopup");
+ key_info.is_cancel = EINA_FALSE;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ key_info.is_cancel = EINA_FALSE;
+ syspopup_destroy_all();
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _key_press_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Down *ev = event;
+ int val = -1;
+
+ if (!ev) {
+ _D("_key_press_cb : Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_press_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_press_cb : %s Pressed", ev->keyname);
+ }
+
+ if (!strcmp(ev->keyname, KEY_SEND)) {
+ _D("Launch calllog");
+ if (menu_daemon_open_app(CALLLOG_PKG_NAME) < 0)
+ _SECURE_E("Failed to launch %s", CALLLOG_PKG_NAME);
+ } else if(!strcmp(ev->keyname, KEY_CONFIG)) {
+ _D("Launch camera");
+ if (menu_daemon_open_app(CAMERA_PKG_NAME) < 0)
+ _SECURE_E("Failed to launch %s", CAMERA_PKG_NAME);
+ } else if (!strcmp(ev->keyname, KEY_HOME)) {
+ _W("Home Key is pressed");
+ if (key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ }
+
+// syspopup_destroy_all();
+ key_info.cancel_key_timer = ecore_timer_add(CANCEL_KEY_TIMER_SEC, _destroy_syspopup_cb, NULL);
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &val) < 0) {
+ _E("Cannot get VCONFKEY");
+ }
+ if (val == SETTING_PSMODE_EMERGENCY) {
+ key_info.homekey_count = 1;
+ _D("Emergency mode, ignore home key..!!");
+ } else {
+ // Check homekey press count
+ key_info.homekey_count++;
+ _W("homekey count : %d", key_info.homekey_count);
+
+ // Check homekey timer
+ if(key_info.homekey_timer) {
+ ecore_timer_del(key_info.homekey_timer);
+ key_info.homekey_timer = NULL;
+ _D("delete homekey timer");
+ }
+ }
+ _D("create long press timer");
+ key_info.long_press_timer = ecore_timer_add(LONG_PRESS_TIMER_SEC, _launch_taskmgr_cb, NULL);
+ if (!key_info.long_press_timer)
+ _E("Failed to add timer for long press detection");
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("Cancel button is pressed");
+ key_info.cancel = EINA_TRUE;
+ key_info.is_cancel = EINA_TRUE;
+ if (key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ }
+ } else if (!strcmp(ev->keyname, KEY_MEDIA)) {
+ _D("Media key is pressed");
+
+ if (key_info.media_long_press) {
+ ecore_timer_del(key_info.media_long_press);
+ key_info.media_long_press = NULL;
+ }
+
+ key_info.media_long_press = ecore_timer_add(0.5, _launch_svoice_cb, NULL);
+ if (!key_info.media_long_press)
+ _E("Failed to add timer for long press detection");
+ } else if (!strcmp(ev->keyname, KEY_APPS)) {
+ _D("App tray key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_TASKSWITCH)) {
+ _D("Task switch key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_WEBPAGE)) {
+ _D("Web page key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_MAIL)) {
+ _D("Mail key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_SEARCH)) {
+ _D("Search key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_VOICE)) {
+ _D("Voice key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_CONNECT)) {
+ _D("Connect key is pressed");
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+void _media_key_event_cb(media_key_e key, media_key_event_e status, void *user_data)
+{
+ _D("MEDIA KEY EVENT : %d", key);
+ if (MEDIA_KEY_STATUS_PRESSED == status) return;
+
+ if (MEDIA_KEY_PAUSE == key) {
+ _release_multimedia_key("KEY_PAUSECD");
+ } else if (MEDIA_KEY_PLAY == key) {
+ _release_multimedia_key("KEY_PLAYCD");
+ } else if (MEDIA_KEY_PLAYPAUSE == key) {
+ _release_multimedia_key("KEY_PLAYPAUSECD");
+ }
+}
+
+
+#define APP_ID_SPLIT_LAUNCHER "com.samsung.split-launcher"
+#define APP_ID_MINIAPPS_LAUNCHER "com.samsung.mini-apps"
+#define STR_ATOM_KEY_BACK_LONGPRESS "KEY_BACK_LONGPRESS"
+#define STR_ATOM_KEY_MENU_LONGPRESS "KEY_MENU_LONGPRESS"
+static Eina_Bool _client_message_cb(void *data, int type, void *event)
+{
+ Ecore_X_Event_Client_Message *ev = event;
+ Ecore_X_Atom safety_assurance_atom;
+ Ecore_X_Atom atomMenuLongPress;
+ Ecore_X_Atom atomBackLongPress;
+
+ if (ev->format != 32)
+ return ECORE_CALLBACK_RENEW;
+
+ safety_assurance_atom = ecore_x_atom_get(STR_ATOM_XKEY_COMPOSITION);
+ atomMenuLongPress = ecore_x_atom_get(STR_ATOM_KEY_MENU_LONGPRESS);
+ atomBackLongPress = ecore_x_atom_get(STR_ATOM_KEY_BACK_LONGPRESS);
+#if 0
+ _D("_client_message_cb, safety_assurance_atom=[0x%x] atomMenuLongPress=[0x%x] atomBackLongPress=[0x%x]",
+ safety_assurance_atom, atomMenuLongPress, atomBackLongPress);
+#endif
+ if ((ev->win == key_info.keyrouter_notiwindow) &&
+ (ev->message_type == safety_assurance_atom) && (ev->format == 32)) {
+#if 0 /* Safety Assistance is changed to power key */
+ int press = ev->data.l[2];
+ int key_sum = ev->data.l[0]+ev->data.l[1];
+ if (key_sum == 245) {
+ _D("check key_sum[%d] to 122(volume_down)+123(volume_up), press=[%d]", key_sum, press);
+ if (press) {
+ if (key_info.client_msg_timer) {
+ ecore_timer_del(key_info.client_msg_timer);
+ key_info.client_msg_timer = NULL;
+ }
+ key_info.enable_safety_assurance = EINA_FALSE;
+ key_info.client_msg_timer = ecore_timer_add(3, _client_msg_timer_cb, NULL);
+ if (!key_info.client_msg_timer)
+ _E("Failed to add timer for clent message");
+ } else {
+ if (key_info.client_msg_timer) {
+ ecore_timer_del(key_info.client_msg_timer);
+ key_info.client_msg_timer = NULL;
+ }
+#if 0
+ if (key_info.enable_safety_assurance == EINA_TRUE) {
+ _D("Launch SafetyAssurance");
+ _launch_safety_assurance();
+ }
+ key_info.enable_safety_assurance = EINA_FALSE;
+#endif
+ }
+ }
+#endif
+ } else if (ev->message_type == atomBackLongPress) {
+ // Back key is long-pressed.
+ _D("ev->message_type=[0x%x], Back key long press", ev->message_type);
+
+ int val = 0;
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+
+ if (VCONFKEY_IDLE_LOCK == val) {
+ _D("Lock state, ignore back key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (vconf_get_int(VCONFKEY_PWLOCK_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_PWLOCK_STATE");
+ }
+
+ if (VCONFKEY_PWLOCK_BOOTING_LOCK == val || VCONFKEY_PWLOCK_RUNNING_LOCK == val) {
+ _E("PW-lock state, ignore back key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _D("Scover is closed, ignore back ke long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+#ifdef SPLIT_LAUNCHER_ENABLE //ORG
+ int multiwindow_enabled = 0;
+ if (vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &multiwindow_enabled) < 0) {
+ _E("Cannot get VCONFKEY");
+ multiwindow_enabled = 0;
+ }
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ val = 0;
+ }
+
+ if ((val == 1) || (multiwindow_enabled == 0)) {
+ _D("TTS : %d, Multiwindow enabled : %d", val, multiwindow_enabled);
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ _D("Launch the split-launcher");
+
+ int ret = aul_launch_app(APP_ID_SPLIT_LAUNCHER, NULL);
+ if (0 > ret) _E("cannot launch the split-launcher (%d)", ret);
+#else //DCM
+ char *package = menu_daemon_get_selected_pkgname();
+ if (!package) return ECORE_CALLBACK_RENEW;
+
+ int apptray_enabled = !strcmp(package, CLUSTER_HOME_PKG_NAME);
+ free(package);
+ if (!apptray_enabled) return ECORE_CALLBACK_RENEW;
+
+ _D("Launch the app-tray");
+
+ bundle *b = bundle_create();
+ retv_if(NULL == b, false);
+ bundle_add(b, "LAUNCH", "ALL_APPS");
+ int ret = aul_launch_app(APP_TRAY_PKG_NAME, b);
+ if (0 > ret) _E("cannot launch the app-tray (%d)", ret);
+ bundle_free(b);
+#endif
+ } else if (ev->message_type == atomMenuLongPress) {
+ // Menu key is long-pressed.
+ _D("ev->message_type=[0x%x], Menu key long press", ev->message_type);
+
+ int val = 0;
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_IDLE_LOCK_STATE");
+ }
+
+ if (VCONFKEY_IDLE_LOCK == val) {
+ _E("Lock state, ignore menu key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (vconf_get_int(VCONFKEY_PWLOCK_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_PWLOCK_STATE");
+ }
+
+ if (VCONFKEY_PWLOCK_BOOTING_LOCK == val || VCONFKEY_PWLOCK_RUNNING_LOCK == val) {
+ _E("PW-lock state, ignore menu key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val) < 0) {
+ _E("Cannot get VCONFKEY_SETAPPL_PSMODE");
+ }
+
+ if (SETTING_PSMODE_EMERGENCY == val) {
+ _E("Emergency mode, ignore menu key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (lockd_get_hall_status() == HALL_COVERED_STATUS) {
+ _D("Scover is closed, ignore menu key long-press.");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ _D("Launch the mini-apps");
+ int ret_aul;
+ bundle *b;
+ b = bundle_create();
+ retv_if(NULL == b, ECORE_CALLBACK_RENEW);
+ bundle_add(b, "HIDE_LAUNCH", "0");
+ ret_aul = aul_launch_app("com.samsung.mini-apps", b);
+ if (0 > ret_aul) _E("cannot launch the mini apps (%d)", ret_aul);
+ bundle_free(b);
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+static bool gesture_is_availble_key(void)
+{
+
+ int ret = 0;
+ int status = 0;
+
+
+ ret = vconf_get_int(VCONFKEY_PWLOCK_STATE, &status);
+ if (ret != 0)
+ {
+ _E("fail to get memory/pwlock/state%d", ret);
+ return false;
+ }
+
+
+ if( status == VCONFKEY_PWLOCK_RUNNING_UNLOCK || status == VCONFKEY_PWLOCK_BOOTING_UNLOCK)
+ {
+ _D("enter the idle mode (%d)", status);
+ }
+ else
+ {
+ _D("don't enter the idle mode(%d)", status);
+ return false;
+ }
+
+ _D("checking idle lock");
+
+ ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &status);
+ if (ret != 0)
+ {
+ _E("fail to get memory/pwlock/state%d", ret);
+ return false;
+ }
+
+
+ if( status == VCONFKEY_IDLE_LOCK)
+ {
+ _D("enter the lock mode(%d)", status);
+ return false;
+ }
+ else
+ {
+ _D("unlock state");
+ }
+
+ return true;
+}
+
+
+static inline void launch_app(int x, int y)
+{
+ // e->cx, e->cy
+ bundle *param;
+ int pid;
+ int status = 0;
+ int ret = 0;
+
+ if(gesture_is_availble_key() == false)
+ {
+ _D("can't launch");
+ return;
+ }
+
+ _D("checking status");
+ ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE , &status);
+ if (ret != 0) _D("fail to VCONFKEY_SETAPPL_PSMODE", ret);
+
+ if( status == SETTING_PSMODE_EMERGENCY)
+ {
+ _D(" emergency on");
+ return;
+ }
+
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS , &status);
+ if (ret != 0) _D("fail to VCONFKEY_SETAPPL_ACCESSIBILITY_TTS", ret);
+
+ if( status == 1)
+ {
+ _D(" tts on");
+ return;
+ }
+
+ ret = vconf_get_bool(_VCONF_QUICK_COMMADN_NAME, &status);
+ if (ret != 0) _E("fail to get db/aircommand/enabled:%d", ret);
+
+ if( status == 0)
+ {
+ _D("can't launch because of off");
+ return;
+ }
+
+ ret = vconf_get_bool("db/aircommand/floating", &status);
+ if (ret != 0) _E("fail to get db/aircommand/floating:%d", ret);
+
+ if( status == 1)
+ {
+ _D("only floating");
+ return;
+ }
+
+ param = bundle_create();
+ if (param) {
+ char coord[16];
+ snprintf(coord, sizeof(coord), "%dx%d", x, y);
+ bundle_add(param, "coordinate", coord);
+ }
+
+ feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP);
+
+ pid = aul_launch_app("com.samsung.air-command", param);
+ _D("Launch Pie Menu: %d\n", pid);
+
+ if (param) {
+ bundle_free(param);
+ }
+}
+
+
+
+#if 0
+static int gesture_hold_cb(void *data, int ev_type, void *ev)
+{
+ Ecore_X_Event_Gesture_Notify_Hold *e = ev;
+
+ if (e->num_fingers != 2) {
+ return 1;
+ }
+
+ switch (e->subtype) {
+ case ECORE_X_GESTURE_BEGIN:
+ _D("Begin: hold[%d]\n", e->hold_time);
+ launch_app(e->cx, e->cy);
+ break;
+ case ECORE_X_GESTURE_UPDATE:
+ _D("Update: hold[%d]\n", e->hold_time);
+ break;
+ case ECORE_X_GESTURE_END:
+ _D("End: hold[%d]\n", e->hold_time);
+ break;
+ default:
+ break;
+ }
+
+ return 1;
+}
+#endif
+
+
+
+static int gesture_cb(void *data, int ev_type, void *ev)
+{
+ Ecore_X_Event_Gesture_Notify_Tap *e = ev;
+
+ _D("key");
+
+ if (e->tap_repeat != 2) {
+ return 1;
+ }
+
+ if (e->num_fingers == 2) {
+ launch_app(e->cx, e->cy);
+ }
+
+ return 1;
+}
+
+
+
+static int gesture_flick_cb(void *data, int ev_type, void *ev)
+{
+ Ecore_X_Event_Gesture_Notify_Flick *e = ev;
+
+ _D(" input bezel");
+
+ if(e->num_fingers == 1)
+ {
+ launch_app(0, 0);
+ }
+
+ return 1;
+}
+
+
+
+static void gesture_key_init(void)
+{
+ int status;
+
+ _D("Init gesture for quick command");
+
+ if( gbRegisterDuobleTap > 1)
+ {
+ _E("Already registered callback cnt[%d]", gbRegisterDuobleTap);
+ return;
+ }
+
+ gbRegisterDuobleTap++;
+
+ status = ecore_x_gesture_event_grab(key_info.win, ECORE_X_GESTURE_EVENT_TAP, 2);
+ if (!status) {
+ _E("%d\n", status);
+ return;
+ }
+#if _DEF_BEZEL_AIR_COMMAND
+ status = ecore_x_gesture_event_grab(key_info.win, ECORE_X_GESTURE_EVENT_FLICK, 1);
+ if (!status) {
+ _E("%d\n", status);
+ return;
+ }
+#endif
+/*
+ status = ecore_x_gesture_event_grab(key_info.win, ECORE_X_GESTURE_EVENT_HOLD, 2);
+ if (!status) {
+ _E("%d\n", status);
+ return;
+ }
+*/
+ key_info.two_finger_double_tap = ecore_event_handler_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, (Ecore_Event_Handler_Cb)gesture_cb, NULL);
+ if (!key_info.two_finger_double_tap) {
+ _E("Failed to add handler\n");
+ }
+#if _DEF_BEZEL_AIR_COMMAND
+ key_info.bezel_gesture = ecore_event_handler_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, (Ecore_Event_Handler_Cb)gesture_flick_cb, NULL);
+ if (!key_info.bezel_gesture) {
+ _E("Failed to add handle about bezel_gesture\n");
+ }
+#endif
+/*
+ key_info.two_finger_long_tap = ecore_event_handler_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, (Ecore_Event_Handler_Cb)gesture_hold_cb, NULL);
+ if (!key_info.two_finger_long_tap) {
+ _E("Failed to add handler\n");
+ }
+*/
+// feedback_initialize();
+}
+
+static void gesture_key_fini(void)
+{
+ int status;
+
+ _D("fini gesture for quick command");
+
+ gbRegisterDuobleTap--;
+
+ if( gbRegisterDuobleTap < 0 )
+ {
+ _D("register value can't be decreased");
+ gbRegisterDuobleTap = 0;
+ }
+
+ if (key_info.two_finger_double_tap) {
+ ecore_event_handler_del(key_info.two_finger_double_tap);
+ key_info.two_finger_double_tap = NULL;
+ }
+
+ if (key_info.two_finger_long_tap) {
+ ecore_event_handler_del(key_info.two_finger_long_tap);
+ key_info.two_finger_long_tap = NULL;
+ }
+
+#if _DEF_BEZEL_AIR_COMMAND
+ if (key_info.bezel_gesture) {
+ ecore_event_handler_del(key_info.bezel_gesture);
+ key_info.bezel_gesture = NULL;
+ }
+#endif
+
+ status = ecore_x_gesture_event_ungrab(key_info.win, ECORE_X_GESTURE_EVENT_TAP, 2);
+ if (!status) {
+ _E("%d\n", status);
+ }
+
+ status = ecore_x_gesture_event_ungrab(key_info.win, ECORE_X_GESTURE_EVENT_HOLD, 2);
+ if (!status) {
+ _E("%d\n", status);
+ }
+#if _DEF_BEZEL_AIR_COMMAND
+ status = ecore_x_gesture_event_ungrab(key_info.win, ECORE_X_GESTURE_EVENT_FLICK, 1);
+ if (!status) {
+ _E("%d\n", status);
+ }
+#endif
+// feedback_deinitialize();
+}
+
+static void gesture_key_vconf_cb(keynode_t *key, void* pUserData)
+{
+ char *keynode_name = vconf_keynode_get_name(key);
+ ret_if(!keynode_name);
+
+ if(!memcmp(keynode_name, _VCONF_QUICK_COMMADN_NAME, strlen(_VCONF_QUICK_COMMADN_NAME)))
+ {
+ if(vconf_keynode_get_int(key))
+ {
+ int ret = 0;
+ int status = 0;
+
+ ret = vconf_get_bool(_VCONF_QUICK_COMMADN_NAME, &status);
+ if (ret != 0) _E("fail to get db/aircommand/enabled:%d", ret);
+
+ if( status == 1)
+ {
+// _D(" quick command on");
+// gesture_key_init();
+
+ int nRet = 0;
+ int nStatus = 0;
+
+ _D(" quick command on");
+
+ nRet = vconf_get_bool("db/aircommand/floating", &nStatus);
+ if (nRet != 0) _E("fail to get db/aircommand/floating:%d", nRet);
+
+ if( nStatus == 1)
+ {
+ int pid = aul_launch_app("com.samsung.air-command", NULL);
+ _D("run a floating window after booting(%d)", pid);
+// gesture_key_fini();
+ }
+ else
+ {
+ _D(" quick command double tap");
+ gesture_key_init();
+ }
+
+ }
+ else
+ {
+ _D(" quick command off");
+
+ gesture_key_fini();
+ }
+ }
+ }
+}
+
+static Eina_Bool gesture_wating_launch_cb(void *data)
+{
+ int pid = -1;
+
+ pid = aul_launch_app("com.samsung.air-command", NULL);
+ _D("launch callback (%d)", pid);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void gesture_floating_vconf_cb(keynode_t *key, void* pUserData)
+{
+ char *keynode_name = vconf_keynode_get_name(key);
+ ret_if(!keynode_name);
+
+ if(!memcmp(keynode_name, _VCONF_QUICK_COMMADN_FLOATING, strlen(_VCONF_QUICK_COMMADN_FLOATING)))
+ {
+ if(vconf_keynode_get_int(key))
+ {
+ int ret = 0;
+ int status = 0;
+
+ _D("changed floating mode");
+
+ ret = vconf_get_bool(_VCONF_QUICK_COMMADN_NAME, &status);
+ if (ret != 0) _E("fail to get db/aircommand/enabled:%d", ret);
+
+ if( status == 1)
+ {
+ int nRet = 0;
+ int nStatus = 0;
+
+ _D(" quick command on");
+
+ nRet = vconf_get_bool(_VCONF_QUICK_COMMADN_FLOATING, &nStatus);
+ if (nRet != 0) _E("fail to get db/aircommand/floating:%d", nRet);
+
+ if( nStatus == 1)
+ {
+
+ if(gtimer_launch)
+ {
+ ecore_timer_del(gtimer_launch);
+ gtimer_launch = NULL;
+ }
+
+ gtimer_launch = ecore_timer_add(0.100f, gesture_wating_launch_cb, NULL);
+
+
+
+/*
+ service_h hService;
+
+ _D(" quick floating window: on");
+
+ service_create(&hService);
+ service_set_package(hService, "com.samsung.air-command");
+
+ if (service_send_launch_request(hService, NULL, this) != SERVICE_ERROR_NONE)
+ {
+ DLOG_QCOMMAND_ERR("Failed to com.samsung.air-command");
+ }
+ else
+ {
+ DLOG_QCOMMAND_DBG("Success to com.samsung.air-command");
+ }
+
+ service_destroy(hService);
+*/
+ }
+ else
+ {
+ _D(" quick command double tap");
+ }
+
+ }
+ else
+ {
+ _D(" already quick command off status");
+ }
+
+ }
+ }
+}
+
+
+static void gesture_enter_idle_initialize(void)
+{
+ int ret = 0;
+ int status = 0;
+
+ _D("Idle enter checking...");
+
+ ret = vconf_get_bool(_VCONF_QUICK_COMMADN_NAME, &status);
+ if (ret != 0) _E("fail to get db/aircommand/enabled:%d", ret);
+
+ if( status == 0)
+ {
+ _D("disabled qujick command");
+ return;
+ }
+
+ status = 0;
+ ret = vconf_get_int(VCONFKEY_PWLOCK_STATE, &status);
+ if (ret != 0)
+ {
+ _E("fail to get db/aircommand/enabled:%d", ret);
+ return;
+ }
+
+ if( status == VCONFKEY_PWLOCK_RUNNING_UNLOCK || status == VCONFKEY_PWLOCK_BOOTING_UNLOCK)
+ {
+ gbenter_idle = true;
+ status = 0;
+
+ /* If it has a floating window, run it*/
+ ret = vconf_get_bool(_VCONF_QUICK_COMMADN_FLOATING, &status);
+ if (ret != 0) _E("fail to get db/aircommand/floating:%d", ret);
+
+ if( status == 1)
+ {
+ if( gbinit_floatwin == false)
+ {
+ int pid = aul_launch_app("com.samsung.air-command", NULL);
+ _D("run a floating window after booting(%d)", pid);
+
+ gbinit_floatwin = true;
+ }
+ }
+ else
+ {
+ if( gbinit_floatwin == false)
+ {
+ _D("register touch grap");
+
+ gesture_key_init();
+
+ gbinit_floatwin = true;
+ }
+
+ }
+ }
+ else
+ {
+ _D("already no idle state(%d)", status);
+ }
+}
+
+static void gesture_enter_idle_vconf_cb(keynode_t *key, void* pUserData)
+{
+ char *keynode_name = vconf_keynode_get_name(key);
+ ret_if(!keynode_name);
+
+ if(!memcmp(keynode_name, VCONFKEY_PWLOCK_STATE, strlen(VCONFKEY_PWLOCK_STATE)))
+ {
+ if(vconf_keynode_get_int(key))
+ {
+ _D("received cb");
+ gesture_enter_idle_initialize();
+ }
+
+ }
+
+}
+
+
+static void gesture_key_register(void)
+{
+ int ret;
+ char buf[1024] = { 0, };
+
+ ret = vconf_notify_key_changed(_VCONF_QUICK_COMMADN_NAME, (vconf_callback_fn)gesture_key_vconf_cb, NULL);
+ if (ret < 0){
+
+ _E("Error: Failed to sigaction[%s]", strerror_r(errno, buf, sizeof(buf)));
+ }
+
+ ret = vconf_notify_key_changed(_VCONF_QUICK_COMMADN_FLOATING, (vconf_callback_fn)gesture_floating_vconf_cb, NULL);
+ if (ret < 0){
+
+ _E("Error: Failed to sigaction[%s]", strerror_r(errno, buf, sizeof(buf)));
+ }
+
+ ret = vconf_notify_key_changed(VCONFKEY_PWLOCK_STATE, (vconf_callback_fn)gesture_enter_idle_vconf_cb, NULL);
+ if (ret < 0){
+
+ _E("Error: Failed to sigaction[%s]", strerror_r(errno, buf, sizeof(buf)));
+ }
+
+ gesture_enter_idle_initialize();
+}
+
+#define PROP_HWKEY_EMULATION "_HWKEY_EMULATION"
+static void _set_long_press_time(void)
+{
+ Ecore_X_Window *keyrouter_input_window;
+ Ecore_X_Atom atom_keyrouter = ecore_x_atom_get(PROP_HWKEY_EMULATION);
+
+ int num = 0;
+ if (EINA_FALSE == ecore_x_window_prop_property_get(ecore_x_window_root_first_get(),
+ atom_keyrouter,
+ ECORE_X_ATOM_WINDOW,
+ 32,
+ (unsigned char **) &keyrouter_input_window,
+ &num))
+ {
+ _E("Cannot get the property");
+ return;
+ }
+
+ int longpress_timeout = 500; // miliseconds
+ int menu_keycode = ecore_x_keysym_keycode_get(KEY_MENU);
+ ecore_x_client_message32_send(*keyrouter_input_window,
+ atom_keyrouter,
+ ECORE_X_EVENT_MASK_NONE,
+ key_info.win,
+ menu_keycode,
+ longpress_timeout,
+ 0,
+ 0);
+
+ int back_keycode = ecore_x_keysym_keycode_get(KEY_BACK);
+ ecore_x_client_message32_send(*keyrouter_input_window,
+ atom_keyrouter,
+ ECORE_X_EVENT_MASK_NONE,
+ key_info.win,
+ back_keycode,
+ longpress_timeout,
+ 0,
+ 0);
+}
+
+void create_key_window(void)
+{
+ int ret;
+ Ecore_X_Atom atomNotiWindow;
+ Ecore_X_Window keyrouter_notiwindow;
+
+ key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+ if (!key_info.win) {
+ _D("Failed to create hidden window");
+ return;
+ }
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_NONE);
+ /*
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_MOUSE_DOWN);
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_MOUSE_UP);
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_MOUSE_IN);
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_MOUSE_OUT);
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_MOUSE_MOVE);
+ */
+
+ ecore_x_icccm_title_set(key_info.win, "menudaemon,key,receiver");
+ ecore_x_netwm_name_set(key_info.win, "menudaemon,key,receiver");
+ ecore_x_netwm_pid_set(key_info.win, getpid());
+
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_HOME, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEDOWN, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEUP, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_CONFIG, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_MEDIA, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_APPS, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_TASKSWITCH, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_WEBPAGE, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_MAIL, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_SEARCH, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_VOICE, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_CONNECT, SHARED_GRAB);
+ ret = utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_POWER, SHARED_GRAB);
+ if (ret != 0) {
+ _E("utilx_grab_key KEY_POWER GrabSHARED_GRAB failed, ret[%d]", ret);
+ }
+
+ key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL);
+ if (!key_info.key_up)
+ _E("Failed to register a key up event handler");
+
+ key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL);
+ if (!key_info.key_down)
+ _E("Failed to register a key down event handler");
+
+ /* Get notifwindow */
+ atomNotiWindow = ecore_x_atom_get(STR_ATOM_KEYROUTER_NOTIWINDOW);
+ ret = ecore_x_window_prop_window_get(ecore_x_window_root_first_get(), atomNotiWindow, &keyrouter_notiwindow, 1);
+ if (ret > 0) {
+ _D("Succeed to get keyrouter notiwindow ! ret = %d (win=0x%x)\n", ret, keyrouter_notiwindow);
+ /* mask set for keyrouter notiwindow */
+ ecore_x_window_sniff(keyrouter_notiwindow);
+ key_info.keyrouter_notiwindow = keyrouter_notiwindow;
+ //xkey_composition = ecore_x_atom_get(STR_ATOM_XKEY_COMPOSITION);
+ /* Register client msg */
+ key_info.client_msg_hd = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
+ _client_message_cb, NULL);
+ if (!key_info.client_msg_hd)
+ _E("failed to add handler(ECORE_X_EVENT_CLIENT_MESSAGE)");
+ } else {
+ _E("Failed to get keyrouter notiwindow!! ret = %d, atomNotiWindow = 0x%x, keyrouter_notiwindow = 0x%x", ret, atomNotiWindow, keyrouter_notiwindow);
+ }
+
+ media_key_reserve(_media_key_event_cb, NULL);
+ //gesture_key_register();
+ _set_long_press_time();
+// gesture_key_init();
+}
+
+
+
+void destroy_key_window(void)
+{
+ gesture_key_fini();
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_HOME);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEDOWN);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEUP);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_CONFIG);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_MEDIA);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_APPS);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_TASKSWITCH);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_WEBPAGE);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_MAIL);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_SEARCH);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_VOICE);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_CONNECT);
+
+ if (key_info.key_up) {
+ ecore_event_handler_del(key_info.key_up);
+ key_info.key_up = NULL;
+ }
+
+ if (key_info.key_down) {
+ ecore_event_handler_del(key_info.key_down);
+ key_info.key_down = NULL;
+ }
+
+ ecore_x_window_delete_request_send(key_info.win);
+ key_info.win = 0x0;
+
+ media_key_release();
+}
+
+
+
+// End of a file
diff --git a/src/hw_key_w.c b/src/hw_key_w.c
new file mode 100755
index 0000000..7dc3d6c
--- /dev/null
+++ b/src/hw_key_w.c
@@ -0,0 +1,1480 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <ail.h>
+#include <bundle.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <vconf.h>
+
+#include <syspopup_caller.h>
+#include <dd-display.h>
+#include <E_DBus.h>
+#include <feedback.h>
+#include <pkgmgr-info.h>
+#include <system/media_key.h>
+
+#include "starter_w.h"
+#include "hw_key_w.h"
+#include "util.h"
+
+#define GRAB_TWO_FINGERS 2
+#define POWERKEY_TIMER_SEC 0.25
+#define POWERKEY_LCDOFF_TIMER_SEC 0.4
+#define LONG_PRESS_TIMER_SEC 0.7
+#define SYSPOPUP_END_TIMER_SEC 0.5
+
+#define APP_CONTROL_OPERATION_MAIN_KEY "__APP_SVC_OP_TYPE__"
+#define APP_CONTROL_OPERATION_MAIN_VALUE "http://tizen.org/appcontrol/operation/main"
+#define APP_CONTROL_OPERATION_DEFAULT_VALUE "http://tizen.org/appcontrol/operation/default"
+#define HOME_OPERATION_KEY "home_op"
+#define POWERKEY_VALUE "powerkey"
+
+#define USE_DBUS_POWEROFF 1
+
+#define POWEROFF_BUS_NAME "org.tizen.system.popup"
+#define POWEROFF_OBJECT_PATH "/Org/Tizen/System/Popup/Poweroff"
+#define POWEROFF_INTERFACE_NAME POWEROFF_BUS_NAME".Poweroff"
+#define METHOD_POWEROFF_NAME "PopupLaunch"
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define DOUBLE_PRESS_NONE "none"
+#define DOUBLE_PRESS_RECENT_APPS "recent"
+#define W_TASKMGR_PKGNAME "com.samsung.w-taskmanager"
+#define W_CONTROLS_PKGNAME "com.samsung.windicator"
+#define MUSIC_PLAYER_PKG_NAME "com.samsung.w-music-player"
+#define W_EMERGENCY_MESSAGE_PKGNAME "com.samsung.emergency-message"
+
+#define SVOICE_PKG_NAME "com.samsung.svoice"
+#define SVOICE_LAUNCH_BUNDLE_KEY "domain"
+#define SVOICE_LAUNCH_BUNDLE_HOMEKEY_VALUE "home_key"
+
+#define VCONFKEY_HOME_IS_TUTORIAL "memory/private/org.tizen.w-home/tutorial"
+#define VCONFKEY_SIMPLECLOCK_UI_STATUS "memory/alpm-clock-manager/simpleclock_ui_status"
+#define VCONFKEY_CALL_FORWARD_REQUESTING "memory/ciss/call_forward_requesting"
+#define VCONFKEY_REMOTE_LOCK_ISLOCKED "db/private/com.samsung.wfmw/is_locked"
+
+static struct {
+ Ecore_X_Window win;
+ Ecore_Event_Handler *key_up;
+ Ecore_Event_Handler *key_down;
+ Ecore_Event_Handler *two_fingers_hold_hd;
+ Ecore_Timer *long_press_timer;
+ Ecore_Timer *powerkey_timer;
+ Eina_Bool is_lcd_on;
+ int is_simple_clock_display;
+ Eina_Bool is_long_press;
+ int powerkey_count;
+ Eina_Bool is_cancel;
+ char *home_pkgname;
+} key_info = {
+ .win = 0x0,
+ .key_up = NULL,
+ .key_down = NULL,
+ .two_fingers_hold_hd = NULL,
+ .long_press_timer = NULL,
+ .powerkey_timer = NULL,
+ .is_lcd_on = EINA_FALSE,
+ .is_simple_clock_display = EINA_FALSE,
+ .is_long_press = EINA_FALSE,
+ .powerkey_count = 0,
+ .is_cancel = EINA_FALSE,
+ .home_pkgname = W_HOME_PKGNAME,
+};
+
+#if 0 // This is not W code
+/* NOTE: THIS FUNCTION Is ONLY USED FOR CONFIDENTIAL FEATURE. REMOVE ME */
+static inline int _launch_running_apps_FOR_TEMPORARY(void)
+{
+ bundle *kb = NULL;
+ char *package;
+ int ret;
+
+ package = menu_daemon_get_selected_pkgname();
+ if (!package)
+ return -ENOENT;
+
+ if (!strcmp(package, MENU_SCREEN_PKG_NAME)) {
+ free(package);
+ return -EINVAL;
+ }
+
+ free(package);
+
+ kb = bundle_create();
+ if (!kb) {
+ _E("Failed to create a bundle");
+ return -EFAULT;
+ }
+
+ bundle_add(kb, "LONG_PRESS", "1");
+ ret = menu_daemon_launch_app(APP_TRAY_PKG_NAME, kb);
+ bundle_free(kb);
+
+ if (ret < 0) {
+ _E("Failed to launch the running apps, ret : %d", ret);
+ return -EFAULT;
+ } else if (ret > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ret, OOM_IGNORE)) {
+ _E("Cannot set the memory policy for App tray(%d)", ret);
+ } else {
+ _E("Set the memory policy for App tray(%d)", ret);
+ }
+ }
+
+ return 0;
+}
+
+
+
+#define DESKDOCK_PKG_NAME "com.samsung.desk-dock"
+static Eina_Bool _launch_by_home_key(void *data)
+{
+ int lock_state = (int) data;
+ _D("lock_state : %d ", lock_state);
+
+ key_info.single_timer = NULL;
+
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ int cradle_status = menu_daemon_get_cradle_status();
+ if (0 < cradle_status) {
+ int ret;
+ _SECURE_D("Cradle is enabled to [%d], we'll launch the desk dock[%s]", cradle_status, DESKDOCK_PKG_NAME);
+ ret = menu_daemon_open_app(DESKDOCK_PKG_NAME);
+ if (ret < 0) {
+ _SECURE_E("cannot launch package %s(err:%d)", DESKDOCK_PKG_NAME, ret);
+ }
+ }
+
+ menu_daemon_open_homescreen(NULL);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+inline static Eina_Bool _launch_svoice(void)
+{
+ const char *pkg_name = NULL;
+ bundle *b;
+
+ pkg_name = menu_daemon_get_svoice_pkg_name();
+ retv_if(NULL == pkg_name, EINA_FALSE);
+
+ if (!strcmp(pkg_name, SVOICE_PKG_NAME)) {
+ int val = -1;
+
+ if (vconf_get_int(VCONFKEY_SVOICE_OPEN_VIA_HOME_KEY, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+
+ if (val != 1) {
+ _D("Launch nothing");
+ return EINA_FALSE;
+ }
+ }
+
+ b = bundle_create();
+ retv_if(!b, EINA_FALSE);
+
+ bundle_add(b, SVOICE_LAUNCH_BUNDLE_KEY, SVOICE_LAUNCH_BUNDLE_HOMEKEY_VALUE);
+ if (menu_daemon_launch_app(pkg_name, b) < 0)
+ _SECURE_E("Failed to launch %s", pkg_name);
+ bundle_free(b);
+
+ return EINA_TRUE;
+}
+
+
+
+static void _launch_safety_assurance(void)
+{
+ _SECURE_D("Launch %s", SAFETY_ASSURANCE_PKG_NAME);
+ if (menu_daemon_open_app(SAFETY_ASSURANCE_PKG_NAME) < 0) {
+ _SECURE_E("Cannot open %s", SAFETY_ASSURANCE_PKG_NAME);
+ }
+}
+
+
+static Eina_Bool _launch_svoice_cb(void* data)
+{
+ key_info.media_long_press = NULL;
+
+ int val = -1;
+ if (vconf_get_int(VCONFKEY_SVOICE_OPEN_VIA_EARPHONE_KEY, &val) < 0) {
+ _D("Cannot get VCONFKEY");
+ }
+ if (1 == val) {
+ _D("Launch SVOICE");
+
+ bundle *b;
+ b = bundle_create();
+ retv_if(!b, ECORE_CALLBACK_CANCEL);
+
+ bundle_add(b, SVOICE_LAUNCH_BUNDLE_KEY, SVOICE_LAUNCH_BUNDLE_VALUE);
+ if (menu_daemon_launch_app(SVOICE_PKG_NAME, b) < 0)
+ _SECURE_E("Failed to launch %s", TASKMGR_PKG_NAME);
+ bundle_free(b);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _client_msg_timer_cb(void* data)
+{
+ _D("_client_msg_timer_cb, safety assurance is enable");
+
+ key_info.enable_safety_assurance = EINA_TRUE;
+ _D("Launch SafetyAssurance");
+ _launch_safety_assurance();
+ key_info.client_msg_timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _set_unlock(void *data)
+{
+ _D("_set_unlock");
+ vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+inline static int _release_home_key(int lock_state)
+{
+ retv_if(NULL == key_info.long_press, EXIT_SUCCESS);
+ ecore_timer_del(key_info.long_press);
+ key_info.long_press = NULL;
+
+ if (NULL == key_info.single_timer) {
+ key_info.single_timer = ecore_timer_add(0.3, _launch_by_home_key, (void *) lock_state);
+ return EXIT_SUCCESS;
+ }
+ ecore_timer_del(key_info.single_timer);
+ key_info.single_timer = NULL;
+
+ if(EINA_TRUE == _launch_svoice()) {
+ if (lock_state == VCONFKEY_IDLE_LOCK) {
+ ecore_timer_add(0.8, _set_unlock, NULL);
+ }
+ }
+ return EXIT_SUCCESS;
+}
+
+
+
+inline static void _release_multimedia_key(const char *value)
+{
+ ret_if(NULL == value);
+
+ _D("Multimedia key is released with %s", value);
+
+ bundle *b;
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return;
+ }
+ bundle_add(b, "multimedia_key", value);
+
+ int ret;
+ ret = menu_daemon_launch_app(MUSIC_PLAYER_PKG_NAME, b);
+ if (ret < 0)
+ _E("Failed to launch the running apps, ret : %d", ret);
+
+ bundle_free(b);
+}
+
+
+static Eina_Bool _client_message_cb(void *data, int type, void *event)
+{
+ int key_sum;
+ int press;
+ Ecore_X_Event_Client_Message *ev = event;
+ Ecore_X_Atom safety_assurance_atom;
+
+ if (ev->format != 32)
+ return ECORE_CALLBACK_RENEW;
+
+ safety_assurance_atom = ecore_x_atom_get(ATOM_KEY_COMPOSITION);
+ if (ev->message_type == safety_assurance_atom) {
+ press = ev->data.l[2];
+ key_sum = ev->data.l[0]+ev->data.l[1];
+ if (key_sum == 245) {
+ _D("check key_sum[%d] to 122(volume_down)+123(volume_up), press=[%d]", key_sum, press);
+ if (press) {
+ if (key_info.client_msg_timer) {
+ ecore_timer_del(key_info.client_msg_timer);
+ key_info.client_msg_timer = NULL;
+ }
+ key_info.enable_safety_assurance = EINA_FALSE;
+ key_info.client_msg_timer = ecore_timer_add(3, _client_msg_timer_cb, NULL);
+ if (!key_info.client_msg_timer)
+ _E("Failed to add timer for clent message");
+ } else {
+ if (key_info.client_msg_timer) {
+ ecore_timer_del(key_info.client_msg_timer);
+ key_info.client_msg_timer = NULL;
+ }
+#if 0
+ if (key_info.enable_safety_assurance == EINA_TRUE) {
+ _D("Launch SafetyAssurance");
+ _launch_safety_assurance();
+ }
+ key_info.enable_safety_assurance = EINA_FALSE;
+#endif
+ }
+ }
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+#endif // This is not W code
+
+
+#if 0
+static int _append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+
+DBusMessage *_invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ _E("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _append_variant(&iter, sig, param);
+ if (r < 0) {
+ _E("append_variant error(%d)", r);
+ return NULL;
+ }
+
+#if 0 //Temp block sync call from power off popup.
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+
+ if (!reply) {
+ _E("dbus_connection_send error(No reply)");
+ }
+
+ if (dbus_error_is_set(&err)) {
+ _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ return reply;
+#else //Temp async call
+ r = dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ if (r != TRUE) {
+ _E("dbus_connection_send error(%s:%s:%s-%s)", dest, path, interface, method);
+ return -ECOMM;
+ }
+ _D("dbus_connection_send, ret=%d", r);
+ return NULL;
+#endif
+}
+
+
+static int _request_Poweroff(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+
+ msg = _invoke_dbus_method_sync(POWEROFF_BUS_NAME, POWEROFF_OBJECT_PATH, POWEROFF_INTERFACE_NAME,
+ METHOD_POWEROFF_NAME, NULL, NULL);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ _E("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ _D("%s-%s : %d", POWEROFF_INTERFACE_NAME, METHOD_POWEROFF_NAME, ret_val);
+ return ret_val;
+}
+#endif
+
+char *_get_app_type(const char *pkgname)
+{
+ int ret = 0;
+ char *apptype = NULL;
+ char *re_apptype = NULL;
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgname, &handle);
+ if (ret != PMINFO_R_OK)
+ return NULL;
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &apptype);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return NULL;
+ }
+
+ /*after call pkgmgrinfo_appinfo_destroy_appinfo, mainappid is destroyed with handle, so must copy it*/
+ re_apptype = strdup(apptype);
+ _SECURE_D("apptype : %s - %s", apptype, re_apptype);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return re_apptype;
+}
+
+static Eina_Bool _launch_home_by_powerkey(void)
+{
+ bundle *b = NULL;
+ int pid = 0;
+
+ _D("%s", __func__);
+
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return EINA_FALSE;
+ }
+ bundle_add(b, HOME_OPERATION_KEY, POWERKEY_VALUE);
+
+ pid = w_launch_app(key_info.home_pkgname, b);
+ _SECURE_D("launch[%s], pid[%d]", key_info.home_pkgname, pid);
+
+ if(pid < AUL_R_OK) {
+ if(b) {
+ bundle_free(b);
+ }
+ return EINA_FALSE;
+ }
+
+ if(b) {
+ bundle_free(b);
+ }
+ return EINA_TRUE;
+}
+
+
+static Eina_Bool _syspopup_end_timer_cb(void *data)
+{
+ /* terminate syspopup */
+ syspopup_destroy_all();
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+#define APP_TYPE_WIDGET "wgt"
+#define W_CAMERA_PKGNAME "com.samsung.w-camera-app"
+static Eina_Bool _launch_app_by_double_press(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return EINA_FALSE;
+ }
+ char *appid = NULL;
+ char *pkgname = NULL;
+ char *pkgtype = NULL;
+ bundle *b = NULL;
+ int pid = 0;
+ int ret = 0;
+ int ret_aul = 0;
+ int val = 0;
+ int tts_status = 0;
+ int pwlock_status = 0;
+
+ _D("%s", __func__);
+
+ /* Check home tutorial mode */
+ if(vconf_get_int(VCONFKEY_HOME_IS_TUTORIAL, &val) < 0) {
+ _E("Failed to get vconfkey[VCONFKEY_HOME_IS_TUTORIAL]");
+ }
+ if(val == 1) { // Home tutorial on
+ _E("Home Tutorial ON, ignore double key");
+ return EINA_FALSE;
+ }
+
+ /* Check UPS mode */
+ if(vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val) < 0) {
+ _E("Failed to get vconfkey[VCONFKEY_SETAPPL_PSMODE]");
+ }
+ if(val == SETTING_PSMODE_WEARABLE_ENHANCED) { //UPS Mode
+ _E("UPS Mode, ignore double key");
+ return EINA_FALSE;
+ }
+
+ /* Check TTS mode */
+ if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_status) < 0) {
+ _E("Failed to get vconfkey[VCONFKEY_SETAPPL_ACCESSIBILITY_TTS]");
+ }
+ if(tts_status == 1){ //TTS mode
+ _E("TTS Mode, ignore double key");
+ return EINA_FALSE;
+ }
+
+ /* Check Cool down mode */
+ if(ad->cool_down_mode != 0){
+ _E("Cool down mode is LimitAction(%d), ignore double key", ad->cool_down_mode);
+ return EINA_FALSE;
+ }
+
+ /* Check PW Lock state */
+ if(vconf_get_int(VCONFKEY_PWLOCK_STATE, &pwlock_status) < 0){
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_PWLOCK_STATE);
+ }
+ if((pwlock_status == VCONFKEY_PWLOCK_BOOTING_LOCK) || (pwlock_status == VCONFKEY_PWLOCK_RUNNING_LOCK)){
+ _E("pwlock state (%d), ignore double key", pwlock_status);
+ return EINA_FALSE;
+ }
+
+ /* Check Privacy Lock state */
+ if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0){
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_IDLE_LOCK_STATE);
+ }
+ if(val > VCONFKEY_IDLE_UNLOCK){
+ _E("lock state (%d), ignore double key", val);
+ return EINA_FALSE;
+ }
+
+ /* Check Call state */
+ if(vconf_get_int(VCONFKEY_CALL_STATE, &val) < 0){
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_CALL_STATE);
+ }
+ if(val != VCONFKEY_CALL_OFF){
+ _E("call state (%d), ignore double key", val);
+ return EINA_FALSE;
+ }
+
+ /* Check remote-lock state */
+ if(vconf_get_bool(VCONFKEY_REMOTE_LOCK_ISLOCKED, &val) < 0){
+ _E("failed to get %s", VCONFKEY_REMOTE_LOCK_ISLOCKED);
+ }
+
+ if(val == true){
+ _E("remote lock is on top (%d), ignore double key", val);
+ return EINA_FALSE;
+ }
+
+ appid = vconf_get_str(VCONFKEY_WMS_POWERKEY_DOUBLE_PRESSING);
+
+ if (appid == NULL) {
+ _E("appid is NULL");
+ } else if (!strcmp(appid, DOUBLE_PRESS_NONE)) {
+ _D("none : DOUBLE_PRESS_NONE !!");
+ return EINA_TRUE;
+ } else if (!strcmp(appid, DOUBLE_PRESS_RECENT_APPS)) {
+ _D("recent : launch task mgr..!!");
+
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return EINA_FALSE;
+ }
+ bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+
+ request_dbus_cpu_booster();
+ ret = w_launch_app(W_TASKMGR_PKGNAME, NULL);
+ if (ret >= 0) {
+ _SECURE_D("[%s] is launched, pid=[%d]", W_TASKMGR_PKGNAME, ret);
+ }
+ if(b) {
+ bundle_free(b);
+ }
+ return EINA_TRUE;
+ } else {
+ char *last = NULL;
+ char *temp = NULL;
+ char *new_appid = NULL;
+ last = strrchr(appid, '/');
+ if (last == NULL || *(last + 1) == NULL) {
+ _E("Invaild data");
+ } else {
+ _D("appid has class name");
+ new_appid = strdup(last + 1);
+ if(new_appid == NULL) {
+ _E("appid is NULL");
+ }
+ temp = strtok(appid, "/");
+ if(temp == NULL){
+ _E("Invalid data");
+ }
+ else{
+ pkgname = strdup(temp);
+ }
+ }
+ free(appid);
+ appid = new_appid;
+ }
+
+ if(appid == NULL) {
+ _E("appid is NULL. set default to none.");
+ return EINA_FALSE;
+ }
+
+ pkgtype = _get_app_type(pkgname);
+ if(pkgtype == NULL) {
+ _E("Failed to get app_type. app_type is NULL");
+ if(appid){
+ free(appid);
+ }
+ if(pkgname){
+ free(pkgname);
+ }
+ return EINA_FALSE;
+ }
+
+ _SECURE_D("appid : %s, pkgname : %s, pkgtype : %s", appid, pkgname, pkgtype);
+
+ if(!strcmp(pkgtype, APP_TYPE_WIDGET)){
+ ret_aul = aul_open_app(appid);
+ if(ret_aul < AUL_R_OK) {
+ _D("Launching app ret : [%d]", ret_aul);
+ free(appid);
+ free(pkgname);
+ free(pkgtype);
+ return EINA_FALSE;
+ }
+ if(appid) {
+ free(appid);
+ }
+ }
+ else{
+
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ if(appid) {
+ free(appid);
+ }
+ return EINA_FALSE;
+ }
+ bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+
+ if (!strcmp(appid, SVOICE_PKG_NAME)) {
+ bundle_add(b, SVOICE_LAUNCH_BUNDLE_KEY, SVOICE_LAUNCH_BUNDLE_HOMEKEY_VALUE);
+ }
+
+ request_dbus_cpu_booster();
+ pid = w_launch_app(appid, b);
+ _SECURE_D("launch[%s], pid[%d]", appid, pid);
+
+ if(pid < AUL_R_OK) {
+ if(b) {
+ bundle_free(b);
+ }
+ if(appid) {
+ free(appid);
+ }
+ return EINA_FALSE;
+ }
+
+#if 0
+ if (strcmp(appid, W_CONTROLS_PKGNAME)) {
+ /* terminate syspopup */
+ //syspopup_destroy_all();
+ ecore_timer_add(SYSPOPUP_END_TIMER_SEC, _syspopup_end_timer_cb, NULL);
+ }
+#endif
+ if(b) {
+ bundle_free(b);
+ }
+ if(appid) {
+ free(appid);
+ }
+ }
+ if(pkgname){
+ free(pkgname);
+ }
+ if(pkgtype){
+ free(pkgtype);
+ }
+ return EINA_TRUE;
+}
+
+
+static Eina_Bool _powerkey_timer_cb(void *data)
+{
+ int val = -1;
+ int trigger_val = -1;
+ int ret = -1;
+
+ _W("%s, powerkey count[%d]", __func__, key_info.powerkey_count);
+#if 0
+ if(key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ _D("delete long_press_timer");
+ }
+
+ if(key_info.powerkey_timer) {
+ ecore_timer_del(key_info.powerkey_timer);
+ key_info.powerkey_timer = NULL;
+ _D("delete powerkey_timer");
+ }
+#endif
+
+ key_info.powerkey_timer = NULL;
+
+ /* setdup_wizard is running : should not turn off LCD*/
+ if(vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_SETUP_WIZARD_STATE);
+ val = -1;
+ }
+ if(val == VCONFKEY_SETUP_WIZARD_LOCK) {
+ _E("setdup_wizard is running");
+ key_info.powerkey_count = 0;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ /* Check critical low batt clock mode */
+ if(vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_PM_KEY_IGNORE);
+ val = -1;
+ }
+ if(val == 1) { //Critical Low Batt Clock Mode
+ _E("Critical Low Batt Clock Mode");
+ key_info.powerkey_count = 0; //initialize powerkey count
+ if(!key_info.is_lcd_on) {
+ _W("just turn on LCD by powerkey.. starter ignore powerkey operation");
+ } else {
+ _W("just turn off LCD");
+ display_change_state(LCD_OFF);
+ }
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+
+ /* Safety Assitance */
+ if(vconf_get_int(VCONFKEY_WMS_SAFETY_ENABLE, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_WMS_SAFETY_ENABLE);
+ val = -1;
+ }
+ if(val == 1) { //Safety Assistance is ON
+ if(key_info.powerkey_count == 2) {
+ /* double press */
+ _W("powerkey double press");
+ key_info.powerkey_count = 0;
+ if(!_launch_app_by_double_press(data)) {
+ _E("Failed to launch by double press");
+ }
+ return ECORE_CALLBACK_CANCEL;
+ } else if(key_info.powerkey_count >= 3) {
+ _E("Safety Assistance : safety is enabled");
+ key_info.powerkey_count = 0;
+#ifdef TELEPHONY_DISABLE //B2
+ if(vconf_get_int(VCONFKEY_WMS_SAFETY_MESSAGE_TRIGGER, &trigger_val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_WMS_SAFETY_MESSAGE_TRIGGER);
+ }
+ _E("Safety Assistance trigger status : [%d]", trigger_val);
+ if(trigger_val == 0) {
+ //set wms trigger
+ if(vconf_set_int(VCONFKEY_WMS_SAFETY_MESSAGE_TRIGGER, 2) < 0) {
+ _SECURE_E("Failed to set vconfkey[%s]", VCONFKEY_WMS_SAFETY_MESSAGE_TRIGGER);
+ }
+
+ feedback_initialize();
+ feedback_play(FEEDBACK_PATTERN_SAFETY_ASSISTANCE);
+ feedback_deinitialize();
+ }
+#else //B2-3G
+ bundle *b;
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return ECORE_CALLBACK_CANCEL;
+ }
+ bundle_add(b, "starter_call", "true");
+
+ ret = w_launch_app(W_EMERGENCY_MESSAGE_PKGNAME, b);
+ if (ret < 0)
+ _E("Failed to launch emergency-message, ret : %d", ret);
+
+ bundle_free(b);
+#endif
+ return ECORE_CALLBACK_CANCEL;
+ }
+ } else { //Safety Assistance is OFF
+ if(key_info.powerkey_count%2 == 0) {
+ /* double press */
+ _W("powerkey double press");
+ key_info.powerkey_count = 0;
+ if(!_launch_app_by_double_press(data)) {
+ _E("Failed to launch by double press");
+ }
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
+ key_info.powerkey_count = 0; //initialize powerkey count
+
+ if (key_info.is_simple_clock_display == 1) {
+ _W("Simple clock is displayed.. starter ignore powerkey operation");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if(!key_info.is_lcd_on) {
+ _W("just turn on LCD by powerkey.. starter ignore powerkey operation");
+ return ECORE_CALLBACK_CANCEL;
+ } else {
+ // Check LCD status
+ if(vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_PM_STATE");
+ }
+ _W("LCD ON when powerkey & current LCD state : %d", val);
+ if(val >= VCONFKEY_PM_STATE_LCDOFF) {
+ _E("Already lcd state was changed while powerkey op. starter ignore powerkey operation");
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
+
+ /* check Call state */
+ if(vconf_get_int(VCONFKEY_CALL_STATE, &val) < 0) {
+ _E("Failed to get call state");
+ val = -1;
+ }
+ if(val == VCONFKEY_CALL_VOICE_ACTIVE) {
+ _W("call state is [%d] -> just turn off LCD", val);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ /* checkLockstate */
+ if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+ _E("Failed to get lock state");
+ val = -1;
+ }
+ if(val == VCONFKEY_IDLE_LOCK) {
+ _W("lock state is [%d] -> just turn off LCD", val);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ /* Check remote-lock state */
+ if(vconf_get_bool(VCONFKEY_REMOTE_LOCK_ISLOCKED, &val) < 0){
+ _E("failed to get %s", VCONFKEY_REMOTE_LOCK_ISLOCKED);
+ val = -1;
+ }
+
+ if(val == true){
+ _W("remote lock is on top (%d), -> just turn off LCD", val);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ /* Show Idle-Clock */
+ if(!_launch_home_by_powerkey())
+ _E("Failed to send powerkey to home..!!");
+#if 0
+ /* terminate syspopup */
+ syspopup_destroy_all();
+#endif
+
+ /* To notify powerkey to fmd & fmw */
+ vconf_set_int("memory/wfmd/wfmd_end_key", 1);
+ vconf_set_int("memory/wfmw/wfmw_end_key", 1);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _long_press_timer_cb(void* data)
+{
+ int pid;
+ bundle *b;
+ int test_mode = -1;
+ int call_forward_requesting = -1;
+ int remote_lock_status = -1;
+
+ _W("%s", __func__);
+
+ key_info.long_press_timer = NULL;
+ key_info.is_long_press = EINA_TRUE;
+ key_info.powerkey_count = 0; //initialize powerkey count
+
+ vconf_get_int(VCONFKEY_TESTMODE_POWER_OFF_POPUP, &test_mode);
+ if (test_mode == VCONFKEY_TESTMODE_POWER_OFF_POPUP_DISABLE) {
+ _E("test mode => skip poweroff popup");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ vconf_get_bool(VCONFKEY_CALL_FORWARD_REQUESTING, &call_forward_requesting);
+ if (call_forward_requesting == TRUE) {
+ _E("call forward requesting => skip poweroff popup");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ /* Check remote-lock state */
+ if(vconf_get_bool(VCONFKEY_REMOTE_LOCK_ISLOCKED, &remote_lock_status) < 0){
+ _E("failed to get %s", VCONFKEY_REMOTE_LOCK_ISLOCKED);
+ }
+
+ if(remote_lock_status == true){
+ _E("remote lock is on top (%d), ignore double key", remote_lock_status);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+#ifdef TARGET
+ if (bincfg_is_factory_binary() == 1) {
+ _E("Factory binary..!!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+#endif
+
+ //Check single powerkey press/release
+ if(key_info.powerkey_timer) {
+ ecore_timer_del(key_info.powerkey_timer);
+ key_info.powerkey_timer = NULL;
+ _D("delete powerkey_timer");
+ }
+
+#if USE_DBUS_POWEROFF
+ //_request_Poweroff();
+ request_Poweroff();
+#else
+ b = bundle_create();
+ if (!b)
+ return ECORE_CALLBACK_CANCEL;
+ pid = syspopup_launch("poweroff-syspopup", b);
+ _D("launch power off syspopup, pid : %d", pid);
+ bundle_free(b);
+#endif
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_HOLD);
+ feedback_deinitialize();
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _key_release_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Up *ev = event;
+ int val = -1;
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_release_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_release_cb : %s Released", ev->keyname);
+ }
+
+ if (!strcmp(ev->keyname, KEY_POWER)) {
+
+ _W("POWER Key is released");
+
+ // Check long press timer
+ if(key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ _D("delete long press timer");
+ }
+
+ // Check powerkey timer
+ if(key_info.powerkey_timer) {
+ ecore_timer_del(key_info.powerkey_timer);
+ key_info.powerkey_timer = NULL;
+ _D("delete powerkey timer");
+ }
+
+ // Cancel key operation
+ if (EINA_TRUE == key_info.is_cancel) {
+ _D("Cancel key is activated");
+ key_info.is_cancel = EINA_FALSE;
+ key_info.powerkey_count = 0; //initialize powerkey count
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ // Check long press operation
+ if(key_info.is_long_press) {
+ _D("ignore power key release by long poress");
+ key_info.is_long_press = EINA_FALSE;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if(!key_info.is_lcd_on) {
+ _D("lcd off --> [%f]sec timer", POWERKEY_LCDOFF_TIMER_SEC);
+ key_info.powerkey_timer = ecore_timer_add(POWERKEY_LCDOFF_TIMER_SEC, _powerkey_timer_cb, data);
+ } else {
+ key_info.powerkey_timer = ecore_timer_add(POWERKEY_TIMER_SEC, _powerkey_timer_cb, data);
+ }
+
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("CANCEL Key is released");
+ key_info.is_cancel = EINA_FALSE;
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+static Eina_Bool _key_press_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Down *ev = event;
+ int pm_val = -1;
+ int val = -1;
+
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_press_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_press_cb : %s Pressed", ev->keyname);
+ }
+
+ if (!strcmp(ev->keyname, KEY_POWER)) {
+
+ _W("POWER Key is pressed");
+
+ // Check LCD status
+ if(vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_PM_STATE");
+ }
+ _W("LCD state : %d", val);
+ if(val <= VCONFKEY_PM_STATE_LCDDIM) {
+ key_info.is_lcd_on = EINA_TRUE;
+ } else if(val >= VCONFKEY_PM_STATE_LCDOFF) {
+ key_info.is_lcd_on = EINA_FALSE;
+ }
+
+ // Check Simple Clock status
+ if(vconf_get_int(VCONFKEY_SIMPLECLOCK_UI_STATUS, &val) < 0) {
+ _E("Failed to get VCONFKEY_SIMPLECLOCK_UI_STATUS");
+ val = 0;
+ }
+ _W("Simple Clock state : %d", val);
+ key_info.is_simple_clock_display = val;
+
+ // Check powerkey press count
+ key_info.powerkey_count++;
+ _W("powerkey count : %d", key_info.powerkey_count);
+
+ // Check powerkey timer
+ if(key_info.powerkey_timer) {
+ ecore_timer_del(key_info.powerkey_timer);
+ key_info.powerkey_timer = NULL;
+ _D("delete powerkey timer");
+ }
+
+ // Check long press
+ if (key_info.long_press_timer) {
+ ecore_timer_del(key_info.long_press_timer);
+ key_info.long_press_timer = NULL;
+ }
+ _D("create long press timer");
+ key_info.is_long_press = EINA_FALSE;
+ key_info.long_press_timer = ecore_timer_add(LONG_PRESS_TIMER_SEC, _long_press_timer_cb, NULL);
+ if(!key_info.long_press_timer) {
+ _E("Failed to add long_press_timer");
+ }
+
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("CANCEL key is pressed");
+ key_info.is_cancel = EINA_TRUE;
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+static int _w_gesture_hold_cb(void *data, int ev_type, void *ev)
+{
+ struct appdata *ad = (struct appdata *)data;
+ if(ad == NULL){
+ _E("app data is NULL");
+ return ECORE_CALLBACK_RENEW;
+ }
+ Ecore_X_Event_Gesture_Notify_Hold *e = ev;
+ int ret = 0;
+ int val = -1;
+ bundle *b = NULL;
+
+ _D("_w_gesture_hold_cb..!!");
+
+#ifdef TARGET
+ if (bincfg_is_factory_binary() == 1) {
+ _E("Factory binary..!!");
+ return ECORE_CALLBACK_RENEW;
+ }
+#endif
+
+ /* Check Simple clock ui status */
+ if(vconf_get_int(VCONFKEY_SIMPLECLOCK_UI_STATUS, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_SIMPLECLOCK_UI_STATUS);
+ }
+ if(val == 1) { //Simple Clock ui Show.
+ _E("Simple Clock ui Show, ignore gesture");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ /* Check critical low batt clock mode */
+ if(vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_PM_KEY_IGNORE);
+ }
+ if(val == 1) { //Critical Low Batt Clock Mode
+ _E("Critical Low Batt Clock Mode, ignore gesture");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ /* Check UPS mode */
+ if(vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val) < 0) {
+ _SECURE_E("Failed to get vconfkey[%s]", VCONFKEY_SETAPPL_PSMODE);
+ }
+ if(val == SETTING_PSMODE_WEARABLE_ENHANCED) { //UPS Mode
+ _E("UPS Mode, ignore gesture");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ /* Check Cool Down mode */
+ if(ad->cool_down_mode !=0){
+ _E("Cool down mode is LimitAction(%d), ignore double key", ad->cool_down_mode);
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if(e->num_fingers == GRAB_TWO_FINGERS) {
+ _D("subtype[%d]: hold[%d]\n", e->subtype, e->hold_time);
+ if (e->subtype == ECORE_X_GESTURE_BEGIN) {
+ _D("Begin : launch task mgr..!!");
+
+ b = bundle_create();
+ if(!b) {
+ _E("Failed to create bundle");
+ return EINA_FALSE;
+ }
+ bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_MAIN_VALUE);
+
+ request_dbus_cpu_booster();
+
+ ret = w_launch_app(W_TASKMGR_PKGNAME, NULL);
+ if (ret >= 0) {
+ _SECURE_D("[%s] is launched, pid=[%d]", W_TASKMGR_PKGNAME, ret);
+#if 0
+ /* terminate syspopup */
+ //syspopup_destroy_all();
+ ecore_timer_add(SYSPOPUP_END_TIMER_SEC*2, _syspopup_end_timer_cb, NULL);
+#endif
+ }
+ if(b) {
+ bundle_free(b);
+ }
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+inline static void _release_multimedia_key(const char *value)
+{
+ int pid = 0;
+
+ ret_if(NULL == value);
+
+ _D("Multimedia key is released with %s", value);
+
+ bundle *b;
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return;
+ }
+ bundle_add(b, "multimedia_key", value);
+ bundle_add(b, APP_CONTROL_OPERATION_MAIN_KEY, APP_CONTROL_OPERATION_DEFAULT_VALUE);
+
+ pid = w_launch_app(MUSIC_PLAYER_PKG_NAME, b);
+ if (pid < 0)
+ _E("Failed to launch music player, ret : %d", pid);
+
+ bundle_free(b);
+}
+
+
+void _media_key_event_cb(media_key_e key, media_key_event_e status, void *user_data)
+{
+ _D("MEDIA KEY EVENT : %d", key);
+ if (MEDIA_KEY_STATUS_PRESSED == status) return;
+
+ if (MEDIA_KEY_PAUSE == key) {
+ _release_multimedia_key("KEY_PAUSECD");
+ } else if (MEDIA_KEY_PLAY == key) {
+ _release_multimedia_key("KEY_PLAYCD");
+ } else if (MEDIA_KEY_PLAYPAUSE == key) {
+ _release_multimedia_key("KEY_PLAYPAUSECD");
+ }
+}
+
+static Eina_Bool _key_release_in_factory_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Up *ev = event;
+ int val = -1;
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_release_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_release_cb : %s Released", ev->keyname);
+ }
+
+ if (!strcmp(ev->keyname, KEY_POWER)) {
+
+ _W("POWER Key is released");
+ if(!key_info.is_lcd_on) {
+ _W("just turn on LCD by powerkey.. starter ignore powerkey operation");
+ } else {
+ _W("just turn off LCD");
+ display_change_state(LCD_OFF);
+ }
+ return ECORE_CALLBACK_CANCEL;
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool _key_press_in_factory_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Down *ev = event;
+ int pm_val = -1;
+ int val = -1;
+
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!ev->keyname) {
+ _D("_key_press_cb : Invalid event keyname object");
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ _D("_key_press_cb : %s Pressed", ev->keyname);
+ }
+
+ if (!strcmp(ev->keyname, KEY_POWER)) {
+
+ _W("POWER Key is pressed");
+ // Check LCD status
+ if(vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ _E("Cannot get VCONFKEY_PM_STATE");
+ }
+ _W("LCD state : %d", val);
+ if(val <= VCONFKEY_PM_STATE_LCDDIM) {
+ key_info.is_lcd_on = EINA_TRUE;
+ } else if(val >= VCONFKEY_PM_STATE_LCDOFF) {
+ key_info.is_lcd_on = EINA_FALSE;
+ }
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+void create_key_window_factory_mode(char *home_pkgname, void *data)
+{
+ int status = -1;
+ int ret = -1;
+
+ _W("create_key_window in factory mode!!");
+
+ key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+ if (!key_info.win) {
+ _E("Failed to create hidden window");
+ return;
+ }
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_NONE);
+ ecore_x_icccm_title_set(key_info.win, "w_starter,key,receiver");
+ ecore_x_netwm_name_set(key_info.win, "w_starter,key,receiver");
+ ecore_x_netwm_pid_set(key_info.win, getpid());
+
+ ret = utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_POWER, SHARED_GRAB);
+ if (ret != 0) {
+ _E("utilx_grab_key KEY_POWER GrabSHARED_GRAB failed, ret[%d]", ret);
+ }
+
+ key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_in_factory_cb, data);
+ if (!key_info.key_up)
+ _E("Failed to register a key up event handler");
+
+ key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_in_factory_cb, NULL);
+ if (!key_info.key_down)
+ _E("Failed to register a key down event handler");
+}
+
+
+
+void create_key_window(char *home_pkgname, void *data)
+{
+ int status = -1;
+ int ret = -1;
+
+ _W("create_key_window..!!");
+
+ key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+ if (!key_info.win) {
+ _E("Failed to create hidden window");
+ return;
+ }
+ ecore_x_event_mask_unset(key_info.win, ECORE_X_EVENT_MASK_NONE);
+ ecore_x_icccm_title_set(key_info.win, "w_starter,key,receiver");
+ ecore_x_netwm_name_set(key_info.win, "w_starter,key,receiver");
+ ecore_x_netwm_pid_set(key_info.win, getpid());
+
+#if 0
+ g_type_init();
+ e_dbus_init();
+
+ init_dbus_ALPM_signal(NULL);
+#endif
+
+ key_info.home_pkgname = home_pkgname;
+
+ ret = utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_POWER, SHARED_GRAB);
+ if (ret != 0) {
+ _E("utilx_grab_key KEY_POWER GrabSHARED_GRAB failed, ret[%d]", ret);
+ }
+
+ key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, data);
+ if (!key_info.key_up)
+ _E("Failed to register a key up event handler");
+
+ key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL);
+ if (!key_info.key_down)
+ _E("Failed to register a key down event handler");
+
+ status = ecore_x_gesture_event_grab(key_info.win, ECORE_X_GESTURE_EVENT_HOLD, GRAB_TWO_FINGERS);
+ _E("ECORE_X_GESTURE_EVENT_HOLD Grab(%d fingers) status[%d]\n", GRAB_TWO_FINGERS, status);
+
+ key_info.two_fingers_hold_hd = ecore_event_handler_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD,
+ (Ecore_Event_Handler_Cb)_w_gesture_hold_cb, data);
+ if (!key_info.two_fingers_hold_hd) {
+ _E("Failed to register handler : ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD\n");
+ }
+
+ media_key_reserve(_media_key_event_cb, NULL);
+
+}
+
+
+
+void destroy_key_window(void)
+{
+ int status;
+
+ if (key_info.two_fingers_hold_hd) {
+ ecore_event_handler_del(key_info.two_fingers_hold_hd);
+ key_info.two_fingers_hold_hd = NULL;
+ }
+
+ status = ecore_x_gesture_event_ungrab(key_info.win, ECORE_X_GESTURE_EVENT_HOLD, GRAB_TWO_FINGERS);
+ if (!status) {
+ _E("ECORE_X_GESTURE_EVENT_HOLD UnGrab(%d fingers) failed, status[%d]\n", GRAB_TWO_FINGERS, status);
+ }
+
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_POWER);
+
+ if (key_info.key_up) {
+ ecore_event_handler_del(key_info.key_up);
+ key_info.key_up = NULL;
+ }
+
+ if (key_info.key_down) {
+ ecore_event_handler_del(key_info.key_down);
+ key_info.key_down = NULL;
+ }
+
+ ecore_x_window_delete_request_send(key_info.win);
+ key_info.win = 0x0;
+
+}
+
+
+
+// End of a file
diff --git a/src/lock-daemon-lite.c b/src/lock-daemon-lite.c
new file mode 100755
index 0000000..5351c58
--- /dev/null
+++ b/src/lock-daemon-lite.c
@@ -0,0 +1,2185 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <glib.h>
+#include <poll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <errno.h>
+//#include <sensors.h>
+#include <feedback.h>
+#include <alarm.h>
+#include <time.h>
+#include <dd-deviced.h>
+#include <dd-display.h>
+#include <E_DBus.h>
+#include <aul.h>
+
+#ifndef FEATURE_LITE
+#include <context_manager.h>
+#endif
+
+#include "lockd-debug.h"
+#include "lock-daemon-lite.h"
+#include "lockd-process-mgr.h"
+#include "lockd-window-mgr.h"
+#include "starter-util.h"
+#include "menu_daemon.h"
+#include "hw_key.h"
+#include "lockd-bt.h"
+#include "dbus-util.h"
+#include "util.h"
+
+static int phone_lock_pid;
+static int auto_lock_pid;
+static bool lock_state_available = TRUE;
+
+struct lockd_data {
+ int lock_app_pid;
+ int phone_lock_app_pid;
+ int lock_type; /* -1: None, 0:Normal, 1:Security, 2:Other */
+ Eina_Bool is_sensor; /* EINA_TRUE : can use sensor EINA_FALSE : cannot use */
+ Eina_Bool request_recovery;
+ Eina_Bool back_to_app;
+ Eina_Bool start_ready;
+ lockw_data *lockw;
+ GPollFD *gpollfd;
+ Eina_Bool is_alarm; /* EINA_TRUE : can use alarm EINA_FALSE : cannot use */
+ alarm_id_t alarm_id; /* -1 : None, others : set alarm */
+ Eina_Bool is_first_boot; /* EINA_TRUE : first boot */
+ int hall_status; /* 0: cover is closed, 1:cover is opened */
+ E_DBus_Connection *hall_conn;
+ E_DBus_Signal_Handler *hall_handler;
+ E_DBus_Connection *display_conn;
+ E_DBus_Signal_Handler *display_handler;
+
+};
+
+
+
+/* Local features*/
+#define _FEATURE_LCD_OFF_DBUS 0 //Check to apply lcd off dbus by PM part
+#define _FEATURE_SCOVER 0 //Scover view
+
+#define VCONFKEY_LOCKSCREEN_FESTIVAL_WALLPAPER_DISPLAYING "db/lockscreen/festival_wallpaper"
+
+
+#define PHLOCK_SOCK_PREFIX "/tmp/phlock"
+#define PHLOCK_SOCK_MAXBUFF 1024
+
+#define VOLUNE_APP_CMDLINE "/usr/apps/org.volume.volume/bin/volume" // LOCK_EXIT_CMD
+#define PHLOCK_APP_CMDLINE "/usr/apps/org.volume.lockscreen/bin/lockscreen" //PHLOCK_UNLOCK_CMD
+#define MDM_APP_CMDLINE "/usr/bin/mdm-server" //PHLOCK_LAUNCH_CMD
+#define VOICE_CALL_APP_CMDLINE "/usr/apps/com.samsung.call/bin/calls" //HOME_RAISE_CMD, LOCK_SHOW_CMD
+#define VIDEO_CALL_APP_CMDLINE "/usr/apps/com.samsung.vtmain/bin/vtmain" //HOME_RAISE_CMD, LOCK_SHOW_CMD
+#define OMA_DRM_AGENT_CMDLINE "/usr/bin/oma-dm-agent" //PHLOCK_UNLOCK_RESET_CMD
+
+#define PHLOCK_UNLOCK_CMD "unlock"
+#define PHLOCK_LAUNCH_CMD "launch_phone_lock"
+#define PHLOCK_UNLOCK_RESET_CMD "unlock_reset"
+#define HOME_RAISE_CMD "raise_homescreen"
+#define LOCK_SHOW_CMD "show_lockscreen"
+#define LOCK_LAUNCH_CMD "launch_lockscreen"
+#define LOCK_EXIT_CMD "exit_lockscreen"
+
+#define LAUNCH_INTERVAL 100*1000
+
+#define HALL_COVERED_STATUS 0
+#define BUS_NAME "org.tizen.system.deviced"
+#define OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define INTERFACE_NAME BUS_NAME
+#define DEVICED_PATH_HALL OBJECT_PATH"/Hall"
+#define DEVICED_INTERFACE_HALL INTERFACE_NAME".hall"
+#define SIGNAL_HALL_STATE "ChangeState"
+#define METHOD_GET_STATUS "getstatus"
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+#define DEVICED_PATH_PMQOS OBJECT_PATH"/PmQos"
+#define DEVICED_INTERFACE_PMQOS INTERFACE_NAME".PmQos"
+#define METHOD_PMQOS_NAME "LockScreen"
+#define REQUEST_PMQOS_DURATION (2 * 1000)
+
+#define DEVICED_PATH_LCD_OFF OBJECT_PATH"/Display"
+#define DEVICED_INTERFACE_LCD_OFF INTERFACE_NAME".display"
+#define METHOD_LCD_OFF_NAME "LCDOffByPowerkey"
+
+#define VOLUME_PKG_NAME "org.tizen.volume"
+#define WALLPAPER_UI_SERVICE_PKG_NAME "com.samsung.wallpaper-ui-service"
+#define SHOW_LOCK "show_lock"
+#define ISTRUE "TRUE"
+#define SMART_ALERT_INTERVAL 0.5
+
+#define PASSWORD_LOCK_PROGRESS "/tmp/.passwordlock"
+static int checkfd = 0;
+
+enum {
+ LOCK_TYPE_NONE = -1,
+ LOCK_TYPE_NORMAL = 0,
+ LOCK_TYPE_SECURITY,
+ LOCK_TYPE_AUTO_LOCK,
+ LOCK_TYPE_OTHER,
+ LOCK_TYPE_MAX
+};
+
+static int lockd_launch_app_lockscreen_lite(struct lockd_data *lockd);
+static int lockd_launch_app_other_lockscreen(struct lockd_data *lockd);
+static void lockd_unlock_other_lockscreen(struct lockd_data *lockd);
+static void lockd_init_vconf(struct lockd_data *lockd);
+static void lockd_fini_vconf(struct lockd_data *lockd);
+static void _lockd_check_ongoing(bool ongoing);
+#if 0
+static Eina_Bool lockd_start_sensor(void *data);
+static void lockd_stop_sensor(void *data);
+#endif
+
+static void _lockd_set_lock_state(int lock_state)
+{
+ LOCKD_DBG("%s, %d, %d", __func__, __LINE__, lock_state);
+ if(lock_state < VCONFKEY_IDLE_UNLOCK || lock_state > VCONFKEY_IDLE_LAUNCHING_LOCK) {
+ LOCKD_ERR("Can't set lock_state : %d out of range", lock_state);
+ } else {
+ vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, lock_state);
+ }
+}
+
+static void _lockd_play_sound(bool unlock)
+{
+ int ret = -1, val = 0;
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &val);
+
+ if(ret == 0 && val == 1) {
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_SOUND, unlock ? FEEDBACK_PATTERN_UNLOCK : FEEDBACK_PATTERN_LOCK);
+ }
+}
+
+int lockd_get_lock_type(void)
+{
+ int lock_type = 0;
+ int ret = 0;
+
+ vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
+
+ if (lock_type == SETTING_SCREEN_LOCK_TYPE_NONE) {
+ ret = LOCK_TYPE_NONE;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_FINGERPRINT ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE) {
+ ret = LOCK_TYPE_SECURITY;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_SWIPE ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_MOTION) {
+ ret = LOCK_TYPE_NORMAL;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_AUTO_LOCK) {
+ ret = LOCK_TYPE_AUTO_LOCK;
+ } else {
+ ret = LOCK_TYPE_OTHER;
+ }
+
+ LOCKD_DBG("lockd_get_lock_type ret(%d), lock_type (%d)", ret, lock_type);
+
+ return ret;
+}
+
+static int _lockd_append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+DBusMessage *_lockd_invoke_dbus_method_async(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ LOCKD_ERR("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ LOCKD_ERR("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _lockd_append_variant(&iter, sig, param);
+ if (r < 0) {
+ LOCKD_ERR("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ r = dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ if (r != TRUE) {
+ LOCKD_ERR("dbus_connection_send error(%s:%s:%s-%s)", dest, path, interface, method);
+ return -ECOMM;
+ }
+ LOCKD_DBG("dbus_connection_send, ret=%d", r);
+ return NULL;
+}
+
+DBusMessage *_lockd_invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ LOCKD_ERR("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ LOCKD_ERR("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _lockd_append_variant(&iter, sig, param);
+ if (r < 0) {
+ LOCKD_ERR("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+ if (!reply) {
+ LOCKD_ERR("dbus_connection_send error(No reply)");
+ }
+
+ if (dbus_error_is_set(&err)) {
+ LOCKD_ERR("dbus_connection_send error(%s:%s)", err.name, err.message);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ return reply;
+}
+
+int lockd_get_hall_status(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+
+ LOCKD_DBG("[ == %s == ]", __func__);
+ msg = _lockd_invoke_dbus_method_sync(BUS_NAME, DEVICED_PATH_HALL, DEVICED_INTERFACE_HALL,
+ METHOD_GET_STATUS, NULL, NULL);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ LOCKD_ERR("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ LOCKD_DBG("%s-%s : %d", DEVICED_INTERFACE_HALL, METHOD_GET_STATUS, ret_val);
+ return ret_val;
+}
+
+int lockd_get_lock_state(void)
+{
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &idle_lock_state) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+ }
+ LOCKD_DBG("Get lock state : %d", idle_lock_state);
+ return idle_lock_state;
+}
+
+static void _lockd_on_changed_receive(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ char *str;
+ int response;
+ int r;
+ int automatic_unlock = 0;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ LOCKD_DBG("hall signal is received");
+
+ r = dbus_message_is_signal(msg, DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE);
+ if (!r) {
+ LOCKD_ERR("dbus_message_is_signal error");
+ return;
+ }
+
+ LOCKD_DBG("%s - %s", DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE);
+
+ dbus_error_init(&err);
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+ if (!r) {
+ LOCKD_ERR("dbus_message_get_args error");
+ return;
+ }
+
+ LOCKD_DBG("receive data : %d", response);
+ lockd->hall_status = response;
+
+}
+
+static int _lockd_request_PmQos(int duration)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+ char *arr[1];
+ char val[32];
+
+ snprintf(val, sizeof(val), "%d", duration);
+ arr[0] = val;
+
+ //msg = _lockd_invoke_dbus_method_sync(BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS,
+ // METHOD_PMQOS_NAME, "i", arr);
+ msg = _lockd_invoke_dbus_method_async(BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS,
+ METHOD_PMQOS_NAME, "i", arr);
+
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ LOCKD_ERR("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ LOCKD_DBG("%s-%s : %d", DEVICED_INTERFACE_PMQOS, METHOD_PMQOS_NAME, ret_val);
+ return ret_val;
+}
+
+static void _lockd_delete_alarm_lite(alarm_id_t id, void * user_param)
+{
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+ LOCKD_DBG("Del alarm_id(%d)", id);
+ ret_val = alarmmgr_remove_alarm(id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+}
+
+static void _lockd_unset_alarms_lite(void)
+{
+ LOCKD_DBG("[ == %s == ]", __func__);
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+ ret_val = alarmmgr_enum_alarm_ids(_lockd_delete_alarm_lite, NULL);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+}
+
+static void _lockd_lauch_other_lockscreen(alarm_id_t alarm_id, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+
+ LOCKD_DBG("[ == %s == ], alarm_id(%d)", __func__, alarm_id);
+
+ lockd_launch_app_other_lockscreen(lockd);
+
+ if(alarm_id != -1) {
+ if(alarm_id != lockd->alarm_id) {
+ LOCKD_ERR("alarm ids are different callback->id(%d), lockd->alarm_id(%d)", alarm_id, lockd->alarm_id);
+ /* delete all registering alarm*/
+ _lockd_unset_alarms_lite();
+ lockd->alarm_id = -1;
+ } else {
+ ret_val = alarmmgr_remove_alarm(alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_remove_alarm() failed");
+ /* delete all registering alarm*/
+ _lockd_unset_alarms_lite();
+ }
+ lockd->alarm_id = -1;
+ }
+ }
+}
+
+static Eina_Bool _lockd_set_alarm(int sec, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return EINA_FALSE;
+ }
+
+ time_t current_time;
+ struct tm current_tm;
+ alarm_entry_t *alarm_info;
+ alarm_id_t alarm_id;
+ alarm_date_t alarm_time;
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+
+ /* delete before registering alarm ids */
+ if(lockd->alarm_id != -1){
+ LOCKD_ERR("ad->alarm_id(%d) deleted", lockd->alarm_id);
+ ret_val = alarmmgr_remove_alarm(lockd->alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_remove_alarm(%d) failed", lockd->alarm_id);
+ _lockd_unset_alarms_lite();
+ }
+ lockd->alarm_id = -1;
+ }
+
+ /* set alarm after sec */
+ time(&current_time);
+
+ localtime_r(&current_time, &current_tm);
+
+ alarm_info = alarmmgr_create_alarm();
+ if(alarm_info == NULL) {
+ LOCKD_ERR("alarmmgr_create_alarm() is failed\n");
+ return EINA_FALSE;
+ }
+
+ alarm_time.year = 0;
+ alarm_time.month = 0;
+ alarm_time.day = 0;
+ alarm_time.hour = current_tm.tm_hour;
+ alarm_time.min = current_tm.tm_min;
+ alarm_time.sec = current_tm.tm_sec + sec;
+
+ alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+ alarmmgr_set_time(alarm_info, alarm_time);
+ alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
+
+ ret_val = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_add_alarm_with_localtime() failed");
+ alarmmgr_free_alarm(alarm_info) ;
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("alarm id(%d) is set", alarm_id);
+ lockd->alarm_id = alarm_id;
+ alarmmgr_free_alarm(alarm_info) ;
+
+ return EINA_TRUE;
+}
+
+
+#ifndef FEATURE_LITE
+static Eina_Bool _lockd_play_smart_alert_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_REACTIVE_ALERT);
+ //feedback_deinitialize();
+ //lockd_stop_sensor(lockd);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void _lockd_context_update_cb(int error, context_item_e context, char* context_data, void* user_data, int req_id)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ struct lockd_data *lockd = (struct lockd_data *)user_data;
+
+ if (error == CONTEXT_ERROR_NONE && context == CONTEXT_ITEM_MOVEMENT) {
+ int action = -1;
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+
+ context_context_data_get_int(context_data, CONTEXT_MOTION_ACTION, &action);
+
+ switch (action) {
+ case CONTEXT_MOVEMENT_ACTION:
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ LOCKD_WARN("[ sensor ] SMART ALERT calls = %d messages = %d", calls, messages);
+ ecore_timer_add(SMART_ALERT_INTERVAL, _lockd_play_smart_alert_cb, user_data);
+ }
+ break;
+ case CONTEXT_MOVEMENT_NONE:
+ break;
+ default:
+ break;
+ }
+ context_unset_changed_callback(CONTEXT_ITEM_MOVEMENT);
+ free(context_data);
+ }
+}
+
+static Eina_Bool _lockd_smart_alert_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int val = -1;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if ((val == VCONFKEY_PM_STATE_LCDOFF) || (val == VCONFKEY_PM_STATE_SLEEP)) {
+ LOCKD_DBG("LCD OFF ==> smart alert start");
+
+ int ret = 0;
+ int is_motion = 0;
+ int is_pickup = 0;
+
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &is_motion);
+ LOCKD_DBG("[ sensor ] ret = %d is_motion = %d", ret, is_motion);
+ if(ret == 0 && is_motion == 1) {
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_USE_PICK_UP, &is_pickup);
+ LOCKD_DBG("[ sensor ] ret = %d is_pickup = %d", ret, is_pickup);
+ if(ret == 0 && is_pickup == 1) {
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+ int req_id, r;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ r = context_set_changed_callback(CONTEXT_ITEM_MOVEMENT, NULL, _lockd_context_update_cb, lockd, &req_id);
+ if (r != CONTEXT_ERROR_NONE) {
+ LOCKD_ERR("[ sensor ] context_set_changed_callback fail");
+ }
+ LOCKD_WARN("[ sensor ] context_set_changed_callback, r=[%d]", r);
+ }
+ }
+ }
+ } else {
+ LOCKD_DBG("Not LCD OFF ==> cancel smart alert");
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+#endif
+
+
+
+static Eina_Bool _lockd_sensor_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int val = -1;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if ((val == VCONFKEY_PM_STATE_LCDOFF) || (val == VCONFKEY_PM_STATE_SLEEP)) {
+ LOCKD_DBG("LCD OFF ==> sensor start");
+
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ if(lockd_start_sensor(data) == EINA_FALSE) {
+ LOCKD_ERR("smart_alert sensor start is failed");
+ }
+ } else {
+ LOCKD_ERR("[ sensor ] sensor is not started calls = %d messages = %d", calls, messages);
+ }
+ } else {
+ LOCKD_DBG("Not LCD OFF ==> cancel sensor start");
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _lockd_alarm_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ _lockd_unset_alarms_lite();
+ lockd->alarm_id = -1;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _lockd_launch_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ _lockd_lauch_other_lockscreen(-1, lockd);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _lockd_notify_pm_state_cb_lite(keynode_t * node, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ return;
+ }
+
+ LOCKD_DBG("[ == %s == ] pm_state(%d)", __func__, val);
+
+ if (val == VCONFKEY_PM_STATE_NORMAL) {
+ LOCKD_DBG("LCD ON");
+ /* delete all alarm registering */
+ LOCKD_DBG("%d", lockd->alarm_id);
+
+ _lockd_unset_alarms_lite();
+ lockd->alarm_id = -1;
+
+ if(lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_NONE) {
+ LOCKD_DBG("Lockscreen type is none, unlock");
+ }
+ }
+}
+
+static int _show_lock_bg(void)
+{
+ bundle *b;
+ int r = 0;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (menu_daemon_get_volume_pid() <0) {
+ LOCKD_DBG("volume is not running");
+ return -1;
+ }
+
+ b = bundle_create();
+
+ bundle_add(b, SHOW_LOCK, ISTRUE);
+ r = aul_launch_app(VOLUME_PKG_NAME, b);
+ if(b) {
+ bundle_free(b);
+ }
+
+ return r;
+}
+
+static void _lockd_notify_pm_lcdoff_cb_lite(keynode_t * node, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+ int lcdoff_source = vconf_keynode_get_int(node);
+ int accessbility_lock_time = 0;
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (lcdoff_source < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY, error (%d)", lcdoff_source);
+ return;
+ }
+
+ LOCKD_DBG("[ %s ] LCD OFF by lcd off source(%d)", __func__, lcdoff_source);
+
+ idle_lock_state = lockd_get_lock_state();
+
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY) {
+ LOCKD_DBG("lcd off by powerkey");
+#if (!_FEATURE_LCD_OFF_DBUS) // move to dbus signal handler.
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SWIPE) {
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ }
+ }
+ lockd_launch_app_other_lockscreen(lockd);
+#endif
+ } else if (lcdoff_source == 3) {
+ LOCKD_DBG("lcd off by proximity sensor..");
+ return;
+ } else {
+ LOCKD_DBG("lcd off by timeout");
+
+ if(idle_lock_state == VCONFKEY_IDLE_LOCK) {
+ LOCKD_DBG("VCONFKEY is set(not need to set alarm)");
+ return;
+ }
+
+ if(lockd->alarm_id != -1) {
+ LOCKD_ERR("Alarm is set yet (alarm_id = %d) : do nothing", lockd->alarm_id);
+ return;
+ }
+
+ if(vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_LOCK_TIME_INT, &accessbility_lock_time) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ accessbility_lock_time = 0;
+ }
+
+ if(accessbility_lock_time == 0) {
+ LOCKD_ERR("accessbility_lock_time is 0");
+ _lockd_lauch_other_lockscreen(-1, lockd);
+ return;
+ } else {
+ if(lockd->is_alarm) {
+ LOCKD_DBG("set alarm %d sec", accessbility_lock_time);
+ if(_lockd_set_alarm(accessbility_lock_time, lockd) != EINA_TRUE) {
+ LOCKD_ERR("_lockd_set_alarm() failed");
+ _lockd_lauch_other_lockscreen(-1, lockd);
+ }
+ }
+ else {
+ LOCKD_ERR("is_alarm is EINA_FALSE");
+ _lockd_lauch_other_lockscreen(-1, lockd);
+ }
+ }
+ }
+}
+
+static void _lockd_notify_time_changed_cb(keynode_t * node, void *data)
+{
+ int festival_wallpaper = 0;
+ LOCKD_DBG("system time chanded!!");
+
+ if(vconf_get_bool(VCONFKEY_LOCKSCREEN_FESTIVAL_WALLPAPER_DISPLAYING, &festival_wallpaper) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ festival_wallpaper = 0;
+ }
+ LOCKD_DBG("festival wallpaper : %d", festival_wallpaper);
+ if(festival_wallpaper){
+ bundle *b;
+ b = bundle_create();
+ if(b == NULL){
+ LOCKD_ERR("bundle create failed.\n");
+ return;
+ }
+ bundle_add(b, "popup_type", "festival");
+ bundle_add(b, "festival_type", "festival_create");
+ aul_launch_app(WALLPAPER_UI_SERVICE_PKG_NAME, b);
+ bundle_free(b);
+ }
+}
+
+static void _lockd_notify_factory_mode_cb(keynode_t * node, void *data)
+{
+ int factory_mode = -1;
+ LOCKD_DBG("Factory mode Notification!!");
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, &factory_mode);
+ if (factory_mode == VCONFKEY_TELEPHONY_SIM_FACTORYMODE_ON) {
+ LOCKD_DBG("Factory mode ON, lock screen can't be launched..!!");
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+}
+
+static void
+_lockd_notify_pwlock_state_changed_cb(keynode_t * node, void *data)
+{
+ LOCKD_DBG("pwlock state changed!!");
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+ int pwlock_state = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ pwlock_state = vconf_keynode_get_int(node);
+
+ if(pwlock_state == VCONFKEY_PWLOCK_BOOTING_UNLOCK){
+ if(checkfd){
+ LOCKD_WARN("remove the progress file.");
+ _lockd_check_ongoing(EINA_FALSE);
+ }
+ if (vconf_ignore_key_changed
+ (VCONFKEY_PWLOCK_STATE, _lockd_notify_pwlock_state_changed_cb) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_PWLOCK_STATE");
+ }
+ }
+}
+
+static void
+_lockd_notify_lock_state_cb(keynode_t * node, void *data)
+{
+ LOCKD_DBG("lock state changed!!");
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+ int pwlock_state = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ val = lockd_get_lock_state();
+ vconf_get_int(VCONFKEY_PWLOCK_STATE, &pwlock_state);
+
+ if (val == VCONFKEY_IDLE_UNLOCK) {
+ LOCKD_DBG("unlocked..!!");
+
+ if(lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD){
+ if(pwlock_state == VCONFKEY_PWLOCK_BOOTING_UNLOCK){
+ if(checkfd){
+ LOCKD_WARN("remove the progress file.");
+ _lockd_check_ongoing(EINA_FALSE);
+ }
+ }
+ else if(pwlock_state == VCONFKEY_PWLOCK_BOOTING_LOCK){
+ LOCKD_WARN("PWLOCK is not ready yet.");
+ if (vconf_notify_key_changed
+ (VCONFKEY_PWLOCK_STATE, _lockd_notify_pwlock_state_changed_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT");
+ }
+ }
+ }
+
+ if (vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_FALSE) < 0) {
+ LOCKD_ERR("Cannot set VCONFKEY");
+ }
+
+ if (lockd->lock_app_pid > 0) {
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER) {
+ LOCKD_DBG("terminate lock app..!!");
+ lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
+ lockd->lock_app_pid = 0;
+ }
+ }
+ }else if (val == VCONFKEY_IDLE_LOCK) {
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ }
+}
+
+static Eina_Bool lockd_set_lock_state_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ _lockd_set_lock_state(VCONFKEY_IDLE_LOCK);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_lockd_notify_phone_lock_verification_cb(keynode_t * node, void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (vconf_get_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ return;
+ }
+
+ if (val == TRUE) {
+ /* password verified */
+ /* lockd_unlock_lockscreen(lockd); */
+ lockd_window_mgr_finish_lock(lockd->lockw);
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+}
+
+static int lockd_app_dead_cb_lite(int pid, void *data)
+{
+ LOCKD_DBG("app dead cb call! (pid : %d)", pid);
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = 0;
+
+ if(pid == lockd->lock_app_pid || pid == lockd->phone_lock_app_pid){
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ LOCKD_DBG("lock daemon(%d) is terminated, lock type : %d pm state : %d", pid, lockd->lock_type, val);
+ if(lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER){
+ lockd_unlock_other_lockscreen(lockd);
+ _lockd_play_sound(TRUE);
+ }
+ else{
+ if(val < VCONFKEY_PM_STATE_LCDOFF){
+ lockd->start_ready = TRUE;
+ lockd_launch_app_lockscreen_lite(lockd);
+ }
+ else{
+ lockd_launch_app_lockscreen_lite(lockd);
+ }
+ }
+ }
+
+ menu_daemon_check_dead_signal(pid);
+
+ return 0;
+}
+
+static Eina_Bool lockd_other_app_create_cb(void *data, int type, void *event)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ if (lockd_window_set_window_effect(lockd->lockw, lockd->lock_app_pid,
+ event) == EINA_TRUE) {
+ //FIXME sometimes show cb is not called.
+ if(lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
+ event) == EINA_FALSE) {
+ LOCKD_ERR("window is not matched..!!");
+ }
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool lockd_other_app_show_cb(void *data, int type, void *event)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ return EINA_TRUE;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ if (lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
+ event)) {
+ lockd_window_set_scroll_property(lockd->lockw, 0);
+ ecore_idler_add(lockd_set_lock_state_cb, NULL);
+ }
+ return EINA_FALSE;
+}
+
+static Eina_Bool _lockd_play_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ _lockd_play_sound(FALSE);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static int lockd_launch_app_lockscreen_lite(struct lockd_data *lockd)
+{
+ LOCKD_DBG("launch app lock screen");
+
+ int call_state = -1, factory_mode = -1, test_mode = -1;
+ int r = 0;
+ int lcdoff_source = 0;
+ int focus_win_pid = 0;
+ int pw_type = 0;
+ int automatic_unlock = 0;
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, &factory_mode);
+ if (factory_mode == VCONFKEY_TELEPHONY_SIM_FACTORYMODE_ON) {
+ LOCKD_ERR("Factory mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ if (test_mode == VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE) {
+ LOCKD_ERR("Test mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+
+ if (lockd->is_first_boot == TRUE) {
+ if(vconf_get_int(VCONFKEY_PWLOCK_STATE, &pw_type) < 0)
+ {
+ LOCKD_ERR("vconf_get_int() failed");
+ pw_type = VCONFKEY_PWLOCK_RUNNING_UNLOCK;
+ }
+ if(pw_type == VCONFKEY_PWLOCK_BOOTING_LOCK || pw_type == VCONFKEY_PWLOCK_RUNNING_LOCK) {
+ LOCKD_ERR("First boot & pwlock state[%d], lock screen can't be launched..!!", pw_type);
+ goto launch_out;
+ }
+ }
+
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_NONE) {
+ LOCKD_ERR("Lock screen type is None..!!");
+ goto launch_out;
+ }
+
+ LOCKD_WARN("lock type : %d", lockd->lock_type);
+ switch (lockd->lock_type) {
+
+ case SETTING_SCREEN_LOCK_TYPE_SWIPE:
+ if(lockd->start_ready == TRUE){
+ lockd->lock_app_pid =
+ lockd_process_mgr_start_ready_lock();
+ lockd->start_ready = FALSE;
+ }
+ else{
+ lockd->lock_app_pid =
+ lockd_process_mgr_start_normal_lock(lockd, lockd_app_dead_cb_lite);
+ if (lockd->lock_app_pid < 0) {
+ goto launch_out;
+ }
+ }
+ break;
+
+ case SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD:
+ case SETTING_SCREEN_LOCK_TYPE_PASSWORD:
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, FALSE);
+
+ /* TO DO : Recovery should be checked by EAS interface later */
+ /* After getting EAS interface, we should remove lockd->request_recovery */
+ if (lockd->request_recovery == TRUE) {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_recovery_lock();
+ lockd->request_recovery = FALSE;
+ } else if (lockd->back_to_app == TRUE) {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_back_to_app_lock();
+ lockd->back_to_app = FALSE;
+ } else if (lockd->start_ready == TRUE) {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_ready_lock();
+ lockd->start_ready = FALSE;
+ } else {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_phone_lock();
+ }
+ phone_lock_pid = lockd->phone_lock_app_pid;
+ LOCKD_WARN("%s, %d, phone_lock_pid = %d", __func__, __LINE__,
+ phone_lock_pid);
+ lockd_window_set_phonelock_pid(lockd->lockw, phone_lock_pid);
+ if (phone_lock_pid > 0) {
+ if(starter_dbus_set_oomadj(phone_lock_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ else{
+ LOCKD_ERR("failed to launch phone lock.");
+ goto launch_out;
+ }
+ lockd_process_mgr_set_lockscreen_priority(phone_lock_pid);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ break;
+
+ default:
+ goto launch_out;
+ }
+
+
+ if (lockd->lock_app_pid > 0) {
+ if(starter_dbus_set_oomadj(lockd->lock_app_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ else{
+ LOCKD_ERR("failed to launch lock");
+ goto launch_out;
+ }
+ LOCKD_WARN("lock app pid : %d", lockd->lock_app_pid);
+ lockd_process_mgr_set_lockscreen_priority(lockd->lock_app_pid);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+
+
+launch_out:
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return -1;
+}
+
+
+static int lockd_launch_app_other_lockscreen(struct lockd_data *lockd)
+{
+ LOCKD_DBG("launch app other lock screen");
+
+ int call_state = -1, factory_mode = -1, test_mode = -1;
+ int r = 0;
+ int lcdoff_source = 0;
+ int focus_win_pid = 0;
+ int pw_type = 0;
+ int automatic_unlock = 0;
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, &factory_mode);
+ if (factory_mode == VCONFKEY_TELEPHONY_SIM_FACTORYMODE_ON) {
+ LOCKD_ERR("Factory mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ if (test_mode == VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE) {
+ LOCKD_ERR("Test mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+
+ if (lockd->is_first_boot == TRUE) {
+ if(vconf_get_int(VCONFKEY_PWLOCK_STATE, &pw_type) < 0)
+ {
+ LOCKD_ERR("vconf_get_int() failed");
+ pw_type = VCONFKEY_PWLOCK_RUNNING_UNLOCK;
+ }
+ if(pw_type == VCONFKEY_PWLOCK_BOOTING_LOCK || pw_type == VCONFKEY_PWLOCK_RUNNING_LOCK) {
+ LOCKD_ERR("First boot & pwlock state[%d], lock screen can't be launched..!!", pw_type);
+ goto launch_out;
+ }
+ }
+
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_NONE) {
+ LOCKD_ERR("Lock screen type is None..!!");
+ goto launch_out;
+ }
+
+ /* Get Call state */
+ if(vconf_get_int(VCONFKEY_PM_LCDOFF_SOURCE, &lcdoff_source) < 0)
+ {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ focus_win_pid = lockd_window_mgr_get_focus_win_pid();
+ vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY) {
+ if ((call_state != VCONFKEY_CALL_OFF) && (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER)) {
+ if (focus_win_pid >0) {
+ if (lockd_process_mgr_check_call(focus_win_pid) == TRUE) {
+ LOCKD_ERR("Call is FG => not allow to launch lock screen!!");
+ goto launch_out;
+ } else {
+ LOCKD_DBG("Call is BG => allow to launch lock screen!!");
+ }
+ }
+ }
+ } else {
+ if ((call_state != VCONFKEY_CALL_OFF) && (lockd->back_to_app == FALSE)) {
+ LOCKD_ERR("Current call state(%d) does not allow to launch lock screen.",
+ call_state);
+ goto launch_out;
+ }
+ }
+
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER) {
+ if (lockd_process_mgr_check_lock(lockd->lock_app_pid) == TRUE) {
+ LOCKD_WARN("Lock Screen App is already running.");
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ }
+
+ if (lockd->lock_app_pid > 0) {
+ LOCKD_ERR("Lock Screen App is remained, pid[%d].", lockd->lock_app_pid);
+ lockd_process_mgr_kill_lock_app(lockd->lock_app_pid);
+ lockd->lock_app_pid = 0;
+ }
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY)
+ ecore_idler_add(_lockd_play_idelr_cb, NULL);
+
+ lockd->lock_app_pid =
+ lockd_process_mgr_start_lock(lockd, lockd_app_dead_cb_lite,
+ lockd->lock_type);
+ if (lockd->lock_app_pid < 0) {
+ LOCKD_ERR("launch 3rd party lockscreen failed.");
+ goto launch_out;
+ }
+ /* reset window mgr before start win mgr */
+ lockd_window_mgr_finish_lock(lockd->lockw);
+ lockd_window_mgr_ready_lock(lockd, lockd->lockw, lockd_other_app_create_cb,
+ lockd_other_app_show_cb);
+ }
+
+ if (lockd->lock_app_pid > 0) {
+ if(starter_dbus_set_oomadj(lockd->lock_app_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ LOCKD_WARN("lock app pid : %d", lockd->lock_app_pid);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+
+
+ launch_out:
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return -1;
+}
+
+static void lockd_unlock_other_lockscreen(struct lockd_data *lockd)
+{
+ LOCKD_DBG("unlock other lock screen");
+ lockd->lock_app_pid = 0;
+
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ lockd_window_mgr_finish_lock(lockd->lockw);
+}
+
+inline static void lockd_set_sock_option(int fd, int cli)
+{
+ int size;
+ int ret;
+ struct timeval tv = { 1, 200 * 1000 }; /* 1.2 sec */
+
+ size = PHLOCK_SOCK_MAXBUFF;
+ ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+ if(ret != 0)
+ return;
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+ if(ret != 0)
+ return;
+ if (cli) {
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ if(ret != 0)
+ return;
+ }
+}
+
+static int lockd_create_sock(void)
+{
+ struct sockaddr_un saddr;
+ int fd;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0); /* support above version 2.6.27 */
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ LOCKD_ERR
+ ("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ LOCKD_ERR("socket error");
+ return -1;
+ }
+ }
+
+ bzero(&saddr, sizeof(saddr));
+ saddr.sun_family = AF_UNIX;
+
+ strncpy(saddr.sun_path, PHLOCK_SOCK_PREFIX, sizeof(saddr.sun_path)-1);
+ saddr.sun_path[strlen(PHLOCK_SOCK_PREFIX)] = 0;
+
+ unlink(saddr.sun_path);
+
+ if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+ LOCKD_ERR("bind error");
+ close(fd);
+ return -1;
+ }
+
+ if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ /* Flawfinder: ignore */
+ LOCKD_ERR("failed to change the socket permission");
+ close(fd);
+ return -1;
+ }
+
+ lockd_set_sock_option(fd, 0);
+
+ if (listen(fd, 10) == -1) {
+ LOCKD_ERR("listen error");
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+static gboolean lockd_glib_check(GSource * src)
+{
+ GSList *fd_list;
+ GPollFD *tmp;
+
+ fd_list = src->poll_fds;
+ do {
+ tmp = (GPollFD *) fd_list->data;
+ if ((tmp->revents & (POLLIN | POLLPRI)))
+ return TRUE;
+ fd_list = fd_list->next;
+ } while (fd_list);
+
+ return FALSE;
+}
+
+static char *lockd_read_cmdline_from_proc(int pid)
+{
+ int memsize = 32;
+ char path[32];
+ char *cmdline = NULL, *tempptr = NULL;
+ FILE *fp = NULL;
+
+ snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
+
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ LOCKD_ERR("Cannot open cmdline on pid[%d]", pid);
+ return NULL;
+ }
+
+ cmdline = malloc(32);
+ if (cmdline == NULL) {
+ LOCKD_ERR("%s", "Out of memory");
+ fclose(fp);
+ return NULL;
+ }
+
+ bzero(cmdline, memsize);
+ if (fgets(cmdline, 32, fp) == NULL) {
+ LOCKD_ERR("%s", "Cannot read cmdline");
+ free(cmdline);
+ fclose(fp);
+ return NULL;
+ }
+
+ while (cmdline[memsize - 2] != 0) {
+ cmdline[memsize - 1] = (char)fgetc(fp);
+ tempptr = realloc(cmdline, memsize + 32);
+ if (tempptr == NULL) {
+ fclose(fp);
+ LOCKD_ERR("%s", "Out of memory");
+ return NULL;
+ }
+ cmdline = tempptr;
+ bzero(cmdline + memsize, 32);
+ fgets(cmdline + memsize, 32, fp);
+ memsize += 32;
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+ return cmdline;
+}
+
+static int lockd_sock_handler(void *data)
+{
+ int cl;
+ int len;
+ int sun_size;
+ int clifd = -1;
+ char cmd[PHLOCK_SOCK_MAXBUFF];
+ char *cmdline = NULL;
+ int fd = -1;
+ int recovery_state = -1;
+ GPollFD *gpollfd;
+
+ struct ucred cr;
+ struct sockaddr_un lockd_addr;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if ((lockd == NULL) || (lockd->gpollfd == NULL)) {
+ LOCKD_ERR("lockd->gpollfd is NULL");
+ return -1;
+ }
+ gpollfd = (GPollFD *)lockd->gpollfd;
+ fd = gpollfd->fd;
+
+ cl = sizeof(cr);
+ sun_size = sizeof(struct sockaddr_un);
+
+ if ((clifd =
+ accept(fd, (struct sockaddr *)&lockd_addr,
+ (socklen_t *) & sun_size)) == -1) {
+ if (errno != EINTR)
+ LOCKD_ERR("accept error");
+ return -1;
+ }
+
+ if (getsockopt(clifd, SOL_SOCKET, SO_PEERCRED, &cr, (socklen_t *) & cl)
+ < 0) {
+ LOCKD_ERR("peer information error");
+ close(clifd);
+ return -1;
+ }
+ LOCKD_ERR("Peer's pid=%d, uid=%d, gid=%d\n", cr.pid, cr.uid, cr.gid);
+
+ memset(cmd, 0, PHLOCK_SOCK_MAXBUFF);
+
+ lockd_set_sock_option(clifd, 1);
+
+ /* receive single packet from socket */
+ len = recv(clifd, cmd, PHLOCK_SOCK_MAXBUFF, 0);
+
+ if (len < 0) {
+ LOCKD_ERR("recv error, read number is less than zero");
+ close(clifd);
+ return -1;
+ }
+
+ cmd[PHLOCK_SOCK_MAXBUFF - 1] = '\0';
+
+ LOCKD_ERR("cmd %s", cmd);
+
+ /* Read command line of the PID from proc fs */
+ cmdline = lockd_read_cmdline_from_proc(cr.pid);
+ if (cmdline == NULL) {
+ /* It's weired. no file in proc file system, */
+ LOCKD_ERR("Error on opening /proc/%d/cmdline", cr.pid);
+ close(clifd);
+ return -1;
+ }
+ LOCKD_SECURE_ERR("/proc/%d/cmdline : %s", cr.pid, cmdline);
+
+ if ((!strncmp(cmd, PHLOCK_UNLOCK_RESET_CMD, strlen(cmd)))
+ && (!strncmp(cmdline, OMA_DRM_AGENT_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ if(phone_lock_pid > 0) {
+ LOCKD_SECURE_ERR("pid [%d] %s is verified, unlock..!!\n", cr.pid,
+ cmdline);
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, TRUE);
+ // reset lockscreen type
+ if (vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE) < 0) {
+ LOCKD_ERR("%s set to %d is failed. error \n",
+ VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE);
+ }
+ }
+ } else if (!strncmp(cmd, PHLOCK_LAUNCH_CMD, strlen(cmd))) {
+ if (!strncmp(cmdline, MDM_APP_CMDLINE, strlen(cmdline))) {
+ LOCKD_ERR("%s request %s \n", cmdline, cmd);
+ if (vconf_get_int(VCONFKEY_EAS_RECOVERY_MODE, &recovery_state) < 0) {
+ LOCKD_ERR("Cannot get vconfkey", VCONFKEY_EAS_RECOVERY_MODE);
+ lockd->request_recovery = FALSE;
+ } else if (recovery_state == 1) {
+ LOCKD_ERR("recovery mode : %d \n", recovery_state);
+ lockd->request_recovery = TRUE;
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ }
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
+ lockd_launch_app_lockscreen_lite(lockd);
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ } else if (!strncmp(cmd, HOME_RAISE_CMD, strlen(cmd))) {
+ if ((!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline)))
+ || (!strncmp(cmdline, VIDEO_CALL_APP_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ menu_daemon_open_homescreen(NULL);
+ }
+ } else if (!strncmp(cmd, LOCK_SHOW_CMD, strlen(cmd))) {
+ if ((!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline)))
+ || (!strncmp(cmdline, VIDEO_CALL_APP_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ lockd->back_to_app = TRUE;
+ }
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD){
+ lockd_launch_app_lockscreen_lite(lockd);
+ } else {
+ lockd->back_to_app = FALSE;
+ }
+ } else if (!strncmp(cmd, LOCK_LAUNCH_CMD, strlen(cmd))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ if (!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline))) {
+ lockd_launch_app_lockscreen_lite(lockd);
+ }
+ }
+
+ if(cmdline != NULL) {
+ free(cmdline);
+ cmdline = NULL;
+ }
+
+ close(clifd);
+ return 0;
+}
+
+static gboolean lockd_glib_handler(gpointer data)
+{
+ if (lockd_sock_handler(data) < 0) {
+ LOCKD_ERR("lockd_sock_handler is failed..!!");
+ }
+ return TRUE;
+}
+
+static gboolean lockd_glib_dispatch(GSource * src, GSourceFunc callback,
+ gpointer data)
+{
+ callback(data);
+ return TRUE;
+}
+
+static gboolean lockd_glib_prepare(GSource * src, gint * timeout)
+{
+ return FALSE;
+}
+
+static GSourceFuncs funcs = {
+ .prepare = lockd_glib_prepare,
+ .check = lockd_glib_check,
+ .dispatch = lockd_glib_dispatch,
+ .finalize = NULL
+};
+
+static int lockd_init_sock(struct lockd_data *lockd)
+{
+ int fd;
+ GPollFD *gpollfd;
+ GSource *src;
+ int ret;
+
+ fd = lockd_create_sock();
+ if (fd < 0) {
+ LOCKD_ERR("lock daemon create sock failed..!!");
+ }
+
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ if (!gpollfd) {
+ LOCKD_ERR("gpollfd is NULL");
+ g_source_unref(src);
+ return -1;
+ }
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ lockd->gpollfd = gpollfd;
+
+ g_source_add_poll(src, lockd->gpollfd);
+ g_source_set_callback(src, (GSourceFunc) lockd_glib_handler,
+ (gpointer) lockd, NULL);
+ g_source_set_priority(src, G_PRIORITY_LOW);
+
+ ret = g_source_attach(src, NULL);
+ if (ret == 0)
+ return -1;
+
+ g_source_unref(src);
+
+ return 0;
+}
+
+
+
+
+static void _lockd_notify_bt_device_connected_status_cb(keynode_t * node, void *data)
+{
+ int is_connected = 0;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ vconf_get_bool(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL , &is_connected);
+ LOCKD_WARN("BT connect status is changed to [%d]", is_connected);
+
+ if (is_connected) {
+ if (lockd_start_bt_monitor() < 0) {
+ LOCKD_ERR("Fail starter BT monitor");
+ }
+ } else {
+ lockd_stop_bt_monitor();
+ lockd_change_security_auto_lock(is_connected);
+ }
+}
+
+
+static void _lockd_notify_lock_type_changed_cb(keynode_t * node, void *data)
+{
+ int lock_type = -1;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ LOCKD_DBG("lock type is changed..!!");
+
+ lock_type = vconf_keynode_get_int(node);
+ lockd->lock_type = lock_type;
+
+ if(lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER){
+ LOCKD_DBG("lock type is 3rd party lock");
+ lockd_init_vconf(lockd);
+ if(lockd->lock_app_pid > 0){
+ lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
+ lockd->lock_app_pid = 0;
+ }
+ if(lockd->phone_lock_app_pid > 0){
+ lockd_process_mgr_terminate_lock_app(lockd->phone_lock_app_pid, 1);
+ lockd->phone_lock_app_pid = 0;
+ }
+ }
+ else{
+ LOCKD_DBG("lock type is not 3rd party lock");
+ lockd_fini_vconf(lockd);
+ lockd->start_ready = TRUE;
+ lockd_launch_app_lockscreen_lite(lockd);
+ }
+}
+
+
+static void lockd_fini_vconf(struct lockd_data *lockd)
+{
+ int val = -1;
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_PM_STATE, _lockd_notify_pm_state_cb_lite) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_PM_STATE");
+ }
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_PM_LCDOFF_SOURCE, _lockd_notify_pm_lcdoff_cb_lite) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_PM_LCDOFF_SOURCE");
+ }
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, _lockd_notify_factory_mode_cb) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_TELEPHONY_SIM_FACTORY_MODE");
+ }
+#if 0
+ if (vconf_ignore_key_changed
+ (VCONFKEY_SYSTEM_TIME_CHANGED, _lockd_notify_time_changed_cb) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_SYSTEM_TIME_CHANGED");
+ }
+#endif
+ if (vconf_ignore_key_changed
+ (VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, _lockd_notify_phone_lock_verification_cb) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION");
+ }
+ if (vconf_ignore_key_changed
+ (VCONFKEY_IDLE_LOCK_STATE, _lockd_notify_lock_state_cb) != 0) {
+ LOCKD_ERR("Fail vconf_ignore_key_changed : VCONFKEY_IDLE_LOCK_STATE");
+ }
+}
+
+
+static void lockd_init_vconf(struct lockd_data *lockd)
+{
+ int val = -1;
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_PM_STATE, _lockd_notify_pm_state_cb_lite, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_PM_LCDOFF_SOURCE, _lockd_notify_pm_lcdoff_cb_lite, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, _lockd_notify_factory_mode_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+#if 0
+ if (vconf_notify_key_changed
+ (VCONFKEY_SYSTEM_TIME_CHANGED, _lockd_notify_time_changed_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+#endif
+ if (vconf_notify_key_changed
+ (VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION,
+ _lockd_notify_phone_lock_verification_cb, lockd) != 0) {
+ if (vconf_get_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, &val) < 0) {
+ LOCKD_ERR
+ ("Cannot get VCONFKEY");
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, 0);
+ if (vconf_notify_key_changed
+ (VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION,
+ _lockd_notify_phone_lock_verification_cb,
+ lockd) != 0) {
+ LOCKD_ERR
+ ("Fail vconf_notify_key_changed " );
+ }
+ } else {
+ LOCKD_ERR
+ ("Fail vconf_notify_key_changed " );
+ }
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_IDLE_LOCK_STATE,
+ _lockd_notify_lock_state_cb,
+ lockd) != 0) {
+ LOCKD_ERR
+ ("[Error] vconf notify : lock state");
+ }
+}
+
+
+static Eina_Bool lockd_init_alarm(void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int ret_val = 0;
+ /* alarm id initialize */
+ lockd->alarm_id = -1;
+
+ g_type_init();
+ ret_val = alarmmgr_init(PACKAGE_NAME);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_init() failed(%d)", ret_val);
+ return EINA_FALSE;
+ }
+ ret_val = alarmmgr_set_cb((alarm_cb_t)_lockd_lauch_other_lockscreen, lockd);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_init() failed");
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("alarm init success");
+ return EINA_TRUE;
+}
+
+static int lockd_init_hall_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ LOCKD_ERR("e_dbus_bus_get error");
+ return -1;
+ }
+ lockd->hall_conn = conn;
+
+#if 0
+ int r;
+ r = e_dbus_request_name(conn, BUS_NAME, 0, NULL, NULL);
+ if (!r) {
+ LOCKD_ERR("e_dbus_request_name erro");
+ return -1;
+ }
+#endif
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DEVICED_PATH_HALL,
+ DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE,
+ _lockd_on_changed_receive, lockd);
+ if (handler == NULL) {
+ LOCKD_ERR("e_dbus_signal_handler_add error");
+ return -1;
+ }
+ lockd->hall_handler = handler;
+ /* S-Cover Lock : Signal <!-- END --> */
+}
+
+
+
+static Eina_Bool _lockd_launch_lockscreen_by_pwr_key(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ LOCKD_DBG("lcd off by powerkey");
+
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SWIPE) {
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ }
+ }
+ lockd_launch_app_lockscreen_lite(lockd);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static void _lockd_receive_lcd_off(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ int r;
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ LOCKD_DBG("lcd off signal is received");
+
+ r = dbus_message_is_signal(msg, DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME);
+ if (!r) {
+ LOCKD_ERR("dbus_message_is_signal error");
+ return;
+ }
+
+ LOCKD_DBG("%s - %s", DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME);
+
+#if 0 //need to check if lockscreen is displayed before lcd off.
+ idle_lock_state = lockd_get_lock_state();
+
+ LOCKD_DBG("lcd off by powerkey");
+
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == LOCK_TYPE_SECURITY || lockd->lock_type == LOCK_TYPE_NORMAL) {
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ }
+ }
+ lockd_launch_app_lockscreen_lite(lockd);
+#else
+ ecore_idler_add(_lockd_launch_lockscreen_by_pwr_key, lockd);
+#endif
+}
+
+
+static int lockd_init_lcd_off_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ LOCKD_ERR("e_dbus_bus_get error");
+ return -1;
+ }
+ lockd->display_conn = conn;
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DEVICED_PATH_LCD_OFF,
+ DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME,
+ _lockd_receive_lcd_off, lockd);
+ if (handler == NULL) {
+ LOCKD_ERR("e_dbus_signal_handler_add error");
+ return -1;
+ }
+ lockd->display_handler = handler;
+}
+
+void lockd_check_vconf_festival_wallpaper(void *data){
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+ int festival_wallpaper = 0;
+
+ if(vconf_get_bool(VCONFKEY_LOCKSCREEN_FESTIVAL_WALLPAPER_DISPLAYING, &festival_wallpaper) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ festival_wallpaper = 0;
+ }
+ LOCKD_DBG("festival wallpaper : %d", festival_wallpaper);
+ if(festival_wallpaper){
+ bundle *b;
+ b = bundle_create();
+ if(b == NULL){
+ LOCKD_ERR("bundle create failed.\n");
+ return;
+ }
+ bundle_add(b, "popup_type", "festival");
+ bundle_add(b, "festival_type", "festival_create");
+ aul_launch_app(WALLPAPER_UI_SERVICE_PKG_NAME, b);
+ bundle_free(b);
+ }
+
+}
+
+static void _lockd_check_ongoing(bool ongoing)
+{
+ if (ongoing) {
+ /* check previous process */
+ if (checkfd) {
+ LOCKD_ERR("checkfd fail\n");
+ return;
+ }
+
+ /* make tmp file */
+ FILE *fp = fopen(PASSWORD_LOCK_PROGRESS, "w+");
+ if (!fp) {
+ LOCKD_ERR("Failed to open file : %s", PASSWORD_LOCK_PROGRESS);
+ checkfd = 0;
+ return;
+ }
+ LOCKD_WARN("make %s file\n", PASSWORD_LOCK_PROGRESS);
+ checkfd = 1;
+ fclose(fp);
+ } else {
+ if (!checkfd) return;
+ if (unlink(PASSWORD_LOCK_PROGRESS) < 0)
+ LOCKD_ERR("fail to remove %s file\n", PASSWORD_LOCK_PROGRESS);
+ close(checkfd);
+ checkfd = 0;
+ LOCKD_WARN("delete %s file\n", PASSWORD_LOCK_PROGRESS);
+ }
+}
+
+static void lockd_start_lock_daemon_lite(void *data)
+{
+ struct lockd_data *lockd = NULL;
+ int r = 0;
+
+ lockd = (struct lockd_data *)data;
+
+ if (!lockd) {
+ return;
+ }
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockd_process_mgr_init();
+
+ /* init alarm manager */
+// lockd_check_vconf_festival_wallpaper(lockd);
+
+ lockd->is_alarm = lockd_init_alarm(lockd);
+
+
+ /* Initialize socket */
+ r = lockd_init_sock(lockd);
+ if (r < 0) {
+ LOCKD_ERR("lockd init socket failed: %d", r);
+ }
+
+ /* Create internal 1x1 window */
+ lockd->lockw = lockd_window_init();
+
+ aul_listen_app_dead_signal(lockd_app_dead_cb_lite, data);
+}
+
+static Eina_Bool _lockd_check_wallpaper_service(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ lockd_check_vconf_festival_wallpaper(lockd);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+int start_lock_daemon_lite(int launch_lock, int is_first_boot)
+{
+ struct lockd_data *lockd = NULL;
+ int recovery_state = -1;
+ int lock_type = 0;
+ int first_boot = 0;
+ int ret = 0;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockd = (struct lockd_data *)malloc(sizeof(struct lockd_data));
+ retv_if(!lockd, 0);
+ memset(lockd, 0x0, sizeof(struct lockd_data));
+ lockd_start_lock_daemon_lite(lockd);
+
+ vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
+ lockd->lock_type = lock_type;
+ if(lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD || lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD){
+ if(checkfd){
+ _lockd_check_ongoing(EINA_FALSE);
+ }
+ else{
+ _lockd_check_ongoing(EINA_TRUE);
+ }
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, _lockd_notify_lock_type_changed_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_SYSTEM_TIME_CHANGED, _lockd_notify_time_changed_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_IDLE_LOCK_STATE,
+ _lockd_notify_lock_state_cb,
+ lockd) != 0) {
+ LOCKD_ERR
+ ("[Error] vconf notify : lock state");
+ }
+
+ lockd->back_to_app = FALSE;
+
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_NONE)
+ return -1;
+ if ((lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) || (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD)) {
+ if (vconf_get_int(VCONFKEY_EAS_RECOVERY_MODE, &recovery_state) < 0) {
+ LOCKD_ERR("Cannot get vconfkey" );
+ lockd->request_recovery = FALSE;
+ } else if (recovery_state == 1) {
+ LOCKD_DBG("recovery mode : %d \n", recovery_state);
+ lockd->request_recovery = TRUE;
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+
+ vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE);
+
+ if (launch_lock == FALSE) {
+ LOCKD_ERR("Don't launch lockscreen..");
+ ecore_idler_add(_lockd_check_wallpaper_service, lockd);
+ return 0;
+ }
+
+ lockd->is_first_boot = is_first_boot;
+ if (lockd->is_first_boot == TRUE){
+ LOCKD_ERR("first_boot : %d \n", lockd->is_first_boot);
+ lockd->start_ready = TRUE;
+ ret = lockd_launch_app_lockscreen_lite(lockd);
+ if(ret < 0){
+ LOCKD_ERR("launch lockscreen failed. retry one more time.");
+ ret = lockd_launch_app_lockscreen_lite(lockd);
+ if(ret < 0){
+ LOCKD_ERR("failed to launch lockscreen.");
+ }
+ }
+ ecore_idler_add(_lockd_check_wallpaper_service, lockd);
+ return 0;
+ }
+
+ if (lockd->lock_type == SETTING_SCREEN_LOCK_TYPE_OTHER) {
+ lockd_init_vconf(lockd);
+ ret = lockd_launch_app_other_lockscreen(lockd);
+ if(ret < 0){
+ LOCKD_ERR("launch 3rd party lockscreen failed. retry one more time.");
+ ret = lockd_launch_app_other_lockscreen(lockd);
+ if(ret < 0){
+ LOCKD_ERR("failed to launch 3rd party lockscreen.");
+ }
+ }
+ } else {
+ ret = lockd_launch_app_lockscreen_lite(lockd);
+ if(ret < 0){
+ LOCKD_ERR("launch lockscreen failed. retry one more time.");
+ ret = lockd_launch_app_lockscreen_lite(lockd);
+ if(ret < 0){
+ LOCKD_ERR("failed to launch lockscreen.");
+ }
+ }
+ }
+ ecore_idler_add(_lockd_check_wallpaper_service, lockd);
+
+ if(feedback_initialize() != FEEDBACK_ERROR_NONE) {
+ LOCKD_ERR("[CAUTION][ERROR] feedback_initialize() is failed..!!");
+ }
+
+ return ret;
+}
+
+
diff --git a/src/lock-daemon.c b/src/lock-daemon.c
new file mode 100755
index 0000000..5e79517
--- /dev/null
+++ b/src/lock-daemon.c
@@ -0,0 +1,2125 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <glib.h>
+#include <poll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <errno.h>
+//#include <sensors.h>
+#include <feedback.h>
+#include <alarm.h>
+#include <time.h>
+#include <dd-deviced.h>
+#include <dd-display.h>
+#include <E_DBus.h>
+#include <aul.h>
+
+#ifndef FEATURE_LITE
+#include <context_manager.h>
+#endif
+
+#include "lockd-debug.h"
+#include "lock-daemon.h"
+#include "lockd-process-mgr.h"
+#include "lockd-window-mgr.h"
+#include "starter-util.h"
+#include "menu_daemon.h"
+#include "hw_key.h"
+#include "lockd-bt.h"
+#include "dbus-util.h"
+
+static int phone_lock_pid;
+static int auto_lock_pid;
+static bool lock_state_available = TRUE;
+
+struct lockd_data {
+ int lock_app_pid;
+ int phone_lock_app_pid;
+ int lock_type; /* -1: None, 0:Normal, 1:Security, 2:Other */
+ Eina_Bool is_sensor; /* EINA_TRUE : can use sensor EINA_FALSE : cannot use */
+ Eina_Bool request_recovery;
+ Eina_Bool back_to_app;
+ lockw_data *lockw;
+ GPollFD *gpollfd;
+ Eina_Bool is_alarm; /* EINA_TRUE : can use alarm EINA_FALSE : cannot use */
+ alarm_id_t alarm_id; /* -1 : None, others : set alarm */
+ Eina_Bool is_first_boot; /* EINA_TRUE : first boot */
+ int hall_status; /* 0: cover is closed, 1:cover is opened */
+ E_DBus_Connection *hall_conn;
+ E_DBus_Signal_Handler *hall_handler;
+ E_DBus_Connection *display_conn;
+ E_DBus_Signal_Handler *display_handler;
+
+};
+
+
+
+/* Local features*/
+#define _FEATURE_LCD_OFF_DBUS 0 //Check to apply lcd off dbus by PM part
+#define _FEATURE_SCOVER 0 //Scover view
+
+
+
+
+#define PHLOCK_SOCK_PREFIX "/tmp/phlock"
+#define PHLOCK_SOCK_MAXBUFF 65535
+
+#define VOLUNE_APP_CMDLINE "/usr/apps/com.samsung.volume/bin/volume" // LOCK_EXIT_CMD
+#define PHLOCK_APP_CMDLINE "/usr/apps/org.tizen.lockscreen/bin/lockscreen" //PHLOCK_UNLOCK_CMD
+#define MDM_APP_CMDLINE "/usr/bin/mdm-server" //PHLOCK_LAUNCH_CMD
+#define VOICE_CALL_APP_CMDLINE "/usr/apps/com.samsung.call/bin/calls" //HOME_RAISE_CMD, LOCK_SHOW_CMD
+#define VIDEO_CALL_APP_CMDLINE "/usr/apps/com.samsung.vtmain/bin/vtmain" //HOME_RAISE_CMD, LOCK_SHOW_CMD
+#define OMA_DRM_AGENT_CMDLINE "/usr/bin/oma-dm-agent" //PHLOCK_UNLOCK_RESET_CMD
+
+#define PHLOCK_UNLOCK_CMD "unlock"
+#define PHLOCK_LAUNCH_CMD "launch_phone_lock"
+#define PHLOCK_UNLOCK_RESET_CMD "unlock_reset"
+#define HOME_RAISE_CMD "raise_homescreen"
+#define LOCK_SHOW_CMD "show_lockscreen"
+#define LOCK_LAUNCH_CMD "launch_lockscreen"
+#define LOCK_EXIT_CMD "exit_lockscreen"
+
+#define LAUNCH_INTERVAL 100*1000
+
+#define HALL_COVERED_STATUS 0
+#define BUS_NAME "org.tizen.system.deviced"
+#define OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define INTERFACE_NAME BUS_NAME
+#define DEVICED_PATH_HALL OBJECT_PATH"/Hall"
+#define DEVICED_INTERFACE_HALL INTERFACE_NAME".hall"
+#define SIGNAL_HALL_STATE "ChangeState"
+#define METHOD_GET_STATUS "getstatus"
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+#define DEVICED_PATH_PMQOS OBJECT_PATH"/PmQos"
+#define DEVICED_INTERFACE_PMQOS INTERFACE_NAME".PmQos"
+#define METHOD_PMQOS_NAME "LockScreen"
+#define REQUEST_PMQOS_DURATION (2 * 1000)
+
+#define DEVICED_PATH_LCD_OFF OBJECT_PATH"/Display"
+#define DEVICED_INTERFACE_LCD_OFF INTERFACE_NAME".display"
+#define METHOD_LCD_OFF_NAME "LCDOffByPowerkey"
+
+#define VOLUME_PKG_NAME "org.tizen.volume"
+#define WALLPAPER_UI_SERVICE_PKG_NAME "com.samsung.wallpaper-ui-service"
+#define SHOW_LOCK "show_lock"
+#define ISTRUE "TRUE"
+#define SMART_ALERT_INTERVAL 0.5
+
+enum {
+ LOCK_TYPE_NONE = -1,
+ LOCK_TYPE_NORMAL = 0,
+ LOCK_TYPE_SECURITY,
+ LOCK_TYPE_AUTO_LOCK,
+ LOCK_TYPE_OTHER,
+ LOCK_TYPE_MAX
+};
+
+static int lockd_launch_app_lockscreen(struct lockd_data *lockd);
+static void lockd_unlock_lockscreen(struct lockd_data *lockd);
+#if 0
+static Eina_Bool lockd_start_sensor(void *data);
+static void lockd_stop_sensor(void *data);
+#endif
+
+static void _lockd_set_lock_state(int lock_state)
+{
+ LOCKD_DBG("%s, %d, %d", __func__, __LINE__, lock_state);
+ if(lock_state < VCONFKEY_IDLE_UNLOCK || lock_state > VCONFKEY_IDLE_LAUNCHING_LOCK) {
+ LOCKD_ERR("Can't set lock_state : %d out of range", lock_state);
+ } else {
+ vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, lock_state);
+ }
+}
+
+static void _lockd_play_sound(bool unlock)
+{
+ int ret = -1, val = 0;
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &val);
+
+ if(ret == 0 && val == 1) {
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_SOUND, unlock ? FEEDBACK_PATTERN_UNLOCK : FEEDBACK_PATTERN_LOCK);
+ }
+}
+
+int lockd_get_lock_type(void)
+{
+ int lock_type = 0;
+ int ret = 0;
+
+ vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
+
+ if (lock_type == SETTING_SCREEN_LOCK_TYPE_NONE) {
+ ret = LOCK_TYPE_NONE;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_FINGERPRINT ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE) {
+ ret = LOCK_TYPE_SECURITY;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_SWIPE ||
+ lock_type == SETTING_SCREEN_LOCK_TYPE_MOTION) {
+ ret = LOCK_TYPE_NORMAL;
+ } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_AUTO_LOCK) {
+ ret = LOCK_TYPE_AUTO_LOCK;
+ } else {
+ ret = LOCK_TYPE_OTHER;
+ }
+
+ LOCKD_DBG("lockd_get_lock_type ret(%d), lock_type (%d)", ret, lock_type);
+
+ return ret;
+}
+
+static int _lockd_append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+ char *ch;
+ int i;
+ int int_type;
+ uint64_t int64_type;
+
+ if (!sig || !param)
+ return 0;
+
+ for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+ switch (*ch) {
+ case 'i':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+ break;
+ case 'u':
+ int_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+ break;
+ case 't':
+ int64_type = atoi(param[i]);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+ break;
+ case 's':
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+DBusMessage *_lockd_invoke_dbus_method_async(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ LOCKD_ERR("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ LOCKD_ERR("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _lockd_append_variant(&iter, sig, param);
+ if (r < 0) {
+ LOCKD_ERR("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ r = dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ if (r != TRUE) {
+ LOCKD_ERR("dbus_connection_send error(%s:%s:%s-%s)", dest, path, interface, method);
+ return -ECOMM;
+ }
+ LOCKD_DBG("dbus_connection_send, ret=%d", r);
+ return NULL;
+}
+
+DBusMessage *_lockd_invoke_dbus_method_sync(const char *dest, const char *path,
+ const char *interface, const char *method,
+ const char *sig, char *param[])
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+ int r;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ LOCKD_ERR("dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ LOCKD_ERR("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ r = _lockd_append_variant(&iter, sig, param);
+ if (r < 0) {
+ LOCKD_ERR("append_variant error(%d)", r);
+ return NULL;
+ }
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+ if (!reply) {
+ LOCKD_ERR("dbus_connection_send error(No reply)");
+ }
+
+ if (dbus_error_is_set(&err)) {
+ LOCKD_ERR("dbus_connection_send error(%s:%s)", err.name, err.message);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ return reply;
+}
+
+int lockd_get_hall_status(void)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+
+ LOCKD_DBG("[ == %s == ]", __func__);
+ msg = _lockd_invoke_dbus_method_sync(BUS_NAME, DEVICED_PATH_HALL, DEVICED_INTERFACE_HALL,
+ METHOD_GET_STATUS, NULL, NULL);
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ LOCKD_ERR("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ LOCKD_DBG("%s-%s : %d", DEVICED_INTERFACE_HALL, METHOD_GET_STATUS, ret_val);
+ return ret_val;
+}
+
+int lockd_get_lock_state(void)
+{
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &idle_lock_state) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+ }
+ LOCKD_DBG("Get lock state : %d", idle_lock_state);
+ return idle_lock_state;
+}
+
+static void _lockd_on_changed_receive(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ char *str;
+ int response;
+ int r;
+ int automatic_unlock = 0;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ LOCKD_DBG("hall signal is received");
+
+ r = dbus_message_is_signal(msg, DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE);
+ if (!r) {
+ LOCKD_ERR("dbus_message_is_signal error");
+ return;
+ }
+
+ LOCKD_DBG("%s - %s", DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE);
+
+ dbus_error_init(&err);
+ r = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+ if (!r) {
+ LOCKD_ERR("dbus_message_get_args error");
+ return;
+ }
+
+ LOCKD_DBG("receive data : %d", response);
+ lockd->hall_status = response;
+
+}
+
+static int _lockd_request_PmQos(int duration)
+{
+ DBusError err;
+ DBusMessage *msg;
+ int ret, ret_val;
+ char *arr[1];
+ char val[32];
+
+ snprintf(val, sizeof(val), "%d", duration);
+ arr[0] = val;
+
+ //msg = _lockd_invoke_dbus_method_sync(BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS,
+ // METHOD_PMQOS_NAME, "i", arr);
+ msg = _lockd_invoke_dbus_method_async(BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS,
+ METHOD_PMQOS_NAME, "i", arr);
+
+ if (!msg)
+ return -EBADMSG;
+
+ dbus_error_init(&err);
+
+ ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
+ if (!ret) {
+ LOCKD_ERR("no message : [%s:%s]", err.name, err.message);
+ ret_val = -EBADMSG;
+ }
+
+ dbus_message_unref(msg);
+ dbus_error_free(&err);
+
+ LOCKD_DBG("%s-%s : %d", DEVICED_INTERFACE_PMQOS, METHOD_PMQOS_NAME, ret_val);
+ return ret_val;
+}
+
+static void _lockd_delete_alarm(alarm_id_t id, void * user_param)
+{
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+ LOCKD_DBG("Del alarm_id(%d)", id);
+ ret_val = alarmmgr_remove_alarm(id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+}
+
+static void _lockd_unset_alarms(void)
+{
+ LOCKD_DBG("[ == %s == ]", __func__);
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+ ret_val = alarmmgr_enum_alarm_ids(_lockd_delete_alarm, NULL);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_enum_alarm_ids() failed");
+ }
+}
+
+static void _lockd_lauch_lockscreen(alarm_id_t alarm_id, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+
+ LOCKD_DBG("[ == %s == ], alarm_id(%d)", __func__, alarm_id);
+
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ lockd_launch_app_lockscreen(lockd);
+
+ if(alarm_id != -1) {
+ if(alarm_id != lockd->alarm_id) {
+ LOCKD_ERR("alarm ids are different callback->id(%d), lockd->alarm_id(%d)", alarm_id, lockd->alarm_id);
+ /* delete all registering alarm*/
+ _lockd_unset_alarms();
+ lockd->alarm_id = -1;
+ } else {
+ ret_val = alarmmgr_remove_alarm(alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_remove_alarm() failed");
+ /* delete all registering alarm*/
+ _lockd_unset_alarms();
+ }
+ lockd->alarm_id = -1;
+ }
+ }
+}
+
+static Eina_Bool _lockd_set_alarm(int sec, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return EINA_FALSE;
+ }
+
+ time_t current_time;
+ struct tm current_tm;
+ alarm_entry_t *alarm_info;
+ alarm_id_t alarm_id;
+ alarm_date_t alarm_time;
+ int ret_val = ALARMMGR_RESULT_SUCCESS;
+
+ /* delete before registering alarm ids */
+ if(lockd->alarm_id != -1){
+ LOCKD_ERR("ad->alarm_id(%d) deleted", lockd->alarm_id);
+ ret_val = alarmmgr_remove_alarm(lockd->alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_remove_alarm(%d) failed", lockd->alarm_id);
+ _lockd_unset_alarms();
+ }
+ lockd->alarm_id = -1;
+ }
+
+ /* set alarm after sec */
+ time(&current_time);
+
+ localtime_r(&current_time, &current_tm);
+
+ alarm_info = alarmmgr_create_alarm();
+ if(alarm_info == NULL) {
+ LOCKD_ERR("alarmmgr_create_alarm() is failed\n");
+ return EINA_FALSE;
+ }
+
+ alarm_time.year = 0;
+ alarm_time.month = 0;
+ alarm_time.day = 0;
+ alarm_time.hour = current_tm.tm_hour;
+ alarm_time.min = current_tm.tm_min;
+ alarm_time.sec = current_tm.tm_sec + sec;
+
+ alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+ alarmmgr_set_time(alarm_info, alarm_time);
+ alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
+
+ ret_val = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_add_alarm_with_localtime() failed");
+ alarmmgr_free_alarm(alarm_info) ;
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("alarm id(%d) is set", alarm_id);
+ lockd->alarm_id = alarm_id;
+ alarmmgr_free_alarm(alarm_info) ;
+
+ return EINA_TRUE;
+}
+
+
+#ifndef FEATURE_LITE
+static Eina_Bool _lockd_play_smart_alert_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_REACTIVE_ALERT);
+ //feedback_deinitialize();
+ //lockd_stop_sensor(lockd);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void _lockd_context_update_cb(int error, context_item_e context, char* context_data, void* user_data, int req_id)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ struct lockd_data *lockd = (struct lockd_data *)user_data;
+
+ if (error == CONTEXT_ERROR_NONE && context == CONTEXT_ITEM_MOVEMENT) {
+ int action = -1;
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+
+ context_context_data_get_int(context_data, CONTEXT_MOTION_ACTION, &action);
+
+ switch (action) {
+ case CONTEXT_MOVEMENT_ACTION:
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ LOCKD_WARN("[ sensor ] SMART ALERT calls = %d messages = %d", calls, messages);
+ ecore_timer_add(SMART_ALERT_INTERVAL, _lockd_play_smart_alert_cb, user_data);
+ }
+ break;
+ case CONTEXT_MOVEMENT_NONE:
+ break;
+ default:
+ break;
+ }
+ context_unset_changed_callback(CONTEXT_ITEM_MOVEMENT);
+ free(context_data);
+ }
+}
+
+static Eina_Bool _lockd_smart_alert_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int val = -1;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if ((val == VCONFKEY_PM_STATE_LCDOFF) || (val == VCONFKEY_PM_STATE_SLEEP)) {
+ LOCKD_DBG("LCD OFF ==> smart alert start");
+
+ int ret = 0;
+ int is_motion = 0;
+ int is_pickup = 0;
+
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &is_motion);
+ LOCKD_DBG("[ sensor ] ret = %d is_motion = %d", ret, is_motion);
+ if(ret == 0 && is_motion == 1) {
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_USE_PICK_UP, &is_pickup);
+ LOCKD_DBG("[ sensor ] ret = %d is_pickup = %d", ret, is_pickup);
+ if(ret == 0 && is_pickup == 1) {
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+ int req_id, r;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ r = context_set_changed_callback(CONTEXT_ITEM_MOVEMENT, NULL, _lockd_context_update_cb, lockd, &req_id);
+ if (r != CONTEXT_ERROR_NONE) {
+ LOCKD_ERR("[ sensor ] context_set_changed_callback fail");
+ }
+ LOCKD_WARN("[ sensor ] context_set_changed_callback, r=[%d]", r);
+ }
+ }
+ }
+ } else {
+ LOCKD_DBG("Not LCD OFF ==> cancel smart alert");
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+#endif
+
+
+
+static Eina_Bool _lockd_sensor_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int val = -1;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if ((val == VCONFKEY_PM_STATE_LCDOFF) || (val == VCONFKEY_PM_STATE_SLEEP)) {
+ LOCKD_DBG("LCD OFF ==> sensor start");
+
+ int ret = 0;
+ int calls = 0;
+ int messages = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_MISSED_CALL, &calls);
+ if(ret != 0)
+ calls = 0;
+
+ ret = vconf_get_int(VCONFKEY_STARTER_UNREAD_MESSAGE, &messages);
+ if(ret != 0)
+ messages = 0;
+
+ if(calls > 0 || messages > 0) {
+ if(lockd_start_sensor(data) == EINA_FALSE) {
+ LOCKD_ERR("smart_alert sensor start is failed");
+ }
+ } else {
+ LOCKD_ERR("[ sensor ] sensor is not started calls = %d messages = %d", calls, messages);
+ }
+ } else {
+ LOCKD_DBG("Not LCD OFF ==> cancel sensor start");
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _lockd_alarm_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ _lockd_unset_alarms();
+ lockd->alarm_id = -1;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _lockd_launch_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ _lockd_lauch_lockscreen(-1, lockd);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _lockd_notify_pm_state_cb(keynode_t * node, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ return;
+ }
+
+ LOCKD_DBG("[ == %s == ] pm_state(%d)", __func__, val);
+
+ if (val == VCONFKEY_PM_STATE_NORMAL) {
+ LOCKD_DBG("LCD ON");
+ /* delete all alarm registering */
+ LOCKD_DBG("%d", lockd->alarm_id);
+
+ _lockd_unset_alarms();
+ lockd->alarm_id = -1;
+
+ if(lockd->lock_type == LOCK_TYPE_NONE) {
+ LOCKD_DBG("Lockscreen type is none, unlock");
+ }
+#ifndef FEATURE_LITE
+ context_unset_changed_callback(CONTEXT_ITEM_MOVEMENT);
+ } else if (val == VCONFKEY_PM_STATE_LCDOFF) {
+ ecore_idler_add(_lockd_smart_alert_idelr_cb, lockd);
+#endif
+ }
+}
+
+static int _show_lock_bg(void)
+{
+ bundle *b;
+ int r = 0;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (menu_daemon_get_volume_pid() <0) {
+ LOCKD_DBG("volume is not running");
+ return -1;
+ }
+
+ b = bundle_create();
+
+ bundle_add(b, SHOW_LOCK, ISTRUE);
+ r = aul_launch_app(VOLUME_PKG_NAME, b);
+ if(b) {
+ bundle_free(b);
+ }
+
+ return r;
+}
+
+static void _lockd_notify_pm_lcdoff_cb(keynode_t * node, void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+ int lcdoff_source = vconf_keynode_get_int(node);
+ int accessbility_lock_time = 0;
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (lcdoff_source < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY, error (%d)", lcdoff_source);
+ return;
+ }
+
+ LOCKD_DBG("[ %s ] LCD OFF by lcd off source(%d)", __func__, lcdoff_source);
+
+ idle_lock_state = lockd_get_lock_state();
+
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY) {
+ LOCKD_DBG("lcd off by powerkey");
+#if (!_FEATURE_LCD_OFF_DBUS) // move to dbus signal handler.
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == LOCK_TYPE_SECURITY || lockd->lock_type == LOCK_TYPE_NORMAL) {
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ }
+ }
+ lockd_launch_app_lockscreen(lockd);
+#endif
+ } else if (lcdoff_source == 3) {
+ LOCKD_DBG("lcd off by proximity sensor..");
+ return;
+ } else {
+ LOCKD_DBG("lcd off by timeout");
+
+ if(idle_lock_state == VCONFKEY_IDLE_LOCK) {
+ LOCKD_DBG("VCONFKEY is set(not need to set alarm)");
+ return;
+ }
+
+ if(lockd->alarm_id != -1) {
+ LOCKD_ERR("Alarm is set yet (alarm_id = %d) : do nothing", lockd->alarm_id);
+ return;
+ }
+
+ if(vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_LOCK_TIME_INT, &accessbility_lock_time) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ accessbility_lock_time = 0;
+ }
+
+ if(accessbility_lock_time == 0) {
+ LOCKD_ERR("accessbility_lock_time is 0");
+ _lockd_lauch_lockscreen(-1, lockd);
+ return;
+ } else {
+ if(lockd->is_alarm) {
+ LOCKD_DBG("set alarm %d sec", accessbility_lock_time);
+ if(_lockd_set_alarm(accessbility_lock_time, lockd) != EINA_TRUE) {
+ LOCKD_ERR("_lockd_set_alarm() failed");
+ _lockd_lauch_lockscreen(-1, lockd);
+ }
+ }
+ else {
+ LOCKD_ERR("is_alarm is EINA_FALSE");
+ _lockd_lauch_lockscreen(-1, lockd);
+ }
+ }
+ }
+}
+
+static void _lockd_notify_time_changed_cb(keynode_t * node, void *data)
+{
+ int festival_wallpaper = 0;
+ LOCKD_DBG("system time chanded!!");
+
+ if(vconf_get_bool(VCONFKEY_LOCKSCREEN_FESTIVAL_WALLPAPER, &festival_wallpaper) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ festival_wallpaper = 0;
+ }
+ LOCKD_DBG("festival wallpaper : %d", festival_wallpaper);
+ if(festival_wallpaper){
+ bundle *b;
+ b = bundle_create();
+ if(b == NULL){
+ LOCKD_ERR("bundle create failed.\n");
+ return;
+ }
+ bundle_add(b, "popup_type", "festival");
+ bundle_add(b, "festival_type", "festival_create");
+ aul_launch_app(WALLPAPER_UI_SERVICE_PKG_NAME, b);
+ bundle_free(b);
+ }
+}
+
+static void _lockd_notify_factory_mode_cb(keynode_t * node, void *data)
+{
+ int factory_mode = -1;
+ LOCKD_DBG("Factory mode Notification!!");
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, &factory_mode);
+ if (factory_mode == VCONFKEY_TELEPHONY_SIM_FACTORYMODE_ON) {
+ LOCKD_DBG("Factory mode ON, lock screen can't be launched..!!");
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+}
+
+static void
+_lockd_notify_lock_state_cb(keynode_t * node, void *data)
+{
+ LOCKD_DBG("lock state changed!!");
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+ int pm_state = -1;
+ int is_sync = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ val = lockd_get_lock_state();
+
+ if (val == VCONFKEY_IDLE_UNLOCK) {
+ LOCKD_DBG("unlocked..!!");
+
+ /*Phone lock can't be terminated..!! */
+ if (phone_lock_pid != 0) {
+ LOCKD_ERR("Security lock[pid = %d] is unlocked why???", phone_lock_pid);
+ _lockd_set_lock_state(VCONFKEY_IDLE_LOCK);
+ return;
+ }
+
+ if (vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_FALSE) < 0) {
+ LOCKD_ERR("Cannot set VCONFKEY");
+ }
+
+ if (lockd->lock_type == LOCK_TYPE_AUTO_LOCK) {
+ if (!lockd_get_auto_lock_security()) {
+ LOCKD_ERR("Auto lock security is set... why???");
+ }
+ lockd->lock_app_pid = auto_lock_pid;
+ auto_lock_pid = 0;
+ }
+
+ if (lockd->lock_app_pid > 0) {
+
+ if (vconf_get_int(VCONFKEY_PM_STATE, &pm_state) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ pm_state = VCONFKEY_PM_STATE_NORMAL;
+ }
+ LOCKD_DBG("pm_state : [%d]..", pm_state);
+ if (pm_state == VCONFKEY_PM_STATE_NORMAL) {
+ LOCKD_DBG("terminate lock app..!!");
+ lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
+ if (lockd->lock_type != LOCK_TYPE_NORMAL) {
+ _lockd_play_sound(TRUE);
+ }
+ lockd->lock_app_pid = 0;
+ } else {
+ vconf_get_int(VCONFKEY_POPSYNC_ACTIVATED_KEY, &is_sync);
+ if (is_sync == 1) {
+ LOCKD_ERR("POP sync is connected");
+ LOCKD_DBG("terminate lock app..!!");
+ lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
+ if (lockd->lock_type != LOCK_TYPE_NORMAL) {
+ _lockd_play_sound(TRUE);
+ }
+ lockd->lock_app_pid = 0;
+ } else if (lock_state_available) {
+ LOCKD_ERR("can't unlock because of lcd off");
+ _lockd_set_lock_state(VCONFKEY_IDLE_LOCK);
+ } else {
+ LOCKD_ERR("Unlock by exit");
+ //we should not re-set lock state because of exit cmd
+ lockd_process_mgr_terminate_lock_app(lockd->lock_app_pid, 1);
+ lock_state_available = TRUE;
+ }
+ }
+ }
+ }else if (val == VCONFKEY_IDLE_LOCK) {
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ }
+}
+
+static Eina_Bool lockd_set_lock_state_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ _lockd_set_lock_state(VCONFKEY_IDLE_LOCK);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_lockd_notify_phone_lock_verification_cb(keynode_t * node, void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ int val = -1;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ if (vconf_get_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, &val) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ return;
+ }
+
+ if (val == TRUE) {
+ /* password verified */
+ /* lockd_unlock_lockscreen(lockd); */
+ lockd_window_mgr_finish_lock(lockd->lockw);
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+}
+
+static int lockd_app_dead_cb(int pid, void *data)
+{
+ LOCKD_DBG("app dead cb call! (pid : %d)", pid);
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (pid == lockd->lock_app_pid && lockd->lock_type == LOCK_TYPE_OTHER) {
+ LOCKD_DBG("lock app(pid:%d) is destroyed.", pid);
+ lockd_unlock_lockscreen(lockd);
+ }
+#ifdef FEATURE_LITE
+ /* set unlock vconf temporarily in Kiran */
+ else if(pid == lockd->lock_app_pid){
+ int idle_lock_state = 0;
+ LOCKD_DBG("lock app(pid:%d) is destroyed.", pid);
+ idle_lock_state = lockd_get_lock_state();
+ if(idle_lock_state != VCONFKEY_IDLE_UNLOCK){
+ LOCKD_ERR("lock app terminated unexpectedly, and lock state is not unlock");
+ lockd_unlock_lockscreen(lockd);
+ }
+
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ }
+#endif
+ menu_daemon_check_dead_signal(pid);
+
+ return 0;
+}
+
+static Eina_Bool lockd_app_create_cb(void *data, int type, void *event)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ if (lockd_window_set_window_effect(lockd->lockw, lockd->lock_app_pid,
+ event) == EINA_TRUE) {
+ //FIXME sometimes show cb is not called.
+ if(lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
+ event) == EINA_FALSE) {
+ LOCKD_ERR("window is not matched..!!");
+ }
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool lockd_app_show_cb(void *data, int type, void *event)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ return EINA_TRUE;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ if (lockd_window_set_window_property(lockd->lockw, lockd->lock_app_pid,
+ event)) {
+ lockd_window_set_scroll_property(lockd->lockw, lockd->lock_type);
+ if (lockd->lock_type > LOCK_TYPE_SECURITY) {
+ ecore_idler_add(lockd_set_lock_state_cb, NULL);
+ }
+ }
+ return EINA_FALSE;
+}
+
+static Eina_Bool _lockd_play_idelr_cb(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ _lockd_play_sound(FALSE);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static int lockd_launch_app_lockscreen(struct lockd_data *lockd)
+{
+ LOCKD_DBG("launch app lock screen");
+
+ int call_state = -1, factory_mode = -1, test_mode = -1;
+ int r = 0;
+ int lcdoff_source = 0;
+ int focus_win_pid = 0;
+ int pw_type = 0;
+ int automatic_unlock = 0;
+
+ //PM LOCK - don't go to sleep
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, &factory_mode);
+ if (factory_mode == VCONFKEY_TELEPHONY_SIM_FACTORYMODE_ON) {
+ LOCKD_DBG("Factory mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ if (test_mode == VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE) {
+ LOCKD_DBG("Test mode ON, lock screen can't be launched..!!");
+ goto launch_out;
+ }
+
+ if (lockd->is_first_boot == TRUE) {
+ if(vconf_get_int(VCONFKEY_PWLOCK_STATE, &pw_type) < 0)
+ {
+ LOCKD_ERR("vconf_get_int() failed");
+ pw_type = VCONFKEY_PWLOCK_RUNNING_UNLOCK;
+ }
+ if(pw_type == VCONFKEY_PWLOCK_BOOTING_LOCK || pw_type == VCONFKEY_PWLOCK_RUNNING_LOCK) {
+ LOCKD_ERR("First boot & pwlock state[%d], lock screen can't be launched..!!", pw_type);
+ goto launch_out;
+ }
+ }
+
+ if (lockd->lock_type == LOCK_TYPE_NONE) {
+ LOCKD_DBG("Lock screen type is None..!!");
+ goto launch_out;
+ }
+
+ /* Get Call state */
+ if(vconf_get_int(VCONFKEY_PM_LCDOFF_SOURCE, &lcdoff_source) < 0)
+ {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ focus_win_pid = lockd_window_mgr_get_focus_win_pid();
+ vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY) {
+ if ((call_state != VCONFKEY_CALL_OFF) && (lockd->lock_type != LOCK_TYPE_SECURITY)) {
+ if (focus_win_pid >0) {
+ if (lockd_process_mgr_check_call(focus_win_pid) == TRUE) {
+ LOCKD_DBG("Call is FG => not allow to launch lock screen!!");
+ goto launch_out;
+ } else {
+ LOCKD_DBG("Call is BG => allow to launch lock screen!!");
+ }
+ }
+ }
+ } else {
+ if ((call_state != VCONFKEY_CALL_OFF) && (lockd->back_to_app == FALSE)) {
+ LOCKD_DBG("Current call state(%d) does not allow to launch lock screen.",
+ call_state);
+ goto launch_out;
+ }
+ }
+
+ if ((lockd->lock_type == LOCK_TYPE_NORMAL) || (lockd->lock_type == LOCK_TYPE_OTHER)) {
+ if (lockd_process_mgr_check_lock(lockd->lock_app_pid) == TRUE) {
+ LOCKD_DBG("Lock Screen App is already running.");
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ }
+
+#if _FEATURE_SCOVER
+ if (lockd->hall_status == HALL_COVERED_STATUS) {
+ vconf_get_bool(VCONFKEY_SETAPPL_ACCESSORY_AUTOMATIC_UNLOCK, &automatic_unlock);
+ LOCKD_DBG("hall status : %d, lockd->hall_status : %d, automatic_unlock : %d", HALL_COVERED_STATUS, lockd->hall_status, automatic_unlock);
+ if (automatic_unlock == 1) {
+ LOCKD_DBG("Don't lauch lockscreen because of non security with scover");
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ }
+ }
+#endif
+ }
+
+ switch (lockd->lock_type) {
+
+ case LOCK_TYPE_NORMAL:
+ _lockd_set_lock_state(VCONFKEY_IDLE_LAUNCHING_LOCK);
+
+ if (lockd->lock_app_pid > 0) {
+ LOCKD_ERR("Lock Screen App is remained, pid[%d].", lockd->lock_app_pid);
+ lockd_process_mgr_kill_lock_app(lockd->lock_app_pid);
+ lockd->lock_app_pid = 0;
+ }
+
+ lockd->lock_app_pid =
+ lockd_process_mgr_start_normal_lock(lockd, lockd_app_dead_cb);
+ if (lockd->lock_app_pid < 0) {
+ goto launch_out;
+ }
+ break;
+
+ case LOCK_TYPE_SECURITY:
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, FALSE);
+
+ if (phone_lock_pid > 0) {
+ LOCKD_DBG("phone lock App is already running.");
+ if ((lockd->request_recovery == FALSE) && (lockd->back_to_app == FALSE)) {
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ }
+ }
+ _lockd_set_lock_state(VCONFKEY_IDLE_LAUNCHING_LOCK);
+
+ /* TO DO : Recovery should be checked by EAS interface later */
+ /* After getting EAS interface, we should remove lockd->request_recovery */
+ if (lockd->request_recovery == TRUE) {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_recovery_lock();
+ lockd->request_recovery = FALSE;
+ } else if (lockd->back_to_app == TRUE) {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_back_to_app_lock();
+ lockd->back_to_app = FALSE;
+ } else {
+ lockd->phone_lock_app_pid =
+ lockd_process_mgr_start_phone_lock();
+ }
+ phone_lock_pid = lockd->phone_lock_app_pid;
+ LOCKD_DBG("%s, %d, phone_lock_pid = %d", __func__, __LINE__,
+ phone_lock_pid);
+ lockd_window_set_phonelock_pid(lockd->lockw, phone_lock_pid);
+ if (phone_lock_pid > 0) {
+ if(starter_dbus_set_oomadj(phone_lock_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ return 1;
+ break;
+
+ case LOCK_TYPE_AUTO_LOCK:
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, FALSE);
+
+ if (auto_lock_pid > 0) {
+ LOCKD_DBG("Auto lock App is already running.");
+ if (lockd->back_to_app == FALSE) {
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 1;
+ }
+ }
+ _lockd_set_lock_state(VCONFKEY_IDLE_LAUNCHING_LOCK);
+
+ if (lockd->back_to_app == TRUE) {
+ auto_lock_pid = lockd_process_mgr_start_back_to_app_lock();
+ lockd->back_to_app = FALSE;
+ } else {
+ auto_lock_pid = lockd_process_mgr_start_phone_lock();
+ }
+ LOCKD_DBG("%s, %d, Auto_lock_pid = %d", __func__, __LINE__, auto_lock_pid);
+
+ if (auto_lock_pid > 0) {
+ if(starter_dbus_set_oomadj(auto_lock_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ return 1;
+ break;
+
+ default:
+ if (lockd->lock_app_pid > 0) {
+ LOCKD_ERR("Lock Screen App is remained, pid[%d].", lockd->lock_app_pid);
+ lockd_process_mgr_kill_lock_app(lockd->lock_app_pid);
+ lockd->lock_app_pid = 0;
+ }
+ if(lcdoff_source == VCONFKEY_PM_LCDOFF_BY_POWERKEY)
+ ecore_idler_add(_lockd_play_idelr_cb, NULL);
+
+ lockd->lock_app_pid =
+ lockd_process_mgr_start_lock(lockd, lockd_app_dead_cb,
+ lockd->lock_type);
+ if (lockd->lock_app_pid < 0) {
+ goto launch_out;
+ }
+ /* reset window mgr before start win mgr */
+ lockd_window_mgr_finish_lock(lockd->lockw);
+ lockd_window_mgr_ready_lock(lockd, lockd->lockw, lockd_app_create_cb,
+ lockd_app_show_cb);
+ break;
+ }
+
+
+ if (lockd->lock_app_pid > 0) {
+ if(starter_dbus_set_oomadj(lockd->lock_app_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ LOCKD_ERR("failed to send oom dbus signal");
+ }
+ if(lockd_process_mgr_check_home(focus_win_pid)) {
+ if(vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ }
+ }
+ }
+ return 1;
+
+
+ launch_out:
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
+ return 0;
+}
+
+static void lockd_unlock_lockscreen(struct lockd_data *lockd)
+{
+ LOCKD_DBG("unlock lock screen");
+ lockd->lock_app_pid = 0;
+
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ lockd_window_mgr_finish_lock(lockd->lockw);
+}
+
+inline static void lockd_set_sock_option(int fd, int cli)
+{
+ int size;
+ int ret;
+ struct timeval tv = { 1, 200 * 1000 }; /* 1.2 sec */
+
+ size = PHLOCK_SOCK_MAXBUFF;
+ ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+ if(ret != 0)
+ return;
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+ if(ret != 0)
+ return;
+ if (cli) {
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ if(ret != 0)
+ return;
+ }
+}
+
+static int lockd_create_sock(void)
+{
+ struct sockaddr_un saddr;
+ int fd;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0); /* support above version 2.6.27 */
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ LOCKD_ERR
+ ("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ LOCKD_ERR("socket error");
+ return -1;
+ }
+ }
+
+ bzero(&saddr, sizeof(saddr));
+ saddr.sun_family = AF_UNIX;
+
+ strncpy(saddr.sun_path, PHLOCK_SOCK_PREFIX, sizeof(saddr.sun_path)-1);
+ saddr.sun_path[strlen(PHLOCK_SOCK_PREFIX)] = 0;
+
+ unlink(saddr.sun_path);
+
+ if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+ LOCKD_ERR("bind error");
+ close(fd);
+ return -1;
+ }
+
+ if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ /* Flawfinder: ignore */
+ LOCKD_ERR("failed to change the socket permission");
+ close(fd);
+ return -1;
+ }
+
+ lockd_set_sock_option(fd, 0);
+
+ if (listen(fd, 10) == -1) {
+ LOCKD_ERR("listen error");
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+static gboolean lockd_glib_check(GSource * src)
+{
+ GSList *fd_list;
+ GPollFD *tmp;
+
+ fd_list = src->poll_fds;
+ do {
+ tmp = (GPollFD *) fd_list->data;
+ if ((tmp->revents & (POLLIN | POLLPRI)))
+ return TRUE;
+ fd_list = fd_list->next;
+ } while (fd_list);
+
+ return FALSE;
+}
+
+static char *lockd_read_cmdline_from_proc(int pid)
+{
+ int memsize = 32;
+ char path[32];
+ char *cmdline = NULL, *tempptr = NULL;
+ FILE *fp = NULL;
+
+ snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
+
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ LOCKD_ERR("Cannot open cmdline on pid[%d]", pid);
+ return NULL;
+ }
+
+ cmdline = malloc(32);
+ if (cmdline == NULL) {
+ LOCKD_ERR("%s", "Out of memory");
+ fclose(fp);
+ return NULL;
+ }
+
+ bzero(cmdline, memsize);
+ if (fgets(cmdline, 32, fp) == NULL) {
+ LOCKD_ERR("%s", "Cannot read cmdline");
+ free(cmdline);
+ fclose(fp);
+ return NULL;
+ }
+
+ while (cmdline[memsize - 2] != 0) {
+ cmdline[memsize - 1] = (char)fgetc(fp);
+ tempptr = realloc(cmdline, memsize + 32);
+ if (tempptr == NULL) {
+ fclose(fp);
+ LOCKD_ERR("%s", "Out of memory");
+ return NULL;
+ }
+ cmdline = tempptr;
+ bzero(cmdline + memsize, 32);
+ fgets(cmdline + memsize, 32, fp);
+ memsize += 32;
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+ return cmdline;
+}
+
+static int lockd_sock_handler(void *data)
+{
+ int cl;
+ int len;
+ int sun_size;
+ int clifd = -1;
+ char cmd[PHLOCK_SOCK_MAXBUFF];
+ char *cmdline = NULL;
+ int fd = -1;
+ int recovery_state = -1;
+ GPollFD *gpollfd;
+
+ struct ucred cr;
+ struct sockaddr_un lockd_addr;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if ((lockd == NULL) || (lockd->gpollfd == NULL)) {
+ LOCKD_ERR("lockd->gpollfd is NULL");
+ return -1;
+ }
+ gpollfd = (GPollFD *)lockd->gpollfd;
+ fd = gpollfd->fd;
+
+ cl = sizeof(cr);
+ sun_size = sizeof(struct sockaddr_un);
+
+ if ((clifd =
+ accept(fd, (struct sockaddr *)&lockd_addr,
+ (socklen_t *) & sun_size)) == -1) {
+ if (errno != EINTR)
+ LOCKD_ERR("accept error");
+ return -1;
+ }
+
+ if (getsockopt(clifd, SOL_SOCKET, SO_PEERCRED, &cr, (socklen_t *) & cl)
+ < 0) {
+ LOCKD_ERR("peer information error");
+ close(clifd);
+ return -1;
+ }
+ LOCKD_ERR("Peer's pid=%d, uid=%d, gid=%d\n", cr.pid, cr.uid, cr.gid);
+
+ memset(cmd, 0, PHLOCK_SOCK_MAXBUFF);
+
+ lockd_set_sock_option(clifd, 1);
+
+ /* receive single packet from socket */
+ len = recv(clifd, cmd, PHLOCK_SOCK_MAXBUFF, 0);
+
+ if (len < 0) {
+ LOCKD_ERR("recv error, read number is less than zero");
+ close(clifd);
+ return -1;
+ }
+
+ cmd[PHLOCK_SOCK_MAXBUFF - 1] = '\0';
+
+ LOCKD_ERR("cmd %s", cmd);
+
+ /* Read command line of the PID from proc fs */
+ cmdline = lockd_read_cmdline_from_proc(cr.pid);
+ if (cmdline == NULL) {
+ /* It's weired. no file in proc file system, */
+ LOCKD_ERR("Error on opening /proc/%d/cmdline", cr.pid);
+ close(clifd);
+ return -1;
+ }
+ LOCKD_SECURE_ERR("/proc/%d/cmdline : %s", cr.pid, cmdline);
+
+ if (!strncmp(cmd, PHLOCK_UNLOCK_CMD, strlen(cmd))) {
+ if (!strncmp(cmdline, PHLOCK_APP_CMDLINE, strlen(cmdline))) {
+ if (lockd->lock_type == LOCK_TYPE_SECURITY) {
+ LOCKD_ERR("phone_lock_pid : %d vs cr.pid : %d", phone_lock_pid, cr.pid);
+ if (phone_lock_pid == cr.pid) {
+ LOCKD_SECURE_ERR("pid [%d] %s is verified, unlock..!!\n", cr.pid,
+ cmdline);
+ lockd_process_mgr_terminate_phone_lock(phone_lock_pid);
+ phone_lock_pid = 0;
+ _lockd_play_sound(TRUE);
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, TRUE);
+ }
+ } else if (lockd->lock_type == LOCK_TYPE_AUTO_LOCK) {
+ LOCKD_ERR("auto_lock_pid : %d vs cr.pid : %d", auto_lock_pid, cr.pid);
+ if (auto_lock_pid == cr.pid) {
+ LOCKD_SECURE_ERR("pid [%d] %s is verified, unlock..!!\n", cr.pid,
+ cmdline);
+ lockd_process_mgr_terminate_phone_lock(auto_lock_pid);
+ auto_lock_pid = 0;
+ _lockd_play_sound(TRUE);
+ lockd_window_mgr_finish_lock(lockd->lockw);
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+ }
+ }
+#if 0
+ else if (!strncmp(cmd, LOCK_EXIT_CMD, strlen(cmd))) {
+ LOCKD_ERR("[%s] for exit", LOCK_EXIT_CMD);
+ //we should not re-set lock state because of exit cmd for scover view.
+ lock_state_available = FALSE;
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+#endif
+ } else if (!strncmp(cmd, LOCK_EXIT_CMD, strlen(cmd))) {
+ if ((!strncmp(cmdline, PHLOCK_APP_CMDLINE, strlen(cmdline))) ||
+ (!strncmp(cmdline, VOLUNE_APP_CMDLINE, strlen(cmdline)))) {
+ //we should not re-set lock state because of exit cmd for scover view.
+ LOCKD_ERR("[%s] for exit", LOCK_EXIT_CMD);
+ lock_state_available = FALSE;
+ _lockd_set_lock_state(VCONFKEY_IDLE_UNLOCK);
+ }
+ } else if ((!strncmp(cmd, PHLOCK_UNLOCK_RESET_CMD, strlen(cmd)))
+ && (!strncmp(cmdline, OMA_DRM_AGENT_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ if(phone_lock_pid > 0) {
+ LOCKD_SECURE_ERR("pid [%d] %s is verified, unlock..!!\n", cr.pid,
+ cmdline);
+ lockd_process_mgr_terminate_phone_lock(phone_lock_pid);
+ phone_lock_pid = 0;
+ _lockd_play_sound(TRUE);
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, TRUE);
+ // reset lockscreen type
+ if (vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE) < 0) {
+ LOCKD_ERR("%s set to %d is failed. error \n",
+ VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE);
+ }
+ }
+ } else if (!strncmp(cmd, PHLOCK_LAUNCH_CMD, strlen(cmd))) {
+ if (!strncmp(cmdline, MDM_APP_CMDLINE, strlen(cmdline))) {
+ LOCKD_ERR("%s request %s \n", cmdline, cmd);
+ if (vconf_get_int(VCONFKEY_EAS_RECOVERY_MODE, &recovery_state) < 0) {
+ LOCKD_ERR("Cannot get vconfkey", VCONFKEY_EAS_RECOVERY_MODE);
+ lockd->request_recovery = FALSE;
+ } else if (recovery_state == 1) {
+ LOCKD_ERR("recovery mode : %d \n", recovery_state);
+ lockd->request_recovery = TRUE;
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ }
+ if (lockd->lock_type == LOCK_TYPE_SECURITY) {
+ lockd_launch_app_lockscreen(lockd);
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ } else if (!strncmp(cmd, HOME_RAISE_CMD, strlen(cmd))) {
+ if ((!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline)))
+ || (!strncmp(cmdline, VIDEO_CALL_APP_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ menu_daemon_open_homescreen(NULL);
+ }
+ } else if (!strncmp(cmd, LOCK_SHOW_CMD, strlen(cmd))) {
+ if ((!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline)))
+ || (!strncmp(cmdline, VIDEO_CALL_APP_CMDLINE, strlen(cmdline)))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ lockd->back_to_app = TRUE;
+ }
+ if ((lockd->lock_type == LOCK_TYPE_SECURITY)
+ || ((lockd->lock_type == LOCK_TYPE_AUTO_LOCK) && (lockd_get_auto_lock_security()))){
+ lockd_launch_app_lockscreen(lockd);
+ } else {
+ lockd->back_to_app = FALSE;
+ }
+ } else if (!strncmp(cmd, LOCK_LAUNCH_CMD, strlen(cmd))) {
+ LOCKD_SECURE_ERR("%s request %s \n", cmdline, cmd);
+ if (!strncmp(cmdline, VOICE_CALL_APP_CMDLINE, strlen(cmdline))) {
+ lockd_launch_app_lockscreen(lockd);
+ }
+ }
+
+ if(cmdline != NULL) {
+ free(cmdline);
+ cmdline = NULL;
+ }
+
+ close(clifd);
+ return 0;
+}
+
+static gboolean lockd_glib_handler(gpointer data)
+{
+ if (lockd_sock_handler(data) < 0) {
+ LOCKD_ERR("lockd_sock_handler is failed..!!");
+ }
+ return TRUE;
+}
+
+static gboolean lockd_glib_dispatch(GSource * src, GSourceFunc callback,
+ gpointer data)
+{
+ callback(data);
+ return TRUE;
+}
+
+static gboolean lockd_glib_prepare(GSource * src, gint * timeout)
+{
+ return FALSE;
+}
+
+static GSourceFuncs funcs = {
+ .prepare = lockd_glib_prepare,
+ .check = lockd_glib_check,
+ .dispatch = lockd_glib_dispatch,
+ .finalize = NULL
+};
+
+static int lockd_init_sock(struct lockd_data *lockd)
+{
+ int fd;
+ GPollFD *gpollfd;
+ GSource *src;
+ int ret;
+
+ fd = lockd_create_sock();
+ if (fd < 0) {
+ LOCKD_ERR("lock daemon create sock failed..!!");
+ }
+
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ lockd->gpollfd = gpollfd;
+
+ g_source_add_poll(src, lockd->gpollfd);
+ g_source_set_callback(src, (GSourceFunc) lockd_glib_handler,
+ (gpointer) lockd, NULL);
+ g_source_set_priority(src, G_PRIORITY_LOW);
+
+ ret = g_source_attach(src, NULL);
+ if (ret == 0)
+ return -1;
+
+ g_source_unref(src);
+
+ return 0;
+}
+
+
+
+
+static void _lockd_notify_bt_device_connected_status_cb(keynode_t * node, void *data)
+{
+ int is_connected = 0;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ vconf_get_bool(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL , &is_connected);
+ LOCKD_WARN("BT connect status is changed to [%d]", is_connected);
+
+ if (is_connected) {
+ if (lockd_start_bt_monitor() < 0) {
+ LOCKD_ERR("Fail starter BT monitor");
+ }
+ } else {
+ lockd_stop_bt_monitor();
+ lockd_change_security_auto_lock(is_connected);
+ }
+}
+
+
+static void _lockd_notify_lock_type_cb(keynode_t * node, void *data)
+{
+ int lock_type = -1;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ LOCKD_DBG("lock type is changed..!!");
+
+ lock_type = lockd_get_lock_type();
+
+ if ((lockd->lock_type != LOCK_TYPE_AUTO_LOCK) && (lock_type == LOCK_TYPE_AUTO_LOCK)) {
+
+ int is_connected = 0;
+
+ LOCKD_WARN("Auto Lock is set ON..!!");
+
+ vconf_get_bool(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL , &is_connected);
+ LOCKD_WARN("BT connect status is [%d]", is_connected);
+
+ if (is_connected) {
+ if (lockd_start_bt_monitor() < 0) {
+ LOCKD_ERR("Fail starter BT monitor");
+ }
+ } else {
+ lockd_change_security_auto_lock(is_connected);
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL, _lockd_notify_bt_device_connected_status_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+ } else if ((lockd->lock_type == LOCK_TYPE_AUTO_LOCK) && (lock_type != LOCK_TYPE_AUTO_LOCK)) {
+
+ LOCKD_WARN("Auto Lock is set OFF..!!");
+
+ lockd_stop_bt_monitor();
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL, _lockd_notify_bt_device_connected_status_cb) != 0) {
+ LOCKD_ERR("Fail to unregister");
+ }
+ }
+ lockd->lock_type = lock_type;
+}
+
+static void lockd_init_vconf(struct lockd_data *lockd)
+{
+ int val = -1;
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_PM_STATE, _lockd_notify_pm_state_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_PM_LCDOFF_SOURCE, _lockd_notify_pm_lcdoff_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_TELEPHONY_SIM_FACTORY_MODE, _lockd_notify_factory_mode_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+#if 0
+ if (vconf_notify_key_changed
+ (VCONFKEY_SYSTEM_TIME_CHANGED, _lockd_notify_time_changed_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+#endif
+ if (vconf_notify_key_changed
+ (VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, _lockd_notify_lock_type_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION,
+ _lockd_notify_phone_lock_verification_cb, lockd) != 0) {
+ if (vconf_get_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, &val) < 0) {
+ LOCKD_ERR
+ ("Cannot get VCONFKEY");
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, 0);
+ if (vconf_notify_key_changed
+ (VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION,
+ _lockd_notify_phone_lock_verification_cb,
+ lockd) != 0) {
+ LOCKD_ERR
+ ("Fail vconf_notify_key_changed " );
+ }
+ } else {
+ LOCKD_ERR
+ ("Fail vconf_notify_key_changed " );
+ }
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_IDLE_LOCK_STATE,
+ _lockd_notify_lock_state_cb,
+ lockd) != 0) {
+ LOCKD_ERR
+ ("[Error] vconf notify : lock state");
+ }
+}
+
+
+static Eina_Bool lockd_init_alarm(void *data)
+{
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int ret_val = 0;
+ /* alarm id initialize */
+ lockd->alarm_id = -1;
+
+ g_type_init();
+ ret_val = alarmmgr_init(PACKAGE_NAME);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_init() failed(%d)", ret_val);
+ return EINA_FALSE;
+ }
+ ret_val = alarmmgr_set_cb((alarm_cb_t)_lockd_lauch_lockscreen, lockd);
+ if(ret_val != ALARMMGR_RESULT_SUCCESS) {
+ LOCKD_ERR("alarmmgr_init() failed");
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("alarm init success");
+ return EINA_TRUE;
+}
+
+static int lockd_init_hall_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ LOCKD_ERR("e_dbus_bus_get error");
+ return -1;
+ }
+ lockd->hall_conn = conn;
+
+#if 0
+ int r;
+ r = e_dbus_request_name(conn, BUS_NAME, 0, NULL, NULL);
+ if (!r) {
+ LOCKD_ERR("e_dbus_request_name erro");
+ return -1;
+ }
+#endif
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DEVICED_PATH_HALL,
+ DEVICED_INTERFACE_HALL, SIGNAL_HALL_STATE,
+ _lockd_on_changed_receive, lockd);
+ if (handler == NULL) {
+ LOCKD_ERR("e_dbus_signal_handler_add error");
+ return -1;
+ }
+ lockd->hall_handler = handler;
+ /* S-Cover Lock : Signal <!-- END --> */
+}
+
+
+
+static Eina_Bool _lockd_launch_lockscreen_by_pwr_key(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ LOCKD_DBG("lcd off by powerkey");
+
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == LOCK_TYPE_SECURITY || lockd->lock_type == LOCK_TYPE_NORMAL) {
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ }
+ }
+ lockd_launch_app_lockscreen(lockd);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static void _lockd_receive_lcd_off(void *data, DBusMessage *msg)
+{
+ DBusError err;
+ int r;
+ int idle_lock_state = VCONFKEY_IDLE_UNLOCK;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+
+ LOCKD_DBG("lcd off signal is received");
+
+ r = dbus_message_is_signal(msg, DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME);
+ if (!r) {
+ LOCKD_ERR("dbus_message_is_signal error");
+ return;
+ }
+
+ LOCKD_DBG("%s - %s", DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME);
+
+#if 0 //need to check if lockscreen is displayed before lcd off.
+ idle_lock_state = lockd_get_lock_state();
+
+ LOCKD_DBG("lcd off by powerkey");
+
+ if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) {
+ if (lockd->lock_type == LOCK_TYPE_SECURITY || lockd->lock_type == LOCK_TYPE_NORMAL) {
+ _lockd_request_PmQos(REQUEST_PMQOS_DURATION);
+ display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ }
+ }
+ lockd_launch_app_lockscreen(lockd);
+#else
+ ecore_idler_add(_lockd_launch_lockscreen_by_pwr_key, lockd);
+#endif
+}
+
+
+static int lockd_init_lcd_off_signal(void *data)
+{
+ E_DBus_Connection *conn;
+ E_DBus_Signal_Handler *handler;
+
+ struct lockd_data *lockd = (struct lockd_data *)data;
+ if(!lockd) {
+ LOCKD_ERR("parameter is NULL");
+ return EINA_FALSE;
+ }
+
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ LOCKD_ERR("e_dbus_bus_get error");
+ return -1;
+ }
+ lockd->display_conn = conn;
+
+ handler = e_dbus_signal_handler_add(conn, NULL, DEVICED_PATH_LCD_OFF,
+ DEVICED_INTERFACE_LCD_OFF, METHOD_LCD_OFF_NAME,
+ _lockd_receive_lcd_off, lockd);
+ if (handler == NULL) {
+ LOCKD_ERR("e_dbus_signal_handler_add error");
+ return -1;
+ }
+ lockd->display_handler = handler;
+}
+
+void lockd_check_vconf_festival_wallpaper(void *data){
+ struct lockd_data *lockd = (struct lockd_data *)data;
+
+ if (lockd == NULL) {
+ LOCKD_ERR("lockd is NULL");
+ return;
+ }
+ int festival_wallpaper = 0;
+
+ if(vconf_get_bool(VCONFKEY_LOCKSCREEN_FESTIVAL_WALLPAPER, &festival_wallpaper) < 0) {
+ LOCKD_ERR("Cannot get VCONFKEY");
+ festival_wallpaper = 0;
+ }
+ LOCKD_DBG("festival wallpaper : %d", festival_wallpaper);
+ if(festival_wallpaper){
+ bundle *b;
+ b = bundle_create();
+ if(b == NULL){
+ LOCKD_ERR("bundle create failed.\n");
+ return;
+ }
+ bundle_add(b, "popup_type", "festival");
+ bundle_add(b, "festival_type", "festival_create");
+ aul_launch_app(WALLPAPER_UI_SERVICE_PKG_NAME, b);
+ bundle_free(b);
+ }
+
+}
+
+static void lockd_start_lock_daemon(void *data)
+{
+ struct lockd_data *lockd = NULL;
+ int r = 0;
+
+ lockd = (struct lockd_data *)data;
+
+ if (!lockd) {
+ return;
+ }
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ /*init and check hall status*/
+ e_dbus_init();
+
+
+#if _FEATURE_SCOVER
+ lockd->hall_status = -1;
+
+ lockd->hall_status = lockd_get_hall_status();
+ LOCKD_DBG(" >>> hall_status : %d", lockd->hall_status);
+
+ if (lockd_init_hall_signal(lockd) < 0) {
+ LOCKD_ERR("Hall signal can't be used.");
+ lockd->hall_status = -1;
+ }
+#endif
+
+#if _FEATURE_LCD_OFF_DBUS
+ if (lockd_init_lcd_off_signal(lockd) < 0) {
+ LOCKD_ERR("LCD off signal can't be used.");
+ lockd->hall_status = -1;
+ }
+#endif
+
+ /*init sensor for smart alert*/
+ //lockd->is_sensor = lockd_init_sensor(lockd);
+
+ /* register vconf notification */
+ lockd_init_vconf(lockd);
+ lockd_process_mgr_init();
+ /* init alarm manager */
+ lockd_check_vconf_festival_wallpaper(lockd);
+
+ lockd->is_alarm = lockd_init_alarm(lockd);
+
+// lockd_set_festival_wallpaper_alarm(lockd);
+
+ /* Initialize socket */
+ r = lockd_init_sock(lockd);
+ if (r < 0) {
+ LOCKD_ERR("lockd init socket failed: %d", r);
+ }
+
+ /* Create internal 1x1 window */
+ lockd->lockw = lockd_window_init();
+
+ aul_listen_app_dead_signal(lockd_app_dead_cb, data);
+
+#if 0 // for booting time
+ if(feedback_initialize() != FEEDBACK_ERROR_NONE) {
+ LOCKD_ERR("[CAUTION][ERROR] feedback_initialize() is failed..!!");
+ }
+#endif
+}
+
+int start_lock_daemon(int launch_lock, int is_first_boot)
+{
+ struct lockd_data *lockd = NULL;
+ int recovery_state = -1;
+ int first_boot = 0;
+ int ret = 0;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockd = (struct lockd_data *)malloc(sizeof(struct lockd_data));
+ memset(lockd, 0x0, sizeof(struct lockd_data));
+ lockd_start_lock_daemon(lockd);
+
+ lockd->lock_type = lockd_get_lock_type();
+ lockd->back_to_app = FALSE;
+
+ if (lockd->lock_type == LOCK_TYPE_NONE)
+ return -1;
+ if (lockd->lock_type == LOCK_TYPE_SECURITY) {
+ if (vconf_get_int(VCONFKEY_EAS_RECOVERY_MODE, &recovery_state) < 0) {
+ LOCKD_ERR("Cannot get vconfkey" );
+ lockd->request_recovery = FALSE;
+ } else if (recovery_state == 1) {
+ LOCKD_DBG("recovery mode : %d \n", recovery_state);
+ lockd->request_recovery = TRUE;
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ } else {
+ lockd->request_recovery = FALSE;
+ }
+ if (lockd->lock_type == LOCK_TYPE_AUTO_LOCK) {
+ int is_connected = 0;
+
+ vconf_get_bool(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL , &is_connected);
+ LOCKD_WARN("BT connect status is [%d]", is_connected);
+
+ if (is_connected) {
+ if (lockd_start_bt_monitor() < 0) {
+ LOCKD_ERR("Fail starter BT monitor");
+ }
+ } else {
+ lockd_change_security_auto_lock(is_connected);
+ }
+
+ if (vconf_notify_key_changed
+ (VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_STATUS_BOOL, _lockd_notify_bt_device_connected_status_cb, lockd) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+ }
+
+ vconf_set_bool(VCONFKEY_SAT_NORMAL_PRIORITY_AVAILABLE_BOOL, EINA_TRUE);
+
+ if (launch_lock == FALSE) {
+ LOCKD_ERR("Don't launch lockscreen..");
+ return 0;
+ }
+
+ lockd->is_first_boot = is_first_boot;
+ if (lockd->is_first_boot == TRUE){
+ LOCKD_ERR("first_boot : %d \n", lockd->is_first_boot);
+ return 0;
+ }
+
+ ret = lockd_launch_app_lockscreen(lockd);
+
+ if(feedback_initialize() != FEEDBACK_ERROR_NONE) {
+ LOCKD_ERR("[CAUTION][ERROR] feedback_initialize() is failed..!!");
+ }
+
+ return ret;
+}
diff --git a/src/lockd-bt.c b/src/lockd-bt.c
new file mode 100755
index 0000000..f817923
--- /dev/null
+++ b/src/lockd-bt.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <vconf.h>
+#include <vconf-keys.h>
+
+#include <bluetooth.h>
+
+#include "lockd-debug.h"
+#include "lockd-bt.h"
+
+
+#define OUT_OF_RANGE_THRESHOLD -70
+#define IN_RANGE_THRESHOLD -60
+
+/*For test*/
+//#define OUT_OF_RANGE_THRESHOLD -45
+//#define IN_RANGE_THRESHOLD -40
+
+
+
+#define VCONFKEY_BT_OUT "file/private/lockscreen/bt_out"
+#define VCONFKEY_BT_IN "file/private/lockscreen/bt_in"
+
+#define OUT_OF_RANGE_ALERT 2
+#define IN_RANGE_ALERT 1
+
+static int g_is_security = 1;
+
+static int out_of_range_threshold = -70;
+static int in_range_threshold = -60;
+
+
+
+#if 0
+static void _lockd_bt_enabled_cb(const char *address,
+ bt_device_connection_link_type_e link_type,
+ int rssi_enabled, void *user_data)
+{
+ LOCKD_WARN("RSSI Enabled: %s %d %d", address, link_type, rssi_enabled);
+}
+
+
+static void _lockd_bt_rssi_alert_cb(char *bt_address,
+ bt_device_connection_link_type_e link_type,
+ int rssi_alert_type, int rssi_alert_dbm, void *user_data)
+{
+ int is_security = TRUE;
+ LOCKD_WARN("RSSI Alert: [Address:%s LinkType:%d][RSSI Alert Type:%d dBm:%d]",
+ bt_address, link_type, rssi_alert_type, rssi_alert_dbm);
+
+#if 0
+ if (rssi_alert_dbm < OUT_OF_RANGE_THRESHOLD) {
+ g_is_security = TRUE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, TRUE);
+ }
+
+ if (rssi_alert_dbm > IN_RANGE_THRESHOLD) {
+ g_is_security = FALSE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, FALSE);
+ }
+#else
+ if (rssi_alert_type == OUT_OF_RANGE_ALERT) {
+ g_is_security = TRUE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, g_is_security);
+ }
+
+ if (rssi_alert_type == IN_RANGE_ALERT) {
+ g_is_security = FALSE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, g_is_security);
+ }
+#endif
+}
+
+
+static void _lockd_notify_security_auto_lock_cb(keynode_t * node, void *data)
+{
+ int is_security = TRUE;
+
+ vconf_get_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, &is_security);
+ LOCKD_WARN("security auto lock is changed to [%d]", is_security);
+ if (is_security != g_is_security) {
+ LOCKD_ERR("Who changes auto lock security..!!, change value from [%d] to [%d]", is_security, g_is_security);
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, g_is_security);
+ }
+}
+
+
+int lockd_start_bt_monitor(void)
+{
+ int r = 0;
+ char *device_name = NULL;
+
+ bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_BREDR;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ r = bt_initialize();
+ if (r < 0) {
+ LOCKD_ERR("bt_initialize is failed, r=%d", r);
+ return -1;
+ }
+
+ device_name = vconf_get_str(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_NAME_STR);
+ if (!device_name) {
+ LOCKD_ERR("cant't get BT device name");
+ return -1;
+ }
+
+ vconf_get_int(VCONFKEY_BT_OUT, &out_of_range_threshold);
+ vconf_get_int(VCONFKEY_BT_IN, &in_range_threshold);
+
+ if ((out_of_range_threshold > 0) || (in_range_threshold > 0) || (out_of_range_threshold > in_range_threshold)) {
+ out_of_range_threshold = OUT_OF_RANGE_THRESHOLD;
+ in_range_threshold = IN_RANGE_THRESHOLD;
+ }
+
+
+ LOCKD_WARN("OUT Range[%d] IN Range [%d] BT device address : [%s]", out_of_range_threshold, in_range_threshold, device_name);
+ r = bt_device_enable_rssi_monitor(device_name, link_type,
+ out_of_range_threshold, in_range_threshold,
+ _lockd_bt_enabled_cb, NULL,
+ _lockd_bt_rssi_alert_cb, NULL);
+ if (r < 0) {
+ LOCKD_ERR("bt_device_enable_rssi_monitor is failed, r=%d", r);
+ return -1;
+ }
+
+ /* BT will be near when auto lock is set */
+ g_is_security = FALSE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, FALSE);
+ if (vconf_notify_key_changed
+ (VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, _lockd_notify_security_auto_lock_cb, NULL) != 0) {
+ LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY");
+ }
+
+ return 0;
+}
+
+
+void lockd_stop_bt_monitor(void)
+{
+ int r = 0;
+ char *device_name = NULL;
+ bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_BREDR;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ device_name = vconf_get_str(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_NAME_STR);
+ if (!device_name) {
+ LOCKD_ERR("cant't get BT device name");
+ }
+ r = bt_device_disable_rssi_monitor(device_name, link_type,
+ _lockd_bt_enabled_cb, NULL);
+ if (r < 0) {
+ LOCKD_ERR("bt_device_disable_rssi_monitor is failed, r=%d", r);
+ }
+
+ /* BT will be far when auto lock is unset */
+ if (vconf_ignore_key_changed
+ (VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, _lockd_notify_security_auto_lock_cb) != 0) {
+ LOCKD_ERR("Fail to unregister");
+ }
+ g_is_security = TRUE;
+
+ r = bt_deinitialize();
+ if (r < 0) {
+ LOCKD_ERR("bt_deinitialize is failed, r=%d", r);
+ }
+}
+
+
+
+static void _lockd_bt_rssi_stregth_cb(char *bt_address,
+ bt_device_connection_link_type_e link_type,
+ int rssi_dbm, void *user_data)
+{
+ LOCKD_WARN("RSSI Strength: [Address %s][Link Type %d][RSSI dBm %d], current auto lock pw security is [%d]",
+ bt_address, link_type, rssi_dbm, g_is_security);
+
+ if ((g_is_security) && (rssi_dbm > in_range_threshold)) {
+ g_is_security = FALSE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, g_is_security);
+ }
+}
+
+void lockd_change_security_auto_lock(int is_connected)
+{
+ LOCKD_WARN("BT connect is changed to [%d], security status is [%d]", is_connected, g_is_security);
+
+ if ((!is_connected) && (!g_is_security)) {
+ g_is_security = TRUE;
+ vconf_set_int(VCONFKEY_LOCKSCREEN_SECURITY_AUTO_LOCK, g_is_security);
+ } else if (is_connected){
+ int r = 0;
+ char *device_name = NULL;
+ bt_device_connection_link_type_e link_type = BT_DEVICE_CONNECTION_LINK_BREDR;
+
+ device_name = vconf_get_str(VCONFKEY_SETAPPL_AUTO_LOCK_DEVICE_NAME_STR);
+ if (!device_name) {
+ LOCKD_ERR("cant't get BT device name");
+ }
+
+ r = bt_device_get_rssi_strength(device_name, link_type,
+ _lockd_bt_rssi_stregth_cb, NULL);
+ }
+}
+
+int lockd_get_auto_lock_security(void)
+{
+ LOCKD_DBG("BT auto lock has security : %d", g_is_security);
+ return g_is_security;
+}
+#endif
diff --git a/lock-mgr/src/lockd-debug.c b/src/lockd-debug.c
index bff5949..934450e 100755
--- a/lock-mgr/src/lockd-debug.c
+++ b/src/lockd-debug.c
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -26,7 +26,7 @@
#include "lockd-debug.h"
#define LINEMAX 256
-#define MAXFILELEN 1048576
+#define MAXFILELEN 1048576 /* 32000 */
#define LOGFILE "/tmp/starter.log"
void lockd_log_t(char *fmt, ...)
@@ -44,7 +44,8 @@ void lockd_log_t(char *fmt, ...)
time_t current_time = 0;
bzero((char *)&debugString, LINEMAX);
time(&current_time);
- gmtime_r(&current_time, &local_t);
+ /* local_t = gmtime(&current_time); */
+ gmtime_r(&current_time, &local_t); /* for prevent 53555 */
int len = snprintf(debugString, sizeof(debugString),
"[%d-%02d-%02d, %02d:%02d:%02d]: ",
local_t.tm_year + 1900, local_t.tm_mon + 1,
@@ -57,10 +58,13 @@ void lockd_log_t(char *fmt, ...)
}
len = g_strlcat(debugString, buf, LINEMAX);
if (len >= LINEMAX) {
+ /* TODO:ERROR handling */
return;
} else {
debugString[len] = '\n';
}
+ /* FIXME this is for permission.. later we should fix and remove this... */
+ /* system("chmod 666 "LOGFILE); */
if ((fd = fopen(LOGFILE, "at+")) == NULL) {
LOCKD_DBG("File fopen fail for writing Pwlock information");
} else {
@@ -74,6 +78,7 @@ void lockd_log_t(char *fmt, ...)
execl("/bin/rm", "rm", "-f", LOGFILE,
(char *)0);
}
+ /* system("rm -rf "LOGFILE); */
} else {
fseek(fd, 0l, SEEK_END);
fileLen = ftell(fd);
@@ -85,6 +90,7 @@ void lockd_log_t(char *fmt, ...)
execl("/bin/rm", "rm", "-f", LOGFILE,
(char *)0);
}
+ /* system("rm -rf "LOGFILE); */
} else
fclose(fd);
}
diff --git a/src/lockd-process-mgr.c b/src/lockd-process-mgr.c
new file mode 100755
index 0000000..d3d0e77
--- /dev/null
+++ b/src/lockd-process-mgr.c
@@ -0,0 +1,414 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <vconf.h>
+#include <vconf-keys.h>
+#include <aul.h>
+#include <pkgmgr-info.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <Ecore.h>
+#include <unistd.h>
+
+#include "lockd-debug.h"
+#include "lockd-process-mgr.h"
+#include "starter-vconf.h"
+
+#define LOCKD_DEFAULT_PKG_NAME "org.tizen.lockscreen"
+#define LOCKD_DRAG_LOCKSCREEN "com.samsung.draglock"
+#define LOCKD_PHONE_LOCK_PKG_NAME LOCKD_DEFAULT_PKG_NAME
+#define RETRY_MAXCOUNT 30
+#define RELAUNCH_INTERVAL 100*1000
+
+#define LOCKD_VOICE_CALL_PKG_NAME "com.samsung.call"
+#define LOCKD_VIDEO_CALL_PKG_NAME "com.samsung.vtmain"
+
+#define NICE_VALUE_PWLOCK -5
+#define NICE_VALUE_LOCKSCREEN -20
+
+static char *default_lockscreen_pkg = NULL;
+
+static bool _lockd_exist_package(char *pkgid)
+{
+ int ret = 0;
+ pkgmgrinfo_appinfo_h handle = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &handle);
+ if (PMINFO_R_OK != ret || NULL == handle) {
+ LOCKD_SECURE_DBG("%s doesn't exist in this binary", pkgid);
+ return false;
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return true;
+}
+
+void lockd_process_mgr_init(void)
+{
+ default_lockscreen_pkg = vconf_get_str(VCONF_PRIVATE_LOCKSCREEN_DEFAULT_PKGNAME);
+ LOCKD_SECURE_DBG("default lock screen pkg name is %s", default_lockscreen_pkg);
+ if (default_lockscreen_pkg == NULL) {
+ default_lockscreen_pkg = LOCKD_DEFAULT_PKG_NAME;
+ }
+ if (!_lockd_exist_package(default_lockscreen_pkg)) {
+ LOCKD_SECURE_ERR("%s is not exist, default lock screen pkg name is set to %s", default_lockscreen_pkg, LOCKD_DRAG_LOCKSCREEN);
+ default_lockscreen_pkg = LOCKD_DRAG_LOCKSCREEN;
+ if (vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, default_lockscreen_pkg) != 0) {
+ LOCKD_SECURE_ERR("vconf key [%s] set [%s] is failed", VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, default_lockscreen_pkg);
+ }
+ }
+}
+
+static char *_lockd_process_mgr_get_pkgname(int lock_type)
+{
+ char *pkgname = NULL;
+
+ if (lock_type > 1) {
+ pkgname = vconf_get_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR);
+ LOCKD_SECURE_DBG("pkg name is %s", pkgname);
+ if (pkgname == NULL) {
+ pkgname = default_lockscreen_pkg;
+ } else if (_lockd_exist_package(pkgname) == FALSE) {
+ pkgname = default_lockscreen_pkg;
+ }
+ } else {
+ pkgname = default_lockscreen_pkg;
+ }
+ return pkgname;
+}
+
+int lockd_process_mgr_restart_lock(int lock_type)
+{
+ char *lock_app_path = NULL;
+ int pid;
+ int i;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ lock_app_path = _lockd_process_mgr_get_pkgname(lock_type);
+
+ for (i=0; i<RETRY_MAXCOUNT; i++)
+ {
+ pid = aul_launch_app(lock_app_path, NULL);
+ LOCKD_DBG("aul_launch_app(%s), pid = %d", lock_app_path, pid);
+ if (pid == AUL_R_ETIMEOUT) {
+ LOCKD_DBG("Relaunch lock application [%d]times", i);
+ usleep(RELAUNCH_INTERVAL);
+ } else {
+ return pid;
+ }
+ }
+
+ LOCKD_SECURE_DBG("Reset : aul_launch_app(%s, NULL), pid = %d", lock_app_path,
+ pid);
+ return pid;
+}
+
+int
+lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *),
+ int lock_type)
+{
+ char *lock_app_path = NULL;
+ int pid;
+ int i;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ lock_app_path = _lockd_process_mgr_get_pkgname(lock_type);
+
+ for (i=0; i<RETRY_MAXCOUNT; i++)
+ {
+ pid = aul_launch_app(lock_app_path, NULL);
+
+ LOCKD_SECURE_DBG("aul_launch_app(%s), pid = %d", lock_app_path, pid);
+
+ if ((pid == AUL_R_ECOMM) || (pid == AUL_R_ETERMINATING)) {
+ LOCKD_DBG("Relaunch lock application [%d]times", i);
+ usleep(RELAUNCH_INTERVAL);
+ } else if (pid == AUL_R_ERROR) {
+ LOCKD_SECURE_ERR("launch[%s] is failed, launch default lock screen", lock_app_path);
+ pid = aul_launch_app(default_lockscreen_pkg, NULL);
+ if (pid == AUL_R_ERROR) {
+ LOCKD_SECURE_ERR("launch[%s] is failed, launch drag lock screen", default_lockscreen_pkg);
+ pid = aul_launch_app(LOCKD_DRAG_LOCKSCREEN, NULL);
+ if (pid >0) {
+ if (vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, LOCKD_DRAG_LOCKSCREEN) != 0) {
+ LOCKD_SECURE_ERR("vconf key [%s] set [%s] is failed", VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, LOCKD_DRAG_LOCKSCREEN);
+ }
+ return pid;
+ }
+ } else {
+ return pid;
+ }
+ } else {
+ return pid;
+ }
+ }
+ LOCKD_ERR("Relaunch lock application failed..!!");
+ return pid;
+}
+
+int lockd_process_mgr_start_normal_lock(void *data, int (*dead_cb) (int, void *))
+{
+ int pid = 0;
+
+ int i;
+ for (i=0; i<RETRY_MAXCOUNT; i++)
+ {
+ pid = aul_launch_app(default_lockscreen_pkg, NULL);
+
+ LOCKD_SECURE_DBG("aul_launch_app(%s), pid = %d", default_lockscreen_pkg, pid);
+
+ if ((pid == AUL_R_ECOMM) || (pid == AUL_R_ETERMINATING)) {
+ LOCKD_DBG("Relaunch lock application [%d]times", i);
+ usleep(RELAUNCH_INTERVAL);
+ } else if (pid == AUL_R_ERROR) {
+ LOCKD_SECURE_DBG("launch[%s] is failed, launch default lock screen", default_lockscreen_pkg);
+ } else {
+ return pid;
+ }
+ }
+ LOCKD_ERR("Relaunch lock application failed..!!");
+ return pid;
+}
+
+static Eina_Bool _set_priority_lockscreen_process_cb(void *data)
+{
+ int prio;
+ char buf[1024] = { 0, };
+
+ prio = getpriority(PRIO_PROCESS, (pid_t)data);
+ if (prio == NICE_VALUE_LOCKSCREEN) {
+ LOCKD_DBG("%s (%d: %d)\n", "setpriority Success", (pid_t)data, prio);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (setpriority(PRIO_PROCESS, (pid_t)data, NICE_VALUE_LOCKSCREEN) < 0 ) {
+ LOCKD_DBG("%s\n", strerror_r(errno, buf, sizeof(buf)));
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool _set_priority_pwlock_process_cb(void *data)
+{
+ int prio;
+ char buf[104] = { 0, };
+
+ prio = getpriority(PRIO_PROCESS, (pid_t)data);
+ if (prio == NICE_VALUE_PWLOCK) {
+ LOCKD_DBG("%s (%d: %d)\n", "setpriority Success", (pid_t)data, prio);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (setpriority(PRIO_PROCESS, (pid_t)data, NICE_VALUE_PWLOCK) < 0 ) {
+ LOCKD_DBG("%s\n", strerror_r(errno, buf, sizeof(buf)));
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+int lockd_process_mgr_start_phone_lock(void)
+{
+ int pid = 0;
+ bundle *b = NULL;
+ int i;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ b = bundle_create();
+
+ bundle_add(b, "lock_type", "phone_lock");
+
+ for (i=0; i<RETRY_MAXCOUNT; i++)
+ {
+ pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
+
+ LOCKD_SECURE_DBG("aul_launch_app(%s), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME, pid);
+
+ if ((pid == AUL_R_ECOMM) || (pid == AUL_R_ETERMINATING)) {
+ LOCKD_DBG("Relaunch lock application [%d]times", i);
+ usleep(RELAUNCH_INTERVAL);
+ } else {
+ if (b)
+ bundle_free(b);
+
+ return pid;
+ }
+ }
+
+ if (b)
+ bundle_free(b);
+
+ return pid;
+}
+
+int lockd_process_mgr_set_lockscreen_priority(int pid)
+{
+ return !ecore_timer_add(1.0f, _set_priority_lockscreen_process_cb, (void *)pid);
+}
+
+int lockd_process_mgr_set_pwlock_priority(int pid)
+{
+ return !ecore_timer_add(1.0f, _set_priority_pwlock_process_cb, (void *)pid);
+}
+
+
+int lockd_process_mgr_start_recovery_lock(void)
+{
+ int pid = 0;
+ bundle *b = NULL;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ b = bundle_create();
+
+ bundle_add(b, "lock_type", "recovery_lock");
+
+ pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
+ LOCKD_SECURE_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
+ pid);
+ if (b)
+ bundle_free(b);
+
+ return pid;
+}
+
+int lockd_process_mgr_start_back_to_app_lock(void)
+{
+ int pid = 0;
+ bundle *b = NULL;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ b = bundle_create();
+
+ bundle_add(b, "lock_type", "back_to_call");
+
+ pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
+ LOCKD_SECURE_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
+ pid);
+ if (b)
+ bundle_free(b);
+
+ return pid;
+}
+
+int lockd_process_mgr_start_ready_lock(void)
+{
+ int pid = 0;
+ bundle *b = NULL;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ b = bundle_create();
+
+ bundle_add(b, "lock_op", "start_ready");
+
+ pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
+ LOCKD_SECURE_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
+ pid);
+ if (b)
+ bundle_free(b);
+
+ return pid;
+}
+
+void
+lockd_process_mgr_terminate_lock_app(int lock_app_pid, int state)
+{
+ LOCKD_DBG
+ ("lockd_process_mgr_terminate_lock_app, state:%d\n",
+ state);
+
+ if (state == 1) {
+ if (lock_app_pid != 0) {
+ LOCKD_DBG("Terminate Lock app(pid : %d)", lock_app_pid);
+ aul_terminate_pid(lock_app_pid);
+ }
+ }
+}
+
+void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid)
+{
+ LOCKD_DBG("Terminate Phone Lock(pid : %d)", phone_lock_pid);
+ aul_terminate_pid(phone_lock_pid);
+}
+
+void lockd_process_mgr_kill_lock_app(int lock_app_pid)
+{
+ LOCKD_DBG ("lockd_process_mgr_kill_lock_app [pid:%d]..", lock_app_pid);
+ aul_kill_pid(lock_app_pid);
+}
+
+int lockd_process_mgr_check_lock(int pid)
+{
+ char buf[128];
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ /* Check pid is invalid. */
+ if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
+ LOCKD_DBG("no such pkg by pid %d\n", pid);
+ } else {
+ LOCKD_SECURE_DBG("app pkgname = %s, pid = %d\n", buf, pid);
+ if (aul_app_is_running(buf) == TRUE) {
+ LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
+ return TRUE;
+ } else {
+ LOCKD_SECURE_DBG("[pid = %d] is exist but %s is not running\n",
+ pid, buf);
+ }
+ }
+ return FALSE;
+}
+
+int lockd_process_mgr_check_call(int pid)
+{
+ char buf[128];
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ /* Check pid is invalid. */
+ if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
+ LOCKD_DBG("no such pkg by pid %d", pid);
+ } else {
+ LOCKD_SECURE_DBG("app pkgname = %s, pid = %d", buf, pid);
+ if ((!strncmp(buf, LOCKD_VOICE_CALL_PKG_NAME, strlen(buf)))
+ || (!strncmp(buf, LOCKD_VIDEO_CALL_PKG_NAME, strlen(buf)))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+int lockd_process_mgr_check_home(int pid)
+{
+ char buf[128];
+ char *pkgname = NULL;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ /* Check pid is invalid. */
+ if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
+ LOCKD_DBG("no such pkg by pid %d", pid);
+ } else {
+ LOCKD_SECURE_DBG("app pkgname = %s, pid = %d", buf, pid);
+
+ pkgname = vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME);
+
+ if ((pkgname != NULL) &&
+ (!strncmp(buf, pkgname, strlen(buf)))) {
+ LOCKD_SECURE_DBG("home pkgname = %s", pkgname);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/src/lockd-window-mgr.c b/src/lockd-window-mgr.c
new file mode 100755
index 0000000..bbe3fcc
--- /dev/null
+++ b/src/lockd-window-mgr.c
@@ -0,0 +1,807 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+#include <Ecore_X.h>
+#include <utilX.h>
+#include <ui-gadget.h>
+#include <vconf.h>
+#include <bundle.h>
+#include <appcore-efl.h>
+#include <app.h>
+
+#include "lockd-debug.h"
+#include "lockd-window-mgr.h"
+#include "util.h"
+
+#define PACKAGE "starter"
+#define SOS_KEY_COUNT 3
+#define SOS_KEY_INTERVAL 0.5
+
+#define _MAKE_ATOM(a, s) \
+ do { \
+ a = ecore_x_atom_get(s); \
+ if (!a) \
+ fprintf(stderr, \
+ "##s creation failed.\n"); \
+ } while(0)
+
+#define STR_ATOM_PANEL_SCROLLABLE_STATE "_E_MOVE_PANEL_SCROLLABLE_STATE"
+
+struct _lockw_data {
+ Evas_Object *main_win;
+ Evas_Object *main_layout;
+
+ Ecore_X_Window lock_x_window;
+
+ Ecore_Event_Handler *h_keydown;
+ Ecore_Event_Handler *h_wincreate;
+ Ecore_Event_Handler *h_winshow;
+
+#if 0
+ Ecore_Timer *pTimerId; /* volume key timer */
+ int volume_key_cnt;
+#endif
+
+ int phone_lock_state; /* 0 : disable, 1 : enable */
+ int phone_lock_app_pid;
+};
+
+#if 0
+Eina_Bool volume_key_expire_cb(void *pData)
+{
+ int api_ret = 0;
+ int vconf_val = 0;
+ lockw_data *lockw = (lockw_data *) pData;
+
+ _DBG("volume_key_expire_cb..!!");
+
+ lockw->volume_key_cnt = 0;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _lockd_window_key_down_cb(void *data, int type, void *event)
+{
+ Ecore_Event_Key *ev = event;
+ lockw_data *lockw = (lockw_data *) data;
+ int vconf_val = 0;
+ int ret = 0;
+
+ LOCKD_DBG("Key Down CB : %s", ev->keyname);
+
+ ret = vconf_get_int(VCONFKEY_MESSAGE_SOS_STATE, &vconf_val);
+
+ if(ret != 0)
+ {
+ LOCKD_ERR("_lockd_window_key_down_cb:VCONFKEY_MESSAGE_SOS_STATE FAILED");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (!strcmp(ev->keyname, KEY_VOLUMEUP) || !strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
+ if (vconf_val == VCONFKEY_MESSAGE_SOS_IDLE) {
+ if (lockw->volume_key_cnt == 0) {
+ lockw->volume_key_cnt++;
+ LOCKD_DBG("Volume key is pressed %d times", lockw->volume_key_cnt);
+ lockw->pTimerId = ecore_timer_add(SOS_KEY_INTERVAL, volume_key_expire_cb, lockw);
+ } else if (lockw->volume_key_cnt == SOS_KEY_COUNT) {
+ LOCKD_DBG("SOS msg invoked");
+ if (lockw->pTimerId != NULL) {
+ ecore_timer_del(lockw->pTimerId);
+ lockw->pTimerId = NULL;
+ lockw->volume_key_cnt =0;
+ vconf_set_int(VCONFKEY_MESSAGE_SOS_STATE, VCONFKEY_MESSAGE_SOS_INVOKED);
+ ecore_x_pointer_grab(lockw->lock_x_window);
+ }
+ } else {
+ if (lockw->pTimerId != NULL) {
+ ecore_timer_del(lockw->pTimerId);
+ lockw->pTimerId = NULL;
+ lockw->volume_key_cnt++;
+ LOCKD_DBG("Volume key is pressed %d times", lockw->volume_key_cnt);
+ lockw->pTimerId = ecore_timer_add(SOS_KEY_INTERVAL, volume_key_expire_cb, lockw);
+ }
+ }
+ }
+ } else if (!strcmp(ev->keyname, KEY_HOME)) {
+ if (vconf_val != VCONFKEY_MESSAGE_SOS_IDLE) {
+ LOCKD_DBG("Home key is pressed set to idle", lockw->volume_key_cnt);
+ vconf_set_int(VCONFKEY_MESSAGE_SOS_STATE, VCONFKEY_MESSAGE_SOS_IDLE);
+ ecore_x_pointer_ungrab();
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+#endif
+
+static int
+_lockd_window_check_validate_rect(Ecore_X_Display * dpy, Ecore_X_Window window)
+{
+ Ecore_X_Window root;
+ Ecore_X_Window child;
+
+ int rel_x = 0;
+ int rel_y = 0;
+ int abs_x = 0;
+ int abs_y = 0;
+
+ unsigned int width = 0;
+ unsigned int height = 0;
+ unsigned int border = 0;
+ unsigned int depth = 0;
+ unsigned int root_w = 0;
+ unsigned int root_h = 0;
+
+ Eina_Bool ret = FALSE;
+
+ root = ecore_x_window_root_first_get();
+ XGetGeometry(dpy, root, &root, &rel_x, &rel_y, &root_w, &root_h, &border, &depth);
+ LOCKD_DBG("root rel_x[%d] rel_y[%d] border[%d] width[%d] height[%d]", rel_x, rel_y, border, root_w, root_h);
+ if (XGetGeometry
+ (dpy, window, &root, &rel_x, &rel_y, &width, &height, &border,
+ &depth)) {
+ if (XTranslateCoordinates
+ (dpy, window, root, 0, 0, &abs_x, &abs_y, &child)) {
+ LOCKD_DBG("abs_x[%d] abs_y[%d] border[%d] width[%d] height[%d]", abs_x, abs_y, border, width, height);
+ if ((abs_x - border) >= root_w || (abs_y - border) >= root_h
+ || (width + abs_x) <= 0 || (height + abs_y) <= 0) {
+ ret = FALSE;
+ } else {
+ ret = (width == root_w) && (height == root_h);
+ }
+ }
+ }
+ return ret;
+}
+
+static Evas_Object *lockd_create_main_window(const char *pkgname)
+{
+ Evas_Object *eo = NULL;
+ int w, h;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ eo = elm_win_add(NULL, pkgname, ELM_WIN_BASIC);
+ if (eo) {
+ elm_win_title_set(eo, pkgname);
+ elm_win_borderless_set(eo, EINA_TRUE);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(),
+ &w, &h);
+ LOCKD_DBG("%s, %d, w = %d, h = %d", __func__, __LINE__, w, h);
+ evas_object_resize(eo, w, h);
+ }
+ return eo;
+}
+
+static Evas_Object *lockd_create_main_layout(Evas_Object * parent)
+{
+ Evas_Object *ly = NULL;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ ly = elm_layout_add(parent);
+ if (!ly) {
+ LOCKD_ERR("UI layout add error");
+ return NULL;
+ }
+
+ elm_layout_theme_set(ly, "layout", "application", "default");
+ evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_show(ly);
+
+ elm_win_indicator_mode_set(parent, ELM_WIN_INDICATOR_SHOW);
+
+ return ly;
+}
+
+static void _lockd_phone_lock_alpha_ug_layout_cb(ui_gadget_h ug,
+ enum ug_mode mode, void *priv)
+{
+ lockw_data *lockw = (lockw_data *) priv;;
+ Evas_Object *base = NULL;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (!ug || !lockw)
+ return;
+
+ base = ug_get_layout(ug);
+ if (!base)
+ return;
+
+ switch (mode) {
+ case UG_MODE_FULLVIEW:
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ ug_disable_effect(ug); /* not use effect when destroy phone lock UG */
+ evas_object_show(base);
+ break;
+ case UG_MODE_FRAMEVIEW:
+ /* elm_layout_content_set(lockw->main_layout, "content", base); *//* not used */
+ break;
+ default:
+ break;
+ }
+}
+
+static void _lockd_phone_lock_alpha_ug_result_cb(ui_gadget_h ug,
+ app_control_h app_control, void *priv)
+{
+ int alpha;
+ const char *val1 = NULL, *val2 = NULL;
+ lockw_data *lockw = (lockw_data *) priv;;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (!ug || !lockw)
+ return;
+
+ app_control_get_extra_data(app_control, "name", &val1);
+
+ if (val1 == NULL)
+ return;
+
+ LOCKD_DBG("val1 = %s", val1);
+
+ app_control_get_extra_data(app_control, "result", &val2);
+
+ if (val2 == NULL){
+ if(val1 != NULL)
+ free(val1);
+ return;
+ }
+
+ LOCKD_DBG("val2 = %s", val2);
+
+
+ if (!strcmp(val1, "phonelock-ug")) {
+ if (!strcmp(val2, "success")) {
+ LOCKD_DBG("password verified. Unlock!\n");
+ }
+ } else if (!strcmp(val1, "phonelock-ug-alpha")) {
+ alpha = atoi(val2);
+ }
+
+ if(val1 != NULL)
+ free(val1);
+
+ if(val2 != NULL)
+ free(val2);
+}
+
+static void _lockd_phone_lock_alpha_ug_destroy_cb(ui_gadget_h ug,
+ void *priv)
+{
+ lockw_data *lockw = (lockw_data *) priv;;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (!ug || !lockw)
+ return;
+
+ ug_destroy(ug);
+ ug = NULL;
+ lockd_destroy_ug_window(lockw);
+ vconf_set_bool(VCONFKEY_LOCKSCREEN_PHONE_LOCK_VERIFICATION, TRUE);
+}
+
+static void _lockd_ug_window_set_win_prop(void *data, int type)
+{
+ Ecore_X_Window w;
+ Evas_Object *win = NULL;
+ lockw_data *lockw = (lockw_data *) data;;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (!lockw)
+ return;
+
+ win = lockw->main_win;
+
+ w = elm_win_xwindow_get(win);
+
+ if (type == ECORE_X_WINDOW_TYPE_NORMAL) {
+ ecore_x_netwm_window_type_set(w, ECORE_X_WINDOW_TYPE_NORMAL);
+ } else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION) {
+ ecore_x_netwm_window_type_set(w,
+ ECORE_X_WINDOW_TYPE_NOTIFICATION);
+ utilx_set_system_notification_level(ecore_x_display_get(), w,
+ UTILX_NOTIFICATION_LEVEL_NORMAL);
+ }
+}
+
+static void _lockd_ug_window_set_key_grab(void *data)
+{
+ Ecore_X_Window w;
+ int ret = 0;
+ Evas_Object *win = NULL;
+ lockw_data *lockw = (lockw_data *) data;;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (!lockw)
+ return;
+
+ win = lockw->main_win;
+ w = elm_win_xwindow_get(win);
+ ret = utilx_grab_key(ecore_x_display_get(), w, KEY_HOME, EXCLUSIVE_GRAB);
+ if(ret)
+ {
+ LOCKD_ERR("Key grab error : KEY_HOME");
+ }
+ ret = utilx_grab_key(ecore_x_display_get(), w, KEY_CONFIG, TOP_POSITION_GRAB);
+ if(ret)
+ {
+ LOCKD_ERR("Key grab error : KEY_CONFIG");
+ }
+}
+
+static void _lockd_ug_window_set_key_ungrab(void *data)
+{
+ Ecore_X_Window xwin;
+ Ecore_X_Display *disp = NULL;
+ lockw_data *lockw = (lockw_data *) data;;
+
+ if (!lockw)
+ return;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ disp = ecore_x_display_get();
+ xwin = elm_win_xwindow_get(lockw->main_win);
+
+ utilx_ungrab_key(disp, xwin, KEY_HOME);
+ utilx_ungrab_key(disp, xwin, KEY_CONFIG);
+}
+
+static void _lockd_ug_window_vconf_call_state_changed_cb(keynode_t * node,
+ void *data)
+{
+ int api_ret = 0;
+ int vconf_val = 0;
+ lockw_data *lockw = (lockw_data *) data;
+
+ if (!lockw)
+ return;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ api_ret = vconf_get_int(VCONFKEY_CALL_STATE, &vconf_val);
+ if (api_ret != 0) {
+ LOCKD_DBG("fail to get vconf key value"
+ );
+ } else {
+ if (vconf_val == VCONFKEY_CALL_OFF) {
+ LOCKD_DBG("call off state..");
+ _lockd_ug_window_set_win_prop(lockw,
+ ECORE_X_WINDOW_TYPE_NOTIFICATION);
+ } else {
+ LOCKD_DBG("call on state..");
+ _lockd_ug_window_set_win_prop(lockw,
+ ECORE_X_WINDOW_TYPE_NORMAL);
+ }
+ }
+ return;
+}
+
+static void _lockd_ug_window_register_vconf_changed(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ if (vconf_notify_key_changed
+ (VCONFKEY_CALL_STATE, _lockd_ug_window_vconf_call_state_changed_cb,
+ data) != 0) {
+ LOCKD_DBG("Fail to register");
+ }
+}
+
+static void _lockd_ug_window_unregister_vconf_changed(void *data)
+{
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_CALL_STATE,
+ _lockd_ug_window_vconf_call_state_changed_cb) != 0) {
+ LOCKD_DBG("Fail to unregister");
+ }
+
+}
+
+void _lockd_window_transient_for_set(void *data)
+{
+ lockw_data *lockw = (lockw_data *) data;
+ Ecore_X_Window xwin_ug;
+ Ecore_X_Window xwin_lock;
+
+ if (!lockw)
+ return;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ xwin_ug = elm_win_xwindow_get(lockw->main_win);
+ xwin_lock = lockw->lock_x_window;
+
+ LOCKD_DBG("ug win id : %x, and lock win id is :%x", xwin_ug, xwin_lock);
+ ecore_x_icccm_transient_for_set(xwin_ug, xwin_lock);
+}
+
+Eina_Bool _lockd_window_set_window_property_timer_cb(void *data)
+{
+ Ecore_X_Window win = (Ecore_X_Window) data;
+ LOCKD_DBG
+ ("[MINSU] win id(%x) set lock screen window property to notification and level low\n",
+ win);
+
+ /* Set notification type */
+ ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION);
+
+ /* Set notification's priority */
+ utilx_set_system_notification_level(ecore_x_display_get(), win,
+ UTILX_NOTIFICATION_LEVEL_LOW);
+
+ return EINA_FALSE;
+}
+
+static Window get_user_created_window(Window win)
+{
+ Atom type_ret = 0;
+ int ret, size_ret = 0;
+ unsigned long num_ret = 0, bytes = 0;
+ unsigned char *prop_ret = NULL;
+ unsigned int xid;
+ Atom prop_user_created_win;
+
+ prop_user_created_win =
+ XInternAtom(ecore_x_display_get(), "_E_USER_CREATED_WINDOW", False);
+
+ ret =
+ XGetWindowProperty(ecore_x_display_get(), win,
+ prop_user_created_win, 0L, 1L, False, 0,
+ &type_ret, &size_ret, &num_ret, &bytes,
+ &prop_ret);
+
+ if (ret != Success) {
+ if (prop_ret)
+ XFree((void *)prop_ret);
+ return win;
+ } else if (!prop_ret) {
+ return win;
+ }
+
+ memcpy(&xid, prop_ret, sizeof(unsigned int));
+ XFree((void *)prop_ret);
+
+ return xid;
+
+}
+
+int
+lockd_window_mgr_get_focus_win_pid(void)
+{
+ Ecore_X_Window x_win_focused = 0;
+ int pid = 0;
+ int ret = -1;
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ x_win_focused = ecore_x_window_focus_get();
+ ret = ecore_x_netwm_pid_get(x_win_focused, &pid);
+ if(ret != 1) {
+ LOCKD_ERR("Can't get pid for focus x window (%x)\n", x_win_focused);
+ return -1;
+ }
+ LOCKD_DBG("PID(%d) for focus x window (%x)\n", pid, x_win_focused);
+
+ return pid;
+}
+
+Eina_Bool
+lockd_window_set_window_property(lockw_data * data, int lock_app_pid,
+ void *event)
+{
+ Ecore_X_Event_Window_Create *e = event;
+ Ecore_X_Window user_window = 0;
+ lockw_data *lockw = (lockw_data *) data;
+ int pid = 0;
+
+ if (!lockw) {
+ return EINA_FALSE;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ user_window = get_user_created_window((Window) (e->win));
+
+ int ret = ecore_x_netwm_pid_get(user_window, &pid);
+ if(ret != 1) {
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("Check PID(%d) window. (lock_app_pid : %d)\n", pid,
+ lock_app_pid);
+
+ if (lock_app_pid == pid) {
+ if (_lockd_window_check_validate_rect
+ (ecore_x_display_get(), user_window) == TRUE) {
+ lockw->lock_x_window = user_window;
+ LOCKD_DBG
+ ("This is lock application. Set window property. win id : %x",
+ user_window);
+
+ /* window effect : fade in /out */
+ ecore_x_icccm_name_class_set(user_window, "LOCK_SCREEN",
+ "LOCK_SCREEN");
+
+ /* Set notification type */
+ ecore_x_netwm_window_type_set(user_window,
+ ECORE_X_WINDOW_TYPE_NOTIFICATION);
+
+ /* Set notification's priority */
+ utilx_set_system_notification_level(ecore_x_display_get
+ (), user_window,
+ UTILX_NOTIFICATION_LEVEL_NORMAL);
+ /* Set opaque state */
+ utilx_set_window_opaque_state(ecore_x_display_get(),
+ user_window,
+ UTILX_OPAQUE_STATE_ON);
+ return EINA_TRUE;
+ }
+ }
+ return EINA_FALSE;
+}
+
+Eina_Bool
+lockd_window_set_window_effect(lockw_data * data, int lock_app_pid, void *event)
+{
+ Ecore_X_Event_Window_Create *e = event;
+ Ecore_X_Window user_window = 0;
+ int pid = 0;
+
+ user_window = get_user_created_window((Window) (e->win));
+ int ret = ecore_x_netwm_pid_get(user_window, &pid);
+ if(ret != 1) {
+ return EINA_FALSE;
+ }
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ LOCKD_DBG("PID(%d) window created. (lock_app_pid : %d)\n", pid,
+ lock_app_pid);
+
+ if (lock_app_pid == pid) {
+ if (_lockd_window_check_validate_rect
+ (ecore_x_display_get(), user_window) == TRUE) {
+ LOCKD_DBG
+ ("This is lock application. Disable window effect. win id : %x\n",
+ user_window);
+
+ /*utilx_set_window_effect_state(ecore_x_display_get(),
+ user_window, 0);*/
+
+ Ecore_X_Atom ATOM_WINDOW_EFFECT_ENABLE = 0;
+ unsigned int effect_state = 0;
+ ATOM_WINDOW_EFFECT_ENABLE = ecore_x_atom_get("_NET_CM_WINDOW_EFFECT_ENABLE");
+ if (ATOM_WINDOW_EFFECT_ENABLE) {
+ ecore_x_window_prop_card32_set(user_window, ATOM_WINDOW_EFFECT_ENABLE, &effect_state, 1);
+ } else {
+ LOCKD_ERR("ecore_x_atom_get() failed");
+ }
+ return EINA_TRUE;
+ }
+ }
+ return EINA_FALSE;
+}
+
+void
+lockd_window_set_scroll_property(lockw_data * data, int lock_type)
+{
+ lockw_data *lockw = (lockw_data *) data;
+ Ecore_X_Atom ATOM_PANEL_SCROLLABLE_STATE = 0;
+ unsigned int val[3];
+
+ if (!lockw) {
+ return;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+
+ // init atoms
+ _MAKE_ATOM(ATOM_PANEL_SCROLLABLE_STATE, STR_ATOM_PANEL_SCROLLABLE_STATE );
+
+ if (lock_type == 1) {
+ val[0] = 0; // always enable F
+ val[1] = 0; // quickpanel enable F
+ val[2] = 0; // apptray enable F
+ } else {
+ val[0] = 0; // always enable F
+ val[1] = 1; // quickpanel enable T
+ val[2] = 0; // apptray enable F
+ }
+ ecore_x_window_prop_card32_set(lockw->lock_x_window,
+ ATOM_PANEL_SCROLLABLE_STATE,
+ val,
+ 3);
+}
+
+void lockd_window_set_phonelock_pid(lockw_data * data, int phone_lock_pid)
+{
+ lockw_data *lockw = (lockw_data *) data;
+
+ if (!lockw) {
+ return;
+ }
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+ lockw->phone_lock_app_pid = phone_lock_pid;
+ LOCKD_DBG("%s, %d, lockw->phone_lock_app_pid = %d", __func__, __LINE__,
+ lockw->phone_lock_app_pid);
+}
+
+void
+lockd_window_mgr_ready_lock(void *data, lockw_data * lockw,
+ Eina_Bool(*create_cb) (void *, int, void *),
+ Eina_Bool(*show_cb) (void *, int, void *))
+{
+ Ecore_X_Window root_window;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (lockw == NULL) {
+ LOCKD_ERR("lockw is NULL.");
+ return;
+ }
+
+ /* For getting window x event */
+ root_window = ecore_x_window_root_first_get();
+ ecore_x_window_client_sniff(root_window);
+
+ /* Register window create CB */
+ lockw->h_wincreate =
+ ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE, create_cb,
+ data);
+ lockw->h_winshow =
+ ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, show_cb, data);
+
+#if 0
+ lockw->volume_key_cnt = 0;
+
+ /* Register keydown event handler */
+ lockw->h_keydown =
+ ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ _lockd_window_key_down_cb, lockw);
+#endif
+}
+
+void lockd_window_mgr_finish_lock(lockw_data * lockw)
+{
+ Ecore_X_Window root_window;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ if (lockw == NULL) {
+ LOCKD_ERR("lockw is NULL.");
+ return;
+ }
+
+ /* delete getting window x event */
+ root_window = ecore_x_window_root_first_get();
+ ecore_x_window_client_sniff(root_window);
+
+ /* delete window create event handler */
+ if (lockw->h_wincreate != NULL) {
+ ecore_event_handler_del(lockw->h_wincreate);
+ lockw->h_wincreate = NULL;
+ }
+ if (lockw->h_winshow != NULL) {
+ ecore_event_handler_del(lockw->h_winshow);
+ lockw->h_winshow = NULL;
+ }
+
+ ecore_x_pointer_ungrab();
+
+ /* delete keydown event handler */
+ if (lockw->h_keydown != NULL) {
+ ecore_event_handler_del(lockw->h_keydown);
+ lockw->h_keydown = NULL;
+ }
+}
+
+lockw_data *lockd_window_init(void)
+{
+ lockw_data *lockw = NULL;
+ long pid;
+
+ /* Create lockd window data */
+ lockw = (lockw_data *) malloc(sizeof(lockw_data));
+ memset(lockw, 0x0, sizeof(lockw_data));
+ retv_if(!lockw, NULL);
+
+ pid = getpid();
+
+ return lockw;
+}
+
+void lockd_create_ug_window(void *data)
+{
+ lockw_data *lockw = NULL;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockw = (lockw_data *) data;
+ if (!lockw) {
+ return;
+ }
+
+ lockd_destroy_ug_window(lockw);
+
+ /* create main window */
+ lockw->main_win = lockd_create_main_window(PACKAGE);
+
+ /* create main layout */
+ /* remove indicator in running time */
+ /* lockw->main_layout = lockd_create_main_layout(lockw->main_win); */
+ appcore_set_i18n(PACKAGE, NULL);
+ _lockd_ug_window_set_key_grab(lockw);
+ _lockd_ug_window_register_vconf_changed(lockw);
+ lockw->phone_lock_state = 1;
+}
+
+void lockd_destroy_ug_window(void *data)
+{
+ lockw_data *lockw = NULL;
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockw = (lockw_data *) data;
+ if (!lockw) {
+ return;
+ }
+
+ _lockd_ug_window_set_key_ungrab(lockw);
+ _lockd_ug_window_unregister_vconf_changed(lockw);
+
+ if (lockw->main_win) {
+ evas_object_del(lockw->main_win);
+ lockw->main_win = NULL;
+ }
+ lockw->phone_lock_state = 0;
+}
+
+void lockd_show_phonelock_alpha_ug(void *data)
+{
+ lockw_data *lockw = NULL;
+ app_control_h app_control;
+ struct ug_cbs cbs = { 0, };
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ lockw = (lockw_data *) data;
+ if (!lockw) {
+ return;
+ }
+
+ cbs.layout_cb = _lockd_phone_lock_alpha_ug_layout_cb;
+ cbs.result_cb = _lockd_phone_lock_alpha_ug_result_cb;
+ cbs.destroy_cb = _lockd_phone_lock_alpha_ug_destroy_cb;
+ cbs.priv = (void *)data;
+
+ app_control_create(&app_control);
+
+ app_control_add_extra_data(app_control, "phone-lock-type", "phone-lock");
+ app_control_add_extra_data(app_control, "window-type", "alpha");
+
+ elm_win_alpha_set(lockw->main_win, TRUE);
+ evas_object_color_set(lockw->main_win, 0, 0, 0, 0);
+
+ /* window effect : fade in /out */
+ ecore_x_icccm_name_class_set(elm_win_xwindow_get(lockw->main_win),
+ "LOCK_SCREEN", "LOCK_SCREEN");
+
+ UG_INIT_EFL(lockw->main_win, UG_OPT_INDICATOR_ENABLE);
+ ug_create(NULL, "phone-lock-efl", UG_MODE_FULLVIEW, app_control, &cbs);
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ app_control_destroy(app_control);
+
+ LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+ evas_object_show(lockw->main_win);
+ _lockd_ug_window_set_win_prop(lockw, ECORE_X_WINDOW_TYPE_NOTIFICATION);
+}
diff --git a/src/menu_daemon.c b/src/menu_daemon.c
new file mode 100755
index 0000000..be0cc94
--- /dev/null
+++ b/src/menu_daemon.c
@@ -0,0 +1,813 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <ail.h>
+#include <aul.h>
+#include <app.h>
+#include <db-util.h>
+#include <Elementary.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pkgmgr-info.h>
+#include <stdio.h>
+#include <dd-deviced.h>
+#include <syspopup_caller.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <vconf.h>
+//#include <bincfg.h>
+
+#include "hw_key.h"
+#include "util.h"
+//#include "xmonitor.h"
+#include "dbus-util.h"
+
+int errno;
+
+
+#define QUERY_UPDATE_NAME "UPDATE app_info SET name='%s' where package='%s';"
+#define RELAUNCH_INTERVAL 100*1000
+#define RETRY_MAXCOUNT 30
+#if !defined(VCONFKEY_SVOICE_PACKAGE_NAME)
+#define VCONFKEY_SVOICE_PACKAGE_NAME "db/svoice/package_name"
+#endif
+#define HOME_TERMINATED "home_terminated"
+#define ISTRUE "TRUE"
+
+#define RELAUNCH_TASKMGR 0
+
+// Define prototype of the "hidden API of AUL"
+//extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
+
+
+
+static struct info {
+ pid_t home_pid;
+ pid_t tray_pid;
+ pid_t taskmgr_pid;
+ pid_t volume_pid;
+ int safe_mode;
+ int cradle_status;
+ int pm_key_ignore;
+ int power_off;
+ char *svoice_pkg_name;
+ char *taskmgr_pkg_name;
+} s_info = {
+ .home_pid = (pid_t)-1,
+ .tray_pid = (pid_t)-1,
+ .taskmgr_pid = (pid_t)-1,
+ .volume_pid = (pid_t)-1,
+ .safe_mode = -1,
+ .cradle_status = -1,
+ .pm_key_ignore = -1,
+ .power_off = 0,
+ .svoice_pkg_name = NULL,
+ .taskmgr_pkg_name = NULL,
+};
+
+
+
+inline char *menu_daemon_get_selected_pkgname(void)
+{
+ char *pkgname = NULL;
+
+ pkgname = vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME);
+ retv_if(NULL == pkgname, NULL);
+
+ return pkgname;
+}
+
+char *menu_daemon_get_taskmgr_pkgname(void)
+{
+ return s_info.taskmgr_pkg_name;
+}
+
+
+#define VCONFKEY_IDLE_SCREEN_SAFEMODE "memory/idle-screen/safemode"
+int menu_daemon_is_safe_mode(void)
+{
+ if (-1 == s_info.safe_mode) {
+ if (vconf_get_int(VCONFKEY_IDLE_SCREEN_SAFEMODE, &s_info.safe_mode) < 0) {
+ _E("Failed to get safemode info");
+ s_info.safe_mode = 0;
+ }
+ }
+
+ return s_info.safe_mode;
+}
+
+
+
+#define VCONFKEY_SYSMAN_CRADLE_STATUS "memory/sysman/cradle_status"
+int menu_daemon_get_cradle_status(void)
+{
+ if (-1 == s_info.cradle_status) {
+ if (vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &s_info.cradle_status) < 0) {
+ _E("Failed to get cradle status");
+ s_info.cradle_status = 0;
+ }
+ }
+
+ return s_info.cradle_status;
+}
+
+
+
+#define RETRY_COUNT 5
+int menu_daemon_open_app(const char *pkgname)
+{
+ register int i;
+ int r = AUL_R_OK;
+ for (i = 0; i < RETRY_COUNT; i ++) {
+ _D("pkgname: %s", pkgname);
+ r = aul_open_app(pkgname);
+ if (0 <= r) return r;
+ else {
+ _D("aul_open_app error(%d)", r);
+ _F("cannot open an app(%s) by %d", pkgname, r);
+ }
+ usleep(500000);
+ }
+
+ return r;
+}
+
+
+
+int menu_daemon_launch_app(const char *pkgname, bundle *b)
+{
+ register int i;
+ int r = AUL_R_OK;
+ pkgmgrinfo_appinfo_filter_h handle = NULL;
+ bool enabled = false;
+
+ if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(pkgname, &handle)) {
+ _E("Cannot get the pkginfo");
+ return -77;
+ }
+ if (PMINFO_R_OK != pkgmgrinfo_appinfo_is_enabled(handle, &enabled)) {
+ _E("Cannot get if app is enabled or not");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return -77;
+ }
+
+ if (enabled) {
+ for (i = 0; i < RETRY_COUNT; i ++) {
+ r = aul_launch_app(pkgname, b);
+ if (0 <= r){
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return r;
+ }
+ else {
+ _D("aul_launch_app error(%d)", r);
+ _F("cannot launch an app(%s) by %d", pkgname, r);
+ }
+ usleep(500000);
+ }
+ }
+ else {
+ _SECURE_E("%s is disabled, so can't launch this", pkgname);
+ r = -77;
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return r;
+}
+
+
+
+void menu_daemon_launch_app_tray(void)
+{
+ bundle *kb = NULL;
+ char *pkgname = NULL;
+
+ _D("launch App-tray");
+
+ pkgname = menu_daemon_get_selected_pkgname();
+ if (!pkgname)
+ return;
+ _SECURE_D("home pkg_name : %s", pkgname);
+
+ //Check preloaded Homescreen
+ if (!strncmp(pkgname, EASY_HOME_PKG_NAME, strlen(pkgname))) {
+ pkgname = EASY_APPS_PKG_NAME;
+ } else if (!strncmp(pkgname, HOMESCREEN_PKG_NAME, strlen(pkgname))) {
+ pkgname = HOMESCREEN_PKG_NAME;
+ }
+ _SECURE_D("apps pkg_name : %s", pkgname);
+
+
+ kb = bundle_create();
+ bundle_add(kb, "HIDE_LAUNCH", "0");
+ bundle_add(kb, "SHOW_APPS", "TRUE");
+
+ s_info.tray_pid = menu_daemon_launch_app(pkgname, kb);
+ if (s_info.tray_pid < 0) {
+ _SECURE_E("Failed to reset %s", pkgname);
+ } else if (s_info.tray_pid > 0) {
+ if(starter_dbus_set_oomadj(s_info.tray_pid, OOM_ADJ_VALUE_HOMESCREEN) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+
+ bundle_free(kb);
+}
+
+
+
+bool menu_daemon_is_homescreen(pid_t pid)
+{
+ if (s_info.home_pid == pid) return true;
+ return false;
+}
+
+
+
+
+static inline void _hide_launch_task_mgr(void)
+{
+ bundle *kb = NULL;
+
+ _D("Hide to launch Taskmgr");
+ kb = bundle_create();
+ bundle_add(kb, "HIDE_LAUNCH", "1");
+
+ s_info.taskmgr_pid = menu_daemon_launch_app(menu_daemon_get_taskmgr_pkgname(), kb);
+ if (s_info.taskmgr_pid < 0) {
+ _SECURE_E("Failed to reset %s", APP_TRAY_PKG_NAME);
+ } else if (s_info.taskmgr_pid > 0) {
+ if(starter_dbus_set_oomadj(s_info.taskmgr_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+
+ bundle_free(kb);
+}
+
+
+
+static bool _exist_package(char *pkgid)
+{
+ int ret = 0;
+ pkgmgrinfo_appinfo_h handle = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &handle);
+ if (PMINFO_R_OK != ret || NULL == handle) {
+ _SECURE_D("%s doesn't exist in this binary", pkgid);
+ return false;
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return true;
+}
+
+
+
+static void _check_home_screen_package(void)
+{
+ char *pkgname = NULL;
+ pkgname = menu_daemon_get_selected_pkgname();
+ if (pkgname) {
+ _SECURE_D("Selected Home-screen : %s", pkgname);
+ bool is_existed = _exist_package(pkgname);
+ free(pkgname);
+ if (true == is_existed) {
+ return;
+ }
+ }
+
+#if 0 /* Homescreen pkg is changed */
+ if (_exist_package(CLUSTER_HOME_PKG_NAME)) {
+ if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, CLUSTER_HOME_PKG_NAME)) {
+ _SECURE_E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, CLUSTER_HOME_PKG_NAME);
+ } else return;
+ }
+#else
+ if (_exist_package(HOMESCREEN_PKG_NAME)) {
+ if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOMESCREEN_PKG_NAME)) {
+ _SECURE_E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOMESCREEN_PKG_NAME);
+ } else return;
+ }
+#endif
+
+ if (_exist_package(MENU_SCREEN_PKG_NAME)) {
+ if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, MENU_SCREEN_PKG_NAME)) {
+ _SECURE_E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, MENU_SCREEN_PKG_NAME);
+ } else return;
+ }
+ _E("Invalid Homescreen..!!");
+}
+
+
+
+#define SERVICE_OPERATION_MAIN_KEY "__APP_SVC_OP_TYPE__"
+#define SERVICE_OPERATION_MAIN_VALUE "http://tizen.org/appcontrol/operation/main"
+inline int menu_daemon_open_homescreen(const char *pkgname)
+{
+ char *homescreen = NULL;
+ char *tmp = NULL;
+
+// if (bincfg_is_factory_binary() != 1) {
+ if (menu_daemon_is_safe_mode()) {
+ homescreen = HOMESCREEN_PKG_NAME;
+ } else {
+ homescreen = (char *) pkgname;
+ }
+/* } else {
+ homescreen = (char *) pkgname;
+ }
+*/
+ if (!pkgname) {
+ tmp = menu_daemon_get_selected_pkgname();
+ retv_if(NULL == tmp, -1);
+ homescreen = tmp;
+ }
+
+ int ret = -1;
+
+ //Check preloaded Homescreen
+ if (!strncmp(homescreen, HOMESCREEN_PKG_NAME, strlen(homescreen))) {
+ _SECURE_D("Launch %s", homescreen);
+ bundle *b = NULL;
+ b = bundle_create();
+ if (!b) {
+ _E("Failed to create bundle");
+ ret = menu_daemon_open_app(homescreen);
+ while (0 > ret) {
+ _E("Failed to open a default home, %s", homescreen);
+ ret = menu_daemon_open_app(homescreen);
+ }
+ } else {
+ bundle_add(b, SERVICE_OPERATION_MAIN_KEY, SERVICE_OPERATION_MAIN_VALUE);
+ ret = menu_daemon_launch_app(homescreen, b);
+ while (0 > ret) {
+ _E("Failed to launch a default home, %s", homescreen);
+ ret = menu_daemon_launch_app(homescreen, b);
+ }
+ bundle_free(b);
+ }
+ } else {
+ ret = menu_daemon_open_app(homescreen);
+ while (0 > ret) {
+ _E("Failed to open a default home, %s", homescreen);
+ ret = menu_daemon_open_app(homescreen);
+ }
+ }
+#if RELAUNCH_TASKMGR
+ if (s_info.taskmgr_pid < 0) {
+ _hide_launch_task_mgr();
+ }
+#endif
+ s_info.home_pid = ret;
+ if (ret > 0) {
+ if(starter_dbus_set_oomadj(ret, OOM_ADJ_VALUE_HOMESCREEN) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+
+ if (tmp) free(tmp);
+ return ret;
+}
+
+
+#if 0
+inline int menu_daemon_get_pm_key_ignore(int ignore_key)
+{
+ return s_info.pm_key_ignore & ignore_key;
+}
+
+
+inline void menu_daemon_set_pm_key_ignore(int ignore_key, int value)
+{
+ if (value) {
+ s_info.pm_key_ignore |= ignore_key;
+ } else {
+ s_info.pm_key_ignore &= ~ignore_key;
+ }
+
+ if (vconf_set_int(VCONFKEY_PM_KEY_IGNORE, s_info.pm_key_ignore) < 0) {
+ _E("Can't set %s", VCONFKEY_PM_KEY_IGNORE);
+ }
+}
+#endif
+
+
+static void _show_cb(keynode_t* node, void *data)
+{
+ int seq;
+
+ _D("[MENU_DAEMON] _show_cb is invoked");
+
+ if (node) {
+ seq = vconf_keynode_get_int(node);
+ } else {
+ if (vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &seq) < 0) {
+ _E("Failed to get sequence info");
+ return;
+ }
+ }
+
+ switch (seq) {
+ case 0:
+ if (s_info.home_pid > 0) {
+ int pid;
+ _D("pid[%d] is terminated.", s_info.home_pid);
+ pid = s_info.home_pid;
+ s_info.home_pid = -1; /* to freeze the dead_cb */
+ if (aul_terminate_pid(pid) != AUL_R_OK)
+ _E("Failed to terminate %d", s_info.home_pid);
+
+ _D("pid[%d] is terminated.", s_info.taskmgr_pid);
+ pid = s_info.taskmgr_pid;
+ s_info.taskmgr_pid = -1; /* to freeze the dead_cb */
+ if (pid > 0 && aul_terminate_pid(pid) != AUL_R_OK)
+ _E("Failed to terminate %d", s_info.taskmgr_pid);
+ }
+ break;
+ case 1:
+ menu_daemon_open_homescreen(NULL);
+ break;
+ default:
+ _E("False sequence [%d]", seq);
+ break;
+ }
+
+ return;
+}
+
+
+
+static void _font_cb(keynode_t* node, void *data)
+{
+ _D("Font is changed");
+
+ if (AUL_R_OK != aul_terminate_pid(s_info.taskmgr_pid))
+ _E("Cannot terminate Taskmgr");
+}
+
+
+
+static void _cradle_status_cb(keynode_t* node, void *data)
+{
+ if (vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &s_info.cradle_status) < 0) {
+ _E("Failed to get cradle status");
+ s_info.cradle_status = 0;
+ }
+
+ _D("Cradle status is changed to [%d]", s_info.cradle_status);
+}
+
+
+#if 0
+static void _pm_key_ignore_cb(keynode_t* node, void *data)
+{
+ if (vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &s_info.pm_key_ignore) < 0) {
+ _E("Failed to get pm key ignore");
+ s_info.pm_key_ignore= -1;
+ }
+
+ _D("pm key ignore is changed to [%d]", s_info.pm_key_ignore);
+}
+#endif
+
+
+static void _pkg_changed(keynode_t* node, void *data)
+{
+ char *pkgname;
+ int seq;
+
+ if (vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &seq) < 0) {
+ _E("Do nothing, there is no sequence info yet");
+ return;
+ }
+
+ if (seq < 1) {
+ _E("Sequence is not ready yet, do nothing");
+ return;
+ }
+
+ _D("_pkg_changed is invoked");
+
+ _check_home_screen_package();
+
+ pkgname = menu_daemon_get_selected_pkgname();
+ if (!pkgname)
+ return;
+
+ _SECURE_D("pkg_name : %s", pkgname);
+
+ if (s_info.home_pid > 0) {
+ char old_pkgname[256];
+
+ if (aul_app_get_pkgname_bypid(s_info.home_pid, old_pkgname, sizeof(old_pkgname)) == AUL_R_OK) {
+ if (!strcmp(pkgname, old_pkgname)) {
+ _D("Package is changed but same package is selected");
+ free(pkgname);
+ return;
+ }
+ }
+
+ if (AUL_R_OK != aul_terminate_pid(s_info.home_pid))
+ _D("Failed to terminate pid %d", s_info.home_pid);
+ } else {
+ /* If there is no running home */
+ menu_daemon_open_homescreen(pkgname);
+ }
+
+ /* NOTE: Dead callback will catch the termination of a current menuscreen
+ * menu_daemon_open_homescreen(pkgname);
+ */
+ free(pkgname);
+ return;
+}
+
+
+
+static void _launch_volume(void)
+{
+ int pid;
+ int i;
+ _D("_launch_volume");
+
+ for (i=0; i<RETRY_MAXCOUNT; i++)
+ {
+ pid = syspopup_launch("volume", NULL);
+
+ _D("syspopup_launch(volume), pid = %d", pid);
+
+ if (pid <0) {
+ _D("syspopup_launch(volume)is failed [%d]times", i);
+ usleep(RELAUNCH_INTERVAL);
+ } else {
+ s_info.volume_pid = pid;
+ if(starter_dbus_set_oomadj(s_info.volume_pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ return;
+ }
+ }
+}
+
+
+static void _menu_daemon_launch_homescreen(const char *pkgname)
+{
+ char *homescreen = NULL;
+ char *tmp = NULL;
+ bundle *b;
+
+// if (bincfg_is_factory_binary() != 1) {
+ if (menu_daemon_is_safe_mode()) {
+ homescreen = HOMESCREEN_PKG_NAME;
+ } else {
+ homescreen = (char *) pkgname;
+ }
+/* } else {
+ homescreen = (char *) pkgname;
+ }
+*/
+ if (!pkgname) {
+ tmp = menu_daemon_get_selected_pkgname();
+ ret_if(NULL == tmp);
+ homescreen = tmp;
+ }
+
+ int ret = -1;
+ b = bundle_create();
+ bundle_add(b, HOME_TERMINATED, ISTRUE);
+ ret = aul_launch_app(homescreen, b);
+ while (0 > ret) {
+ _E("Failed to open a default home, %s", homescreen);
+ ret = aul_launch_app(homescreen, b);
+ }
+
+ if(b) {
+ bundle_free(b);
+ }
+#if RELAUNCH_TASKMGR
+ if (s_info.taskmgr_pid < 0) {
+ _hide_launch_task_mgr();
+ }
+#endif
+ s_info.home_pid = ret;
+ if (ret > 0) {
+ if(starter_dbus_set_oomadj(ret, OOM_ADJ_VALUE_HOMESCREEN) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+
+ if (tmp) free(tmp);
+}
+
+
+int menu_daemon_check_dead_signal(int pid)
+{
+ char *pkgname;
+
+ _D("Process %d is termianted", pid);
+
+ if (pid < 0) return 0;
+ if (s_info.power_off) return 0;
+
+ pkgname = menu_daemon_get_selected_pkgname();
+ if (!pkgname)
+ return 0;
+
+ if (pid == s_info.home_pid) {
+ /* Relaunch */
+ _SECURE_D("pkg_name : %s", pkgname);
+ //menu_daemon_open_homescreen(pkgname);
+ _menu_daemon_launch_homescreen(pkgname);
+ }
+#if RELAUNCH_TASKMGR
+ else if (pid == s_info.taskmgr_pid) {
+ _hide_launch_task_mgr();
+ }
+#endif
+ else if (pid == s_info.volume_pid) {
+ /* Relaunch */
+ _launch_volume();
+ } else {
+ _D("Unknown process, ignore it (dead pid %d, home pid %d, taskmgr pid %d)",
+ pid, s_info.home_pid, s_info.taskmgr_pid);
+ }
+
+ free(pkgname);
+
+ return 0;
+}
+
+
+int menu_daemon_get_volume_pid(void)
+{
+ return s_info.volume_pid;
+}
+
+
+static void _svoice_pkg_cb(keynode_t* node, void *data)
+{
+ if (s_info.svoice_pkg_name) free(s_info.svoice_pkg_name);
+
+ s_info.svoice_pkg_name = vconf_get_str(VCONFKEY_SVOICE_PACKAGE_NAME);
+ ret_if(NULL == s_info.svoice_pkg_name);
+
+ _SECURE_D("svoice pkg name is changed to [%s]", s_info.svoice_pkg_name);
+}
+
+
+#define SERVICE_OPERATION_POPUP_SEARCH "http://samsung.com/appcontrol/operation/search"
+#define SEARCH_PKG_NAME "com.samsung.sfinder"
+int menu_daemon_launch_search(void)
+{
+ app_control_h app_control;
+ int ret = APP_CONTROL_ERROR_NONE;
+
+ app_control_create(&app_control);
+ app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_app_id(app_control, SEARCH_PKG_NAME);
+
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+
+ if(ret != APP_CONTROL_ERROR_NONE) {
+ _E("Cannot launch search!! err[%d]", ret);
+ }
+
+ app_control_destroy(app_control);
+ return ret;
+}
+
+
+const char *menu_daemon_get_svoice_pkg_name(void)
+{
+ return s_info.svoice_pkg_name;
+}
+
+
+
+static void _power_off_cb(keynode_t* node, void *data)
+{
+ int val = VCONFKEY_SYSMAN_POWER_OFF_NONE;
+ ret_if(vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0);
+
+ if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART) {
+ s_info.power_off = 1;
+ } else s_info.power_off = 0;
+
+ _D("power off status : %d", s_info.power_off);
+}
+
+static Eina_Bool _launch_volume_idler_cb(void *data)
+{
+ _D("%s, %d", __func__, __LINE__);
+ _launch_volume();
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void menu_daemon_init(void *data)
+{
+ bool is_exist = false;
+ _D( "[MENU_DAEMON]menu_daemon_init is invoked");
+
+ aul_launch_init(NULL,NULL);
+
+ _check_home_screen_package();
+
+ create_key_window();
+ //if (xmonitor_init() < 0) _E("cannot init xmonitor");
+
+// _launch_volume();
+
+ is_exist = _exist_package(TASKMGR_PKG_NAME);
+ if(is_exist){
+ s_info.taskmgr_pkg_name = TASKMGR_PKG_NAME;
+ }
+ else{
+ s_info.taskmgr_pkg_name = DEFAULT_TASKMGR_PKG_NAME; /* rsa task manager */
+ }
+
+ if (vconf_notify_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, _pkg_changed, NULL) < 0)
+ _E("Failed to add the callback for package change event");
+
+ if (vconf_notify_key_changed(VCONFKEY_STARTER_SEQUENCE, _show_cb, NULL) < 0)
+ _E("Failed to add the callback for show event");
+
+ if (vconf_notify_key_changed("db/setting/accessibility/font_name", _font_cb, NULL) < 0)
+ _E("Failed to add the callback for font event");
+
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_CRADLE_STATUS, _cradle_status_cb, NULL) < 0)
+ _E("Failed to add the callback for cradle status");
+
+ _D("Cradle status : %d", menu_daemon_get_cradle_status());
+
+#if 0
+ if (vconf_notify_key_changed(VCONFKEY_PM_KEY_IGNORE, _pm_key_ignore_cb, NULL) < 0)
+ _E("Failed to add the callback for pm key ignore");
+ _pm_key_ignore_cb(NULL, NULL);
+#endif
+
+ _pkg_changed(NULL, NULL);
+
+ ecore_idler_add(_launch_volume_idler_cb, NULL);
+
+ if (vconf_notify_key_changed(VCONFKEY_SVOICE_PACKAGE_NAME, _svoice_pkg_cb, NULL) < 0)
+ _E("Failed to add the callback for svoice pkg");
+
+ _svoice_pkg_cb(NULL, NULL);
+
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb, NULL) < 0)
+ _E("Failed to add the callback for power-off");
+
+ // THIS ROUTINE IS FOR SAT.
+ vconf_set_int(VCONFKEY_IDLE_SCREEN_LAUNCHED, VCONFKEY_IDLE_SCREEN_LAUNCHED_TRUE);
+}
+
+
+
+void menu_daemon_fini(void)
+{
+ if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, _pkg_changed) < 0)
+ _E("Failed to ignore the callback for package change event");
+
+ if (vconf_ignore_key_changed(VCONFKEY_STARTER_SEQUENCE, _show_cb) < 0)
+ _E("Failed to ignore the callback for show event");
+
+ if (vconf_ignore_key_changed("db/setting/accessibility/font_name", _font_cb) < 0)
+ _E("Failed to ignore the callback for font event");
+
+ if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_CRADLE_STATUS, _cradle_status_cb) < 0)
+ _E("Failed to ignore the callback for cradle status");
+
+#if 0
+ if (vconf_ignore_key_changed(VCONFKEY_PM_KEY_IGNORE, _pm_key_ignore_cb) < 0)
+ _E("Failed to ignore the callback for pm key ignore");
+#endif
+
+ if (vconf_ignore_key_changed(VCONFKEY_SVOICE_PACKAGE_NAME, _svoice_pkg_cb) < 0)
+ _E("Failed to ignore the callback for svoice pkg");
+ if (s_info.svoice_pkg_name) free(s_info.svoice_pkg_name);
+
+ if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb) < 0)
+ _E("Failed to ignore the callback for power-off");
+
+ //xmonitor_fini();
+ destroy_key_window();
+}
+
+
+
+// End of a file
diff --git a/src/pkg_event.c b/src/pkg_event.c
new file mode 100755
index 0000000..0a64238
--- /dev/null
+++ b/src/pkg_event.c
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <ail.h>
+#include <errno.h>
+#include <Elementary.h>
+#include <Ecore.h>
+#include <Ecore_File.h>
+#include <stdio.h>
+#include <sys/inotify.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <vconf.h>
+
+#include "pkg_event.h"
+#include "util.h"
+
+
+#define CONF_FILE "/usr/share/install-info/desktop.conf"
+#define BUFSZE 1024
+
+
+extern int errno;
+struct inotify_path
+{
+ int wd;
+ char *path;
+};
+
+struct desktop_notifier s_desktop_notifier = {
+ .number = 0,
+ .ifd = 0,
+ .handler = NULL,
+};
+
+
+
+struct inotify_path paths[CONF_PATH_NUMBER];
+
+
+static Eina_Bool
+directory_notify(void* data, Ecore_Fd_Handler* fd_handler)
+{
+ char *buf;
+ ssize_t read_size, len, i = 0;
+ int fd;
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ _D("There are some modification, ifd [%d]", fd);
+ if(fd < 0) {
+ _E("Failed to get fd");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (ioctl(fd, FIONREAD, &read_size) < 0) {
+ _E("Failed to get q size");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (read_size <= 0) {
+ _E("Buffer is not ready!!!");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ buf = malloc(read_size);
+ if (!buf) {
+ _E("Failed to allocate heap for event handling");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ memset(buf, 0, read_size);
+
+ len = read(fd, buf, read_size);
+ if (len < 0) {
+ free(buf);
+ // Stop monitoring about this invalid file descriptor
+ return ECORE_CALLBACK_CANCEL;
+ }
+ buf[read_size - 1] = '\0';
+
+ while (i < len) {
+ struct inotify_event* event = (struct inotify_event*) &buf[i];
+ char *str_potksed = "potksed.";
+ char *package = NULL;
+ ssize_t idx;
+ int nev_name;
+
+ // 1. check the extension of a file
+ nev_name = strlen(event->name) - 1;
+ for (idx = 0; nev_name >= 0 && str_potksed[idx]; idx++) {
+ if (event->name[nev_name] != str_potksed[idx]) {
+ break;
+ }
+ nev_name --;
+ }
+
+ if (str_potksed[idx] != '\0' || nev_name < 0) {
+ _SECURE_D("This is not a desktop file : %s", event->name);
+ i += sizeof(struct inotify_event) + event->len;
+ continue;
+ }
+
+ package = strdup(event->name);
+ break_if(NULL == package);
+
+ package[nev_name + 1] = '\0';
+ _SECURE_D("Package : %s", package);
+
+ // add & update
+ if (event->mask & IN_CLOSE_WRITE || event->mask & IN_MOVED_TO) { // for moving
+ ail_appinfo_h ai = NULL;
+ ail_error_e ret;
+
+ ret = ail_get_appinfo(package, &ai);
+ if (AIL_ERROR_OK == ret || AIL_ERROR_NO_DATA == ret) {
+ if (ai) ail_destroy_appinfo(ai);
+
+ if (AIL_ERROR_NO_DATA == ret) {
+ if (ail_desktop_add(package) < 0) {
+ _SECURE_D("Failed to add a new package (%s)", event->name);
+ }
+ } else if (AIL_ERROR_OK == ret) {
+ if (ail_desktop_update(package) < 0) {
+ _SECURE_D("Failed to add a new package (%s)", event->name);
+ }
+ }
+ } else {
+ _E("Failed to get appinfo");
+ }
+ } else if (event->mask & IN_DELETE) { // for deleting
+ if (ail_desktop_remove(package) < 0)
+ _SECURE_D("Failed to remove a package (%s)", event->name);
+ } else {
+ _D("this event is not dealt with inotify");
+ }
+
+ free(package);
+
+ i += sizeof(struct inotify_event) + event->len;
+ }
+
+ free(buf);
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+static inline char *_ltrim(char *str)
+{
+ retv_if(NULL == str, NULL);
+ while (*str && (*str == ' ' || *str == '\t' || *str == '\n')) str ++;
+ return str;
+}
+
+
+
+static inline int _rtrim(char *str)
+{
+ int len;
+
+ retv_if(NULL == str, 0);
+
+ len = strlen(str);
+ while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) {
+ str[len] = '\0';
+ }
+
+ return len;
+}
+
+
+
+static int _retrieve_conf_path(struct inotify_path* paths)
+{
+ char *line = NULL;
+ FILE *fp;
+ size_t size = 0;
+ ssize_t read;
+ int i = 0;
+
+ fp = fopen(CONF_FILE, "r");
+ if (NULL == fp) {
+ _E(CONF_FILE);
+ return -1;
+ }
+
+ while ((read = getline(&line, &size, fp)) != -1 && i < CONF_PATH_NUMBER - 1) {
+ char *begin;
+
+ if (size <= 0) break;
+
+ begin = _ltrim(line);
+ _rtrim(line);
+
+ if (*begin == '#' || *begin == '\0') continue;
+
+ paths[i].path = strdup(begin);
+ i++;
+ }
+
+ if (line) free(line);
+ paths[i].path = NULL;
+ fclose(fp);
+
+ return i;
+}
+
+
+
+static void _unretrieve_conf_path(struct inotify_path* paths, int number)
+{
+ register int i;
+
+ for (i = 0; i < number; i ++) {
+ if (paths[i].path) {
+ free(paths[i].path);
+ paths[i].path = NULL;
+ }
+ }
+}
+
+
+
+void pkg_event_init()
+{
+ int wd = 0;
+ int i;
+ char buf[1024] = { 0, };
+
+ s_desktop_notifier.ifd = inotify_init();
+ if (s_desktop_notifier.ifd == -1) {
+ _E("inotify_init error: %s", strerror_r(errno, buf, sizeof(buf)));
+ return;
+ }
+
+ s_desktop_notifier.number = _retrieve_conf_path(paths);
+
+ for (i = 0; i < CONF_PATH_NUMBER && paths[i].path; i++)
+ {
+ _D("Configuration file for desktop file monitoring [%s] is added", paths[i].path);
+ if (access(paths[i].path, R_OK) != 0)
+ {
+ ecore_file_mkpath(paths[i].path);
+ if (chmod(paths[i].path, 0777) == -1) {
+ _E("cannot chmod %s", paths[i].path);
+ }
+ }
+
+ wd = inotify_add_watch(s_desktop_notifier.ifd, paths[i].path, IN_CLOSE_WRITE | IN_MOVED_TO | IN_DELETE);
+ if (wd == -1) {
+ _E("inotify_add_watch error: %s", strerror_r(errno, buf, sizeof(buf)));
+ close(s_desktop_notifier.ifd);
+ return;
+ }
+
+ paths[i].wd = wd;
+ }
+
+ s_desktop_notifier.handler = ecore_main_fd_handler_add(s_desktop_notifier.ifd, ECORE_FD_READ, directory_notify, NULL, NULL, NULL);
+ if (!s_desktop_notifier.handler) {
+ // TODO: Handles me.. EXCEPTION!!
+ _E("cannot add handler for inotify");
+ }
+}
+
+
+
+void pkg_event_fini(void)
+{
+ register int i;
+ char buf[1024] = { 0 , };
+
+ if (s_desktop_notifier.handler) {
+ ecore_main_fd_handler_del(s_desktop_notifier.handler);
+ }
+
+ for (i = 0; i < CONF_PATH_NUMBER; i ++) {
+ if (paths[i].wd) {
+ if (inotify_rm_watch(s_desktop_notifier.ifd, paths[i].wd) < 0) {
+ _E("Error: %s", strerror_r(errno, buf, sizeof(buf)));
+ }
+ paths[i].wd = 0;
+ }
+ }
+
+ _unretrieve_conf_path(paths, s_desktop_notifier.number);
+
+ if (s_desktop_notifier.ifd) {
+ close(s_desktop_notifier.ifd);
+ s_desktop_notifier.ifd = 0;
+ }
+}
+
+
+// End of a file
diff --git a/src/starter.c b/src/starter.c
new file mode 100755
index 0000000..061c3cb
--- /dev/null
+++ b/src/starter.c
@@ -0,0 +1,594 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <poll.h>
+
+#include <aul.h>
+#include <vconf.h>
+#include <signal.h>
+
+#include "starter.h"
+#include "starter-util.h"
+#include "x11.h"
+#include "lock-daemon.h"
+#include "lockd-debug.h"
+#include "menu_daemon.h"
+
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME "com.samsung.starter"
+#endif
+
+#define DEFAULT_THEME "tizen"
+#define PWLOCK_PATH "/usr/apps/com.samsung.pwlock/bin/pwlock"
+#define PWLOCK_PKG_NAME "com.samsung.pwlock"
+#define PWLOCK_LITE_PKG_NAME "com.samsung.pwlock-lite"
+
+#define DATA_UNENCRYPTED "unencrypted"
+#define DATA_MOUNTED "mounted"
+#define SD_DATA_ENCRYPTED "encrypted"
+#define SD_CRYPT_META_FILE ".MetaEcfsFile"
+#define MMC_MOUNT_POINT "/opt/storage/sdcard"
+
+#ifdef FEATURE_LITE
+#define _FIRST_HOME 1
+#else
+#define _FIRST_HOME 1
+#endif
+
+static int _check_encrypt_sdcard()
+{
+ const char *crypt_file = SD_CRYPT_META_FILE;
+ char *meta_data_file = NULL;
+ int ret = -1;
+ int length = 0;
+
+ length = strlen(MMC_MOUNT_POINT) + strlen(crypt_file) + 2;
+
+ meta_data_file = malloc(length);
+ if (!meta_data_file) {
+ _DBG("malloc error");
+ return -1;
+ }
+
+ snprintf(meta_data_file, length, "%s/%s", MMC_MOUNT_POINT, crypt_file);
+ if (access(meta_data_file, F_OK) == 0) {
+ ret = 0;
+ }
+ free(meta_data_file);
+
+ _DBG("Check sd card ecryption : %d", ret);
+
+ return ret;
+}
+
+static void lock_menu_screen(void)
+{
+ vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 0);
+}
+
+static void unlock_menu_screen(void)
+{
+ int r;
+ int show_menu;
+
+ show_menu = 0;
+ r = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &show_menu);
+ if (r || !show_menu) {
+ vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 1);
+ }
+}
+
+static void _set_elm_theme(void)
+{
+ char *vstr;
+ char *theme;
+ Elm_Theme *th = NULL;
+ vstr = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
+ if (vstr == NULL)
+ theme = DEFAULT_THEME;
+ else
+ theme = vstr;
+
+ th = elm_theme_new();
+ _DBG("theme vconf[%s]\n set[%s]\n", vstr, theme);
+ elm_theme_set(th, theme);
+
+ if (vstr)
+ free(vstr);
+}
+
+#if 0
+static void _set_elm_entry(void)
+{
+ int v;
+ int r;
+
+ r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOCAPITAL_ALLOW_BOOL, &v);
+ if (!r) {
+ prop_int_set("ENLIGHTENMENT_AUTOCAPITAL_ALLOW", v);
+ _DBG("vconf autocatipal[%d]", v);
+ }
+
+ r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOPERIOD_ALLOW_BOOL, &v);
+ if (!r) {
+ prop_int_set("ENLIGHTENMENT_AUTOPERIOD_ALLOW", v);
+ _DBG("vconf autoperiod[%d]", v);
+ }
+}
+#endif
+
+static int _launch_pwlock(void)
+{
+ int r;
+ //int i = 0;
+
+ _DBG("%s", __func__);
+
+#ifdef FEATURE_LITE
+ r = aul_launch_app(PWLOCK_LITE_PKG_NAME, NULL);
+ if (r < 0) {
+ _ERR("PWLock launch error: error(%d)", r);
+ if (r == AUL_R_ETIMEOUT) {
+ _DBG("Launch pwlock is failed for AUL_R_ETIMEOUT, again launch pwlock-lite");
+ r = aul_launch_app(PWLOCK_LITE_PKG_NAME, NULL);
+ if (r < 0) {
+ _ERR("2'nd PWLock launch error: error(%d)", r);
+ return -1;
+ } else {
+ _DBG("Launch pwlock-lite");
+ return r;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ _DBG("Launch pwlock-lite");
+ return r;
+ }
+#else
+ r = aul_launch_app(PWLOCK_LITE_PKG_NAME, NULL);
+ if (r < 0) {
+ _ERR("PWLock launch error: error(%d)", r);
+ if (r == AUL_R_ETIMEOUT) {
+ _DBG("Launch pwlock is failed for AUL_R_ETIMEOUT, again launch pwlock");
+ r = aul_launch_app(PWLOCK_LITE_PKG_NAME, NULL);
+ if (r < 0) {
+ _ERR("2'nd PWLock launch error: error(%d)", r);
+ return -1;
+ } else {
+ _DBG("Launch pwlock");
+ return r;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ _DBG("Launch pwlock");
+ return r;
+ }
+#endif
+#if 0
+ retry_con:
+ r = aul_launch_app("com.samsung.pwlock", NULL);
+ if (r < 0) {
+ _ERR("PWLock launch error: error(%d)", r);
+ if (r == AUL_R_ETIMEOUT) {
+ i++;
+ _DBG("Launching pwlock is failed [%d]times for AUL_R_ETIMEOUT ", i);
+ goto retry_con;
+ } else {
+ return -1;
+ }
+ } else {
+ _DBG("Launch pwlock");
+ return 0;
+ }
+#endif
+}
+
+static void _signal_handler(int signum, siginfo_t *info, void *unused)
+{
+ _DBG("_signal_handler : Terminated...");
+ elm_exit();
+}
+
+#if 0
+static void _heynoti_event_power_off(void *data)
+{
+ _DBG("_heynoti_event_power_off : Terminated...");
+ elm_exit();
+}
+#endif
+
+static void _poweroff_control_cb(keynode_t *in_key, void *data)
+{
+ int val;
+ if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) == 0 &&
+ (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART)) {
+ _DBG("_poweroff_control_cb : Terminated...");
+ elm_exit();
+ }
+}
+
+#define APP_ID_SPLIT_LAUNCHER "com.samsung.split-launcher"
+static Eina_Bool _fini_boot(void *data)
+{
+ _DBG("%s %d\n", __func__, __LINE__);
+
+ int multiwindow_enabled = 0;
+ int val = 0;
+
+ if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) {
+ _ERR("Failed to set boot animation finished set");
+ }
+
+ if (vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &multiwindow_enabled) < 0) {
+ _ERR("Cannot get VCONFKEY");
+ multiwindow_enabled = 0;
+ }
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &val) < 0) {
+ _DBG("Cannot get VCONFKEY");
+ val = 0;
+ }
+
+ if ((val == 1) || (multiwindow_enabled == 0)) {
+ _DBG("TTS : %d, Multiwindow enabled : %d", val, multiwindow_enabled);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ _DBG("Launch the split-launcher");
+
+ int ret = aul_launch_app(APP_ID_SPLIT_LAUNCHER, NULL);
+ if (0 > ret) _ERR("cannot launch the split-launcher (%d)", ret);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _init_idle(void *data)
+{
+ _DBG("%s %d\n", __func__, __LINE__);
+ int pwlock_pid = 0;
+ if ((pwlock_pid = _launch_pwlock()) < 0) {
+ _ERR("launch pwlock error");
+ }
+ else{
+ lockd_process_mgr_set_pwlock_priority(pwlock_pid);
+ }
+ _fini_boot(NULL);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _lock_state_cb(keynode_t * node, void *data)
+{
+ _DBG("%s %d\n", __func__, __LINE__);
+#if 0
+ if (_launch_pwlock() < 0) {
+ _ERR("launch pwlock error");
+ }
+ menu_daemon_init(NULL);
+#else
+ _fini_boot(NULL);
+#endif
+ if (vconf_ignore_key_changed(VCONFKEY_IDLE_LOCK_STATE,
+ _lock_state_cb) != 0) {
+ LOCKD_DBG("Fail to unregister");
+ }
+}
+
+static Eina_Bool _init_lock_lite(void *data)
+{
+ char *file = NULL;
+ int pwlock_pid = 0;
+
+ _DBG("%s %d\n", __func__, __LINE__);
+
+ /* Check SD card encription */
+ file = vconf_get_str(VCONFKEY_SDE_CRYPTO_STATE);
+ if (file && !strncmp(SD_DATA_ENCRYPTED, file, strlen(file)) && _check_encrypt_sdcard() == 0) {
+ _ERR("SD card is encripted");
+ if (start_lock_daemon_lite(FALSE, FALSE) == 1) {
+ if ((pwlock_pid = _launch_pwlock()) < 0) {
+ _ERR("launch pwlock error");
+ }
+ else{
+ lockd_process_mgr_set_pwlock_priority(pwlock_pid);
+ }
+ ecore_timer_add(0.5, _fini_boot, NULL);
+ } else {
+ _init_idle(NULL);
+ }
+ } else {
+ if (start_lock_daemon_lite(TRUE, FALSE) == 1) {
+ if ((pwlock_pid = _launch_pwlock()) < 0) {
+ _ERR("launch pwlock error");
+ }
+ else{
+ lockd_process_mgr_set_pwlock_priority(pwlock_pid);
+ }
+ if (vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE,
+ _lock_state_cb, NULL) != 0) {
+ _ERR("[Error] vconf notify : lock state");
+ ecore_timer_add(0.5, _fini_boot, NULL);
+ }
+ } else {
+ _init_idle(NULL);
+ }
+ }
+ free(file);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _init_lock(void *data)
+{
+ char *file = NULL;
+
+ _DBG("%s %d\n", __func__, __LINE__);
+
+ /* Check SD card encription */
+ file = vconf_get_str(VCONFKEY_SDE_CRYPTO_STATE);
+ if (file && !strncmp(SD_DATA_ENCRYPTED, file, strlen(file)) && _check_encrypt_sdcard() == 0) {
+ _ERR("SD card is encripted");
+ if (start_lock_daemon(FALSE, FALSE) == 1) {
+ if (_launch_pwlock() < 0) {
+ _ERR("launch pwlock error");
+ }
+ ecore_timer_add(0.5, _fini_boot, NULL);
+ } else {
+ _init_idle(NULL);
+ }
+ } else {
+ if (start_lock_daemon(TRUE, FALSE) == 1) {
+ if (_launch_pwlock() < 0) {
+ _ERR("launch pwlock error");
+ }
+ if (vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE,
+ _lock_state_cb, NULL) != 0) {
+ _ERR("[Error] vconf notify : lock state");
+ ecore_timer_add(0.5, _fini_boot, NULL);
+ }
+ } else {
+ _init_idle(NULL);
+ }
+ }
+ free(file);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _data_encryption_cb(keynode_t * node, void *data)
+{
+ char *file = NULL;
+
+ _DBG("%s %d\n", __func__, __LINE__);
+
+ file = vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
+ if (file != NULL) {
+ _DBG("get VCONFKEY : %s\n", file);
+ if (!strcmp(file, DATA_MOUNTED)) {
+#ifdef FEATURE_LITE
+ start_lock_daemon_lite(FALSE, FALSE);
+#else
+ start_lock_daemon(FALSE, FALSE);
+#endif
+ menu_daemon_init(NULL);
+ }
+ free(file);
+ }
+}
+
+static Eina_Bool _start_sequence_cb(void *data)
+{
+ _DBG("%s, %d", __func__, __LINE__);
+
+ unlock_menu_screen();
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _init(struct appdata *ad)
+{
+ int r;
+ struct sigaction act;
+ char *file = NULL;
+ int first = -1;
+ int pwlock_pid = 0;
+
+ memset(&act,0x00,sizeof(struct sigaction));
+ act.sa_sigaction = _signal_handler;
+ act.sa_flags = SA_SIGINFO;
+
+ int ret = sigemptyset(&act.sa_mask);
+ if (ret < 0) {
+ _ERR("Failed to sigemptyset[%s]", strerror(errno));
+ }
+ ret = sigaddset(&act.sa_mask, SIGTERM);
+ if (ret < 0) {
+ _ERR("Failed to sigaddset[%s]", strerror(errno));
+ }
+ ret = sigaction(SIGTERM, &act, NULL);
+ if (ret < 0) {
+ _ERR("Failed to sigaction[%s]", strerror(errno));
+ }
+
+ memset(ad, 0, sizeof(struct appdata));
+
+ gettimeofday(&ad->tv_start, NULL);
+
+/* if (bincfg_is_factory_binary() == 1) {
+ _DBG("Factory binary..!!");
+ _set_elm_theme();
+ unlock_menu_screen();
+ menu_daemon_init(NULL);
+ } else {
+*/ _DBG("%s %d\n", __func__, __LINE__);
+ lock_menu_screen();
+ _set_elm_theme();
+
+ /* Check data encrption */
+ file = vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
+ if (file != NULL) {
+ _DBG("get VCONFKEY : %s\n", file);
+ if (strncmp(DATA_UNENCRYPTED, file, strlen(file))) {
+ if (vconf_notify_key_changed(VCONFKEY_ODE_CRYPTO_STATE,
+ _data_encryption_cb, NULL) != 0) {
+ _ERR("[Error] vconf notify changed is failed: %s", VCONFKEY_ODE_CRYPTO_STATE);
+ } else {
+ _DBG("waiting mount..!!");
+ if ((pwlock_pid = _launch_pwlock()) < 0) {
+ _ERR("launch pwlock error");
+ }
+ else{
+ lockd_process_mgr_set_pwlock_priority(pwlock_pid);
+ }
+ free(file);
+ return;
+ }
+ }
+ free(file);
+ }
+
+#if 0
+ r = start_lock_daemon(TRUE);
+ if (r == 1) {
+ if (vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE,
+ _lock_state_cb, NULL) != 0) {
+ _ERR("[Error] vconf notify : lock state");
+ ecore_timer_add(1.5, _init_idle, NULL);
+ }
+ } else {
+ if (_launch_pwlock() < 0) {
+ _ERR("launch pwlock error");
+ }
+ menu_daemon_init(NULL);
+ }
+#else
+
+ r = vconf_get_bool(VCONFKEY_PWLOCK_FIRST_BOOT, &first);
+ _ERR("vconf get First boot result:%d, get_value:%d", r, first);
+ if (r == 0 && first == 0){
+ _DBG("Not first booting time");
+
+#if (!_FIRST_HOME)
+ _DBG("Not First home");
+ unlock_menu_screen();
+ menu_daemon_init(NULL);
+#ifdef FEATURE_LITE
+ _init_lock_lite(NULL);
+#else
+ _init_lock(NULL);
+#endif
+#else //_FIRST_HOME
+ _DBG("First home");
+#ifdef FEATURE_LITE
+ _init_lock_lite(NULL);
+#else
+ _init_lock(NULL);
+#endif
+ menu_daemon_init(NULL);
+ ecore_idler_add(_start_sequence_cb, NULL);
+#endif
+ } else {
+ _ERR("First booting time");
+ menu_daemon_init(NULL);
+#ifdef FEATURE_LITE
+ r = start_lock_daemon_lite(TRUE, TRUE);
+#else
+ r = start_lock_daemon(TRUE, TRUE);
+#endif
+ _DBG("start_lock_daemon ret:%d", r);
+ if ((pwlock_pid = _launch_pwlock()) < 0) {
+ _ERR("launch pwlock error");
+ if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) {
+ _ERR("Failed to set boot animation finished set");
+ }
+ unlock_menu_screen();
+ } else {
+ lockd_process_mgr_set_pwlock_priority(pwlock_pid);
+ ecore_timer_add(1, _fini_boot, NULL);
+ }
+ }
+#endif
+// }
+}
+
+static void _fini(struct appdata *ad)
+{
+ struct timeval tv, res;
+
+ if (ad == NULL) {
+ fprintf(stderr, "Invalid argument: appdata is NULL\n");
+ return;
+ }
+
+ unlock_menu_screen();
+ menu_daemon_fini();
+
+ gettimeofday(&tv, NULL);
+ timersub(&tv, &ad->tv_start, &res);
+ _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
+}
+
+int main(int argc, char *argv[])
+{
+ struct appdata ad;
+
+ _DBG("starter is launched..!!");
+#if 0
+ set_window_scale(); /* not in loop */
+#endif
+
+#if 0
+ int heyfd = heynoti_init();
+ if (heyfd < 0) {
+ _ERR("Failed to heynoti_init[%d]", heyfd);
+ return -1;
+ }
+
+ int ret = heynoti_subscribe(heyfd, "power_off_start", _heynoti_event_power_off, NULL);
+ if (ret < 0) {
+ _ERR("Failed to heynoti_subscribe[%d]", ret);
+ }
+ ret = heynoti_attach_handler(heyfd);
+ if (ret < 0) {
+ _ERR("Failed to heynoti_attach_handler[%d]", ret);
+ }
+#else
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void *)_poweroff_control_cb, NULL) < 0) {
+ _ERR("Vconf notify key chaneged failed: VCONFKEY_SYSMAN_POWER_OFF_STATUS");
+ }
+#endif
+
+ elm_init(argc, argv);
+
+ _init(&ad);
+
+ elm_run();
+
+ _fini(&ad);
+
+ elm_shutdown();
+
+ return 0;
+}
diff --git a/src/starter_w.c b/src/starter_w.c
new file mode 100755
index 0000000..3b0d4fd
--- /dev/null
+++ b/src/starter_w.c
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. 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 <Elementary.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <poll.h>
+#include <errno.h>
+#include <string.h>
+#include <glib.h>
+
+#include <vconf.h>
+#include <signal.h>
+
+#include <dd-deviced.h>
+
+#include "starter_w.h"
+#include "starter-util.h"
+#include "x11.h"
+#include "lockd-debug.h"
+#include "hw_key_w.h"
+#include "util.h"
+
+int errno;
+
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME "com.samsung.starter"
+#endif
+
+#define DEFAULT_THEME "tizen"
+
+#define W_LOCKSCREEN_PKGNAME "com.samsung.w-lockscreen"
+#define REMOTE_LOCK_PKGNAME "com.samsung.wfmw-remote-lock"
+
+#ifdef FEATURE_TIZENW2
+#define SETUP_WIZARD_PKGNAME "com.samsung.b2-setup-wizard"
+#else
+#define SETUP_WIZARD_PKGNAME "com.samsung.b2-setup-wizard"
+#endif
+#define PWLOCK_PKGNAME "com.samsung.b2-pwlock"
+
+#define NOTIFICATION_APP_PKGNAME "com.samsung.idle-noti-drawer"
+
+#define FACTORY_TDF_NOTIFIER_PATH "/csa/factory/cblkftdf"
+
+#define VCONFKEY_BT_CONNECTED "memory/private/sap/conn_type"
+
+#define VCONFKEY_REMOTE_LOCK_ISLOCKED "db/private/com.samsung.wfmw/is_locked"
+
+static struct appdata *g_app_data = NULL;
+
+void *starter_get_app_data(void){
+ return g_app_data;
+}
+
+
+static void _signal_handler(int signum, siginfo_t *info, void *unused)
+{
+ _DBG("_signal_handler : Terminated...");
+ elm_exit();
+}
+
+int w_open_app(char *pkgname)
+{
+ int r = AUL_R_OK;
+
+ _SECURE_D("w_open_app:[%s]", pkgname);
+
+ r = aul_open_app(pkgname);
+
+ if (r < 0) {
+ _ERR("open app failed [%s] ret=[%d]", pkgname, r);
+ }
+
+ return r;
+}
+
+int w_launch_app(char *pkgname, bundle *b)
+{
+ int r = AUL_R_OK;
+
+ _SECURE_D("w_launch_app:[%s]", pkgname);
+
+ r = aul_launch_app(pkgname, b);
+
+ if (r < 0) {
+ _ERR("launch failed [%s] ret=[%d]", pkgname, r);
+ }
+
+ return r;
+}
+
+#define RETRY_CNT 5
+static Eina_Bool _w_retry_idler_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ ad->retry_cnt++;
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ else{
+ if(ad->retry_cnt >= RETRY_CNT){
+ ad->retry_cnt = 0;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ else{
+ return ECORE_CALLBACK_RENEW;
+ }
+ }
+ ad->retry_cnt = 0;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _w_retry_idler_first_launch_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ bundle *b;
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ bundle_add(b, "home_op", "first_boot");
+
+ ad->retry_cnt++;
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, b);
+
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ else{
+ if(ad->retry_cnt >= RETRY_CNT){
+ ad->retry_cnt = 0;
+ bundle_free(b);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ else{
+ bundle_free(b);
+ return ECORE_CALLBACK_RENEW;
+ }
+ }
+ ad->retry_cnt = 0;
+ bundle_free(b);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static int _w_app_dead_cb(int pid, void *data)
+{
+ _DBG("app dead cb call! (pid : %d)", pid);
+
+ struct appdata *ad = (struct appdata *)data;
+
+ if (pid == ad->launcher_pid) {
+ _ERR("w-launcher-app (pid:%d) is destroyed.", pid);
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ else{
+ _ERR("Launch Home failed.");
+ ecore_idler_add(_w_retry_idler_cb, ad);
+ }
+ } else if (pid == ad->pid_clock_viewer) {
+ _ERR("w-clock-viewer (pid:%d) is destroyed.", pid);
+ int ambient_mode = 0;
+ if (vconf_get_bool(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, &ambient_mode) < 0) {
+ _E("Failed to get vconfkey : %s", VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL);
+ ambient_mode = 0;
+ }
+
+ if (ambient_mode) {
+ ad->pid_clock_viewer = w_launch_app(W_CLOCK_VIEWER_PKGNAME, NULL);
+ }
+ }
+
+ return 0;
+}
+
+static int _w_check_first_boot(void)
+{
+ int is_first = 0;
+ int ret = 0;
+
+#if 1 // NOT YET define vconfkey from setting "VCONFKEY_SETUP_WIZARD_FIRST_BOOT"
+ ret = vconf_get_bool(VCONFKEY_SETUP_WIZARD_FIRST_BOOT, &is_first);
+ if (ret < 0){
+ _ERR("can't get vconfkey value of [%s], ret=[%d]", VCONFKEY_SETUP_WIZARD_FIRST_BOOT, ret);
+ is_first = 0;
+ } else if (is_first == 1) {
+ _ERR("[%s] value is [%d], first booting..!!", VCONFKEY_SETUP_WIZARD_FIRST_BOOT, is_first);
+ }
+#endif
+
+ return is_first;
+}
+
+static Eina_Bool _w_starter_idler_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ else{
+ _ERR("Launch Home failed.");
+ ecore_idler_add(_w_retry_idler_cb, ad);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool _w_starter_lockscreen_idler_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ w_launch_app(W_LOCKSCREEN_PKGNAME, NULL);
+
+ if (ad->first_boot == FALSE)
+ ecore_idler_add(_w_starter_idler_cb, ad);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+#define TEMP_VCONFKEY_LOCK_TYPE "db/setting/lock_type"
+static void _w_BT_changed_cb(keynode_t* node, void *data)
+{
+ int bt_state = -1;
+ int lock_type = -1;
+ int test_mode = -1;
+ struct appdata *ad = (struct appdata *)data;
+
+ _DBG("%s, %d", __func__, __LINE__);
+
+ if (node) {
+ bt_state = vconf_keynode_get_int(node);
+ } else {
+ if (vconf_get_int(VCONFKEY_BT_CONNECTED, &bt_state) < 0) {
+ _ERR("Failed to get %s", VCONFKEY_BT_CONNECTED);
+ return;
+ }
+ }
+ _DBG("WMS key value:[%d], previous state:[%d]", bt_state, ad->bt_connected);
+
+ vconf_get_int(TEMP_VCONFKEY_LOCK_TYPE, &lock_type);
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+
+ if ((lock_type != 1) || (test_mode == VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE)) {
+ ad->bt_connected = bt_state;
+ return;
+ }
+
+ if (bt_state == FALSE) {
+ if (ad->bt_connected == TRUE) {
+ _ERR("BT connect state is changed from [%d] to [%d]", ad->bt_connected, bt_state);
+ w_launch_app(W_LOCKSCREEN_PKGNAME, NULL);
+ }
+ }
+ ad->bt_connected = bt_state;
+
+ return;
+}
+
+static void _w_power_off_cb(keynode_t* node, void *data)
+{
+ int val = VCONFKEY_SYSMAN_POWER_OFF_NONE;
+
+ vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val);
+
+ if (val > VCONFKEY_SYSMAN_POWER_OFF_POPUP) {
+ _ERR("power off status : %d", val);
+ if (vconf_ignore_key_changed(VCONFKEY_BT_CONNECTED, _w_BT_changed_cb) < 0)
+ _ERR("Failed to ignore the callback for [%s]", VCONFKEY_BT_CONNECTED);
+ exit(0);
+ }
+}
+
+static void _w_lang_changed_cb(keynode_t* node, void *data)
+{
+ char *locale = NULL;
+ _DBG("%s, %d", __func__, __LINE__);
+
+ locale = vconf_get_str(VCONFKEY_LANGSET);
+
+ if (locale != NULL) {
+ elm_language_set(locale);
+ }
+}
+
+
+static void _launch_home_cb(keynode_t* node, void *data)
+{
+ int seq;
+ struct appdata *ad = (struct appdata *)data;
+ bundle *b = NULL;
+
+ if (node) {
+ seq = vconf_keynode_get_int(node);
+ } else {
+ if (vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &seq) < 0) {
+ _E("Failed to get sequence info");
+ return;
+ }
+ }
+
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return;
+ }
+ bundle_add(b, "home_op", "first_boot");
+
+ _DBG("_launch_home_cb, seq=%d", seq);
+ if (seq == 1) {
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, b);
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ } else{
+ _ERR("Launch Home failed.");
+ ecore_idler_add(_w_retry_idler_first_launch_cb, ad);
+ }
+ }
+
+ create_key_window(ad->home_pkgname, ad);
+ bundle_free(b);
+}
+
+static void _ambient_mode_event_add(void *data)
+{
+ _DBG("%s", __func__);
+
+ int ambient_mode = 0;
+ struct appdata *ad = (struct appdata *)data;
+ ret_if(!ad);
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, &ambient_mode) < 0) {
+ _E("Failed to get vconfkey : %s", VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL);
+ ambient_mode = 0;
+ }
+
+ if (ambient_mode) {
+ ad->pid_clock_viewer = w_launch_app(W_CLOCK_VIEWER_PKGNAME, NULL);
+ }
+}
+
+static void _init(struct appdata *ad)
+{
+ int r;
+ struct sigaction act;
+ char *file = NULL;
+ int first = -1;
+ int lock_type = -1;
+ int bt_state = -1;
+ int test_mode = -1;
+ int remote_lock = 0;
+
+ memset(&act,0x00,sizeof(struct sigaction));
+ act.sa_sigaction = _signal_handler;
+ act.sa_flags = SA_SIGINFO;
+
+ int ret = sigemptyset(&act.sa_mask);
+ if (ret < 0) {
+ _ERR("Failed to sigemptyset[%s]", strerror(errno));
+ }
+ ret = sigaddset(&act.sa_mask, SIGTERM);
+ if (ret < 0) {
+ _ERR("Failed to sigaddset[%s]", strerror(errno));
+ }
+ ret = sigaction(SIGTERM, &act, NULL);
+ if (ret < 0) {
+ _ERR("Failed to sigaction[%s]", strerror(errno));
+ }
+
+ memset(ad, 0, sizeof(struct appdata));
+ g_app_data = &*ad;
+
+ ad->retry_cnt = 0;
+ ad->nike_running_status = 0;
+ ad->lcd_status = 0;
+
+ gettimeofday(&ad->tv_start, NULL);
+ aul_launch_init(NULL,NULL);
+
+ aul_listen_app_dead_signal(_w_app_dead_cb, ad);
+
+ if (vconf_notify_key_changed(VCONFKEY_LANGSET, _w_lang_changed_cb, NULL) < 0)
+ _ERR("Failed to add the callback for [%s]", VCONFKEY_LANGSET);
+
+ ad->home_pkgname = vconf_get_str("file/private/homescreen/pkgname");
+ if (!ad->home_pkgname) {
+ ad->home_pkgname = W_HOME_PKGNAME;
+ }
+ _ERR("Home pkg name is [%s]", ad->home_pkgname);
+
+#ifdef TARGET
+ if (bincfg_is_factory_binary() == BIN_TYPE_FACTORY) {
+ gchar *contents;
+ gsize length;
+ GError *error = NULL;
+ gboolean result = FALSE;
+
+ _ERR("Factory binary..!!");
+
+ if (g_file_get_contents(FACTORY_TDF_NOTIFIER_PATH, &contents, &length, &error)) {
+ gchar *found = NULL;
+ _ERR("Read %d bytes from filesystem", length);
+ if ((found = g_strstr_len(contents, strlen(contents), "ON"))) {
+ // Launch TDF Notifier
+ char *argv[3];
+ argv[0] = "/usr/bin/testmode";
+ argv[1] = "*#833#";
+ argv[2] = NULL;
+
+ execv("/usr/bin/testmode", argv);
+
+ g_free(contents);
+ return;
+ }
+ g_free(contents);
+ } else {
+ _ERR("read failed [%d]: [%s]", error->code, error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+ if(ad->launcher_pid < 0){
+ _ERR("Launch Home failed.");
+ ecore_idler_add(_w_retry_idler_cb, ad);
+ }
+ create_key_window_factory_mode(ad->home_pkgname, ad);
+ } else {
+#endif
+ if (vconf_notify_key_changed(VCONFKEY_BT_CONNECTED, _w_BT_changed_cb, ad) < 0) {
+ _ERR("Failed to add the callback for %s changed", VCONFKEY_BT_CONNECTED);
+ }
+ if (vconf_get_int(VCONFKEY_BT_CONNECTED, &bt_state) < 0) {
+ _ERR("Failed to get [%s]", VCONFKEY_BT_CONNECTED);
+ } else {
+ ad->bt_connected = bt_state;
+ _DBG("ad->bt_connected : [%d]", ad->bt_connected);
+ }
+
+#ifdef TELEPHONY_DISABLE //B2
+ if (_w_check_first_boot() == TRUE) {
+ w_launch_app(SETUP_WIZARD_PKGNAME, NULL);
+ ecore_idler_add(_w_starter_idler_cb, ad);
+ } else {
+ _DBG("Not first booting, launch [%s]..!!", ad->home_pkgname);
+
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ vconf_get_int(TEMP_VCONFKEY_LOCK_TYPE, &lock_type);
+
+ if ((bt_state == FALSE) && (lock_type == 1) && (test_mode != VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE)) {
+ _ERR("BT disconneted and privacy lock is set");
+ w_launch_app(W_LOCKSCREEN_PKGNAME, NULL);
+ ecore_idler_add(_w_starter_idler_cb, ad);
+ } else {
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ }
+ }
+#else //B2-3G //TELEPHONY_DISABLE
+
+#if 0 // To do not display home before setupwizard
+
+ w_launch_app(PWLOCK_PKGNAME, NULL);
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ vconf_get_int(TEMP_VCONFKEY_LOCK_TYPE, &lock_type);
+
+ if ((wms_state == FALSE) && (lock_type == 1) && (test_mode != VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE)) {
+ _ERR("BT disconneted and privacy lock is set");
+ ecore_idler_add(_w_starter_lockscreen_idler_cb, ad);
+ } else {
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ }
+
+#else //B3
+
+ vconf_get_int(VCONFKEY_TESTMODE_SCREEN_LOCK, &test_mode);
+ vconf_get_int(TEMP_VCONFKEY_LOCK_TYPE, &lock_type);
+
+ if (_w_check_first_boot() == TRUE) {
+
+ //First boot : launch pwlock > set seq > home
+ ad->first_boot = TRUE;
+
+ vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 0);
+
+ if (vconf_notify_key_changed(VCONFKEY_STARTER_SEQUENCE, _launch_home_cb, ad) < 0)
+ _ERR("Failed to add the callback for show event");
+#ifdef MODEM_ALWAYS_OFF
+ w_launch_app(SETUP_WIZARD_PKGNAME, NULL);
+#else
+ w_launch_app(PWLOCK_PKGNAME, NULL);
+#endif
+ if ((bt_state == FALSE) && (lock_type == 1) && (test_mode != VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE)) {
+ _ERR("BT disconneted and privacy lock is set");
+ ecore_idler_add(_w_starter_lockscreen_idler_cb, ad);
+ }
+ }else {
+
+ // Not first boot : launch home > pwlock
+ ad->first_boot = FALSE;
+
+ if ((bt_state == FALSE) && (lock_type == 1) && (test_mode != VCONFKEY_TESTMODE_SCREEN_LOCK_DISABLE)) {
+ _ERR("BT disconneted and privacy lock is set");
+ ecore_idler_add(_w_starter_lockscreen_idler_cb, ad);
+ } else {
+ ad->launcher_pid = w_launch_app(ad->home_pkgname, NULL);
+ if (ad->launcher_pid > 0) {
+ if (-1 == deviced_conf_set_mempolicy_bypid(ad->launcher_pid, OOM_IGNORE)) {
+ _ERR("Cannot set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ } else {
+ _ERR("Set the memory policy for Homescreen(%d)", ad->launcher_pid);
+ }
+ }
+ else{
+ _ERR("Launch Home failed.");
+ ecore_idler_add(_w_retry_idler_cb, ad);
+ }
+ }
+ create_key_window(ad->home_pkgname, ad);
+#ifndef MODEM_ALWAYS_OFF
+ w_launch_app(PWLOCK_PKGNAME, NULL);
+#endif
+ }
+#endif
+
+#endif //TELEPHONY_DISABLE
+#ifdef TARGET
+ }
+#endif
+
+ /* add ambient mode event */
+ _ambient_mode_event_add(ad);
+
+ /* Check remote-lock state */
+ if(vconf_get_bool(VCONFKEY_REMOTE_LOCK_ISLOCKED, &remote_lock) < 0){
+ _E("failed to get %s", VCONFKEY_REMOTE_LOCK_ISLOCKED);
+ }
+
+ if(remote_lock == true){
+ w_launch_app(REMOTE_LOCK_PKGNAME, NULL);
+ }
+
+// create_key_window(ad->home_pkgname, ad);
+ init_hourly_alert(ad);
+ get_dbus_cool_down_mode(ad);
+ init_dbus_COOL_DOWN_MODE_signal(ad);
+ starter_dbus_connection_get();
+ init_dbus_lcd_on_off_signal(ad);
+ init_clock_mgr(ad);
+
+ // THIS ROUTINE IS FOR SAT.
+ vconf_set_int(VCONFKEY_IDLE_SCREEN_LAUNCHED, VCONFKEY_IDLE_SCREEN_LAUNCHED_TRUE);
+
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, _w_power_off_cb, NULL) < 0)
+ _ERR("Failed to add the callback for [%s]", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
+
+ return;
+}
+
+static void _fini(struct appdata *ad)
+{
+ struct timeval tv, res;
+
+ if (ad == NULL) {
+ fprintf(stderr, "Invalid argument: appdata is NULL\n");
+ return;
+ }
+
+ destroy_key_window();
+ fini_hourly_alert(ad);
+ fini_clock_mgr();
+
+ gettimeofday(&tv, NULL);
+ timersub(&tv, &ad->tv_start, &res);
+ _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
+}
+
+int main(int argc, char *argv[])
+{
+ struct appdata ad;
+
+// WRITE_FILE_LOG("%s", "Main function is started in starter");
+ _DBG("starter is launched..!!");
+#if 0
+ set_window_scale(); /* not in loop */
+#endif
+
+ elm_init(argc, argv);
+
+ _init(&ad);
+
+ elm_run();
+
+ _fini(&ad);
+
+ elm_shutdown();
+
+ return 0;
+}
diff --git a/boot-mgr/x11.c b/src/x11.c
index d9d8aa9..5b94df6 100755
--- a/boot-mgr/x11.c
+++ b/src/x11.c
@@ -1,11 +1,11 @@
/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * 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.tizenopensource.org/license
+ * 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,
@@ -80,3 +80,30 @@ void prop_int_set(const char *name, unsigned int val)
XCloseDisplay(d);
}
+void set_window_scale(void)
+{
+ double root_width = 0.0, root_height = 0.0;
+ char buf[128] = { 0, };
+ Display *disp;
+ int screen_num;
+
+ disp = XOpenDisplay(NULL);
+ if (disp == NULL)
+ return;
+
+ screen_num = DefaultScreen(disp);
+
+ root_width = DisplayWidth(disp, screen_num);
+ root_height = DisplayHeight(disp, screen_num);
+
+ XCloseDisplay(disp);
+
+ snprintf(buf, sizeof(buf), "%lf", root_height / DEFAULT_WINDOW_H);
+
+ if (root_width == 800 && root_height == 1280) {
+ snprintf(buf, sizeof(buf), "0.71");
+ }
+
+ setenv("ELM_SCALE", buf, 1);
+ setenv("SCALE_FACTOR", buf, 1);
+}
diff --git a/starter b/starter
index b5c0fa6..03d278c 100755..100644
--- a/starter
+++ b/starter
@@ -6,9 +6,10 @@ CURRENT_RUNLEVEL=`basename $PWD`
if [ x"$CURRENT_RUNLEVEL" == x"rc3.d" ]; then
while [ ! -f /tmp/.wm_ready ];
do
- sleep 0.1
+ /bin/sleep 0.1
done
fi
/usr/bin/starter &
+
diff --git a/starter.init.sh b/starter.init.sh
deleted file mode 100755
index b4e0f40..0000000
--- a/starter.init.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-cp -f /usr/ug/lib/libug-openlock-setting.so /opt/ug/lib
-cp -f /usr/ug/lib/libug-openlock-setting.so.0.1.0 /opt/ug/lib
diff --git a/starter.manifest b/starter.manifest
new file mode 100755
index 0000000..d93ffad
--- /dev/null
+++ b/starter.manifest
@@ -0,0 +1,36 @@
+<manifest>
+ <define>
+ <domain name="starter"/>
+ <request>
+ <smack request="sys-assert::core" type="rwxat"/>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="system::vconf" type="rwxat"/>
+ <smack request="system::vconf_setting" type="rwxat"/>
+ <smack request="org.tizen.setting::private" type="rw"/>
+ <smack request="system::media" type="rwxat"/>
+ <smack request="system::media::root" type="rwxat"/>
+ <smack request="system::share" type="rwxat"/>
+ <smack request="pulseaudio" type="rwxat"/>
+ <smack request="deviced::display" type="rw"/>
+ <smack request="deviced::haptic" type="rw"/>
+ <smack request="alarm-server::alarm" type="w"/>
+ <smack request="aul::launch" type="x"/>
+ <smack request="aul::terminate" type="x"/>
+ <smack request="tts-server" type="rwx"/>
+ <smack request="bt-service::gap" type="rwxt"/>
+ <smack request="e17::notification" type="rw"/>
+ </request>
+ <provide>
+ <label name="starter::vconf"/>
+ </provide>
+ </define>
+ <request>
+ <domain name="starter"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/starter" label="starter" exec_label="starter" />
+ <filesystem path="/etc/init.d/rd3starter" label="_" exec_label="none" />
+ <filesystem path="/etc/init.d/rd4starter" label="_" exec_label="none" />
+ <filesystem path="/usr/share/locale" label="_" exec_label="_" />
+ </assign>
+</manifest>
diff --git a/test/get_entry.c b/test/get_entry.c
new file mode 100755
index 0000000..6a69348
--- /dev/null
+++ b/test/get_entry.c
@@ -0,0 +1,92 @@
+/*
+ * starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * 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 <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+int main(int argc, char *argv[])
+{
+ unsigned char *prop_ret;
+ Atom type_ret;
+ unsigned long bytes_after, num_ret;
+ int format_ret;
+ unsigned int i;
+ int num;
+
+ Display *d;
+ Atom a_ac;
+ Atom a_ap;
+ Status r;
+
+ d = XOpenDisplay(NULL);
+ if (d == NULL) {
+ printf("Display open error\n");
+ return 1;
+ }
+
+ a_ac = XInternAtom(d, "ENLIGHTENMENT_AUTOCAPITAL_ALLOW", False);
+ if (a_ac == None) {
+ printf("XInternAtom error\n");
+ goto exit;
+ }
+
+ r = XGetWindowProperty(d, DefaultRootWindow(d), a_ac, 0, 0x7fffffff,
+ False, XA_CARDINAL, &type_ret, &format_ret,
+ &num_ret, &bytes_after, &prop_ret);
+ if (r != Success) {
+ printf("XGetWindowProperty error\n");
+ goto exit;
+ }
+
+ if (type_ret == XA_CARDINAL && format_ret == 32 && num_ret > 0
+ && prop_ret) {
+ printf("Auto capital: %lu\n", ((unsigned long *)prop_ret)[0]);
+ }
+ if (prop_ret)
+ XFree(prop_ret);
+
+ a_ap = XInternAtom(d, "ENLIGHTENMENT_AUTOPERIOD_ALLOW", False);
+ if (a_ap == None) {
+ printf("XInternAtom error\n");
+ goto exit;
+ }
+
+ r = XGetWindowProperty(d, DefaultRootWindow(d), a_ap, 0, 0x7fffffff,
+ False, XA_CARDINAL, &type_ret, &format_ret,
+ &num_ret, &bytes_after, &prop_ret);
+ if (r != Success) {
+ printf("XGetWindowProperty error\n");
+ goto exit;
+ }
+
+ if (type_ret == XA_CARDINAL && format_ret == 32 && num_ret > 0
+ && prop_ret) {
+ printf("Auto period: %lu\n", ((unsigned long *)prop_ret)[0]);
+ }
+ if (prop_ret)
+ XFree(prop_ret);
+
+ exit:
+ XCloseDisplay(d);
+ return 0;
+}
diff --git a/test/get_theme.c b/test/get_theme.c
new file mode 100755
index 0000000..afc4947
--- /dev/null
+++ b/test/get_theme.c
@@ -0,0 +1,59 @@
+/*
+ * starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * 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 <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+int main(int argc, char *argv[])
+{
+ XTextProperty xtp;
+ Display *d;
+ Atom a_e17;
+ Status r;
+
+ d = XOpenDisplay(NULL);
+ if (d == NULL) {
+ printf("Display open error\n");
+ return 1;
+ }
+
+ a_e17 = XInternAtom(d, "ENLIGHTENMENT_THEME", False);
+ if (a_e17 == None) {
+ printf("XInternAtom error\n");
+ goto exit;
+ }
+
+ r = XGetTextProperty(d, DefaultRootWindow(d), &xtp, a_e17);
+ if (!r) {
+ printf("XGetTextProperty error\n");
+ goto exit;
+ }
+
+ printf("THEME: [%s]\n", (char *)xtp.value);
+
+ XFree(xtp.value);
+
+ exit:
+ XCloseDisplay(d);
+ return 0;
+}
diff --git a/test/set_theme.c b/test/set_theme.c
new file mode 100755
index 0000000..3d45966
--- /dev/null
+++ b/test/set_theme.c
@@ -0,0 +1,65 @@
+/*
+ * starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * 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 <string.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+void set_elm_theme(void)
+{
+ char *theme;
+ Display *d;
+ Atom a_e17;
+ Atom a_UTF8;
+ XTextProperty xtp;
+
+ theme = "beat:kessler";
+
+ d = XOpenDisplay(NULL);
+ if (d == NULL)
+ return;
+
+ a_e17 = XInternAtom(d, "ENLIGHTENMENT_THEME", False);
+ if (a_e17 == None)
+ goto exit;
+
+ a_UTF8 = XInternAtom(d, "UTF8_STRING", False);
+ if (a_UTF8 == None)
+ goto exit;
+
+ xtp.value = (unsigned char *)theme;
+ xtp.format = 8;
+ xtp.encoding = a_UTF8;
+ xtp.nitems = strlen(theme);
+
+ XSetTextProperty(d, DefaultRootWindow(d), &xtp, a_e17);
+
+ exit:
+ XCloseDisplay(d);
+}
+
+int main(int argc, char *argv[])
+{
+ set_elm_theme();
+ return 0;
+}