--- /dev/null
+Giyeol Ok <giyeol.ok@samsung.com>\r
+Suchang Woo <suchang.woo@samsung.com>\r
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(system_server C)
+
+SET(SRCS
+ ss_main.c
+ ss_sysnoti.c
+ ss_launch.c
+ ss_queue.c
+ ss_core.c
+ ss_sig_handler.c
+ ss_log.c
+ ss_device_change_handler.c
+ ss_predefine.c
+ ss_noti.c
+ ss_lowbat_handler.c
+ ss_lowmem_handler.c
+ ss_pmon_handler.c
+ ss_mmc_handler.c
+ ss_usb_handler.c
+ ss_ta_handler.c
+ ss_bs.c
+ ss_procmgr.c
+ ss_timemgr.c
+ ss_cpu_handler.c
+ ss_device_plugin.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(MOVINAND_FORMAT movi_format.sh)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ ecore
+ ecore-file
+ ecore-x
+ eina
+ sysman
+ vconf
+ heynoti
+ pmapi
+ tapi
+ dlog
+ syspopup-caller
+ devman
+ devman_plugin)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+ADD_DEFINITIONS("-DDEBUG -DENABLE_DLOG_OUT")
+
+SET(UDEV_RULES_PATH share/system-server/udev-rules)
+SET(UDEV_RULES udev-rules/91-system-server.rules)
+
+CONFIGURE_FILE(${UDEV_RULES}.in ${UDEV_RULES} @ONLY)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+INSTALL(FILES ${MOVINAND_FORMAT} DESTINATION bin)
+INSTALL(FILES ${UDEV_RULES} DESTINATION ${UDEV_RULES_PATH})
+INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/system_server.sh DESTINATION /etc/rc.d/init.d)
+INSTALL(FILES system-server.conf DESTINATION /etc/dbus-1/system.d)
+
+ADD_SUBDIRECTORY(restarter)
+ADD_SUBDIRECTORY(sys_event)
+ADD_SUBDIRECTORY(sys_device_noti)
+ADD_SUBDIRECTORY(sys_pci_noti)
--- /dev/null
+
+ 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 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.
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, This software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
--- /dev/null
+Source: system-server
+Section: tools
+Priority: extra
+Maintainer: Jonghoon Han <jonghoon.han@samsung.com> Jinkun Jang <jinkun.jang@samsung.com> DongGi Jang <dg0402.jang@samsung.com> TAESOO JUN <steve.jun@samsung.com>
+Uploaders: Jinkun Jang <jinkun.jang@samsung.com> Wonil Choi <wonil22.choi@samsung.com>
+Build-Depends: debhelper (>= 5),
+ libecore-dev,
+ libheynoti-dev,
+ libslp-setting-dev,
+ libslp-sysman-dev,
+ libslp-tapi-dev,
+ libslp-pm-dev,
+ libdevman-dev,
+ libdevman-plugin-dev,
+ libedbus-dev,
+ dlog-dev,
+ syspopup-caller-dev,
+ libattr1-dev
+Standards-Version: 3.7.2
+
+Package: system-server-bin
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: System server
+
+Package: system-server-bin-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, system-server-bin (= ${Source-Version})
+Description: System server degug package (unstripped)
--- /dev/null
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" 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.
+ $(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.
+ -$(MAKE) clean
+
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+ rm -rf *.so
+ rm -rf ./restarter/CMakeCache.txt
+ rm -rf ./restarter/CMakeFiles
+ rm -rf ./restarter/cmake_install.cmake
+ rm -rf ./restarter/Makefile
+ rm -rf ./restarter/install_manifest.txt
+ rm -rf ./sys_event/CMakeCache.txt
+ rm -rf ./sys_event/CMakeFiles
+ rm -rf ./sys_event/cmake_install.cmake
+ rm -rf ./sys_event/Makefile
+ rm -rf ./sys_event/install_manifest.txt
+ rm -rf ./udev-rules/*.rules
+
+ 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/tmp.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+ ln -s ../init.d/system_server.sh $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S35system-server
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/
+ ln -s ../init.d/system_server.sh $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S00system-server
+
+# 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
+ dh_strip --dbg-package=system-server-bin-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
--- /dev/null
+@PREFIX@/bin/*
+@PREFIX@/share/system-server/*
+/etc/*
--- /dev/null
+#!/bin/sh
+
+vconftool set -t int memory/sysman/usbhost_status -1 -i
+vconftool set -t int memory/sysman/mmc -1 -i
+vconftool set -t int memory/sysman/earjack_key 0 -i
+
+vconftool set -t int memory/sysman/added_usb_storage 0 -i
+vconftool set -t int memory/sysman/removed_usb_storage 0 -i
+vconftool set -t int memory/sysman/charger_status -1 -i
+vconftool set -t int memory/sysman/charge_now -1 -i
+vconftool set -t int memory/sysman/battery_status_low -1 -i
+vconftool set -t int memory/sysman/battery_capacity -1 -i
+vconftool set -t int memory/sysman/usb_status -1 -i
+vconftool set -t int memory/sysman/earjack -1 -i
+vconftool set -t int memory/sysman/low_memory 1 -i
+vconftool set -t int memory/sysman/sliding_keyboard -1 -i
+vconftool set -t int memory/sysman/mmc_mount -1 -i
+vconftool set -t int memory/sysman/mmc_unmount -1 -i
+vconftool set -t int memory/sysman/mmc_format -1 -i
+
+vconftool set -t string memory/private/sysman/added_storage_uevent "" -i
+vconftool set -t string memory/private/sysman/removed_storage_uevent "" -i
+
+
+heynotitool set power_off_start
+
+heynotitool set mmcblk_add
+heynotitool set mmcblk_remove
+
+heynotitool set device_usb_chgdet
+heynotitool set device_ta_chgdet
+heynotitool set device_earjack_chgdet
+heynotitool set device_earkey_chgdet
+heynotitool set device_tvout_chgdet
+heynotitool set device_hdmi_chgdet
+heynotitool set device_charge_chgdet
+heynotitool set device_keyboard_chgdet
+heynotitool set device_keyboard_add
+heynotitool set device_keyboard_remove
+heynotitool set device_mouse_add
+heynotitool set device_mouse_remove
+
+mkdir -p /etc/udev/rules.d
+if ! [ -L /etc/udev/rules.d/91-system-server.rules ]; then
+ ln -s @PREFIX@/share/system-server/udev-rules/91-system-server.rules /etc/udev/rules.d/91-system-server.rules
+fi
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_DATA_H__
+#define __SS_DATA_H__
+
+#include <Ecore.h>
+#include <unistd.h>
+
+enum {
+ WIN_CREATE = 0,
+ WIN_SHOW,
+ WIN_DELETE,
+ WIN_MAX
+};
+
+#define FM_RADIO_APP "FM_radio"
+#define MULTIMEDIA_APP "music"
+#define BLUETOOTH_APP "bluetooth"
+#define VOICERECORDER_APP "voicerecorder"
+
+#define MMC_DEV "/dev/mmcblk"
+
+#define VCONFKEY_INTERNAL_ADDED_USB_STORAGE "memory/private/sysman/added_storage_uevent"
+#define VCONFKEY_INTERNAL_REMOVED_USB_STORAGE "memory/private/sysman/removed_storage_uevent"
+
+#define PREDEF_CALL "call"
+#define PREDEF_LOWMEM "lowmem"
+#define PREDEF_LOWBAT "lowbat"
+#define PREDEF_USBCON "usbcon"
+#define PREDEF_POWEROFF "poweroff"
+#define PREDEF_REBOOT "reboot"
+#define PREDEF_PWROFF_POPUP "pwroff-popup"
+#define PREDEF_BACKGRD "backgrd"
+#define PREDEF_FOREGRD "foregrd"
+#define PREDEF_ACTIVE "active"
+#define PREDEF_USB_STORAGE_ADD "usbstorage-add"
+#define PREDEF_USB_STORAGE_REMOVE "usbstorage-remove"
+#define PREDEF_INACTIVE "inactive"
+
+#define OOMADJ_SET "oomadj_set"
+#define LOW_MEM_ACT "low_mem_act"
+#define OOM_MEM_ACT "oom_mem_act"
+
+#define WARNING_LOW_BAT_ACT "warning_low_bat_act"
+#define CRITICAL_LOW_BAT_ACT "critical_low_bat_act"
+#define POWER_OFF_BAT_ACT "power_off_bat_act"
+#define CHARGE_BAT_ACT "charge_bat_act"
+#define CHARGE_CHECK_ACT "charge_check_act"
+#define CHARGE_ERROR_ACT "charge_error_act"
+
+#define PREDEF_EARJACKCON "earjack_predef_internal"
+
+#define PREDEF_SET_DATETIME "set_datetime"
+#define PREDEF_SET_TIMEZONE "set_timezone"
+
+#define PREDEF_MOUNT_MMC "mountmmc"
+#define PREDEF_UNMOUNT_MMC "unmountmmc"
+#define PREDEF_FORMAT_MMC "formatmmc"
+
+#define PREDEF_SET_MAX_FREQUENCY "set_max_frequency"
+#define PREDEF_SET_MIN_FREQUENCY "set_min_frequency"
+#define PREDEF_RELEASE_MAX_FREQUENCY "release_max_frequency"
+#define PREDEF_RELEASE_MIN_FREQUENCY "release_min_frequency"
+
+#define PREDEF_FLIGHT_MODE "flightmode"
+#define OOMADJ_SU (-17)
+#define OOMADJ_INIT (-16)
+#define OOMADJ_FOREGRD_LOCKED (-15)
+#define OOMADJ_FOREGRD_UNLOCKED (-10)
+#define OOMADJ_BACKGRD_LOCKED (-5)
+#define OOMADJ_BACKGRD_UNLOCKED (1)
+
+#define OOMADJ_APP_LIMIT (-16)
+
+#define MOVINAND_MOUNT_POINT "/opt/media"
+#define MMC_MOUNT_POINT "/opt/storage/sdcard"
+
+struct ui_contention_info {
+
+};
+
+struct ss_main_data {
+ int sysnoti_fd;
+ int noti_fd;
+};
+
+#endif /* __SS_DATA_H__ */
--- /dev/null
+#!/bin/sh
+
+fdisk -H 1 /dev/mmcblk0 << EOF
+d
+1
+d
+2
+d
+3
+n
+p
+1
+2
+728576
+n
+p
+2
+
+990720
+n
+p
+3
+
+1003520
+p
+wq
+EOF
+
+sleep 1
+
+fat.format -s 32 -S 512 -F 32 /dev/mmcblk0p1
+fat.format -s 32 -S 512 -F 32 /dev/mmcblk0p2
+fat.format -s 4 -S 4096 -F 16 /dev/mmcblk0p3
+
--- /dev/null
+<manifest>
+ <define>
+ <domain name="system-server"/>
+ <request>
+ <smack request="sys-assert::core" type="rwxat" />
+ </request>
+ </define>
+ <assign>
+ <filesystem path="/etc/init.d/system_server.sh" label="_" exec_label="none" />
+ <filesystem path="/etc/rc.d/init.d/system_server.sh" label="_" exec_label="none" />
+ <filesystem path="/etc/rc.d/rc3.d/S35system-server" label="_" exec_label="none" />
+ <filesystem path="/etc/rc.d/rc5.d/S00system-server" label="_" exec_label="none" />
+ </assign>
+ <request>
+ <domain name="system-server"/>
+ </request>
+</manifest>
--- /dev/null
+[Unit]
+Description=Start the system server service
+
+[Service]
+# set DISPLAY for usb_setting launching
+Environment=DISPLAY=:0
+ExecStart=/usr/bin/system_server
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+#sbs-git:slp/pkgs/s/system-server system-server 0.1.51 56e16bca39f96d6c8aed9ed3df2fea9b393801be
+Name: system-server
+Summary: System server
+Version: 0.1.63
+Release: 1
+Group: framework-system
+License: APLv2
+Source0: system-server-%{version}.tar.gz
+Source1: system-server.service
+Source2: system-server.manifest
+BuildRequires: cmake
+BuildRequires: libattr-devel
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(sysman)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(devman)
+BuildRequires: pkgconfig(pmapi)
+BuildRequires: pkgconfig(edbus)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires: pkgconfig(devman_plugin)
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(svi)
+BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(usbutils)
+BuildRequires: gettext
+Requires: sys-assert
+Requires(preun): /usr/bin/systemctl
+Requires(post): /usr/bin/systemctl
+Requires(post): /usr/bin/vconftool
+Requires(postun): /usr/bin/systemctl
+
+%description
+Description: System server
+
+%prep
+%setup -q
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+%build
+cp %{SOURCE2} .
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d/
+ln -s %{_sysconfdir}/init.d/system_server.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S35system-server
+mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d/
+ln -s %{_sysconfdir}/init.d/system_server.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S00system-server
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %{SOURCE1} %{buildroot}%{_libdir}/systemd/system/system-server.service
+ln -s ../system-server.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/system-server.service
+
+%post
+
+vconftool set -t int memory/sysman/usbhost_status -1 -i
+vconftool set -t int memory/sysman/mmc -1 -i
+vconftool set -t int memory/sysman/earjack_key 0 -i
+vconftool set -t int memory/sysman/added_usb_storage 0 -i
+vconftool set -t int memory/sysman/removed_usb_storage 0 -i
+vconftool set -t int memory/sysman/charger_status -1 -i
+vconftool set -t int memory/sysman/charge_now -1 -i
+vconftool set -t int memory/sysman/battery_status_low -1 -i
+vconftool set -t int memory/sysman/battery_capacity -1 -i
+vconftool set -t int memory/sysman/usb_status -1 -i
+vconftool set -t int memory/sysman/earjack -1 -i
+vconftool set -t int memory/sysman/low_memory 1 -i
+vconftool set -t int memory/sysman/sliding_keyboard -1 -i
+vconftool set -t int memory/sysman/mmc_mount -1 -i
+vconftool set -t int memory/sysman/mmc_unmount -1 -i
+vconftool set -t int memory/sysman/mmc_format -1 -i
+
+vconftool set -t string memory/private/sysman/added_storage_uevent "" -i
+vconftool set -t string memory/private/sysman/removed_storage_uevent "" -u 5000 -i
+
+vconftool set -t int memory/sysman/hdmi 0 -i
+
+heynotitool set power_off_start
+
+heynotitool set mmcblk_add
+heynotitool set mmcblk_remove
+
+heynotitool set device_usb_chgdet
+heynotitool set device_ta_chgdet
+heynotitool set device_earjack_chgdet
+heynotitool set device_earkey_chgdet
+heynotitool set device_tvout_chgdet
+heynotitool set device_hdmi_chgdet
+heynotitool set device_charge_chgdet
+heynotitool set device_keyboard_chgdet
+heynotitool set device_usb_host_add
+heynotitool set device_usb_host_remove
+heynotitool set device_pci_keyboard_add
+heynotitool set device_pci_keyboard_remove
+
+
+mkdir -p /etc/udev/rules.d
+if ! [ -L /etc/udev/rules.d/91-system-server.rules ]; then
+ ln -s %{_datadir}/system-server/udev-rules/91-system-server.rules /etc/udev/rules.d/91-system-server.rules
+fi
+
+systemctl daemon-reload
+if [ $1 == 1 ]; then
+ systemctl restart system-server.service
+fi
+
+if [ -f %{_libdir}/rpm-plugins/msm.so ] ; then
+ find /opt/share/crash -print0 | xargs -0 chsmack -a 'sys-assert::core'
+ find /opt/share/crash -type d -print0 | xargs -0 chsmack -t
+fi
+
+
+%preun
+if [ $1 == 0 ]; then
+ systemctl stop system-server.service
+fi
+
+%postun
+systemctl daemon-reload
+
+
+%files
+%manifest system-server.manifest
+%config %{_sysconfdir}/dbus-1/system.d/system-server.conf
+%{_sysconfdir}/rc.d/init.d/system_server.sh
+%{_sysconfdir}/rc.d/rc3.d/S35system-server
+%{_sysconfdir}/rc.d/rc5.d/S00system-server
+%{_bindir}/system_server
+%if 0%{?simulator}
+%exclude %{_bindir}/restart
+%else
+%{_bindir}/restart
+%endif
+%{_bindir}/movi_format.sh
+%{_bindir}/sys_event
+%{_bindir}/sys_device_noti
+%{_bindir}/sys_pci_noti
+%{_libdir}/systemd/system/multi-user.target.wants/system-server.service
+%{_libdir}/systemd/system/system-server.service
+%{_datadir}/system-server/sys_device_noti/batt_full_icon.png
+%{_datadir}/system-server/udev-rules/91-system-server.rules
+%{_datadir}/system-server/sys_device_noti/res/locale/*/LC_MESSAGES/*.mo
+%{_datadir}/system-server/sys_pci_noti/res/locale/*/LC_MESSAGES/*.mo
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(xxx-predefine C)
+
+SET(SRCS xxx-predefine.c)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION 1.0)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED sysman)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DDEBUG")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+
+SET(CMAKE_LDFLAGS "-Wl,zdefs")
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+
--- /dev/null
+cd `dirname $0`
+
+. ../../../../../setup.conf || exit 1
+
+. ${TPLDIR}/cmake.tpl
+run
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sysman.h>
+
+int SS_PREDEFINE_ACT_FUNC(int argc, char **argv)
+{
+ int i;
+ printf("kqwekrqkwerqwer\n");
+ for (i = 0; i < argc; i++)
+ printf("%s\n", argv[i]);
+ return 0;
+}
+
+int SS_IS_ACCESSABLE_FUNC(int pid)
+{
+ printf("qwerqerqewr %d\n", pid);
+ return 1;
+}
+
+int SS_UI_VIEWABLE_FUNC()
+{
+ printf("kakak viewable\n");
+ return 1;
+}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(restart C)
+
+SET(SRCS restart.c)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <signal.h>
+#include <sys/reboot.h>
+
+int main(int argc, char *argv[])
+{
+ system("/etc/rc.d/rc.shutdown &");
+ sleep(1);
+ sync();
+ reboot(RB_AUTOBOOT);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <unistd.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sysman.h>
+#include <Ecore_File.h>
+
+#include "ss_log.h"
+#include "ss_launch.h"
+
+#define CRASH_PID_MAX 7
+#define CRASH_MODE_MAX 2
+#define CRASH_TIME_MAX 65
+#define CRASH_ARG_NUM 6
+#define CRASH_DELIMITER "|"
+#define CRASH_VERIFY_MAX 5
+#define CRASH_PROCESSNAME_MAX NAME_MAX
+#define CRASH_EXEPATH_MAX NAME_MAX
+#define CRASH_ARG_MAX (CRASH_PROCESSNAME_MAX + CRASH_EXEPATH_MAX + CRASH_TIME_MAX + CRASH_PID_MAX + CRASH_MODE_MAX + CRASH_VERIFY_MAX)
+#define CRASH_NOTI_DIR "/opt/share/crash"
+#define CRASH_NOTI_FILE "curbs.log"
+#define CRASH_NOTI_PATH CRASH_NOTI_DIR"/"CRASH_NOTI_FILE
+#define CRASH_WORKER_PATH "/usr/bin/crash-worker"
+#define CRASH_POPUP_PATH "/usr/apps/org.tizen.crash-popup/bin/crash-popup"
+
+static int noti_fd;
+static int add_noti(void);
+struct crash_arg
+{
+ char crash_mode[CRASH_MODE_MAX];
+ char crash_processname[CRASH_PROCESSNAME_MAX];
+ char crash_timestr[CRASH_TIME_MAX];
+ char crash_pid[CRASH_PID_MAX];
+ char crash_exepath[CRASH_EXEPATH_MAX];
+ char crash_verify[CRASH_VERIFY_MAX];
+};
+
+static int is_running_process(pid_t pid)
+{
+ char buf[PATH_MAX + 1];
+ snprintf(buf, sizeof(buf), "/proc/%d", pid);
+ if (!access(buf, R_OK))
+ return 1;
+ return 0;
+}
+static int make_noti_file(const char *path, const char *file)
+{
+ PRT_TRACE("Make Noti File");
+ int fd;
+ char buf[PATH_MAX];
+
+ /* make a directory */
+ if (access(path, F_OK) == -1) {
+ snprintf(buf, sizeof(buf), "mkdir -p %s", path);
+ system(buf);
+ snprintf(buf, sizeof(buf), "chown root:app %s", path);
+ system(buf);
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", path, file);
+
+ if (access(buf, F_OK) == 0)
+ return -1;
+
+ if ((fd = open(buf, O_CREAT, S_IRUSR | S_IWUSR)) < 0)
+ return -1;
+ close(fd);
+ snprintf(buf, sizeof(buf), "chmod 666 %s/%s", path, file);
+ system(buf);
+ snprintf(buf, sizeof(buf), "chown root:app %s/%s", path, file);
+ system(buf);
+
+ return 0;
+}
+static int crash_arg_parser(char *linebuffer, struct crash_arg *arg)
+{
+ char *ptr = NULL;
+ int verify_num = 0;
+ int verify_arg_num = 0;
+
+ if (linebuffer == NULL || arg == NULL) {
+ PRT_TRACE_ERR("crash_arg_parser input arguments is NULL\n");
+ return -1;
+ }
+ ptr = strtok(linebuffer, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_mode, CRASH_MODE_MAX, "%s", ptr);
+ ptr = strtok(NULL, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_processname, CRASH_PROCESSNAME_MAX, "%s", ptr);
+ ptr = strtok(NULL, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_timestr, CRASH_TIME_MAX, "%s", ptr);
+ ptr = strtok(NULL, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_pid, CRASH_PID_MAX, "%s", ptr);
+ ptr = strtok(NULL, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_exepath, CRASH_EXEPATH_MAX, "%s", ptr);
+ ptr = strtok(NULL, CRASH_DELIMITER);
+ if (ptr == NULL) {
+ PRT_TRACE_ERR("can't strtok linebuffer ptr(%s)\n", ptr);
+ return -1;
+ }
+ snprintf(arg->crash_verify, CRASH_VERIFY_MAX, "%s", ptr);
+ verify_num = strlen(arg->crash_processname) + strlen(arg->crash_exepath);
+ verify_arg_num = atoi(arg->crash_verify);
+ PRT_TRACE("vnum %d vanum %d\n", verify_num, verify_arg_num);
+ if (verify_num == verify_arg_num)
+ return 1;
+ else
+ return 0;
+}
+static void launch_crash_worker(void *data)
+{
+ static int popup_pid = 0;
+ FILE *fp;
+ int ret = -1;
+ int len = 0;
+ char linebuffer[CRASH_ARG_MAX] = {0,};
+ char crash_worker_args[CRASH_ARG_MAX] = {0,};
+ struct crash_arg parsing_arg;
+ fp = fopen((char *)data, "r");
+ if (fp == NULL) {
+ return;
+ }
+ /* launch crash process */
+ while (fgets(linebuffer, CRASH_ARG_MAX, fp) != NULL) {
+ len = strlen(linebuffer);
+ if (!len || linebuffer[len - 1] != '\n') {
+ PRT_TRACE_ERR("crash inoti msg must be terminated with new line character\n");
+ break;
+ }
+ /* change last caracter from \n to \0 */
+ linebuffer[strlen(linebuffer) - 1] = '\0';
+ if (crash_arg_parser(linebuffer, &parsing_arg) != 1)
+ continue;
+ snprintf(crash_worker_args, sizeof(crash_worker_args), "%s %s %s %s %s",
+ parsing_arg.crash_mode, parsing_arg.crash_processname,
+ parsing_arg.crash_timestr, parsing_arg.crash_pid, parsing_arg.crash_exepath);
+ PRT_TRACE("crash_worker args(%s)\n", crash_worker_args);
+ PRT_TRACE("(%s%s%s)\n", parsing_arg.crash_mode,
+ parsing_arg.crash_processname, parsing_arg.crash_timestr);
+ ret = ss_launch_evenif_exist (CRASH_WORKER_PATH, crash_worker_args);
+ if (ret > 0) {
+ char buf[PATH_MAX];
+ FILE *fpAdj;
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", ret);
+ fpAdj = fopen(buf, "w");
+ if (fpAdj != NULL) {
+ fprintf(fpAdj, "%d", (-17));
+ fclose(fpAdj);
+ }
+ }
+ if (!is_running_process(popup_pid))
+ popup_pid = ss_launch_evenif_exist (CRASH_POPUP_PATH, parsing_arg.crash_processname);
+
+ if (popup_pid < 0) {
+ PRT_TRACE_ERR("popup failed)\n");
+ break;
+ }
+ }
+ fclose(fp);
+
+ if (ret != -1) {
+ fp = fopen((char *)data, "w");
+ if (fp == NULL) {
+ return;
+ }
+ fclose(fp);
+ }
+
+ return;
+}
+
+static Ecore_File_Monitor *crash_file_monitor;
+
+static Ecore_File_Monitor_Cb __crash_file_cb(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path)
+{
+ switch (event) {
+ case ECORE_FILE_EVENT_DELETED_DIRECTORY:
+ case ECORE_FILE_EVENT_DELETED_SELF:
+ if (0 > make_noti_file(CRASH_NOTI_DIR, CRASH_NOTI_FILE)) {
+ launch_crash_worker((void *)path);
+ }
+ break;
+ case ECORE_FILE_EVENT_MODIFIED:
+ default:
+ launch_crash_worker((void *)path);
+ break;
+ }
+
+ return NULL;
+}
+
+int ss_bs_init(void)
+{
+ if (0 > make_noti_file(CRASH_NOTI_DIR, CRASH_NOTI_FILE)) {
+ PRT_TRACE_ERR("make_noti_file() failed");
+ launch_crash_worker((void *)CRASH_NOTI_PATH);
+ }
+
+ if (0 == ecore_file_init()) {
+ PRT_TRACE_ERR("ecore_file_init() failed");
+ launch_crash_worker((void *)CRASH_NOTI_PATH);
+ }
+
+ crash_file_monitor = ecore_file_monitor_add(CRASH_NOTI_PATH,(void *) __crash_file_cb, NULL);
+ if (!crash_file_monitor) {
+ PRT_TRACE_ERR("ecore_file_monitor_add() failed");
+ launch_crash_worker((void *)CRASH_NOTI_PATH);
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_BS_H__
+#define __SS_BS_H__
+
+int ss_bs_init(void);
+
+#endif /* __SS_BS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sysman.h>
+#include "include/ss_data.h"
+#include "ss_queue.h"
+#include "ss_log.h"
+#include "ss_predefine.h"
+#include "ss_core.h"
+
+enum ss_core_cmd_type {
+ SS_CORE_ACT_RUN,
+ SS_CORE_ACT_CLEAR
+};
+
+struct _internal_msg {
+ int type;
+ int pid;
+};
+
+static int core_pipe[2];
+
+static int _ss_core_action_run(void *user_data,
+ struct ss_run_queue_entry *rq_entry)
+{
+ struct ss_action_entry *act_entry = rq_entry->action_entry;
+ int ret;
+ char tmp[128];
+
+ rq_entry->state = SS_STATE_RUNNING;
+ ret = act_entry->predefine_action(rq_entry->argc, rq_entry->argv);
+ if (ret <= 0) {
+ if (ret < 0)
+ PRT_TRACE_ERR("[SYSMAN] predefine action failed");
+ goto fast_done;
+ } else {
+ snprintf(tmp, sizeof(tmp), "/proc/%d/status", ret);
+ if (access(tmp, R_OK) == 0)
+ rq_entry->forked_pid = ret;
+ else
+ goto fast_done;
+ }
+ return 0;
+
+ fast_done:
+ rq_entry->forked_pid = -1;
+ rq_entry->state = SS_STATE_DONE;
+ ss_core_action_clear(-1);
+ return 0;
+}
+
+static int core_pipe_cb(void *userdata, Ecore_Fd_Handler * fd_handler)
+{
+ struct ss_main_data *ad = (struct ss_main_data *)userdata;
+ struct _internal_msg p_msg;
+
+ if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
+ PRT_TRACE_ERR
+ ("ecore_main_fd_handler_active_get error , return\n");
+ return 1;
+ }
+
+ read(core_pipe[0], &p_msg, sizeof(struct _internal_msg));
+
+ switch (p_msg.type) {
+ case SS_CORE_ACT_RUN:
+ ss_run_queue_run(SS_STATE_INIT, _ss_core_action_run, ad);
+ break;
+ case SS_CORE_ACT_CLEAR:
+ ss_run_queue_del_bypid(p_msg.pid);
+ break;
+ }
+ return 1;
+}
+
+int ss_core_action_run()
+{
+ struct _internal_msg p_msg;
+
+ p_msg.type = SS_CORE_ACT_RUN;
+ p_msg.pid = 0;
+ write(core_pipe[1], &p_msg, sizeof(struct _internal_msg));
+
+ return 0;
+}
+
+int ss_core_action_clear(int pid)
+{
+ struct _internal_msg p_msg;
+
+ p_msg.type = SS_CORE_ACT_CLEAR;
+ p_msg.pid = pid;
+ write(core_pipe[1], &p_msg, sizeof(struct _internal_msg));
+
+ return 0;
+}
+
+int ss_core_init(struct ss_main_data *ad)
+{
+ if (pipe(core_pipe) < 0) {
+ PRT_TRACE_ERR("pipe cannot create");
+ exit(1);
+ }
+
+ ecore_main_fd_handler_add(core_pipe[0], ECORE_FD_READ,
+ core_pipe_cb, ad, NULL, NULL);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_CORE_H__
+#define __SS_CORE_H__
+
+#include "include/ss_data.h"
+
+int ss_core_action_run();
+int ss_core_action_clear(int pid);
+int ss_core_init(struct ss_main_data *ad);
+
+#endif /* __SS_CORE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <fcntl.h>
+
+#include "ss_device_plugin.h"
+#include "ss_log.h"
+#include "include/ss_data.h"
+#include "vconf.h"
+
+#define DEFAULT_MAX_CPU_FREQ 1200000
+#define DEFAULT_MIN_CPU_FREQ 100000
+#define POWER_SAVING_CPUFREQ 800000
+
+static int max_cpu_freq_limit = -1;
+static int min_cpu_freq_limit = -1;
+static int cur_max_cpu_freq = INT_MAX;
+static int cur_min_cpu_freq = INT_MIN;
+
+static Eina_List *max_cpu_freq_list;
+static Eina_List *min_cpu_freq_list;
+
+struct cpu_freq_entry {
+ int pid;
+ int freq;
+};
+
+static void __set_freq_limit();
+static int __is_entry_enble(int pid);
+static int __remove_entry_from_max_cpu_freq_list(int pid);
+static int __remove_entry_from_min_cpu_freq_list(int pid);
+static int __add_entry_to_max_cpu_freq_list(int pid, int freq);
+static int __add_entry_to_min_cpu_freq_list(int pid, int freq);
+static int __write_max_cpu_freq(int freq);
+static int __write_min_cpu_freq(int freq);
+
+int set_max_frequency_action(int argc, char **argv)
+{
+ int r = -1;
+
+ if (argc < 2)
+ return -1;
+
+ r = __add_entry_to_max_cpu_freq_list(atoi(argv[0]), atoi(argv[1]));
+ if (r < 0) {
+ PRT_TRACE_ERR("Add entry failed");
+ return -1;
+ }
+
+ r = __write_max_cpu_freq(cur_max_cpu_freq);
+ if (r < 0) {
+ PRT_TRACE_ERR("Write entry failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int set_min_frequency_action(int argc, char **argv)
+{
+ int r = -1;
+
+ if (argc < 2)
+ return -1;
+
+ r = __add_entry_to_min_cpu_freq_list(atoi(argv[0]), atoi(argv[1]));
+ if (r < 0) {
+ PRT_TRACE_ERR("Add entry failed");
+ return -1;
+ }
+
+ r = __write_min_cpu_freq(cur_min_cpu_freq);
+ if (r < 0) {
+ PRT_TRACE_ERR("Write entry failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int release_max_frequency_action(int argc, char **argv)
+{
+ int r = -1;
+ if (argc < 1)
+ return -1;
+
+ r = __remove_entry_from_max_cpu_freq_list(atoi(argv[0]));
+ if (r < 0) {
+ PRT_TRACE_ERR("Remove entry failed");
+ return -1;
+ }
+
+ if (cur_max_cpu_freq == INT_MAX)
+ cur_max_cpu_freq = max_cpu_freq_limit;
+
+ r = __write_max_cpu_freq(cur_max_cpu_freq);
+ if (r < 0) {
+ PRT_TRACE_ERR("Write freq failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int release_min_frequency_action(int argc, char **argv)
+{
+ int r = -1;
+
+ if (argc < 1)
+ return -1;
+
+ r = __remove_entry_from_min_cpu_freq_list(atoi(argv[0]));
+ if (r < 0) {
+ PRT_TRACE_ERR("Remove entry failed");
+ return -1;
+ }
+
+ if (cur_min_cpu_freq == INT_MIN)
+ cur_min_cpu_freq = min_cpu_freq_limit;
+
+ r = __write_min_cpu_freq(cur_min_cpu_freq);
+ if (r < 0) {
+ PRT_TRACE_ERR("Write entry failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int power_saving_cb(keynode_t *key_nodes, void *data)
+{
+ int ret = -1;
+ int power_saving_stat = -1;
+ int power_saving_cpu_stat = -1;
+
+ power_saving_stat = vconf_keynode_get_bool(key_nodes);
+ if (power_saving_stat == 1) {
+ if (vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &power_saving_cpu_stat) == 0) {
+ if (power_saving_cpu_stat == 1) {
+ ret = __add_entry_to_max_cpu_freq_list(getpid(), POWER_SAVING_CPUFREQ);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Add entry failed");
+ return -1;
+ }
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ return -1;
+ }
+ } else {
+ ret = __remove_entry_from_max_cpu_freq_list(getpid());
+ if (ret < 0) {
+ PRT_TRACE_ERR("Remove entry failed");
+ return -1;
+ }
+ if (cur_max_cpu_freq == INT_MIN)
+ cur_max_cpu_freq = max_cpu_freq_limit;
+ }
+ ret = __write_max_cpu_freq(cur_max_cpu_freq);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Write failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int power_saving_cpu_cb(keynode_t *key_nodes, void *data)
+{
+ int ret = -1;
+ int power_saving_stat = -1;
+ int power_saving_cpu_stat = -1;
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat) == 0) {
+ if (power_saving_stat == 1) {
+ power_saving_cpu_stat = vconf_keynode_get_bool(key_nodes);
+ if (power_saving_cpu_stat == 1) {
+ ret = __add_entry_to_max_cpu_freq_list(getpid(), POWER_SAVING_CPUFREQ);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Add entry failed");
+ return -1;
+ }
+ } else {
+ ret = __remove_entry_from_max_cpu_freq_list(getpid());
+ if (ret < 0) {
+ PRT_TRACE_ERR("Remove entry failed");
+ return -1;
+ }
+ if (cur_max_cpu_freq == INT_MAX)
+ cur_max_cpu_freq = max_cpu_freq_limit;
+ }
+ ret = __write_max_cpu_freq(cur_max_cpu_freq);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Write failed");
+ return -1;
+ }
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ return -1;
+ }
+
+ return 0;
+}
+
+int ss_cpu_handler_init(void)
+{
+ __set_freq_limit();
+
+ ss_action_entry_add_internal(PREDEF_SET_MAX_FREQUENCY, set_max_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_SET_MIN_FREQUENCY, set_min_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_RELEASE_MAX_FREQUENCY, release_max_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_RELEASE_MIN_FREQUENCY, release_min_frequency_action, NULL, NULL);
+
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, (void *)power_saving_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, (void *)power_saving_cpu_cb, NULL);
+
+ return 0;
+}
+
+static void __set_freq_limit()
+{
+ int ret;
+
+ ret = plugin_intf->OEM_sys_get_cpufreq_cpuinfo_max_freq(&max_cpu_freq_limit);
+ if (ret < 0) {
+ PRT_TRACE_ERR("get cpufreq cpuinfo max readerror: %s", strerror(errno));
+ max_cpu_freq_limit = DEFAULT_MAX_CPU_FREQ;
+ }
+
+ ret = plugin_intf->OEM_sys_get_cpufreq_cpuinfo_min_freq(&min_cpu_freq_limit);
+ if (ret < 0) {
+ PRT_TRACE_ERR("get cpufreq cpuinfo min readerror: %s", strerror(errno));
+ min_cpu_freq_limit = DEFAULT_MIN_CPU_FREQ;
+ }
+
+ /* check power saving */
+ int power_saving_stat = -1;
+ int power_saving_cpu_stat = -1;
+ if (vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat) == 0) {
+ if (power_saving_stat == 1) {
+ if (vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &power_saving_cpu_stat) == 0) {
+ if (power_saving_cpu_stat == 1) {
+ ret = __add_entry_to_max_cpu_freq_list(getpid(), POWER_SAVING_CPUFREQ);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Add entry failed");
+ return;
+ }
+ ret = __write_max_cpu_freq(cur_max_cpu_freq);
+ if (ret < 0) {
+ PRT_TRACE_ERR("Write entry failed");
+ return;
+ }
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ }
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ }
+}
+
+static int __is_entry_enable(int pid)
+{
+ char pid_path[PATH_MAX];
+
+ snprintf(pid_path, PATH_MAX, "/proc/%d", pid);
+ if (access(pid_path, F_OK) < 0) {
+ return 0;
+ }
+
+ return 1;
+}
+
+static int __remove_entry_from_max_cpu_freq_list(int pid)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct cpu_freq_entry *entry;
+
+ cur_max_cpu_freq = INT_MAX;
+
+ EINA_LIST_FOREACH_SAFE(max_cpu_freq_list, tmp, tmp_next, entry) {
+ if (entry != NULL) {
+ if ((!__is_entry_enable(entry->pid)) || (entry->pid == pid)) {
+ max_cpu_freq_list = eina_list_remove(max_cpu_freq_list, entry);
+ free(entry);
+ continue;
+ }
+
+ if (entry->freq < cur_max_cpu_freq) {
+ cur_max_cpu_freq = entry->freq;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int __remove_entry_from_min_cpu_freq_list(int pid)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct cpu_freq_entry *entry;
+
+ cur_min_cpu_freq = INT_MIN;
+
+ EINA_LIST_FOREACH_SAFE(min_cpu_freq_list, tmp, tmp_next, entry) {
+ if (entry != NULL) {
+ if ((!__is_entry_enable(entry->pid)) || (entry->pid == pid)) {
+ min_cpu_freq_list = eina_list_remove(min_cpu_freq_list, entry);
+ free(entry);
+ continue;
+ }
+
+ if (entry->freq > cur_min_cpu_freq) {
+ cur_min_cpu_freq = entry->freq;
+ }
+
+ }
+ }
+
+ return 0;
+}
+
+static int __add_entry_to_max_cpu_freq_list(int pid, int freq)
+{
+ int r = -1;
+ struct cpu_freq_entry *entry;
+
+ r = __remove_entry_from_max_cpu_freq_list(pid);
+ if (r < 0) {
+ PRT_TRACE_ERR("Remove duplicated entry failed");
+ }
+
+ if (freq < cur_max_cpu_freq) {
+ cur_max_cpu_freq = freq;
+ }
+
+ entry = malloc(sizeof(struct cpu_freq_entry));
+ if (!entry) {
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ entry->pid = pid;
+ entry->freq = freq;
+
+ max_cpu_freq_list = eina_list_prepend(max_cpu_freq_list, entry);
+ if (!max_cpu_freq_list) {
+ PRT_TRACE_ERR("eina_list_prepend failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __add_entry_to_min_cpu_freq_list(int pid, int freq)
+{
+ int r = -1;
+ struct cpu_freq_entry *entry;
+
+ r = __remove_entry_from_min_cpu_freq_list(pid);
+ if (r < 0) {
+ PRT_TRACE_ERR("Remove duplicated entry failed");
+ }
+
+ if (freq > cur_min_cpu_freq) {
+ cur_min_cpu_freq = freq;
+ }
+
+ entry = malloc(sizeof(struct cpu_freq_entry));
+ if (!entry) {
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ entry->pid = pid;
+ entry->freq = freq;
+
+ min_cpu_freq_list = eina_list_prepend(min_cpu_freq_list, entry);
+ if (!min_cpu_freq_list) {
+ PRT_TRACE_ERR("eina_list_prepend failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __write_max_cpu_freq(int freq)
+{
+ int ret;
+
+ ret = plugin_intf->OEM_sys_set_cpufreq_scaling_max_freq(freq);
+ if (ret < 0) {
+ PRT_TRACE_ERR("set cpufreq max freq write error: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __write_min_cpu_freq(int freq)
+{
+ int ret;
+
+ ret = plugin_intf->OEM_sys_set_cpufreq_scaling_min_freq(freq);
+ if (ret < 0) {
+ PRT_TRACE_ERR("set cpufreq min freq write error: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_CPU_HANDLER_H__
+#define __SS_CPU_HANDLER_H__
+
+int ss_cpu_handler_init(void);
+
+#endif /* __SS_CPU_HANDKER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdlib.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <vconf.h>
+#include <sysman.h>
+#include <pmapi.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <syspopup_caller.h>
+#include <aul.h>
+#include <bundle.h>
+#include <dirent.h>
+
+#include "ss_queue.h"
+#include "ss_log.h"
+#include "ss_device_handler.h"
+#include "ss_device_plugin.h"
+#include "ss_noti.h"
+#include "include/ss_data.h"
+#include "sys_device_noti/sys_device_noti.h"
+#include "sys_pci_noti/sys_pci_noti.h"
+
+#define BUFF_MAX 255
+#define SYS_CLASS_INPUT "/sys/class/input"
+#define USBCON_EXEC_PATH PREFIX"/bin/usb-server"
+#define DEFAULT_USB_INFO_PATH "/tmp/usb_default"
+#define STORE_DEFAULT_USB_INFO "usb-devices > "DEFAULT_USB_INFO_PATH
+#define HDMI_NOT_SUPPORTED (-1)
+
+struct input_event {
+ long dummy[2];
+ unsigned short type;
+ unsigned short code;
+ int value;
+};
+
+enum snd_jack_types {
+ SND_JACK_HEADPHONE = 0x0001,
+ SND_JACK_MICROPHONE = 0x0002,
+ SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
+ SND_JACK_LINEOUT = 0x0004,
+ SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
+ SND_JACK_VIDEOOUT = 0x0010,
+ SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
+};
+
+
+static int input_device_number;
+static int check_lowbat_charge_device(int bInserted)
+{
+ static int bChargeDeviceInserted = 0;
+ int val = -1;
+ int bat_state = -1;
+ int ret = -1;
+ if (bInserted == 1) {
+ if (plugin_intf->OEM_sys_get_battery_charge_now(&val) == 0) {
+ if (val == 1)
+ bChargeDeviceInserted = 1;
+ return 0;
+ }
+ } else if (bInserted == 0) {
+ if (plugin_intf->OEM_sys_get_battery_charge_now(&val) == 0) {
+ if (val == 0 && bChargeDeviceInserted == 1) {
+ bChargeDeviceInserted = 0;
+ //low bat popup during charging device removing
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) == 0) {
+ if (bat_state < VCONFKEY_SYSMAN_BAT_NORMAL ||
+ bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF) {
+ bundle *b = NULL;
+ b = bundle_create();
+ if(bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF)
+ bundle_add(b,"_SYSPOPUP_CONTENT_", "poweroff");
+ else
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
+ ret = syspopup_launch("lowbat-syspopup", b);
+ if (ret < 0) {
+ PRT_TRACE_EM("popup lauch failed\n");
+ }
+ bundle_free(b);
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ return -1;
+ }
+ }
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void usb_chgdet_cb(struct ss_main_data *ad)
+{
+ int val = -1;
+ char params[BUFF_MAX];
+ PRT_TRACE("jack - usb changed\n");
+ pm_change_state(LCD_NORMAL);
+ /* check charging now */
+ ss_lowbat_is_charge_in_now();
+ /* check current battery level */
+ ss_lowbat_monitor(NULL);
+ ss_action_entry_call_internal(PREDEF_USBCON, 0);
+
+ if (plugin_intf->OEM_sys_get_jack_usb_online(&val)==0) {
+ check_lowbat_charge_device(val);
+ if (val==1) {
+ snprintf(params, sizeof(params), "%d", CB_NOTI_BATT_CHARGE);
+ ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
+ PRT_TRACE("usb device notification");
+ }
+ }
+}
+
+static void ta_chgdet_cb(struct ss_main_data *ad)
+{
+ PRT_TRACE("jack - ta changed\n");
+ pm_change_state(LCD_NORMAL);
+ /* check charging now */
+ ss_lowbat_is_charge_in_now();
+ /* check current battery level */
+ ss_lowbat_monitor(NULL);
+
+ int val = -1;
+ int ret = -1;
+ int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
+ char params[BUFF_MAX];
+
+ if (plugin_intf->OEM_sys_get_jack_charger_online(&val) == 0) {
+ check_lowbat_charge_device(val);
+ vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, val);
+ if (val == 0) {
+ pm_unlock_state(LCD_OFF, STAY_CUR_STATE);
+ } else {
+ pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ snprintf(params, sizeof(params), "%d", CB_NOTI_BATT_CHARGE);
+ ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
+ PRT_TRACE("ta device notification");
+ }
+ }
+ else
+ PRT_TRACE_ERR("failed to get ta status\n");
+}
+
+static void earjack_chgdet_cb(struct ss_main_data *ad)
+{
+ PRT_TRACE("jack - earjack changed\n");
+ ss_action_entry_call_internal(PREDEF_EARJACKCON, 0);
+}
+
+static void earkey_chgdet_cb(struct ss_main_data *ad)
+{
+ int val;
+ PRT_TRACE("jack - earkey changed\n");
+
+ if (plugin_intf->OEM_sys_get_jack_earkey_online(&val) == 0)
+ vconf_set_int(VCONFKEY_SYSMAN_EARJACKKEY, val);
+}
+
+static void tvout_chgdet_cb(struct ss_main_data *ad)
+{
+ PRT_TRACE("jack - tvout changed\n");
+ pm_change_state(LCD_NORMAL);
+}
+
+static void hdmi_chgdet_cb(struct ss_main_data *ad)
+{
+ PRT_TRACE("jack - hdmi changed\n");
+ int val;
+ pm_change_state(LCD_NORMAL);
+ if (plugin_intf->OEM_sys_get_hdmi_support(&val) == 0) {
+ if (val!=1) {
+ PRT_TRACE_ERR("target is not support HDMI");
+ vconf_set_int(VCONFKEY_SYSMAN_HDMI, HDMI_NOT_SUPPORTED);
+ return;
+ }
+ }
+ if (plugin_intf->OEM_sys_get_jack_hdmi_online(&val) == 0) {
+ vconf_set_int(VCONFKEY_SYSMAN_HDMI,val);
+ if(val == 1)
+ pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0);
+ else
+ pm_unlock_state(LCD_NORMAL, PM_SLEEP_MARGIN);
+ }
+}
+
+static void keyboard_chgdet_cb(struct ss_main_data *ad)
+{
+ int val = -1;
+ int ret = -1;
+ PRT_TRACE("jack - keyboard changed\n");
+
+ ret = plugin_intf->OEM_sys_get_jack_keyboard_online(&val);
+ if( ret == 0) {
+ if(val != 1)
+ val = 0;
+ vconf_set_int(VCONFKEY_SYSMAN_SLIDING_KEYBOARD, val);
+ } else {
+ vconf_set_int(VCONFKEY_SYSMAN_SLIDING_KEYBOARD, VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED);
+ }
+}
+
+static void mmc_chgdet_cb(void *data)
+{
+ int ret = -1;
+ int val = -1;
+ if (data == NULL) {
+ PRT_TRACE("mmc removed");
+ ss_mmc_removed();
+ } else {
+ PRT_TRACE("mmc added");
+ ret = ss_mmc_inserted();
+ if (ret == -1) {
+ vconf_get_int(VCONFKEY_SYSMAN_MMC_MOUNT,&val);
+ if (val == VCONFKEY_SYSMAN_MMC_MOUNT_FAILED) {
+ bundle *b = NULL;
+ b = bundle_create();
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "mounterr");
+ ret = syspopup_launch("mmc-syspopup", b);
+ if (ret < 0) {
+ PRT_TRACE_ERR("popup launch failed");
+ }
+ bundle_free(b);
+ }
+ }
+ }
+}
+
+static void ums_unmount_cb(void *data)
+{
+ umount(MOVINAND_MOUNT_POINT);
+}
+
+static void charge_cb(struct ss_main_data *ad)
+{
+ int val = -1;
+ char params[BUFF_MAX];
+ static int bat_full_noti = 0;
+ ss_lowbat_monitor(NULL);
+ if (plugin_intf->OEM_sys_get_battery_health(&val) == 0) {
+ if (val==BATTERY_OVERHEAT || val==BATTERY_COLD) {
+ PRT_TRACE_ERR("Battery health status is not good (%d)", val);
+ ss_action_entry_call_internal(PREDEF_LOWBAT, 1, CHARGE_ERROR_ACT);
+ return;
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get battery health status");
+ }
+ plugin_intf->OEM_sys_get_battery_charge_full(&val);
+ if (val==0) {
+ if (bat_full_noti==1) {
+ snprintf(params, sizeof(params), "%d %d", CB_NOTI_BATT_FULL, CB_NOTI_OFF);
+ ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
+ }
+ bat_full_noti = 0;
+ } else {
+ if (val==1 && bat_full_noti==0) {
+ bat_full_noti = 1;
+ PRT_TRACE("battery full noti");
+ snprintf(params, sizeof(params), "%d %d", CB_NOTI_BATT_FULL, CB_NOTI_ON);
+ ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
+ }
+ }
+}
+
+static void usb_host_chgdet_cb(keynode_t *in_key, struct ss_main_data *ad)
+{
+ PRT_TRACE("ENTER: usb_host_chgdet_cb()");
+ int status;
+ int ret = vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &status);
+ if (ret != 0) {
+ PRT_TRACE_ERR("vconf get failed(VCONFKEY_SYSMAN_USB_HOST_STATUS)\n");
+ return ;
+ }
+
+ if(VCONFKEY_SYSMAN_USB_HOST_CONNECTED == status) {
+ int pid = ss_launch_if_noexist(USBCON_EXEC_PATH, NULL);
+ if (pid < 0) {
+ PRT_TRACE("usb-server launching failed\n");
+ return;
+ }
+ }
+ PRT_TRACE("EXIT: usb_host_chgdet_cb()");
+}
+
+static void usb_host_add_cb()
+{
+ PRT_TRACE("ENTER: usb_host_add_cb()\n");
+ int status;
+ int ret = vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &status);
+ if (ret != 0) {
+ PRT_TRACE("vconf get failed ()\n");
+ return;
+ }
+
+ if (-1 == status) { /* '-1' means that USB host mode is not loaded yet */
+ PRT_TRACE("This usb device is connected defaultly\n");
+
+ ret = system(STORE_DEFAULT_USB_INFO);
+ PRT_TRACE("Return value of usb-devices: %d\n", ret);
+ if (0 != access(DEFAULT_USB_INFO_PATH, F_OK)) {
+ ret = system(STORE_DEFAULT_USB_INFO);
+ PRT_TRACE("Return value of usb-devices: %d\n", ret);
+ }
+ }
+ PRT_TRACE("EXIT: usb_host_add_cb()\n");
+}
+
+static void pci_keyboard_add_cb(struct ss_main_data *ad)
+{
+ char params[BUFF_MAX];
+ PRT_TRACE("pci- keyboard inserted\n");
+ pm_change_state(LCD_NORMAL);
+
+ snprintf(params, sizeof(params), "%d", CB_NOTI_PCI_INSERTED);
+ ss_launch_if_noexist("/usr/bin/sys_pci_noti", params);
+
+}
+static void pci_keyboard_remove_cb(struct ss_main_data *ad)
+{
+ char params[BUFF_MAX];
+ PRT_TRACE("pci- keyboard removed\n");
+ pm_change_state(LCD_NORMAL);
+
+ snprintf(params, sizeof(params), "%d", CB_NOTI_PCI_REMOVED);
+ ss_launch_if_noexist("/usr/bin/sys_pci_noti", params);
+}
+int ss_device_change_init(struct ss_main_data *ad)
+{
+ /* for simple noti change cb */
+ ss_noti_add("device_usb_chgdet", (void *)usb_chgdet_cb, (void *)ad);
+ ss_noti_add("device_ta_chgdet", (void *)ta_chgdet_cb, (void *)ad);
+ ss_noti_add("device_earjack_chgdet", (void *)earjack_chgdet_cb, (void *)ad);
+ ss_noti_add("device_earkey_chgdet", (void *)earkey_chgdet_cb, (void *)ad);
+ ss_noti_add("device_tvout_chgdet", (void *)tvout_chgdet_cb, (void *)ad);
+ ss_noti_add("device_hdmi_chgdet", (void *)hdmi_chgdet_cb, (void *)ad);
+ ss_noti_add("device_keyboard_chgdet", (void *)keyboard_chgdet_cb, (void *)ad);
+
+ ss_noti_add("device_usb_host_add", (void *)usb_host_add_cb, (void *)ad);
+ ss_noti_add("mmcblk_add", (void *)mmc_chgdet_cb, (void *)1);
+ ss_noti_add("mmcblk_remove", (void *)mmc_chgdet_cb, NULL);
+
+ ss_noti_add("unmount_ums", (void *)ums_unmount_cb, NULL);
+ ss_noti_add("device_charge_chgdet", (void *)charge_cb, (void *)ad);
+
+ ss_noti_add("device_pci_keyboard_add", (void *)pci_keyboard_add_cb, (void *)ad);
+ ss_noti_add("device_pci_keyboard_remove", (void *)pci_keyboard_remove_cb, (void *)ad);
+
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_HOST_STATUS, usb_host_chgdet_cb, NULL) < 0) {
+ PRT_TRACE_ERR("vconf key notify failed(VCONFKEY_SYSMAN_USB_HOST_STATUS)");
+ }
+
+ /* set initial state for devices */
+ input_device_number = 0;
+ keyboard_chgdet_cb(NULL);
+ hdmi_chgdet_cb(NULL);
+ system(STORE_DEFAULT_USB_INFO);
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_DEVICE_HANDLER_H__
+#define __SS_DEVICE_HANDLER_H__
+
+#include "include/ss_data.h"
+
+/* MMC functions */
+int ss_mmc_init();
+int ss_mmc_inserted();
+int ss_mmc_removed();
+
+/* USB Storage */
+int _ss_usb_storage_init(void);
+
+/* Battery functions */
+int ss_lowbat_init(struct ss_main_data *ad);
+int ss_lowbat_is_charge_in_now();
+int ss_lowbat_set_charge_on(int onoff);
+int ss_lowbat_monitor(void *data);
+
+/* Low memory functions */
+int ss_lowmem_init(struct ss_main_data *ad);
+
+/* USB functions */
+int ss_usb_init();
+
+/* TA functions */
+int ss_ta_init();
+
+/* device change init */
+int ss_device_change_init(struct ss_main_data *ad);
+
+#endif /* __SS_DEVICE_HANDLER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <dlfcn.h>
+#include <unistd.h>
+
+#include "ss_log.h"
+#include "ss_device_plugin.h"
+
+static void *dlopen_handle;
+
+int _ss_devman_plugin_init()
+{
+ char *error;
+
+ dlopen_handle = dlopen(DEVMAN_PLUGIN_PATH, RTLD_NOW);
+ if (!dlopen_handle) {
+ PRT_TRACE_ERR("dlopen() failed");
+ return -1;
+ }
+
+ const OEM_sys_devman_plugin_interface *(*get_devman_plugin_interface) ();
+ get_devman_plugin_interface = dlsym(dlopen_handle, "OEM_sys_get_devman_plugin_interface");
+ if ((error = dlerror()) != NULL) {
+ PRT_TRACE_ERR("dlsym() failed: %s", error);
+ dlclose(dlopen_handle);
+ return -1;
+ }
+
+ plugin_intf = get_devman_plugin_interface();
+ if (!plugin_intf) {
+ PRT_TRACE_ERR("get_devman_plugin_interface() failed");
+ dlclose(dlopen_handle);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int _ss_devman_plugin_fini()
+{
+ if (dlopen_handle) {
+ dlclose(dlopen_handle);
+ }
+
+ return 0;
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_DEVICE_PLUGIN_H__
+#define __SS_DEVICE_PLUGIN_H__
+
+#include "devman_plugin_intf.h"
+
+#define DEVMAN_PLUGIN_PATH "/usr/lib/libslp_devman_plugin.so"
+
+int _ss_devman_plugin_init(void);
+int _ss_devman_plugin_fini(void);
+
+const OEM_sys_devman_plugin_interface *plugin_intf;
+
+#endif /* __SS_DEVICE_PLUGIN_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "vconf-keys.h"
+#include "ss_log.h"
+#include "ss_launch.h"
+
+#define MAX_ARGS 255
+
+#define _S(str) ((str == NULL) ? "" : str)
+
+int ss_set_current_lang(void)
+{
+ char *lang;
+ int ret;
+ lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (lang == NULL)
+ return -1;
+ ret = setenv("LANG", lang, 1);
+ if (ret < 0)
+ return -1;
+ free(lang);
+ return 0;
+}
+
+
+static void prepare_exec(void)
+{
+ int i;
+ int maxfd;
+ char buf[MAX_ARGS];
+ FILE *fp;
+
+ maxfd = getdtablesize();
+ for (i = 3; i < maxfd; i++)
+ close(i);
+
+ for (i = 0; i < _NSIG; i++)
+ signal(i, SIG_DFL);
+
+ /* RESET oomadj value */
+ sprintf(buf,"/proc/%d/oom_adj",getpid());
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return;
+ fprintf(fp, "%d", 0);
+ fclose(fp);
+}
+
+static int parse_cmd(const char *cmdline, char **argv, int max_args)
+{
+ const char *p;
+ char *buf, *bufp;
+ int nargs = 0;
+ int escape = 0, squote = 0, dquote = 0;
+ int bufsize;
+
+ if (cmdline == NULL || cmdline[0] == '\0')
+ return -1;
+ bufsize = strlen(cmdline)+1;
+ bufp = buf = malloc(bufsize);
+ if (bufp == NULL || buf == NULL)
+ return -1;
+ memset(buf, 0, bufsize);
+ p = cmdline;
+
+ while (*p) {
+ if (escape) {
+ *bufp++ = *p;
+ escape = 0;
+ } else {
+ switch (*p) {
+ case '\\':
+ escape = 1;
+ break;
+ case '"':
+ if (squote)
+ *bufp++ = *p;
+ else
+ dquote = !dquote;
+ break;
+ case '\'':
+ if (dquote)
+ *bufp++ = *p;
+ else
+ squote = !squote;
+ break;
+ case ' ':
+ if (!squote && !dquote) {
+ *bufp = '\0';
+ if (nargs < max_args)
+ argv[nargs++] = strdup(buf);
+ bufp = buf;
+ break;
+ }
+ default:
+ *bufp++ = *p;
+ break;
+ }
+ }
+ p++;
+ }
+
+ if (bufp != buf) {
+ *bufp = '\0';
+ if (nargs < max_args)
+ argv[nargs++] = strdup(buf);
+ }
+
+ argv[nargs++] = NULL;
+
+ free(buf);
+ return nargs;
+}
+
+int launch_app_with_nice(const char *file, char *const argv[], pid_t *pid, int _nice)
+{
+ int ret;
+ int _pid;
+
+ if (file == NULL || access(file, X_OK) != 0) {
+ PRT_TRACE_ERR("launch app error: Invalid input");
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (pid && (*pid > 0 && kill(*pid, 0) != -1))
+ return *pid;
+
+ _pid = fork();
+
+ if (_pid == -1) {
+ PRT_TRACE_ERR("fork error: %s", strerror(errno));
+ /* keep errno */
+ return -1;
+ }
+
+ if (_pid > 0) { /* parent */
+ if (pid)
+ *pid = _pid;
+ return _pid;
+ }
+
+ /* child */
+ prepare_exec();
+
+ ret = nice(_nice);
+
+ if (ret == -1 && errno != 0)
+ PRT_TRACE_ERR("nice error: %s", strerror(errno));
+
+ ret = execvp(file, argv);
+
+ /* If failed... */
+ PRT_TRACE_ERR("exec. error: %s", strerror(errno));
+ return -2;
+}
+
+int launch_app_cmd_with_nice(const char *cmdline, int _nice)
+{
+ int i;
+ int nargs;
+ int ret;
+ char *argv[MAX_ARGS + 1];
+
+ nargs = parse_cmd(cmdline, argv, MAX_ARGS + 1);
+ if (nargs == -1) {
+ PRT_TRACE_ERR("launch app error: Invalid input");
+ errno = EINVAL;
+ return -1;
+ }
+
+ ret = launch_app_with_nice(argv[0], argv, NULL, _nice);
+
+ for (i = 0; i < nargs; i++)
+ free(argv[i]);
+
+ return ret;
+}
+
+int launch_app_cmd(const char *cmdline)
+{
+ return launch_app_cmd_with_nice(cmdline, 0);
+}
+
+int ss_launch_if_noexist(const char *execpath, const char *arg, ...)
+{
+ char *buf;
+ int pid;
+ int nice_value = 0;
+ int flag = 0;
+ int buf_size = -1;
+ va_list argptr;
+
+ if (execpath == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (pid = sysman_get_pid(execpath) > 0)
+ return pid;
+
+ va_start(argptr, arg);
+ flag = va_arg(argptr, int);
+
+ if (flag & SS_LAUNCH_NICE)
+ nice_value = va_arg(argptr, int);
+
+ va_end(argptr);
+
+ ss_set_current_lang();
+ arg = _S(arg);
+
+ buf_size = strlen(execpath) + strlen(arg) + 10;
+ buf = malloc(buf_size);
+ if (buf == NULL) {
+ /* Do something for not enought memory error */
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ snprintf(buf, buf_size, "%s %s", execpath, arg);
+ pid = launch_app_cmd_with_nice(buf, nice_value);
+ if (pid == -2)
+ exit(0);
+ free(buf);
+
+ return pid;
+}
+
+int ss_launch_evenif_exist(const char *execpath, const char *arg, ...)
+{
+ char *buf;
+ int pid;
+ int nice_value = 0;
+ int flag = 0;
+ int buf_size = -1;
+
+ va_list argptr;
+
+ if (execpath == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ va_start(argptr, arg);
+ flag = va_arg(argptr, int);
+
+ if (flag & SS_LAUNCH_NICE)
+ nice_value = va_arg(argptr, int);
+
+ va_end(argptr);
+
+ ss_set_current_lang();
+
+ arg = _S(arg);
+
+ buf_size = strlen(execpath) + strlen(arg) + 10;
+ buf = malloc(buf_size);
+ if (buf == NULL) {
+ /* Do something for not enought memory error */
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ snprintf(buf, buf_size, "%s %s", execpath, arg);
+ pid = launch_app_cmd_with_nice(buf, nice_value);
+ if (pid == -2)
+ exit(0);
+ free(buf);
+
+ return pid;
+}
+
+int ss_launch_after_kill_if_exist(const char *execpath, const char *arg, ...)
+{
+ char *buf;
+ int pid;
+ int nice_value = 0;
+ int flag = 0;
+ int buf_size = -1;
+ int exist_pid;
+ va_list argptr;
+
+ if (execpath == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ((exist_pid = sysman_get_pid(execpath)) > 0)
+ kill(exist_pid, SIGTERM);
+
+ va_start(argptr, arg);
+ flag = va_arg(argptr, int);
+
+ if (flag & SS_LAUNCH_NICE)
+ nice_value = va_arg(argptr, int);
+
+ va_end(argptr);
+
+ ss_set_current_lang();
+
+ arg = _S(arg);
+
+ buf_size = strlen(execpath) + strlen(arg) + 10;
+ buf = malloc(buf_size);
+ if (buf == NULL) {
+ /* Do something for not enought memory error */
+ PRT_TRACE_ERR("Malloc Failed");
+ return -1;
+ }
+
+ snprintf(buf, buf_size, "%s %s", execpath, arg);
+ pid = launch_app_cmd_with_nice(buf, nice_value);
+ if (pid == -2)
+ exit(0);
+ free(buf);
+
+ return pid;
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_LAUNCH_H__
+#define __SS_LAUNCH_H__
+
+#define SS_LAUNCH_NICE 0x0002
+
+int ss_launch_if_noexist(const char *execpath, const char *arg, ...);
+int ss_launch_evenif_exist(const char *execpath, const char *arg, ...);
+int ss_launch_after_kill_if_exist(const char *execpath, const char *arg, ...);
+
+#endif /* __SS_LAUNCH_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#ifdef DEBUG
+void __cyg_profile_func_enter(void *, void *)
+ __attribute__ ((no_instrument_function));
+void __cyg_profile_func_exit(void *, void *)
+ __attribute__ ((no_instrument_function));
+
+int g_trace_depth = -2;
+
+void __cyg_profile_func_enter(void *func, void *caller)
+{
+ g_trace_depth++;
+}
+
+void __cyg_profile_func_exit(void *func, void *caller)
+{
+ g_trace_depth--;
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_LOG_H__
+#define __SS_LOG_H__
+
+#include <stdio.h>
+
+#if defined(ENABLE_DLOG_OUT)
+#define LOG_TAG "SYSTEM_SERVER"
+#include <dlog.h>
+#define DLOG_ERR DLOG_ERROR
+#define __LOG(prio, fmt, arg...) \
+ do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0)
+#define __LOGD(prio, fmt, arg...) \
+ do { SLOG(prio, LOG_TAG, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); } while (0)
+#define __PRT(prio, fmt, arg...) \
+ do { fprintf(((D##prio) == DLOG_ERR ? stderr : stdout), fmt"\n", ##arg); } while (0)
+#define __PRTD(prio, fmt, arg...) \
+ do { \
+ fprintf(((D##prio) == DLOG_ERR ? stderr : stdout), \
+ "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); \
+ } while (0)
+#else
+#include <syslog.h>
+#define __LOG(prio, fmt, arg...) \
+ do { syslog(prio, fmt, ##arg); } while (0)
+#define __LOGD(prio, fmt, arg...) \
+ do { syslog(prio, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); } while (0)
+#define __PRT(prio, fmt, arg...) \
+ do { fprintf(((prio) == LOG_ERR ? stderr : stdout), fmt"\n", ##arg); } while (0)
+#define __PRTD(prio, fmt, arg...) \
+ do { \
+ fprintf(((prio) == LOG_ERR ? stderr : stdout), \
+ "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); \
+ } while (0)
+#endif
+
+#ifdef DEBUG
+extern int g_trace_depth;
+#define __PRT_TRACE(prio, fmt, arg...) \
+ do { __LOGD(prio, fmt, ##arg); } while (0)
+/* do { \
+ int ___i;\
+ for(___i=0;___i<g_trace_depth;___i++)\
+ {\
+ fprintf(stdout, " "); \
+ }\
+ fprintf(stdout,\
+ "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__,##arg); \
+ __LOGD(prio, fmt, ##arg); \
+ } while (0) */
+#define __PRT_TRACE_ERR(prio, fmt, arg...) \
+ do { __LOGD(prio, fmt, ##arg); } while (0)
+/* do { \
+ int ___i;\
+ for(___i=0;___i<g_trace_depth;___i++)\
+ {\
+ fprintf(stdout, " "); \
+ }\
+ printf(\
+ "%c[1;31m[%s:%d] "fmt"%c[0m\n",27, __FUNCTION__, __LINE__,##arg,27); \
+ __LOGD(prio, fmt, ##arg); \
+ } while (0)*/
+#define __PRT_TRACE_EM(prio, fmt, arg...) \
+ do { __LOGD(prio, fmt, ##arg); } while (0)
+/* do { \
+ int ___i;\
+ for(___i=0;___i<g_trace_depth;___i++)\
+ {\
+ fprintf(stdout, " "); \
+ }\
+ printf(\
+ "%c[1;34m[%s:%d] "fmt"%c[0m\n",27, __FUNCTION__, __LINE__,##arg,27); \
+ __LOGD(prio, fmt, ##arg); \
+ } while (0)*/
+#endif
+
+#define _NOUT(prio, fmt, arg...) do { } while (0)
+
+#ifdef DEBUG
+# define _LOGD __LOGD
+# define _LOG __LOGD
+# define _PRTD __PRTD
+# define _PRT __PRTD
+# define _PRT_TRACE __PRT_TRACE
+# define _PRT_TRACE_ERR __PRT_TRACE_ERR
+# define _PRT_TRACE_EM __PRT_TRACE_EM
+#else
+# define _LOGD _NOUT
+# define _LOG __LOG
+# define _PRTD _NOUT
+# define _PRT __PRT
+# define _PRT_TRACE _NOUT
+# define _PRT_TRACE_ERR _NOUT
+# define _PRT_TRACE_EM _NOUT
+#endif
+
+#define PRT_INFO(fmt, arg...) _PRT(LOG_INFO, fmt, ##arg)
+#define PRT_ERR(fmt, arg...) _PRT(LOG_ERR, fmt, ##arg)
+#define PRT_DBG(fmt, arg...) _PRTD(LOG_DEBUG, fmt, ##arg)
+#define PRT_TRACE(fmt, arg...) _PRT_TRACE(LOG_DEBUG, fmt, ##arg)
+#define PRT_TRACE_ERR(fmt, arg...) _PRT_TRACE_ERR(LOG_ERR, fmt, ##arg)
+#define PRT_TRACE_EM(fmt, arg...) _PRT_TRACE_EM(LOG_DEBUG, fmt, ##arg)
+
+#if defined(SYSLOG_OUT)
+# define SYSLOG_INFO(fmt, arg...) _LOG(LOG_INFO, fmt, ##arg)
+# define SYSLOG_ERR(fmt, arg...) _LOG(LOG_ERR, fmt, ##arg)
+# define SYSLOG_DBG(fmt, arg...) _LOGD(LOG_DEBUG, fmt, ##arg)
+# define INFO SYSLOG_INFO
+# define ERR SYSLOG_ERR
+# define DBG SYSLOG_DBG
+#elif defined(ENABLE_DLOG_OUT)
+# define INFO SLOGI
+# define ERR SLOGE
+# define DBG SLOGD
+#else
+# define INFO PRT_INFO
+# define ERR PRT_ERR
+# define DBG PRT_DBG
+#endif
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <assert.h>
+#include <limits.h>
+#include <heynoti.h>
+#include <vconf.h>
+#include <sysman.h>
+#include <fcntl.h>
+
+#include "ss_log.h"
+#include "ss_launch.h"
+#include "ss_noti.h"
+#include "ss_queue.h"
+#include "ss_device_plugin.h"
+#include "include/ss_data.h"
+
+#define BAT_MON_INTERVAL 30
+#define BAT_MON_INTERVAL_MIN 2
+
+#define BATTERY_CHARGING 65535
+#define BATTERY_UNKNOWN -1
+#define BATTERY_FULL 100
+#define BATTERY_NORMAL 100
+#define BATTERY_WARNING_LOW 15
+#define BATTERY_CRITICAL_LOW 5
+#define BATTERY_POWER_OFF 1
+#define BATTERY_REAL_POWER_OFF 0
+
+#define MAX_BATTERY_ERROR 10
+#define RESET_RETRY_COUNT 3
+
+#define LOWBAT_EXEC_PATH PREFIX"/bin/lowbatt-popup"
+
+static int battery_level_table[] = {
+ 5, /* BATTERY_LEVEL0 */
+ 15, /* 1 */
+ 25, /* 2 */
+ 40, /* 3 */
+ 60, /* 4 */
+ 80, /* 5 */
+ 100, /* 6 */
+};
+
+#define _SYS_LOW_POWER "LOW_POWER"
+
+struct lowbat_process_entry {
+ unsigned cur_bat_state;
+ unsigned new_bat_state;
+ int (*action) (void *);
+};
+
+static Ecore_Timer *lowbat_timer;
+static int cur_bat_state = BATTERY_UNKNOWN;
+static int cur_bat_capacity = -1;
+
+static int bat_err_count = 0;
+
+static int battery_warning_low_act(void *ad);
+static int battery_critical_low_act(void *ad);
+static int battery_power_off_act(void *ad);
+
+static struct lowbat_process_entry lpe[] = {
+ {BATTERY_NORMAL, BATTERY_WARNING_LOW, battery_warning_low_act},
+ {BATTERY_WARNING_LOW, BATTERY_CRITICAL_LOW, battery_critical_low_act},
+ {BATTERY_CRITICAL_LOW, BATTERY_POWER_OFF, battery_critical_low_act},
+ {BATTERY_POWER_OFF, BATTERY_REAL_POWER_OFF, battery_power_off_act},
+ {BATTERY_NORMAL, BATTERY_CRITICAL_LOW, battery_critical_low_act},
+ {BATTERY_WARNING_LOW, BATTERY_POWER_OFF, battery_critical_low_act},
+ {BATTERY_CRITICAL_LOW, BATTERY_REAL_POWER_OFF, battery_power_off_act},
+ {BATTERY_NORMAL, BATTERY_POWER_OFF, battery_critical_low_act},
+ {BATTERY_WARNING_LOW, BATTERY_REAL_POWER_OFF, battery_power_off_act},
+ {BATTERY_NORMAL, BATTERY_REAL_POWER_OFF, battery_power_off_act},
+};
+
+static int battery_warning_low_act(void *data)
+{
+ char lowbat_noti_name[NAME_MAX];
+
+ heynoti_get_snoti_name(_SYS_LOW_POWER, lowbat_noti_name, NAME_MAX);
+ ss_noti_send(lowbat_noti_name);
+
+ ss_action_entry_call_internal(PREDEF_LOWBAT, 1, WARNING_LOW_BAT_ACT);
+ return 0;
+}
+
+static int battery_critical_low_act(void *data)
+{
+ ss_action_entry_call_internal(PREDEF_LOWBAT, 1, CRITICAL_LOW_BAT_ACT);
+ return 0;
+}
+
+static int battery_power_off_act(void *data)
+{
+ ss_action_entry_call_internal(PREDEF_LOWBAT, 1, POWER_OFF_BAT_ACT);
+ return 0;
+}
+
+static int battery_charge_act(void *data)
+{
+ return 0;
+}
+
+int ss_lowbat_set_charge_on(int onoff)
+{
+ if(vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, onoff)!=0) {
+ PRT_TRACE_ERR("fail to set charge vconf value");
+ return -1;
+ }
+ return 0;
+}
+
+int ss_lowbat_is_charge_in_now()
+{
+ int val = 0;
+ if (0 > plugin_intf->OEM_sys_get_battery_charge_now(&val)) {
+ PRT_TRACE_ERR("fail to read charge now from kernel");
+ ss_lowbat_set_charge_on(0);
+ return 0;
+ }
+
+ if (val == 1) {
+ ss_lowbat_set_charge_on(1);
+ return 1;
+ } else {
+ ss_lowbat_set_charge_on(0);
+ return 0;
+ }
+}
+
+static int lowbat_process(int bat_percent, void *ad)
+{
+ int new_bat_capacity;
+ int new_bat_state;
+ int vconf_state = -1;
+ int bat_full = -1;
+ int i, ret = 0;
+ int val = 0;
+ new_bat_capacity = bat_percent;
+ if (new_bat_capacity < 0)
+ return -1;
+ if (new_bat_capacity != cur_bat_capacity) {
+ PRT_TRACE("[BAT_MON] cur = %d new = %d", cur_bat_capacity, new_bat_capacity);
+ if (vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, new_bat_capacity) == 0)
+ cur_bat_capacity = new_bat_capacity;
+ }
+
+ if (0 > vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &vconf_state)) {
+ PRT_TRACE_ERR("vconf_get_int() failed");
+ return -1;
+ }
+
+ if (new_bat_capacity <= BATTERY_REAL_POWER_OFF) {
+ if (0 > plugin_intf->OEM_sys_get_battery_charge_now(&val)) {
+ PRT_TRACE_ERR("fail to read charge now from kernel");
+ }
+ PRT_TRACE("charge_now status %d",val);
+ if (val == 1) {
+ new_bat_state = BATTERY_POWER_OFF;
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_POWER_OFF)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_POWER_OFF);
+ } else {
+ new_bat_state = BATTERY_REAL_POWER_OFF;
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF);
+ }
+ } else if (new_bat_capacity <= BATTERY_POWER_OFF) {
+ new_bat_state = BATTERY_POWER_OFF;
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_POWER_OFF)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_POWER_OFF);
+ } else if (new_bat_capacity <= BATTERY_CRITICAL_LOW) {
+ new_bat_state = BATTERY_CRITICAL_LOW;
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_CRITICAL_LOW)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_CRITICAL_LOW);
+ } else if (new_bat_capacity <= BATTERY_WARNING_LOW) {
+ new_bat_state = BATTERY_WARNING_LOW;
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_WARNING_LOW)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_WARNING_LOW);
+ } else {
+ new_bat_state = BATTERY_NORMAL;
+ if (new_bat_capacity == BATTERY_FULL) {
+ plugin_intf->OEM_sys_get_battery_charge_full(&bat_full);
+ if (bat_full == 1) {
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_FULL)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_FULL);
+ } else {
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_NORMAL)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_NORMAL);
+ }
+ } else {
+ if (vconf_state != VCONFKEY_SYSMAN_BAT_NORMAL)
+ ret=vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, VCONFKEY_SYSMAN_BAT_NORMAL);
+ }
+ }
+
+ if(ret < 0)
+ return -1;
+
+ ss_lowbat_is_charge_in_now();
+
+ if (cur_bat_state == new_bat_state) {
+ return 0;
+ }
+
+ if (cur_bat_state == BATTERY_UNKNOWN) {
+ for (i = 0;
+ i < sizeof(lpe) / sizeof(struct lowbat_process_entry);
+ i++) {
+ if (new_bat_state == lpe[i].new_bat_state) {
+ lpe[i].action(ad);
+ cur_bat_state = new_bat_state;
+ return 0;
+ }
+ }
+ } else {
+ for (i = 0;
+ i < sizeof(lpe) / sizeof(struct lowbat_process_entry);
+ i++) {
+ if ((cur_bat_state == lpe[i].cur_bat_state)
+ && (new_bat_state == lpe[i].new_bat_state)) {
+ lpe[i].action(ad);
+ cur_bat_state = new_bat_state;
+ return 0;
+ }
+ }
+ }
+ PRT_TRACE("[BATMON] Unknown battery state cur:%d new:%d",cur_bat_state,new_bat_state);
+ cur_bat_state = new_bat_state;
+ return -1;
+}
+
+static int lowbat_read()
+{
+ int bat_percent;
+
+ plugin_intf->OEM_sys_get_battery_capacity(&bat_percent);
+
+ return bat_percent;
+}
+
+int ss_lowbat_monitor(void *data)
+{
+ struct ss_main_data *ad = (struct ss_main_data *)data;
+ int bat_percent;
+
+ bat_percent = lowbat_read();
+ if (bat_percent < 0) {
+ ecore_timer_interval_set(lowbat_timer, BAT_MON_INTERVAL_MIN);
+ bat_err_count++;
+ if (bat_err_count > MAX_BATTERY_ERROR) {
+ PRT_TRACE_ERR
+ ("[BATMON] Cannot read battery gage. stop read fuel gage");
+ return 0;
+ }
+ return 1;
+ }
+ if (bat_percent > 100)
+ bat_percent = 100;
+
+ if (lowbat_process(bat_percent, ad) < 0)
+ ecore_timer_interval_set(lowbat_timer, BAT_MON_INTERVAL_MIN);
+ else
+ ecore_timer_interval_set(lowbat_timer, BAT_MON_INTERVAL);
+
+ return 1;
+}
+
+static int wakeup_cb(keynode_t *key_nodes, void *data)
+{
+ int pm_state = 0;
+
+ if ((pm_state =
+ vconf_keynode_get_int(key_nodes)) == VCONFKEY_PM_STATE_LCDOFF)
+ ss_lowbat_monitor(NULL);
+
+ return 0;
+}
+
+/* for debugging (request by kernel) */
+static int check_battery()
+{
+ int r;
+ int ret = -1;
+
+ if (0 > plugin_intf->OEM_sys_get_battery_present(&ret)) {
+ PRT_TRACE_ERR("[BATMON] battery check : %d", ret);
+ }
+ PRT_TRACE("[BATMON] battery check : %d", ret);
+
+ return ret;
+}
+
+int ss_lowbat_init(struct ss_main_data *ad)
+{
+ int i;
+
+ /* need check battery */
+ lowbat_timer =
+ ecore_timer_add(BAT_MON_INTERVAL_MIN, ss_lowbat_monitor, ad);
+ ss_lowbat_is_charge_in_now();
+
+ vconf_notify_key_changed(VCONFKEY_PM_STATE, (void *)wakeup_cb, NULL);
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <fcntl.h>
+#include <assert.h>
+#include <limits.h>
+#include <sysman.h>
+#include <heynoti.h>
+#include <vconf.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/shm.h>
+
+#include "ss_device_plugin.h"
+#include "ss_log.h"
+#include "ss_noti.h"
+#include "ss_queue.h"
+#include "include/ss_data.h"
+
+#define DELETE_SM "sh -c "PREFIX"/bin/delete.sm"
+
+#define MEMNOTIFY_NORMAL 0x0000
+#define MEMNOTIFY_LOW 0xfaac
+#define MEMNOTIFY_CRITICAL 0xdead
+#define MEMNOTIFY_REBOOT 0xb00f
+
+#define _SYS_RES_CLEANUP "RES_CLEANUP"
+
+#define MEM_THRESHOLD_LV1 60
+#define MEM_THRESHOLD_LV2 40
+
+
+struct lowmem_process_entry {
+ unsigned cur_mem_state;
+ unsigned new_mem_state;
+ int (*action) (void *);
+};
+
+static int lowmem_fd = -1;
+static int cur_mem_state = MEMNOTIFY_NORMAL;
+
+Ecore_Timer *oom_timer;
+#define OOM_TIMER_INTERVAL 5
+
+static int memory_low_act(void *ad);
+static int memory_oom_act(void *ad);
+static int memory_normal_act(void *ad);
+
+static struct lowmem_process_entry lpe[] = {
+ {MEMNOTIFY_NORMAL, MEMNOTIFY_LOW, memory_low_act},
+ {MEMNOTIFY_NORMAL, MEMNOTIFY_CRITICAL, memory_oom_act},
+ {MEMNOTIFY_LOW, MEMNOTIFY_CRITICAL, memory_oom_act},
+ {MEMNOTIFY_CRITICAL, MEMNOTIFY_CRITICAL, memory_oom_act},
+ {MEMNOTIFY_LOW, MEMNOTIFY_NORMAL, memory_normal_act},
+ {MEMNOTIFY_CRITICAL, MEMNOTIFY_NORMAL, memory_normal_act},
+
+};
+
+unsigned int oom_delete_sm_time = 0;
+
+static int remove_shm()
+{
+ int maxid, shmid, id;
+ struct shmid_ds shmseg;
+ struct shm_info shm_info;
+
+ maxid = shmctl(0, SHM_INFO, (struct shmid_ds *)(void *)&shm_info);
+ if (maxid < 0) {
+ PRT_TRACE_ERR("shared mem error\n");
+ return -1;
+ }
+
+ for (id = 0; id <= maxid; id++) {
+ shmid = shmctl(id, SHM_STAT, &shmseg);
+ if (shmid < 0)
+ continue;
+ if (shmseg.shm_nattch == 0) {
+ PRT_TRACE("shared memory killer ==> %d killed\n",
+ shmid);
+ shmctl(shmid, IPC_RMID, NULL);
+ }
+ }
+ return 0;
+}
+
+static char *convert_to_str(unsigned int mem_state)
+{
+ char *tmp;
+ switch (mem_state) {
+ case MEMNOTIFY_NORMAL:
+ tmp = "mem normal";
+ break;
+ case MEMNOTIFY_LOW:
+ tmp = "mem low";
+ break;
+ case MEMNOTIFY_CRITICAL:
+ tmp = "mem critical";
+ break;
+ case MEMNOTIFY_REBOOT:
+ tmp = "mem reboot";
+ break;
+ default:
+ assert(0);
+ }
+ return tmp;
+}
+
+static void print_lowmem_state(unsigned int mem_state)
+{
+ PRT_TRACE("[LOW MEM STATE] %s ==> %s", convert_to_str(cur_mem_state),
+ convert_to_str(mem_state));
+}
+#define BUF_MAX 1024
+static int get_lowmemnotify_info(FILE *output_fp)
+{
+ FILE *fp;
+ char line[BUF_MAX];
+
+ if (output_fp == NULL)
+ return -1;
+
+ fp = fopen("/sys/class/memnotify/meminfo", "r");
+ if (fp == NULL)
+ return -1;
+ PRT_TRACE("make LOWMEM_LOG");
+ fprintf(output_fp,
+ "====================================================================\n");
+ fprintf(output_fp, "MEMORY INFO by lowmemnotify\n");
+
+ while (fgets(line, BUF_MAX, fp) != NULL) {
+ PRT_TRACE("%s",line);
+ fputs(line, output_fp);
+ }
+ fclose(fp);
+
+ return 0;
+}
+
+static void make_LMM_log(char *file, pid_t pid, char *victim_name)
+{
+ time_t now;
+ struct tm *cur_tm;
+ char new_log[NAME_MAX];
+ static pid_t old_pid = 0;
+ int ret=-1;
+ FILE *output_file = NULL;
+
+ if (old_pid == pid)
+ return;
+ old_pid = pid;
+
+ now = time(NULL);
+ cur_tm = (struct tm *)malloc(sizeof(struct tm));
+ if (cur_tm == NULL) {
+ PRT_TRACE_ERR("Fail to memory allocation");
+ return;
+ }
+
+ if (localtime_r(&now, cur_tm) == NULL) {
+ PRT_TRACE_ERR("Fail to get localtime");
+ free(cur_tm);
+ return;
+ }
+
+ PRT_TRACE("%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
+ pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
+ cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
+ cur_tm->tm_sec);
+ snprintf(new_log, sizeof(new_log),
+ "%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
+ pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
+ cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
+ cur_tm->tm_sec);
+
+ output_file = fopen(new_log, "w+");
+ if(!output_file) {
+ PRT_TRACE_ERR("cannot open output file(%s)",new_log);
+ free(cur_tm);
+ return;
+ }
+ get_lowmemnotify_info(output_file);
+ fclose(output_file);
+ free(cur_tm);
+}
+
+
+
+static int memory_low_act(void *data)
+{
+ char lowmem_noti_name[NAME_MAX];
+
+ PRT_TRACE("[LOW MEM STATE] memory low state");
+ make_LMM_log("/var/log/memps", 1, "LOWMEM_WARNING");
+ remove_shm();
+
+ heynoti_get_snoti_name(_SYS_RES_CLEANUP, lowmem_noti_name, NAME_MAX);
+ ss_noti_send(lowmem_noti_name);
+ vconf_set_int(VCONFKEY_SYSMAN_LOW_MEMORY,
+ VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING);
+
+ return 0;
+}
+
+static int memory_oom_act(void *data)
+{
+ unsigned int cur_time;
+ char lowmem_noti_name[NAME_MAX];
+
+ PRT_TRACE("[LOW MEM STATE] memory oom state");
+ cur_time = time(NULL);
+ PRT_TRACE("cur=%d, old=%d, cur-old=%d", cur_time, oom_delete_sm_time,
+ cur_time - oom_delete_sm_time);
+ if (cur_time - oom_delete_sm_time > 15) {
+ remove_shm();
+ oom_delete_sm_time = cur_time;
+ /* Also clean up unreturned memory of applications */
+ heynoti_get_snoti_name(_SYS_RES_CLEANUP, lowmem_noti_name,
+ NAME_MAX);
+ ss_noti_send(lowmem_noti_name);
+ }
+ ss_action_entry_call_internal(PREDEF_LOWMEM, 1, OOM_MEM_ACT);
+
+ vconf_set_int(VCONFKEY_SYSMAN_LOW_MEMORY,
+ VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING);
+
+
+ return 1;
+}
+
+static int memory_normal_act(void *data)
+{
+ PRT_TRACE("[LOW MEM STATE] memory normal state");
+ vconf_set_int(VCONFKEY_SYSMAN_LOW_MEMORY,
+ VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL);
+ return 0;
+}
+
+static int lowmem_process(unsigned int mem_state, void *ad)
+{
+ int i;
+ for (i = 0; i < sizeof(lpe) / sizeof(struct lowmem_process_entry); i++) {
+ if ((cur_mem_state == lpe[i].cur_mem_state)
+ && (mem_state == lpe[i].new_mem_state)) {
+
+ if(oom_timer != NULL) {
+ ecore_timer_del(oom_timer);
+ oom_timer = NULL;
+ }
+ lpe[i].action(ad);
+ if(mem_state == MEMNOTIFY_CRITICAL)
+ oom_timer = ecore_timer_add(OOM_TIMER_INTERVAL,lpe[i].action, ad);
+ return 0;
+ }
+ }
+ return 0;
+}
+
+static unsigned int lowmem_read(int fd)
+{
+ unsigned int mem_state;
+ read(fd, &mem_state, sizeof(mem_state));
+ return mem_state;
+}
+
+static int lowmem_cb(void *data, Ecore_Fd_Handler * fd_handler)
+{
+ int fd;
+ struct ss_main_data *ad = (struct ss_main_data *)data;
+ unsigned int mem_state;
+
+ if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
+ PRT_TRACE_ERR
+ ("ecore_main_fd_handler_active_get error , return\n");
+ return 1;
+ }
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ if (fd < 0) {
+ PRT_TRACE_ERR("ecore_main_fd_handler_fd_get error , return");
+ return 1;
+ }
+ mem_state = lowmem_read(fd);
+ print_lowmem_state(mem_state);
+ lowmem_process(mem_state, ad);
+ cur_mem_state = mem_state;
+
+ return 1;
+}
+
+static int set_threshold()
+{
+ if (0 > plugin_intf->OEM_sys_set_memnotify_threshold_lv1(MEM_THRESHOLD_LV1)) {
+ PRT_TRACE_ERR("Set memnorify threshold lv1 failed");
+ return -1;
+ }
+
+ if (0 > plugin_intf->OEM_sys_set_memnotify_threshold_lv2(MEM_THRESHOLD_LV2)) {
+ PRT_TRACE_ERR("Set memnorify threshold lv2 failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int ss_lowmem_init(struct ss_main_data *ad)
+{
+ char lowmem_dev_node[PATH_MAX];
+
+ if (0 > plugin_intf->OEM_sys_get_memnotify_node(lowmem_dev_node)) {
+ PRT_TRACE_ERR("Low memory handler fd init failed");
+ return -1;
+ }
+
+ lowmem_fd = open(lowmem_dev_node, O_RDONLY);
+ if (lowmem_fd < 0) {
+ PRT_TRACE_ERR("ss_lowmem_init fd open failed");
+ return -1;
+ }
+
+ oom_timer = NULL;
+ ecore_main_fd_handler_add(lowmem_fd, ECORE_FD_READ, lowmem_cb, ad, NULL,
+ NULL);
+ if (set_threshold() < 0) {
+ PRT_TRACE_ERR("Setting lowmem threshold is failed");
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <fcntl.h>
+#include <heynoti.h>
+
+#include "ss_log.h"
+#include "ss_core.h"
+#include "ss_sig_handler.h"
+#include "ss_device_handler.h"
+#include "ss_pmon_handler.h"
+#include "ss_sysnoti.h"
+#include "ss_noti.h"
+#include "ss_queue.h"
+#include "ss_predefine.h"
+#include "ss_bs.h"
+#include "ss_procmgr.h"
+#include "ss_timemgr.h"
+#include "ss_cpu_handler.h"
+#include "ss_device_plugin.h"
+#include "include/ss_data.h"
+
+static void fini(struct ss_main_data *ad)
+{
+}
+
+static void init_ad(struct ss_main_data *ad)
+{
+ memset(ad, 0x0, sizeof(struct ss_main_data));
+}
+
+static void writepid(char *pidpath)
+{
+ FILE *fp;
+
+ fp = fopen(pidpath, "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d", getpid());
+ fclose(fp);
+ }
+}
+
+static void system_server_init(struct ss_main_data *ad)
+{
+ if (0 > _ss_devman_plugin_init()) {
+ PRT_TRACE_ERR("Device Manager Plugin Initialize failed");
+ exit (-1);
+ }
+
+ ad->sysnoti_fd = ss_sysnoti_init();
+ if (ss_noti_init() < 0)
+ PRT_TRACE_ERR("init noti error");
+
+ ss_queue_init();
+ ss_core_init(ad);
+ ss_signal_init();
+ ss_predefine_internal_init();
+ ss_process_manager_init();
+ ss_time_manager_init();
+ ss_cpu_handler_init();
+
+ ss_lowmem_init(ad);
+ ss_lowbat_init(ad);
+ ss_usb_init();
+ ss_ta_init();
+ ss_pmon_init(ad);
+ ss_device_change_init(ad);
+ ss_mmc_init();
+ ss_bs_init();
+}
+
+#define SS_PIDFILE_PATH "/var/run/.system_server.pid"
+
+static int system_main(int argc, char **argv)
+{
+ struct ss_main_data ad;
+
+ init_ad(&ad);
+ if ((ad.noti_fd = heynoti_init()) < 0) {
+ PRT_TRACE_ERR("Hey Notification Initialize failed");
+ fini(&ad);
+ return 0;
+ }
+ if (heynoti_attach_handler(ad.noti_fd) != 0) {
+ PRT_TRACE_ERR("fail to attach hey noti handler");
+ fini(&ad);
+ return 0;
+ }
+ system_server_init(&ad);
+
+ ecore_main_loop_begin();
+
+ fini(&ad);
+ ecore_shutdown();
+
+ return 0;
+}
+
+static int elm_main(int argc, char **argv)
+{
+ return system_main(argc, argv);
+}
+
+int main(int argc, char **argv)
+{
+ writepid(SS_PIDFILE_PATH);
+ ecore_init();
+ return elm_main(argc, argv);
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <unistd.h>
+#include <sys/mount.h>
+#include <errno.h>
+#include <vconf.h>
+#include <devman.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sysman.h>
+#include "ss_log.h"
+#include "ss_device_handler.h"
+
+#define MOVINAND_DEV "/dev/mmcblk0p1"
+#define FORMAT_MMC PREFIX"/sbin/mkfs.vfat "
+#define FORMAT_MOVINAND PREFIX"/bin/movi_format.sh"
+
+int mmc_status;
+
+int get_mmcblk_num()
+{
+ DIR *dp;
+ struct dirent *dir;
+ struct stat stat;
+ char buf[255];
+ int fd;
+ int r;
+ int mmcblk_num;
+
+ if ((dp = opendir("/sys/block")) == NULL) {
+ PRT_TRACE_ERR("Can not open directory..\n");
+ return -1;
+ }
+ chdir("/sys/block");
+
+ while ((dir = readdir(dp)) != NULL) {
+ memset(&stat, 0, sizeof(struct stat));
+ if (lstat(dir->d_name, &stat) < 0)
+ continue;
+ if (S_ISDIR(stat.st_mode) || S_ISLNK(stat.st_mode)) {
+ if (strncmp(".", dir->d_name, 1) == 0
+ || strncmp("..", dir->d_name, 2) == 0)
+ continue;
+ if (strncmp("mmcblk", dir->d_name, 6) == 0) {
+ snprintf(buf, 255, "/sys/block/%s/device/type",
+ dir->d_name);
+
+ fd = open(buf, O_RDONLY);
+ if (fd == -1) {
+ PRT_TRACE_ERR("%s open error: %s", buf,
+ strerror(errno));
+ continue;
+ }
+ r = read(fd, buf, 10);
+ if ((r >= 0) && (r < 10))
+ buf[r] = '\0';
+ else
+ PRT_TRACE_ERR("%s read error: %s", buf,
+ strerror(errno));
+ close(fd);
+ if (strncmp("SD", buf, 2) == 0) {
+ char *str_mmcblk_num = strndup((dir->d_name) + 6, 1);
+ if (str_mmcblk_num == NULL) {
+ PRT_TRACE_ERR("Memory Allocation Failed");
+ closedir(dp);
+ return -1;
+ }
+ mmcblk_num =
+ atoi(str_mmcblk_num);
+
+ free(str_mmcblk_num);
+ closedir(dp);
+ PRT_TRACE("%d \n", mmcblk_num);
+ return mmcblk_num;
+ }
+ }
+
+ }
+ }
+ closedir(dp);
+ PRT_TRACE_ERR("Failed to find mmc block number\n");
+ return -1;
+}
+
+static int ss_mmc_format(keynode_t *key_nodes, void *data)
+{
+ PRT_TRACE_ERR("mmc format called");
+ device_set_property(DEVTYPE_MMC, MMC_PROP_FORMAT, 0);
+
+ return 0;
+}
+
+int ss_mmc_unmounted(int argc, char **argv)
+{
+ int option = -1;
+
+ if (argc < 1) {
+ PRT_TRACE_ERR("Option is wong");
+ return -1;
+ }
+ if ((option = atoi(argv[0])) < 0) {
+ PRT_TRACE_ERR("Option is wong : %d", option);
+ return -1;
+ }
+
+ if (umount2(MMC_MOUNT_POINT, option) != 0) {
+ PRT_TRACE_ERR("Failed to unmount mmc card\n");
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_UNMOUNT,
+ VCONFKEY_SYSMAN_MMC_UNMOUNT_FAILED);
+ return -1;
+
+ }
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_UNMOUNT,
+ VCONFKEY_SYSMAN_MMC_UNMOUNT_COMPLETED);
+ mmc_status = VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED;
+
+ return 0;
+}
+
+int ss_mmc_init()
+{
+ /* mmc card mount */
+ ss_mmc_inserted();
+
+ ss_action_entry_add_internal(PREDEF_MOUNT_MMC, ss_mmc_inserted, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_UNMOUNT_MMC, ss_mmc_unmounted, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_FORMAT_MMC, ss_mmc_format, NULL,
+ NULL);
+ return 0;
+}
+
+int ss_mmc_inserted()
+{
+ char buf[NAME_MAX];
+ int blk_num, ret, retry = 0;
+ char opt[NAME_MAX];
+ char *popt = opt;
+ int r = 0;
+ if (mmc_status == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+ PRT_DBG("Mmc is already mounted.\n");
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_MOUNTED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT,
+ VCONFKEY_SYSMAN_MMC_MOUNT_ALREADY);
+ return -1;
+ }
+
+ if (access(MMC_MOUNT_POINT, R_OK) != 0) {
+ r = mkdir(MMC_MOUNT_POINT, 0755);
+ if(r < 0) {
+ PRT_TRACE_ERR("Make Directory is failed");
+ return -1;
+ }
+ }
+
+ if ((blk_num = get_mmcblk_num()) == -1) {
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_REMOVED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT,
+ VCONFKEY_SYSMAN_MMC_MOUNT_FAILED);
+ mmc_status = VCONFKEY_SYSMAN_MMC_REMOVED;
+ return 0;
+ }
+ popt = NULL;
+
+ snprintf(buf, sizeof(buf), "%s%d", MMC_DEV, blk_num);
+ if (mount
+ (buf, MMC_MOUNT_POINT, "vfat", 0,
+ "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed,smackfsroot=*,smackfsdef=*")
+ == 0) {
+ PRT_DBG("Mounted mmc card\n");
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_MOUNTED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT,
+ VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED);
+ mmc_status = VCONFKEY_SYSMAN_MMC_MOUNTED;
+ return 0;
+ }
+ do {
+ snprintf(buf, sizeof(buf), "%s%dp1", MMC_DEV, blk_num);
+ if ((ret =
+ mount(buf, MMC_MOUNT_POINT, "vfat", 0,
+ "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed,smackfsroot=*,smackfsdef=*"))
+ == 0) {
+ PRT_DBG("Mounted mmc card partition 1(%s)\n", buf);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_MOUNTED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT,
+ VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED);
+ mmc_status = VCONFKEY_SYSMAN_MMC_MOUNTED;
+ return 0;
+ }
+ usleep(100000);
+ } while (ret == -1 && errno == ENOENT && retry++ < 10);
+
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
+ VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED);
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT,
+ VCONFKEY_SYSMAN_MMC_MOUNT_FAILED);
+ mmc_status = VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED;
+ PRT_TRACE_ERR("Failed to mount mmc card\n");
+ return -1;
+}
+
+int ss_mmc_removed()
+{
+ vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS, VCONFKEY_SYSMAN_MMC_REMOVED);
+
+ if (umount2(MMC_MOUNT_POINT, MNT_DETACH) != 0) {
+ PRT_TRACE_ERR("Failed to unmount mmc card\n");
+ }
+ mmc_status = VCONFKEY_SYSMAN_MMC_REMOVED;
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <heynoti.h>
+#include "ss_log.h"
+
+static int noti_fd;
+
+int ss_noti_getfd()
+{
+ return noti_fd;
+}
+
+int ss_noti_send(char *filename)
+{
+ return heynoti_publish(filename);
+}
+
+int ss_noti_init()
+{
+ noti_fd = heynoti_init();
+ if (noti_fd < 0) {
+ PRT_TRACE_ERR("heynoti_init error");
+ return -1;
+ }
+
+ if (heynoti_attach_handler(noti_fd) < 0) {
+ PRT_TRACE_ERR("heynoti_attach_handler error");
+ return -1;
+ }
+
+ return 0;
+}
+
+int ss_noti_add(const char *noti, void (*cb) (void *), void *data)
+{
+ if (noti_fd < 0)
+ return -1;
+
+ return heynoti_subscribe(noti_fd, noti, cb, data);
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_NOTI_H__
+#define __SS_NOTI_H__
+
+int ss_noti_getfd(void);
+int ss_noti_send(char *filename);
+int ss_noti_add(const char *noti, void (*cb) (void *), void *data);
+int ss_noti_init(void);
+
+#endif /* __SS_NOTI_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sysman.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "ss_device_plugin.h"
+#include "ss_log.h"
+#include "ss_launch.h"
+#include "include/ss_data.h"
+
+#define PMON_PERMANENT_DIR "/tmp/permanent"
+
+static int pmon_fd = -1;
+
+static int replace_char(int size, char *t)
+{
+ while (size > 0) {
+ if (*t == 0)
+ *t = ' ';
+ size--;
+ t++;
+ }
+ return 0;
+}
+
+static char *pmon_get_permanent_pname(int pid)
+{
+ int fd;
+ char buf[PATH_MAX];
+ struct stat st;
+ char *cmdline = NULL;
+
+ snprintf(buf, sizeof(buf), "%s/%d", PMON_PERMANENT_DIR, pid);
+ fd = open(buf, O_RDONLY);
+ if (fd == -1) {
+ PRT_TRACE_ERR("file open error");
+ return NULL;
+ }
+
+ if (fstat(fd, &st) < 0) {
+ PRT_TRACE_ERR("fstat error");
+ close(fd);
+ return NULL;
+ }
+
+ PRT_TRACE("size = %d", (int)st.st_size);
+
+ cmdline = malloc(st.st_size + 1);
+ if (cmdline == NULL) {
+ PRT_TRACE_ERR("Not enough memory");
+ close(fd);
+ return NULL;
+ }
+ memset(cmdline, 0, st.st_size + 1);
+
+ read(fd, cmdline, st.st_size);
+ /* TODO - must change more smarter */
+ replace_char(st.st_size - 1, cmdline);
+ close(fd);
+
+ return cmdline;
+}
+
+static void print_pmon_state(unsigned int dead_pid)
+{
+ PRT_TRACE("[Process MON] %d killed", dead_pid);
+}
+
+static int pmon_process(int pid, void *ad)
+{
+ char *cmdline;
+ int new_pid;
+ char old_file[PATH_MAX];
+ int fd;
+ int r;
+
+ if (sysconf_is_vip(pid)) {
+ PRT_TRACE_ERR("=======================================");
+ PRT_TRACE_ERR("[Process MON] VIP process dead.");
+ PRT_TRACE_ERR("=======================================");
+ }
+ /* If there is NOT a .hibernation_start file, run following codes
+ * On hibernation processing, just ignore relaunching */
+ else if (access("/tmp/.hibernation_start", R_OK) != 0) {
+ cmdline = pmon_get_permanent_pname(pid);
+ if (cmdline != NULL) {
+ PRT_TRACE("[Process MON] %s relaunch", cmdline);
+ new_pid = ss_launch_evenif_exist(cmdline, "");
+ free(cmdline);
+ if (new_pid > 0) {
+ /* TODO - set oom */
+ char buf[PATH_MAX];
+ char filepath[PATH_MAX];
+ int cnt;
+
+ if (access(PMON_PERMANENT_DIR, R_OK) < 0) {
+ PRT_TRACE("no predefined matrix dir = %s, so created", PMON_PERMANENT_DIR);
+ r = mkdir(PMON_PERMANENT_DIR, 0777);
+ if(r < 0) {
+ PRT_TRACE("Make Directory is failed");
+ return -1;
+ }
+ }
+
+ snprintf(filepath, sizeof(filepath), "%s/%d", PMON_PERMANENT_DIR, pid);
+ fd = open(filepath, O_RDONLY);
+ if (fd == -1) {
+ PRT_TRACE("Failed to open");
+ return -1;
+ }
+
+ cnt = read(fd, buf, PATH_MAX);
+ close(fd);
+
+ if (cnt <= 0) {
+ PRT_TRACE("Failed to read");
+ return -1;
+ }
+
+ snprintf(filepath, sizeof(filepath), "%s/%d", PMON_PERMANENT_DIR, new_pid);
+
+ fd = open(filepath, O_CREAT | O_WRONLY, 0644);
+ if (fd == -1) {
+ PRT_TRACE("Failed to open");
+ return -1;
+ }
+
+ if (write(fd, buf, cnt) == -1) {
+ PRT_TRACE("Failed to write");
+ close(fd);
+ return -1;
+ }
+ close(fd);
+
+ if (0 > plugin_intf->OEM_sys_set_process_monitor_mp_pnp(new_pid)) {
+ PRT_TRACE_ERR("Write new pid failed");
+ }
+ PRT_TRACE("[Process MON] %d ", new_pid);
+
+ FILE *fp;
+
+ PRT_TRACE
+ ("[Process MON] OOMADJ_SET : pid %d, new_oomadj %d",
+ new_pid, (-17));
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj",
+ new_pid);
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return -1;
+ fprintf(fp, "%d", (-17));
+ fclose(fp);
+
+ snprintf(old_file, sizeof(old_file), "%s/%d",
+ PMON_PERMANENT_DIR, pid);
+ unlink(old_file);
+ } else {
+ PRT_TRACE_ERR("[Process MON] failed relaunching");
+ }
+ }
+ }
+ return 0;
+}
+/*
+static unsigned int pmon_read(int fd)
+{
+ unsigned int pid;
+ read(fd, &pid, sizeof(pid));
+ return pid;
+}
+*/
+
+static int pmon_cb(void *data, Ecore_Fd_Handler * fd_handler)
+{
+ int fd;
+ struct ss_main_data *ad = (struct ss_main_data *)data;
+ int dead_pid;
+
+ if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
+ PRT_TRACE_ERR
+ ("ecore_main_fd_handler_active_get error , return\n");
+ return 1;
+ }
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+
+ if (fd < 0) {
+ PRT_TRACE_ERR("ecore_main_fd_handler_fd_get error , return");
+ return 1;
+ }
+ if ((read(fd, &dead_pid, sizeof(dead_pid))) < 0) {
+ PRT_TRACE_ERR("Reading DEAD_PID failed, Return");
+ return 1;
+ }
+
+ print_pmon_state(dead_pid);
+ pmon_process(dead_pid, ad);
+
+ return 1;
+}
+
+int ss_pmon_init(struct ss_main_data *ad)
+{
+ char pmon_dev_node[PATH_MAX];
+
+ if (0 > plugin_intf->OEM_sys_get_process_monitor_node(pmon_dev_node)) {
+ PRT_TRACE_ERR("ss_pmon_init get dev node path failed");
+ return -1;
+ }
+
+ pmon_fd = open(pmon_dev_node, O_RDONLY);
+ if (pmon_fd < 0) {
+ PRT_TRACE_ERR("ss_pmon_init fd open failed");
+ return -1;
+ }
+ ecore_main_fd_handler_add(pmon_fd, ECORE_FD_READ, pmon_cb, ad, NULL,
+ NULL);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_PMON_HANDLER_H__
+#define __SS_PMON_HANDLER_H__
+
+#include "include/ss_data.h"
+
+int ss_pmon_init(struct ss_main_data *ad);
+
+#endif /* __SS_PMON_HANDLER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <unistd.h>
+#include <time.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sysman.h>
+#include <vconf.h>
+#include <pmapi.h>
+#include <ITapiModem.h>
+#include <TelPower.h>
+#include <tapi_event.h>
+#include <tapi_common.h>
+#include <syspopup_caller.h>
+#include <sys/reboot.h>
+#include <sys/time.h>
+
+#include "ss_log.h"
+#include "ss_launch.h"
+#include "ss_queue.h"
+#include "ss_device_handler.h"
+#include "ss_device_plugin.h"
+#include "ss_predefine.h"
+#include "ss_procmgr.h"
+#include "include/ss_data.h"
+
+#define PREDEFINE_SO_DIR PREFIX"/lib/ss_predefine/"
+
+#define CALL_EXEC_PATH PREFIX"/bin/call"
+#define LOWMEM_EXEC_PATH PREFIX"/bin/lowmem-popup"
+#define LOWBAT_EXEC_PATH PREFIX"/bin/lowbatt-popup"
+#define USBCON_EXEC_PATH PREFIX"/bin/usb-server"
+#define TVOUT_EXEC_PATH PREFIX"/bin/tvout-selector"
+#define PWROFF_EXEC_PATH PREFIX"/bin/poweroff-popup"
+#define MEMPS_EXEC_PATH PREFIX"/bin/memps"
+
+/* wait for 5 sec as victim process be dead */
+#define WAITING_INTERVAL 5
+
+#define TVOUT_X_BIN "/usr/bin/xberc"
+#define TVOUT_FLAG 0x00000001
+#define MEMPS_LOG_FILE "/var/log/memps"
+#define MAX_RETRY 2
+
+#define POWEROFF_DURATION 2
+#define POWEROFF_ANIMATION_PATH "/usr/bin/boot-animation"
+#define POWEROFF_NOTI_NAME "power_off_start"
+
+#define WM_READY_PATH "/tmp/.wm_ready"
+
+#define LOWBAT_OPT_WARNING 1
+#define LOWBAT_OPT_POWEROFF 2
+#define LOWBAT_OPT_CHARGEERR 3
+#define LOWBAT_OPT_CHECK 4
+
+static Ecore_Timer *lowbat_popup_id = NULL;
+static int lowbat_popup_option = 0;
+
+static struct timeval tv_start_poweroff;
+static void powerdown_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+
+static int ss_flags = 0;
+
+static Ecore_Timer *poweroff_timer_id = NULL;
+static TapiHandle *tapi_handle = NULL;
+
+static void make_memps_log(char *file, pid_t pid, char *victim_name)
+{
+ time_t now;
+ struct tm cur_tm;
+ char params[4096];
+ char new_log[NAME_MAX];
+ static pid_t old_pid = 0;
+ int ret=-1;
+
+ if (old_pid == pid)
+ return;
+ old_pid = pid;
+
+ now = time(NULL);
+
+ if (localtime_r(&now, &cur_tm) == NULL) {
+ PRT_TRACE_ERR("Fail to get localtime");
+ return;
+ }
+
+ PRT_TRACE("%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
+ pid, (1900 + cur_tm.tm_year), 1 + cur_tm.tm_mon,
+ cur_tm.tm_mday, cur_tm.tm_hour, cur_tm.tm_min,
+ cur_tm.tm_sec);
+ snprintf(new_log, sizeof(new_log),
+ "%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
+ pid, (1900 + cur_tm.tm_year), 1 + cur_tm.tm_mon,
+ cur_tm.tm_mday, cur_tm.tm_hour, cur_tm.tm_min,
+ cur_tm.tm_sec);
+
+ snprintf(params, sizeof(params), "-f %s", new_log);
+ ret = ss_launch_evenif_exist(MEMPS_EXEC_PATH, params);
+
+ if(ret > 0) {
+ char buf[PATH_MAX];
+ FILE *fp;
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", ret);
+ fp = fopen(buf, "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d", (-17));
+ fclose(fp);
+ }
+ }
+}
+
+static int lowmem_get_victim_pid()
+{
+ pid_t pid;
+ int fd;
+
+ if (0 > plugin_intf->OEM_sys_get_memnotify_victim_task(&pid)) {
+ PRT_TRACE_ERR("Get victim task failed");
+ return -1;
+ }
+
+ return pid;
+}
+
+int lowmem_def_predefine_action(int argc, char **argv)
+{
+ int pid, ret, oom_adj;
+ char appname[PATH_MAX];
+
+ if (argc < 1)
+ return -1;
+
+ if (!strcmp(argv[0], OOM_MEM_ACT)) {
+ pid = lowmem_get_victim_pid();
+ if (pid > 0 && pid != sysman_get_pid(LOWMEM_EXEC_PATH) && pid != sysman_get_pid(MEMPS_EXEC_PATH)) {
+ if ((sysman_get_cmdline_name(pid, appname, PATH_MAX)) ==
+ 0) {
+ PRT_TRACE_EM
+ ("we will kill, lowmem lv2 = %d (%s)\n",
+ pid, appname);
+
+ make_memps_log(MEMPS_LOG_FILE, pid, appname);
+
+ if(get_app_oomadj(pid, &oom_adj) < 0) {
+ PRT_TRACE_ERR("Failed to get oom_adj");
+ }
+ PRT_TRACE("%d will be killed with %d oom_adj value", pid, oom_adj);
+
+ kill(pid, SIGTERM);
+
+ if (oom_adj != OOMADJ_FOREGRD_LOCKED && oom_adj != OOMADJ_FOREGRD_UNLOCKED) {
+ return 0;
+ }
+
+ bundle *b = NULL;
+
+ b = bundle_create();
+ bundle_add(b, "_APP_NAME_", appname);
+ ret = syspopup_launch("lowmem-syspopup", b);
+ bundle_free(b);
+ if (ret < 0) {
+ PRT_TRACE_EM("popup lauch failed\n");
+ return -1;
+ }
+
+ if (set_app_oomadj(ret, OOMADJ_SU) < 0) {
+ PRT_TRACE_ERR("Failed to set oom_adj");
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+int usbcon_def_predefine_action(int argc, char **argv)
+{
+ int pid;
+ int val = -1;
+ int ret = -1;
+ int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
+
+ if (plugin_intf->OEM_sys_get_jack_usb_online(&val) == 0) {
+ if (val == 0) {
+ vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
+ VCONFKEY_SYSMAN_USB_DISCONNECTED);
+ pm_unlock_state(LCD_OFF, STAY_CUR_STATE);
+ return 0;
+ }
+
+ vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
+ VCONFKEY_SYSMAN_USB_AVAILABLE);
+ pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ pid = ss_launch_if_noexist(USBCON_EXEC_PATH, NULL);
+ if (pid < 0) {
+ PRT_TRACE_ERR("usb predefine action failed\n");
+ return -1;
+ }
+ return pid;
+ }
+ PRT_TRACE_ERR("failed to get usb status\n");
+ return -1;
+}
+
+int earjackcon_def_predefine_action(int argc, char **argv)
+{
+ int val;
+
+ PRT_TRACE_EM("earjack_normal predefine action\n");
+ if (plugin_intf->OEM_sys_get_jack_earjack_online(&val) == 0) {
+ return vconf_set_int(VCONFKEY_SYSMAN_EARJACK, val);
+ }
+
+ return -1;
+}
+
+int lowbat_popup(void *data)
+{
+ int ret = -1, state = 0;
+ ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &state);
+ if (state == 1 || ret != 0) {
+ bundle *b = NULL;
+ b = bundle_create();
+ if(lowbat_popup_option == LOWBAT_OPT_WARNING) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
+ } else if(lowbat_popup_option == LOWBAT_OPT_POWEROFF) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "poweroff");
+ } else if(lowbat_popup_option == LOWBAT_OPT_CHARGEERR) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "chargeerr");
+ } else {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "check");
+ }
+
+ ret = syspopup_launch("lowbat-syspopup", b);
+ if (ret < 0) {
+ PRT_TRACE_EM("popup lauch failed\n");
+ bundle_free(b);
+ return 1;
+ }
+ lowbat_popup_id = NULL;
+ lowbat_popup_option = 0;
+ bundle_free(b);
+ } else {
+ PRT_TRACE_EM("boot-animation running yet");
+ return 1;
+ }
+
+ return 0;
+}
+
+int lowbat_def_predefine_action(int argc, char **argv)
+{
+ int ret, state=0;
+ char argstr[128];
+ char* option = NULL;
+
+ if (argc < 1)
+ return -1;
+
+ if(lowbat_popup_id != NULL) {
+ ecore_timer_del(lowbat_popup_id);
+ lowbat_popup_id = NULL;
+ }
+
+ bundle *b = NULL;
+ b = bundle_create();
+ if(!strcmp(argv[0],WARNING_LOW_BAT_ACT) || !strcmp(argv[0],CRITICAL_LOW_BAT_ACT)) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
+ lowbat_popup_option = LOWBAT_OPT_WARNING;
+ } else if(!strcmp(argv[0],POWER_OFF_BAT_ACT)) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "poweroff");
+ lowbat_popup_option = LOWBAT_OPT_POWEROFF;
+ } else if(!strcmp(argv[0],CHARGE_ERROR_ACT)) {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "chargeerr");
+ lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
+ } else {
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "check");
+ lowbat_popup_option = LOWBAT_OPT_CHECK;
+ }
+
+ ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &state);
+ if (state == 1 || ret != 0) {
+ ret = syspopup_launch("lowbat-syspopup", b);
+ if (ret < 0) {
+ PRT_TRACE_EM("popup lauch failed\n");
+ bundle_free(b);
+ lowbat_popup_option = 0;
+ return -1;
+ }
+ } else {
+ PRT_TRACE_EM("boot-animation running yet");
+ lowbat_popup_id = ecore_timer_add(1, lowbat_popup, NULL);
+ }
+ bundle_free(b);
+ return 0;
+}
+
+Eina_Bool powerdown_ap_by_force(void *data)
+{
+ struct timeval now;
+ int poweroff_duration = POWEROFF_DURATION;
+ char *buf;
+
+ if(tapi_handle != NULL)
+ {
+ tel_deinit(tapi_handle);
+ tapi_handle = NULL;
+ }
+ /* Getting poweroff duration */
+ buf = getenv("PWROFF_DUR");
+ if (buf != NULL && strlen(buf) < 1024)
+ poweroff_duration = atoi(buf);
+ if (poweroff_duration < 0 || poweroff_duration > 60)
+ poweroff_duration = POWEROFF_DURATION;
+
+ gettimeofday(&now, NULL);
+ /* Waiting until power off duration and displaying animation */
+ while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
+ usleep(100000);
+ gettimeofday(&now, NULL);
+ }
+
+ PRT_TRACE("Power off by force\n");
+ kill(-1, SIGTERM);
+ /* give a chance to be terminated for each process */
+ sleep(1);
+ sync();
+ reboot(RB_POWER_OFF);
+ return EINA_TRUE;
+}
+
+static void powerdown_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ struct timeval now;
+ int poweroff_duration = POWEROFF_DURATION;
+ char *buf;
+
+ if (poweroff_timer_id) {
+ ecore_timer_del(poweroff_timer_id);
+ poweroff_timer_id = NULL;
+ }
+ if (tapi_handle) {
+ tel_deregister_noti_event(tapi_handle,TAPI_NOTI_MODEM_POWER);
+ tel_deinit(tapi_handle);
+ tapi_handle = NULL;
+ }
+ PRT_TRACE("Power off \n");
+
+ /* Getting poweroff duration */
+ buf = getenv("PWROFF_DUR");
+ if (buf != NULL && strlen(buf) < 1024)
+ poweroff_duration = atoi(buf);
+ if (poweroff_duration < 0 || poweroff_duration > 60)
+ poweroff_duration = POWEROFF_DURATION;
+
+ gettimeofday(&now, NULL);
+ /* Waiting until power off duration and displaying animation */
+ while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
+ usleep(100000);
+ gettimeofday(&now, NULL);
+ }
+
+ kill(-1, SIGTERM);
+ /* give a chance to be terminated for each process */
+ sleep(1);
+ sync();
+ reboot(RB_POWER_OFF);
+}
+static void powerdown_res_cb(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ PRT_TRACE("poweroff command request : %d",result);
+}
+int poweroff_def_predefine_action(int argc, char **argv)
+{
+ int ret;
+
+ heynoti_publish(POWEROFF_NOTI_NAME);
+
+ pm_change_state(LCD_NORMAL);
+ system("/etc/rc.d/rc.shutdown &");
+ sync();
+
+ gettimeofday(&tv_start_poweroff, NULL);
+ if (tapi_handle) {
+ ret = tel_register_noti_event(tapi_handle, TAPI_NOTI_MODEM_POWER, powerdown_ap, NULL);
+
+ if (ret != TAPI_API_SUCCESS) {
+ PRT_TRACE_ERR
+ ("tel_register_event is not subscribed. error %d\n", ret);
+ powerdown_ap_by_force(NULL);
+ return 0;
+ }
+
+ ret = tel_process_power_command(tapi_handle, TAPI_PHONE_POWER_OFF, powerdown_res_cb, NULL);
+ if (ret != TAPI_API_SUCCESS) {
+ PRT_TRACE_ERR("tel_process_power_command() error %d\n", ret);
+ powerdown_ap_by_force(NULL);
+ return 0;
+ }
+ poweroff_timer_id = ecore_timer_add(15, powerdown_ap_by_force, NULL);
+ } else {
+ powerdown_ap_by_force(NULL);
+ }
+ return 0;
+}
+
+static void enter_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ int bCurFlightMode = 0;
+ if (result != TAPI_POWER_FLIGHT_MODE_ENTER) {
+ PRT_TRACE_ERR("flight mode enter failed %d",result);
+ } else {
+ PRT_TRACE("enter flight mode result : %d",result);
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE,&bCurFlightMode) == 0) {
+ PRT_TRACE("Flight Mode is %d", bCurFlightMode);
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ }
+ }
+}
+
+static void leave_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ int bCurFlightMode = 0;
+ if (result != TAPI_POWER_FLIGHT_MODE_LEAVE) {
+ PRT_TRACE_ERR("flight mode leave failed %d",result);
+ } else {
+ PRT_TRACE("leave flight mode result : %d",result);
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE,&bCurFlightMode) == 0) {
+ PRT_TRACE("Flight Mode is %d", bCurFlightMode);
+ } else {
+ PRT_TRACE_ERR("failed to get vconf key");
+ }
+ }
+}
+
+int entersleep_def_predefine_action(int argc, char **argv)
+{
+ int ret;
+
+ pm_change_state(LCD_NORMAL);
+ sync();
+
+ ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_ENTER, enter_flight_mode_cb, NULL);
+ PRT_TRACE_ERR("request for changing into flight mode : %d\n", ret);
+
+ system("/etc/rc.d/rc.entersleep");
+ pm_change_state(POWER_OFF);
+
+ return 0;
+}
+
+int leavesleep_def_predefine_action(int argc, char **argv)
+{
+ int ret;
+
+ pm_change_state(LCD_NORMAL);
+ sync();
+
+ ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE, leave_flight_mode_cb, NULL);
+ PRT_TRACE_ERR("request for changing into flight mode : %d\n", ret);
+
+ return 0;
+}
+
+static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+
+Eina_Bool restart_ap_ecore(void *data)
+{
+ restart_ap(tapi_handle,NULL,(void *)-1,NULL);
+ return EINA_TRUE;
+}
+
+static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ struct timeval now;
+ int poweroff_duration = POWEROFF_DURATION;
+ char *buf;
+
+ if (poweroff_timer_id) {
+ ecore_timer_del(poweroff_timer_id);
+ poweroff_timer_id = NULL;
+ }
+
+
+ if(tapi_handle != NULL)
+ {
+ tel_deregister_noti_event(tapi_handle,TAPI_NOTI_MODEM_POWER);
+ tel_deinit(tapi_handle);
+ tapi_handle = NULL;
+ }
+
+ PRT_INFO("Restart\n");
+ sync();
+
+ buf = getenv("PWROFF_DUR");
+ if (buf != NULL && strlen(buf) < 1024)
+ poweroff_duration = atoi(buf);
+ if (poweroff_duration < 0 || poweroff_duration > 60)
+ poweroff_duration = POWEROFF_DURATION;
+ gettimeofday(&now, NULL);
+ while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
+ usleep(100000);
+ gettimeofday(&now, NULL);
+ }
+
+ reboot(RB_AUTOBOOT);
+}
+
+static void restart_ap_by_force(void *data)
+{
+ struct timeval now;
+ int poweroff_duration = POWEROFF_DURATION;
+ char *buf;
+
+ if (poweroff_timer_id) {
+ ecore_timer_del(poweroff_timer_id);
+ poweroff_timer_id = NULL;
+ }
+
+
+ if(tapi_handle != NULL)
+ {
+ tel_deinit(tapi_handle);
+ tapi_handle = NULL;
+ }
+
+ PRT_INFO("Restart\n");
+ sync();
+
+ buf = getenv("PWROFF_DUR");
+ if (buf != NULL && strlen(buf) < 1024)
+ poweroff_duration = atoi(buf);
+ if (poweroff_duration < 0 || poweroff_duration > 60)
+ poweroff_duration = POWEROFF_DURATION;
+ gettimeofday(&now, NULL);
+ while (now.tv_sec - tv_start_poweroff.tv_sec < poweroff_duration) {
+ usleep(100000);
+ gettimeofday(&now, NULL);
+ }
+
+ reboot(RB_AUTOBOOT);
+}
+
+int restart_def_predefine_action(int argc, char **argv)
+{
+ int ret;
+
+ pm_change_state(LCD_NORMAL);
+ system("/etc/rc.d/rc.shutdown &");
+ sync();
+
+ gettimeofday(&tv_start_poweroff, NULL);
+
+ ret =
+ tel_register_noti_event(tapi_handle, TAPI_NOTI_MODEM_POWER, restart_ap, NULL);
+ if (ret != TAPI_API_SUCCESS) {
+ PRT_TRACE_ERR
+ ("tel_register_event is not subscribed. error %d\n", ret);
+ restart_ap_by_force((void *)-1);
+ return 0;
+ }
+
+
+ ret = tel_process_power_command(tapi_handle, TAPI_PHONE_POWER_OFF, powerdown_res_cb, NULL);
+ if (ret != TAPI_API_SUCCESS) {
+ PRT_TRACE_ERR("tel_process_power_command() error %d\n", ret);
+ restart_ap_by_force((void *)-1);
+ return 0;
+ }
+
+ poweroff_timer_id = ecore_timer_add(15, restart_ap_ecore, NULL);
+ return 0;
+}
+
+int launching_predefine_action(int argc, char **argv)
+{
+ int ret;
+
+ if (argc < 0)
+ return -1;
+
+ /* current just launching poweroff-popup */
+ ret = syspopup_launch("poweroff-syspopup", NULL);
+ if (ret < 0) {
+ PRT_TRACE_ERR("poweroff popup predefine action failed");
+ return -1;
+ }
+ return 0;
+}
+
+int flight_mode_def_predefine_action(int argc, char **argv)
+{
+ int bCurFlightMode;
+ int err = TAPI_API_SUCCESS;
+ if (argc != 1 || argv[0] == NULL) {
+ PRT_TRACE_ERR("FlightMode Set predefine action failed");
+ return -1;
+ }
+ bCurFlightMode = atoi(argv[0]);
+ if (bCurFlightMode == 1) {
+ err = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE, leave_flight_mode_cb, NULL);
+ } else if (bCurFlightMode == 0) {
+ err = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_ENTER, enter_flight_mode_cb, NULL);
+ }
+ if (err != TAPI_API_SUCCESS)
+ PRT_TRACE_ERR("FlightMode tel api action failed %d",err);
+ return 0;
+
+}
+static void ss_action_entry_load_from_sodir()
+{
+ DIR *dp;
+ struct dirent *dentry;
+ struct sysnoti *msg;
+ char *ext;
+ char tmp[128];
+
+ dp = opendir(PREDEFINE_SO_DIR);
+ if (!dp) {
+ ERR("fail open %s", PREDEFINE_SO_DIR);
+ return;
+ }
+
+ msg = malloc(sizeof(struct sysnoti));
+ if (msg == NULL) {
+ ERR("Malloc failed");
+ closedir(dp);
+ return;
+ }
+
+ msg->pid = getpid();
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if ((ext = strstr(dentry->d_name, ".so")) == NULL)
+ continue;
+
+ snprintf(tmp, sizeof(tmp), "%s/%s", PREDEFINE_SO_DIR,
+ dentry->d_name);
+ msg->path = tmp;
+ *ext = 0;
+ msg->type = &(dentry->d_name[3]);
+ ss_action_entry_add(msg);
+ }
+ free(msg);
+
+ closedir(dp);
+}
+static void __tel_init_cb(keynode_t *key_nodes,void *data)
+{
+ int bTelReady = 0;
+ bTelReady = vconf_keynode_get_bool(key_nodes);
+ if (bTelReady == 1) {
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_READY, (void*)__tel_init_cb);
+ tapi_handle = tel_init(NULL);
+ if (tapi_handle == NULL) {
+ PRT_TRACE_ERR("tapi init error");
+ }
+ } else {
+ PRT_TRACE_ERR("tapi is not ready yet");
+ }
+}
+void ss_predefine_internal_init(void)
+{
+
+ /* telephony initialize */
+ int ret = 0;
+ int bTelReady = 0;
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_READY,&bTelReady) == 0) {
+ if (bTelReady == 1) {
+ tapi_handle = tel_init(NULL);
+ if (tapi_handle == NULL) {
+ PRT_TRACE_ERR("tapi init error");
+ }
+ } else {
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY, (void *)__tel_init_cb, NULL);
+ }
+ } else {
+ PRT_TRACE_ERR("failed to get tapi vconf key");
+ }
+#ifdef NOUSE
+ ss_action_entry_add_internal(PREDEF_CALL, call_predefine_action, NULL,
+ NULL);
+#endif
+ ss_action_entry_add_internal(PREDEF_LOWMEM, lowmem_def_predefine_action,
+ NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_LOWBAT, lowbat_def_predefine_action,
+ NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_USBCON, usbcon_def_predefine_action,
+ NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_EARJACKCON,
+ earjackcon_def_predefine_action, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_POWEROFF,
+ poweroff_def_predefine_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_PWROFF_POPUP,
+ launching_predefine_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_REBOOT,
+ restart_def_predefine_action, NULL, NULL);
+
+ ss_action_entry_add_internal(PREDEF_FLIGHT_MODE,
+ flight_mode_def_predefine_action, NULL, NULL);
+ ss_action_entry_load_from_sodir();
+
+ /* check and set earjack init status */
+ earjackcon_def_predefine_action(0, NULL);
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_PREDEFINE_H__
+#define __SS_PREDEFINE_H__
+
+int call_predefine_action(int argc, char **argv);
+void ss_predefine_internal_init(void);
+
+#endif /* __SS_PREDEFINE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdbool.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+
+#include <sysman.h>
+#include "include/ss_data.h"
+#include "ss_queue.h"
+#include "ss_log.h"
+
+#define LIMITED_BACKGRD_NUM 15
+#define MAX_BACKGRD_OOMADJ (OOMADJ_BACKGRD_UNLOCKED + LIMITED_BACKGRD_NUM)
+
+int get_app_oomadj(int pid, int *oomadj)
+{
+ if (pid < 0)
+ return -1;
+
+ char buf[PATH_MAX];
+ FILE *fp = NULL;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "r");
+ if (fp == NULL)
+ return -1;
+ if (fgets(buf, PATH_MAX, fp) == NULL) {
+ fclose(fp);
+ return -1;
+ }
+ (*oomadj) = atoi(buf);
+ fclose(fp);
+ return 0;
+}
+
+int set_app_oomadj(pid_t pid, int new_oomadj)
+{
+ char buf[PATH_MAX];
+ FILE *fp;
+ int old_oomadj;
+ char exe_name[PATH_MAX];
+
+ if (sysman_get_cmdline_name(pid, exe_name, PATH_MAX) < 0)
+ snprintf(exe_name, sizeof(exe_name), "Unknown (maybe dead)");
+
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "r");
+ if (fp == NULL)
+ return -1;
+ if (fgets(buf, PATH_MAX, fp) == NULL) {
+ fclose(fp);
+ return -1;
+ }
+ old_oomadj = atoi(buf);
+ fclose(fp);
+ PRT_TRACE_EM("Process %s, pid %d, old_oomadj %d", exe_name, pid,
+ old_oomadj);
+
+ if (old_oomadj < OOMADJ_APP_LIMIT)
+ return 0;
+
+ PRT_TRACE_EM("Process %s, pid %d, new_oomadj %d", exe_name, pid,
+ new_oomadj);
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return -1;
+
+ fprintf(fp, "%d", new_oomadj);
+ fclose(fp);
+
+ return 0;
+}
+
+int set_oomadj_action(int argc, char **argv)
+{
+ int pid = -1;
+ int new_oomadj = -20;
+
+ if (argc < 2)
+ return -1;
+ if ((pid = atoi(argv[0])) < 0 || (new_oomadj = atoi(argv[1])) <= -20)
+ return -1;
+
+ char buf[255];
+ FILE *fp;
+
+ PRT_TRACE_EM("OOMADJ_SET : pid %d, new_oomadj %d", pid, new_oomadj);
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return -1;
+ fprintf(fp, "%d", new_oomadj);
+ fclose(fp);
+
+ return 0;
+}
+
+static int update_backgrd_app_oomadj(pid_t pid, int new_oomadj)
+{
+ char buf[PATH_MAX];
+ FILE* fp;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return -1;
+
+ fprintf(fp, "%d", new_oomadj);
+ fclose(fp);
+
+ return 0;
+}
+
+int check_and_set_old_backgrd()
+{
+ int pid = -1;
+ DIR *dp;
+ struct dirent *dentry;
+ FILE *fp;
+ char buf[PATH_MAX];
+ int token =0;
+ int oom_adj, new_oomadj, i;
+ pid_t buckets[MAX_BACKGRD_OOMADJ][LIMITED_BACKGRD_NUM];
+
+ dp = opendir("/proc");
+ if (!dp) {
+ PRT_TRACE_EM("BACKGRD MANAGE : fail to open /proc : %s", strerror(errno));
+ return -1;
+ }
+
+ memset(buckets, 0, sizeof(buckets));
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ pid = atoi(dentry->d_name);
+
+ snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+ fp = fopen(buf, "r");
+ if (fp == NULL)
+ continue;
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ fclose(fp);
+ continue;
+ }
+ oom_adj = atoi(buf);
+ if (oom_adj < MAX_BACKGRD_OOMADJ && oom_adj >= OOMADJ_BACKGRD_UNLOCKED) {
+ pid_t *bucket = buckets[oom_adj];
+ for (i = 0; i < LIMITED_BACKGRD_NUM; i++) {
+ if (!bucket[i])
+ break;
+ }
+ if (i >= LIMITED_BACKGRD_NUM)
+ PRT_TRACE_EM("BACKGRB MANAGE : background applications(oom_adj %d) exceeds limitation", i);
+ else
+ bucket[i] = pid;
+ }
+ fclose(fp);
+ }
+ closedir(dp);
+
+ new_oomadj = OOMADJ_BACKGRD_UNLOCKED + 1;
+ for (oom_adj = OOMADJ_BACKGRD_UNLOCKED; oom_adj < MAX_BACKGRD_OOMADJ; oom_adj++) {
+ for (i = 0; i < LIMITED_BACKGRD_NUM; i++) {
+ pid = buckets[oom_adj][i];
+ if (!pid)
+ break;
+ if (new_oomadj >= MAX_BACKGRD_OOMADJ) {
+ PRT_TRACE("BACKGRD MANAGE : kill the process %d (oom_adj %d)", pid, MAX_BACKGRD_OOMADJ);
+ kill(pid, SIGTERM);
+ }
+ else {
+ if (new_oomadj != oom_adj)
+ update_backgrd_app_oomadj(pid, new_oomadj);
+ new_oomadj++;
+ }
+ }
+ }
+
+ return 0;
+}
+
+int set_active_action(int argc, char **argv)
+{
+ int pid = -1;
+ int ret = 0;
+ int oomadj = 0;
+
+ if (argc < 1)
+ return -1;
+ if ((pid = atoi(argv[0])) < 0)
+ return -1;
+
+ if (get_app_oomadj(pid, &oomadj) < 0)
+ return -1;
+
+ switch (oomadj) {
+ case OOMADJ_FOREGRD_LOCKED:
+ case OOMADJ_BACKGRD_LOCKED:
+ case OOMADJ_SU:
+ ret = 0;
+ break;
+ case OOMADJ_FOREGRD_UNLOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_LOCKED);
+ break;
+ case OOMADJ_BACKGRD_UNLOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_LOCKED);
+ break;
+ case OOMADJ_INIT:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_LOCKED);
+ break;
+ default:
+ if(oomadj > OOMADJ_BACKGRD_UNLOCKED) {
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_LOCKED);
+ } else {
+ PRT_TRACE_EM("Unknown oomadj value (%d) !", oomadj);
+ ret = -1;
+ }
+ break;
+ }
+ return ret;
+}
+
+int set_inactive_action(int argc, char **argv)
+{
+ int pid = -1;
+ int ret = 0;
+ int oomadj = 0;
+
+ if (argc < 1)
+ return -1;
+ if ((pid = atoi(argv[0])) < 0)
+ return -1;
+
+ if (get_app_oomadj(pid, &oomadj) < 0)
+ return -1;
+
+ switch (oomadj) {
+ case OOMADJ_FOREGRD_UNLOCKED:
+ case OOMADJ_BACKGRD_UNLOCKED:
+ case OOMADJ_SU:
+ ret = 0;
+ break;
+ case OOMADJ_FOREGRD_LOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_UNLOCKED);
+ break;
+ case OOMADJ_BACKGRD_LOCKED:
+ check_and_set_old_backgrd();
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_UNLOCKED);
+ break;
+ case OOMADJ_INIT:
+ check_and_set_old_backgrd();
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_UNLOCKED);
+ break;
+ default:
+ if(oomadj > OOMADJ_BACKGRD_UNLOCKED) {
+ ret = 0;
+ } else {
+ PRT_TRACE_EM("Unknown oomadj value (%d) !", oomadj);
+ ret = -1;
+ }
+ break;
+
+ }
+ return ret;
+}
+
+int set_foregrd_action(int argc, char **argv)
+{
+ int pid = -1;
+ int ret = 0;
+ int oomadj = 0;
+
+ if (argc < 1)
+ return -1;
+ if ((pid = atoi(argv[0])) < 0)
+ return -1;
+
+ if (get_app_oomadj(pid, &oomadj) < 0)
+ return -1;
+
+ switch (oomadj) {
+ case OOMADJ_FOREGRD_LOCKED:
+ case OOMADJ_FOREGRD_UNLOCKED:
+ case OOMADJ_SU:
+ ret = 0;
+ break;
+ case OOMADJ_BACKGRD_LOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_LOCKED);
+ break;
+ case OOMADJ_BACKGRD_UNLOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_UNLOCKED);
+ break;
+ case OOMADJ_INIT:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_UNLOCKED);
+ break;
+ default:
+ if(oomadj > OOMADJ_BACKGRD_UNLOCKED) {
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_FOREGRD_UNLOCKED);
+ } else {
+ PRT_TRACE_EM("Unknown oomadj value (%d) !", oomadj);
+ ret = -1;
+ }
+ break;
+
+ }
+ return ret;
+}
+
+int set_backgrd_action(int argc, char **argv)
+{
+ int pid = -1;
+ int ret = 0;
+ int oomadj = 0;
+
+ if (argc < 1)
+ return -1;
+ if ((pid = atoi(argv[0])) < 0)
+ return -1;
+
+ if (get_app_oomadj(pid, &oomadj) < 0)
+ return -1;
+
+ switch (oomadj) {
+ case OOMADJ_BACKGRD_LOCKED:
+ case OOMADJ_BACKGRD_UNLOCKED:
+ case OOMADJ_SU:
+ ret = 0;
+ break;
+ case OOMADJ_FOREGRD_LOCKED:
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_LOCKED);
+ break;
+ case OOMADJ_FOREGRD_UNLOCKED:
+ check_and_set_old_backgrd();
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_UNLOCKED);
+ break;
+ case OOMADJ_INIT:
+ check_and_set_old_backgrd();
+ ret = set_app_oomadj((pid_t) pid, OOMADJ_BACKGRD_UNLOCKED);
+ break;
+ default:
+ if(oomadj > OOMADJ_BACKGRD_UNLOCKED) {
+ ret = 0;
+ } else {
+ PRT_TRACE_EM("Unknown oomadj value (%d) !", oomadj);
+ ret = -1;
+ }
+ break;
+ }
+ return ret;
+}
+
+int ss_process_manager_init(void)
+{
+ ss_action_entry_add_internal(PREDEF_FOREGRD, set_foregrd_action, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_BACKGRD, set_backgrd_action, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_ACTIVE, set_active_action, NULL,
+ NULL);
+ ss_action_entry_add_internal(PREDEF_INACTIVE, set_inactive_action, NULL,
+ NULL);
+ ss_action_entry_add_internal(OOMADJ_SET, set_oomadj_action, NULL, NULL);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_PROCMGR_H__
+#define __SS_PROCMGR_H__
+
+int ss_process_manager_init(void);
+
+int get_app_oomadj(int pid, int *oomadj);
+int set_app_oomadj(int pid, int new_oomadj);
+
+#endif /* __SS_PROCMGR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sysman.h>
+#include <dlfcn.h>
+#include "include/ss_data.h"
+#include "ss_core.h"
+#include "ss_queue.h"
+#include "ss_log.h"
+
+#define SS_PREDEFINE_ACT_FUNC_STR "ss_predefine_action"
+#define SS_IS_ACCESSABLE_FUNC_STR "ss_is_accessable"
+#define SS_UI_VIEWABLE_FUNC_STR "ss_ui_viewable"
+
+static Eina_List *predef_act_list;
+static Eina_List *run_queue;
+
+static struct ss_action_entry *ss_action_entry_find(char *type)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_action_entry *data;
+
+ EINA_LIST_FOREACH_SAFE(predef_act_list, tmp, tmp_next, data) {
+ if ((data != NULL) && (!strcmp(data->type, type)))
+ return data;
+ }
+
+ return NULL;
+}
+
+int ss_action_entry_add_internal(char *type,
+ int (*predefine_action) (),
+ int (*ui_viewable) (),
+ int (*is_accessable) (int))
+{
+ struct ss_action_entry *data;
+
+ data = malloc(sizeof(struct ss_action_entry));
+
+ if (data == NULL) {
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ data->type = NULL;
+ if (ss_action_entry_find(type) != NULL)
+ goto err;
+
+ data->handle = NULL;
+ data->predefine_action = predefine_action;
+ if (data->predefine_action == NULL)
+ goto err;
+
+ data->is_accessable = is_accessable;
+ data->ui_viewable = ui_viewable;
+ data->owner_pid = getpid();
+ data->type = strdup(type);
+ data->path = strdup("");
+
+ predef_act_list = eina_list_prepend(predef_act_list, data);
+
+ PRT_TRACE_ERR("[SYSMAN] add predefine action entry suceessfully - %s",
+ data->type);
+ return 0;
+ err:
+ if (data->type != NULL)
+ PRT_TRACE_ERR("[SYSMAN] add predefine action entry -%s",
+ data->type);
+ free(data);
+ return -1;
+}
+
+int ss_action_entry_add(struct sysnoti *msg)
+{
+ struct ss_action_entry *data;
+
+ data = malloc(sizeof(struct ss_action_entry));
+
+ if (data == NULL) {
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ if (ss_action_entry_find(msg->type) != NULL)
+ goto err;
+
+ data->handle = dlopen(msg->path, RTLD_LAZY);
+ if (!data->handle) {
+ PRT_TRACE_ERR("cannot find such library");
+ goto err;
+ }
+
+ data->predefine_action = dlsym(data->handle, SS_PREDEFINE_ACT_FUNC_STR);
+ if (data->predefine_action == NULL) {
+ PRT_TRACE_ERR("cannot find predefine_action symbol : %s",
+ SS_PREDEFINE_ACT_FUNC_STR);
+ goto err;
+ }
+
+ data->is_accessable = dlsym(data->handle, SS_IS_ACCESSABLE_FUNC_STR);
+ data->ui_viewable = dlsym(data->handle, SS_UI_VIEWABLE_FUNC_STR);
+ data->owner_pid = msg->pid;
+ data->type = strdup(msg->type);
+ data->path = strdup(msg->path);
+
+ predef_act_list = eina_list_prepend(predef_act_list, data);
+
+ PRT_TRACE_ERR("[SYSMAN]add predefine action entry suceessfully - %s",
+ data->type);
+ return 0;
+ err:
+ PRT_TRACE_ERR("[SYSMAN] FAIL predefine action entry - %s", msg->type);
+ free(data);
+ return -1;
+}
+
+int ss_action_entry_call_internal(char *type, int argc, ...)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_action_entry *data;
+ va_list argptr;
+ int i;
+ char *args = NULL;
+ char *argv[SYSMAN_MAXARG];
+
+ if (argc > SYSMAN_MAXARG || type == NULL)
+ return -1;
+
+ EINA_LIST_FOREACH_SAFE(predef_act_list, tmp, tmp_next, data) {
+ if ((data != NULL) && (!strcmp(data->type, type))) {
+ va_start(argptr, argc);
+ for (i = 0; i < argc; i++) {
+ args = va_arg(argptr, char *);
+ if (args != NULL)
+ argv[i] = strdup(args);
+ else
+ argv[i] = NULL;
+ }
+ va_end(argptr);
+
+ int ret;
+ ret=ss_run_queue_add(data, argc, argv);
+ PRT_TRACE_ERR("ss_run_queue_add : %d",ret);
+ ret=ss_core_action_run();
+ PRT_TRACE_ERR("ss_core_action_run : %d",ret);
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+int ss_action_entry_call(struct sysnoti *msg, int argc, char **argv)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_action_entry *data;
+
+ EINA_LIST_FOREACH_SAFE(predef_act_list, tmp, tmp_next, data) {
+ if ((data != NULL) && (!strcmp(data->type, msg->type))) {
+ if (data->is_accessable != NULL
+ && data->is_accessable(msg->pid) == 0) {
+ PRT_TRACE_ERR
+ ("%d cannot call that predefine module",
+ msg->pid);
+ return -1;
+ }
+ int ret;
+ ret=ss_run_queue_add(data, argc, argv);
+ PRT_TRACE_ERR("ss_run_queue_add : %d",ret);
+ ret=ss_core_action_run();
+ PRT_TRACE_ERR("ss_core_action_run : %d",ret);
+ return 0;
+ }
+ }
+
+ PRT_TRACE_EM("[SYSMAN] cannot found action");
+ return -1;
+}
+
+int ss_run_queue_add(struct ss_action_entry *act_entry, int argc, char **argv)
+{
+ struct ss_run_queue_entry *rq_entry;
+ int i;
+
+ rq_entry = malloc(sizeof(struct ss_run_queue_entry));
+
+ if (rq_entry == NULL) {
+ PRT_TRACE_ERR("Malloc failed");
+ return -1;
+ }
+
+ rq_entry->state = SS_STATE_INIT;
+ rq_entry->action_entry = act_entry;
+ rq_entry->forked_pid = 0;
+ if ( argc < 0 ) {
+ rq_entry->argc = 0;
+ } else {
+ rq_entry->argc = argc;
+ for (i = 0; i < argc; i++)
+ rq_entry->argv[i] = argv[i];
+ }
+
+ run_queue = eina_list_prepend(run_queue, rq_entry);
+
+ PRT_TRACE_EM("[SYSMAN] new action called : %s", act_entry->type);
+ return 0;
+}
+
+int ss_run_queue_run(enum ss_run_state state,
+ int (*run_func) (void *, struct ss_run_queue_entry *),
+ void *user_data)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_run_queue_entry *rq_entry;
+
+ EINA_LIST_FOREACH_SAFE(run_queue, tmp, tmp_next, rq_entry) {
+ if ((rq_entry != NULL) && (rq_entry->state == state))
+ run_func(user_data, rq_entry);
+ }
+
+ return 0;
+}
+
+struct ss_run_queue_entry *ss_run_queue_find_bypid(int pid)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_run_queue_entry *rq_entry;
+
+ EINA_LIST_FOREACH_SAFE(run_queue, tmp, tmp_next, rq_entry) {
+ if ((rq_entry != NULL) && (rq_entry->forked_pid == pid))
+ return rq_entry;
+ }
+
+ return NULL;
+}
+
+int ss_run_queue_del(struct ss_run_queue_entry *entry)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_run_queue_entry *rq_entry;
+ int i;
+
+ EINA_LIST_FOREACH_SAFE(run_queue, tmp, tmp_next, rq_entry) {
+ if ((rq_entry != NULL) && (rq_entry == entry)) {
+ run_queue = eina_list_remove(run_queue, rq_entry);
+ PRT_TRACE_EM("[SYSMAN] action deleted : %s",
+ rq_entry->action_entry->type);
+ for (i = 0; i < rq_entry->argc; i++) {
+ if (rq_entry->argv[i])
+ free(rq_entry->argv[i]);
+ }
+ free(rq_entry);
+ }
+ }
+
+ return 0;
+}
+
+int ss_run_queue_del_bypid(int pid)
+{
+ Eina_List *tmp;
+ Eina_List *tmp_next;
+ struct ss_run_queue_entry *rq_entry;
+ int i;
+
+ EINA_LIST_FOREACH_SAFE(run_queue, tmp, tmp_next, rq_entry) {
+ if ((rq_entry != NULL) && (rq_entry->forked_pid == pid)) {
+ run_queue = eina_list_remove(run_queue, rq_entry);
+ PRT_TRACE_EM("[SYSMAN] action deleted : %s",
+ rq_entry->action_entry->type);
+ for (i = 0; i < rq_entry->argc; i++) {
+ if (rq_entry->argv[i])
+ free(rq_entry->argv[i]);
+ }
+ free(rq_entry);
+ }
+ }
+
+ return 0;
+}
+
+void ss_queue_init()
+{
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_QUEUE_H__
+#define __SS_QUEUE_H__
+
+#include "ss_sysnoti.h"
+
+struct ss_action_entry {
+ int owner_pid;
+ void *handle;
+ char *type;
+ char *path;
+ int (*predefine_action) ();
+ int (*ui_viewable) ();
+ int (*is_accessable) (int caller_pid);
+};
+
+enum ss_run_state {
+ SS_STATE_INIT,
+ SS_STATE_RUNNING,
+ SS_STATE_DONE
+};
+
+struct ss_run_queue_entry {
+ enum ss_run_state state;
+ struct ss_action_entry *action_entry;
+ int forked_pid;
+ int argc;
+ char *argv[SYSMAN_MAXARG];
+};
+
+int ss_action_entry_add_internal(char *type,
+ int (*predefine_action) (),
+ int (*ui_viewable) (),
+ int (*is_accessable) (int));
+int ss_action_entry_add(struct sysnoti *msg);
+int ss_action_entry_call_internal(char *type, int argc, ...);
+int ss_action_entry_call(struct sysnoti *msg, int argc, char **argv);
+
+int ss_run_queue_run(enum ss_run_state state,
+ int (*run_func) (void *, struct ss_run_queue_entry *),
+ void *user_data);
+
+struct ss_run_queue_entry *ss_run_queue_find_bypid(int pid);
+int ss_run_queue_add(struct ss_action_entry *act_entry, int argc, char **argv);
+int ss_run_queue_del(struct ss_run_queue_entry *entry);
+int ss_run_queue_del_bypid(int pid);
+
+void ss_queue_init();
+
+#endif /* __SS_QUEUE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sys/types.h>
+#include <sys/wait.h>
+#include "ss_core.h"
+
+#define PRT_TRACE_ERR(format, args...) do { \
+ char buf[255];\
+ snprintf(buf, 255, format, ##args);\
+ write(2, buf, strlen(buf));\
+} while (0);
+
+#define PRT_TRACE(format, args...) do { \
+ char buf[255];\
+ snprintf(buf, 255, format, ##args);\
+ write(1, buf, strlen(buf));\
+} while (0);
+
+static struct sigaction sig_child_old_act;
+static struct sigaction sig_pipe_old_act;
+
+static void sig_child_handler(int signo, siginfo_t *info, void *data)
+{
+ pid_t pid;
+ int status;
+
+ pid = waitpid(info->si_pid, &status, 0);
+ if (pid == -1) {
+ PRT_TRACE_ERR("SIGCHLD received\n");
+ return;
+ }
+
+ PRT_TRACE("sig child actend call - %d\n", info->si_pid);
+
+ ss_core_action_clear(info->si_pid);
+}
+
+static void sig_pipe_handler(int signo, siginfo_t *info, void *data)
+{
+
+}
+
+void ss_signal_init()
+{
+ struct sigaction sig_act;
+
+ sig_act.sa_handler = NULL;
+ sig_act.sa_sigaction = sig_child_handler;
+ sig_act.sa_flags = SA_SIGINFO;
+ sigemptyset(&sig_act.sa_mask);
+ sigaction(SIGCHLD, &sig_act, &sig_child_old_act);
+
+ sig_act.sa_handler = NULL;
+ sig_act.sa_sigaction = sig_pipe_handler;
+ sig_act.sa_flags = SA_SIGINFO;
+ sigemptyset(&sig_act.sa_mask);
+ sigaction(SIGPIPE, &sig_act, &sig_pipe_old_act);
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_SIG_HANDLER_H__
+#define __SS_SIG_HANDLER_H__
+
+void ss_signal_init(void);
+
+#endif /* __SS_SIG_HANDLER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sysman.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+#include "include/ss_data.h"
+#include "ss_log.h"
+#include "ss_queue.h"
+
+#define SYSNOTI_SOCKET_PATH "/tmp/sn"
+
+enum sysnoti_cmd {
+ ADD_SYSMAN_ACTION,
+ CALL_SYSMAN_ACTION
+};
+
+static void print_sysnoti_msg(const char *title, struct sysnoti *msg)
+{
+ int i;
+ char exe_name[PATH_MAX];
+
+ if (sysman_get_cmdline_name(msg->pid, exe_name, PATH_MAX) < 0)
+ snprintf(exe_name, sizeof(exe_name), "Unknown (maybe dead)");
+
+ PRT_TRACE_ERR("=====================");
+ PRT_TRACE_ERR("pid : %d", msg->pid);
+ PRT_TRACE_ERR("process name : %s", exe_name);
+ PRT_TRACE_ERR("cmd : %d", msg->cmd);
+ PRT_TRACE_ERR("type : %s", msg->type);
+ PRT_TRACE_ERR("path : %s", msg->path);
+ for (i = 0; i < msg->argc; i++)
+ PRT_TRACE_ERR("arg%d : %s", i, msg->argv[i]);
+ PRT_TRACE_ERR("=====================");
+}
+
+static inline int recv_int(int fd)
+{
+ int val, r = -1;
+ while(1) {
+ r = read(fd, &val, sizeof(int));
+ if (r < 0) {
+ if(errno == EINTR) {
+ PRT_TRACE_ERR("Re-read for error(EINTR)");
+ continue;
+ }
+ else {
+ PRT_TRACE_ERR("Read fail for int");
+ return -1;
+ }
+ } else {
+ return val;
+ }
+ }
+}
+
+static inline char *recv_str(int fd)
+{
+ int len, r = -1;
+ char *str;
+
+ while(1) {
+ r = read(fd, &len, sizeof(int));
+ if (r < 0) {
+ if(errno == EINTR) {
+ PRT_TRACE_ERR("Re-read for error(EINTR)");
+ continue;
+ }
+ else {
+ PRT_TRACE_ERR("Read fail for str length");
+ return NULL;
+ }
+ } else
+ break;
+ }
+
+ if (len <= 0) {
+ PRT_TRACE_ERR("str is null");
+ return NULL;
+ }
+
+ if (len >= INT_MAX) {
+ PRT_TRACE_ERR("size is over INT_MAX");
+ return NULL;
+ }
+
+ str = (char *)malloc(len + 1);
+ if (str == NULL) {
+ PRT_TRACE_ERR("Not enough memory");
+ return NULL;
+ }
+
+ while(1) {
+ r = read(fd, str, len);
+ if(r < 0) {
+ if(errno == EINTR) {
+ PRT_TRACE_ERR("Re-read for error(EINTR)");
+ continue;
+ }
+ else {
+ PRT_TRACE_ERR("Read fail for str");
+ free(str);
+ str = NULL;
+ return NULL;
+ }
+ } else
+ break;
+ }
+ str[len] = 0;
+
+ return str;
+}
+
+static int read_message(int fd, struct sysnoti *msg)
+{
+ int i;
+
+ msg->pid = recv_int(fd);
+ msg->cmd = recv_int(fd);
+ msg->type = recv_str(fd);
+ msg->path = recv_str(fd);
+ msg->argc = recv_int(fd);
+
+ if (msg->argc < 0)
+ return 0;
+ for (i = 0; i < msg->argc; i++)
+ msg->argv[i] = recv_str(fd);
+
+ return 0;
+}
+
+static inline void internal_free(char *str)
+{
+ if (!str)
+ free(str);
+}
+
+static inline void free_message(struct sysnoti *msg)
+{
+ internal_free(msg->type);
+ internal_free(msg->path);
+ free(msg);
+}
+
+static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
+{
+ int fd;
+ struct sysnoti *msg;
+ int ret = -1;
+ struct sockaddr_un client_address;
+ int client_sockfd;
+ int client_len;
+
+ if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
+ PRT_TRACE_ERR
+ ("ecore_main_fd_handler_active_get error , return\n");
+ return 1;
+ }
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+
+ msg = malloc(sizeof(struct sysnoti));
+ if (msg == NULL) {
+ PRT_TRACE_ERR("%s : Not enough memory", __FUNCTION__);
+ return 1;
+ }
+
+ client_len = sizeof(client_address);
+ client_sockfd =
+ accept(fd, (struct sockaddr *)&client_address,
+ (socklen_t *)&client_len);
+ if(client_sockfd == -1) {
+ PRT_TRACE_ERR("socket accept error");
+ free(msg);
+ return 1;
+ }
+
+ if (read_message(client_sockfd, msg) < 0) {
+ PRT_TRACE_ERR("%s : recv error msg", __FUNCTION__);
+ free_message(msg);
+ write(client_sockfd, &ret, sizeof(int));
+ close(client_sockfd);
+ return 1;
+ }
+
+ print_sysnoti_msg(__FUNCTION__, msg);
+ if (msg->argc > SYSMAN_MAXARG) {
+ PRT_TRACE_ERR("%s : error argument", __FUNCTION__);
+ free_message(msg);
+ write(client_sockfd, &ret, sizeof(int));
+ close(client_sockfd);
+ return 1;
+ }
+
+ switch (msg->cmd) {
+ case CALL_SYSMAN_ACTION:
+ ret = ss_action_entry_call(msg, msg->argc, msg->argv);
+ break;
+ default:
+ ret = -1;
+ }
+
+ write(client_sockfd, &ret, sizeof(int));
+ close(client_sockfd);
+
+ free_message(msg);
+
+ return 1;
+}
+
+static int ss_sysnoti_server_init(void)
+{
+ int fd;
+ struct sockaddr_un serveraddr;
+
+ if (access(SYSNOTI_SOCKET_PATH, F_OK) == 0)
+ unlink(SYSNOTI_SOCKET_PATH);
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ PRT_ERR("%s: socket create failed\n", __FUNCTION__);
+ return -1;
+ }
+
+ if((fsetxattr(fd, "security.SMACK64IPOUT", "@", 2, 0)) < 0 ) {
+ PRT_ERR("%s: Socket SMACK labeling failed\n", __FUNCTION__);
+ if(errno != EOPNOTSUPP) {
+ close(fd);
+ return -1;
+ }
+ }
+
+ if((fsetxattr(fd, "security.SMACK64IPIN", "*", 2, 0)) < 0 ) {
+ PRT_ERR("%s: Socket SMACK labeling failed\n", __FUNCTION__);
+ if(errno != EOPNOTSUPP) {
+ close(fd);
+ return -1;
+ }
+ }
+
+ bzero(&serveraddr, sizeof(struct sockaddr_un));
+ serveraddr.sun_family = AF_UNIX;
+ strncpy(serveraddr.sun_path, SYSNOTI_SOCKET_PATH,
+ sizeof(serveraddr.sun_path));
+
+ if (bind(fd, (struct sockaddr *)&serveraddr, sizeof(struct sockaddr)) <
+ 0) {
+ PRT_ERR("%s: socket bind failed\n", __FUNCTION__);
+ close(fd);
+ return -1;
+ }
+
+ if (chmod(SYSNOTI_SOCKET_PATH, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) /* 0777 */
+ PRT_ERR("failed to change the socket permission");
+
+ if (listen(fd, 5) < 0) {
+ PRT_ERR("failed to listen");
+ close(fd);
+ return -1;
+ }
+ PRT_INFO("socket create & listen ok\n");
+
+ return fd;
+}
+
+int ss_sysnoti_init(void)
+{
+ int fd;
+ fd = ss_sysnoti_server_init();
+ if ( fd < 0 )
+ return -1;
+ ecore_main_fd_handler_add(fd, ECORE_FD_READ, sysnoti_cb, NULL, NULL,
+ NULL);
+ return fd;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_SYSNOTI_H__
+#define __SS_SYSNOTI_H__
+
+#define SYSMAN_MAXARG 16
+
+struct sysnoti {
+ int pid;
+ int cmd;
+ char *type;
+ char *path;
+ int argc;
+ char *argv[SYSMAN_MAXARG];
+};
+
+int ss_sysnoti_init(void);
+
+#endif /* __SS_SYSNOTI_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <pmapi.h>
+#include <vconf.h>
+#include <sysman.h>
+
+#include "ss_device_plugin.h"
+#include "ss_log.h"
+#include "include/ss_data.h"
+
+#define RETRY 3
+
+int ss_ta_init()
+{
+ int val = -1, i = 0, pid;
+
+ PRT_TRACE("check ta connection");
+ if (plugin_intf->OEM_sys_get_jack_charger_online(&val) == 0) {
+ if ( val==1 ) {
+ vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ VCONFKEY_SYSMAN_CHARGER_CONNECTED);
+ while (i < RETRY
+ && pm_lock_state(LCD_OFF, STAY_CUR_STATE,
+ 0) == -1) {
+ i++;
+ sleep(1);
+ }
+ PRT_TRACE("ta is connected");
+ }
+ else if ( val==0 )
+ vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ VCONFKEY_SYSMAN_CHARGER_DISCONNECTED);
+ }
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdbool.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <pmapi.h>
+#include <vconf.h>
+
+#include <sysman.h>
+#include "include/ss_data.h"
+#include "ss_queue.h"
+#include "ss_log.h"
+
+#include <time.h>
+#include <sys/ioctl.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+
+
+static const char default_rtc0[] = "/dev/rtc0";
+static const char default_rtc1[] = "/dev/rtc1";
+static const char default_localtime[] = "/opt/etc/localtime";
+
+char *substring(const char *str, size_t begin, size_t len)
+{
+ if (str == 0 || strlen(str) == 0 || strlen(str) < begin
+ || strlen(str) < (begin + len))
+ return 0;
+
+ return strndup(str + begin, len);
+}
+
+int handle_timezone(char *str)
+{
+ int ret;
+ struct stat sts;
+ const char *sympath = default_localtime;
+
+ if (str == NULL)
+ return -1;
+ const char *tzpath = str;
+
+ PRT_TRACE("TZPATH = %s\n", tzpath);
+
+ /* unlink current link
+ * eg. rm /opt/etc/localtime */
+ if (stat(sympath, &sts) == -1 && errno == ENOENT) {
+ /* DO NOTHING */
+ } else {
+ ret = unlink(sympath);
+ if (ret < 0) {
+ PRT_TRACE("unlink error : [%d]%s\n", ret,
+ strerror(errno));
+ return -1;
+ } else
+ PRT_TRACE("unlink success\n");
+
+ }
+
+ /* symlink new link
+ * eg. ln -s /usr/share/zoneinfo/Asia/Seoul /opt/etc/localtime */
+ ret = symlink(tzpath, sympath);
+ if (ret < 0) {
+ PRT_TRACE("symlink error : [%d]%s\n", ret, strerror(errno));
+ return -1;
+ } else
+ PRT_TRACE("symlink success\n");
+
+ tzset();
+ return 0;
+}
+
+/*
+ * TODO : error handling code should be added here.
+ */
+int handle_date(char *str)
+{
+ long int tmp = 0;
+ time_t timet = 0;
+ time_t before = 0;
+
+ if (str == NULL)
+ return -1;
+
+ tmp = (long int)atoi(str);
+ timet = (time_t) tmp;
+
+ PRT_TRACE("ctime = %s", ctime(&timet));
+ vconf_set_int(VCONFKEY_SYSTEM_TIMECHANGE, timet);
+
+ return 0;
+}
+
+int set_datetime_action(int argc, char **argv)
+{
+ int ret = 0;
+ unsigned int pm_state;
+ if (argc < 1)
+ return -1;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &ret) != 0)
+ PRT_TRACE("Fail to get vconf value for pm state\n");
+ if (ret == 1)
+ pm_state = 0x1;
+ else if (ret == 2)
+ pm_state = 0x2;
+ else
+ pm_state = 0x4;
+
+ pm_lock_state(pm_state, STAY_CUR_STATE, 0);
+ ret = handle_date(argv[0]);
+ pm_unlock_state(pm_state, STAY_CUR_STATE);
+ return ret;
+}
+
+int set_timezone_action(int argc, char **argv)
+{
+ int ret;
+ unsigned int pm_state;
+ if (argc < 1)
+ return -1;
+ if (vconf_get_int(VCONFKEY_PM_STATE, &ret) != 0)
+ PRT_TRACE("Fail to get vconf value for pm state\n");
+ if (ret == 1)
+ pm_state = 0x1;
+ else if (ret == 2)
+ pm_state = 0x2;
+ else
+ pm_state = 0x4;
+
+ pm_lock_state(pm_state, STAY_CUR_STATE, 0);
+ ret = handle_timezone(argv[0]);
+ pm_unlock_state(pm_state, STAY_CUR_STATE);
+ return ret;
+}
+
+int ss_time_manager_init(void)
+{
+ ss_action_entry_add_internal(PREDEF_SET_DATETIME, set_datetime_action,
+ NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_SET_TIMEZONE, set_timezone_action,
+ NULL, NULL);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 __SS_TIMEMGR_H__
+#define __SS_TIMEMGR_H__
+
+int ss_time_manager_init(void);
+
+#endif /* __SS_TIMEMGR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <pmapi.h>
+#include <vconf.h>
+#include <sysman.h>
+
+#include "ss_log.h"
+#include "ss_device_plugin.h"
+#include "ss_launch.h"
+#include "include/ss_data.h"
+
+#define USBCON_EXEC_PATH PREFIX"/bin/usb-server"
+#define RETRY 3
+
+int ss_usb_init()
+{
+ int val = -1, i = 0, pid;
+
+ PRT_TRACE("check usb connection");
+ if (plugin_intf->OEM_sys_get_jack_usb_online(&val) == 0) {
+ if (val==1) {
+ vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
+ VCONFKEY_SYSMAN_USB_AVAILABLE);
+ while (i < RETRY
+ && pm_lock_state(LCD_OFF, STAY_CUR_STATE,
+ 0) == -1) {
+ i++;
+ sleep(1);
+ }
+ pid = ss_launch_if_noexist(USBCON_EXEC_PATH, NULL);
+ if (pid < 0) {
+ PRT_TRACE_ERR("usb appl launching failed\n");
+ return -1;
+ }
+ }
+ else if (val==0)
+ vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,VCONFKEY_SYSMAN_USB_DISCONNECTED);
+ }
+
+ return 0;
+}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sys_device_noti C)
+
+SET(SRCS sys_device_noti.c)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} /usr/include/svi /usr/include/notification)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lsvi -lnotification")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/batt_full_icon.png DESTINATION share/system-server/sys_device_noti)
+
+#i18n
+ADD_SUBDIRECTORY(po_sys_device_noti)
--- /dev/null
+# for i18n
+
+SET(POFILES ar.po el_GR.po es_ES.po fi.po gl.po hy.po ka.po lv.po pl.po ru_RU.po sv.po zh_CN.po az.po cs.po en_PH.po es_US.po fr_CA.po hi.po is.po kk.po mk.po pt_BR.po sk.po tr_TR.po zh_HK.po bg.po da.po en.po et.po fr_FR.po hr.po it_IT.po ko_KR.po nb.po pt_PT.po sl.po uk.po zh_SG.po ca.po de_DE.po en_US.po eu.po ga.po hu.po ja_JP.po lt.po nl_NL.po ro.po sr.po uz.po zh_TW.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 share/system-server/sys_device_noti/res/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po_sys_device_noti ALL DEPENDS ${moFiles})
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "تم شحن البطارية كاملا"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "فصل الشاحن"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batareya tam doludur"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Adapteri rozetkadan çıxarın"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Батерията напълно заредена"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Изключете зарядното устройство"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Bateria completament carregada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desendollar carregador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterie je plně nabitá"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Odpojte nabíječku"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batteri fuldt opladet"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Fjern oplader"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Akku vollständig geladen"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Ladegerät entfernen"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Μπαταρία πλήρως φορτισμένη"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Αποσύνδεση φορτιστή"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Battery fully charged"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Unplug charger"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Battery fully charged"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Unplug charger"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Battery fully charged"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Unplug charger"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batería totalmente cargada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desconectar cargador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batería completamente cargada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desconectar el cargador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Aku on laetud"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Eraldage laadija"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Bateria guztiz kargatuta"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desentxufatu kargadorea"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Akku on täysin ladattu"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Irrota laturi"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "La pile est chargée"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Débrancher le chargeur"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batterie chargée"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Débrancher le chargeur"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Ceallra lánluchtaithe"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Díphlugáil an luchtaire"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batería totalmente cargada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desenchufar cargador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "बैटरी पूरी चार्ज है।"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "चार्जर निकालें"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterija puna"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Iskopčajte punjač"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Az akkumulátor feltöltve"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Húzza ki a töltőt"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Մարտկոցը ամբողջովին լիցքավորված է"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Վարդակից անջատել լիցքավորիչը"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Rafhlaða fullhlaðin"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Aftengja hleðslutæki"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batteria ricaricata"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Scollega caricabatterie"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "バッテリ充電完了"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "充電器を取り外してください。"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "კვების ელემენტი დაიტენა"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "გამორთეთ დამტენი"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Батарея толық зарядталған"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Зарядтағышты ажырату"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "배터리가 충전되었습니다"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "충전기 분리"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterija visiškai įkrauta"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Atjunkite kroviklį"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Akumulators uzlādēts"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Atvienojiet lādētāju"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Батеријата е наполнета"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Откачете го полначот"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batteri fulladet"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Ta ut laderen"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "De batterij is opgeladen"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Oplader loskoppelen"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Bateria w pełni naładowana"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Odłącz ładowarkę"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Bateria completamente carregada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desconectar carregador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Bateria completamente carregada"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Desligue o carregador"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterie încărcată complet"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Deconectaţi încărcătorul"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Аккумулятор заряжен"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Отключите зарядное устройство"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batéria je plne nabitá"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Odpojte nabíjačku"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterija je polna"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Izklopite napajalnik"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Baterija skroz napunjena"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Otkači punjač"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batteriet fulladdat"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Ta ut laddaren"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Pil tümüyle şarj oldu"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Şarjı fişten çekin"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Батарею заряджено повністю"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Відключіть зарядний пристрій"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "Batareya to‘la zaryadlandi"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "Zaryadlash qurilmasini chiqaring"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "电池已满"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "拔下充电器"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "電池已完全充電"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "拔除充電器"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "充电完毕"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "拔下充电器"
+
--- /dev/null
+msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
+msgstr "電池已完全充電"
+
+msgid "IDS_QP_BODY_UNPLUG_CHARGER"
+msgstr "斷開充電器"
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <svi.h>
+#include <pmapi.h>
+#include <notification.h>
+#include <libintl.h>
+#include <locale.h>
+#include <vconf.h>
+#include "ss_log.h"
+#include "sys_device_noti.h"
+
+#define BATTERY_FULL_ICON_PATH "/usr/share/system-server/sys_device_noti/batt_full_icon.png"
+static int battery_full_noti(int bNoti)
+{
+ int charge_full = bNoti;
+ char *lang;
+ char *r;
+
+
+
+ notification_h noti = NULL;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ if (charge_full == 1) {
+ lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (lang) {
+ setenv("LANG", lang, 1);
+ setenv("LC_MESSAGES", lang, 1);
+ r = setlocale(LC_ALL, "");
+ if (r == NULL) {
+ setlocale(LC_ALL, lang);
+ }
+ free(lang);
+ }
+ bindtextdomain("sys_device_noti","/usr/share/system-server/sys_device_noti/res/locale/");
+ textdomain("sys_device_noti");
+ noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
+ PRT_TRACE("[BAT_FULL_NOTI] add notification for battery full\n");
+ noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ if (noti == NULL) {
+ PRT_TRACE("[BAT_FULL_NOTI] Errot noti == NULL\n");
+ return -1;
+ }
+
+ noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, _("IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_title : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, _("IDS_QP_BODY_UNPLUG_CHARGER"), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_content : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, _("IDS_QP_BODY_UNPLUG_CHARGER"), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_content : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_time(noti, time(NULL));
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_time : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, BATTERY_FULL_ICON_PATH);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_image : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH | NOTIFICATION_PROP_DISABLE_TICKERNOTI | NOTIFICATION_PROP_VOLATILE_DISPLAY);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_property : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_set_display_applist : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_insert(noti, NULL);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_insert : %d\n", noti_err);
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ return -1;
+ }
+
+ noti_err = notification_free(noti);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ PRT_TRACE("[BAT_FULL_NOTI] Error notification_free : %d\n", noti_err);
+ return -1;
+ }
+ pm_change_state(LCD_NORMAL);
+ } else {
+ noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
+ PRT_TRACE("[BAT_FULL_NOTI] Leave battery full status\n");
+ }
+
+ return 0;
+}
+int main(int argc, char *argv[])
+{
+ int r = 0;
+ int handle = 0;
+ int bNoti = -1;
+ sound_type snd = -1;
+ vibration_type vib = -1;
+ cb_noti_type cb_type = -1;
+
+ if (argc == 3)
+ bNoti = atoi(argv[2]);
+ cb_type = (cb_noti_type)atoi(argv[1]);
+ switch (cb_type) {
+ case CB_NOTI_BATT_CHARGE:
+ vib = SVI_VIB_OPERATION_CHARGERCONN;
+ snd = SVI_SND_OPERATION_CHARGERCONN;
+ break;
+ case CB_NOTI_BATT_FULL:
+ battery_full_noti(bNoti);
+ if (1==bNoti) {
+ vib = SVI_VIB_OPERATION_FULLCHARGED;
+ snd = SVI_SND_OPERATION_FULLCHARGED;
+ break;
+ } else
+ return 0;
+ default:
+ PRT_TRACE("sys_device_noti cb_type error(%d)",cb_type);
+ break;
+ }
+
+ r = svi_init(&handle); /* Initialize SVI */
+
+ if (r != SVI_SUCCESS) {
+ PRT_TRACE("Cannot initialize SVI.\n");
+ } else {
+ r = svi_play(handle, vib, snd);
+ if (r != SVI_SUCCESS)
+ PRT_TRACE("Cannot play sound or vibration.\n");
+ r = svi_fini(handle); /* Finalize SVI */
+ if (r != SVI_SUCCESS)
+ PRT_TRACE("Cannot close SVI.\n");
+ }
+ return 0;
+}
--- /dev/null
+/*\r
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+\r
+#ifndef __SYS_DEVICE_NOTI_H__\r
+#define __SYS_DEVICE_NOTI_H__\r
+\r
+#ifndef _\r
+#define _(str) gettext(str)\r
+#endif\r
+\r
+#ifndef gettext_noop\r
+#define gettext_noop(str) (str)\r
+#endif\r
+\r
+#ifndef N_\r
+#define N_(str) gettext_noop(str)\r
+#endif\r
+\r
+typedef enum {\r
+ CB_NOTI_BATT_CHARGE,\r
+ CB_NOTI_BATT_LOW,\r
+ CB_NOTI_BATT_FULL,\r
+ CB_NOTI_MAX\r
+}cb_noti_type;\r
+typedef enum {\r
+ CB_NOTI_OFF = 0,\r
+ CB_NOTI_ON = 1\r
+}cb_noti_onoff_type;\r
+\r
+#endif /* __SYS_DEVICE__NOTI_H__ */\r
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sys_event C)
+
+SET(SRCS sys_event.c)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED heynoti)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <heynoti.h>
+
+int main(int argc, char **argv)
+{
+ if (argc != 2) {
+ printf("[usage] sys_event <noti file>\n");
+ return -1;
+ }
+
+ heynoti_publish(argv[1]);
+ return 0;
+}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sys_pci_noti C)
+
+SET(SRCS sys_pci_noti.c)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+IF( $ENV{ARCH} MATCHES "arm" )
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF()
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
+#i18n
+ADD_SUBDIRECTORY(po_sys_pci_noti)
--- /dev/null
+# for i18n
+
+SET(POFILES ar.po el_GR.po es_ES.po fi.po gl.po hy.po ka.po lv.po pl.po ru_RU.po sv.po zh_CN.po az.po cs.po en_PH.po es_US.po fr_CA.po hi.po is.po kk.po mk.po pt_BR.po sk.po tr_TR.po zh_HK.po bg.po da.po en.po et.po fr_FR.po hr.po it_IT.po ko_KR.po nb.po pt_PT.po sl.po uk.po zh_SG.po ca.po de_DE.po en_US.po eu.po ga.po hu.po ja_JP.po lt.po nl_NL.po ro.po sr.po uz.po zh_TW.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 share/system-server/sys_pci_noti/res/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po_sys_pci_noti ALL DEPENDS ${moFiles})
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "تم توصيل لوحة المفاتيح"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "تم فصل لوحة المفاتيح"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klaviatura qoşuldu"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klaviatura ilə əlaqə kəsildi"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Клавиатурата е свързана"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Връзката с клав. е прекъсната"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclat connectat"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclat desconnectat"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klávesnice byla připojena"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klávesnice byla odpojena"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatur tilsluttet"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatur frakoblet"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatur verbunden"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatur getrennt"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Συνδέθηκε πληκτρολόγιο"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Το πληκτρολόγιο αποσυνδέθηκε"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Keyboard connected"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Keyboard disconnected"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Keyboard connected"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Keyboard disconnected"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Keyboard connected"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Keyboard disconnected"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado conectado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desconectado"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado conectado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desconectado"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klaviatuur on ühendatud"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klaviatuuri ühendus on katk."
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teklatua konektatuta"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teklatua deskonektatuta"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Näppäimistö kytketty"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Näppäimistö irrotettu"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Clavier connecté"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Clavier déconnecté"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Clavier connecté"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Clavier déconnecté"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Eochairchlár ceangailte"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Eochairchlár dícheangailte"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado conectado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desconectado"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "कीबोर्ड कनेक्ट किया गया"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "कीबोर्ड डिसकनेक्ट किया गया"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tipkovnica spojena"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tipkovnica odspojena"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Billentyűzet csatlakoztatva"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Billentyűzet leválasztva"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Ստեղնաշարը միացված է"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Ստեղնաշարն անջատված է"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Lyklaborð tengt"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Lyklaborð aftengt"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastiera connessa"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastiera disconnessa"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "キーボードが接続されました。"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "キーボードが取り外されました。"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "კლავიატურა დაკავშირებულია"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "კლავიატურა გათიშულია"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Пернетақта қосылды"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Пернетақта ажыратылды"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "키보드가 연결되었습니다"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "키보드와 연결이 끊어졌습니다"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Prijungta klaviatūra"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klaviatūra atjungta"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatūra pievienota"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatūra atvienota"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Поврзана е тастатура"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Тастатурата не е поврзана"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatur tilkoblet"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatur frakoblet"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Toetsenbord aangesloten"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Toetsenbord losgekoppeld"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klawiatura podłączona"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klawiatura odłączona"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado conectado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desconectado"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado ligado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desligado"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatură conectată"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatură deconectată"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Клавиатура подключена"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Клавиатура отключена"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klávesnica je pripojená"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klávesnica je odpojená"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tipkovnica je povezana"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tipkovnica je odstranjena"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tastatura je priključena"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tastatura je otkačena"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Tangentbord anslutet"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Tangentbord frånkopplat"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klavye bağlandı"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klavye bağlı değil"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Клавіатуру підключено"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Клавіатуру відключено"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Klaviatura ulandi"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Klaviatura chiqarib olindi"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "键盘已连接"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "键盘已断开"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "鍵盤已連接"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "鍵盤已中斷連接"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "键盘已连接"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "键盘已断开"
+
--- /dev/null
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "鍵盤已連接"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "鍵盤已中斷連接"
+
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <libintl.h>
+#include <locale.h>
+#include <vconf.h>
+#include <syspopup_caller.h>
+#include "ss_log.h"
+#include "sys_pci_noti.h"
+
+#define TICKERNOTI_LOCATION_TOP 0
+
+static void pci_noti(pci_noti_type iPCI)
+{
+ char *lang;
+ char *r;
+ int ret = -1;
+ bundle *b = NULL;
+ const int arrSize = 2;
+ char str_tickernoti[arrSize];
+
+ lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (lang) {
+ setenv("LANG", lang, 1);
+ setenv("LC_MESSAGES", lang, 1);
+ r = setlocale(LC_ALL, "");
+ if (r == NULL) {
+ setlocale(LC_ALL, lang);
+ }
+ free(lang);
+ }
+ bindtextdomain("sys_pci_noti","/usr/share/system-server/sys_pci_noti/res/locale/");
+ textdomain("sys_pci_noti");
+
+ b = bundle_create();
+ if(b == NULL) {
+ PRT_TRACE_ERR("FAIL: bundle_create()");
+ return;
+ }
+ /* set tickernoti style */
+ ret = bundle_add(b, "0", "info");
+ if (ret != 0)
+ goto BUNDLE_ADD_ERR;
+
+ /* set tickernoti text */
+ if (iPCI == CB_NOTI_PCI_REMOVED)
+ ret = bundle_add(b, "1", _("IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"));
+ else if (iPCI == CB_NOTI_PCI_INSERTED)
+ ret = bundle_add(b, "1", _("IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"));
+ if (ret != 0)
+ goto BUNDLE_ADD_ERR;
+ /* set tickernoti orientation */
+ snprintf(str_tickernoti,arrSize,"%d",TICKERNOTI_LOCATION_TOP);
+ ret = bundle_add(b, "2", str_tickernoti);
+ if (ret != 0)
+ goto BUNDLE_ADD_ERR;
+
+ /* set tickernoti timeout */
+ ret = bundle_add(b, "3", "3");
+ if (ret != 0)
+ goto BUNDLE_ADD_ERR;
+
+ /* launch tickernoti */
+ ret = syspopup_launch("tickernoti-syspopup", b);
+ if (ret < 0)
+ PRT_TRACE_ERR("FAIL: syspopup_launch()");
+
+ if(bundle_free(b) != 0)
+ PRT_TRACE_ERR("FAIL: bundle_free()");
+ return;
+
+BUNDLE_ADD_ERR:
+ PRT_TRACE_ERR("FAIL: bundle_add()");
+ if (bundle_free(b) != 0)
+ PRT_TRACE_ERR("FAIL: bundle_free()");
+ return;
+
+}
+int main(int argc, char *argv[])
+{
+ int r = 0;
+ int handle = 0;
+ int bNoti = -1;
+ pci_noti_type cb_type = -1;
+
+ if (argc == 2) {
+ cb_type = (pci_noti_type)atoi(argv[1]);
+ pci_noti(cb_type);
+ }
+ else {
+ PRT_TRACE_ERR("FAIL param error");
+ }
+
+ return 0;
+}
--- /dev/null
+/*\r
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+\r
+\r
+#ifndef __SYS_PCI_NOTI_H__\r
+#define __SYS_PCI_NOTI_H__\r
+\r
+#ifndef _\r
+#define _(str) gettext(str)\r
+#endif\r
+\r
+#ifndef gettext_noop\r
+#define gettext_noop(str) (str)\r
+#endif\r
+\r
+#ifndef N_\r
+#define N_(str) gettext_noop(str)\r
+#endif\r
+\r
+typedef enum {\r
+ CB_NOTI_PCI_REMOVED = 0,\r
+ CB_NOTI_PCI_INSERTED\r
+}pci_noti_type;\r
+\r
+#endif /* __SYS_PCI_NOTI_H__ */\r
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="slp.system.server"/>
+ </policy>
+ <policy context="default">
+ <deny own="slp.system.server"/>
+ </policy>
+</busconfig>
--- /dev/null
+#!/bin/sh
+
+/usr/bin/system_server &
--- /dev/null
+#MMC
+ACTION=="add", KERNEL=="mmcblk[0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/sys_event mmcblk_add"
+ACTION=="remove", KERNEL=="mmcblk[0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/sys_event mmcblk_remove"
+
+#Process Monitor
+#ACTION=="change" SUBSYSTEM=="pmon", RUN+="@PREFIX@/bin/restart"
+
+#Jack
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="usb" RUN+="@PREFIX@/bin/sys_event device_usb_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="charger" RUN+="@PREFIX@/bin/sys_event device_ta_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="earjack" RUN+="@PREFIX@/bin/sys_event device_earjack_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="earkey" RUN+="@PREFIX@/bin/sys_event device_earkey_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="tvout" RUN+="@PREFIX@/bin/sys_event device_tvout_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="hdmi" RUN+="@PREFIX@/bin/sys_event device_hdmi_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="cdrom" RUN+="@PREFIX@/bin/start_composite.sh"
+ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="keyboard" RUN+="@PREFIX@/bin/sys_event device_keyboard_chgdet"
+
+#USB Host Device
+ACTION=="add", SUBSYSTEM=="usb_device", RUN+="/usr/bin/sys_event device_usb_host_add"
+ACTION=="remove", SUBSYSTEM=="usb_device", RUN+="/usr/bin/sys_event device_usb_host_remove"
+ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="ADD", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 1 -f"
+ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="REMOVE", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 0 -f"
+ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="OVERCURRENT", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 2 -f"
+
+#USB Storage
+ACTION=="add", KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/vconftool set -t string memory/private/sysman/added_storage_uevent %N -f"
+ACTION=="remove", KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/vconftool set -t string memory/private/sysman/removed_storage_uevent $name -f"
+
+#charge
+ACTION=="change" DEVPATH=="/devices/platform/samsung-battery/power_supply/battery" RUN+="/usr/bin/sys_event device_charge_chgdet"
+ACTION=="change" DEVPATH=="/devices/platform/charger-manager.0" RUN+="@PREFIX@/bin/sys_event device_charge_chgdet"
+
+#USB Keyboard
+ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_keyboard_add"
+ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_keyboard_remove"
+ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_MOUSE}=="?*" RUN+="/usr/bin/sys_event device_mouse_add"
+ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_MOUSE}=="?*" RUN+="/usr/bin/sys_event device_mouse_remove"
+
+#PCI keyboard
+ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/virtio[1-9]*/input/input[1-9]*/event[1-9]*" ENV{ID_PATH}=="*virtio-pci*" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_pci_keyboard_add"
+ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/virtio[1-9]*/input/input[1-9]*/event[1-9]*" ENV{ID_PATH}=="*virtio-pci*" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_pci_keyboard_remove"