From 0082f3580b82b9988242bb88389e70d5d8acb469 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 5 Nov 2013 11:05:24 -0800 Subject: [PATCH 1/6] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6745e7046ff9 Author: Julien Wajsberg Desc: Merge pull request #13354 from julienw/924475-master-fix Bug 924475 - [Messages] The context menu is missing the contact name and... ======== https://hg.mozilla.org/integration/gaia-central/rev/2e8d579602e3 Author: Julien Wajsberg Desc: Bug 924475 - [Messages] The context menu is missing the contact name and mobile type r=borja Do not output a header if this is a known contact --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 5ecb3d3acb9..5d488e0bf66 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "53c6a2b0bf4c238d39ee0096b79d911aec2de0fc", + "revision": "6745e7046ff9a18195746fb2f0f46f71b0db4cc2", "repo_path": "/integration/gaia-central" } From 71ff563ebce492daac58a6b2f23412f5a39a9288 Mon Sep 17 00:00:00 2001 From: Garner Lee Date: Fri, 1 Nov 2013 14:52:59 +0800 Subject: [PATCH 2/6] Bug 933635 - Part 1: NFC IPC Makefiles. r=khuey --- ipc/moz.build | 5 ++++- ipc/nfc/moz.build | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ipc/moz.build b/ipc/moz.build index 1dc549316da..471c23534f4 100644 --- a/ipc/moz.build +++ b/ipc/moz.build @@ -17,7 +17,10 @@ if CONFIG['MOZ_B2G_RIL']: if CONFIG['MOZ_B2G_BT_BLUEZ']: DIRS += ['dbus'] -if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': +if CONFIG['MOZ_NFC']: + DIRS += ['nfc'] + +if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_NFC'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': DIRS += ['unixsocket'] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': diff --git a/ipc/nfc/moz.build b/ipc/nfc/moz.build index a359e40cdc9..0cae9d7e4bd 100644 --- a/ipc/nfc/moz.build +++ b/ipc/nfc/moz.build @@ -3,7 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG['MOZ_B2G_NFC']: +if CONFIG['MOZ_NFC']: MODULE = 'ipc' EXPORTS.mozilla.ipc += [ 'Nfc.h', From 093d8a1dcc9c99bdae4422a6885c013f3f183cf9 Mon Sep 17 00:00:00 2001 From: Garner Lee Date: Fri, 1 Nov 2013 14:53:37 +0800 Subject: [PATCH 3/6] Bug 933635 - Part 2: SystemWorkerManagager IDL changes. r=khuey --- dom/system/gonk/nsISystemWorkerManager.idl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom/system/gonk/nsISystemWorkerManager.idl b/dom/system/gonk/nsISystemWorkerManager.idl index 46932ee3caf..f928400db19 100644 --- a/dom/system/gonk/nsISystemWorkerManager.idl +++ b/dom/system/gonk/nsISystemWorkerManager.idl @@ -7,10 +7,13 @@ /** * Information about networks that is exposed to network manager API consumers. */ -[scriptable, builtinclass, uuid(02166330-2ff6-4ea5-895a-693c0c2b4c1f)] +[scriptable, builtinclass, uuid(a9ea96a0-407d-11e3-aa6e-0800200c9a66)] interface nsISystemWorkerManager : nsISupports { [implicit_jscontext] void registerRilWorker(in unsigned long aClientId, in jsval aWorker); + + [implicit_jscontext] + void registerNfcWorker(in jsval aWorker); }; From 8bd7d040541b5e4bd9f4d287ef040494a703f3bd Mon Sep 17 00:00:00 2001 From: Garner Lee Date: Fri, 1 Nov 2013 17:45:46 +0800 Subject: [PATCH 4/6] Bug 933635 - Part 3: NFC IPC Sources. r=yoshi --- dom/system/gonk/SystemWorkerManager.cpp | 29 ++++ ipc/nfc/Nfc.cpp | 193 +++++++++++++++++++----- ipc/nfc/Nfc.h | 27 ++-- 3 files changed, 204 insertions(+), 45 deletions(-) diff --git a/dom/system/gonk/SystemWorkerManager.cpp b/dom/system/gonk/SystemWorkerManager.cpp index 637760689d3..e48b87e258a 100644 --- a/dom/system/gonk/SystemWorkerManager.cpp +++ b/dom/system/gonk/SystemWorkerManager.cpp @@ -31,6 +31,9 @@ #ifdef MOZ_B2G_RIL #include "mozilla/ipc/Ril.h" #endif +#ifdef MOZ_NFC +#include "mozilla/ipc/Nfc.h" +#endif #include "mozilla/ipc/KeyStore.h" #include "nsIObserverService.h" #include "nsCxPusher.h" @@ -275,6 +278,10 @@ SystemWorkerManager::Shutdown() RilConsumer::Shutdown(); #endif +#ifdef MOZ_NFC + NfcConsumer::Shutdown(); +#endif + StopNetd(); mNetdWorker = nullptr; @@ -361,6 +368,28 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId, #endif // MOZ_B2G_RIL } +nsresult +SystemWorkerManager::RegisterNfcWorker(const JS::Value& aWorker, + JSContext* aCx) +{ +#ifndef MOZ_NFC + return NS_ERROR_NOT_IMPLEMENTED; +#else + NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED); + + JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker)); + + WorkerCrossThreadDispatcher* wctd = + GetWorkerCrossThreadDispatcher(aCx, aWorker); + if (!wctd) { + NS_WARNING("Failed to GetWorkerCrossThreadDispatcher for nfc"); + return NS_ERROR_FAILURE; + } + + return NfcConsumer::Register(wctd); +#endif // MOZ_NFC +} + nsresult SystemWorkerManager::InitNetd(JSContext *cx) { diff --git a/ipc/nfc/Nfc.cpp b/ipc/nfc/Nfc.cpp index a0258aa6c66..f249c37df99 100644 --- a/ipc/nfc/Nfc.cpp +++ b/ipc/nfc/Nfc.cpp @@ -4,10 +4,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include -#include +/* Copyright © 2013, Deutsche Telekom, Inc. */ +#include "mozilla/ipc/Nfc.h" + +#include #include #include @@ -21,7 +22,6 @@ #include "jsfriendapi.h" #include "nsThreadUtils.h" // For NS_IsMainThread. -#include "Nfc.h" USING_WORKERS_NAMESPACE using namespace mozilla::ipc; @@ -32,34 +32,139 @@ const char* NFC_SOCKET_NAME = "/dev/socket/nfcd"; // Network port to connect to for adb forwarded sockets when doing // desktop development. -const uint32_t NFCD_TEST_PORT = 6400; +const uint32_t NFC_TEST_PORT = 6400; -class DispatchNfcEvent : public WorkerTask +nsRefPtr sNfcConsumer; + +class ConnectWorkerToNFC : public WorkerTask { public: - DispatchNfcEvent(UnixSocketRawData* aMessage) - : mMessage(aMessage) + ConnectWorkerToNFC() { } - virtual bool RunTask(JSContext *aCx); + virtual bool RunTask(JSContext* aCx); +}; + +class SendNfcSocketDataTask : public nsRunnable +{ +public: + SendNfcSocketDataTask(UnixSocketRawData* aRawData) + : mRawData(aRawData) + { } + + NS_IMETHOD Run() + { + MOZ_ASSERT(NS_IsMainThread()); + + if (!sNfcConsumer || + sNfcConsumer->GetConnectionStatus() != SOCKET_CONNECTED) { + // Probably shuting down. + delete mRawData; + return NS_OK; + } + + sNfcConsumer->SendSocketData(mRawData); + return NS_OK; + } + +private: + UnixSocketRawData* mRawData; +}; + +bool +PostToNFC(JSContext* aCx, + unsigned aArgc, + JS::Value* aArgv) +{ + NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); + + if (aArgc != 1) { + JS_ReportError(aCx, "Expecting one argument with the NFC message"); + return false; + } + + JS::Value v = JS_ARGV(aCx, aArgv)[0]; + + JSAutoByteString abs; + void* data; + size_t size; + if (JSVAL_IS_STRING(v)) { + JSString* str = JSVAL_TO_STRING(v); + if (!abs.encodeUtf8(aCx, str)) { + return false; + } + + data = abs.ptr(); + size = abs.length(); + } else if (!JSVAL_IS_PRIMITIVE(v)) { + JSObject* obj = JSVAL_TO_OBJECT(v); + if (!JS_IsTypedArrayObject(obj)) { + JS_ReportError(aCx, "Object passed in wasn't a typed array"); + return false; + } + + uint32_t type = JS_GetArrayBufferViewType(obj); + if (type != js::ArrayBufferView::TYPE_INT8 && + type != js::ArrayBufferView::TYPE_UINT8 && + type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) { + JS_ReportError(aCx, "Typed array data is not octets"); + return false; + } + + size = JS_GetTypedArrayByteLength(obj); + data = JS_GetArrayBufferViewData(obj); + } else { + JS_ReportError(aCx, + "Incorrect argument. Expecting a string or a typed array"); + return false; + } + + UnixSocketRawData* raw = new UnixSocketRawData(data, size); + + nsRefPtr task = + new SendNfcSocketDataTask(raw); + NS_DispatchToMainThread(task); + return true; +} + +bool +ConnectWorkerToNFC::RunTask(JSContext* aCx) +{ + // Set up the postNFCMessage on the function for worker -> NFC thread + // communication. + NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); + NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?"); + JSObject* workerGlobal = JS::CurrentGlobalOrNull(aCx); + + return !!JS_DefineFunction(aCx, workerGlobal, + "postNfcMessage", PostToNFC, 1, 0); +} + +class DispatchNFCEvent : public WorkerTask +{ +public: + DispatchNFCEvent(UnixSocketRawData* aMessage) + : mMessage(aMessage) + { } + + virtual bool RunTask(JSContext* aCx); private: nsAutoPtr mMessage; }; bool -DispatchNfcEvent::RunTask(JSContext *aCx) +DispatchNFCEvent::RunTask(JSContext* aCx) { - MOZ_ASSERT(NS_IsMainThread(), "DispatchNfcEvent on main thread"); - MOZ_ASSERT(aCx); + JSObject* obj = JS::CurrentGlobalOrNull(aCx); - JSObject *obj = JS::CurrentGlobalOrNull(aCx); - JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize); + JSObject* array = JS_NewUint8Array(aCx, mMessage->mSize); if (!array) { return false; } + memcpy(JS_GetArrayBufferViewData(array), mMessage->mData, mMessage->mSize); - jsval argv[] = { OBJECT_TO_JSVAL(array) }; + JS::Value argv[] = { OBJECT_TO_JSVAL(array) }; return JS_CallFunctionName(aCx, obj, "onNfcMessage", NS_ARRAY_LENGTH(argv), argv, argv); } @@ -67,7 +172,9 @@ DispatchNfcEvent::RunTask(JSContext *aCx) class NfcConnector : public mozilla::ipc::UnixSocketConnector { public: - NfcConnector() {} + NfcConnector() + {} + virtual ~NfcConnector() {} @@ -97,7 +204,7 @@ NfcConnector::Create() #endif if (fd < 0) { - NS_WARNING("Could not open Nfc socket!"); + NS_WARNING("Could not open nfc socket!"); return -1; } @@ -133,7 +240,7 @@ NfcConnector::CreateAddr(bool aIsServer, break; case AF_INET: aAddr.in.sin_family = af; - aAddr.in.sin_port = htons(NFCD_TEST_PORT); + aAddr.in.sin_port = htons(NFC_TEST_PORT); aAddr.in.sin_addr.s_addr = htons(INADDR_LOOPBACK); aAddrSize = sizeof(sockaddr_in); break; @@ -142,7 +249,6 @@ NfcConnector::CreateAddr(bool aIsServer, return false; } return true; - } bool @@ -168,7 +274,6 @@ NfcConnector::GetSocketAddr(const sockaddr_any& aAddr, } // anonymous namespace - namespace mozilla { namespace ipc { @@ -176,24 +281,46 @@ NfcConsumer::NfcConsumer(WorkerCrossThreadDispatcher* aDispatcher) : mDispatcher(aDispatcher) , mShutdown(false) { - ConnectSocket(new NfcConnector(), NFC_SOCKET_NAME); + mAddress = NFC_SOCKET_NAME; + + ConnectSocket(new NfcConnector(), mAddress.get()); +} + +nsresult +NfcConsumer::Register(WorkerCrossThreadDispatcher* aDispatcher) +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (sNfcConsumer) { + return NS_ERROR_FAILURE; + } + + nsRefPtr connection = new ConnectWorkerToNFC(); + if (!aDispatcher->PostTask(connection)) { + return NS_ERROR_UNEXPECTED; + } + + // Now that we're set up, connect ourselves to the NFC thread. + sNfcConsumer = new NfcConsumer(aDispatcher); + return NS_OK; } void NfcConsumer::Shutdown() { - mShutdown = true; - CloseSocket(); + MOZ_ASSERT(NS_IsMainThread()); + + sNfcConsumer->mShutdown = true; + sNfcConsumer->CloseSocket(); + sNfcConsumer = nullptr; } void NfcConsumer::ReceiveSocketData(nsAutoPtr& aMessage) { MOZ_ASSERT(NS_IsMainThread()); -#ifdef DEBUG - LOG("ReceiveSocketData\n"); -#endif - nsRefPtr dre(new DispatchNfcEvent(aMessage.forget())); + + nsRefPtr dre(new DispatchNFCEvent(aMessage.forget())); mDispatcher->PostTask(dre); } @@ -201,26 +328,22 @@ void NfcConsumer::OnConnectSuccess() { // Nothing to do here. - LOG("Socket open for Nfc\n"); + LOG("NFC: %s\n", __FUNCTION__); } void NfcConsumer::OnConnectError() { -#ifdef DEBUG - LOG("%s\n", __FUNCTION__); -#endif + LOG("NFC: %s\n", __FUNCTION__); CloseSocket(); } void NfcConsumer::OnDisconnect() { -#ifdef DEBUG - LOG("%s\n", __FUNCTION__); -#endif + LOG("NFC: %s\n", __FUNCTION__); if (!mShutdown) { - ConnectSocket(new NfcConnector(), NFC_SOCKET_NAME, 1000); + ConnectSocket(new NfcConnector(), mAddress.get(), 1000); } } diff --git a/ipc/nfc/Nfc.h b/ipc/nfc/Nfc.h index 1662a7bf6fe..7448827c972 100644 --- a/ipc/nfc/Nfc.h +++ b/ipc/nfc/Nfc.h @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* Copyright © 2013, Deutsche Telekom, Inc. */ + #ifndef mozilla_ipc_Nfc_h #define mozilla_ipc_Nfc_h 1 @@ -16,19 +18,24 @@ namespace ipc { class NfcConsumer : public mozilla::ipc::UnixSocketConsumer { public: - NfcConsumer(mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); - virtual ~NfcConsumer() { } - void Shutdown(); -private: - virtual void ReceiveSocketData(nsAutoPtr& aMessage); + virtual ~NfcConsumer() { } - virtual void OnConnectSuccess(); - virtual void OnConnectError(); - virtual void OnDisconnect(); + static nsresult Register(mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); + static void Shutdown(); private: - nsRefPtr mDispatcher; - bool mShutdown; + NfcConsumer(mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); + + virtual void ReceiveSocketData(nsAutoPtr& aMessage); + + virtual void OnConnectSuccess(); + virtual void OnConnectError(); + virtual void OnDisconnect(); + +private: + nsRefPtr mDispatcher; + nsCString mAddress; + bool mShutdown; }; } // namespace ipc From a6456e3528454935cfdaa3fc8aef2d41acfe8c49 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 5 Nov 2013 11:55:24 -0800 Subject: [PATCH 5/6] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/897ebc324cd5 Author: Bob Silverberg Desc: Merge pull request #13388 from zacc/bug_935041 Bug 935041 - Investigate test_sms_add_contact failure, resolve and re-en... ======== https://hg.mozilla.org/integration/gaia-central/rev/bfe3328d3051 Author: Zac Campbell Desc: Bug 935041 - Investigate test_sms_add_contact failure, resolve and re-enable the test --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 5d488e0bf66..c63359c27f2 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "6745e7046ff9a18195746fb2f0f46f71b0db4cc2", + "revision": "897ebc324cd5f6b3cf556197f4541ba54b1af7e3", "repo_path": "/integration/gaia-central" } From 0dfbb6b0345944114634de092642799b903999f1 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 5 Nov 2013 12:40:32 -0800 Subject: [PATCH 6/6] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/fe012cdbca54 Author: Adam Hyland Desc: Add truncation to avoid MMS filename limitation r=rwaldron --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c63359c27f2..5528d86cb36 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "897ebc324cd5f6b3cf556197f4541ba54b1af7e3", + "revision": "fe012cdbca542f414a72b0cba9cfb50a4aaf62ae", "repo_path": "/integration/gaia-central" }