Merge branch 'tizen_2.2' into tizen tizen_3.0 submit/tizen/20130904.062602
authorjy910.yun <jy910.yun@samsung.com>
Tue, 3 Sep 2013 12:11:11 +0000 (21:11 +0900)
committerjy910.yun <jy910.yun@samsung.com>
Tue, 3 Sep 2013 12:11:11 +0000 (21:11 +0900)
Conflicts:
packaging/system-server.manifest
packaging/system-server.spec
ss_predefine.c

Signed-off-by: jy910.yun <jy910.yun@samsung.com>
91 files changed:
CMakeLists.txt
deviced.pc.in [new file with mode: 0644]
include/ss_data.h
mmc-smack-label [new file with mode: 0755]
packaging/deviced.manifest [new file with mode: 0644]
packaging/system-server.manifest
packaging/system-server.rule
packaging/system-server.spec
src/deviced/dd-battery.h [new file with mode: 0644]
src/shared/battery.c [new file with mode: 0644]
src/shared/log.h [new file with mode: 0644]
ss_common.c [new file with mode: 0644]
ss_common.h [new file with mode: 0644]
ss_core.c
ss_cpu_handler.c
ss_device_change_handler.c
ss_launch.c
ss_lowbat_handler.c
ss_main.c
ss_mmc_handler.c
ss_pmon_handler.c
ss_predefine.c
ss_predefine.h
ss_procmgr.c
ss_queue.c
ss_queue.h
ss_sysnoti.c
ss_timemgr.c
ss_usb_handler.c
ss_vibrator.c
sys_device_noti/CMakeLists.txt [deleted file]
sys_device_noti/data/batt_full_icon.png [deleted file]
sys_device_noti/po_sys_device_noti/CMakeLists.txt [deleted file]
sys_device_noti/po_sys_device_noti/ar.po [deleted file]
sys_device_noti/po_sys_device_noti/az.po [deleted file]
sys_device_noti/po_sys_device_noti/bg.po [deleted file]
sys_device_noti/po_sys_device_noti/ca.po [deleted file]
sys_device_noti/po_sys_device_noti/cs.po [deleted file]
sys_device_noti/po_sys_device_noti/da.po [deleted file]
sys_device_noti/po_sys_device_noti/de_DE.po [deleted file]
sys_device_noti/po_sys_device_noti/el_GR.po [deleted file]
sys_device_noti/po_sys_device_noti/en.po [deleted file]
sys_device_noti/po_sys_device_noti/en_PH.po [deleted file]
sys_device_noti/po_sys_device_noti/en_US.po [deleted file]
sys_device_noti/po_sys_device_noti/es_ES.po [deleted file]
sys_device_noti/po_sys_device_noti/es_US.po [deleted file]
sys_device_noti/po_sys_device_noti/et.po [deleted file]
sys_device_noti/po_sys_device_noti/eu.po [deleted file]
sys_device_noti/po_sys_device_noti/fi.po [deleted file]
sys_device_noti/po_sys_device_noti/fr_CA.po [deleted file]
sys_device_noti/po_sys_device_noti/fr_FR.po [deleted file]
sys_device_noti/po_sys_device_noti/ga.po [deleted file]
sys_device_noti/po_sys_device_noti/gl.po [deleted file]
sys_device_noti/po_sys_device_noti/hi.po [deleted file]
sys_device_noti/po_sys_device_noti/hr.po [deleted file]
sys_device_noti/po_sys_device_noti/hu.po [deleted file]
sys_device_noti/po_sys_device_noti/hy.po [deleted file]
sys_device_noti/po_sys_device_noti/is.po [deleted file]
sys_device_noti/po_sys_device_noti/it_IT.po [deleted file]
sys_device_noti/po_sys_device_noti/ja_JP.po [deleted file]
sys_device_noti/po_sys_device_noti/ka.po [deleted file]
sys_device_noti/po_sys_device_noti/kk.po [deleted file]
sys_device_noti/po_sys_device_noti/ko_KR.po [deleted file]
sys_device_noti/po_sys_device_noti/lt.po [deleted file]
sys_device_noti/po_sys_device_noti/lv.po [deleted file]
sys_device_noti/po_sys_device_noti/mk.po [deleted file]
sys_device_noti/po_sys_device_noti/nb.po [deleted file]
sys_device_noti/po_sys_device_noti/nl_NL.po [deleted file]
sys_device_noti/po_sys_device_noti/pl.po [deleted file]
sys_device_noti/po_sys_device_noti/pt_BR.po [deleted file]
sys_device_noti/po_sys_device_noti/pt_PT.po [deleted file]
sys_device_noti/po_sys_device_noti/ro.po [deleted file]
sys_device_noti/po_sys_device_noti/ru_RU.po [deleted file]
sys_device_noti/po_sys_device_noti/sk.po [deleted file]
sys_device_noti/po_sys_device_noti/sl.po [deleted file]
sys_device_noti/po_sys_device_noti/sr.po [deleted file]
sys_device_noti/po_sys_device_noti/sv.po [deleted file]
sys_device_noti/po_sys_device_noti/tr_TR.po [deleted file]
sys_device_noti/po_sys_device_noti/uk.po [deleted file]
sys_device_noti/po_sys_device_noti/uz.po [deleted file]
sys_device_noti/po_sys_device_noti/zh_CN.po [deleted file]
sys_device_noti/po_sys_device_noti/zh_HK.po [deleted file]
sys_device_noti/po_sys_device_noti/zh_SG.po [deleted file]
sys_device_noti/po_sys_device_noti/zh_TW.po [deleted file]
sys_device_noti/sys_device_noti.c [deleted file]
sys_device_noti/sys_device_noti.h [deleted file]
sys_pci_noti/po_sys_pci_noti/es_US.po [new file with mode: 0755]
sys_pci_noti/sys_pci_noti.c
systemd/system-server.service [moved from packaging/system-server.service with 82% similarity]
systemd/system-server.socket [new file with mode: 0644]
udev-rules/91-system-server.rules.in

index eda0ddb..f2975ee 100755 (executable)
@@ -1,6 +1,10 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(system_server C)
 
+# deviced
+SET(DEVICED_NAME deviced)
+SET(VERSION 0.1.0)
+
 SET(SRCS
        ss_main.c
        ss_sysnoti.c
@@ -22,11 +26,21 @@ SET(SRCS
        ss_procmgr.c
        ss_timemgr.c
        ss_cpu_handler.c
-       ss_vibrator.c
-       )
+       ss_common.c
+       ss_vibrator.c)
+
+# libdeviced
+SET(DEVICED_SRCS
+       src/shared/battery.c)
+
+SET(DEVICED_HEADERS
+       src/deviced/dd-battery.h)
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
+# libdeviced
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced)
+
 SET(MOVINAND_FORMAT movi_format.sh)
 
 INCLUDE(FindPkgConfig)
@@ -43,13 +57,17 @@ pkg_check_modules(pkgs REQUIRED
        dlog
        syspopup-caller
        notification
-       devman
-       device-node)
+       device-node
+       libsmack
+       libsystemd-daemon)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
+# libdeviced
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
@@ -69,16 +87,32 @@ 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")
+# libdeviced
+ADD_LIBRARY(${DEVICED_NAME} SHARED ${DEVICED_SRCS})
+TARGET_LINK_LIBRARIES(${DEVICED_NAME} ${pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${DEVICED_NAME} PROPERTIES VERSION ${VERSION})
+INSTALL(TARGETS ${DEVICED_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
 
+FOREACH(hfile ${DEVICED_HEADERS})
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${DEVICED_NAME})
+ENDFOREACH(hfile)
+
+CONFIGURE_FILE(${DEVICED_NAME}.pc.in ${DEVICED_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DEVICED_NAME}.pc DESTINATION lib/pkgconfig)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-ludev" "-lsmack")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
 INSTALL(FILES ${MOVINAND_FORMAT} DESTINATION bin)
 INSTALL(FILES ${UDEV_RULES} DESTINATION ${UDEV_RULES_PATH})
 INSTALL(FILES system-server.conf DESTINATION /etc/dbus-1/system.d)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/packaging/system-server.rule DESTINATION /opt/etc/smack/accesses.d)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/mmc-smack-label DESTINATION bin)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/system-server.service DESTINATION /usr/lib/systemd/system)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/system-server.socket  DESTINATION /usr/lib/systemd/system)
 
 ADD_SUBDIRECTORY(restarter)
 ADD_SUBDIRECTORY(sys_event)
-ADD_SUBDIRECTORY(sys_device_noti)
 ADD_SUBDIRECTORY(sys_pci_noti)
