+BT_EXPORT_API int bluetooth_telephony_get_battery_level(
+ const char *remote_address, unsigned int *level)
+{
+ GVariant *reply;
+ GError *err = NULL;
+ GVariant *param = NULL;
+ int ret;
+
+ FN_START;
+
+ BT_TELEPHONY_CHECK_INITIALIZED();
+ BT_TELEPHONY_CHECK_ENABLED();
+
+ param = g_variant_new("(s)", remote_address);
+
+ reply = __bluetooth_telephony_dbus_method_send(
+ HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
+ "GetHfBatteryLevel", &err, param);
+
+ if (!reply) {
+ BT_ERR("Error returned in method call\n");
+ if (err) {
+ g_dbus_error_strip_remote_error(err);
+ ret = __bt_telephony_get_error(err->message);
+ g_error_free(err);
+ return ret;
+ }
+ return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+ }
+
+ g_variant_get(reply, "(u)", level);
+
+ g_variant_unref(reply);
+
+ FN_END;
+ return BLUETOOTH_TELEPHONY_ERROR_NONE;
+}
+