From 4abcf784aa979eb569c8f432df484bca0c80d5e1 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 13 Feb 2020 17:36:57 +0900 Subject: [PATCH 01/16] Fix coverity issue CID 1123903 (#1 of 1): Incorrect deallocator used (ALLOC_FREE_MISMATCH) Change-Id: I88366204c9bb349e42dd3a79688a1c13280fe622 Signed-off-by: Youngjae Cho --- src/display/auto-brightness.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/auto-brightness.c b/src/display/auto-brightness.c index c2207db..89ec7af 100644 --- a/src/display/auto-brightness.c +++ b/src/display/auto-brightness.c @@ -291,7 +291,7 @@ static int connect_sensor(void) else sensor = list[0]; - free(list); + g_free(list); ret = sensor_get_min_range(sensor, &lmin); if (ret != SENSOR_ERROR_NONE) { -- 2.7.4 From 556e21b06998c885f4327580667730f5ed18ad35 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 14 Feb 2020 11:43:05 +0900 Subject: [PATCH 02/16] Add dbus interface for setting DIM_FLAG Path : /Org/Tizen/System/DeviceD/Display Interface : org.tizen.system.deviced.display Method : DimStayControl Signature : "(i)" Parameter : 0(Unset flag), 1(Set flag) Control DimStay. Update DIM_FLAG and change brightness accordingly. Change-Id: I7b3197a965044fdf9e0313ebf8b4d1f383ea7017 Signed-off-by: Youngjae Cho --- src/display/display-dbus.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 9b3402d..c402aa1 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -1088,6 +1088,33 @@ out: return g_variant_new("(i)", ret); } +static GVariant *dbus_dimstay_control(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int dimstay; + + g_variant_get(param, "(i)", &dimstay); + + if (dimstay < 0) { + _E("Invalid dimstay set value %d.", dimstay); + return g_variant_new("(i)", -EINVAL); + } + + if (dimstay) { + _I("Set DIM_FLAG."); + pm_status_flag |= DIM_FLAG; + } else { + _I("Unset DIM_FLAG."); + pm_status_flag &= ~DIM_FLAG; + } + + if (pm_cur_state == S_NORMAL) + backlight_ops.update(); + + return g_variant_new("(i)", 0); +} + static const dbus_method_s dbus_methods[] = { { "start", NULL, NULL, dbus_start }, { "stop", NULL, NULL, dbus_stop }, @@ -1123,6 +1150,7 @@ static const dbus_method_s dbus_methods[] = { { "CurrentBrightness", "i", "i", dbus_getbrightness }, /* deprecated. It is remained for tizen 2.4 */ { "LockTimeoutExpired", "s", "i", dbus_locktimeout_expired }, { "LockTimeoutInput", "si", "i", dbus_locktimeout_input }, + { "DimStayControl", "i", "i", dbus_dimstay_control }, /* Add methods here */ }; -- 2.7.4 From 87c1848b43ad680f1c84c97564e06aa89292066d Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 17 Feb 2020 18:47:41 +0900 Subject: [PATCH 03/16] Delete critical-log module Replace critical-log module to dlog API Change-Id: Ie2e7c6ddebe47a1d5c89cf494f7ce0fe6102f89f Signed-off-by: Youngjae Cho --- CMakeLists.txt | 5 - packaging/deviced.spec | 5 - src/critical-log/critical-log.c | 487 ---------------------------------------- 3 files changed, 497 deletions(-) delete mode 100644 src/critical-log/critical-log.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c98524c..5b2e8a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,11 +159,6 @@ IF(DEVICE_BOARD_MODULE STREQUAL on) SET(SRCS ${SRCS} ${BOARD_SRCS}) ENDIF() -IF(CRITICAL_LOG_MODULE STREQUAL on) - ADD_SOURCE(src/critical-log CRITICAL_LOG_SRCS) - SET(SRCS ${SRCS} ${CRITICAL_LOG_SRCS}) -ENDIF() - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 89e7c7f..e4aaff2 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -165,7 +165,6 @@ Plugin libraries for IoT devices -DTOUCH_SENSITIVITY_MODULE=on \ -DDUMP_MODULE=on \ -DDEVICE_BOARD_MODULE=on \ - -DCRITICAL_LOG_MODULE=on \ #eol %build @@ -295,7 +294,6 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %license LICENSE.Apache-2.0 %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/mobile-display.conf -%config %{_sysconfdir}/deviced/critical-log.conf %{_libdir}/mobile-display.so %{_unitdir}/rndis.service %{_bindir}/rndis.sh @@ -305,7 +303,6 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %license LICENSE.Apache-2.0 %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/wearable-display.conf -%config %{_sysconfdir}/deviced/critical-log.conf %{_libdir}/wearable-display.so %{_unitdir}/rndis.service %{_bindir}/rndis.sh @@ -316,7 +313,6 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/tv-display.conf %config %{_sysconfdir}/deviced/display.conf -%config %{_sysconfdir}/deviced/critical-log.conf %{_libdir}/tv-display.so %files plugin-profile-iot @@ -324,5 +320,4 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %license LICENSE.Apache-2.0 %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/display.conf -%config %{_sysconfdir}/deviced/critical-log.conf %{_libdir}/iot-display.so diff --git a/src/critical-log/critical-log.c b/src/critical-log/critical-log.c deleted file mode 100644 index e4eb3a8..0000000 --- a/src/critical-log/critical-log.c +++ /dev/null @@ -1,487 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2018 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 -#include -#include -#include -#include - -#include "core/log.h" -#include "core/devices.h" -#include "core/common.h" -#include "core/config-parser.h" -#include "core/device-notifier.h" -#ifdef BATTERY_MODULE -#include "battery/power-supply.h" -#endif -#include "power/power-handler.h" - -#define CLOG_SAVE_FILE "/var/log/critical-log.log" -#define CLOG_BACKUP_FILE "/var/log/critical-log.1.log" -#define CLOG_CONF_FILE "/etc/deviced/critical-log.conf" -#define CLOG_TIME_FORMAT "%y-%m-%d/%H:%M:%S" -#define CLOG_MIN_SIZE 3 -#define CLOG_MSG_MAX 512 -#define CLOG_PATH_MAX 512 -#define BOOT_REASON_PATH "/sys/class/system_stats/rbrs" -#define CLOG_FILE_MAX 51200 - -#define CLOG_INDENTED_TAG "%*s" - -struct clog_tag_info { - char *name; - int name_len; - int type; - int count; - int limit; -}; - -struct clog_msg_info { - int type; - char *log; -}; - -static dd_list *clog_tags; -static dd_list *clog_msgs; -static int max_name_len; - -static void free_clog_data(void) -{ - dd_list *n, *next; - struct clog_tag_info *tag; - struct clog_msg_info *msg; - - DD_LIST_FOREACH_SAFE(clog_tags, n, next, tag) { - DD_LIST_REMOVE(clog_tags, tag); - if (tag->name) { - free(tag->name); - tag->name = NULL; - } - free(tag); - tag = NULL; - } - DD_LIST_FOREACH_SAFE(clog_msgs, n, next, msg) { - DD_LIST_REMOVE(clog_msgs, msg); - if (msg->log) { - free(msg->log); - msg->log = NULL; - } - free(msg); - msg = NULL; - } -} - -static int clog_load_config(struct parse_result *result, void *user_data) -{ - static int type; - struct clog_tag_info *tag = NULL; - int ret; - - if (!result || !result->section) { - _E("There is no section."); - ret = -EINVAL; - goto out; - } - - tag = calloc(1, sizeof(struct clog_tag_info)); - if (!tag) { - _E("Failed to allocate memory."); - ret = -ENOMEM; - goto out; - } - - tag->name = strdup(result->section); - if (!tag->name) { - _E("Failed to allocate memory."); - ret = -ENOMEM; - goto out; - } - type++; - tag->type = type; - tag->name_len = strlen(tag->name); - if (max_name_len < tag->name_len) - max_name_len = tag->name_len; - if (result->name && result->value && MATCH(result->name, "Limit")) - tag->limit = strtol(result->value, NULL, 10); - else - tag->limit = CLOG_MIN_SIZE; - - DD_LIST_APPEND(clog_tags, tag); - - _D("[%d]%s count %d limit %d.", tag->type, tag->name, tag->count, tag->limit); - return 0; -out: - if (tag) - free(tag); - free_clog_data(); - return ret; -} - -static int clog_execute(void *data) -{ - dd_list *n, *next; - struct clog_tag_info *tag; - struct clog_msg_info *msg; - char *input, *check, *tag_name, *name = NULL; - int name_len, ret; - struct timespec tspec; - struct tm tm_now; - char str_buff[CLOG_MSG_MAX] = {0,}; - char str_time[32] = {0,}; - char str_msec[32] = {0,}; - - if (!data) - return -EINVAL; - - msg = calloc(1, sizeof(struct clog_msg_info)); - if (!msg) { - _E("Failed to allocate memory."); - return -EINVAL; - } - - input = (char *)data; - check = strchr(input, '|'); - if (!check) { - _E("There is no tag name separator(|)."); - ret = -EINVAL; - goto out; - } - - *check = '\0'; - tag_name = input; - while (*tag_name == ' ') - tag_name++; - name = strdup(tag_name); - if (!name) { - _E("Failed to allocate memory."); - ret = -ENOMEM; - goto out; - } - *check = '|'; - - name_len = strlen(name); - DD_LIST_FOREACH_SAFE(clog_tags, n, next, tag) { - if (tag->name_len != name_len) - continue; - if (strncmp(tag->name, name, name_len)) - continue; - break; - } - if (!tag) { - _E("There is no matched tag name."); - ret = -EINVAL; - goto out; - } - - clock_gettime(CLOCK_REALTIME, &tspec); - localtime_r((time_t *)&tspec.tv_sec, &tm_now); - strftime(str_time, sizeof(str_time), CLOG_TIME_FORMAT, &tm_now); - snprintf(str_msec, sizeof(str_msec), ":%03ld|", tspec.tv_nsec / 1000000); -#ifdef BATTERY_MODULE - snprintf(str_buff, sizeof(str_buff), "%s%s[%d]%s BAT(P:%s S:%s C:%d M:%d Chg_ON:%d)\n", - str_time, str_msec, getpid(), input, - battery.power_source_s, - battery.status_s, - battery.capacity, - battery.misc, - battery.charger_charging); -#else - snprintf(str_buff, sizeof(str_buff), "%s%s[%d]%s\n", - str_time, str_msec, getpid(), input); -#endif - _D("%s", str_buff); - msg->log = strdup(str_buff); - msg->type = tag->type; - DD_LIST_APPEND(clog_msgs, msg); - tag->count++; - - if (tag->count > tag->limit) { - DD_LIST_FOREACH_SAFE(clog_msgs, n, next, msg) { - if (tag->type != msg->type) - continue; - DD_LIST_REMOVE(clog_msgs, msg); - if (msg->log) - free(msg->log); - free(msg); - tag->count--; - break; - } - } - if (name) - free(name); - return 0; -out: - if (name) - free(name); - if (msg) { - if (msg->log) - free(msg->log); - free(msg); - } - return ret; -} - -#ifdef BATTERY_MODULE -static int clog_battery_health(void *data) -{ - char clog[CLOG_MSG_MAX] = {0,}; - static int old = HEALTH_GOOD; - int health; - - if (!data) { - _E("There is no data."); - return -EINVAL; - } - - health = *(int *)data; - if (old == health) - return 0; - - old = health; - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|%s", max_name_len, "BatteryHealth", battery.health_s); - - return clog_execute((void *)clog); -} - -static int clog_battery_present(void *data) -{ - char clog[CLOG_MSG_MAX] = {0,}; - static int old = PRESENT_NORMAL; - int present; - - if (!data) { - _E("There is no data."); - return -EINVAL; - } - - present = *(int *)data; - if (old == present) - return 0; - - old = present; - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|%s", max_name_len, "Battery", (present == PRESENT_ABNORMAL) ? "CFOpened" : "CFNormal"); - - return clog_execute((void *)clog); -} -#endif - -static void clog_save_log(void) -{ - dd_list *n, *next; - struct clog_tag_info *tag; - struct clog_msg_info *msg; - struct stat st; - int fd; - int ret; - - fd = open(CLOG_SAVE_FILE, O_RDONLY); - if (fd != -1) { - if (fstat(fd, &st) >= 0 && st.st_size > CLOG_FILE_MAX) { - if (remove(CLOG_BACKUP_FILE) < 0) - _E("Failed to remove %d.", errno); - if (rename(CLOG_SAVE_FILE, CLOG_BACKUP_FILE) < 0) - _E("Failed to backup %d.", errno); - } - close(fd); - } - - fd = open(CLOG_SAVE_FILE, O_CREAT | O_EXCL | O_WRONLY, 0644); - if (fd == -1) { - fd = open(CLOG_SAVE_FILE, O_APPEND | O_WRONLY); - if (fd == -1) { - _E("Fail to open clog file."); - return; - } - } - DD_LIST_FOREACH_SAFE(clog_msgs, n, next, msg) { - ret = write(fd, msg->log, strlen(msg->log)); - if (ret < 0) - _E("Failed to write %d", errno); - } - close(fd); - - DD_LIST_FOREACH_SAFE(clog_tags, n, next, tag) - tag->count = 0; - DD_LIST_FOREACH_SAFE(clog_msgs, n, next, msg) { - DD_LIST_REMOVE(clog_msgs, msg); - if (msg->log) { - free(msg->log); - msg->log = NULL; - } - free(msg); - msg = NULL; - } -} - -static int clog_common_log(void *data) -{ - char clog[CLOG_MSG_MAX] = {0,}; - - if (data) - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|%s", max_name_len, "Common", (char *)data); - else - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|LogDump", max_name_len, "Common"); - - clog_execute((void *)clog); - - if (!data) - clog_save_log(); - return 0; -} - -static int clog_power_off(void *data) -{ - char clog[CLOG_MSG_MAX] = {0,}; - struct power_option *opt = (struct power_option *)data; - - if (!opt || (opt->type != POWEROFF_TYPE_DIRECT && opt->type != POWEROFF_TYPE_RESTART)) - goto save_log; - - if (opt->type == POWEROFF_TYPE_DIRECT) - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|%s ", max_name_len, "PowerHandle", "PowerOff"); - else - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|%s with %s ", max_name_len, "PowerHandle", - "Reboot", (opt->option) ? opt->option : "NULL"); - - clog_execute((void *)clog); - -save_log: - clog_save_log(); - return 0; -} - -static int clog_booting_done(void *data) -{ - DIR *dir; - struct dirent *result; - static int done; - char clog[CLOG_MSG_MAX * 2] = {0,}; - char node[CLOG_PATH_MAX] = {0,}; - char val[CLOG_PATH_MAX] = {0,}; - char elem; - int prefix; - int fd; - unsigned int cnt; - int ret; - - if (data == NULL) - return done; - done = *(int *)data; - if (done == 0) - return 0; - - snprintf(clog, CLOG_MSG_MAX, CLOG_INDENTED_TAG"|Boot", max_name_len, "PowerHandle"); - - dir = opendir(BOOT_REASON_PATH); - if (!dir) { - _E("Failed to opendir %s.", BOOT_REASON_PATH); - goto out; - } - - prefix = strlen(clog); - while ((result = readdir(dir))) { - if (strncmp(result->d_name, "summary", 7) != 0) - continue; - snprintf(node, sizeof(node), BOOT_REASON_PATH"/%s", result->d_name); - fd = open(node, O_RDONLY); - if (fd < 0) - continue; - ret = 0; - cnt = 0; - while (read(fd, &elem, 1) != 0) { - if (cnt >= 4 || ret >= CLOG_PATH_MAX - 1) - break; - if (elem != '\n') { - val[ret++] = elem; - } else { - val[ret++] = ' '; - cnt++; - } - } - val[ret] = '\0'; - snprintf(clog + prefix, CLOG_MSG_MAX - prefix, "|%s(%s) ", result->d_name, val); - close(fd); - closedir(dir); - goto out; - } - - while ((result = readdir(dir))) { - if (result->d_name[0] == '.' || - result->d_type == DT_DIR || - strncmp(result->d_name, "uevent", 6) == 0 || - strncmp(result->d_name, "power", 5) == 0 || - strncmp(result->d_name, "subsystem", 9) == 0) - continue; - snprintf(node, sizeof(node), BOOT_REASON_PATH"/%s", result->d_name); - fd = open(node, O_RDONLY); - if (fd < 0) - continue; - ret = read(fd, val, CLOG_PATH_MAX); - if (ret < 0 || ret >= CLOG_PATH_MAX) { - cnt = UINT_MAX; - } else { - val[ret] = '\0'; - cnt = strtoul(val, NULL, 10); - } - snprintf(clog + prefix, CLOG_MSG_MAX - prefix, "|%s%u ", result->d_name, cnt); - close(fd); - prefix = strlen(clog); - } - if (dir) - closedir(dir); -out: - clog_execute((void *)clog); - clog_save_log(); - unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, clog_booting_done); - return done; -} - -static void clog_init(void *none) -{ - register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, clog_booting_done); -#ifdef BATTERY_MODULE - register_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, clog_battery_health); - register_notifier(DEVICE_NOTIFIER_BATTERY_PRESENT, clog_battery_present); -#endif - register_notifier(DEVICE_NOTIFIER_CRITICAL_LOG, clog_common_log); - register_notifier(DEVICE_NOTIFIER_POWEROFF, clog_power_off); - if (config_parse(CLOG_CONF_FILE, clog_load_config, NULL) < 0) - _E("Fail to init configuration."); -} - -static void clog_exit(void *data) -{ -#ifdef BATTERY_MODULE - unregister_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, clog_battery_health); - unregister_notifier(DEVICE_NOTIFIER_BATTERY_PRESENT, clog_battery_present); -#endif - unregister_notifier(DEVICE_NOTIFIER_CRITICAL_LOG, clog_common_log); - unregister_notifier(DEVICE_NOTIFIER_POWEROFF, clog_power_off); - free_clog_data(); -} - -static const struct device_ops clog_device_ops = { - .name = "clog", - .init = clog_init, - .exit = clog_exit, - .execute = clog_execute, -}; - -DEVICE_OPS_REGISTER(&clog_device_ops) -- 2.7.4 From 63f40e14df96e1b0105fd04dd7492684d06ef92d Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 17 Feb 2020 17:14:58 +0900 Subject: [PATCH 04/16] Introduce critical-log API from dlog Below are added as critical-log - Power(Display) lock/unlock - PowerOff/Reboot - Battery status/health Change-Id: I6f2f5b1ee660d4f6a8a426b71d311719f9304a36 Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 4 ++-- plugins/mobile/display/core.c | 4 ++-- plugins/tv/display/core.c | 4 ++-- plugins/wearable/display/core.c | 4 ++-- src/battery/lowbat-handler.c | 2 ++ src/battery/power-supply.c | 15 +++++++++++---- src/core/main.c | 4 +++- src/power/boot.c | 2 +- src/power/power-handler.c | 14 ++++++++++---- src/shared/log-macro.h | 4 ++++ 10 files changed, 39 insertions(+), 18 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index ea376e6..c75b0d5 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -1459,7 +1459,7 @@ static void proc_condition_lock(PMMsg *data) if (state == S_LCDOFF) set_process_active(true, pid); - _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); + CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; @@ -1511,7 +1511,7 @@ static void proc_condition_unlock(PMMsg *data) if (state == S_LCDOFF) set_process_active(false, pid); - _I("[%s] unlocked by %5d", states[state].name, pid); + CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 8a5b71c..224c0b9 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1469,7 +1469,7 @@ static void proc_condition_lock(PMMsg *data) if (state == S_LCDOFF) set_process_active(true, pid); - _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); + CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; @@ -1521,7 +1521,7 @@ static void proc_condition_unlock(PMMsg *data) if (state == S_LCDOFF) set_process_active(false, pid); - _I("[%s] unlocked by %5d", states[state].name, pid); + CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index fc02a25..ecb23ab 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1456,7 +1456,7 @@ static void proc_condition_lock(PMMsg *data) if (state == S_LCDOFF) set_process_active(true, pid); - _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); + CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; @@ -1508,7 +1508,7 @@ static void proc_condition_unlock(PMMsg *data) if (state == S_LCDOFF) set_process_active(false, pid); - _I("[%s] unlocked by %5d", states[state].name, pid); + CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 9627b9e..b5bcc18 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1479,7 +1479,7 @@ static void proc_condition_lock(PMMsg *data) if (state == S_LCDOFF) set_process_active(true, pid); - _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); + CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; @@ -1531,7 +1531,7 @@ static void proc_condition_unlock(PMMsg *data) if (state == S_LCDOFF) set_process_active(false, pid); - _I("[%s] unlocked by %5d", states[state].name, pid); + CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid); /* for debug */ if (state == S_LCDOFF) lock_type = PM_LCDOFF_STR; diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 4a2934b..670d2b2 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -432,6 +432,7 @@ static int battery_critical_low_act(void *data) int battery_power_off_act(void *data) { + CRITICAL_LOG("Low battery power off."); return power_execute(POWER_POWEROFF); } @@ -587,6 +588,7 @@ static void battery_level_send_system_event(int bat_percent) prev = str; _D("System_event: %s", str); + CRITICAL_LOG("Battery %s.", str); event_system_send(SYS_EVENT_BATTERY_LEVEL_STATUS, EVT_KEY_BATTERY_LEVEL_STATUS, str); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 0932597..4e8bbcf 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -199,7 +199,7 @@ static gboolean health_timer_cb(void *data) if (battery.health != HEALTH_LOW && battery.health != HEALTH_HIGH) return G_SOURCE_REMOVE; - _I("Popup: Battery health status is not good."); + CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); if (disp_plgn.pm_unlock_internal) @@ -472,14 +472,19 @@ static void charger_state_send_system_event(int state) str = EVT_VAL_BATTERY_CHARGER_CHARGING; break; case CHARGE_STATUS_FULL: + str = EVT_VAL_BATTERY_CHARGER_DISCHARGING; + CRITICAL_LOG("Battery %s", str); + break; case CHARGE_STATUS_DISCHARGING: str = EVT_VAL_BATTERY_CHARGER_DISCHARGING; break; case CHARGE_STATUS_CONNECTED: str = EVT_VAL_BATTERY_CHARGER_CONNECTED; + CRITICAL_LOG("Battery %s", str); break; case CHARGE_STATUS_DISCONNECTED: str = EVT_VAL_BATTERY_CHARGER_DISCONNECTED; + CRITICAL_LOG("Battery %s", str); break; default: _E("Invalid parameter: %d", state); @@ -501,7 +506,7 @@ int changed_battery_cf(int status) static void update_present(enum battery_noti_status status) { - _I("Charge(%d) present(%d)", battery.charge_now, battery.present); + CRITICAL_LOG("Charge(%d) present(%d)", battery.charge_now, battery.present); if (status == DEVICE_NOTI_ON) { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); @@ -529,9 +534,9 @@ void remove_health_popup(void) static void update_health(enum battery_noti_status status) { _I("Charge(%d) health(%d)", battery.charge_now, battery.health); + CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s); if (status == DEVICE_NOTI_ON) { - _I("Popup: Battery health status is not good."); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); if (disp_plgn.pm_change_internal) disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); @@ -1148,6 +1153,8 @@ static GVariant *dbus_charger_charging(GDBusConnection *conn, if (ret == 0 && val != chg_on) { battery.charger_charging = val; ret = sys_set_int(CHARGER_CHARGE_ON_NODE, battery.charger_charging); + CRITICAL_LOG("chg_on changed to %d %s", battery.charger_charging, + (ret == 0) ? "success" : "fail"); _I("%s to change status with %d.", ((ret == 0) ? "success" : "fail"), battery.charger_charging); } else { _I("Skip change status with %d (ret %d prev %d)", val, ret, battery.charger_charging); @@ -1476,7 +1483,7 @@ static void change_health_popup_timer(enum battery_noti_status status) static void launch_health_popup(void) { - _I("Popup - Health is not good(health %s)", (battery.health == HEALTH_HIGH) ? "TempHigh" : "TempLow"); + CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s); health_popup_timer_init(__func__); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); diff --git a/src/core/main.c b/src/core/main.c index 5c80542..ac24e73 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -57,7 +57,7 @@ static void sig_quit(int signo) static void sig_usr1(int signo) { - _D("Received SIGUSR1 signal(%d), deviced'll be finished.", signo); + CRITICAL_LOG("Received SIGUSR1 signal(%d), deviced'll be finished.", signo); if (mainloop && g_main_loop_is_running(mainloop)) g_main_loop_quit(mainloop); } @@ -92,6 +92,7 @@ static int deviced_main(int argc, char **argv) int ret; dbus_handle_h handle = NULL; + CRITICAL_LOG("Initializing deviced."); mainloop = g_main_loop_new(NULL, FALSE); ret = check_power_flag(); @@ -123,6 +124,7 @@ static int deviced_main(int argc, char **argv) g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_TIMEOUT, watchdog_cb, NULL, NULL); /* g_main_loop */ + CRITICAL_LOG("Starting deviced."); g_main_loop_run(mainloop); g_main_loop_unref(mainloop); diff --git a/src/power/boot.c b/src/power/boot.c index 3302b77..77b04bc 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -61,7 +61,7 @@ static void booting_done_received(GDBusConnection *conn, _E("System session is not ready yet."); return; } - _I("System session is ready."); + CRITICAL_LOG("System session is ready."); device_notify_once(DEVICE_NOTIFIER_BOOTING_DONE, &system_done); } else if (strcmp(name, SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED) == 0) { diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 52caa68..d67103e 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -174,7 +174,6 @@ static bool disable_coredump_handler(void) static void poweroff_request_shutdown(void) { - _I("Requested power off via systemd."); const char *method; @@ -189,6 +188,7 @@ static void poweroff_request_shutdown(void) return; } + CRITICAL_LOG("Requested %s via systemd.", method); dbus_handle_method_sync_timeout(SYSTEMD_DBUS_DEST, SYSTEMD_DBUS_PATH, SYSTEMD_DBUS_IFACE_MANAGER, @@ -204,11 +204,17 @@ void poweroff_prepare(void) { int off = poweroff_opt.type; + if (off == POWEROFF_TYPE_POWEROFF) + CRITICAL_LOG("Prepare PowerOff."); + else if (off == POWEROFF_TYPE_REBOOT) + CRITICAL_LOG("Prepare Reboot."); + poweroff_notify_resourced(); disable_systemd_journald(); disable_coredump_handler(); disable_display(); + device_notify(DEVICE_NOTIFIER_POWEROFF, &off); } @@ -544,7 +550,7 @@ static GVariant *dbus_power_handler(GDBusConnection *conn, if (ret < 0) goto out; - _I("Poweroff PID(%d) requests %s.", ret, type_str); + CRITICAL_LOG("Poweroff PID(%d) requests %s.", ret, type_str); ret = power_execute_pid(type_str, NULL); out: @@ -565,7 +571,7 @@ static GVariant *dbus_power_option_handler(GDBusConnection *conn, if (ret < 0) goto out; - _I("Poweroff PID(%d) requests type=%s option=%s.", ret, type, option); + CRITICAL_LOG("Poweroff PID(%d) requests type=%s option=%s.", ret, type, option); ret = power_execute_pid(type, option); out: @@ -595,7 +601,7 @@ static GVariant *add_poweroff_time(GDBusConnection *conn, pid = (pid_t)ret; - _D("add_poweroff_timer pid=%d", pid); + CRITICAL_LOG("PID %d request poweroff timer.", pid); DD_LIST_FOREACH(poweroff_handles, l, handle) { if (handle->pid == pid) diff --git a/src/shared/log-macro.h b/src/shared/log-macro.h index cb309af..773ea44 100644 --- a/src/shared/log-macro.h +++ b/src/shared/log-macro.h @@ -22,6 +22,10 @@ #ifdef ENABLE_DLOG #include +/* critical log */ +#define CRITICAL_LOG(fmt, arg...) \ + do { CRITICAL_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, fmt, ##arg); } while (0) + #define _D(fmt, arg...) \ do { SLOGD(fmt, ##arg); } while (0) #define _I(fmt, arg...) \ -- 2.7.4 From 5856f0755b1aa3fa6bfb3dbf0faeb587c1b149aa Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 18 Feb 2020 14:36:27 +0900 Subject: [PATCH 05/16] Add iot-display.conf Change-Id: I40b5b40f7cabb5165baaaacf6776139f1faf22cc Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 2 +- conf/{display.conf => iot-display.conf} | 3 +++ packaging/deviced.spec | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) rename conf/{display.conf => iot-display.conf} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b2e8a7..cbd204a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,7 @@ ADD_SUBDIRECTORY(plugins/mobile/display) ADD_SUBDIRECTORY(plugins/wearable/display) ADD_SUBDIRECTORY(plugins/tv/display) ADD_SUBDIRECTORY(plugins/iot/display) -INSTALL_CONF(conf display) INSTALL_CONF(conf mobile-display) INSTALL_CONF(conf wearable-display) INSTALL_CONF(conf tv-display) +INSTALL_CONF(conf iot-display) diff --git a/conf/display.conf b/conf/iot-display.conf similarity index 96% rename from conf/display.conf rename to conf/iot-display.conf index 08ec195..4e14b86 100644 --- a/conf/display.conf +++ b/conf/iot-display.conf @@ -34,3 +34,6 @@ # If this value is no, LCD is turned off just by external requests. # TimeoutEnable=(yes or no) +LCDAlwaysOn=yes +TimeoutEnable=no +SleepSupport=no diff --git a/packaging/deviced.spec b/packaging/deviced.spec index e4aaff2..68f5723 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -228,6 +228,7 @@ mkdir -p %{_libdir}/deviced mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so %post plugin-profile-iot +mv %{_sysconfdir}/deviced/iot-display.conf %{_sysconfdir}/deviced/display.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so @@ -312,12 +313,11 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %license LICENSE.Apache-2.0 %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/tv-display.conf -%config %{_sysconfdir}/deviced/display.conf %{_libdir}/tv-display.so %files plugin-profile-iot %manifest deviced.manifest %license LICENSE.Apache-2.0 %defattr(-,root,root,-) -%config %{_sysconfdir}/deviced/display.conf +%config %{_sysconfdir}/deviced/iot-display.conf %{_libdir}/iot-display.so -- 2.7.4 From 0e3524a6af8e600a1f5202245aa7c68d86e2f1ec Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 18 Feb 2020 15:07:35 +0900 Subject: [PATCH 06/16] Enable rndis usb mode for tv and iot profile Iot profile use rndis usb mode without usb tethering feature. So, all profile have to support usb rndis mode. Change-Id: Ib75aaf0c141fcb8b554cdcd2adea9a8ad37e3b02 --- packaging/deviced.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 68f5723..185a302 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -314,6 +314,8 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/tv-display.conf %{_libdir}/tv-display.so +%{_unitdir}/rndis.service +%{_bindir}/rndis.sh %files plugin-profile-iot %manifest deviced.manifest @@ -321,3 +323,5 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/iot-display.conf %{_libdir}/iot-display.so +%{_unitdir}/rndis.service +%{_bindir}/rndis.sh -- 2.7.4 From 4175f3b0f0551a57d9f04643e06e6d0d9e43ab05 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 13 Feb 2020 16:40:09 +0900 Subject: [PATCH 07/16] Fix usb mode<->vconf conversion We consider usb mode is always valid wherease usb vconf may not represent the mode correctly as it is determined manually. (eg. As mode mapping table or vconf definition is hard-coded manually, it can cause mismatch as usb policy changes.) So mode update always take place, but vconf update doesn't if converted vconf is invalid. You can see this in usb_state_set_selected_mode(). usb_selected_mode is always updated regardless of converted vconf is valid or not. The vconf update, on the other hand, doesn't take place if the converted vconf is invalid. Change-Id: I4f7b0d7529b3612947baf2b9869f4b77571d264f Signed-off-by: Youngjae Cho --- src/usb/usb-state.c | 104 ++++++++++++++++++++++------------------------------ src/usb/usb.h | 3 ++ 2 files changed, 46 insertions(+), 61 deletions(-) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 8299968..6769827 100644 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -37,23 +37,25 @@ #define MTP_RESPONDER_PATH "/usr/lib/systemd/system/mtp-responder.service" static int noti_id = -1; + static unsigned int usb_current_mode = USB_FUNCTION_NONE; -static unsigned int usb_selected_mode = USB_FUNCTION_SDB; /* USB_FUNCTION_SDB is for debugging */ +static unsigned int usb_selected_mode = USB_FUNCTION_NONE; + static extcon_usb_state_e usb_connection = USB_DISCONNECTED; /** * Important * You must keep the order for the specific items. * - * There may be several mode_vconfs for a mode. + * There may be several mode_v for a mode. * In this case, the representative value should be placed on top. * * In case of SET_USB_SDB_DIAG and SET_USB_DIAG_SDB, SET_USB_SDB_DIAG should be above. * As another example, SEt_USB_RNDIS_SDB should be at the top of them. */ static const struct _usb_mode_mapping_table { - int mode_vconf; - unsigned int mode; + int mode_v; /* Integer defined by vconf */ + unsigned int mode; /* Bitmap of usb function combination */ } usb_mode_mapping_table[] = { /* Hack for performance. In most cases this is the value. */ {SET_USB_DEFAULT, USB_FUNCTION_MTP | USB_FUNCTION_ACM}, @@ -73,20 +75,20 @@ static const struct _usb_mode_mapping_table { {13, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, /* SET_USB_RNDIS_SDB_ACM */ }; -static unsigned int selected_mode_from_vconf(int mode_vconf) +static unsigned int get_mode_bitmap_from_vconf(int mode_v) { int i; int array_len = sizeof(usb_mode_mapping_table)/sizeof(usb_mode_mapping_table[0]); for (i = 0; i < array_len; i++) { - if (usb_mode_mapping_table[i].mode_vconf == mode_vconf) + if (usb_mode_mapping_table[i].mode_v == mode_v) return usb_mode_mapping_table[i].mode; } - return USB_FUNCTION_NONE; + return USB_FUNCTION_INVALID; } -static int selected_mode_to_vconf(unsigned int mode) +static int get_mode_vconf_from_bitmap(unsigned int mode) { int i; int array_len = sizeof(usb_mode_mapping_table)/sizeof(usb_mode_mapping_table[0]); @@ -94,47 +96,10 @@ static int selected_mode_to_vconf(unsigned int mode) /* Caution: The order to search the usb_mode_mapping_table must start with a low index. */ for (i = 0; i < array_len; i++) { if (usb_mode_mapping_table[i].mode == mode) - return usb_mode_mapping_table[i].mode_vconf; + return usb_mode_mapping_table[i].mode_v; } - return SET_USB_DEFAULT; /* To prevent usb abnormal operation, use it instead of SET_USB_NONE */ -} - -static int current_mode_to_vconf(unsigned int mode) -{ - bool mtp = mode & USB_FUNCTION_MTP; - bool sdb = mode & USB_FUNCTION_SDB; - bool acm = mode & USB_FUNCTION_ACM; - bool diag = mode & USB_FUNCTION_DIAG; - bool rndis = mode & USB_FUNCTION_RNDIS; - bool dm = mode & USB_FUNCTION_DM; - bool rmnet = mode & USB_FUNCTION_RMNET; - - if (mode == USB_FUNCTION_NONE) - return SET_USB_NONE; - - if (mtp && acm) { - if (sdb) { - if (diag) - return SET_USB_SDB_DIAG; - return SET_USB_SDB; - } - return SET_USB_DEFAULT; - } - - if (rndis) - return SET_USB_RNDIS; - - if (diag && sdb) - return SET_USB_DIAG_SDB; - - if (diag && rmnet) - return 11; /* SET_USB_DIAG_RMNET */ - - if (acm && sdb && dm) - return 12; /* SET_USB_ACM_SDB_DM */ - - return -EINVAL; + return SET_USB_INVALID; } static void usb_state_send_system_event(int status) @@ -177,19 +142,26 @@ extcon_usb_state_e usb_state_get_connection(void) void usb_state_retrieve_selected_mode(void) { int ret; - int mode_vconf; + int mode_v; + unsigned int mode; - ret = vconf_get_int(VCONFKEY_USB_SEL_MODE, &mode_vconf); + ret = vconf_get_int(VCONFKEY_USB_SEL_MODE, &mode_v); if (ret < 0) { _E("Failed to get vconf value for usb sel mode: %d", vconf_get_ext_errno()); return; } - usb_selected_mode = selected_mode_from_vconf(mode_vconf); - _I("usb_select_mode_vconf=%d, condition=%x", mode_vconf, usb_selected_mode); + mode = get_mode_bitmap_from_vconf(mode_v); + + if (mode != USB_FUNCTION_INVALID) { + usb_selected_mode = mode; + _I("Succeeded to convert vconf to mode. vconf=%d, mode=0x%x.", mode_v, usb_selected_mode); + } else { + _E("Failed to convert vconf to mode. There is no mode matches up with vconf %d.", mode_v); + } #ifdef ENGINEER_MODE - _I("Engineer mode. usb selected mode %d, debug state %d", usb_selected_mode, get_usb_debug_state()); + _I("Engineer mode. usb selected mode 0x%x, debug state %d", usb_selected_mode, get_usb_debug_state()); if (!(usb_selected_mode & USB_FUNCTION_SDB)) { usb_selected_mode = USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB; @@ -213,12 +185,17 @@ unsigned int usb_state_get_selected_mode(void) int usb_state_set_selected_mode(unsigned int mode) { int ret; - int mode_vconf; + int mode_v; usb_selected_mode = mode; - mode_vconf = selected_mode_to_vconf(mode); - ret = vconf_set_int(VCONFKEY_USB_SEL_MODE, mode_vconf); + mode_v = get_mode_vconf_from_bitmap(mode); + if (mode_v == SET_USB_INVALID) { + _E("Failed to convert selected_mode to vconf. There is no vconf matches up with mode 0x%x", mode); + return -EINVAL; + } + + ret = vconf_set_int(VCONFKEY_USB_SEL_MODE, mode_v); if (ret < 0) _E("Failed to set vconf value for usb selected mode: %d", vconf_get_ext_errno()); @@ -234,15 +211,20 @@ unsigned int usb_state_get_current_mode(void) int usb_state_set_current_mode(unsigned int mode) { int ret = 0; - int mode_vconf; - static int old_mode_vconf = -1; + int mode_v; + static int old_mode_v = -1; usb_current_mode = mode; - mode_vconf = current_mode_to_vconf(mode); - if (mode_vconf >= 0 && old_mode_vconf != mode_vconf) { - old_mode_vconf = mode_vconf; - ret = vconf_set_int(VCONFKEY_USB_CUR_MODE, mode_vconf); + mode_v = get_mode_vconf_from_bitmap(mode); + if (mode_v == SET_USB_INVALID) { + _E("Failed to convert current_mode to vconf. There is no vconf matches up with mode 0x%x", mode); + return -EINVAL; + } + + if (old_mode_v != mode_v) { + old_mode_v = mode_v; + ret = vconf_set_int(VCONFKEY_USB_CUR_MODE, mode_v); if (ret < 0) _E("Failed to set vconf value for usb current mode: %d", vconf_get_ext_errno()); } diff --git a/src/usb/usb.h b/src/usb/usb.h index 45567c4..ff968ea 100644 --- a/src/usb/usb.h +++ b/src/usb/usb.h @@ -23,6 +23,9 @@ #include #include "extcon/extcon.h" +#define USB_FUNCTION_INVALID UINT_MAX +#define SET_USB_INVALID INT_MAX + #define USB_CONFIG_OPS_REGISTER(dev) \ static void __CONSTRUCTOR__ usb_config_init(void) \ { \ -- 2.7.4 From ac35a1ad00a4990a5380dab418635a93145054e3 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Wed, 19 Feb 2020 09:00:21 +0900 Subject: [PATCH 08/16] Remove to check if mtp-responder.service exists. If you disable mtp mode if there is not mtp service. The predefined usb mode and current usb state do not match. So, mtp-responder-dummy.service is created int libdevice-node. This prevents inconsistencies between predefined usb mode and the current state. Change-Id: I05dec48b4aabe8bbf0f9139502a2092e518d1aa3 --- src/usb/usb-state.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 6769827..8d1e1e6 100644 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -34,8 +34,6 @@ #include "usb-tethering.h" #include "usb-debug.h" -#define MTP_RESPONDER_PATH "/usr/lib/systemd/system/mtp-responder.service" - static int noti_id = -1; static unsigned int usb_current_mode = USB_FUNCTION_NONE; @@ -169,11 +167,6 @@ void usb_state_retrieve_selected_mode(void) set_usb_debug_state(true); } #endif - - if (access(MTP_RESPONDER_PATH, R_OK) != 0) { - usb_selected_mode &= ~USB_FUNCTION_MTP; - (void)usb_state_set_selected_mode(usb_selected_mode); - } } /* Cache of vconf_get_int(VCONFKEY_USB_SEL_MODE) */ -- 2.7.4 From 73a833334eb1c5cb91a2e983ded21bb6ae2eddb9 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 19 Feb 2020 17:23:02 +0900 Subject: [PATCH 09/16] Fix dbus method: change_usb_client_mode() Change-Id: I285ecde35f611642bbec068ddade0482107603a5 Signed-off-by: Youngjae Cho --- src/usb/usb-dbus.c | 55 +++++++++++++++-------------------------------------- src/usb/usb-state.c | 2 +- src/usb/usb.h | 1 + 3 files changed, 17 insertions(+), 41 deletions(-) diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c index 3b1c6b1..69b118a 100644 --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -27,6 +27,7 @@ #include "core/common.h" #include "core/devices.h" #include "usb.h" +#include "usb-debug.h" /* Legacy signals */ #define SIGNAL_STATE_CHANGED "StateChanged" @@ -125,56 +126,30 @@ static void change_usb_client_mode(GDBusConnection *conn, gpointer data) { - int req, debug; + int req_vconf = -1; int ret; unsigned mode; - g_variant_get(param, "(i)", &req); - - debug = 0; - switch (req) { - case SET_USB_DEFAULT: - case SET_USB_SDB: - case SET_USB_SDB_DIAG: - mode = USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB; - debug = 1; - break; - case SET_USB_RNDIS: - case SET_USB_RNDIS_DIAG: - mode = USB_FUNCTION_RNDIS | USB_FUNCTION_SDB; - debug = 1; - break; - case SET_USB_RNDIS_SDB: - mode = USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM; - debug = 1; - break; - case 11: /* SET_USB_DIAG_RMNET */ - mode = USB_FUNCTION_DIAG | USB_FUNCTION_ACM | USB_FUNCTION_RMNET; - debug = 1; - break; - case 12: /* SET_USB_ACM_SDB_DM */ - mode = USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM; - debug = 1; - break; - case 13: /* SET_USB_RNDIS_SDB_ACM */ - mode = USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM; - debug = 1; - break; - default: - _E("(%d) is unknown usb mode.", req); - goto out; + g_variant_get(param, "(i)", &req_vconf); + if (req_vconf < 0) { + _E("Failed to get req_vconf."); + return; } - ret = vconf_set_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, debug); - if (ret < 0) - _E("Failed to set usb debug mode: %d", vconf_get_ext_errno()); + mode = get_mode_bitmap_from_vconf(req_vconf); + + if (mode == USB_FUNCTION_INVALID) { + _E("Failed to convert vconf to mode. There is no mode matches up with vconf %d.", req_vconf); + return; + } ret = usb_change_mode(mode); if (ret < 0) _E("Failed to change usb mode: %d", ret); -out: - return ; + /* Get selected_mode once more, just in case usb_change_mode() fails */ + mode = usb_state_get_selected_mode(); + set_usb_debug_state((bool)(mode & USB_FUNCTION_SDB)); } /* dbus methods */ diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 8d1e1e6..6470f41 100644 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -73,7 +73,7 @@ static const struct _usb_mode_mapping_table { {13, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, /* SET_USB_RNDIS_SDB_ACM */ }; -static unsigned int get_mode_bitmap_from_vconf(int mode_v) +unsigned int get_mode_bitmap_from_vconf(int mode_v) { int i; int array_len = sizeof(usb_mode_mapping_table)/sizeof(usb_mode_mapping_table[0]); diff --git a/src/usb/usb.h b/src/usb/usb.h index ff968ea..1b620be 100644 --- a/src/usb/usb.h +++ b/src/usb/usb.h @@ -55,6 +55,7 @@ struct usb_config_plugin_ops { void add_usb_config(const struct usb_config_ops *ops); void remove_usb_config(const struct usb_config_ops *ops); +unsigned int get_mode_bitmap_from_vconf(int mode_v); int usb_change_mode(unsigned int mode); void usb_state_update_state(extcon_usb_state_e state, unsigned int mode); -- 2.7.4 From 613ecd25da136c6cf210e00a15a21783f7ecdf5b Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 20 Feb 2020 13:17:39 +0900 Subject: [PATCH 10/16] Update pm_cur_state correctly in lcd_on_direct() Change-Id: Ic72bbd46a90a597e814de87b45f9c2962d3d7e0d Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 3 ++- plugins/mobile/display/core.c | 3 ++- plugins/tv/display/core.c | 3 ++- plugins/wearable/display/core.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index c75b0d5..7f1ed5c 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -1123,9 +1123,10 @@ void lcd_on_direct(enum device_flags flags) && pm_cur_state == S_SLEEP) { broadcast_pm_wakeup(); power_ops.power_lock(); - pm_cur_state = S_NORMAL; } + pm_cur_state = S_NORMAL; + _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); lcd_on_procedure(LCD_NORMAL, flags); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 224c0b9..1dee4df 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1129,9 +1129,10 @@ void lcd_on_direct(enum device_flags flags) && pm_cur_state == S_SLEEP) { broadcast_pm_wakeup(); power_ops.power_lock(); - pm_cur_state = S_NORMAL; } + pm_cur_state = S_NORMAL; + _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); lcd_on_procedure(LCD_NORMAL, flags); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index ecb23ab..3d2ca7d 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1120,9 +1120,10 @@ void lcd_on_direct(enum device_flags flags) && pm_cur_state == S_SLEEP) { broadcast_pm_wakeup(); power_ops.power_lock(); - pm_cur_state = S_NORMAL; } + pm_cur_state = S_NORMAL; + _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); lcd_on_procedure(LCD_NORMAL, flags); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b5bcc18..7a04a38 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1128,9 +1128,10 @@ void lcd_on_direct(enum device_flags flags) && pm_cur_state == S_SLEEP) { broadcast_pm_wakeup(); power_ops.power_lock(); - pm_cur_state = S_NORMAL; } + pm_cur_state = S_NORMAL; + _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); lcd_on_procedure(LCD_NORMAL, flags); -- 2.7.4 From dd2ae938a210f552220d4ec42c3f4bde87f8b90c Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 20 Feb 2020 14:54:28 +0900 Subject: [PATCH 11/16] Add FreqStrength to locate optimal position for D2D charging For D2D charge, user doesn't know the optimal location for charging. To improve this, support information about frequency strength to user so that they can adjust device charging position. Change-Id: Id002cc62b1aaf37d31328fcc47e0ef3368a0a20f Signed-off-by: Youngjae Cho --- src/auto-test/battery.c | 123 ++++++++++++++++++++++++--------------------- src/battery/power-supply.c | 51 ++++++++++++++++--- src/battery/power-supply.h | 3 ++ 3 files changed, 114 insertions(+), 63 deletions(-) diff --git a/src/auto-test/battery.c b/src/auto-test/battery.c index 4ef6fe8..7bd4597 100644 --- a/src/auto-test/battery.c +++ b/src/auto-test/battery.c @@ -48,6 +48,10 @@ #define PRESENT_ABNORMAL "0" #define PRESENT_NORMAL "1" +#define FREQ_STRENGTH_LEVEL_0 "0" +#define FREQ_STRENGTH_LEVEL_1 "50" +#define FREQ_STRENGTH_LEVEL_2 "100" + #define DEFAULT_LOWBATLEVEL 15 #define S_ENTER 1 @@ -61,62 +65,68 @@ static struct power_supply_type { char *health; char *online; char *present; + char *freq_strength; char *name; } power_supply_types[] = { - {"norm", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, - {"norm", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, - {"norm", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"heat1", S_ENTER, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, - {"heat1", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(H) BEFORE CHARGE"}, - {"heat1", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, - {"heat1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"heat2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, - {"heat2", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(H) AFTER CHARGE"}, - {"heat2", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, - {"heat2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"cold1", S_ENTER, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, - {"cold1", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(L) BEFORE CHARGE"}, - {"cold1", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, - {"cold1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"cold2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, - {"cold2", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(L) AFTER CHARGE"}, - {"cold2", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, - {"cold2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"ovp", S_ENTER, "100", DISCHARGE_NAME, OVERVOLT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "OVP"}, - {"ovp", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"pres1", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, NULL}, - {"pres1", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, "PRESENT BEFORE CHARGE"}, - {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, "DISCHARGE"}, - {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"pres2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, - {"pres2", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, "PRESENT AFTER CHARGE"}, - {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, "DISCHARGE"}, - {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ - - {"bat15", S_ENTER, "15", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 15%"}, /* lowbat 15% */ - {"bat15", S_LEAVE, "15", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 15%"}, - {"bat5", S_ENTER, "5", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 5%"}, /* lowbat 5% */ - {"bat5", S_LEAVE, "5", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 5%"}, - {"bat3", S_ENTER, "3", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 3%"}, /* lowbat 3% */ - {"bat3", S_LEAVE, "3", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 3%"}, - {"bat1", S_ENTER, "1", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 1%"}, /* lowbat 1% */ - {"bat1", S_LEAVE, "1", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 1%"}, - - {"ta", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, /* charging */ - {"ta", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"},/* discharging */ - - {"full", S_ENTER, "100", CHARGEFULL_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, /* full */ - {"full", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"},/* discharging */ - - {"capa", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "CAPACITY"},/* discharging */ - {"capa", S_LEAVE, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CAPACITY"},/* charging */ + {"norm", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CHARGE"}, + {"norm", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"norm", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"heat1", S_ENTER, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"heat1", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "HEALTH(H) BEFORE CHARGE"}, + {"heat1", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"heat1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"heat2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"heat2", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "HEALTH(H) AFTER CHARGE"}, + {"heat2", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"heat2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"cold1", S_ENTER, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"cold1", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "HEALTH(L) BEFORE CHARGE"}, + {"cold1", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"cold1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"cold2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"cold2", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "HEALTH(L) AFTER CHARGE"}, + {"cold2", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"cold2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"ovp", S_ENTER, "100", DISCHARGE_NAME, OVERVOLT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "OVP"}, + {"ovp", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"pres1", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"pres1", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, FREQ_STRENGTH_LEVEL_0, "PRESENT BEFORE CHARGE"}, + {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"pres2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, + {"pres2", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, FREQ_STRENGTH_LEVEL_0, "PRESENT AFTER CHARGE"}, + {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, + {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, NULL}, /* init */ + + {"bat15", S_ENTER, "15", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 15%"}, /* lowbat 15% */ + {"bat15", S_LEAVE, "15", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 15%"}, + {"bat5", S_ENTER, "5", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 5%"}, /* lowbat 5% */ + {"bat5", S_LEAVE, "5", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 5%"}, + {"bat3", S_ENTER, "3", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 3%"}, /* lowbat 3% */ + {"bat3", S_LEAVE, "3", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 3%"}, + {"bat1", S_ENTER, "1", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 1%"}, /* lowbat 1% */ + {"bat1", S_LEAVE, "1", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "LOWBAT 1%"}, + + {"ta", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CHARGE"}, /* charging */ + {"ta", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"},/* discharging */ + + {"full", S_ENTER, "100", CHARGEFULL_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CHARGE"}, /* full */ + {"full", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"},/* discharging */ + + {"capa", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CAPACITY"},/* discharging */ + {"capa", S_LEAVE, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CAPACITY"},/* charging */ + + {"freq", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "CHARGE"}, + {"freq", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_1, "FREQ LEVEL 1 AFTER CHARGE"}, + {"freq", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_2, "FREQ LEVEL 2 AFTER CHARGE"}, + {"freq", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, FREQ_STRENGTH_LEVEL_0, "DISCHARGE"}, /* init */ }; @@ -336,13 +346,14 @@ static bool set_battery_power_supply(int index) bool ret = FALSE; GVariant *var; - var = g_variant_new("(sisssss)", POWER_SUBSYSTEM, + var = g_variant_new("(sissssss)", POWER_SUBSYSTEM, 5, power_supply_types[index].capacity, power_supply_types[index].charge_status, power_supply_types[index].health, power_supply_types[index].online, - power_supply_types[index].present); + power_supply_types[index].present, + power_supply_types[index].freq_strength); _I("C(%s , %s) P(%s) STATUS(%s) HEALTH(%s)", power_supply_types[index].capacity, power_supply_types[index].online, diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 4e8bbcf..1b60cf2 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -69,6 +69,7 @@ #define CHARGER_WIRELESS_TYPE_BT 10 #define CHARGER_WIRELESS_TYPE_3G 22 #define CHARGER_INCOMPATIBLE_TYPE 11 +#define CHARGER_D2D_TYPE 110 #define WIRELESS_CHARGER_CONNECTED 2 #define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" @@ -660,6 +661,8 @@ static bool update_online(void) battery.online_type = CHARGER_TYPE_WIRELESS; else if (battery.online == CHARGER_INCOMPATIBLE_TYPE) battery.online_type = CHARGER_TYPE_INCOMPATIBLE; + else if (battery.online == CHARGER_D2D_TYPE) + battery.online_type = CHARGER_TYPE_D2D; else battery.online_type = CHARGER_TYPE_WIRE; @@ -736,6 +739,15 @@ static void check_misc_status(const char *env_value) battery.misc = atoi(env_value); } +static void check_freq_strength_status(const char *env_value) +{ + if (env_value == NULL) { + battery.freq_strength = 0; + return; + } + battery.freq_strength = atoi(env_value); +} + static void check_online_status(const char *env_value) { if (env_value == NULL) @@ -861,6 +873,10 @@ static void process_power_supply(void *data) if (power_supply_broadcast(CHARGE_MISC_EVENT_SIGNAL, battery.misc) < 0) broadcasted = false; + if (old_battery.freq_strength != battery.freq_strength) + if (power_supply_broadcast(CHARGE_FREQ_STRENGTH_SIGNAL, battery.freq_strength) < 0) + broadcasted = false; + if (old_battery.charge_full != battery.charge_full) noti_batt_full(); @@ -869,8 +885,9 @@ static void process_power_supply(void *data) old_battery.capacity != battery.capacity || old_battery.health != battery.health || old_battery.misc != battery.misc || + old_battery.freq_strength != battery.freq_strength || old_battery.online_type != battery.online_type) - _I("Signal(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d : %s)", + _I("Signal(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d : %s) %s(%d)", broadcasted, CHARGER_STATUS_SIGNAL, online_status, CHARGER_TYPE_SIGNAL, battery.online_type, @@ -879,7 +896,8 @@ static void process_power_supply(void *data) CHARGE_CAPACITY_SIGNAL, battery.capacity, CHARGE_LEVEL_SIGNAL, battery.charging_level, CHARGE_MISC_EVENT_SIGNAL, battery.misc, - CHARGE_HEALTH_SIGNAL, battery.health, battery.health_s); + CHARGE_HEALTH_SIGNAL, battery.health, battery.health_s, + CHARGE_FREQ_STRENGTH_SIGNAL, battery.freq_strength); old_battery.capacity = battery.capacity; old_battery.charging_level = battery.charging_level; @@ -892,6 +910,7 @@ static void process_power_supply(void *data) old_battery.health = battery.health; old_battery.misc = battery.misc; + old_battery.freq_strength = battery.freq_strength; old_battery.present = battery.present; snprintf(old_battery.health_s, sizeof(old_battery.health_s), "%s", battery.health_s); @@ -976,7 +995,8 @@ static int battery_state(struct battery_info *info) prev_status.charge_now == battery.charge_now && prev_status.health == battery.health && prev_status.present == battery.present && - prev_status.online == battery.online) + prev_status.online == battery.online && + prev_status.freq_strength == battery.freq_strength) return 0; prev_status.capacity = battery.capacity; @@ -986,6 +1006,7 @@ static int battery_state(struct battery_info *info) prev_status.health = battery.health; prev_status.present = battery.present; prev_status.online = battery.online; + prev_status.freq_strength = battery.freq_strength; _I("%s(%s) %s(%d) Capa(%d) Hth(%s,%d) Pres(%d) Curr(%d,%d)", info->status, @@ -1037,6 +1058,7 @@ static void battery_changed(struct battery_info *info, void *data) battery.current_now = info->current_now; battery.current_average = info->current_average; battery.temperature = info->temperature; + battery.freq_strength = info->freq_strength; ret = battery_state(info); if (ret != 1) @@ -1244,6 +1266,14 @@ static GVariant *dbus_get_misc(GDBusConnection *conn, return g_variant_new("(i)", ret); } + +static GVariant *dbus_get_freq_strength(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + return g_variant_new("(i)", battery.freq_strength); +} + static GVariant *dbus_power_supply_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -1252,7 +1282,7 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, int ret = 0; int argc = 0; char *type_str; - char *argv[6]; + char *argv[7]; g_variant_get(param, "(sissssss)", &type_str, &argc, @@ -1261,7 +1291,8 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, &argv[2], &argv[3], &argv[4], - &argv[5]); + &argv[5], + &argv[6]); if (argc < 0) { _E("Message is invalid."); @@ -1281,6 +1312,7 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, check_online_status(argv[3]); check_present_status(argv[4]); check_misc_status(argv[5]); + check_freq_strength_status(argv[6]); if (battery_dev) battery_changed(NULL, NULL); snprintf(battery.status_s, sizeof(battery.status_s), "%s", @@ -1288,7 +1320,7 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, (battery.charge_now == CHARGER_ABNORMAL) ? "Not Charging" : (battery.charge_full == CHARGING_FULL) ? "Full" : "Discharging"); - _I("%s(%d) %s(f:%d n:%d) %s(%d) %s(%d) %s(%d) %s(%d)", + _I("%s(%d) %s(f:%d n:%d) %s(%d) %s(%d) %s(%d) %s(%d) %s(%d)", argv[0], battery.capacity, argv[1], @@ -1301,7 +1333,9 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, argv[4], battery.present, argv[5], - battery.misc); + battery.misc, + argv[6], + battery.freq_strength); if (battery.online > POWER_SUPPLY_TYPE_BATTERY) power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON); @@ -1317,6 +1351,7 @@ out: g_free(argv[3]); g_free(argv[4]); g_free(argv[5]); + g_free(argv[6]); return g_variant_new("(i)", ret); } @@ -1420,6 +1455,7 @@ static const dbus_method_s dbus_methods[] = { { "ChargerCharging", "i", "i", dbus_charger_charging }, { CHARGE_BATTERY_PROPERTIES, NULL, "iiiiii", dbus_get_battery_props }, { CHARGE_MISC_EVENT_SIGNAL, NULL, "i", dbus_get_misc }, + { CHARGE_FREQ_STRENGTH_SIGNAL, NULL, "i", dbus_get_freq_strength} }; static const dbus_interface_u dbus_interface = { @@ -1740,6 +1776,7 @@ static void power_supply_init(void *data) battery.capacity = -1; battery.charger_charging = CHARGER_ENABLED; battery.misc = MISC_NONE; + battery.freq_strength = 0; /* process check battery timer until booting done */ power_supply_timer_start(); diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h index 567ed07..34bb993 100644 --- a/src/battery/power-supply.h +++ b/src/battery/power-supply.h @@ -89,6 +89,7 @@ enum charger_type { CHARGER_TYPE_WIRE, CHARGER_TYPE_WIRELESS, CHARGER_TYPE_INCOMPATIBLE, + CHARGER_TYPE_D2D, }; struct battery_status { @@ -108,6 +109,7 @@ struct battery_status { int charging_level; int charger_charging; int misc; + int freq_strength; char status_s[32]; char health_s[32]; char power_source_s[32]; @@ -127,5 +129,6 @@ int power_supply_broadcast(char *sig, int status); #define CHARGE_FULL_SIGNAL "IsFull" #define CHARGE_BATTERY_PROPERTIES "BatteryProperties" #define CHARGE_MISC_EVENT_SIGNAL "MiscEvent" +#define CHARGE_FREQ_STRENGTH_SIGNAL "FreqStrength" #endif /* __POWER_SUPPLY_H__ */ -- 2.7.4 From f09ab346ee1fa15bb05ba7687e44bc0270393882 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Fri, 21 Feb 2020 12:47:17 +0900 Subject: [PATCH 12/16] sync usb mode index with vconf Change-Id: Ifa79010dd982e48df995a02a6c6dc519c0e40733 --- src/usb/usb-state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 6470f41..02d20fa 100644 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -62,15 +62,15 @@ static const struct _usb_mode_mapping_table { {SET_USB_NONE, USB_FUNCTION_NONE}, {SET_USB_RNDIS, USB_FUNCTION_RNDIS}, {SET_USB_RNDIS_DIAG, USB_FUNCTION_RNDIS | USB_FUNCTION_DIAG}, - {11, USB_FUNCTION_DIAG | USB_FUNCTION_RMNET}, /* SET_USB_DIAG_RMNET */ - {12, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM}, /* SET_USB_ACM_SDB_DM */ + {SET_USB_DIAG_RMNET, USB_FUNCTION_DIAG | USB_FUNCTION_RMNET}, + {SET_USB_ACM_SDB_DM, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM}, {SET_USB_SDB_DIAG, USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG}, {SET_USB_DIAG_SDB, USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG}, {SET_USB_RNDIS_SDB, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, {SET_USB_RNDIS_TETHERING, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, - {13, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, /* SET_USB_RNDIS_SDB_ACM */ + {SET_USB_RNDIS_SDB_ACM, USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_RNDIS}, }; unsigned int get_mode_bitmap_from_vconf(int mode_v) -- 2.7.4 From ea0ac6abce073b155741c6e2c1388d4270896167 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 20 Feb 2020 17:40:45 +0900 Subject: [PATCH 13/16] Add strings for LCDON triggered from bezel/backkey Change-Id: I2dc3a91991ee318b5419822f8f161d648820715d Signed-off-by: Youngjae Cho --- plugins/iot/display/key-filter.c | 2 +- plugins/mobile/display/key-filter.c | 2 +- plugins/tv/display/key-filter.c | 2 +- plugins/wearable/display/core.c | 6 ++++++ plugins/wearable/display/key-filter.c | 2 +- src/core/devices.h | 19 ++++++++++--------- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/plugins/iot/display/key-filter.c b/plugins/iot/display/key-filter.c index a046080..71ee649 100644 --- a/plugins/iot/display/key-filter.c +++ b/plugins/iot/display/key-filter.c @@ -445,7 +445,7 @@ static int process_back_key(struct input_event *pinput) int ignore = true; if (pinput->value == KEY_PRESSED) { - switch_on_lcd(LCD_ON_BY_POWER_KEY); + switch_on_lcd(LCD_ON_BY_BACK_KEY); _I("back key pressed"); ignore = false; } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 7af0516..0da1315 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -434,7 +434,7 @@ static int process_back_key(struct input_event *pinput) int ignore = true; if (pinput->value == KEY_PRESSED) { - switch_on_lcd(LCD_ON_BY_POWER_KEY); + switch_on_lcd(LCD_ON_BY_BACK_KEY); _I("back key pressed"); ignore = false; } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index c631ae8..d67d3a6 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -445,7 +445,7 @@ static int process_back_key(struct input_event *pinput) int ignore = true; if (pinput->value == KEY_PRESSED) { - switch_on_lcd(LCD_ON_BY_POWER_KEY); + switch_on_lcd(LCD_ON_BY_BACK_KEY); _I("back key pressed"); ignore = false; } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 7a04a38..2e67c3d 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -77,8 +77,10 @@ #define GESTURE_STR "gesture" #define POWER_KEY_STR "powerkey" +#define BACK_KEY_STR "backkey" #define TOUCH_STR "touch" #define EVENT_STR "event" +#define BEZEL_STR "bezel" #define TIMEOUT_STR "timeout" #define PROXI_STR "proximity" #define PALM_STR "palm" @@ -379,10 +381,14 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) str = GESTURE_STR; else if (flags & LCD_ON_BY_POWER_KEY) str = POWER_KEY_STR; + else if (flags & LCD_ON_BY_BACK_KEY) + str = BACK_KEY_STR; else if (flags & LCD_ON_BY_EVENT) str = EVENT_STR; else if (flags & LCD_ON_BY_TOUCH) str = TOUCH_STR; + else if (flags & LCD_ON_BY_BEZEL) + str = BEZEL_STR; else str = UNKNOWN_STR; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 1f4734c..920674d 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -434,7 +434,7 @@ static int process_back_key(struct input_event *pinput) int ignore = true; if (pinput->value == KEY_PRESSED) { - switch_on_lcd(LCD_ON_BY_POWER_KEY); + switch_on_lcd(LCD_ON_BY_BACK_KEY); _I("back key pressed"); ignore = false; } diff --git a/src/core/devices.h b/src/core/devices.h index 8a8f4cd..8e79009 100644 --- a/src/core/devices.h +++ b/src/core/devices.h @@ -33,15 +33,16 @@ enum device_flags { NORMAL_MODE = 0x00000001, AMBIENT_MODE = 0x00000002, FORCE_OFF_MODE = 0x00000004, - CORE_LOGIC_MODE = 0x00010000, - TOUCH_SCREEN_OFF_MODE = 0x00020000, - LCD_PANEL_OFF_MODE = 0x00040000, - LCD_PHASED_TRANSIT_MODE = 0x00080000, - LCD_ON_BY_GESTURE = 0x00100000, - LCD_ON_BY_POWER_KEY = 0x00200000, - LCD_ON_BY_EVENT = 0x00400000, - LCD_ON_BY_TOUCH = 0x00800000, - LCD_ON_BY_BEZEL = 0x01000000, + CORE_LOGIC_MODE = 0x00001000, + TOUCH_SCREEN_OFF_MODE = 0x00002000, + LCD_PANEL_OFF_MODE = 0x00004000, + LCD_PHASED_TRANSIT_MODE = 0x00008000, + LCD_ON_BY_GESTURE = 0x00010000, + LCD_ON_BY_POWER_KEY = 0x00020000, + LCD_ON_BY_BACK_KEY = 0x00040000, + LCD_ON_BY_EVENT = 0x00080000, + LCD_ON_BY_TOUCH = 0x00100000, + LCD_ON_BY_BEZEL = 0x00200000, LCD_OFF_BY_POWER_KEY = 0x02000000, LCD_OFF_BY_TIMEOUT = 0x04000000, LCD_OFF_BY_EVENT = 0x08000000, -- 2.7.4 From 0d2d371c811f14e28f09b0bdb8b295f93f0d8461 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 21 Feb 2020 14:49:59 +0900 Subject: [PATCH 14/16] Add LCD_OFF_COMPLETE notifier DEVICE_NOTIFIER_LCD_OFF_COMPLETE is used for disabling lbm on LCDOFF. Change-Id: I88064ef316dd69623be197e5824c168c0069bf74 Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 2 ++ plugins/mobile/display/core.c | 2 ++ plugins/tv/display/core.c | 2 ++ plugins/wearable/display/core.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 7f1ed5c..33265e1 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -600,6 +600,8 @@ inline void lcd_off_procedure(enum device_flags flag) broadcast_lcd_off_late(flags); else broadcast_lcd_off(SIGNAL_POST, flags); + + device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); } void set_stay_touchscreen_off(int val) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 1dee4df..163a1f0 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -608,6 +608,8 @@ inline void lcd_off_procedure(enum device_flags flag) broadcast_lcd_off_late(flags); else broadcast_lcd_off(SIGNAL_POST, flags); + + device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); } void set_stay_touchscreen_off(int val) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 3d2ca7d..facb73f 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -600,6 +600,8 @@ inline void lcd_off_procedure(enum device_flags flag) broadcast_lcd_off_late(flags); else broadcast_lcd_off(SIGNAL_POST, flags); + + device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); } void set_stay_touchscreen_off(int val) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 2e67c3d..0e62786 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -614,6 +614,8 @@ inline void lcd_off_procedure(enum device_flags flag) broadcast_lcd_off_late(flags); else broadcast_lcd_off(SIGNAL_POST, flags); + + device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); } void set_stay_touchscreen_off(int val) -- 2.7.4 From 0235fd379f29a3eeb491561d31a9f29b63e5fc67 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 11 Feb 2020 21:10:34 +0900 Subject: [PATCH 15/16] add static keyword to locally used functions Change-Id: Ia9869628db2e6fe89f3a95d89894f4c31eeb9592 Signed-off-by: sanghyeok.oh --- plugins/wearable/display/hbm.c | 2 +- src/battery/battery-time.c | 2 +- src/control/control.c | 5 ++-- src/core/devices.c | 2 +- src/core/event-handler.c | 6 ++--- src/display/display-dbus.c | 58 +++++++++++++++++++++--------------------- src/extcon/cradle.c | 2 +- src/extcon/hdmi.c | 2 +- src/power/low-power.c | 6 ++--- src/proc/cpu-info.c | 2 +- src/time/time-handler.c | 2 +- src/touchscreen/touchscreen.c | 4 +-- src/usb/usb-dbus.c | 4 +-- 13 files changed, 48 insertions(+), 49 deletions(-) diff --git a/plugins/wearable/display/hbm.c b/plugins/wearable/display/hbm.c index 8ff1f4e..37b02e4 100644 --- a/plugins/wearable/display/hbm.c +++ b/plugins/wearable/display/hbm.c @@ -193,7 +193,7 @@ static int hbm_set_state_with_timeout(int hbm, int timeout) return 0; } -void hbm_check_timeout(void) +static void hbm_check_timeout(void) { struct timespec now; int ret; diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 7966247..4a74bef 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -352,7 +352,7 @@ static void end_battinfo_gathering(void) del_all_batt_node(B_CHARGING); } -GVariant * dbus_get_timetofull(GDBusConnection *conn, +static GVariant * dbus_get_timetofull(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/control/control.c b/src/control/control.c index 6aa82cd..7a1bd3e 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -114,7 +114,7 @@ static int get_control_handler(int argc, char **argv) return extcon_get_status(devices[i].name); } -GVariant *dbus_control_handler(GDBusConnection *conn, +static GVariant *dbus_control_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -145,8 +145,7 @@ out: return g_variant_new("(i)", ret); } - -GVariant *dbus_get_control_handler(GDBusConnection *conn, +static GVariant *dbus_get_control_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/core/devices.c b/src/core/devices.c index 69e0106..393e9da 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -80,7 +80,7 @@ int check_default(const struct device_ops *dev) return (dev == &default_ops); } -GVariant *dbus_device_list(GDBusConnection *conn, +static GVariant *dbus_device_list(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/core/event-handler.c b/src/core/event-handler.c index a4871b7..e5ecec4 100644 --- a/src/core/event-handler.c +++ b/src/core/event-handler.c @@ -28,7 +28,7 @@ static device_notifier_state_e state = DEVICE_NOTIFIER_STATE_STOP; -GVariant *dbus_start_event_handler(GDBusConnection *conn, +static GVariant *dbus_start_event_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -40,7 +40,7 @@ GVariant *dbus_start_event_handler(GDBusConnection *conn, return g_variant_new("(i)", 0); } -GVariant *dbus_stop_event_handler(GDBusConnection *conn, +static GVariant *dbus_stop_event_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -52,7 +52,7 @@ GVariant *dbus_stop_event_handler(GDBusConnection *conn, return g_variant_new("(i)", 0); } -GVariant *dbus_udev_event_handler(GDBusConnection *conn, +static GVariant *dbus_udev_event_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index c402aa1..bc1baac 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -69,7 +69,7 @@ #define EXPIRED_POPUP_COMM "_APP_COMM_" #define EXPIRED_POPUP_ID "_REQUEST_ID_" -GVariant *dbus_start(GDBusConnection *conn, +static GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -85,7 +85,7 @@ out: return dbus_handle_new_g_variant_tuple(); } -GVariant *dbus_stop(GDBusConnection *conn, +static GVariant *dbus_stop(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -101,7 +101,7 @@ out: return dbus_handle_new_g_variant_tuple(); } -GVariant *dbus_lockstate(GDBusConnection *conn, +static GVariant *dbus_lockstate(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -189,7 +189,7 @@ out: return g_variant_new("(i)", ret); } -GVariant *dbus_unlockstate(GDBusConnection *conn, +static GVariant *dbus_unlockstate(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -247,7 +247,7 @@ out: return g_variant_new("(i)", ret); } -GVariant *dbus_changestate(GDBusConnection *conn, +static GVariant *dbus_changestate(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -328,7 +328,7 @@ out: return g_variant_new("(i)", ret); } -GVariant *dbus_getdisplaycount(GDBusConnection *conn, +static GVariant *dbus_getdisplaycount(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -339,7 +339,7 @@ GVariant *dbus_getdisplaycount(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_getmaxbrightness(GDBusConnection *conn, +static GVariant *dbus_getmaxbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -356,7 +356,7 @@ GVariant *dbus_getmaxbrightness(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_setmaxbrightness(GDBusConnection *conn, +static GVariant *dbus_setmaxbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -367,7 +367,7 @@ GVariant *dbus_setmaxbrightness(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_getbrightness(GDBusConnection *conn, +static GVariant *dbus_getbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -394,7 +394,7 @@ GVariant *dbus_getbrightness(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_setbrightness(GDBusConnection *conn, +static GVariant *dbus_setbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -459,7 +459,7 @@ error: return g_variant_new("(i)", ret); } -GVariant *dbus_holdbrightness(GDBusConnection *conn, +static GVariant *dbus_holdbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -508,7 +508,7 @@ error: return g_variant_new("(i)", ret); } -GVariant *dbus_releasebrightness(GDBusConnection *conn, +static GVariant *dbus_releasebrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -580,7 +580,7 @@ error: return g_variant_new("(i)", ret); } -GVariant *dbus_setrefreshrate(GDBusConnection *conn, +static GVariant *dbus_setrefreshrate(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -616,7 +616,7 @@ error: return g_variant_new("(i)", ret); } -GVariant *dbus_setautobrightnessmin(GDBusConnection *conn, +static GVariant *dbus_setautobrightnessmin(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -648,7 +648,7 @@ error: return g_variant_new("(i)", ret); } -GVariant *dbus_setlcdtimeout(GDBusConnection *conn, +static GVariant *dbus_setlcdtimeout(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -675,7 +675,7 @@ GVariant *dbus_setlcdtimeout(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_lockscreenbgon(GDBusConnection *conn, +static GVariant *dbus_lockscreenbgon(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -697,7 +697,7 @@ GVariant *dbus_lockscreenbgon(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_dumpmode(GDBusConnection *conn, +static GVariant *dbus_dumpmode(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -726,7 +726,7 @@ GVariant *dbus_dumpmode(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_savelog(GDBusConnection *conn, +static GVariant *dbus_savelog(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -734,7 +734,7 @@ GVariant *dbus_savelog(GDBusConnection *conn, return dbus_handle_new_g_variant_tuple(); } -GVariant *dbus_powerkeyignore(GDBusConnection *conn, +static GVariant *dbus_powerkeyignore(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -749,7 +749,7 @@ GVariant *dbus_powerkeyignore(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, +static GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -763,7 +763,7 @@ GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_customlcdon(GDBusConnection *conn, +static GVariant *dbus_customlcdon(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -777,7 +777,7 @@ GVariant *dbus_customlcdon(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_customlcdoff(GDBusConnection *conn, +static GVariant *dbus_customlcdoff(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -805,7 +805,7 @@ out: return g_variant_new("(i)", ret); } -GVariant *dbus_changestatebyreason(GDBusConnection *conn, +static GVariant *dbus_changestatebyreason(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -826,7 +826,7 @@ GVariant *dbus_changestatebyreason(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, +static GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -840,7 +840,7 @@ GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, +static GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -854,7 +854,7 @@ GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_actorcontrol(GDBusConnection *conn, +static GVariant *dbus_actorcontrol(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -874,7 +874,7 @@ GVariant *dbus_actorcontrol(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_getcustombrightness(GDBusConnection *conn, +static GVariant *dbus_getcustombrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -929,7 +929,7 @@ static int get_command(pid_t pid, char *comm, size_t len) return 0; } -GVariant *dbus_locktimeout_expired(GDBusConnection *conn, +static GVariant *dbus_locktimeout_expired(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -1056,7 +1056,7 @@ out: free(item); } -GVariant *dbus_locktimeout_input(GDBusConnection *conn, +static GVariant *dbus_locktimeout_input(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 2f37d04..06c9152 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -100,7 +100,7 @@ static int display_changed(void *data) return 0; } -GVariant *dbus_cradle_handler(GDBusConnection *conn, +static GVariant *dbus_cradle_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 1a3b2f6..08c89e9 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -95,7 +95,7 @@ static int display_changed(void *data) return 0; } -GVariant *dbus_hdmi_handler(GDBusConnection *conn, +static GVariant *dbus_hdmi_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/power/low-power.c b/src/power/low-power.c index f71315a..0061bec 100644 --- a/src/power/low-power.c +++ b/src/power/low-power.c @@ -101,7 +101,7 @@ out: return done; } -GVariant *dbus_low_power_start(GDBusConnection *conn, +static GVariant *dbus_low_power_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -124,7 +124,7 @@ GVariant *dbus_low_power_start(GDBusConnection *conn, out: return g_variant_new("(i)", ret); } -GVariant *dbus_low_power_stop(GDBusConnection *conn, +static GVariant *dbus_low_power_stop(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -148,7 +148,7 @@ out: return g_variant_new("(i)", ret); } -GVariant *dbus_low_power_get_state(GDBusConnection *conn, +static GVariant *dbus_low_power_get_state(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/proc/cpu-info.c b/src/proc/cpu-info.c index 79f437f..cbf3db2 100644 --- a/src/proc/cpu-info.c +++ b/src/proc/cpu-info.c @@ -112,7 +112,7 @@ static int get_revision(char *rev, int len) return 0; } -GVariant *dbus_revision_handler(GDBusConnection *conn, +static GVariant *dbus_revision_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 6ffebd1..964783b 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -301,7 +301,7 @@ out: return G_SOURCE_CONTINUE; } -GVariant *dbus_time_handler(GDBusConnection *conn, +static GVariant *dbus_time_handler(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 23b4090..a452ec7 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -255,7 +255,7 @@ static int touchscreen_dump(FILE *fp, int mode, void *dump_data) return 0; } -GVariant *dbus_touchscreen_enable(GDBusConnection *conn, +static GVariant *dbus_touchscreen_enable(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -265,7 +265,7 @@ GVariant *dbus_touchscreen_enable(GDBusConnection *conn, return g_variant_new("(i)", ret); } -GVariant *dbus_touchscreen_disable(GDBusConnection *conn, +static GVariant *dbus_touchscreen_disable(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c index 69b118a..35b2c2f 100644 --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -153,7 +153,7 @@ static void change_usb_client_mode(GDBusConnection *conn, } /* dbus methods */ -GVariant *get_usb_client_state(GDBusConnection *conn, +static GVariant *get_usb_client_state(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -164,7 +164,7 @@ GVariant *get_usb_client_state(GDBusConnection *conn, return g_variant_new("(u)", state); } -GVariant *get_usb_client_mode(GDBusConnection *conn, +static GVariant *get_usb_client_mode(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { -- 2.7.4 From 5e0411aa7b79261fc314a53dc03fa6a4a297c7ab Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 24 Feb 2020 14:06:30 +0900 Subject: [PATCH 16/16] Removed "route add" in rndis usb mode Ifconfig command will also automatically add route information to the routing table in the kernel. So if you run "route add" additionally, you have duplicate routing table entries. sh-3.2# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0 cns1.sec.samsun 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0 cns2.sec.samsun 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0 192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0 192.168.0.1 * 255.255.255.255 UH 0 0 0 wlan0 192.168.129.0 * 255.255.255.0 U 0 0 0 usb0 <== here 192.168.129.0 * 255.255.255.0 U 0 0 0 usb0 <== here Change-Id: I96c290ce5de1da81ff7b9f99cfaefc8a64b618ac --- scripts/rndis.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/rndis.sh b/scripts/rndis.sh index eb38cdb..66f8294 100755 --- a/scripts/rndis.sh +++ b/scripts/rndis.sh @@ -24,21 +24,12 @@ else fi ######################################################################################### -IP1=`echo $IP_ADDR | cut -d"." -f1` -IP2=`echo $IP_ADDR | cut -d"." -f2` -IP3=`echo $IP_ADDR | cut -d"." -f3` -NETWORK=$IP1"."$IP2"."$IP3"."0 - -######################################################################################### echo "rndis network inteface =" $IFNAME echo "rndis ip address =" $IP_ADDR -echo "rndis network =" $NETWORK if [ x$1 == "xstart" ] then /sbin/ifconfig $IFNAME $IP_ADDR up - /sbin/route add -net $NETWORK netmask 255.255.255.0 dev $IFNAME else - /sbin/route del -net $NETWORK netmask 255.255.255.0 dev $IFNAME /sbin/ifconfig $IFNAME down fi -- 2.7.4