diff --git a/deviced.pc.in b/deviced.pc.in
new file mode 100644 (file)
index 0000000..3de6ff0
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=/usr/lib
+includedir=/usr/include/deviced
+
+Name: deviced library
+Description: Tizen platform device control library
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -ldeviced
+Cflags: -I${includedir}
index d56aad7..0a08245 100644 (file)
@@ -71,6 +71,9 @@ enum {
 #define PREDEF_MOUNT_MMC               "mountmmc"
 #define PREDEF_UNMOUNT_MMC             "unmountmmc"
 #define PREDEF_FORMAT_MMC              "formatmmc"
+#define PREDEF_CHECK_SMACK_MMC "checksmackmmc"
+#define PREDEF_CHECK_MMC               "checkmmc"
+#define PREDEF_CHECK_MMC_PROC  "checkmmcproc"
 
 #define PREDEF_SET_MAX_FREQUENCY       "set_max_frequency"     
 #define PREDEF_SET_MIN_FREQUENCY       "set_min_frequency"     
@@ -78,6 +81,12 @@ enum {
 #define PREDEF_RELEASE_MIN_FREQUENCY   "release_min_frequency" 
 
 #define PREDEF_FLIGHT_MODE             "flightmode"
+
+#define PREDEF_DEVICE_CHANGED  "device_changed"
+#define PREDEF_INTERNAL_POWEROFF       "internal_poweroff"
+
+#define PROCESS_GROUP_SET              "process_group_set"
+
 #define OOMADJ_SU                       (-17)
 #define OOMADJ_INIT                     (-16)
 #define OOMADJ_FOREGRD_LOCKED           (-15)
diff --git a/mmc-smack-label b/mmc-smack-label
new file mode 100755 (executable)
index 0000000..4d8fcad
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+MOUNT_DIRECTORY=$1
+find $MOUNT_DIRECTORY -type d | xargs chsmack -a 'system::ext_storage' -t
+find $MOUNT_DIRECTORY -type f | xargs chsmack -a 'system::ext_storage'
+find $MOUNT_DIRECTORY -type f | xargs chmod -x
+find $MOUNT_DIRECTORY | xargs chown app:app
+find $MOUNT_DIRECTORY | xargs chmod 777
diff --git a/packaging/deviced.manifest b/packaging/deviced.manifest
new file mode 100644 (file)
index 0000000..3256181
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+<request>
+       <domain name="_"/>
+</request>
+</manifest>
index 017d22d..2a56863 100644 (file)
@@ -1,5 +1,18 @@
 <manifest>
- <request>
-    <domain name="_"/>
- </request>
+       <define>
+               <domain name="deviced" policy="shared"/>
+       </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" />
+               <filesystem path="/usr/lib/systemd/system/system-server.service" label="_" exec_label="none" />
+               <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/system-server.service" label="_" exec_label="none" />
+               <filesystem path="/usr/lib/systemd/system/system-server.socket" label="_" exec_label="none" />
+               <filesystem path="/usr/lib/systemd/system/sockets.target.wants/system-server.socket" label="_" exec_label="none" />
+       </assign>
+       <request>
+               <domain name="deviced"/>
+       </request>
 </manifest>
index 3442a87..23855cb 100644 (file)
@@ -2,4 +2,6 @@ deviced sys-assert::core rwxat
 deviced system::vconf rwxat
 deviced telephony_framework::api_manager r
 deviced telephony_framework::api_modem wx
+deviced data-provider-master::notification rw
+deviced data-provider-master::notification.client w
 pulseaudio deviced rw
index 751b448..49177fc 100755 (executable)
@@ -6,8 +6,8 @@ Release:    6
 Group:      Framework/system
 License:    Apache License, Version 2.0
 Source0:    system-server-%{version}.tar.gz
-Source1:    system-server.service
 Source2:    system-server.manifest
+Source3:    deviced.manifest
 BuildRequires:  cmake
 BuildRequires:  libattr-devel
 BuildRequires:  pkgconfig(ecore)
@@ -15,17 +15,19 @@ 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(x11)
-BuildRequires:  pkgconfig(svi)
 BuildRequires:  pkgconfig(notification)
 BuildRequires:  pkgconfig(usbutils)
+BuildRequires:  pkgconfig(udev)
 BuildRequires:  pkgconfig(device-node)
+BuildRequires:  pkgconfig(libsmack)
 BuildRequires: gettext
+BuildRequires:  pkgconfig(libsystemd-daemon)
+%{?systemd_requires}
 Requires(preun): /usr/bin/systemctl
 Requires(post): /usr/bin/systemctl
 Requires(post): /usr/bin/vconftool
@@ -34,12 +36,28 @@ Requires(postun): /usr/bin/systemctl
 %description
 Description: System server
 
+%package -n libdeviced
+Summary:    Deviced library
+Group:      Development/Libraries
+
+%description -n libdeviced
+Deviced library for device control
+
+%package -n libdeviced-devel
+Summary:    Deviced library for (devel)
+Group:      Development/Libraries
+Requires:   libdeviced = %{version}-%{release}
+
+%description -n libdeviced-devel
+Deviced library for device control (devel)
+
 %prep
 %setup -q
 %cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 %build
 cp %{SOURCE2} .
+cp %{SOURCE3} .
 make %{?jobs:-j%jobs}
 
 %install
@@ -47,13 +65,14 @@ rm -rf %{buildroot}
 %make_install
 
 mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
-install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/system-server.service
+mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
 ln -s ../system-server.service %{buildroot}%{_unitdir}/multi-user.target.wants/system-server.service
+ln -s ../system-server.service %{buildroot}%{_unitdir}/sockets.target.wants/system-server.socket
 
 %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/mmc 0 -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
@@ -86,6 +105,11 @@ heynotitool set power_off_start
 
 heynotitool set mmcblk_add
 heynotitool set mmcblk_remove
+heynotitool set device_charge_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
 
 heynotitool set device_usb_chgdet
 heynotitool set device_ta_chgdet
@@ -93,12 +117,7 @@ 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
@@ -132,11 +151,22 @@ systemctl daemon-reload
 %endif
 %{_bindir}/movi_format.sh
 %{_bindir}/sys_event
-%{_bindir}/sys_device_noti
 %{_bindir}/sys_pci_noti
+%{_bindir}/mmc-smack-label
 %{_unitdir}/multi-user.target.wants/system-server.service
+%{_unitdir}/sockets.target.wants/system-server.socket
 %{_unitdir}/system-server.service
-%{_datadir}/system-server/sys_device_noti/batt_full_icon.png
+%{_unitdir}/system-server.socket
 %{_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
+
+%files -n libdeviced
+%defattr(-,root,root,-)
+%{_libdir}/libdeviced.so.*
+%manifest deviced.manifest
+
+%files -n libdeviced-devel
+%defattr(-,root,root,-)
+%{_includedir}/deviced/dd-battery.h
+%{_libdir}/libdeviced.so
+%{_libdir}/pkgconfig/deviced.pc
diff --git a/src/deviced/dd-battery.h b/src/deviced/dd-battery.h
new file mode 100644 (file)
index 0000000..78fd9b3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 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 __DD_BATTERY_H__
+#define __DD_BATTERY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file        dd-battery.h
+ * @ingroup     DEVICED_LIBRARY
+ * @brief       This file provides for control of battery
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/shared/battery.c b/src/shared/battery.c
new file mode 100644 (file)
index 0000000..7d7d238
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 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 <vconf.h>
+#include <errno.h>
+#include <device-node.h>
+
+#include "log.h"
+#include "dd-battery.h"
diff --git a/src/shared/log.h b/src/shared/log.h
new file mode 100644 (file)
index 0000000..78e7e47
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 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 __LOG_H__
+#define __LOG_H__
+
+#include <stdio.h>
+
+#if defined(ENABLE_DLOG_OUT)
+#define LOG_TAG                "DEVICED"
+#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: %s(%d) > " fmt, __MODULE__, __func__, __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: %s(%d) > "fmt"\n", __MODULE__, __func__, __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: %s(%d) > "fmt"\n", __MODULE__, __func__, __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: %s(%d) > "fmt"\n", __MODULE__, __func__, __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
diff --git a/ss_common.c b/ss_common.c
new file mode 100644 (file)
index 0000000..fff43aa
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+/**
+ * Opens "/proc/$pid/oom_adj" file for w/r;
+ * Return: FILE pointer or NULL
+ */
+FILE * open_proc_oom_adj_file(int pid, const char *mode)
+{
+        char buf[32];
+        FILE *fp;
+
+       /* snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid); */
+       /*
+        * Warn that /proc/pid/oom_adj is deprecated, see
+        * Documentation/feature-removal-schedule.txt.
+        * Please use /proc/%d/oom_score_adj instead.
+        */
+       snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", pid);
+       fp = fopen(buf, mode);
+       return fp;
+}
+
diff --git a/ss_common.h b/ss_common.h
new file mode 100644 (file)
index 0000000..a7af544
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _SS_COMMON_H
+#define _SS_COMMON_H
+
+FILE * open_proc_oom_adj_file(int pid, const char *mode);
+
+#endif /* _SS_COMMON_H */
+
index ae28c45..a5fb577 100644 (file)
--- a/ss_core.c
+++ b/ss_core.c
@@ -33,6 +33,10 @@ struct _internal_msg {
 };
 
 static int core_pipe[2];
+Ecore_Fd_Handler *g_pipe_efd = NULL;
+
+static int __pipe_start(struct ss_main_data *ad);
+static int __pipe_stop(int fd);
 
 static int _ss_core_action_run(void *user_data,
                               struct ss_run_queue_entry *rq_entry)
@@ -67,14 +71,31 @@ 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;
-
+       int retry_count = 0;
+       int r = -1;
        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));
+       while (retry_count < 5) {
+               r = read(core_pipe[0], &p_msg, sizeof(struct _internal_msg));
+               if (r < 0) {
+                       if (errno == EINTR) {
+                               PRT_TRACE_ERR("Re-read for error(EINTR)");
+                               retry_count++;
+                               continue;
+                       } else {
+                               __pipe_stop(core_pipe[0]);
+                               __pipe_stop(core_pipe[1]);
+                               PRT_TRACE_ERR("restart pipe fd");
+                               __pipe_start(ad);
+                       }
+               } else {
+                       break;
+               }
+       }
 
        switch (p_msg.type) {
        case SS_CORE_ACT_RUN:
@@ -111,12 +132,40 @@ int ss_core_action_clear(int pid)
 
 int ss_core_init(struct ss_main_data *ad)
 {
+       __pipe_stop(core_pipe[0]);
+       __pipe_stop(core_pipe[1]);
+
+       if (__pipe_start(ad) == -1) {
+               PRT_TRACE_ERR("fail pipe control fd init");
+               return -1;
+       }
+       return 0;
+}
+
+static int __pipe_start(struct ss_main_data *ad)
+{
        if (pipe(core_pipe) < 0) {
                PRT_TRACE_ERR("pipe cannot create");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
-       ecore_main_fd_handler_add(core_pipe[0], ECORE_FD_READ,
+       g_pipe_efd = ecore_main_fd_handler_add(core_pipe[0], ECORE_FD_READ,
                                  core_pipe_cb, ad, NULL, NULL);
+       if (!g_pipe_efd) {
+               PRT_TRACE_ERR("error ecore_main_fd_handler_add");
+               return -1;
+       }
+       return 0;
+}
+
+static int __pipe_stop(int fd)
+{
+       if (g_pipe_efd) {
+               ecore_main_fd_handler_del(g_pipe_efd);
+               g_pipe_efd = NULL;
+       }
+       if (fd >=0)
+               close(fd);
+
        return 0;
 }
index c88ef9f..e9a808e 100644 (file)
@@ -50,7 +50,7 @@ static int __write_min_cpu_freq(int freq);
 
 int set_max_frequency_action(int argc, char **argv)
 {
-       int r = -1;
+       int r;
        
        if (argc < 2)
                return -1;
@@ -72,7 +72,7 @@ int set_max_frequency_action(int argc, char **argv)
 
 int set_min_frequency_action(int argc, char **argv)
 {
-       int r = -1;
+       int r;
        
        if (argc < 2)
                return -1;
@@ -94,7 +94,7 @@ int set_min_frequency_action(int argc, char **argv)
 
 int release_max_frequency_action(int argc, char **argv)
 {
-       int r = -1;
+       int r;
        if (argc < 1)
                return -1;
        
@@ -118,7 +118,7 @@ int release_max_frequency_action(int argc, char **argv)
 
 int release_min_frequency_action(int argc, char **argv)
 {
-       int r = -1;
+       int r;
 
        if (argc < 1)
                return -1;
@@ -235,6 +235,8 @@ int ss_cpu_handler_init(void)
 static void __set_freq_limit()
 {
        int ret;
+       int power_saving_stat = -1;
+       int power_saving_cpu_stat = -1;
 
        ret = device_get_property(DEVICE_TYPE_CPU, PROP_CPU_CPUINFO_MAX_FREQ, &max_cpu_freq_limit);
        if (ret < 0) {
@@ -249,8 +251,6 @@ static void __set_freq_limit()
        }
 
        /* 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) {
@@ -340,7 +340,7 @@ static int __remove_entry_from_min_cpu_freq_list(int pid)
 
 static int __add_entry_to_max_cpu_freq_list(int pid, int freq)
 {
-       int r = -1;
+       int r;
        struct cpu_freq_entry *entry;
        
        r = __remove_entry_from_max_cpu_freq_list(pid);
@@ -372,7 +372,7 @@ 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)
 {
-       int r = -1;
+       int r;
        struct cpu_freq_entry *entry;
        
        r = __remove_entry_from_min_cpu_freq_list(pid);
index 2ef3bc1..9129a24 100755 (executable)
@@ -16,6 +16,7 @@
 
 
 #include <stdlib.h>
+#include <stdbool.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <errno.h>
 #include <aul.h>
 #include <bundle.h>
 #include <dirent.h>
-
+#include <libudev.h>
 #include "ss_queue.h"
 #include "ss_log.h"
 #include "ss_device_handler.h"
 #include "device-node.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"
-
+#include "ss_predefine.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)
+#ifdef ENABLE_EDBUS_USE
+#include <E_DBus.h>
+static E_DBus_Connection *conn;
+#endif                         /* ENABLE_EDBUS_USE */
+
+typedef enum {
+       CB_NOTI_BATT_CHARGE,
+       CB_NOTI_BATT_LOW,
+       CB_NOTI_BATT_FULL,
+       CB_NOTI_MAX
+} cb_noti_type;
+
+typedef enum {
+       CB_NOTI_OFF     = 0,
+       CB_NOTI_ON      = 1
+} cb_noti_onoff_type;
 
 struct input_event {
        long dummy[2];
@@ -63,8 +79,27 @@ enum snd_jack_types {
        SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
 };
 
+#define CHANGE_ACTION          "change"
+#define ENV_FILTER             "CHGDET"
+#define ENV_VALUE_USB          "usb"
+#define ENV_VALUE_CHARGER      "charger"
+#define ENV_VALUE_EARJACK      "earjack"
+#define ENV_VALUE_EARKEY       "earkey"
+#define ENV_VALUE_TVOUT        "tvout"
+#define ENV_VALUE_HDMI                 "hdmi"
+#define ENV_VALUE_KEYBOARD     "keyboard"
+
+
+#define ABNORMAL_POPUP_COUNTER 5
 
 static int input_device_number;
+
+static struct udev_monitor *mon = NULL;
+static struct udev *udev = NULL;
+static Ecore_Fd_Handler *ufdh = NULL;
+
+static int uevent_control_cb(void *data, Ecore_Fd_Handler *fd_handler);
+
 static int check_lowbat_charge_device(int bInserted)
 {
        static int bChargeDeviceInserted = 0;
@@ -83,8 +118,8 @@ static int check_lowbat_charge_device(int bInserted)
                                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) {
+                                       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)
@@ -112,14 +147,14 @@ 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);
+
+       predefine_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 (device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_USB_ONLINE, &val) == 0) {
                PRT_TRACE("jack - usb changed %d",val);
                check_lowbat_charge_device(val);
@@ -128,23 +163,37 @@ static void usb_chgdet_cb(struct ss_main_data *ad)
                        ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
                        PRT_TRACE("usb device notification");
                }
+       } else {
+               PRT_TRACE_ERR("fail to get usb_online status");
        }
 }
 
-static void ta_chgdet_cb(struct ss_main_data *ad)
+static void __sync_usb_status(void)
 {
-       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 status = -1;
+       if (device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_USB_ONLINE, &val) != 0 ||
+           vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS,&status) != 0)
+               return;
+       if ((val == 1 && status == VCONFKEY_SYSMAN_USB_DISCONNECTED) ||
+           (val == 0 && status == VCONFKEY_SYSMAN_USB_AVAILABLE))
+               ss_action_entry_call_internal(PREDEF_USBCON, 0);
+}
 
+static void ta_chgdet_cb(struct ss_main_data *ad)
+{
        int val = -1;
        int ret = -1;
        int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
        char params[BUFF_MAX];
 
+       predefine_pm_change_state(LCD_NORMAL);
+
+       /* check charging now */
+       ss_lowbat_is_charge_in_now();
+       /* check current battery level */
+       ss_lowbat_monitor(NULL);
+
        if (device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_TA_ONLINE, &val) == 0) {
                PRT_TRACE("jack - ta changed %d",val);
                check_lowbat_charge_device(val);
@@ -157,6 +206,7 @@ static void ta_chgdet_cb(struct ss_main_data *ad)
                        ss_launch_if_noexist("/usr/bin/sys_device_noti", params);
                        PRT_TRACE("ta device notification");
                }
+               __sync_usb_status();
        }
        else
                PRT_TRACE_ERR("failed to get ta status\n");
@@ -184,8 +234,9 @@ static void tvout_chgdet_cb(struct ss_main_data *ad)
 
 static void hdmi_chgdet_cb(struct ss_main_data *ad)
 {
-       PRT_TRACE("jack - hdmi changed\n");
        int val;
+       int ret = -1;
+
        pm_change_state(LCD_NORMAL);
        if (device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_HDMI_SUPPORT, &val) == 0) {
                if (val!=1) {
@@ -201,14 +252,14 @@ static void hdmi_chgdet_cb(struct ss_main_data *ad)
                        pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0);
                else
                        pm_unlock_state(LCD_NORMAL, PM_SLEEP_MARGIN);
+       } else {
+               PRT_TRACE_ERR("failed to get hdmi_online status");
        }
 }
 
 static void keyboard_chgdet_cb(struct ss_main_data *ad)
 {
        int val = -1;
-       int ret = -1;
-       PRT_TRACE("jack - keyboard changed\n");
 
        if (device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_KEYBOARD_ONLINE, &val) == 0) {
                PRT_TRACE("jack - keyboard changed %d",val);
@@ -222,12 +273,33 @@ static void keyboard_chgdet_cb(struct ss_main_data *ad)
 
 static void mmc_chgdet_cb(void *data)
 {
+       static bool first, inserted;
+       int mmc_status;
        int ret = -1;
        int val = -1;
+
+       /* at first time, this part will be judge mmc is already inserted or not. */
+       if (!first) {
+               vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_status);
+               if (mmc_status == VCONFKEY_SYSMAN_MMC_MOUNTED)
+                       inserted = true;
+               first = true;
+       }
+
        if (data == NULL) {
+               /* when removed mmc, emul kernel notify twice
+                * So this code ignores second event */
+               if (!inserted)
+                       return;
+               inserted = false;
                PRT_TRACE("mmc removed");
                ss_mmc_removed();
        } else {
+               /* when inserted mmc, emul kernel notify twice(insert, changed)
+                * So this code ignores second event */
+               if (inserted)
+                       return;
+               inserted = true;
                PRT_TRACE("mmc added");
                ret = ss_mmc_inserted();
                if (ret == -1) {
@@ -235,12 +307,29 @@ static void mmc_chgdet_cb(void *data)
                        if (val == VCONFKEY_SYSMAN_MMC_MOUNT_FAILED) {
                                bundle *b = NULL;
                                b = bundle_create();
+                               if (b == NULL) {
+                                       PRT_TRACE_ERR("error bundle_create()");
+                                       return;
+                               }
                                bundle_add(b, "_SYSPOPUP_CONTENT_", "mounterr");
                                ret = syspopup_launch("mmc-syspopup", b);
                                if (ret < 0) {
                                        PRT_TRACE_ERR("popup launch failed");
                                }
                                bundle_free(b);
+                       } else if (val == VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED) {
+                               bundle *b = NULL;
+                               b = bundle_create();
+                               if (b == NULL) {
+                                       PRT_TRACE_ERR("error bundle_create()");
+                                       return;
+                               }
+                               bundle_add(b, "_SYSPOPUP_CONTENT_", "mountrdonly");
+                               ret = syspopup_launch("mmc-syspopup", b);
+                               if (ret < 0) {
+                                       PRT_TRACE_ERR("popup launch failed");
+                               }
+                               bundle_free(b);
                        }
                }
        }
@@ -251,18 +340,48 @@ static void ums_unmount_cb(void *data)
        umount(MOVINAND_MOUNT_POINT);
 }
 
+static int __check_abnormal_popup_launch(void)
+{
+       static int noti_count = 0;
+       if (noti_count >= ABNORMAL_POPUP_COUNTER) {
+               noti_count = 0;
+               return 0;
+       } else {
+               noti_count++;
+               return -EAGAIN;
+       }
+}
+
 static void charge_cb(struct ss_main_data *ad)
 {
        int val = -1;
+       int charge_now = -1;
+       int capacity = -1;
        char params[BUFF_MAX];
        static int bat_full_noti = 0;
+
        ss_lowbat_monitor(NULL);
 
+       if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CHARGE_NOW, &charge_now) != 0 ||
+           device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &capacity) != 0)
+               PRT_TRACE_ERR("fail to get battery node value");
+       if (charge_now == 0 && capacity == 0) {
+               PRT_TRACE_ERR("target will be shut down");
+               ss_action_entry_call_internal(PREDEF_LOWBAT, 1, POWER_OFF_BAT_ACT);
+               return;
+       }
+
        if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_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);
 
