)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/power.conf DESTINATION /etc/deviced/device)
+
IF(UNIX)
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
%manifest %{name}.manifest
%license LICENSE.APLv2
%{_libdir}/libcapi-system-device.so.*
+/etc/deviced/device/*.conf
%files devel
%manifest %{name}.manifest
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <string.h>
+#include <errno.h>
+#include "common.h"
+
+#define MAX_LINE 128
+#define MAX_SECTION 64
+#define WHITESPACE " \t"
+#define NEWLINE "\n\r"
+#define COMMENT '#'
+
+static inline char *trim_str(char *s)
+{
+ char *t;
+ /* left trim */
+ s += strspn(s, WHITESPACE);
+
+ /* right trim */
+ for (t = strchr(s, 0); t > s; t--)
+ if (!strchr(WHITESPACE, t[-1]))
+ break;
+ *t = 0;
+ return s;
+}
+
+int config_parse(const char *file_name, int cb(struct parse_result *result,
+ void *user_data), void *user_data)
+{
+ FILE *f = NULL;
+ struct parse_result result;
+ /* use stack for parsing */
+ char line[MAX_LINE];
+ char section[MAX_SECTION];
+ char *start, *end, *name, *value;
+ int lineno = 0, ret = 0;
+
+ if (!file_name || !cb) {
+ ret = -EINVAL;
+ goto error;
+ }
+
+ /* open conf file */
+ f = fopen(file_name, "r");
+ if (!f) {
+ if (errno == ENOENT) {
+ _I("There is no power config file");
+ return 0;
+ }
+
+ _E("Failed to open file %s", file_name);
+ ret = -EIO;
+ goto error;
+ }
+
+ /* parsing line by line */
+ while (fgets(line, MAX_LINE, f) != NULL) {
+ lineno++;
+
+ start = line;
+ start[strcspn(start, NEWLINE)] = '\0';
+ start = trim_str(start);
+
+ if (*start == COMMENT) {
+ continue;
+ } else if (*start == '[') {
+ /* parse section */
+ end = strchr(start, ']');
+ if (!end || *end != ']') {
+ ret = -EBADMSG;
+ goto error;
+ }
+
+ *end = '\0';
+ strncpy(section, start + 1, sizeof(section));
+ section[MAX_SECTION-1] = '\0';
+ } else if (*start) {
+ /* parse name & value */
+ end = strchr(start, '=');
+ if (!end || *end != '=') {
+ ret = -EBADMSG;
+ goto error;
+ }
+ *end = '\0';
+ name = trim_str(start);
+ value = trim_str(end + 1);
+ end = strchr(value, COMMENT);
+ if (end && *end == COMMENT) {
+ *end = '\0';
+ value = trim_str(value);
+ }
+
+ result.section = section;
+ result.name = name;
+ result.value = value;
+ /* callback with parse result */
+ ret = cb(&result, user_data);
+ if (ret < 0) {
+ ret = -EBADMSG;
+ goto error;
+ }
+ }
+ }
+ _D("Success to load %s", file_name);
+ fclose(f);
+ return 0;
+
+error:
+ if (f)
+ fclose(f);
+ _E("Failed to read %s:%d!", file_name, lineno);
+ return ret;
+}
}
}
+struct parse_result {
+ char *section;
+ char *name;
+ char *value;
+};
+
+int config_parse(const char *file_name,
+ int cb(struct parse_result *result, void *data),
+ void *user_data);
+
#endif /* __COMMON_H__ */
#define STR_LCD_DIM "lcddim"
#define STR_LCD_ON "lcdon"
-#define LOCK_CPU_TIMEOUT_MAX (60*60*1000) /* milliseconds */
+#define LOCK_CPU_TIMEOUT_MAX (24*60*60*1000) /* milliseconds */
#define LOCK_CPU_PADDING_TIMEOUT (20*1000) /* milliseconds */
+#define POWER_CONF "/etc/deviced/device/power.conf"
+
#ifdef TIZEN_FEATURE_TRACKER
static guint off_lock_timeout;
static guint padding_timeout;
static int prev_count;
#endif
+static struct _lock_timeout {
+ unsigned int release;
+ unsigned int padding;
+} lock_timeout = {
+ .release = LOCK_CPU_TIMEOUT_MAX,
+ .padding = LOCK_CPU_PADDING_TIMEOUT,
+};
+
static char *get_state_str(display_state_e state)
{
switch (state) {
_I("Padding timeout handler added");
- id = g_timeout_add(LOCK_CPU_PADDING_TIMEOUT,
+ id = g_timeout_add(lock_timeout.padding,
padding_timeout_expired, NULL);
if (id)
padding_timeout = id;
_I("Power lock timeout handler added");
- id = g_timeout_add(LOCK_CPU_TIMEOUT_MAX,
+ id = g_timeout_add(lock_timeout.release,
off_lock_timeout_expired, NULL);
if (id)
off_lock_timeout = id;
if (type == POWER_LOCK_CPU) {
ret = lock_state(DISPLAY_STATE_SCREEN_OFF, STAY_CUR_STATE, timeout_ms);
if (ret == 0 &&
- (timeout_ms == 0 || timeout_ms > LOCK_CPU_TIMEOUT_MAX))
+ (timeout_ms == 0 || timeout_ms > lock_timeout.release))
add_off_lock_timeout();
} else if (type == POWER_LOCK_DISPLAY) {
_W("DEPRECATION WARNING: This power lock enum is deprecated and will be removed from next release. Use efl_util_set_window_screen_mode() instead.");
return errno_to_device_error(ret);
}
//LCOV_EXCL_STOP
+
+static int power_load_config(struct parse_result *result, void *data)
+{
+ unsigned int value;
+
+ if (!result)
+ return 0;
+
+ if (strncmp(result->section, "Power", 6))
+ return 0;
+
+ value = strtoul(result->value, NULL, 10);
+ if (value == 0)
+ return 0;
+
+ if (!strncmp(result->name, "LockTimeout", 12)) {
+ _I("Power Lock Auto Release Timeout: %ld msec", value);
+ lock_timeout.release = value;
+ } else if (!strncmp(result->name, "LockPaddingTimeout", 12)) {
+ _I("Power Lock Auto Release Padding Timeout: %ld msec", value);
+ lock_timeout.padding = value;
+ }
+
+ return 0;
+}
+
+static void __CONSTRUCTOR__ power_init(void)
+{
+ int ret;
+
+ ret = config_parse(POWER_CONF, power_load_config, NULL);
+ if (ret < 0)
+ _E("Failed to load config file (%d)", ret);
+}
--- /dev/null
+[Power]
+# milliseconds
+LockTimeout=86400000
+# milliseconds
+LockPaddingTimeout=20000