Bug 1052304 - Notify OPP manager when Bluetooth socket message error occurs. r=btian

This commit is contained in:
Jamin Liu 2014-10-09 17:54:38 +08:00
Родитель 5bd1ffe804
Коммит 643d379c50
2 изменённых файлов: 33 добавлений и 4 удалений

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

@ -368,6 +368,11 @@ public:
return; return;
} }
if (aConnectionStatus != 0) {
mImpl->mConsumer->NotifyError();
return;
}
mImpl->mConsumer->SetAddress(aBdAddress); mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd)); XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
} }
@ -376,6 +381,14 @@ public:
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
BT_LOGR("BluetoothSocketInterface::Accept failed: %d", (int)aStatus); BT_LOGR("BluetoothSocketInterface::Accept failed: %d", (int)aStatus);
if (!mImpl->IsShutdownOnMainThread()) {
// Instead of NotifyError(), call NotifyDisconnect() to trigger
// BluetoothOppManager::OnSocketDisconnect() as
// DroidSocketImpl::OnFileCanReadWithoutBlocking() in Firefox OS 2.0 in
// order to keep the same behavior and reduce regression risk.
mImpl->mConsumer->NotifyDisconnect();
}
} }
private: private:
@ -504,9 +517,17 @@ public:
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (!mImpl->IsShutdownOnMainThread()) { if (mImpl->IsShutdownOnMainThread()) {
mImpl->mConsumer->SetAddress(aBdAddress); BT_LOGD("mConsumer is null, aborting send!");
return;
} }
if (aConnectionStatus != 0) {
mImpl->mConsumer->NotifyError();
return;
}
mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new SocketConnectTask(mImpl, aFd)); new SocketConnectTask(mImpl, aFd));
} }
@ -515,6 +536,14 @@ public:
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
BT_WARNING("Connect failed: %d", (int)aStatus); BT_WARNING("Connect failed: %d", (int)aStatus);
if (!mImpl->IsShutdownOnMainThread()) {
// Instead of NotifyError(), call NotifyDisconnect() to trigger
// BluetoothOppManager::OnSocketDisconnect() as
// DroidSocketImpl::OnFileCanReadWithoutBlocking() in Firefox OS 2.0 in
// order to keep the same behavior and reduce regression risk.
mImpl->mConsumer->NotifyDisconnect();
}
} }
private: private:

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

@ -286,7 +286,7 @@ private:
msg.msg_iovlen = 1; msg.msg_iovlen = 1;
ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL)); ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL));
if (res < 0) { if (res <= 0) {
return STATUS_FAIL; return STATUS_FAIL;
} }
@ -311,7 +311,7 @@ private:
msg.msg_controllen = sizeof(cmsgbuf); msg.msg_controllen = sizeof(cmsgbuf);
ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL)); ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL));
if (res < 0) { if (res <= 0) {
return STATUS_FAIL; return STATUS_FAIL;
} }