+                       if (__check_abnormal_popup_launch() != 0)
+                               return;
+
+                       if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &val) == 0 && val <= 0)
+                               ss_action_entry_call_internal(PREDEF_LOWBAT, 1, POWER_OFF_BAT_ACT);
+                       else
+                               ss_action_entry_call_internal(PREDEF_LOWBAT, 1, CHARGE_ERROR_ACT);
                        return;
                }
        } else {
@@ -285,6 +404,25 @@ static void charge_cb(struct ss_main_data *ad)
        }
 }
 
+#ifdef ENABLE_EDBUS_USE
+static void cb_xxxxx_signaled(void *data, DBusMessage * msg)
+{
+       char *args;
+       DBusError err;
+       struct ss_main_data *ad;
+
+       ad = data;
+
+       dbus_error_init(&err);
+       if (dbus_message_get_args
+           (msg, &err, DBUS_TYPE_STRING, &args, DBUS_TYPE_INVALID)) {
+               if (!strcmp(args, "action")) ;  /* action */
+       }
+
+       return;
+}
+#endif                         /* ENABLE_EDBUS_USE */
+
 static void usb_host_chgdet_cb(keynode_t *in_key, struct ss_main_data *ad)
 {
        PRT_TRACE("ENTER: usb_host_chgdet_cb()");
@@ -328,6 +466,139 @@ static void usb_host_add_cb()
        PRT_TRACE("EXIT: usb_host_add_cb()\n");
 }
 
+static int uevent_control_stop(int ufd)
+{
+       if (ufdh) {
+               ecore_main_fd_handler_del(ufdh);
+               ufdh = NULL;
+       }
+       if (ufd >= 0) {
+               close(ufd);
+               ufd = -1;
+       }
+       if (mon) {
+               udev_monitor_unref(mon);
+               mon = NULL;
+       }
+       if (udev) {
+               udev_unref(udev);
+               udev = NULL;
+       }
+       return 0;
+}
+
+static int uevent_control_start(void)
+{
+       int ufd = -1;
+
+       udev = udev_new();
+       if (!udev) {
+               PRT_TRACE_ERR("error create udev");
+               return -1;
+       }
+
+       mon = udev_monitor_new_from_netlink(udev, "kernel");
+       if (mon == NULL) {
+               PRT_TRACE_ERR("error udev_monitor create");
+               uevent_control_stop(-1);
+               return -1;
+       }
+
+       udev_monitor_set_receive_buffer_size(mon, 1024);
+       if (udev_monitor_filter_add_match_subsystem_devtype(mon, "platform", NULL) < 0) {
+               PRT_TRACE_ERR("error apply subsystem filter");
+               uevent_control_stop(-1);
+               return -1;
+       }
+
+       ufd = udev_monitor_get_fd(mon);
+       if (ufd == -1) {
+               PRT_TRACE_ERR("error udev_monitor_get_fd");
+               uevent_control_stop(ufd);
+               return -1;
+       }
+
+       ufdh = ecore_main_fd_handler_add(ufd, ECORE_FD_READ, uevent_control_cb, NULL, NULL, NULL);
+       if (!ufdh) {
+               PRT_TRACE_ERR("error ecore_main_fd_handler_add");
+               uevent_control_stop(ufd);
+               return -1;
+       }
+
+       if (udev_monitor_enable_receiving(mon) < 0) {
+               PRT_TRACE_ERR("error unable to subscribe to udev events");
+               uevent_control_stop(ufd);
+               return -1;
+       }
+
+       return 0;
+}
+
+static int uevent_control_cb(void *data, Ecore_Fd_Handler *fd_handler)
+{
+       struct udev_device *dev = NULL;
+       struct udev_list_entry *list_entry = NULL;
+       char *env_name = NULL;
+       char *env_value = NULL;
+       int ufd = -1;
+       int ret = -1;
+
+       if (!ecore_main_fd_handler_active_get(fd_handler,ECORE_FD_READ))
+               return -1;
+       if ((ufd = ecore_main_fd_handler_fd_get(fd_handler)) == -1)
+               return -1;
+       if ((dev = udev_monitor_receive_device(mon)) == NULL)
+               return -1;
+
+       udev_list_entry_foreach(list_entry,udev_device_get_properties_list_entry(dev)) {
+               env_name = udev_list_entry_get_name(list_entry);
+               if (strncmp(env_name, ENV_FILTER, strlen(ENV_FILTER)) == 0) {
+                       env_value = udev_list_entry_get_value(list_entry);
+                       ret = 0;
+                       break;
+               }
+       }
+
+       if (ret != 0) {
+               udev_device_unref(dev);
+               return -1;
+       }
+
+       PRT_TRACE("UEVENT DETECTED (%s)",env_value);
+       ss_action_entry_call_internal(PREDEF_DEVICE_CHANGED,1,env_value);
+
+       udev_device_unref(dev);
+       uevent_control_stop(ufd);
+       uevent_control_start();
+
+       return 0;
+}
+
+int changed_device_def_predefine_action(int argc, char **argv)
+{
+       if (argc != 1 || argv[0] == NULL) {
+               PRT_TRACE_ERR("param is failed");
+               return -1;
+       }
+
+       if (strncmp(argv[0], ENV_VALUE_USB, strlen(ENV_VALUE_USB)) == 0)
+               usb_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_CHARGER, strlen(ENV_VALUE_CHARGER)) == 0)
+               ta_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_EARJACK, strlen(ENV_VALUE_EARJACK)) == 0)
+               earjack_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_EARKEY, strlen(ENV_VALUE_EARKEY)) == 0)
+               earkey_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_TVOUT, strlen(ENV_VALUE_TVOUT)) == 0)
+               tvout_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_HDMI, strlen(ENV_VALUE_HDMI)) == 0)
+               hdmi_chgdet_cb(NULL);
+       if (strncmp(argv[0], ENV_VALUE_KEYBOARD, strlen(ENV_VALUE_KEYBOARD)) == 0)
+               keyboard_chgdet_cb(NULL);
+
+       return 0;
+}
+
 static void pci_keyboard_add_cb(struct ss_main_data *ad)
 {
        char params[BUFF_MAX];
@@ -349,6 +620,12 @@ static void pci_keyboard_remove_cb(struct ss_main_data *ad)
 }
 int ss_device_change_init(struct ss_main_data *ad)
 {
+       ss_action_entry_add_internal(PREDEF_DEVICE_CHANGED, changed_device_def_predefine_action, NULL, NULL);
+
+       if (uevent_control_start() == -1) {
+               PRT_TRACE_ERR("fail uevent control init");
+               return -1;
+       }
        /* 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);
@@ -371,6 +648,17 @@ int ss_device_change_init(struct ss_main_data *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)");
        }
+       /* dbus noti change cb */
+#ifdef ENABLE_EDBUS_USE
+       e_dbus_init();
+       conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+       if (!conn)
+               PRT_TRACE_ERR("check system dbus running!\n");
+
+       e_dbus_signal_handler_add(conn, NULL, "/system/uevent/xxxxx",
+                                 "system.uevent.xxxxx",
+                                 "Change", cb_xxxxx_signaled, ad);
+#endif                         /* ENABLE_EDBUS_USE */
 
        /* set initial state for devices */
        input_device_number = 0;
index cdaf673..24b77c8 100644 (file)
@@ -51,7 +51,6 @@ static void prepare_exec(void)
 {
        int i;
        int maxfd;
-       char buf[MAX_ARGS];
        FILE *fp;
 
        maxfd = getdtablesize();
@@ -61,13 +60,6 @@ static void prepare_exec(void)
        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)
@@ -242,9 +234,10 @@ int ss_launch_if_noexist(const char *execpath, const char *arg, ...)
        }
 
        snprintf(buf, buf_size, "%s %s", execpath, arg);
+       //pid = launch_app_cmd_with_nice(buf, nice_value, flag);
        pid = launch_app_cmd_with_nice(buf, nice_value);
        if (pid == -2)
-               exit(0);
+               exit(EXIT_FAILURE);
        free(buf);
 
        return pid;
@@ -280,15 +273,16 @@ int ss_launch_evenif_exist(const char *execpath, const char *arg, ...)
        buf_size = strlen(execpath) + strlen(arg) + 10;
        buf = malloc(buf_size);
        if (buf == NULL) {
-               /* Do something for not enought memory error */
+               // 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, flag);
        pid = launch_app_cmd_with_nice(buf, nice_value);
        if (pid == -2)
-               exit(0);
+               exit(EXIT_FAILURE);
        free(buf);
 
        return pid;
@@ -298,11 +292,11 @@ 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 flag;
+       int buf_size;
        int exist_pid;
        va_list argptr;
+       int nice_value = 0;
 
        if (execpath == NULL) {
                errno = EINVAL;
@@ -333,9 +327,10 @@ int ss_launch_after_kill_if_exist(const char *execpath, const char *arg, ...)
        }
 
        snprintf(buf, buf_size, "%s %s", execpath, arg);
+       //pid = launch_app_cmd_with_nice(buf, nice_value, flag);
        pid = launch_app_cmd_with_nice(buf, nice_value);
-       if (pid == -2)
-               exit(0);
+       if (pid == -2)          /* It means that the 'execvp' return -1 */
+               exit(EXIT_FAILURE);
        free(buf);
 
        return pid;
index f6ce0fe..5f97290 100755 (executable)
@@ -82,6 +82,18 @@ static struct lowbat_process_entry lpe[] = {
        {BATTERY_NORMAL,                BATTERY_REAL_POWER_OFF, battery_power_off_act},
 };
 
+/*
+ * TODO: remove this function
+ */
+static void print_lowbat_state(unsigned int bat_percent)
+{
+#if 0
+       int i;
+       for (i = 0; i < BAT_MON_SAMPLES; i++)
+               PRT_TRACE("\t%d", recent_bat_percent[i]);
+#endif
+}
+
 static int battery_warning_low_act(void *data)
 {
        char lowbat_noti_name[NAME_MAX];
@@ -154,7 +166,8 @@ static int lowbat_process(int bat_percent, void *ad)
                        cur_bat_capacity = new_bat_capacity;
        }
 
-       if (0 > vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &vconf_state)) {
+
+       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &vconf_state) < 0) {
                PRT_TRACE_ERR("vconf_get_int() failed");
                return -1;
        }
@@ -188,9 +201,7 @@ static int lowbat_process(int bat_percent, void *ad)
        } else {
                new_bat_state = BATTERY_NORMAL;
                if (new_bat_capacity == BATTERY_FULL) {
-                       if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CHARGE_FULL, &bat_full) < 0) {
-                               PRT_TRACE_ERR("fail to read charge full from kernel");
-                       }
+                       device_get_property(DEVICE_TYPE_POWER, PROP_POWER_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);
@@ -235,19 +246,23 @@ static int lowbat_process(int bat_percent, void *ad)
                        }
                }
        }
+
        PRT_TRACE("[BATMON] Unknown battery state cur:%d new:%d",cur_bat_state,new_bat_state);
        cur_bat_state = new_bat_state;
-       return -1;
+
+       if (new_bat_capacity != cur_bat_capacity)
+               return -1;
+
+       return 0;
 }
 
-static int lowbat_read()
+static int lowbat_read(void)
 {
-       int bat_percent;
+       int bat_percent, r;
 
-       if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &bat_percent) < 0) {
-               PRT_TRACE_ERR("fail to read power capacity from kernel");
-               return -1;
-       }
+       r = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &bat_percent);
+       if (r < 0)
+               return r;
 
        return bat_percent;
 }
@@ -281,7 +296,7 @@ static void __ss_change_lowbat_level(int bat_percent)
                vconf_set_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, now);
 }
 
-static int __check_lowbat_percent(void)
+static int __check_lowbat_percent(int *pct)
 {
        int bat_percent;
 
@@ -292,28 +307,34 @@ static int __check_lowbat_percent(void)
                if (bat_err_count > MAX_BATTERY_ERROR) {
                        PRT_TRACE_ERR
                            ("[BATMON] Cannot read battery gage. stop read fuel gage");
+                       return -ENODEV;
                }
-               return -1;
+               return -ENODEV;
        }
        if (bat_percent > 100)
                bat_percent = 100;
        __ss_change_lowbat_level(bat_percent);
-       return bat_percent;
+       *pct = bat_percent;
+       return 0;
 }
 
-int ss_lowbat_monitor(void *data)
+Eina_Bool ss_lowbat_monitor(void *data)
 {
        struct ss_main_data *ad = (struct ss_main_data *)data;
-       int bat_percent;
+       int bat_percent, r;
 
-       bat_percent = __check_lowbat_percent();
+       r = __check_lowbat_percent(&bat_percent);
+       if (r < 0)
+               return ECORE_CALLBACK_RENEW;
+
+       print_lowbat_state(bat_percent);
 
        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;
+       return ECORE_CALLBACK_RENEW;
 }
 
 static int wakeup_cb(keynode_t *key_nodes, void *data)
@@ -343,13 +364,13 @@ static int check_battery()
 
 int ss_lowbat_init(struct ss_main_data *ad)
 {
-       int i;
+       int i, pct;
 
        /* need check battery */
        lowbat_timer =
-           ecore_timer_add(BAT_MON_INTERVAL_MIN, ss_lowbat_monitor, ad);
+               ecore_timer_add(BAT_MON_INTERVAL_MIN, ss_lowbat_monitor, ad);
 
-       __check_lowbat_percent();
+       __check_lowbat_percent(&pct);
 
        ss_lowbat_is_charge_in_now();
 
index aceac64..d103b50 100644 (file)
--- a/ss_main.c
+++ b/ss_main.c
  * limitations under the License.
  */
 
-
+#include <systemd/sd-daemon.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <heynoti.h>
+#include <sys/reboot.h>
 
 #include "ss_log.h"
 #include "ss_core.h"
 #include "ss_cpu_handler.h"
 #include "include/ss_data.h"
 
-#define SS_PIDFILE_PATH                "/var/run/.system_server.pid"
-
 static void fini(struct ss_main_data *ad)
 {
-       // try to remove pid file
-       unlink(SS_PIDFILE_PATH);
 }
 
 static void init_ad(struct ss_main_data *ad)
@@ -82,6 +79,13 @@ static void system_server_init(struct ss_main_data *ad)
        ss_bs_init();
 }
 
