summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaeyoung <ty317.kim@samsung.com>2016-10-24 16:49:50 +0900
committertaeyoung <ty317.kim@samsung.com>2016-10-24 16:49:50 +0900
commit2c2c7b5a4a09d8193963f19c94477665ab630df2 (patch)
tree84c47bbb43d04a3c47096b3f2d068355bc701766
parentf83ddb614cc9928617731f41f0d01988973b38c1 (diff)
downloaddeviced-2c2c7b5a4a09d8193963f19c94477665ab630df2.tar.gz
deviced-2c2c7b5a4a09d8193963f19c94477665ab630df2.tar.bz2
deviced-2c2c7b5a4a09d8193963f19c94477665ab630df2.zip
battery: remove OAL related codes
The function device-set/get-property() for OAL are not supported anymore. Thus they are changed to use battery variable which store battery status. Change-Id: I03311ede1781cf056d82b5474324b5f2b12d83a5 Signed-off-by: taeyoung <ty317.kim@samsung.com>
-rw-r--r--src/battery/battery-time.c90
1 files changed, 5 insertions, 85 deletions
diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c
index 1a243def..01b768ce 100644
--- a/src/battery/battery-time.c
+++ b/src/battery/battery-time.c
@@ -29,9 +29,9 @@
#include "core/log.h"
#include "core/edbus-handler.h"
#include "display/setting.h"
+#include "power_supply.h"
#define CHARGING_STATE(x) ((x) & CHRGR_FLAG)
-#define FULL_CAPACITY_RAW (10000)
#define FULL_CAPACITY (100)
#define BATTERY_FULL_THRESHOLD (98)
#define MAX_COUNT_UNCHARGING (10)
@@ -42,8 +42,6 @@
#define SIGNAL_TIMETOFULL "TimeToFull"
#define SIGNAL_TIMETOEMPTY "TimeToEmpty"
-int (*get_battery_capacity_cb)(void);
-
enum state_b {
B_UNCHARGING = 0,
B_CHARGING = 1,
@@ -69,64 +67,12 @@ static struct Batt_node *batt_head[B_END];
static struct Batt_node *batt_tail[B_END];
static int MAX_VALUE_COUNT[B_END] = {MAX_COUNT_UNCHARGING, MAX_COUNT_CHARGING};
static double avg_factor[B_END] = {-1.0, -1.0};
-static int full_capacity;
static int old_capacity;
static int charging_state;
extern int system_wakeup_flag;
static int time_to_full = -1;
static int time_to_empty = -1;
-static int get_battery_capacity(void)
-{
- int value = 0;
- int ret = -1;
-
- ret = device_get_property(DEVICE_TYPE_POWER,
- PROP_POWER_CAPACITY, &value);
-
- if (ret < 0)
- return ret;
-
- if (value < 0)
- return 0;
-
- return value;
-}
-
-static int get_battery_capacity_raw(void)
-{
- int value = 0;
- int ret = -1;
-
- ret = device_get_property(DEVICE_TYPE_POWER,
- PROP_POWER_CAPACITY_RAW, &value);
-
- if (ret < 0)
- return ret;
-
- if (value < 0)
- return 0;
-
- return value;
-}
-
-static int get_battery_charge_full(void)
-{
- int value = 0;
- int ret = -1;
-
- ret = device_get_property(DEVICE_TYPE_POWER,
- PROP_POWER_CHARGE_FULL, &value);
-
- if (ret < 0)
- return ret;
-
- if (value < 0)
- return 0;
-
- return value;
-}
-
static int add_batt_node(enum state_b b_index, time_t clock, int capacity)
{
struct Batt_node *node = NULL;
@@ -304,7 +250,7 @@ static int battinfo_calculation(void)
int estimated_time = 0;
int tmp = 0;
- capacity = get_battery_capacity_cb();
+ capacity = battery.capacity;
if (capacity <= 0)
return -1;
@@ -319,9 +265,9 @@ static int battinfo_calculation(void)
clock = time(NULL);
if (charging_state == EINA_TRUE) {
del_all_batt_node(B_UNCHARGING);
- if ((capacity * 100 / full_capacity)
+ if ((capacity * 100 / FULL_CAPACITY)
>= BATTERY_FULL_THRESHOLD) {
- if (get_battery_charge_full()) {
+ if (battery.charge_full == CHARGING_FULL) {
del_all_batt_node(B_CHARGING);
_I("battery fully charged!");
update_time(A_TIMETOFULL, 0);
@@ -334,7 +280,7 @@ static int battinfo_calculation(void)
add_batt_node(B_CHARGING, clock, capacity);
avg_factor[B_CHARGING] = update_factor(B_CHARGING);
}
- estimated_time = (float)(full_capacity - capacity) *
+ estimated_time = (float)(FULL_CAPACITY - capacity) *
avg_factor[B_CHARGING];
update_time(A_TIMETOFULL, estimated_time);
} else {
@@ -361,30 +307,6 @@ static Eina_Bool battinfo_cb(void *data)
return ECORE_CALLBACK_RENEW;
}
-static int init_battery_func(void)
-{
- int ret = -1;
-
- ret = get_battery_capacity_raw();
- if (ret >= 0) {
- get_battery_capacity_cb = get_battery_capacity_raw;
- full_capacity = FULL_CAPACITY_RAW;
- _I("init_battery_func : full capacity(%d)", full_capacity);
- return 0;
- }
-
- ret = get_battery_capacity();
- if (ret >= 0) {
- get_battery_capacity_cb = get_battery_capacity;
- full_capacity = FULL_CAPACITY;
- _I("init_battery_func : full capacity(%d)", full_capacity);
- return 0;
- }
-
- _E("init_battery_func : fail to get battery info!");
- return -1;
-}
-
static int start_battinfo_gathering(int timeout)
{
_I("Start battery gathering!");
@@ -393,8 +315,6 @@ static int start_battinfo_gathering(int timeout)
_E("invalid timeout value [%d]!", timeout);
return -1;
}
- if (init_battery_func() != 0)
- return -1;
old_capacity = 0;
battinfo_calculation();