Bug 834551 - Replace 'LOG()' with 'BT_WARNING()' defined in BluetoothCommon.h for consistency, r=qdot

This commit is contained in:
Eric Chou 2013-01-28 19:23:12 +08:00
Родитель 7d026ba601
Коммит 48165f030d
3 изменённых файлов: 34 добавлений и 46 удалений

Просмотреть файл

@ -24,6 +24,10 @@ extern bool gBluetoothDebugFlag;
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \ __android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \
} \ } \
} while(0) } while(0)
#define BT_WARNING(args...) \
__android_log_print(ANDROID_LOG_WARN, "GeckoBluetooth", args)
#else #else
#define BT_LOG(args...) \ #define BT_LOG(args...) \
do { \ do { \
@ -31,6 +35,8 @@ extern bool gBluetoothDebugFlag;
printf(args); \ printf(args); \
} \ } \
} while(0) } while(0)
#define BT_WARNING(args...) printf(args);
#endif #endif
#define BEGIN_BLUETOOTH_NAMESPACE \ #define BEGIN_BLUETOOTH_NAMESPACE \

Просмотреть файл

@ -35,15 +35,6 @@
#include "BluetoothUnixSocketConnector.h" #include "BluetoothUnixSocketConnector.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#undef LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkDBus", args);
#else
#define BTDEBUG true
#define LOG(args...) if (BTDEBUG) printf(args);
#endif
USING_BLUETOOTH_NAMESPACE USING_BLUETOOTH_NAMESPACE
static const int RFCOMM_SO_SNDBUF = 70 * 1024; // 70 KB send buffer static const int RFCOMM_SO_SNDBUF = 70 * 1024; // 70 KB send buffer

Просмотреть файл