+#define SS_PIDFILE_PATH                "/var/run/.system_server.pid"
+static void sig_quit(int signo)
+{
+       PRT_TRACE_ERR("received SIGTERM signal %d", signo);
+       if (is_power_off() == 1)
+               reboot(RB_POWER_OFF);
+}
 static int system_main(int argc, char **argv)
 {
        struct ss_main_data ad;
@@ -97,7 +101,13 @@ static int system_main(int argc, char **argv)
                fini(&ad);
                return 0;
        }
+
        system_server_init(&ad);
+       signal(SIGTERM, sig_quit);
+
+       // Notyfication to systemd
+       if (sd_booted())
+               sd_notify(0, "READY=1");
 
        ecore_main_loop_begin();
 
@@ -107,14 +117,9 @@ static int system_main(int argc, char **argv)
        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);
+       return system_main(argc, argv);
 }
index 61074b8..126175d 100644 (file)
 
 #include <unistd.h>
 #include <sys/mount.h>
+#include <sys/smack.h>
+#include <sys/statvfs.h>
 #include <errno.h>
 #include <vconf.h>
 #include <fcntl.h>
 #include <dirent.h>
-#include <sysman.h>
+#include <sys/statfs.h>
+#include <bundle.h>
 #include "ss_log.h"
 #include "ss_device_handler.h"
+#include "ss_predefine.h"
 
+#define VCONFKEY_INTERNAL_PRIVATE_MMC_ID       "db/private/sysman/mmc_device_id"
+
+#define MMC_MOUNT_POINT                        "/opt/storage/sdcard"
+
+#define MMC_DEV                        "/dev/mmcblk"
 #define MOVINAND_DEV           "/dev/mmcblk0p1"
 #define FORMAT_MMC             PREFIX"/sbin/mkfs.vfat "
 #define FORMAT_MOVINAND                PREFIX"/bin/movi_format.sh"
 
-#define FS_VFAT_MOUNT_OPT  "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed,smackfsroot=*,smackfsdef=*"
+#define FS_VFAT_NAME "mkdosfs"
+#define FS_VFAT_MOUNT_OPT  "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed"
+#define FS_VFAT_CHECKER "/sbin/fsck.vfat"
+#define FS_EXT4_CHECKER "/sbin/fsck.ext4"
+#define FS_VFAT_CHECK_PARAM "-a %s"
+#define FS_EXT4_CHECK_PARAM "-f -y %s"
+#define FS_EXT4_SMACK_LABEL "mmc-smack-label "MMC_MOUNT_POINT
+
+#define SMACKFS_MAGIC          0x43415d53
+#define SMACKFS_MNT            "/smack"
+#define SMACKFS_MOUNT_OPT      "smackfsroot=*,smackfsdef=*"
+
+#ifndef ST_RDONLY
+#define ST_RDONLY      0x0001
+#endif
 
 #define MMC_PARENT_PATH     "/opt/storage"
 
 
 #define MMC_32GB_SIZE           61315072
 
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+typedef enum {
+       FS_TYPE_NONE = 0,
+       FS_TYPE_FAT = 1,
+       FS_TYPE_EXT4
+} mmc_fs_type;
+
+typedef enum {
+       FS_MOUNT_ERR = -1,
+       FS_MOUNT_FAIL = 0,
+       FS_MOUNT_SUCCESS = 1,
+} mmc_mount_type;
+
+
+struct fs_check {
+       unsigned int type;
+       char *name;
+       unsigned int offset;
+       unsigned int magic_sz;
+       char magic[4];
+};
+
+static struct fs_check fs_types[2] = {
+       {
+               FS_TYPE_FAT,
+               "vfat",
+               0x1fe,
+               2,
+               {0x55, 0xaa}
+       },
+       {
+               FS_TYPE_EXT4,
+               "ext4",
+               0x438,
+               2,
+               {0x53, 0xef}
+       },
+};
+
+
+static const char *fsstr[] = {
+    [FS_TYPE_FAT] = "mkdosfs",
+};
+
 static const char *vfat_arg[] = {
        "/sbin/mkfs.vfat",
        NULL, NULL,
 };
 
-int mmc_status;
-int ss_mmc_inserted(void);
-static int __umount_fs(void);
+static const char *ext4_arg[] = {
+    "/sbin/mkfs.ext4",
+    NULL, NULL,
+};
+
+static const char *vfat_check_arg[] = {
+    "/sbin/fsck.vfat",
+    "-a", NULL, NULL,
+};
+
+static const char *ext4_check_arg[] = {
+    "/sbin/fsck.ext4",
+    "-f", "-y", NULL, NULL,
+};
+
+
+static int smack;
+static int mmc_popup_pid;
+static mmc_fs_type inserted_type;
+
+static void __attribute__ ((constructor)) smack_check(void)
+{
+       struct statfs sfs;
+       int ret;
+
+       do {
+               ret = statfs(SMACKFS_MNT, &sfs);
+       } while (ret < 0 && errno == EINTR);
+
+       if (ret == 0 && sfs.f_type == SMACKFS_MAGIC)
+               smack = 1;
+       PRT_TRACE_ERR("smackfs check %d", smack);
+}
 
 static int exec_process(const char **argv)
 {
@@ -72,7 +170,7 @@ static int exec_process(const char **argv)
        return pid;
 }
 
-int get_mmcblk_num()
+int get_mmcblk_num(void)
 {
        DIR *dp;
        struct dirent *dir;
@@ -81,6 +179,8 @@ int get_mmcblk_num()
        int fd;
        int r;
        int mmcblk_num;
+       char *pre_mmc_device_id = NULL;
+       int mmc_dev_changed = 0;
 
        if ((dp = opendir("/sys/block")) == NULL) {
                PRT_TRACE_ERR("Can not open directory..\n");
@@ -117,7 +217,7 @@ int get_mmcblk_num()
                                        if (str_mmcblk_num == NULL) {
                                                PRT_TRACE_ERR("Memory Allocation Failed");
                                                closedir(dp);
-                                               return -1; 
+                                               return -1;
                                        }
                                        mmcblk_num =
                                            atoi(str_mmcblk_num);
@@ -125,6 +225,38 @@ int get_mmcblk_num()
                                        free(str_mmcblk_num);
                                        closedir(dp);
                                        PRT_TRACE("%d \n", mmcblk_num);
+
+                                       snprintf(buf, 255, "/sys/block/%s/device/cid", dir->d_name);
+
+                                       fd = open(buf, O_RDONLY);
+                                       if (fd == -1) {
+                                               PRT_TRACE_ERR("%s open error", buf, strerror(errno));
+                                               return mmcblk_num;
+                                       }
+                                       r = read(fd, buf, 255);
+                                       if ((r >=0) && (r < 255)) {
+                                               buf[r] = '\0';
+                                       } else {
+                                               PRT_TRACE_ERR("%s read error: %s", buf,strerror(errno));
+                                       }
+                                       close(fd);
+                                       pre_mmc_device_id = vconf_get_str(VCONFKEY_INTERNAL_PRIVATE_MMC_ID);
+                                       if (pre_mmc_device_id) {
+                                               if (strcmp(pre_mmc_device_id, "") == 0) {
+                                                       vconf_set_str(VCONFKEY_INTERNAL_PRIVATE_MMC_ID, buf);
+                                               } else if (strncmp(pre_mmc_device_id,buf,33) == 0) {
+                                                       if ( vconf_get_int(VCONFKEY_SYSMAN_MMC_DEVICE_CHANGED,&mmc_dev_changed) == 0
+                                                       && mmc_dev_changed != VCONFKEY_SYSMAN_MMC_NOT_CHANGED) {
+                                                               vconf_set_int(VCONFKEY_SYSMAN_MMC_DEVICE_CHANGED, VCONFKEY_SYSMAN_MMC_NOT_CHANGED);
+                                                       }
+                                               } else if (strncmp(pre_mmc_device_id,buf,32) != 0) {
+                                                       vconf_set_str(VCONFKEY_INTERNAL_PRIVATE_MMC_ID, buf);
+                                                       vconf_set_int(VCONFKEY_SYSMAN_MMC_DEVICE_CHANGED, VCONFKEY_SYSMAN_MMC_CHANGED);
+                                               }
+                                               free(pre_mmc_device_id);
+                                       } else {
+                                               PRT_TRACE_ERR("failed to get pre_mmc_device_id");
+                                       }
                                        return mmcblk_num;
                                }
                        }
@@ -136,6 +268,104 @@ int get_mmcblk_num()
        return -1;
 }
 
+static int __umount_fs(void)
+{
+       int ret;
+       if ((ret = umount2(MMC_MOUNT_POINT, MNT_DETACH)) != 0) {
+               PRT_TRACE_ERR("Failed to unmount mmc card : %s\n", strerror(errno));
+       }
+       return ret;
+}
+
+static int __check_mmc_fs_type(const char *path)
+{
+       int fd, ret, i;
+       char buf[20];
+       int len = 20;
+       char *tmpbuf = buf;
+       int cnr = 0;
+       struct statfs sfs;
+
+       inserted_type = FS_TYPE_NONE;
+       if ((fd = open(path, O_RDONLY)) < 0) {
+               PRT_TRACE_ERR("can't open the '%s': %s", path, strerror(errno));
+               return -1;
+       }
+
+       while (len != 0 && (ret = read(fd, tmpbuf, len)) != 0) {
+               if (ret == -1) {
+                       if (errno == EINTR) {
+                               PRT_TRACE_ERR("check_mmc_fs error(%d)", errno);
+                               continue;
+                       }
+                       PRT_TRACE_ERR("Can't read the '%s': %s", path, strerror(errno));
+                       inserted_type = FS_TYPE_FAT;
+                       goto check_return;
+               }
+               len -= ret;
+               tmpbuf += ret;
+               cnr += ret;
+       }
+       PRT_TRACE("mmc search path: %s, %s", path, buf);
+
+       /* check fs type with magic code */
+       for (i = 0; i < ARRAY_SIZE(fs_types); i++)
+       {
+               ret = lseek(fd, fs_types[i].offset, SEEK_SET);
+               if (ret < 0)
+                       goto check_return;
+               ret = read(fd, buf, 2);
+               if (ret < 0)
+                       goto check_return;
+               PRT_TRACE("mmc search magic : 0x%2x, 0x%2x", buf[0],buf[1]);
+               if (!memcmp(buf, fs_types[i].magic, fs_types[i].magic_sz)) {
+                       inserted_type =  fs_types[i].type;
+                       PRT_TRACE("mmc type : %s", fs_types[i].name);
+                       goto check_return;
+               }
+       }
+
+       if (inserted_type == FS_TYPE_NONE)
+               inserted_type = FS_TYPE_FAT;
+
+check_return:
+       close(fd);
+       return 0;
+}
+
+static int get_format_type(const char *path)
+{
+       unsigned int size;
+
+       if (__check_mmc_fs_type(path) != 0) {
+               PRT_TRACE_ERR("fail to check mount point %s", path);
+               return -1;
+       }
+       if (inserted_type == FS_TYPE_EXT4)
+               return 0;
+
+       return 0;
+}
+
+static const char **get_argument(const char *path, int fs)
+{
+       int argc;
+
+       switch (fs) {
+       case FS_TYPE_FAT:
+               argc = ARRAY_SIZE(vfat_arg);
+               vfat_arg[argc - 2] = path;
+               return vfat_arg;
+       case FS_TYPE_EXT4:
+               argc = ARRAY_SIZE(ext4_arg);
+               ext4_arg[argc - 2] = path;
+               return ext4_arg;
+       default:
+               break;
+       }
+       return NULL;
+}
+
 static int check_mount_state(void)
 {
        struct stat parent_stat, mount_stat;
@@ -162,28 +392,38 @@ static int check_mount_state(void)
 static int create_partition(const char *dev_path)
 {
        int r;
+       char data[256];
+
+       snprintf(data, sizeof(data), "printf \"n\\n\\n\\n\\n\\nw\" | fdisk %s", dev_path);
 
-       r = system("printf \"n\\n\\n\\n\\n\\nw\" | fdisk /dev/mmcblk1");
+       r = system(data);
        if (WIFSIGNALED(r) && (WTERMSIG(r) == SIGINT || WTERMSIG(r) == SIGQUIT || WEXITSTATUS(r)))
                return -1;
 
        return 0;
 }
 
-static int format_mmc(const char *path)
+static int format_mmc(const char *path, int fs)
 {
+       mmc_fs_type type;
+       unsigned int size;
        int mkfs_pid;
+       const char **argv;
        char buf[NAME_MAX];
+       int r;
 
        if (path == NULL) {
                PRT_TRACE_ERR("Invalid parameter");
                return -1;
        }
 
-       vfat_arg[1] = path;
-
-       mkfs_pid = exec_process(vfat_arg);
+       argv = get_argument(path, fs);
+       if (argv == NULL) {
+               PRT_TRACE_ERR("get_argument fail");
+               return -1;
+       }
 
+       mkfs_pid = exec_process(argv);
        if (mkfs_pid < 0) {
                PRT_TRACE_ERR("%s fail");
                return -1;
@@ -205,7 +445,7 @@ static int format_exec(int blknum)
 {
        char dev_mmcblk[NAME_MAX];
        char dev_mmcblkp[NAME_MAX];
-       int r;
+       int fs, r;
 
        if (check_mount_state() == 1) {
                PRT_TRACE_ERR("Mounted, will be unmounted");
@@ -230,9 +470,11 @@ static int format_exec(int blknum)
                }
        }
 
-       r = format_mmc(dev_mmcblkp);
+       PRT_TRACE_ERR("insert type : %d", inserted_type);
+
+       r = format_mmc(dev_mmcblkp, inserted_type);
        if (r < 0) {
-               PRT_TRACE_ERR("format_mmc fail");
+               PRT_TRACE_ERR("%s format fail", dev_mmcblkp);
                vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, VCONFKEY_SYSMAN_MMC_FORMAT_FAILED);
                heynoti_publish("mmcblk_remove");
                return -1;
@@ -243,15 +485,46 @@ static int format_exec(int blknum)
        return 0;
 }
 
-static int ss_mmc_format(keynode_t *key_nodes, void *data)
+static const char **get_check_argument(const char *path)
 {
-       PRT_TRACE_ERR("mmc format called");
-       __umount_fs();
-       vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS, VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS_NOW);
-       format_exec(get_mmcblk_num());
-       vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS, VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS_NONE);
-       ss_mmc_inserted();
+       int argc;
+
+       switch (inserted_type) {
+       case FS_TYPE_EXT4:
+               argc = ARRAY_SIZE(ext4_check_arg);
+               ext4_check_arg[argc - 2] = path;
+               return ext4_check_arg;
+       default:
+               break;
+       }
+       return NULL;
+}
+
+static int mmc_check_process_launch(int argc,  char **argv)
+{
+       const char **params;
+       char buf[NAME_MAX];
+       int pid;
+
+       params = get_check_argument((const char*)argv[1]);
+       if ((pid = exec_process(params)) < 0) {
+               PRT_TRACE_ERR("mmc checker failed");
+               goto run_mount;
+       }
+
+       snprintf(buf, sizeof(buf), "%s%d", "/proc/", pid);
+       PRT_TRACE_ERR("child process : %s", buf);
+
+       while (1) {
+               sleep(1);
+               PRT_TRACE_ERR("mmc checking ....");
+               if (access(buf, R_OK) != 0)
+                       break;
+       }
+run_mount:
+       ss_action_entry_call_internal(PREDEF_CHECK_MMC,0);
        return 0;
+
 }
 
 int ss_mmc_unmounted(int argc, char **argv)
