plugins: Separate freezer module 33/216233/10
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 22 Oct 2019 10:00:50 +0000 (12:00 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 13 Nov 2019 15:39:16 +0000 (16:39 +0100)
Change-Id: Id5a60a03a93064a8e8666cef682214e750baca50

packaging/resourced.spec
src/CMakeLists.txt
src/common/freezer-common.c [moved from src/freezer/freezer-common.c with 70% similarity]
src/common/freezer-common.h [new file with mode: 0644]
src/freezer/freezer.c
src/freezer/include/freezer.h
src/proc-stat/proc-main.c

index 29de6cd..3d931db 100644 (file)
@@ -33,7 +33,6 @@ Source0:    %{name}-%{version}.tar.gz
 
 # Defines for resourced.common variant - see build section for defines for
 # light variant.
-%define freezer_module         ON
 %define heart_module           ON
 %define swap_module            ON
 
@@ -130,7 +129,6 @@ pushd build_common
 %cmake .. -DFULLVER=%{version} \
         -DCMAKE_BUILD_TYPE=Release \
         -DCPU_MODULE=%{cpu_module} \
-        -DFREEZER_MODULE=%{freezer_module} \
         -DHEART_MODULE=%{heart_module} \
         -DMEMORY_MODULE=%{memory_module} \
         -DMEM_STRESS=%{mem_stress} \
@@ -154,7 +152,6 @@ pushd build_light
 
 %cmake .. -DFULLVER=%{version} \
         -DCMAKE_BUILD_TYPE=Release \
-        -DFREEZER_MODULE=OFF \
         -DHEART_MODULE=OFF \
         -DSWAP_MODULE=OFF \
         -DCPU_MODULE=%{cpu_module} \
@@ -251,6 +248,7 @@ fi
 %manifest resourced.manifest
 %ghost %{_bindir}/resourced
 %{plugindir}/libblock.so
+%{plugindir}/libfreezer.so
 %{_libdir}/*.so.*
 %attr(-,root, root) %{_bindir}/resourced.common
 %if %{?heart_module} == ON
index 6acf7c0..1fcc9e8 100644 (file)
@@ -44,13 +44,6 @@ SET(RESOURCED_SHARED_SOURCES ${RESOURCED_SHARED_SOURCES}
   ${PROC-STAT_SOURCE_DIR}/proc-watchdog.c
 )
 
-#freezer module
-IF("${FREEZER_MODULE}" STREQUAL "ON")
-   SET(SOURCES ${SOURCES} ${FREEZER_SOURCE_DIR}/freezer.c)
-   ADD_DEFINITIONS("-DSYSTEM_LIB_PATH=\"${LIB_INSTALL_DIR}\"")
-ELSE()
-   SET(SOURCES ${SOURCES} ${FREEZER_SOURCE_DIR}/freezer-common.c)
-ENDIF()
 
 IF("${VIP_AGENT}" STREQUAL "ON")
   SET(SOURCES ${SOURCES}
@@ -142,6 +135,11 @@ TARGET_LINK_LIBRARIES(block resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLA
 INSTALL(TARGETS block DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
 INSTALL(FILES ${BLOCK_SOURCE_DIR}/block.conf DESTINATION ${RD_CONFIG_PATH})
 
+ADD_DEFINITIONS("-DFREEZER_DIR=\"${LIB_INSTALL_DIR}\"")
+ADD_LIBRARY(freezer MODULE ${FREEZER_SOURCE_DIR}/freezer.c)
+TARGET_LINK_LIBRARIES(freezer resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
+INSTALL(TARGETS freezer DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
+
 ADD_EXECUTABLE(${RD_BINARY_NAME}
   ${RESOURCED_SOURCE_DIR}/init.c
   ${RESOURCED_SOURCE_DIR}/main.c
similarity index 70%
rename from src/freezer/freezer-common.c
rename to src/common/freezer-common.c
index b7c15cf..43b6f92 100644 (file)
 
 #include "trace.h"
 
+/* Freezer cgroup late control setting retrieval */
+int (*resourced_freezer_get_proc_late_control)(void) = NULL;
+
+/* freezer_proc_get_late_control function defined for freezer module on case */
 int resourced_freezer_proc_late_control(void)
 {
-       _E("Using dummy definition of freezer_proc_get_late_control");
+       if (resourced_freezer_get_proc_late_control)
+               return resourced_freezer_get_proc_late_control();
+
+       _E("Using dummy definition of freezer_proc_get_late_control - freezer not loaded");
        return FREEZER_LATE_CONTROL_DISABLED;
 }
-
diff --git a/src/common/freezer-common.h b/src/common/freezer-common.h
new file mode 100644 (file)
index 0000000..1fcbd73
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __FREEZER_COMMON_H__
+#define __FREEZER_COMMON_H__
+
+extern int (*resourced_freezer_get_proc_late_control)(void);
+
+/* Freezer cgroup late control setting retrieval */
+int resourced_freezer_proc_late_control(void);
+
+#endif /* __FREEZER_COMMON_H__ */
+
index c55a1e2..f55b96e 100644 (file)
 #include "proc-main.h"
 #include "freezer.h"
 
-#define FREEZER_MODULE_PATH SYSTEM_LIB_PATH"/libsystem-freezer.so.0"
+#define FREEZER_MODULE_PATH FREEZER_DIR"/libsystem-freezer.so.0"
 
 static int freezer_init_check;
 
 /******************************************** Freezer symbols *************************************************/
-/* Freezer cgroup late control setting retrieval */
-static int (*resourced_freezer_get_proc_late_control)(void) = NULL;
 
 /* Freezer suspend status retrieval */
 static bool (*resourced_freezer_is_suspended)(void) = NULL;
@@ -80,16 +78,6 @@ static int (*resourced_freezer_power_off)(void *data) = NULL;
 static void *dlopen_handle;
 /****************************************** Freezer symbols end ***********************************************/
 
-/* freezer_proc_get_late_control function defined for freezer module on case */
-int resourced_freezer_proc_late_control(void)
-{
-       if (resourced_freezer_get_proc_late_control)
-               return resourced_freezer_get_proc_late_control();
-
-       _E("freezer_get_proc_late_control is not loaded!");
-       return 0;
-}
-
 /****************************************** Internal symbols **************************************************/
 static void resourced_freezer_dbus_method_handler_generic(
                GDBusMethodInvocation *invocation, GVariant *params)
index f3d0b3e..7ca2b2b 100644 (file)
@@ -27,6 +27,7 @@
 #define __FREEZER_H__
 
 #include <glib.h>
+#include "freezer-common.h"
 
 /* Freezer dbus signal names */
 #define SIGNAL_FREEZER_STATE            "FreezerState"
@@ -67,8 +68,5 @@ struct freezer_init_data {
        GSList **resourced_app_list;
 };
 
-/* Freezer cgroup late control setting retrieval */
-int resourced_freezer_proc_late_control(void);
-
 #endif /* __FREEZER_H__ */
 
index eba70de..b384e8d 100644 (file)
@@ -47,6 +47,7 @@
 #include "appinfo-list.h"
 #include "util.h"
 #include "file-helper.h"
+#include "freezer-common.h"
 #include "config-parser.h"
 
 #ifndef gettid