From d015842e4413445707556227a50215e341b905b6 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 7 Jun 2022 14:31:25 +0900 Subject: [PATCH] battery: remove unused variable, charger_charging Change-Id: Ic7ea822a41b9cc1a1561d6b1a2c40da648220a3d Signed-off-by: Youngjae Cho --- src/battery/lowbat-handler.c | 8 +++--- src/battery/power-supply.c | 49 ----------------------------------- src/battery/power-supply.h | 6 ----- tests/auto-test/test_dbus_interface.c | 25 ------------------ 4 files changed, 3 insertions(+), 85 deletions(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index a0d5b65..54b85f5 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -497,9 +497,7 @@ static int lowbat_process(int bat_percent, void *ad) } if (new_bat_capacity <= battery_info.realoff) { - if (battery->charge_now == CHARGER_CHARGING || battery->charger_charging == CHARGER_DISABLED) { - _I("Skip lowbat poweroff during test (c:%d charge:%d online:%d charger_charging:%d)", - battery->capacity, battery->charge_now, battery->charger_connected, battery->charger_charging); + if (battery->charge_now == CHARGER_CHARGING) { new_bat_state = battery_info.poweroff; if (vconf_state != VCONFKEY_SYSMAN_BAT_POWER_OFF) status = VCONFKEY_SYSMAN_BAT_POWER_OFF; @@ -542,8 +540,8 @@ static int lowbat_process(int bat_percent, void *ad) if (low_bat_skip_cnt >= RETRY_MAX) { new_bat_state = battery_info.realoff; status = VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF; - _I("Go to real poweroff inspite of charging (c:%d charge:%d online:%d charger_charging %d current now %d)", - battery->capacity, battery->charge_now, battery->charger_connected, battery->charger_charging, battery->current_now); + _I("Go to real poweroff inspite of charging (c:%d charge:%d online:%d current_now:%d)", + battery->capacity, battery->charge_now, battery->charger_connected, battery->current_now); low_bat_skip_cnt = 0; } else if (battery->current_now <= MIN_INOW_VALUE) { low_bat_skip_cnt++; diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 7a98161..7d33f84 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -326,7 +326,6 @@ int power_supply_broadcast(char *sig, int status) static int old; static char sig_old[32]; int ret; - int chg_on; if (!sig) { _E("There is no signal name."); @@ -339,18 +338,6 @@ int power_supply_broadcast(char *sig, int status) old = status; - if (battery.charger_charging == CHARGER_DISABLED) { - ret = sys_get_int(CHARGER_CHARGE_ON_NODE, &chg_on); - if (ret == 0 && battery.charger_charging != chg_on) { - ret = sys_set_int(CHARGER_CHARGE_ON_NODE, battery.charger_charging); - _I("%s to change status with %d", ((ret == 0) ? "success" : "fail"), battery.charger_charging); - } - if (strncmp(sig, CHARGE_NOW_SIGNAL, strlen(CHARGE_NOW_SIGNAL)) == 0) { - _I("Skip signal while charger disabled."); - return 0; - } - } - snprintf(sig_old, sizeof(sig_old), "%s", sig); ret = gdbus_signal_emit(NULL, @@ -1112,40 +1099,6 @@ static GVariant *dbus_get_charger_type(GDBusConnection *conn, return g_variant_new("(i)", type); } -static GVariant *dbus_charger_charging(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) -{ - int ret = 0; - int val; - int chg_on; - - g_variant_get(param, "(i)", &val); - - if (val != CHARGER_ENABLED && val != CHARGER_DISABLED) { - _E("There is no valid input: %d", battery.charger_charging); - ret = -EINVAL; - goto out; - } - if (battery.charger_connected == 0) { - _E("There is no charger(%d) input(%d).", battery.charger_connected, battery.charger_charging); - ret = -EACCES; - goto out; - } - ret = sys_get_int(CHARGER_CHARGE_ON_NODE, &chg_on); - 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); - } -out: - return g_variant_new("(i)", ret); -} - static GVariant *dbus_get_charge_now(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -1445,7 +1398,6 @@ static const dbus_method_s dbus_methods[] = { { GET_POWER_SUBSYSTEM, NULL, "iiiiiiisiiiii", dbus_get_power_supply_handler }, { "GetBatteryInfo", NULL, "isssiiiiiiii", dbus_get_battery_info }, { CHARGER_TYPE_SIGNAL, NULL, "i", dbus_get_charger_type }, - { "ChargerCharging", "i", "i", dbus_charger_charging }, { CHARGE_BATTERY_PROPERTIES, NULL, "iiiiii", dbus_get_battery_props }, { CHARGE_MISC_EVENT_SIGNAL, NULL, "i", dbus_get_misc }, }; @@ -1652,7 +1604,6 @@ static void power_supply_init(void *data) memset(&battery, 0, sizeof(struct battery_status)); memset(&old_battery, 0, sizeof(struct battery_status)); - battery.charger_charging = CHARGER_ENABLED; battery.misc = MISC_NONE; battery.charger_connected = -1; diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h index 6e41b3d..c85cb90 100644 --- a/src/battery/power-supply.h +++ b/src/battery/power-supply.h @@ -80,11 +80,6 @@ enum battery_noti_status { DEVICE_NOTI_ON, }; -enum charger_charging_status { - CHARGER_DISABLED, - CHARGER_ENABLED, -}; - enum charger_type { CHARGER_TYPE_NONE = 0, CHARGER_TYPE_AC, @@ -107,7 +102,6 @@ struct battery_status { int current_now; int current_average; int capacity_level; - int charger_charging; int misc; char status_s[32]; char health_s[32]; diff --git a/tests/auto-test/test_dbus_interface.c b/tests/auto-test/test_dbus_interface.c index 92d7404..f1e2a1e 100644 --- a/tests/auto-test/test_dbus_interface.c +++ b/tests/auto-test/test_dbus_interface.c @@ -554,31 +554,6 @@ GVariant * test_deviced_Battery_BatteryProperties(void) return reply; } -// ChargerCharging : in i, out i - -gint test_deviced_Battery_ChargerCharging(gint param1) -{ - gint val1; - GVariant *reply; - int ret_dbus; - - ret_dbus = gdbus_call_sync_with_reply("org.tizen.system.deviced", - "/Org/Tizen/System/DeviceD/Battery", - "org.tizen.system.deviced.Battery", - "ChargerCharging", - g_variant_new("(i)", param1), - &reply);; - if (ret_dbus < 0) { - _E("failed ChargerCharging"); - return 0; - } - - g_variant_get(reply, "(i)", &val1); - g_variant_unref(reply); - - return val1; -} - // ChargerType : in , out i gint test_deviced_Battery_ChargerType(void) -- 2.7.4