@@ -281,20 +554,41 @@ int ss_mmc_unmounted(int argc, char **argv)
                      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;
+}
+
 
+static int __ss_rw_mount(const char* szPath)
+{
+       struct statvfs mount_stat;
+       if (!statvfs(szPath, &mount_stat)) {
+               if ((mount_stat.f_flag & ST_RDONLY) == ST_RDONLY)
+                       return -1;
+       }
        return 0;
 }
 
-int ss_mmc_init()
+static int __ss_check_smack_popup(void)
 {
-       /* mmc card mount */
-       ss_mmc_inserted();
+       bundle *b = NULL;
+       int ret = -1;
+       int val = -1;
+
+       b = bundle_create();
+       bundle_add(b, "_SYSPOPUP_CONTENT_", "checksmack");
+       ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &val);
+       if (val == 1 || ret != 0) {
+               if ((mmc_popup_pid = syspopup_launch("mmc-syspopup", b)) < 0) {
+                       PRT_TRACE_EM("popup launch failed\n");
+               }
+       }
+       bundle_free(b);
 
-       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);
+       if (ss_action_entry_call_internal(PREDEF_CHECK_SMACK_MMC, 0) < 0) {
+               PRT_TRACE_ERR("fail to launch mmc checker,direct mount mmc");
+       }
        return 0;
+
 }
 
 static int __mount_fs(char *path, const char *fs_name, const char *mount_data)
@@ -303,7 +597,7 @@ static int __mount_fs(char *path, const char *fs_name, const char *mount_data)
 
        do {
                if ((ret = mount(path, MMC_MOUNT_POINT, fs_name, 0, mount_data)) == 0) {
-                       PRT_TRACE("Mounted mmc card\n");
+                       PRT_TRACE_ERR("Mounted mmc card %s", fs_name);
                        return 0;
                }
                usleep(100000);
@@ -316,6 +610,7 @@ static int __mmc_mount_fs(void)
 {
        char buf[NAME_MAX];
        char params[NAME_MAX];
+       char options[NAME_MAX];
        int fd;
        int blk_num;
 
@@ -340,57 +635,122 @@ static int __mmc_mount_fs(void)
        } else
                close(fd);
 
-       if (__mount_fs(buf, "vfat", FS_VFAT_MOUNT_OPT) != 0)
-               return errno;
+       switch (inserted_type) {
+       case FS_TYPE_FAT:
+               if (smack)
+                       snprintf(options, sizeof(options), "%s,%s", FS_VFAT_MOUNT_OPT, SMACKFS_MOUNT_OPT);
+               else
+                       snprintf(options, sizeof(options), "%s", FS_VFAT_MOUNT_OPT);
+               if (__mount_fs(buf, "vfat", options) != 0)
+                       return -1;
+               break;
+       case FS_TYPE_EXT4:
+               if (__mount_fs(buf, "ext4", NULL) != 0)
+                       return errno;
+               if (smack) {
+                       if (__ss_check_smack_popup() != 0)
+                               return -1;
+               }
+               return smack;
+       }
        return 0;
-
 }
-int ss_mmc_inserted(void)
-{
-       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;
-       }
 
+static int mmc_check_mount(int argc,  char **argv)
+{
+       int r;
        r = __mmc_mount_fs();
        if (r == 0)
                goto mount_complete;
+       else if (r == 1)
+               goto mount_wait;
        else if (r == -1)
                goto mount_fail;
        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);
        vconf_set_int(VCONFKEY_SYSMAN_MMC_ERR_STATUS, errno);
-       mmc_status = VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED;
        PRT_TRACE_ERR("Failed to mount mmc card\n");
        return -1;
 
 mount_complete:
+       r = __ss_rw_mount(MMC_MOUNT_POINT);
        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;
+       if (r == -1)
+               return -1;
        return 0;
 mount_fail:
        vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS, VCONFKEY_SYSMAN_MMC_REMOVED);
        vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT, VCONFKEY_SYSMAN_MMC_MOUNT_FAILED);
        vconf_set_int(VCONFKEY_SYSMAN_MMC_ERR_STATUS, VCONFKEY_SYSMAN_MMC_EINVAL);
-       mmc_status = VCONFKEY_SYSMAN_MMC_REMOVED;
+       return 0;
+mount_wait:
+       PRT_TRACE_ERR("wait ext4 smack rule checking");
        return 0;
 }
-static int __umount_fs(void)
+
+static int __check_mmc_fs(void)
+{
+       char buf[NAME_MAX];
+       char params[NAME_MAX];
+       char options[NAME_MAX];
+       int fd;
+       int blk_num;
+       int ret = 0;
+
+       if (access(MMC_MOUNT_POINT, R_OK) != 0) {
+               if (mkdir(MMC_MOUNT_POINT, 0755) < 0) {
+                       PRT_TRACE_ERR("Make Directory is failed");
+                       return errno;
+               }
+       }
+
+       blk_num = get_mmcblk_num();
+       if (blk_num  == -1) {
+               PRT_TRACE_ERR("fail to check mmc block");
+               return -1;
+       }
+
+       snprintf(buf, sizeof(buf), "%s%dp1", MMC_DEV, blk_num);
+       fd = open(buf, O_RDONLY);
+       if (fd < 0) {
+               PRT_TRACE_ERR("can't open the '%s': %s", buf, strerror(errno));
+               snprintf(buf, sizeof(buf), "%s%d", MMC_DEV, blk_num);
+       }
+       else
+               close(fd);
+
+       if (__check_mmc_fs_type(buf) != 0) {
+               PRT_TRACE_ERR("fail to check mount point %s", buf);
+               return -1;
+       }
+       snprintf(params, sizeof(params), "%d", inserted_type);
+       if (ss_action_entry_call_internal(PREDEF_CHECK_MMC_PROC, 2, params, buf) < 0) {
+               PRT_TRACE_ERR("fail to launch mmc checker,direct mount mmc");
+               ret = mmc_check_mount(0, NULL);
+       }
+       return ret;
+}
+
+int ss_mmc_inserted(void)
 {
+       int mmc_status;
        int ret;
-       if ((ret = umount2(MMC_MOUNT_POINT, MNT_DETACH)) != 0) {
-               PRT_TRACE_ERR("Failed to unmount mmc card\n");
+
+       vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_status);
+
+       if (mmc_status == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+               PRT_DBG("Mmc is already mounted.\n");
+               vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT, VCONFKEY_SYSMAN_MMC_MOUNT_ALREADY);
+               return 0;
        }
-       mmc_status = VCONFKEY_SYSMAN_MMC_REMOVED;
+
+       if ((ret = __check_mmc_fs()) != 0)
+               PRT_TRACE_ERR("fail to check mmc");
        return ret;
 }
-int ss_mmc_removed()
+
+int ss_mmc_removed(void)
 {
        int mmc_err = 0;
        vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS, VCONFKEY_SYSMAN_MMC_REMOVED);
@@ -399,3 +759,46 @@ int ss_mmc_removed()
 
        return 0;
 }
+
+static int ss_mmc_format(int argc, char **argv)
+{
+       PRT_TRACE_ERR("mmc format called");
+       __umount_fs();
+
+       vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS, VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS_NOW);
+       format_exec(get_mmcblk_num());
+       vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS, VCONFKEY_SYSMAN_MMC_FORMAT_PROGRESS_NONE);
+
+       if (__check_mmc_fs() != 0)
+               PRT_TRACE_ERR("fail to check mmc");
+
+       return 0;
+}
+
+static int ss_mmc_check_smack(int argc, char **argv)
+{
+       int pid;
+       system(FS_EXT4_SMACK_LABEL);
+       PRT_TRACE_ERR("smack labeling script is run");
+       vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS, VCONFKEY_SYSMAN_MMC_MOUNTED);
+       vconf_set_int(VCONFKEY_SYSMAN_MMC_MOUNT, VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED);
+       if (mmc_popup_pid > 0) {
+               PRT_TRACE_ERR("will be killed mmc-popup(%d)", mmc_popup_pid);
+               kill(mmc_popup_pid, SIGTERM);
+       }
+       return 0;
+}
+
+int ss_mmc_init(void)
+{
+       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);
+       ss_action_entry_add_internal(PREDEF_CHECK_SMACK_MMC, ss_mmc_check_smack, NULL, NULL);
+       ss_action_entry_add_internal(PREDEF_CHECK_MMC, mmc_check_mount, NULL, NULL);
+       ss_action_entry_add_internal(PREDEF_CHECK_MMC_PROC, mmc_check_process_launch, NULL, NULL);
+       /* mmc card mount */
+       if (__check_mmc_fs() != 0)
+               PRT_TRACE_ERR("fail to check mmc");
+       return 0;
+}
index 2a5a105..c5476be 100644 (file)
 #include "ss_log.h"
 #include "ss_launch.h"
 #include "include/ss_data.h"
+#include "ss_common.h"
 
 #define PMON_PERMANENT_DIR     "/tmp/permanent"
 
-static int pmon_fd = -1;
+static Ecore_Fd_Handler *pmon_efd = NULL;
 
+static int __pmon_start(struct ss_main_data *ad);
+static int __pmon_stop(int fd);
 static int replace_char(int size, char *t)
 {
        while (size > 0) {
@@ -61,7 +64,6 @@ static char *pmon_get_permanent_pname(int pid)
                close(fd);
                return NULL;
        }
-
        PRT_TRACE("size = %d", (int)st.st_size);
 
        cmdline = malloc(st.st_size + 1);
@@ -127,7 +129,6 @@ static int pmon_process(int pid, void *ad)
                                        PRT_TRACE("Failed to open");
                                        return -1;
                                }
-
                                cnt = read(fd, buf, PATH_MAX);
                                close(fd);
 
@@ -143,14 +144,12 @@ static int pmon_process(int pid, void *ad)
                                        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 ( device_set_property(DEVICE_TYPE_PROCESS, PROP_PROCESS_MP_PNP, new_pid) < 0) {
                                        PRT_TRACE_ERR("Write new pid failed");
                                }
@@ -161,9 +160,8 @@ static int pmon_process(int pid, void *ad)
                                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");
+                               
+                               fp = open_proc_oom_adj_file(new_pid, "w");
                                if (fp == NULL)
                                        return -1;
                                fprintf(fp, "%d", (-17));
@@ -193,22 +191,23 @@ 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;
+               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;
+               return -1;
        }
-       if ((read(fd, &dead_pid, sizeof(dead_pid))) < 0) {
-               PRT_TRACE_ERR("Reading DEAD_PID failed, Return");
-               return 1;
+       if (read(fd, &dead_pid, sizeof(dead_pid)) < 0) {
+               __pmon_stop(fd);
+               PRT_TRACE_ERR("Reading DEAD_PID failed, restart ecore fd");
+               __pmon_start(ad);
+               return -1;
        }
                
        print_pmon_state(dead_pid);
@@ -219,7 +218,23 @@ static int pmon_cb(void *data, Ecore_Fd_Handler * fd_handler)
 
 int ss_pmon_init(struct ss_main_data *ad)
 {
+       int ret = -1;
+       if (pmon_efd) {
+               ecore_main_fd_handler_del(pmon_efd);
+               pmon_efd = NULL;
+       }
+       if (__pmon_start(ad) == -1) {
+               PRT_TRACE_ERR("fail pmon control fd init");
+               return -1;
+       }
+       return 0;
+}
+
+static int __pmon_start(struct ss_main_data *ad)
+{
+       int pmon_fd = -1;
        char pmon_dev_node[PATH_MAX];
+
        if (device_get_property(DEVICE_TYPE_PROCESS, PROP_PROCESS_NODE, pmon_dev_node) < 0) {
                PRT_TRACE_ERR("ss_pmon_init get dev node path failed");
                return -1;
@@ -230,7 +245,22 @@ int ss_pmon_init(struct ss_main_data *ad)
                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);
+       pmon_efd = ecore_main_fd_handler_add(pmon_fd, ECORE_FD_READ, pmon_cb, ad, NULL, NULL);
+       if (!pmon_efd) {
+               PRT_TRACE_ERR("error ecore_main_fd_handler_add");
+               return -1;
+       }
+       return 0;
+}
+static int __pmon_stop(int fd)
+{
+       if (pmon_efd) {
+               ecore_main_fd_handler_del(pmon_efd);
+               pmon_efd = NULL;
+       }
+       if (fd >=0) {
+               close(fd);
+               fd = -1;
+       }
        return 0;
 }
index fd7ed32..44e8d28 100644 (file)
@@ -30,6 +30,8 @@
 #include <syspopup_caller.h>
 #include <sys/reboot.h>
 #include <sys/time.h>
+#include <mntent.h>
+#include <sys/mount.h>
 
 #include "ss_log.h"
 #include "ss_launch.h"
 #include "ss_procmgr.h"
 #include "ss_vibrator.h"
 #include "include/ss_data.h"
-
-#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"
+#include "ss_common.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"
+#define HDMI_NOTI_EXEC_PATH            PREFIX"/bin/hdmi_connection_noti"
+#define LOWBAT_POPUP_NAME              "lowbat-syspopup"
+#define POWEROFF_POPUP_NAME            "poweroff-syspopup"
+#define HDMI_POPUP_NAME                        "hdmi-syspopup"
+#define LOWMEM_POPUP_NAME              "lowmem-syspopup"
 
 /* wait for 5 sec as victim process be dead */
-#define WAITING_INTERVAL                       5
+#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 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 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 WM_READY_PATH                  "/tmp/.wm_ready"
 
 #define LOWBAT_OPT_WARNING             1
 #define LOWBAT_OPT_POWEROFF            2
-#define LOWBAT_OPT_CHARGEERR   3
+#define LOWBAT_OPT_CHARGEERR           3
 #define LOWBAT_OPT_CHECK               4
 
 static Ecore_Timer *lowbat_popup_id = NULL;
@@ -74,6 +84,7 @@ 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 void poweroff_control_cb(keynode_t *in_key, struct ss_main_data *ad);
+int internal_poweroff_def_predefine_action(int argc, char **argv);
 
 static int ss_flags = 0;
 
@@ -81,10 +92,56 @@ static Ecore_Timer *poweroff_timer_id = NULL;
 static TapiHandle *tapi_handle = NULL;
 static int power_off = 0;
 
+static int __predefine_get_pid(const char *execpath)
+{
+       DIR *dp;
+       struct dirent *dentry;
+       int pid = -1, fd;
+       char buf[PATH_MAX];
+       char buf2[PATH_MAX];
+
+       dp = opendir("/proc");
+       if (!dp) {
+               PRT_TRACE_ERR("open /proc");
+               return -1;
+       }
+
+       while ((dentry = readdir(dp)) != NULL) {
+               if (!isdigit(dentry->d_name[0]))
+                       continue;
+
+               pid = atoi(dentry->d_name);
+
+               snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
+               fd = open(buf, O_RDONLY);
+               if (fd < 0)
+                       continue;
+               if (read(fd, buf2, PATH_MAX) < 0) {
+                       close(fd);
+                       continue;
+               }
+               close(fd);
+
+               if (!strcmp(buf2, execpath)) {
+                       closedir(dp);
+                       return pid;
+               }
+       }
+
+       errno = ESRCH;
+       closedir(dp);
+       return -1;
+}
+
+int is_power_off(void)
+{
+       return power_off;
+}
+
 static void make_memps_log(char *file, pid_t pid, char *victim_name)
 {
        time_t now;
-       struct tm cur_tm;
+       struct tm *cur_tm;
        char params[4096];
        char new_log[NAME_MAX];
        static pid_t old_pid = 0;
@@ -95,35 +152,71 @@ static void make_memps_log(char *file, pid_t pid, char *victim_name)
        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) {
+       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);
+                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);
+                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);
-
+       /* will be removed, just for debugging */
        if(ret > 0) {
-               char buf[PATH_MAX];
                FILE *fp;
-               snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", ret);
-               fp = fopen(buf, "w");
+               fp = open_proc_oom_adj_file(ret, "w");
                if (fp != NULL) {
                        fprintf(fp, "%d", (-17));
                        fclose(fp);
                }
        }
