aboutsummaryrefslogtreecommitdiffstats
path: root/binding/telephony-binding.c
diff options
context:
space:
mode:
authorsaman <mahmoudi.saman1@gmail.com>2020-11-07 09:58:01 +0330
committersaman <mahmoudi.saman1@gmail.com>2020-11-19 09:08:28 +0330
commit56fec224dc4dd73a631ac2c15c1a240fd8e92e81 (patch)
tree64293bd46878d2ad7052b8387d4f6f21c04acf82 /binding/telephony-binding.c
parent5762ff51fce596eadbd57522a6ab2978147cd830 (diff)
Getting battery level of connected phone device
Adding "get_battery_level" verb for getting battery level of connected phone device. Is used ofono service and handsfree interface. Bug-AGL: SPEC-3687 Signed-off-by: saman <mahmoudi.saman1@gmail.com> Change-Id: I9713cb186195a170909e6511991cfc32380e12a1
Diffstat (limited to 'binding/telephony-binding.c')
-rw-r--r--binding/telephony-binding.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c
index c84af2c..dce0ef9 100644
--- a/binding/telephony-binding.c
+++ b/binding/telephony-binding.c
@@ -106,6 +106,24 @@ static void answer(afb_req_t request)
}
}
+static void get_battery_level(afb_req_t request)
+{
+ const gchar *device;
+
+ device = ofono_manager_get_default_modem_path();
+ if (!device) {
+ afb_req_fail(request, "failed", "No path find");
+ return;
+ }
+
+ json_object *result = ofono_get_property(device, OFONO_HANDSFREE_INTERFACE, "BatteryChargeLevel", NULL);
+ if (!result)
+ afb_req_fail(request, "failed", "Can not find Battery object");
+ else
+ afb_req_success(request, result, "OK");
+ return;
+}
+
static void subscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
@@ -354,6 +372,10 @@ static const afb_verb_t verbs[]= {
.callback = answer,
},
{
+ .verb = "get_battery_level",
+ .callback = get_battery_level,
+ },
+ {
.verb = "subscribe",
.callback = subscribe,
},