ERROR:Reject SCO: Agent not registered.
by Abhishek Dharmapurikar
Hi,
I was trying to setup HFP uing ofono. I have the following setup
Rasperry Pi B+ ( ARM1176JZF-S)
Bluez 5.32
Pulseaudio 6.0
ofono 1.16
Used the following steps
http://padovan.org/blog/2010/02/handsfree-profile-into-bluez-and-ofono/
start pulseaudio, bluetoothd and ofonod
Connect to phone using bluetoothctl
./enable-modem
./dial-number
loopback
I was able to pair my nexus 4 device and use the script ./dial-number which
actually sets a call up. But the audio of the call doesn't route to the
default sink. I see the following error in ofonod
*Reject SCO: Agent not registered*
Which could be the reason for the audio problem.
Things that I have already tried.
Patched http://cgit.freedesktop.org/~jprvita/pulseaudio/ file
bluetooth-headsets-media-api.
Recompiled the raspbian kernel with
*CONFIG_BT_SCOCONFIG_BT_HCIUSB_SCO*
enabled
Added
*Enable = Source,Sink,Headset,Gateway,Control,MediaDisable = Socket*
to /etc/bluetooth/audio.conf.
Things that could be wrong
When I do a pactl list cards, i see the bluetooth card at #0 with two
profiles.
* Profiles: a2dp_source: High Fidelity Capture (A2DP
Source) (sinks: 0, sources: 1, priority: 10, available: yes)
headset_audio_gateway: Headset Audio Gateway (HSP/HFP) (sinks: 1, sources:
1, priority: 20, available: no) off: Off (sinks: 0, sources:
0, priority: 0, available: yes) Active Profile: a2dp_source*
But when I try making the headset_audio_gateway the default profile. I get
*$ sudo pactl set-card-profile 0 headset_audio_gatewayFailure: Input/Output
error*
Also read this in the pulseaudio notes
http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/6.0/
"When building PulseAudio, it's possible to choose between "native" and
"ofono" BlueZ 5 headset backends."
How do I specify that I wish to use the ofono headset backend? Is that the
problem?
5 years, 1 month
[PATCH] gdbus: Drop message replies if the sender requested no reply
by Philip Withnall
If the sender flags a D-Bus message as not expecting a reply, it is
against system bus policy to send a reply — sending one will result in
errors being sent to us by dbus-daemon.
Magically drop all replies to messages which request no reply.
This is not a complete fix. In an ideal world, the existing check for
G_DBUS_METHOD_FLAG_NOREPLY would be dropped, as the server should be
prepared to return a reply to every method, if the client requests and
expects one — otherwise the client will time out. However, that’s a
much
bigger change with a much bigger risk of breaking things, so I’ll stick
with this for now.
Signed-off-by: Philip Withnall <philip.withnall(a)collabora.co.uk>
Reviewed-by: Simon McVittie <simon.mcvittie(a)collabora.co.uk>
---
gdbus/object.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index 96db516..146a255 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -258,7 +258,8 @@ static DBusHandlerResult
process_message(DBusConnection *connection,
reply = method->function(connection, message,
iface_user_data);
- if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY) {
+ if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY ||
+ dbus_message_get_no_reply(message)) {
if (reply != NULL)
dbus_message_unref(reply);
return DBUS_HANDLER_RESULT_HANDLED;
--
2.5.0
5 years, 1 month
[PATCH] gatchat/gatppp.c: Add timeout handler in ppp_enter_phase
by Marko Šulejić
* ppp_enter_phase calls ppp_dead if the PPP phase is PPP_PHASE_DEAD
&& ppp->sta_pending == FALSE, but fails if sta_pending is never set
to FALSE. So a timeout handler was added to handle this case too.
---
gatchat/gatppp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 5144084..f84535a 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -361,8 +361,12 @@ static inline void ppp_enter_phase(GAtPPP *ppp, enum ppp_phase phase)
DBG(ppp, "%d", phase);
ppp->phase = phase;
- if (phase == PPP_PHASE_DEAD && ppp->sta_pending == FALSE)
- ppp->ppp_dead_source = g_idle_add(ppp_dead, ppp);
+ if (phase == PPP_PHASE_DEAD) {
+ if(ppp->sta_pending)
+ ppp->ppp_dead_source = g_timeout_add(5000, ppp_dead, ppp);
+ else
+ ppp->ppp_dead_source = g_idle_add(ppp_dead, ppp);
+ }
}
void ppp_set_auth(GAtPPP *ppp, const guint8* auth_data)
--
2.1.0
5 years, 1 month
Huawei 3131 with idVendor=12d1, idProduct=14fe
by matti kaasinen
Hi!
Have anyone managed using newer version of Huawei 3131 (idVendor=12d1,
idProduct=14fe pair) together with connman/ofono?
Older version of Huawei 3131 registered nicely with cdc_ether and was shown
as wired service and connected automatically with eth1 interface.
------------------
Modeswitch:
------------------
seems noticing modem as idVendor=12d1, idProduct=1506 device.
-------------------------------------------------------------
Connman seems creating wwan0 interface
-------------------------------------------------------------
connmand[349]: wwan0 {create} index 3 type 1 <ETHER>
connmand[349]: wwan0 {update} flags 4098 <DOWN>
connmand[349]: wwan0 {newlink} index 3 address 58:2C:80:13:92:63 mtu 1500
connmand[349]: wwan0 {newlink} index 3 operstate 2 <DOWN>
connmand[349]: Adding interface wwan0 [ cellular ]
-----------
usbcore:
-----------
usbcore: registered new interface driver usbserial
usb-storage 2-1:1.5: USB Mass Storage device detected
usbcore: registered new interface driver cdc_ncm
usbcore: registered new interface driver cdc_wdm
usbcore: registered new interface driver option
-------------------------
huawei_cdc_ncm:
--------------------------
huawei_cdc_ncm 2-1:1.1 wwan0: register 'huawei_cdc_ncm' at
usb-musb-hdrc.1.auto-1, Huawei CDC NCM device, 58:2c:80:13:92:63
-------------------------
usbserial:
--------------------------
usbserial: USB Serial support registered for GSM modem (1-port)
usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
usb 2-1: GSM modem (1-port) converter now attached to ttyUSB2
-------------------------
ofono:
--------------------------
Modem and NDIS support (CDC support: NDIS port)
Besides /dev/ttyUSBx ports there also exists /dev/cdc-wdm0
Modem shows up with connmanctl technologies
/net/connman/technology/cellular
Name = Cellular
Type = cellular
Powered = False
Connected = False
Tethering = False
But it does not show as service
It is required to make manual online-modem ofono test command to get
cellular technology powered. Then it is also shown as service. Also fast
blinking green sign switches to slow blinking blue sign.
However, no interfaces are shown with ifconfig command nor any connection
is made when etherenet is unplugged.
Also no proggress is shown when
connmanctl session connect --type cellular
is made.
Do anyone know what I miss?
Thanks,
Matti
If so, what kernel modules should I have present?
5 years, 1 month
[PATCH] gprs: Fix the ContextAdded() signal Introspection
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
This matches the behavior described by the documentation the signal
value returned by the code. This was causing a headache when using
stricter D-Bus wrappers like dbus-c++.
---
src/gprs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gprs.c b/src/gprs.c
index ba797dd..9192e68 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -2385,7 +2385,7 @@ static const GDBusSignalTable manager_signals[] = {
{ GDBUS_SIGNAL("PropertyChanged",
GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
{ GDBUS_SIGNAL("ContextAdded",
- GDBUS_ARGS({ "path", "o" }, { "properties", "v" })) },
+ GDBUS_ARGS({ "path", "o" }, { "properties", "a{sv}" })) },
{ GDBUS_SIGNAL("ContextRemoved", GDBUS_ARGS({ "path", "o" })) },
{ }
};
--
1.9.1
5 years, 2 months
[PATCH] network: Fix use-after-free caused by Scan() in poor reception.
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
When issuing a Scan() in poor reception while attached to an operator it's
fully possible to get no results, which causes the attached operator to be
cleaned up. In certain scenarios this would cause a use-after-free.
Make sure to clean up all the references to the operator when it's destroyed.
---
src/network.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/network.c b/src/network.c
index 1dddcac..5329c28 100644
--- a/src/network.c
+++ b/src/network.c
@@ -257,6 +257,9 @@ static void network_operator_destroy(gpointer user_data)
{
struct network_operator_data *op = user_data;
+ if (op->netreg->current_operator == op)
+ op->netreg->current_operator = NULL;
+
g_free(op);
}
--
1.9.1
5 years, 2 months
[PATCH] gprs: Make the ContextAdded return a variant.
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
This matches the behavior described by the documentation and the signal
value described in the introspection. This was causing a headache when
using stricter D-Bus wrappers like dbus-c++.
---
src/gprs.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index ba797dd..b583c28 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1879,7 +1879,17 @@ static void send_context_added_signal(struct ofono_gprs *gprs,
const char *path;
DBusMessage *signal;
DBusMessageIter iter;
+ DBusMessageIter var;
DBusMessageIter dict;
+ char typesig[5];
+ char arraysig[6];
+
+ arraysig[0] = DBUS_TYPE_ARRAY;
+ arraysig[1] = typesig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
+ arraysig[2] = typesig[1] = DBUS_TYPE_STRING;
+ arraysig[3] = typesig[2] = DBUS_TYPE_VARIANT;
+ arraysig[4] = typesig[3] = DBUS_DICT_ENTRY_END_CHAR;
+ arraysig[5] = typesig[4] = '\0';
path = __ofono_atom_get_path(gprs->atom);
signal = dbus_message_new_signal(path,
@@ -1893,11 +1903,15 @@ static void send_context_added_signal(struct ofono_gprs *gprs,
path = context->path;
dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+ arraysig, &var);
+
+ dbus_message_iter_open_container(&var, DBUS_TYPE_ARRAY,
+ typesig,
&dict);
append_context_properties(context, &dict);
- dbus_message_iter_close_container(&iter, &dict);
+ dbus_message_iter_close_container(&var, &dict);
+ dbus_message_iter_close_container(&iter, &var);
g_dbus_send_message(conn, signal);
}
--
1.9.1
5 years, 2 months
[PATCH] cbs: Resolve a use-after-free that could occur with rapid location changes.
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
What happens is that the timeout leaks and then the cbs struct with
the callback is cleaned up, resulting in a SIGSEGV when the callback
occurs from the glib loop.
---
src/cbs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/cbs.c b/src/cbs.c
index b5f0b72..fdc44a1 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -1029,11 +1029,14 @@ out:
/*
* In order to minimize signal transmissions we wait about X seconds
- * before reseting the base station id. The hope is that we receive
+ * before resetting the base station id. The hope is that we receive
* another cell broadcast with the new base station name within
* that time
*/
if (lac_changed || ci_changed) {
+ if(cbs->reset_source)
+ g_source_remove(cbs->reset_source);
+
cbs->reset_source =
g_timeout_add_seconds(3, reset_base_station_name, cbs);
}
--
1.9.1
5 years, 2 months
[PATCH] gprs: Make the ContextAdded return a variant.
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
I am not sure if this is the desired way to resolve this issue. This will
break compatibility with Connman and possibly other systems using oFono
through D-Bus.
I do have a patch for Connman that I can send to them if this patch is
accepted, but not for any other potential systems.
It is also possible to change the introspection and the documentation,
the proposed patch is however more in line with the rest of oFono's
D-Bus API.
Discussion regarding this is encouraged before any possible acception
of this patch.
John Ernberg (1):
gprs: Make the ContextAdded return a variant.
src/gprs.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
--
1.9.1
5 years, 2 months
[PATCH 1/2 v5] plugins: add upower battery monitor for bluetooth
by Tony Espy
---
plugins/upower.c | 370 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 370 insertions(+)
create mode 100644 plugins/upower.c
diff --git a/plugins/upower.c b/plugins/upower.c
new file mode 100644
index 0000000..f3c33b7
--- /dev/null
+++ b/plugins/upower.c
@@ -0,0 +1,370 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2015 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gdbus.h>
+#include <ofono.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/modem.h>
+#include <ofono/log.h>
+#include <ofono/emulator.h>
+
+#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+#define UPOWER_SERVICE "org.freedesktop.UPower"
+#define UPOWER_PATH "/org/freedesktop/UPower"
+#define UPOWER_INTERFACE UPOWER_SERVICE
+#define UPOWER_DEVICE_INTERFACE UPOWER_SERVICE ".Device"
+
+static guint modem_watch;
+static guint upower_daemon_watch;
+static DBusConnection *connection;
+static int last_battery_level;
+static char *battery_device_path;
+
+static void emulator_battery_cb(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+ int val = GPOINTER_TO_INT(data);
+
+ DBG("calling set_indicator: %d", val);
+ ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_BATTERY, val);
+}
+
+static void update_modem_battery_indicator(struct ofono_modem *modem,
+ void *data)
+{
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_battery_cb,
+ data);
+}
+
+static void update_battery_level(double percentage_val)
+{
+ int battery_level;
+
+ if (percentage_val <= 1.00) {
+ battery_level = 0;
+ } else if (percentage_val > 1.00 && percentage_val <= 100.00) {
+ battery_level = ((int) percentage_val - 1) / 20 + 1;
+ } else {
+ ofono_error("%s: Invalid value for battery level: %f",
+ __func__,
+ percentage_val);
+ return;
+ }
+
+ DBG("last_battery_level: %d battery_level: %d (%f)", last_battery_level,
+ battery_level, percentage_val);
+
+ if (last_battery_level == battery_level)
+ return;
+
+ last_battery_level = battery_level;
+
+ __ofono_modem_foreach(update_modem_battery_indicator,
+ GINT_TO_POINTER(battery_level));
+}
+
+static gboolean battery_props_changed(DBusConnection *conn, DBusMessage *msg,
+ void *user_data)
+
+{
+ const char *iface;
+ DBusMessageIter iter, dict;
+ double percentage_val;
+ gboolean percentage_found = FALSE;
+ gboolean retval = FALSE;
+
+ DBG("");
+
+ dbus_message_iter_init(msg, &iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
+ ofono_error("%s: iface != TYPE_STRING!", __func__);
+ goto done;
+ }
+
+ dbus_message_iter_get_basic(&iter, &iface);
+
+ if (g_str_equal(iface, UPOWER_DEVICE_INTERFACE) != TRUE) {
+ ofono_error("%s: wrong iface: %s!", __func__, iface);
+ goto done;
+ }
+
+ if (!dbus_message_iter_next(&iter)) {
+ ofono_error("%s: advance iter failed!", __func__);
+ goto done;
+ }
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
+ ofono_error("%s: type != ARRAY!", __func__);
+ goto done;
+ }
+
+ dbus_message_iter_recurse(&iter, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, val;
+ const char *key;
+
+ dbus_message_iter_recurse(&dict, &entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) !=
+ DBUS_TYPE_STRING) {
+ ofono_error("%s: key type != STRING!", __func__);
+ goto done;
+ }
+
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (g_str_equal(key, "Percentage") != TRUE) {
+ dbus_message_iter_next(&dict);
+ continue;
+ }
+
+ dbus_message_iter_next(&entry);
+ if (dbus_message_iter_get_arg_type(&entry) !=
+ DBUS_TYPE_VARIANT) {
+ ofono_error("%s: 'Percentage' val != VARIANT",
+ __func__);
+ goto done;
+ }
+
+ dbus_message_iter_recurse(&entry, &val);
+
+ if (dbus_message_iter_get_arg_type(&val) != DBUS_TYPE_DOUBLE) {
+ ofono_error("%s: 'Percentage' val != DOUBLE", __func__);
+ goto done;
+ }
+
+ dbus_message_iter_get_basic(&val, &percentage_val);
+ percentage_found = TRUE;
+ break;
+ }
+
+ /* No errors found during parsing, so don't trigger cb removal */
+ retval = TRUE;
+
+ if (percentage_found == FALSE)
+ goto done;
+
+ update_battery_level(percentage_val);
+
+done:
+ return retval;
+}
+
+static void emulator_hfp_watch(struct ofono_atom *atom,
+ enum ofono_atom_watch_condition cond,
+ void *data)
+{
+ if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED) {
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ DBG("REGISTERED; calling set_indicator: %d", last_battery_level);
+
+ ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_BATTERY,
+ last_battery_level);
+ return;
+ }
+
+ DBG("UNREGISTERED");
+}
+
+static void modemwatch(struct ofono_modem *modem, gboolean added, void *user)
+{
+
+ const char *path = ofono_modem_get_path(modem);
+
+ DBG("modem: %s, added: %d", path, added);
+
+ if (added)
+ __ofono_modem_add_atom_watch(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_hfp_watch, NULL, NULL);
+
+}
+
+static void call_modemwatch(struct ofono_modem *modem, void *user)
+{
+ modemwatch(modem, TRUE, user);
+}
+
+static gboolean parse_devices_reply(DBusMessage *reply)
+{
+ DBusMessageIter array, iter;
+ const char *path;
+
+ DBG("");
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ ofono_error("%s: ERROR reply to EnumerateDevices", __func__);
+ return FALSE;
+ }
+
+ if (dbus_message_iter_init(reply, &array) == FALSE) {
+ ofono_error("%s: error initializing array iter", __func__);
+ return FALSE;
+ }
+
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) {
+ ofono_error("%s: type != ARRAY!", __func__);
+ return FALSE;
+ }
+
+ dbus_message_iter_recurse(&array, &iter);
+
+ while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_OBJECT_PATH) {
+
+ dbus_message_iter_get_basic(&iter, &path);
+
+ if (g_strrstr(path, "/battery_")) {
+ ofono_info("%s: found 1st battery device: %s", __func__,
+ path);
+ battery_device_path = g_strdup(path);
+ break;
+ }
+
+ if (!dbus_message_iter_next(&iter))
+ break;
+ }
+
+ return TRUE;
+}
+
+static void enum_devices_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+ if (reply == NULL) {
+ ofono_error("%s: dbus_message_new_method failed", __func__);
+ goto done;
+ }
+
+ if (parse_devices_reply(reply) == FALSE)
+ goto done;
+
+ DBG("parse_devices_reply OK");
+
+ /* TODO: handle removable batteries */
+
+ if (battery_device_path == NULL) {
+ ofono_error("%s: no battery detected", __func__);
+ goto done;
+ }
+
+ /* Always listen to PropertiesChanged for battery */
+ g_dbus_add_signal_watch(connection, UPOWER_SERVICE, battery_device_path,
+ DBUS_INTERFACE_PROPERTIES,
+ "PropertiesChanged",
+ battery_props_changed,
+ NULL, NULL);
+
+ modem_watch = __ofono_modemwatch_add(modemwatch, NULL, NULL);
+ __ofono_modem_foreach(call_modemwatch, NULL);
+
+done:
+ if (reply)
+ dbus_message_unref(reply);
+
+ dbus_pending_call_unref(call);
+}
+
+static void upower_connect(DBusConnection *conn, void *user_data)
+{
+ DBusPendingCall *call;
+ DBusMessage *msg;
+
+ DBG("upower connect");
+
+ msg = dbus_message_new_method_call(UPOWER_SERVICE,
+ UPOWER_PATH,
+ UPOWER_INTERFACE,
+ "EnumerateDevices");
+ if (msg == NULL) {
+ ofono_error("%s: dbus_message_new_method failed", __func__);
+ return;
+ }
+
+ if (!dbus_connection_send_with_reply(conn, msg, &call, -1)) {
+ ofono_error("%s: Sending EnumerateDevices failed", __func__);
+ goto done;
+ }
+
+ dbus_pending_call_set_notify(call, enum_devices_reply, NULL, NULL);
+done:
+ dbus_message_unref(msg);
+}
+
+static void upower_disconnect(DBusConnection *conn, void *user_data)
+{
+ DBG("upower disconnect");
+
+ if (modem_watch) {
+ __ofono_modemwatch_remove(modem_watch);
+ modem_watch = 0;
+ }
+
+ if (battery_device_path) {
+ g_free(battery_device_path);
+ battery_device_path = NULL;
+ }
+}
+
+static int upower_init(void)
+{
+ DBG("upower init");
+
+ connection = ofono_dbus_get_connection();
+ upower_daemon_watch = g_dbus_add_service_watch(connection,
+ UPOWER_SERVICE,
+ upower_connect,
+ upower_disconnect,
+ NULL, NULL);
+
+ return 0;
+}
+
+static void upower_exit(void)
+{
+ if (upower_daemon_watch)
+ g_dbus_remove_watch(connection, upower_daemon_watch);
+
+ if (modem_watch)
+ __ofono_modemwatch_remove(modem_watch);
+
+ if (battery_device_path)
+ g_free(battery_device_path);
+
+}
+
+OFONO_PLUGIN_DEFINE(upower, "upower battery monitor", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, upower_init, upower_exit)
--
2.1.4
5 years, 2 months