+       free(cur_tm);
+}
+
+static void remount_ro()
+{
+       struct mntent* mnt;
+       const char* table = "/etc/mtab";
+       const char mmtpoint[10][64];
+       FILE* fp;
+       int r = -1, foundmount=0;
+       char buf[256];
+       fp = setmntent(table, "r");
+
+       if (!fp)
+               return;
+
+       while (mnt=getmntent(fp)) {
+               if (foundmount >= 10)
+                       continue;
+               if (!strcmp(mnt->mnt_type, "ext4") && strstr(mnt->mnt_opts, "rw")) {
+                       memset(mmtpoint[foundmount], 0, 64);
+                       strncpy(mmtpoint[foundmount], mnt->mnt_dir, 63);
+                       foundmount++;
+               }
+       }
+       endmntent(fp);
+       while (foundmount) {
+               foundmount--;
+               snprintf(buf, sizeof(buf), "fuser -c %s -k -15", mmtpoint[foundmount]);
+               sleep(1);
+               umount2(mmtpoint[foundmount], MNT_DETACH);
+       }
 }
 
 static int lowmem_get_victim_pid()
@@ -160,6 +253,7 @@ int lowmem_def_predefine_action(int argc, char **argv)
 
                                if(get_app_oomadj(pid, &oom_adj) < 0) {
                                        PRT_TRACE_ERR("Failed to get oom_adj");
+                                       return -1;
                                }
                                PRT_TRACE("%d will be killed with %d oom_adj value", pid, oom_adj);
 
@@ -204,6 +298,9 @@ int usbcon_def_predefine_action(int argc, char **argv)
                        return 0;
                }
 
+               if ( vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, &val) == 0 && val == VCONFKEY_SYSMAN_USB_AVAILABLE)
+                       return 0;
+
                vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
                              VCONFKEY_SYSMAN_USB_AVAILABLE);
                pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
@@ -237,7 +334,7 @@ int lowbat_popup(void *data)
        if (state == 1 || ret != 0) {
                bundle *b = NULL;
                b = bundle_create();
-               if(lowbat_popup_option == LOWBAT_OPT_WARNING) {
+               if (lowbat_popup_option == LOWBAT_OPT_WARNING || lowbat_popup_option == LOWBAT_OPT_CHECK) {
                        bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
                } else if(lowbat_popup_option == LOWBAT_OPT_POWEROFF) {
                        bundle_add(b, "_SYSPOPUP_CONTENT_", "poweroff");
@@ -264,6 +361,58 @@ int lowbat_popup(void *data)
        return 0;
 }
 
+
+int predefine_control_launch(char *name, bundle *b)
+{
+       int pid;
+       static int launched_poweroff = 0;
+       //lowbat-popup
+       if (strncmp(name, LOWBAT_POPUP_NAME, strlen(LOWBAT_POPUP_NAME)) == 0) {
+               if (launched_poweroff == 1) {
+                       PRT_TRACE_ERR("will be foreced power off");
+                       internal_poweroff_def_predefine_action(0,NULL);
+                       return 0;
+               }
+
+               if (lowbat_popup_option == LOWBAT_OPT_POWEROFF)
+                       launched_poweroff = 1;
+
+               pid = __predefine_get_pid(LOWBAT_EXEC_PATH);
+               if (pid > 0) {
+                       PRT_TRACE_ERR("pre launched %s destroy", LOWBAT_EXEC_PATH);
+                       kill(pid, SIGTERM);
+               }
+               if (syspopup_launch(name, b) < 0)
+                       return -1;
+       }
+       //poweroff-popup
+       if (strncmp(name, POWEROFF_POPUP_NAME, strlen(POWEROFF_POPUP_NAME)) == 0) {
+               if (syspopup_launch(name, b) < 0)
+                       return -1;
+       }
+       //hdmi-popup
+       if (strncmp(name, HDMI_POPUP_NAME, strlen(HDMI_POPUP_NAME)) == 0) {
+               if (syspopup_launch(name, b) < 0)
+                       return -1;
+       }
+       //hdmi-noti
+       if (strncmp(name, HDMI_NOTI_EXEC_PATH, strlen(HDMI_NOTI_EXEC_PATH)) == 0) {
+               if (ss_launch_if_noexist(name, "1") < 0)
+                       return -1;
+       }
+       //user mem lowmem-popup
+       if (strncmp(name, LOWMEM_POPUP_NAME, strlen(LOWMEM_POPUP_NAME)) == 0) {
+               if (syspopup_launch(name, b) < 0)
+                       return -1;
+       }
+       return 0;
+}
+
+void predefine_pm_change_state(unsigned int s_bits)
+{
+       pm_change_state(s_bits);
+}
+
 int lowbat_def_predefine_action(int argc, char **argv)
 {
        int ret, state=0;
@@ -273,14 +422,17 @@ int lowbat_def_predefine_action(int argc, char **argv)
        if (argc < 1)
                return -1;
 
-       if(lowbat_popup_id != NULL) {
+       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)) {
+       if (!strcmp(argv[0],CRITICAL_LOW_BAT_ACT)) {
+               bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
+               lowbat_popup_option = LOWBAT_OPT_CHECK;
+       } else if(!strcmp(argv[0],WARNING_LOW_BAT_ACT)) {
                bundle_add(b, "_SYSPOPUP_CONTENT_", "warning");
                lowbat_popup_option = LOWBAT_OPT_WARNING;
        } else if(!strcmp(argv[0],POWER_OFF_BAT_ACT)) {
@@ -289,19 +441,15 @@ int lowbat_def_predefine_action(int argc, char **argv)
        } 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;
+               if (predefine_control_launch("lowbat-syspopup", b) < 0) {
+                               PRT_TRACE_ERR("popup lauch failed\n");
+                               bundle_free(b);
+                               lowbat_popup_option = 0;
+                               return -1;
                }
        } else {
                PRT_TRACE_EM("boot-animation running yet");
@@ -339,8 +487,8 @@ Eina_Bool powerdown_ap_by_force(void *data)
        PRT_TRACE("Power off by force\n");
        /* give a chance to be terminated for each process */
        power_off = 1;
-       sleep(1);
        sync();
+       remount_ro();
        reboot(RB_POWER_OFF);
        return EINA_TRUE;
 }
@@ -378,22 +526,37 @@ static void powerdown_ap(TapiHandle *handle, const char *noti_id, void *data, vo
 
        /* give a chance to be terminated for each process */
        power_off = 1;
-       sleep(1);
        sync();
+       remount_ro();
        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;
+       int retry_count = 0;
 
        heynoti_publish(POWEROFF_NOTI_NAME);
-       vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
 
-       pm_change_state(LCD_NORMAL);
+       while (retry_count < MAX_RETRY) {
+               if (ss_action_entry_call_internal(PREDEF_INTERNAL_POWEROFF, 0) < 0) {
+                       PRT_TRACE_ERR("failed to request poweroff to system_server \n");
+                       retry_count++;
+                       continue;
+               }
+               vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
+               return 0;
+       }
+       return -1;
+}
+
+int internal_poweroff_def_predefine_action(int argc, char **argv)
+{
+       int ret;
+
        system("/etc/rc.d/rc.shutdown &");
        sync();
 
@@ -508,6 +671,8 @@ static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void
        }
 
        PRT_INFO("Restart\n");
+       vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
+       power_off = 1;
        sync();
 
        buf = getenv("PWROFF_DUR");
@@ -520,6 +685,7 @@ static void restart_ap(TapiHandle *handle, const char *noti_id, void *data, void
                usleep(100000);
                gettimeofday(&now, NULL);
        }
+       remount_ro();
 
        reboot(RB_AUTOBOOT);
 }
@@ -543,6 +709,7 @@ static void restart_ap_by_force(void *data)
        }
 
        PRT_INFO("Restart\n");
+       power_off = 1;
        sync();
 
        buf = getenv("PWROFF_DUR");
@@ -555,6 +722,7 @@ static void restart_ap_by_force(void *data)
                usleep(100000);
                gettimeofday(&now, NULL);
        }
+       remount_ro();
 
        reboot(RB_AUTOBOOT);
 }
@@ -563,6 +731,7 @@ int restart_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();
@@ -598,9 +767,8 @@ int launching_predefine_action(int argc, char **argv)
                return -1;
 
        /* current just launching poweroff-popup */
-       ret = syspopup_launch("poweroff-syspopup", NULL);
-       if (ret < 0) {
-               PRT_TRACE_ERR("poweroff popup predefine action failed");
+       if (predefine_control_launch("poweroff-syspopup", NULL) < 0) {
+               PRT_TRACE_ERR("poweroff-syspopup launch failed");
                return -1;
        }
        return 0;
@@ -690,6 +858,9 @@ static void poweroff_control_cb(keynode_t *in_key, struct ss_main_data *ad)
        case VCONFKEY_SYSMAN_POWER_OFF_POPUP:
                ss_action_entry_call_internal(PREDEF_PWROFF_POPUP, 0);
                break;
+       case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
+               ss_action_entry_call_internal(PREDEF_REBOOT, 0);
+               break;
        }
 }
 
@@ -732,6 +903,8 @@ void ss_predefine_internal_init(void)
                                     restart_def_predefine_action, NULL, NULL);
        ss_action_entry_add_internal(PREDEF_FLIGHT_MODE,
                                     flight_mode_def_predefine_action, NULL, NULL);
+       ss_action_entry_add_internal(PREDEF_INTERNAL_POWEROFF,
+                                    internal_poweroff_def_predefine_action, NULL, NULL);
        ss_action_entry_add_internal(PREDEF_HAPTIC, haptic_def_predefine_action,
                                        NULL, NULL);
 
index c05cb0a..1548ec7 100644 (file)
 
 #ifndef __SS_PREDEFINE_H__
 #define __SS_PREDEFINE_H__
+#include <bundle.h>
 
 int call_predefine_action(int argc, char **argv);
 void ss_predefine_internal_init(void);
-
+int is_power_off(void);
+void predefine_pm_change_state(unsigned int s_bits);
+int predefine_control_launch(char *popup_name, bundle *b);
 #endif /* __SS_PREDEFINE_H__ */
index 9a6faee..de789eb 100755 (executable)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <sys/types.h>
+#include <device-node.h>
 
 #include <sysman.h>
 #include "include/ss_data.h"
@@ -28,6 +29,8 @@
 
 #define LIMITED_BACKGRD_NUM 15
 #define MAX_BACKGRD_OOMADJ (OOMADJ_BACKGRD_UNLOCKED + LIMITED_BACKGRD_NUM)
+#define PROCESS_VIP            "process_vip"
+#define PROCESS_PERMANENT      "process_permanent"
 
 int get_app_oomadj(int pid, int *oomadj)
 {
@@ -183,11 +186,7 @@ int check_and_set_old_backgrd()
                        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 < MAX_BACKGRD_OOMADJ) {
                                if (new_oomadj != oom_adj)
                                        update_backgrd_app_oomadj(pid, new_oomadj);
                                new_oomadj++;
@@ -353,7 +352,6 @@ int set_backgrd_action(int argc, char **argv)
                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:
@@ -368,6 +366,28 @@ int set_backgrd_action(int argc, char **argv)
        return ret;
 }
 
+int set_process_group_action(int argc, char **argv)
+{
+       int pid = -1;
+       int ret = -1;
+
+       if (argc != 2)
+               return -1;
+       if ((pid = atoi(argv[0])) < 0)
+               return -1;
+
+       if (strncmp(argv[1], PROCESS_VIP, strlen(PROCESS_VIP)) == 0)
+               ret = device_set_property(DEVICE_TYPE_PROCESS, PROP_PROCESS_MP_VIP, pid);
+       else if (strncmp(argv[1], PROCESS_PERMANENT, strlen(PROCESS_PERMANENT)) == 0)
+               ret = device_set_property(DEVICE_TYPE_PROCESS, PROP_PROCESS_MP_PNP, pid);
+
+       if (ret == 0)
+               PRT_TRACE_ERR("%s : pid %d", argv[1], pid);
+       else
+               PRT_TRACE_ERR("fail to set %s : pid %d",argv[1], pid);
+       return 0;
+}
+
 int ss_process_manager_init(void)
 {
        ss_action_entry_add_internal(PREDEF_FOREGRD, set_foregrd_action, NULL,
@@ -379,5 +399,6 @@ int ss_process_manager_init(void)
        ss_action_entry_add_internal(PREDEF_INACTIVE, set_inactive_action, NULL,
                                     NULL);
        ss_action_entry_add_internal(OOMADJ_SET, set_oomadj_action, NULL, NULL);
+       ss_action_entry_add_internal(PROCESS_GROUP_SET, set_process_group_action, NULL, NULL);
        return 0;
 }
index ec62c15..4269d10 100644 (file)
@@ -23,7 +23,7 @@
 #include "ss_log.h"
 
 #define SS_PREDEFINE_ACT_FUNC_STR              "ss_predefine_action"
-#define SS_IS_ACCESSABLE_FUNC_STR              "ss_is_accessable"
+#define SS_IS_ACCESSIBLE_FUNC_STR              "ss_is_accessible"
 #define SS_UI_VIEWABLE_FUNC_STR                        "ss_ui_viewable"
 
 static Eina_List *predef_act_list;
@@ -46,7 +46,7 @@ static struct ss_action_entry *ss_action_entry_find(char *type)
 int ss_action_entry_add_internal(char *type,
                                 int (*predefine_action) (),
                                 int (*ui_viewable) (),
-                                int (*is_accessable) (int))
+                                int (*is_accessible) (int))
 {
        struct ss_action_entry *data;
 
@@ -66,7 +66,7 @@ int ss_action_entry_add_internal(char *type,
        if (data->predefine_action == NULL)
                goto err;
 
-       data->is_accessable = is_accessable;
+       data->is_accessible = is_accessible;
        data->ui_viewable = ui_viewable;
        data->owner_pid = getpid();
        data->type = strdup(type);
@@ -112,7 +112,7 @@ int ss_action_entry_add(struct sysnoti *msg)
                goto err;
        }
 
-       data->is_accessable = dlsym(data->handle, SS_IS_ACCESSABLE_FUNC_STR);
+       data->is_accessible = dlsym(data->handle, SS_IS_ACCESSIBLE_FUNC_STR);
        data->ui_viewable = dlsym(data->handle, SS_UI_VIEWABLE_FUNC_STR);
        data->owner_pid = msg->pid;
        data->type = strdup(msg->type);
@@ -166,7 +166,7 @@ int ss_action_entry_call_internal(char *type, int argc, ...)
        return 0;
 }
 
