libtzplatform-config
libcap
dbus-1
+ iniparser
)
FOREACH(flag ${${this_target_pool}_CFLAGS})
src/debugger_info.c
src/launchpad_debug.c
src/launchpad_signal.c
+ src/launchpad_config.c
)
ADD_EXECUTABLE(${LAUNCHPAD_PROCESS_POOL} ${${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES})
CONFIGURE_FILE(packaging/default.loader.in packaging/default.loader @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/default.loader DESTINATION share/aul)
+CONFIGURE_FILE(conf/launchpad.conf.in conf/launchpad.conf @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/launchpad.conf DESTINATION share/aul)
+
# liblaunchpad
SET(LAUNCHPAD_LIB "launchpad")
ADD_LIBRARY(${LAUNCHPAD_LIB} SHARED
--- /dev/null
+[MemoryStatus]
+LowKey=memory/sysman/low_memory
+LowValue=2
+NormalKey=memory/sysman/low_memory
+NormalValue=1
--- /dev/null
+/*
+ * 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 __LAUNCHPAD_CONFIG_H__
+#define __LAUNCHPAD_CONFIG_H__
+
+typedef enum {
+ CONFIG_TYPE_MEMORY_STATUS_LOW_KEY,
+ CONFIG_TYPE_MEMORY_STATUS_LOW_VALUE,
+ CONFIG_TYPE_MEMORY_STATUS_NORMAL_KEY,
+ CONFIG_TYPE_MEMORY_STATUS_NORMAL_VALUE,
+} config_type_e;
+
+const char *_config_get_string_value(config_type_e type);
+
+int _config_get_int_value(config_type_e type);
+
+int _config_init(void);
+
+void _config_fini(void);
+
+#endif /* __LAUNCHPAD_CONFIG_H__ */
BuildRequires: pkgconfig(libcap)
BuildRequires: pkgconfig(tanchor)
BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(iniparser)
Requires(post): /sbin/ldconfig
Requires(post): /usr/bin/systemctl
%{_unitdir}/user-sockets@.target.wants/launchpad-process-pool@.socket
%{_unitdir}/user-basic@.target.wants/launchpad-process-pool@.service
%{_bindir}/launchpad-process-pool
+%{_prefix}/share/aul/launchpad.conf
%files devel
%{_includedir}/launchpad/*.h
#include "loader_info.h"
#include "launcher_info.h"
#include "launchpad_debug.h"
+#include "launchpad_config.h"
#define AUL_PR_NAME 16
#define EXEC_CANDIDATE_EXPIRED 5
static app_labels_monitor *label_monitor;
static GList *launcher_info_list;
static GHashTable *__pid_table;
-static int __memory_status;
+static int __memory_status_low;
+static int __memory_status_normal;
static sequencer __sequencer;
+static int MEMORY_STATUS_LOW;
+static int MEMORY_STATUS_NORMAL;
static candidate_process_context_t *__add_slot(int type, int loader_id,
int caller_pid, const char *loader_path, const char *extra,
static bool __is_low_memory(void)
{
- if (__memory_status >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING)
+ if (__memory_status_low >= MEMORY_STATUS_LOW)
return true;
return false;
}
setenv("LANG", lang, 1);
}
-static void __memory_status_changed_cb(keynode_t *node, void *data)
+static void __memory_status_low_changed_cb(keynode_t *node, void *data)
{
candidate_process_context_t *cpc;
- GList *iter = candidate_slot_list;
+ GList *iter;
- __memory_status = vconf_keynode_get_int(node);
- if (__memory_status >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) {
+ __memory_status_low = vconf_keynode_get_int(node);
+ if (__memory_status_low >= MEMORY_STATUS_LOW) {
_W("Low memory");
+ iter = candidate_slot_list;
while (iter) {
cpc = (candidate_process_context_t *)iter->data;
__update_slot_state(cpc, METHOD_OUT_OF_MEMORY);
iter = g_list_next(iter);
}
- } else {
+ }
+}
+
+static void __memory_status_normal_changed_cb(keynode_t *node, void *data)
+{
+ candidate_process_context_t *cpc;
+ GList *iter;
+
+ __memory_status_normal = vconf_keynode_get_int(node);
+ if (__memory_status_normal == MEMORY_STATUS_NORMAL) {
_W("Normal");
+ iter = candidate_slot_list;
while (iter) {
cpc = (candidate_process_context_t *)iter->data;
__update_slot_state(cpc, METHOD_AVAILABLE_MEMORY);
static void __unregister_vconf_events(void)
{
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY,
- __memory_status_changed_cb);
+ const char *key;
+ config_type_e type;
+
+ type = CONFIG_TYPE_MEMORY_STATUS_NORMAL_KEY;
+ key = _config_get_string_value(type);
+ vconf_ignore_key_changed(key, __memory_status_normal_changed_cb);
+
+ type = CONFIG_TYPE_MEMORY_STATUS_LOW_KEY;
+ key = _config_get_string_value(type);
+ vconf_ignore_key_changed(key, __memory_status_low_changed_cb);
+
vconf_ignore_key_changed(VCONFKEY_LANGSET,
__update_lang);
vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
{
int r;
char *lang;
+ const char *key;
+ config_type_e type;
r = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &__sys_hwacc);
if (r != VCONF_OK)
if (r != VCONF_OK)
_E("Failed to register callback for langset. err = %d", r);
- r = vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &__memory_status);
+ type = CONFIG_TYPE_MEMORY_STATUS_LOW_KEY;
+ key = _config_get_string_value(type);
+ type = CONFIG_TYPE_MEMORY_STATUS_LOW_VALUE;
+ MEMORY_STATUS_LOW = _config_get_int_value(type);
+
+ r = vconf_get_int(key, &__memory_status_low);
if (r != VCONF_OK)
_E("Failed to get vconf low memory. err = %d", r);
- r = vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY,
- __memory_status_changed_cb, NULL);
+ r = vconf_notify_key_changed(key,
+ __memory_status_low_changed_cb, NULL);
if (r != 0)
_E("Failed to register callback for low memory. err = %d", r);
+ type = CONFIG_TYPE_MEMORY_STATUS_NORMAL_KEY;
+ key = _config_get_string_value(type);
+ type = CONFIG_TYPE_MEMORY_STATUS_NORMAL_VALUE;
+ MEMORY_STATUS_NORMAL = _config_get_int_value(type);
+
+ r = vconf_get_int(key, &__memory_status_normal);
+ if (r != VCONF_OK)
+ _E("Failed to get vconf normal memory. err = %d", r);
+
+ r = vconf_notify_key_changed(key,
+ __memory_status_normal_changed_cb, NULL);
+ if (r != 0)
+ _E("Failed to register callback for normal memory. err = %d", r);
+
return 0;
}
if (ret != 0)
_W("Failed to initialize label monitor");
+ ret = _config_init();
+ if (ret != 0)
+ _W("Failed to initialize config");
+
__add_default_slots();
launcher_info_list = _launcher_info_load(LAUNCHER_INFO_PATH);
_debug_fini();
_launcher_info_unload(launcher_info_list);
+ _config_fini();
if (label_monitor)
security_manager_app_labels_monitor_finish(label_monitor);
--- /dev/null
+/*
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <iniparser.h>
+#include <vconf.h>
+
+#include "launchpad_common.h"
+#include "launchpad_config.h"
+
+#define PATH_LAUNCHPAD_CONF "/usr/share/aul/launchpad.conf"
+#define TAG_MEMORY_STATUS "MemoryStatus"
+#define KEY_MEMORY_STATUS_LOW_KEY "LowKey"
+#define KEY_MEMORY_STATUS_LOW_VALUE "LowValue"
+#define KEY_MEMORY_STATUS_NORMAL_KEY "NormalKey"
+#define KEY_MEMORY_STATUS_NORMAL_VALUE "NormalValue"
+
+struct memory_status_s {
+ char *low_key;
+ int low_value;
+ char *normal_key;
+ int normal_value;
+};
+
+static struct memory_status_s __memory_status;
+
+const char *_config_get_string_value(config_type_e type)
+{
+ const char *value;
+
+ switch (type) {
+ case CONFIG_TYPE_MEMORY_STATUS_LOW_KEY:
+ value = __memory_status.low_key;
+ break;
+ case CONFIG_TYPE_MEMORY_STATUS_NORMAL_KEY:
+ value = __memory_status.normal_key;
+ break;
+ default:
+ _E("Unknown type");
+ value = NULL;
+ break;
+ }
+
+ return value;
+}
+
+int _config_get_int_value(config_type_e type)
+{
+ int value;
+
+ switch (type) {
+ case CONFIG_TYPE_MEMORY_STATUS_LOW_VALUE:
+ value = __memory_status.low_value;
+ break;
+ case CONFIG_TYPE_MEMORY_STATUS_NORMAL_VALUE:
+ value = __memory_status.normal_value;
+ break;
+ default:
+ _E("Unknown type");
+ value = INT_MIN;
+ }
+
+ return value;
+}
+
+static char *__get_string_value(dictionary *d, const char *tag,
+ const char *key)
+{
+ char buf[128];
+
+ snprintf(buf, sizeof(buf), "%s:%s", tag, key);
+ return iniparser_getstring(d, buf, NULL);
+}
+
+static int __get_int_value(dictionary *d, const char *tag,
+ const char *key)
+{
+ char buf[128];
+
+ snprintf(buf, sizeof(buf), "%s:%s", tag, key);
+ return iniparser_getint(d, buf, INT_MIN);
+}
+
+int _config_init(void)
+{
+ dictionary *d;
+ char *val;
+ char *str;
+ int ret;
+
+ _D("config init");
+
+ __memory_status.low_key = strdup(VCONFKEY_SYSMAN_LOW_MEMORY);
+ __memory_status.low_value = VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING;
+ __memory_status.normal_key = strdup(VCONFKEY_SYSMAN_LOW_MEMORY);
+ __memory_status.normal_value = VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL;
+
+ ret = access(PATH_LAUNCHPAD_CONF, F_OK);
+ if (ret != 0) {
+ _W("The file doesn't exist. errno(%d)", errno);
+ return 0;
+ }
+
+ d = iniparser_load(PATH_LAUNCHPAD_CONF);
+ if (!d) {
+ _E("Failed to load the config file");
+ return -1;
+ }
+
+ str = __get_string_value(d, TAG_MEMORY_STATUS,
+ KEY_MEMORY_STATUS_LOW_KEY);
+ if (str) {
+ val = strdup(str);
+ if (val) {
+ free(__memory_status.low_key);
+ __memory_status.low_key = val;
+ }
+ }
+
+ ret = __get_int_value(d, TAG_MEMORY_STATUS,
+ KEY_MEMORY_STATUS_LOW_VALUE);
+ if (ret != INT_MIN)
+ __memory_status.low_value = ret;
+
+ str = __get_string_value(d, TAG_MEMORY_STATUS,
+ KEY_MEMORY_STATUS_NORMAL_KEY);
+ if (str) {
+ val = strdup(str);
+ if (val) {
+ free(__memory_status.normal_key);
+ __memory_status.normal_key = val;
+ }
+ }
+
+ ret = __get_int_value(d, TAG_MEMORY_STATUS,
+ KEY_MEMORY_STATUS_NORMAL_VALUE);
+ if (ret != INT_MIN)
+ __memory_status.normal_value = ret;
+
+ _W("Memory Status Low(%s:%d), Normal(%s:%d)",
+ __memory_status.low_key,
+ __memory_status.low_value,
+ __memory_status.normal_key,
+ __memory_status.normal_value);
+
+ iniparser_freedict(d);
+
+ return 0;
+}
+
+void _config_fini(void)
+{
+ _D("config fini");
+
+ free(__memory_status.normal_key);
+ free(__memory_status.low_key);
+}