@ -59,15 +59,6 @@ using namespace mozilla;
using namespace mozilla::ipc; using namespace mozilla::ipc;
USING_BLUETOOTH_NAMESPACE USING_BLUETOOTH_NAMESPACE
#undef LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkDBus", args);
#else
#define BTDEBUG true
#define LOG(args...) if (BTDEBUG) printf(args);
#endif
#define B2G_AGENT_CAPABILITIES "DisplayYesNo" #define B2G_AGENT_CAPABILITIES "DisplayYesNo"
#define DBUS_MANAGER_IFACE BLUEZ_DBUS_BASE_IFC ".Manager" #define DBUS_MANAGER_IFACE BLUEZ_DBUS_BASE_IFC ".Manager"
#define DBUS_ADAPTER_IFACE BLUEZ_DBUS_BASE_IFC ".Adapter" #define DBUS_ADAPTER_IFACE BLUEZ_DBUS_BASE_IFC ".Adapter"
@ -420,7 +411,7 @@ static DBusHandlerResult
AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
{ {
if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_METHOD_CALL) { if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_METHOD_CALL) {
LOG("%s: agent handler not interested (not a method call).\n", __FUNCTION__); BT_WARNING("%s: agent handler not interested (not a method call).\n", __FUNCTION__);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
@ -460,7 +451,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_OBJECT_PATH, &objectPath,
DBUS_TYPE_STRING, &uuid, DBUS_TYPE_STRING, &uuid,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Invalid arguments for Authorize() method", __FUNCTION__); BT_WARNING("%s: Invalid arguments for Authorize() method", __FUNCTION__);
errorStr.AssignLiteral("Invalid arguments for Authorize() method"); errorStr.AssignLiteral("Invalid arguments for Authorize() method");
} else { } else {
nsString deviceAddress = nsString deviceAddress =
@ -492,7 +483,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_OBJECT_PATH, &objectPath,
DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_UINT32, &passkey,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Invalid arguments for RequestConfirmation() method", __FUNCTION__); BT_WARNING("%s: Invalid arguments for RequestConfirmation() method", __FUNCTION__);
errorStr.AssignLiteral("Invalid arguments for RequestConfirmation() method"); errorStr.AssignLiteral("Invalid arguments for RequestConfirmation() method");
} else { } else {
parameters.AppendElement(BluetoothNamedValue( parameters.AppendElement(BluetoothNamedValue(
@ -524,7 +515,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
if (!dbus_message_get_args(msg, NULL, if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_OBJECT_PATH, &objectPath,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Invalid arguments for RequestPinCode() method", __FUNCTION__); BT_WARNING("%s: Invalid arguments for RequestPinCode() method", __FUNCTION__);
errorStr.AssignLiteral("Invalid arguments for RequestPinCode() method"); errorStr.AssignLiteral("Invalid arguments for RequestPinCode() method");
} else { } else {
parameters.AppendElement(BluetoothNamedValue( parameters.AppendElement(BluetoothNamedValue(
@ -552,7 +543,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
if (!dbus_message_get_args(msg, NULL, if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_OBJECT_PATH, &objectPath,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Invalid arguments for RequestPasskey() method", __FUNCTION__); BT_WARNING("%s: Invalid arguments for RequestPasskey() method", __FUNCTION__);
errorStr.AssignLiteral("Invalid arguments for RequestPasskey() method"); errorStr.AssignLiteral("Invalid arguments for RequestPasskey() method");
} else { } else {
parameters.AppendElement(BluetoothNamedValue( parameters.AppendElement(BluetoothNamedValue(
@ -590,7 +581,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
} }
} else { } else {
#ifdef DEBUG #ifdef DEBUG
LOG("agent handler %s: Unhandled event. Ignore.", __FUNCTION__); BT_WARNING("agent handler %s: Unhandled event. Ignore.", __FUNCTION__);
#endif #endif
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
@ -631,7 +622,7 @@ RegisterLocalAgent(const char* adapterPath,
agentPath, agentPath,
&agentVtable, &agentVtable,
NULL)) { NULL)) {
LOG("%s: Can't register object path %s for agent!", BT_WARNING("%s: Can't register object path %s for agent!",
__FUNCTION__, agentPath); __FUNCTION__, agentPath);
return false; return false;
} }
@ -640,7 +631,7 @@ RegisterLocalAgent(const char* adapterPath,
dbus_message_new_method_call("org.bluez", adapterPath, dbus_message_new_method_call("org.bluez", adapterPath,
DBUS_ADAPTER_IFACE, "RegisterAgent"); DBUS_ADAPTER_IFACE, "RegisterAgent");
if (!msg) { if (!msg) {
LOG("%s: Can't allocate new method call for agent!", __FUNCTION__); BT_WARNING("%s: Can't allocate new method call for agent!", __FUNCTION__);
return false; return false;
} }
@ -648,7 +639,7 @@ RegisterLocalAgent(const char* adapterPath,
DBUS_TYPE_OBJECT_PATH, &agentPath, DBUS_TYPE_OBJECT_PATH, &agentPath,
DBUS_TYPE_STRING, &capabilities, DBUS_TYPE_STRING, &capabilities,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__);
return false; return false;
} }
@ -665,11 +656,11 @@ RegisterLocalAgent(const char* adapterPath,
if (!strcmp(err.name, "org.bluez.Error.AlreadyExists")) { if (!strcmp(err.name, "org.bluez.Error.AlreadyExists")) {
LOG_AND_FREE_DBUS_ERROR(&err); LOG_AND_FREE_DBUS_ERROR(&err);
#ifdef DEBUG #ifdef DEBUG
LOG("Agent already registered, still returning true"); BT_WARNING("Agent already registered, still returning true");
#endif #endif
} else { } else {
LOG_AND_FREE_DBUS_ERROR(&err); LOG_AND_FREE_DBUS_ERROR(&err);
LOG("%s: Can't register agent!", __FUNCTION__); BT_WARNING("%s: Can't register agent!", __FUNCTION__);
return false; return false;
} }
} }
@ -699,7 +690,7 @@ RegisterAgent(const nsAString& aAdapterPath)
REMOTE_AGENT_PATH, REMOTE_AGENT_PATH,
&agentVtable, &agentVtable,
NULL)) { NULL)) {
LOG("%s: Can't register object path %s for remote device agent!", BT_WARNING("%s: Can't register object path %s for remote device agent!",
__FUNCTION__, REMOTE_AGENT_PATH); __FUNCTION__, REMOTE_AGENT_PATH);
return false; return false;
@ -721,7 +712,7 @@ ExtractHandles(DBusMessage *aReply, nsTArray<uint32_t>& aOutHandles)
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &handles, &len, DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &handles, &len,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
if (!handles) { if (!handles) {
LOG("Null array in extract_handles"); BT_WARNING("Null array in extract_handles");
} else { } else {
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
aOutHandles.AppendElement(handles[i]); aOutHandles.AppendElement(handles[i]);
@ -775,7 +766,7 @@ BluetoothDBusService::AddReservedServicesInternal(const nsAString& aAdapterPath,
&services, length, DBUS_TYPE_INVALID); &services, length, DBUS_TYPE_INVALID);
if (!reply) { if (!reply) {
LOG("Null DBus message. Couldn't extract handles."); BT_WARNING("Null DBus message. Couldn't extract handles.");
return false; return false;
} }
@ -1307,13 +1298,13 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
NS_ASSERTION(!NS_IsMainThread(), "Shouldn't be called from Main Thread!"); NS_ASSERTION(!NS_IsMainThread(), "Shouldn't be called from Main Thread!");
if (dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_SIGNAL) { if (dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_SIGNAL) {
LOG("%s: event handler not interested in %s (not a signal).\n", BT_WARNING("%s: event handler not interested in %s (not a signal).\n",
__FUNCTION__, dbus_message_get_member(aMsg)); __FUNCTION__, dbus_message_get_member(aMsg));
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
if (dbus_message_get_path(aMsg) == NULL) { if (dbus_message_get_path(aMsg) == NULL) {
LOG("DBusMessage %s has no bluetooth destination, ignoring\n", BT_WARNING("DBusMessage %s has no bluetooth destination, ignoring\n",
dbus_message_get_member(aMsg)); dbus_message_get_member(aMsg));
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
@ -1635,13 +1626,13 @@ BluetoothDBusService::StopInternal()
if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(), if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(),
LOCAL_AGENT_PATH)) { LOCAL_AGENT_PATH)) {
LOG("%s: Can't unregister object path %s for agent!", BT_WARNING("%s: Can't unregister object path %s for agent!",
__FUNCTION__, LOCAL_AGENT_PATH); __FUNCTION__, LOCAL_AGENT_PATH);
} }
if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(), if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(),
REMOTE_AGENT_PATH)) { REMOTE_AGENT_PATH)) {
LOG("%s: Can't unregister object path %s for agent!", BT_WARNING("%s: Can't unregister object path %s for agent!",
__FUNCTION__, LOCAL_AGENT_PATH); __FUNCTION__, LOCAL_AGENT_PATH);
} }
@ -2229,7 +2220,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
BluetoothValue v = true; BluetoothValue v = true;
DBusMessage *msg; DBusMessage *msg;
if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
LOG("%s: Couldn't get original request message.", __FUNCTION__); BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message."); errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
return false; return false;
@ -2238,7 +2229,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
DBusMessage *reply = dbus_message_new_method_return(msg); DBusMessage *reply = dbus_message_new_method_return(msg);
if (!reply) { if (!reply) {
LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__);
dbus_message_unref(msg); dbus_message_unref(msg);
errorStr.AssignLiteral("Memory can't be allocated for the message."); errorStr.AssignLiteral("Memory can't be allocated for the message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
@ -2253,7 +2244,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
if (!dbus_message_append_args(reply, if (!dbus_message_append_args(reply,
DBUS_TYPE_STRING, &pinCode, DBUS_TYPE_STRING, &pinCode,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't append arguments to dbus message."); errorStr.AssignLiteral("Couldn't append arguments to dbus message.");
result = false; result = false;
} else { } else {
@ -2277,7 +2268,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
BluetoothValue v = true; BluetoothValue v = true;
DBusMessage *msg; DBusMessage *msg;
if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
LOG("%s: Couldn't get original request message.", __FUNCTION__); BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message."); errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
return false; return false;
@ -2286,7 +2277,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
DBusMessage *reply = dbus_message_new_method_return(msg); DBusMessage *reply = dbus_message_new_method_return(msg);
if (!reply) { if (!reply) {
LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__);
dbus_message_unref(msg); dbus_message_unref(msg);
errorStr.AssignLiteral("Memory can't be allocated for the message."); errorStr.AssignLiteral("Memory can't be allocated for the message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
@ -2299,7 +2290,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
if (!dbus_message_append_args(reply, if (!dbus_message_append_args(reply,
DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_UINT32, &passkey,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't append arguments to dbus message."); errorStr.AssignLiteral("Couldn't append arguments to dbus message.");
result = false; result = false;
} else { } else {
@ -2323,7 +2314,7 @@ BluetoothDBusService::SetPairingConfirmationInternal(const nsAString& aDeviceAdd
BluetoothValue v = true; BluetoothValue v = true;
DBusMessage *msg; DBusMessage *msg;
if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
LOG("%s: Couldn't get original request message.", __FUNCTION__); BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message."); errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
return false; return false;
@ -2339,7 +2330,7 @@ BluetoothDBusService::SetPairingConfirmationInternal(const nsAString& aDeviceAdd
} }
if (!reply) { if (!reply) {
LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__);
dbus_message_unref(msg); dbus_message_unref(msg);
errorStr.AssignLiteral("Memory can't be allocated for the message."); errorStr.AssignLiteral("Memory can't be allocated for the message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
@ -2368,7 +2359,7 @@ BluetoothDBusService::SetAuthorizationInternal(const nsAString& aDeviceAddress,
DBusMessage *msg; DBusMessage *msg;
if (!sAuthorizeReqTable.Get(aDeviceAddress, &msg)) { if (!sAuthorizeReqTable.Get(aDeviceAddress, &msg)) {
LOG("%s: Couldn't get original request message.", __FUNCTION__); BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message."); errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);
return false; return false;
@ -2384,7 +2375,7 @@ BluetoothDBusService::SetAuthorizationInternal(const nsAString& aDeviceAddress,
} }
if (!reply) { if (!reply) {
LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__);
dbus_message_unref(msg); dbus_message_unref(msg);
errorStr.AssignLiteral("Memory can't be allocated for the message."); errorStr.AssignLiteral("Memory can't be allocated for the message.");
DispatchBluetoothReply(aRunnable, v, errorStr); DispatchBluetoothReply(aRunnable, v, errorStr);