-int ss_action_entry_call(struct sysnoti *msg, int argc, char **argv)
+int ss_action_entry_call(struct sysnoti *msg, int sockfd)
 {
        Eina_List *tmp;
        Eina_List *tmp_next;
@@ -174,15 +174,15 @@ int ss_action_entry_call(struct sysnoti *msg, int argc, char **argv)
 
        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) {
+                       if (data->is_accessible != NULL
+                           && data->is_accessible(sockfd) == 0) {
                                PRT_TRACE_ERR
                                    ("%d cannot call that predefine module",
                                     msg->pid);
                                return -1;
                        }
                        int ret;
-                       ret=ss_run_queue_add(data, argc, argv);
+                       ret=ss_run_queue_add(data, msg->argc, msg->argv);
                        PRT_TRACE_ERR("ss_run_queue_add : %d",ret);
                        ret=ss_core_action_run();
                        PRT_TRACE_ERR("ss_core_action_run : %d",ret);
index ee9a304..6b9d899 100644 (file)
@@ -27,7 +27,7 @@ struct ss_action_entry {
        char *path;
        int (*predefine_action) ();
        int (*ui_viewable) ();
-       int (*is_accessable) (int caller_pid);
+       int (*is_accessible) (int caller_sockfd);
 };
 
 enum ss_run_state {
@@ -47,10 +47,10 @@ struct ss_run_queue_entry {
 int ss_action_entry_add_internal(char *type,
                                 int (*predefine_action) (),
                                 int (*ui_viewable) (),
-                                int (*is_accessable) (int));
+                                int (*is_accessible) (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_action_entry_call(struct sysnoti *msg, int sockfd);
 
 int ss_run_queue_run(enum ss_run_state state,
                     int (*run_func) (void *, struct ss_run_queue_entry *),
index 558a6df..ec93479 100755 (executable)
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-
+#include <stdbool.h>
+#include <systemd/sd-daemon.h>
 #include <sysman.h>
 #include <limits.h>
 #include <sys/types.h>
 #include "ss_queue.h"
 
 #define SYSNOTI_SOCKET_PATH "/tmp/sn"
+#define RETRY_READ_COUNT       5
+
+#define POWER_MANAGER_STR      "power_manager"
+#define ACTIVE_STR                     "active"
+#define INACTIVE_STR           "inactive"
 
 enum sysnoti_cmd {
        ADD_SYSMAN_ACTION,
        CALL_SYSMAN_ACTION
 };
 
+static Ecore_Fd_Handler *sysnoti_efd = NULL;
+
+static int __sysnoti_start(void);
+static int __sysnoti_stop(int fd);
+
 static void print_sysnoti_msg(const char *title, struct sysnoti *msg)
 {
        int i;
@@ -40,25 +51,20 @@ static void print_sysnoti_msg(const char *title, struct sysnoti *msg)
        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("=====================");
+       PRT_TRACE_ERR("pid : %d name: %s cmd : %d type : %s path : %s",
+                       msg->pid, exe_name, msg->cmd, msg->type, msg->path);
 }
 
 static inline int recv_int(int fd)
 {
        int val, r = -1;
-       while(1) {
+       int retry_count = 0;
+       while (retry_count < RETRY_READ_COUNT) {
                r = read(fd, &val, sizeof(int));
                if (r < 0) {
                        if(errno == EINTR) {
                                PRT_TRACE_ERR("Re-read for error(EINTR)");
+                               retry_count++;
                                continue;
                        }
                        else {
@@ -69,18 +75,21 @@ static inline int recv_int(int fd)
                        return val;
                }
        }
+       return -1;
 }
 
 static inline char *recv_str(int fd)
 {
        int len, r = -1;
+       int retry_count = 0;
        char *str;
 
-       while(1) {
+       while (retry_count < RETRY_READ_COUNT) {
                r = read(fd, &len, sizeof(int));
                if (r < 0) {
                        if(errno == EINTR) {
                                PRT_TRACE_ERR("Re-read for error(EINTR)");
+                               retry_count++;
                                continue;
                        }
                        else {
@@ -90,7 +99,10 @@ static inline char *recv_str(int fd)
                } else
                        break;
        }
-
+       if (retry_count == RETRY_READ_COUNT) {
+               PRT_TRACE_ERR("Read retry failed");
+               return NULL;
+       }
        if (len <= 0) {
                PRT_TRACE_ERR("str is null");
                return NULL;
@@ -107,11 +119,13 @@ static inline char *recv_str(int fd)
                return NULL;
        }
 
-       while(1) {
+       retry_count = 0;
+       while (retry_count < RETRY_READ_COUNT) {
                r = read(fd, str, len);
                if(r < 0) {
                        if(errno == EINTR) {
                                PRT_TRACE_ERR("Re-read for error(EINTR)");
+                               retry_count++;
                                continue;                       
                        }                                               
                        else {      
@@ -123,6 +137,13 @@ static inline char *recv_str(int fd)
                } else
                        break;
        }
+       if (retry_count == RETRY_READ_COUNT) {
+               PRT_TRACE_ERR("Read retry failed");
+               free(str);
+               str = NULL;
+               return NULL;
+       }
+
        str[len] = 0;
 
        return str;
@@ -132,14 +153,17 @@ 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);
+       if ((msg->pid = recv_int(fd)) == -1)
+               return -1;
+       if ((msg->cmd = recv_int(fd)) == -1)
+               return -1;
+       if ((msg->type = recv_str(fd)) == NULL)
+               return -1;
        msg->path = recv_str(fd);
        msg->argc = recv_int(fd);
 
        if (msg->argc < 0)
-               return 0;
+               return -1;
        for (i = 0; i < msg->argc; i++)
                msg->argv[i] = recv_str(fd);
 
@@ -148,7 +172,7 @@ static int read_message(int fd, struct sysnoti *msg)
 
 static inline void internal_free(char *str)
 {
-       if (!str)
+       if (str)
                free(str);
 }
 
@@ -159,6 +183,21 @@ static inline void free_message(struct sysnoti *msg)
        free(msg);
 }
 
+static bool check_sync_request(struct sysnoti *msg)
+{
+       char path[PATH_MAX];
+
+       if (sysman_get_cmdline_name(msg->pid, path, PATH_MAX) < 0)
+               return true;
+
+       PRT_TRACE_ERR("path : %s, type : %s", path, msg->type);
+       if (!strcmp(path, POWER_MANAGER_STR) &&
+                       (!strcmp(msg->type, INACTIVE_STR) || !strcmp(msg->type, ACTIVE_STR)))
+               return false;
+
+       return true;
+}
+
 static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
 {
        int fd;
@@ -167,6 +206,7 @@ static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
        struct sockaddr_un client_address;
        int client_sockfd;
        int client_len;
+       bool sync;
 
        if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
                PRT_TRACE_ERR
@@ -175,7 +215,6 @@ static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
        }
 
        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__);
@@ -183,41 +222,46 @@ static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
        }
 
        client_len = sizeof(client_address);
-       client_sockfd =
-           accept(fd, (struct sockaddr *)&client_address,
-                  (socklen_t *)&client_len);
-       if(client_sockfd == -1) {
+       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;
+               return -1;
        }
-
        if (read_message(client_sockfd, msg) < 0) {
                PRT_TRACE_ERR("%s : recv error msg", __FUNCTION__);
+               print_sysnoti_msg(__FUNCTION__, msg);
                free_message(msg);
                write(client_sockfd, &ret, sizeof(int));
                close(client_sockfd);
-               return 1;
+               __sysnoti_stop(fd);
+               __sysnoti_start();
+               return -1;
        }
 
+       sync = check_sync_request(msg);
+
        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));
+               if (sync)
+                       write(client_sockfd, &ret, sizeof(int));
                close(client_sockfd);
-               return 1;
+               return -1;
        }
 
        switch (msg->cmd) {
        case CALL_SYSMAN_ACTION:
-               ret = ss_action_entry_call(msg, msg->argc, msg->argv);
+               ret = ss_action_entry_call(msg, client_sockfd);
                break;
        default:
                ret = -1;
        }
 
-       write(client_sockfd, &ret, sizeof(int));
+       if (sync)
+               write(client_sockfd, &ret, sizeof(int));
        close(client_sockfd);
 
        free_message(msg);
@@ -225,11 +269,46 @@ static int sysnoti_cb(void *data, Ecore_Fd_Handler * fd_handler)
        return 1;
 }
 
+static int ss_sysnoti_systemd_socket_test(const char *path)
+{
+       int type = SOCK_STREAM;
+       int listening = 1;
+       size_t length = 0;
+       int fd = -1;
+       int rc;
+       int n;
+       int i;
+
+       // Gets number of created by systemd file descriptors that represent open sockets.
+       n = sd_listen_fds(0);
+       for (i = 0; i < n; i ++) {
+
+               // File descriptor calculation
+               fd = SD_LISTEN_FDS_START  + i;
+
+               // File descriptor veryfication.
+               if ((rc = sd_is_socket_unix(fd, type, listening, path, length)) > 0)
+                       return fd;
+
+               // Check error
+               if (rc < 0)
+                       return -1;
+       }
+
+       // No proper socket
+       return -1;
+}
+
 static int ss_sysnoti_server_init(void)
 {
        int fd;
        struct sockaddr_un serveraddr;
 
+       // Getting systemd socket
+       fd = ss_sysnoti_systemd_socket_test(SYSNOTI_SOCKET_PATH);
+       if (fd >= 0)
+               return fd;
+
        if (access(SYSNOTI_SOCKET_PATH, F_OK) == 0)
                unlink(SYSNOTI_SOCKET_PATH);
 
@@ -238,7 +317,6 @@ static int ss_sysnoti_server_init(void)
                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) {
@@ -260,8 +338,7 @@ static int ss_sysnoti_server_init(void)
        strncpy(serveraddr.sun_path, SYSNOTI_SOCKET_PATH,
                sizeof(serveraddr.sun_path));
 
-       if (bind(fd, (struct sockaddr *)&serveraddr, sizeof(struct sockaddr)) <
-           0) {
+       if (bind(fd, (struct sockaddr *)&serveraddr, sizeof(struct sockaddr)) < 0) {
                PRT_ERR("%s: socket bind failed\n", __FUNCTION__);
                close(fd);
                return -1;
@@ -282,11 +359,33 @@ static int ss_sysnoti_server_init(void)
 
 int ss_sysnoti_init(void)
 {
+       return __sysnoti_start();
+}
+
+static int __sysnoti_start(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,
+       sysnoti_efd = ecore_main_fd_handler_add(fd, ECORE_FD_READ, sysnoti_cb, NULL, NULL,
                                  NULL);
+       if (!sysnoti_efd) {
+               PRT_TRACE_ERR("error ecore_main_fd_handler_add");
+               return -1;
+       }
        return fd;
 }
+
+static int __sysnoti_stop(int fd)
+{
+       if (sysnoti_efd) {
+               ecore_main_fd_handler_del(sysnoti_efd);
+               sysnoti_efd = NULL;
+       }
+       if (fd >=0) {
+               close(fd);
+               fd = -1;
+       }
+       return 0;
+}
index 854319d..cecbbb1 100644 (file)
@@ -178,7 +178,7 @@ int set_timezone_action(int argc, char **argv)
 
 static int timerfd_check_start(void)
 {
-       int tfd = -1;
+       int tfd;
        struct itimerspec tmr;
 
        if ((tfd = timerfd_create(CLOCK_REALTIME,TFD_NONBLOCK|TFD_CLOEXEC)) == -1) {
index b97c358..815aca7 100644 (file)
@@ -37,8 +37,7 @@ int ss_usb_init()
                        vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,
                                        VCONFKEY_SYSMAN_USB_AVAILABLE);
                        while (i < RETRY
-                                       && pm_lock_state(LCD_OFF, STAY_CUR_STATE,
-                                               0) == -1) {
+                                       && pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0) == -1) {
                                i++;
                                sleep(1);
                        }
index 7e42faa..9d5c7c8 100644 (file)
@@ -309,4 +309,4 @@ int haptic_def_predefine_action(int argc, char **argv)
        }
 
        return -1;
-}
+}
\ No newline at end of file
diff --git a/sys_device_noti/CMakeLists.txt b/sys_device_noti/CMakeLists.txt
deleted file mode 100755 (executable)
index c56d50b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-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)
diff --git a/sys_device_noti/data/batt_full_icon.png b/sys_device_noti/data/batt_full_icon.png
deleted file mode 100755 (executable)
index 4245ccc..0000000
Binary files a/sys_device_noti/data/batt_full_icon.png and /dev/null differ
diff --git a/sys_device_noti/po_sys_device_noti/CMakeLists.txt b/sys_device_noti/po_sys_device_noti/CMakeLists.txt
deleted file mode 100644 (file)
index a08d14a..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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})
diff --git a/sys_device_noti/po_sys_device_noti/ar.po b/sys_device_noti/po_sys_device_noti/ar.po
deleted file mode 100755 (executable)
index 1e20482..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "تم شحن البطارية كاملا"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "فصل الشاحن"
-
diff --git a/sys_device_noti/po_sys_device_noti/az.po b/sys_device_noti/po_sys_device_noti/az.po
deleted file mode 100755 (executable)
index e749e15..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batareya tam doludur"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Adapteri rozetkadan çıxarın"
-
diff --git a/sys_device_noti/po_sys_device_noti/bg.po b/sys_device_noti/po_sys_device_noti/bg.po
deleted file mode 100755 (executable)
index a6af4c4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Батерията напълно заредена"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Изключете зарядното устройство"
-
diff --git a/sys_device_noti/po_sys_device_noti/ca.po b/sys_device_noti/po_sys_device_noti/ca.po
deleted file mode 100755 (executable)
index 61d8398..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Bateria completament carregada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desendollar carregador"
-
diff --git a/sys_device_noti/po_sys_device_noti/cs.po b/sys_device_noti/po_sys_device_noti/cs.po
deleted file mode 100755 (executable)
index e9f137c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterie je plně nabitá"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Odpojte nabíječku"
-
diff --git a/sys_device_noti/po_sys_device_noti/da.po b/sys_device_noti/po_sys_device_noti/da.po
deleted file mode 100755 (executable)
index b290706..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batteri fuldt opladet"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Fjern oplader"
-
diff --git a/sys_device_noti/po_sys_device_noti/de_DE.po b/sys_device_noti/po_sys_device_noti/de_DE.po
deleted file mode 100755 (executable)
index ad85846..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Akku vollständig geladen"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Ladegerät entfernen"
-
diff --git a/sys_device_noti/po_sys_device_noti/el_GR.po b/sys_device_noti/po_sys_device_noti/el_GR.po
deleted file mode 100755 (executable)
index 996e1da..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Μπαταρία πλήρως φορτισμένη"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Αποσύνδεση φορτιστή"
-
diff --git a/sys_device_noti/po_sys_device_noti/en.po b/sys_device_noti/po_sys_device_noti/en.po
deleted file mode 100755 (executable)
index d1c5e7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Battery fully charged"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Unplug charger"
-
diff --git a/sys_device_noti/po_sys_device_noti/en_PH.po b/sys_device_noti/po_sys_device_noti/en_PH.po
deleted file mode 100755 (executable)
index d1c5e7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Battery fully charged"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Unplug charger"
-
diff --git a/sys_device_noti/po_sys_device_noti/en_US.po b/sys_device_noti/po_sys_device_noti/en_US.po
deleted file mode 100755 (executable)
index d1c5e7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Battery fully charged"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Unplug charger"
-
diff --git a/sys_device_noti/po_sys_device_noti/es_ES.po b/sys_device_noti/po_sys_device_noti/es_ES.po
deleted file mode 100755 (executable)
index fe563d5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batería totalmente cargada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desconectar cargador"
-
diff --git a/sys_device_noti/po_sys_device_noti/es_US.po b/sys_device_noti/po_sys_device_noti/es_US.po
deleted file mode 100755 (executable)
index b99a618..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batería completamente cargada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desconectar el cargador"
-
diff --git a/sys_device_noti/po_sys_device_noti/et.po b/sys_device_noti/po_sys_device_noti/et.po
deleted file mode 100755 (executable)
index 33a53bc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Aku on laetud"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Eraldage laadija"
-
diff --git a/sys_device_noti/po_sys_device_noti/eu.po b/sys_device_noti/po_sys_device_noti/eu.po
deleted file mode 100755 (executable)
index 17a2621..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Bateria guztiz kargatuta"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desentxufatu kargadorea"
-
diff --git a/sys_device_noti/po_sys_device_noti/fi.po b/sys_device_noti/po_sys_device_noti/fi.po
deleted file mode 100755 (executable)
index 247d9e7..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Akku on täysin ladattu"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Irrota laturi"
-
diff --git a/sys_device_noti/po_sys_device_noti/fr_CA.po b/sys_device_noti/po_sys_device_noti/fr_CA.po
deleted file mode 100755 (executable)
index 9004f3e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "La pile est chargée"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Débrancher le chargeur"
-
diff --git a/sys_device_noti/po_sys_device_noti/fr_FR.po b/sys_device_noti/po_sys_device_noti/fr_FR.po
deleted file mode 100755 (executable)
index 8f166dd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batterie chargée"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Débrancher le chargeur"
-
diff --git a/sys_device_noti/po_sys_device_noti/ga.po b/sys_device_noti/po_sys_device_noti/ga.po
deleted file mode 100755 (executable)
index a984b80..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Ceallra lánluchtaithe"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Díphlugáil an luchtaire"
-
diff --git a/sys_device_noti/po_sys_device_noti/gl.po b/sys_device_noti/po_sys_device_noti/gl.po
deleted file mode 100755 (executable)
index cd9e232..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batería totalmente cargada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desenchufar cargador"
-
diff --git a/sys_device_noti/po_sys_device_noti/hi.po b/sys_device_noti/po_sys_device_noti/hi.po
deleted file mode 100755 (executable)
index fcde0c3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "बैटरी पूरी चार्ज है।"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "चार्जर निकालें"
-
diff --git a/sys_device_noti/po_sys_device_noti/hr.po b/sys_device_noti/po_sys_device_noti/hr.po
deleted file mode 100755 (executable)
index 96d0bb3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterija puna"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Iskopčajte punjač"
-
diff --git a/sys_device_noti/po_sys_device_noti/hu.po b/sys_device_noti/po_sys_device_noti/hu.po
deleted file mode 100755 (executable)
index a4e8646..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-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"
-
diff --git a/sys_device_noti/po_sys_device_noti/hy.po b/sys_device_noti/po_sys_device_noti/hy.po
deleted file mode 100755 (executable)
index 9a30dde..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Մարտկոցը ամբողջովին լիցքավորված է"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Վարդակից անջատել լիցքավորիչը"
-
diff --git a/sys_device_noti/po_sys_device_noti/is.po b/sys_device_noti/po_sys_device_noti/is.po
deleted file mode 100755 (executable)
index 0d29520..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Rafhlaða fullhlaðin"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Aftengja hleðslutæki"
-
diff --git a/sys_device_noti/po_sys_device_noti/it_IT.po b/sys_device_noti/po_sys_device_noti/it_IT.po
deleted file mode 100755 (executable)
index 3094490..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batteria ricaricata"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Scollega caricabatterie"
-
diff --git a/sys_device_noti/po_sys_device_noti/ja_JP.po b/sys_device_noti/po_sys_device_noti/ja_JP.po
deleted file mode 100755 (executable)
index 8c6a6ee..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "バッテリ​充電​完了"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "充電​器​を​取り​外し​て​ください。"
-
diff --git a/sys_device_noti/po_sys_device_noti/ka.po b/sys_device_noti/po_sys_device_noti/ka.po
deleted file mode 100755 (executable)
index 9bbd215..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "კვების ელემენტი დაიტენა"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "გამორთეთ დამტენი"
-
diff --git a/sys_device_noti/po_sys_device_noti/kk.po b/sys_device_noti/po_sys_device_noti/kk.po
deleted file mode 100755 (executable)
index bd53198..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Батарея толық зарядталған"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Зарядтағышты ажырату"
-
diff --git a/sys_device_noti/po_sys_device_noti/ko_KR.po b/sys_device_noti/po_sys_device_noti/ko_KR.po
deleted file mode 100755 (executable)
index 571b80a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "배터리가 충전되었습니다"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "충전기 분리"
-
diff --git a/sys_device_noti/po_sys_device_noti/lt.po b/sys_device_noti/po_sys_device_noti/lt.po
deleted file mode 100755 (executable)
index d1658d1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterija visiškai įkrauta"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Atjunkite kroviklį"
-
diff --git a/sys_device_noti/po_sys_device_noti/lv.po b/sys_device_noti/po_sys_device_noti/lv.po
deleted file mode 100755 (executable)
index 432e6dd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Akumulators uzlādēts"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Atvienojiet lādētāju"
-
diff --git a/sys_device_noti/po_sys_device_noti/mk.po b/sys_device_noti/po_sys_device_noti/mk.po
deleted file mode 100755 (executable)
index 5df479c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Батеријата е наполнета"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Откачете го полначот"
-
diff --git a/sys_device_noti/po_sys_device_noti/nb.po b/sys_device_noti/po_sys_device_noti/nb.po
deleted file mode 100755 (executable)
index dec39c0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batteri fulladet"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Ta ut laderen"
-
diff --git a/sys_device_noti/po_sys_device_noti/nl_NL.po b/sys_device_noti/po_sys_device_noti/nl_NL.po
deleted file mode 100755 (executable)
index 4fe8d28..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "De batterij is opgeladen"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Oplader loskoppelen"
-
diff --git a/sys_device_noti/po_sys_device_noti/pl.po b/sys_device_noti/po_sys_device_noti/pl.po
deleted file mode 100755 (executable)
index 08e174a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Bateria w pełni naładowana"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Odłącz ładowarkę"
-
diff --git a/sys_device_noti/po_sys_device_noti/pt_BR.po b/sys_device_noti/po_sys_device_noti/pt_BR.po
deleted file mode 100755 (executable)
index 2f0d9bc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Bateria completamente carregada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desconectar carregador"
-
diff --git a/sys_device_noti/po_sys_device_noti/pt_PT.po b/sys_device_noti/po_sys_device_noti/pt_PT.po
deleted file mode 100755 (executable)
index 119ec91..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Bateria completamente carregada"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Desligue o carregador"
-
diff --git a/sys_device_noti/po_sys_device_noti/ro.po b/sys_device_noti/po_sys_device_noti/ro.po
deleted file mode 100755 (executable)
index 3f6a7b9..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterie încărcată complet"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Deconectaţi încărcătorul"
-
diff --git a/sys_device_noti/po_sys_device_noti/ru_RU.po b/sys_device_noti/po_sys_device_noti/ru_RU.po
deleted file mode 100755 (executable)
index b26c1ee..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Аккумулятор заряжен"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Отключите зарядное устройство"
-
diff --git a/sys_device_noti/po_sys_device_noti/sk.po b/sys_device_noti/po_sys_device_noti/sk.po
deleted file mode 100755 (executable)
index 489fdc7..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batéria je plne nabitá"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Odpojte nabíjačku"
-
diff --git a/sys_device_noti/po_sys_device_noti/sl.po b/sys_device_noti/po_sys_device_noti/sl.po
deleted file mode 100755 (executable)
index a8fa525..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterija je polna"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Izklopite napajalnik"
-
diff --git a/sys_device_noti/po_sys_device_noti/sr.po b/sys_device_noti/po_sys_device_noti/sr.po
deleted file mode 100755 (executable)
index 59c217b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Baterija skroz napunjena"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Otkači punjač"
-
diff --git a/sys_device_noti/po_sys_device_noti/sv.po b/sys_device_noti/po_sys_device_noti/sv.po
deleted file mode 100755 (executable)
index d4ecc45..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batteriet fulladdat"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Ta ut laddaren"
-
diff --git a/sys_device_noti/po_sys_device_noti/tr_TR.po b/sys_device_noti/po_sys_device_noti/tr_TR.po
deleted file mode 100755 (executable)
index d1fe727..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-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"
-
diff --git a/sys_device_noti/po_sys_device_noti/uk.po b/sys_device_noti/po_sys_device_noti/uk.po
deleted file mode 100755 (executable)
index 1548d19..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Батарею заряджено повністю"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Відключіть зарядний пристрій"
-
diff --git a/sys_device_noti/po_sys_device_noti/uz.po b/sys_device_noti/po_sys_device_noti/uz.po
deleted file mode 100755 (executable)
index 084b6d3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "Batareya to‘la zaryadlandi"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "Zaryadlash qurilmasini chiqaring"
-
diff --git a/sys_device_noti/po_sys_device_noti/zh_CN.po b/sys_device_noti/po_sys_device_noti/zh_CN.po
deleted file mode 100755 (executable)
index 4a7a468..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "电池已满"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "拔下充电器"
-
diff --git a/sys_device_noti/po_sys_device_noti/zh_HK.po b/sys_device_noti/po_sys_device_noti/zh_HK.po
deleted file mode 100755 (executable)
index 8ec1bbd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "電池已完全充電"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "拔除充電器"
-
diff --git a/sys_device_noti/po_sys_device_noti/zh_SG.po b/sys_device_noti/po_sys_device_noti/zh_SG.po
deleted file mode 100755 (executable)
index d5a0fdc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "充电完毕"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "拔下充电器"
-
diff --git a/sys_device_noti/po_sys_device_noti/zh_TW.po b/sys_device_noti/po_sys_device_noti/zh_TW.po
deleted file mode 100755 (executable)
index 49325b9..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
-msgstr "電池已完全充電"
-
-msgid "IDS_QP_BODY_UNPLUG_CHARGER"
-msgstr "斷開充電器"
-
diff --git a/sys_device_noti/sys_device_noti.c b/sys_device_noti/sys_device_noti.c
deleted file mode 100755 (executable)
index 4a356b0..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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;
-}
diff --git a/sys_device_noti/sys_device_noti.h b/sys_device_noti/sys_device_noti.h
deleted file mode 100755 (executable)
index 807c738..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*\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
diff --git a/sys_pci_noti/po_sys_pci_noti/es_US.po b/sys_pci_noti/po_sys_pci_noti/es_US.po
new file mode 100755 (executable)
index 0000000..cc8dfc7
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"
+msgstr "Teclado conectado"
+
+msgid "IDS_COM_POP_KEYBOARD_DISCONNECTED_ABB2"
+msgstr "Teclado desconectado"
+
index 7f3b279..919b82d 100755 (executable)
@@ -80,4 +80,4 @@ int main(int argc, char *argv[])
        }
 
        return 0;
-}
+}
\ No newline at end of file
similarity index 82%
rename from packaging/system-server.service
rename to systemd/system-server.service
index 4ce8d4a..01cf784 100644 (file)
@@ -4,9 +4,11 @@ After=vconf-setup.service
 
 [Service]
 # set DISPLAY for usb_setting launching
+Type=notify
 Environment=DISPLAY=:0
 ExecStart=/usr/bin/system_server
-TimeoutSec=2
+TimeoutStopSec=2
+NotifyAccess=all
 
 [Install]
 WantedBy=multi-user.target
diff --git a/systemd/system-server.socket b/systemd/system-server.socket
new file mode 100644 (file)
index 0000000..aa36429
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=System server socket
+
+[Socket]
+ListenStream=/tmp/sn
+SocketMode=0777
+PassCredentials=yes
+SmackLabelIPIn=*
+SmackLabelIPOut=@
+Accept=false
index b3ddb85..1c1d528 100644 (file)
@@ -6,14 +6,7 @@ ACTION=="remove", KERNEL=="mmcblk[0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/
 #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"
@@ -28,7 +21,9 @@ ACTION=="remove",     KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block",     RUN+="@PREFIX@/bin
 
 #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"
+ACTION=="change"       DEVPATH=="/devices/platform/charger-manager.0"                          RUN+="@PREFIX@/bin/sys_event device_charge_chgdet"
+ACTION=="change"       DEVPATH=="/devices/virtual/power_supply/battery"                        RUN+="/usr/bin/sys_event device_charge_chgdet"
+ACTION=="change"       DEVPATH=="/devices/platform/sec-battery/power_supply/battery"           RUN+="/usr/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"