Merge b2g-inbound to m-c a=merge CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Thu, 05 Mar 2015 15:35:34 -0800
changeset 232112 0189941a3fd5eb549c1ac95c166a5c7aaca3249b
parent 232072 1fe0dd36816b6171f04a98988cfb81af8016c94d (current diff)
parent 232111 1037f319225f4d5ea4aff28160cbedc8c9906f68 (diff)
child 232120 654067a71b22f19eaf898a38a2fafebab8ac78dc
child 232130 bfc78edb03a70bd6853e68323dc75e57bfaf8789
child 232143 cee98b327db359055ced05b751bcfb88d106c47f
push id28369
push userkwierso@gmail.com
push dateThu, 05 Mar 2015 23:36:09 +0000
treeherdermozilla-central@0189941a3fd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone39.0a1
first release with
nightly linux32
0189941a3fd5 / 39.0a1 / 20150306030229 / files
nightly linux64
0189941a3fd5 / 39.0a1 / 20150306030229 / files
nightly mac
0189941a3fd5 / 39.0a1 / 20150306030229 / files
nightly win32
0189941a3fd5 / 39.0a1 / 20150306030229 / files
nightly win64
0189941a3fd5 / 39.0a1 / 20150306030229 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge b2g-inbound to m-c a=merge CLOSED TREE
b2g/installer/package-manifest.in
--- a/b2g/config/dolphin/sources.xml
+++ b/b2g/config/dolphin/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="83760d213fb3bec7b4117d266fcfbf6fe2ba14ab"/>
   <project name="device/common" path="device/common" revision="6a2995683de147791e516aae2ccb31fdfbe2ad30"/>
@@ -116,17 +116,17 @@
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="cfcef469537869947abb9aa1d656774cc2678d4c"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
   <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="e0fc03e0a3062063c3c85996dcc881c0a49ed98d"/>
   <project name="platform/system/extras" path="system/extras" revision="10e78a05252b3de785f88c2d0b9ea8a428009c50"/>
   <project name="platform/system/media" path="system/media" revision="7ff72c2ea2496fa50b5e8a915e56e901c3ccd240"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="8f7d94ac711af4678169805137c6c42def39b3ed"/>
   <project name="platform/system/netd" path="system/netd" revision="3ae56364946d4a5bf5a5f83f12f9a45a30398e33"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
-  <project name="platform/system/vold" path="system/vold" revision="2e43efe1b30d0b98574d293059556aebd2f46454"/>
+  <project name="platform/system/vold" path="system/vold" revision="1a4ed05ce98de851c867ace572f2a97c0b50bb2e"/>
   <!--original fetch url was http://sprdsource.spreadtrum.com:8085/b2g/android-->
   <remote fetch="https://git.mozilla.org/external/sprd-aosp" name="sprd-aosp"/>
   <default remote="sprd-aosp" revision="sprdb2g_gonk4.4" sync-j="4"/>
   <!-- Stock Android things -->
   <project name="platform/external/icu4c" path="external/icu4c" revision="2bb01561780583cc37bc667f0ea79f48a122d8a2"/>
   <!-- dolphin specific things -->
   <project name="device/sprd" path="device/sprd" revision="e37e2ab9e0ac5fd78607cbbe3505f9a0a40d7a14"/>
   <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="2ea7f18a7bc45e16cb97a835dc86ee64d2d6b0b3"/>
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="173b3104bfcbd23fc9dccd4b0035fc49aae3d444">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="97c3d9b8b87774ca7a08c89145e95b55652459ef"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform_bionic" path="bionic" remote="b2g" revision="e2b3733ba3fa5e3f404e983d2e4142b1f6b1b846"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="4efd19d199ae52656604f794c5a77518400220fd">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
@@ -130,12 +130,12 @@
   <project name="android-development" path="development" remote="b2g" revision="dab55669da8f48b6e57df95d5af9f16b4a87b0b1"/>
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="3a9a17613cc685aa232432566ad6cc607eab4ec1"/>
   <project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="197cd9492b9fadaa915c5daf36ff557f8f4a8d1c"/>
   <project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="7d33aaf740bbf6c7c6e9c34a92b371eda311b66b"/>
   <project name="libnfcemu" path="external/libnfcemu" remote="b2g" revision="125ccf9bd5986c7728ea44508b3e1d1185ac028b"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c5f8d282efe4a4e8b1e31a37300944e338e60e4f"/>
   <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="9f28c4faea3b2f01db227b2467b08aeba96d9bec"/>
-  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="2eac5a8f931ab1c4aa41be7ac02db8a821df6efc"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="95faf8d85851de4a87d351b424c8c2f3cde3aa5b"/>
   <project name="android-sdk" path="sdk" remote="b2g" revision="8b1365af38c9a653df97349ee53a3f5d64fd590a"/>
   <project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
 </manifest>
--- a/b2g/config/emulator-kk/sources.xml
+++ b/b2g/config/emulator-kk/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="1950e4760fa14688b83cdbb5acaa1af9f82ef434"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="ac6eb97a37035c09fb5ede0852f0881e9aadf9ad"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="737f591c5f95477148d26602c7be56cbea0cdeb9"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="51da9b1981be481b92a59a826d4d78dc73d0989a"/>
   <project name="device/common" path="device/common" revision="798a3664597e6041985feab9aef42e98d458bc3d"/>
--- a/b2g/config/emulator-l/sources.xml
+++ b/b2g/config/emulator-l/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="52775e03a2d8532429dff579cb2cd56718e488c3">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="50d1ca4ab8add54523b7bc692860d57e8ee4c0d1"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="fb3845864573857677f9b500040a8f011eaf5078"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" revision="354496e8eddd28c743d8e02c02eeab02958367e6"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" revision="b37c91354272b7413a0dc058b7445e677921d39e"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" revision="a227c92e0170bcf2296a63386956946b0dd78ca7"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" revision="884626610186b6dbea52cec5194b1c4bcfe1cb98"/>
   <project groups="pdk,linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" path="prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" revision="29f9b82faa1af9730f52e933dca848546cbea84c"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="173b3104bfcbd23fc9dccd4b0035fc49aae3d444">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="97c3d9b8b87774ca7a08c89145e95b55652459ef"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform_bionic" path="bionic" remote="b2g" revision="e2b3733ba3fa5e3f404e983d2e4142b1f6b1b846"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/flame-kk/sources.xml
+++ b/b2g/config/flame-kk/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="a32003194f707f66a2d8cdb913ed1869f1926c5d"/>
   <project name="device/common" path="device/common" revision="96d4d2006c4fcb2f19a3fa47ab10cb409faa017b"/>
@@ -141,13 +141,13 @@
   <project name="platform/hardware/qcom/camera" path="hardware/qcom/camera" revision="2a1ded216a91bf62a72b1640cf01ab4998f37028"/>
   <project name="platform/hardware/qcom/display" path="hardware/qcom/display" revision="a74adcf8d88320d936daa8d20ce88ca0107fb916"/>
   <project name="platform/hardware/qcom/gps" path="hardware/qcom/gps" revision="9883ea57b0668d8f60dba025d4522dfa69a1fbfa"/>
   <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="a558dc844bf5144fc38603fd8f4df8d9557052a5"/>
   <project name="platform/hardware/qcom/wlan" path="hardware/qcom/wlan" revision="57ee1320ed7b4a1a1274d8f3f6c177cd6b9becb2"/>
   <project name="platform/hardware/ril" path="hardware/ril" revision="12b1977cc704b35f2e9db2bb423fa405348bc2f3"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="985bf15264d865fe7b9c5b45f61c451cbaafa43d"/>
   <project name="platform/system/core" path="system/core" revision="42839aedcf70bf6bc92a3b7ea4a5cc9bf9aef3f9"/>
-  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="2eac5a8f931ab1c4aa41be7ac02db8a821df6efc"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="95faf8d85851de4a87d351b424c8c2f3cde3aa5b"/>
   <project name="platform/system/qcom" path="system/qcom" revision="63e3f6f176caad587d42bba4c16b66d953fb23c2"/>
   <project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="d8952a42771045fca73ec600e2b42a4c7129d723"/>
   <project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="4c187c1f3a0dffd8e51a961735474ea703535b99"/>
 </manifest>
--- a/b2g/config/flame/sources.xml
+++ b/b2g/config/flame/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="4efd19d199ae52656604f794c5a77518400220fd">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="e95b4ce22c825da44d14299e1190ea39a5260bde"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="471afab478649078ad7c75ec6b252481a59e19b8"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
@@ -140,13 +140,13 @@
   <project name="platform/hardware/qcom/camera" path="hardware/qcom/camera" revision="5e110615212302c5d798a3c223dcee458817651c"/>
   <project name="platform/hardware/qcom/display" path="hardware/qcom/display" revision="fa9ffd47948eb24466de227e48fe9c4a7c5e7711"/>
   <project name="platform/hardware/qcom/gps" path="hardware/qcom/gps" revision="cd76b19aafd4229ccf83853d02faef8c51ca8b34"/>
   <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="8a0d0b0d9889ef99c4c6317c810db4c09295f15a"/>
   <project name="platform/hardware/qcom/wlan" path="hardware/qcom/wlan" revision="2208fa3537ace873b8f9ec2355055761c79dfd5f"/>
   <project name="platform/hardware/ril" path="hardware/ril" revision="c4e2ac95907a5519a0e09f01a0d8e27fec101af0"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="e1eb226fa3ad3874ea7b63c56a9dc7012d7ff3c2"/>
   <project name="platform/system/core" path="system/core" revision="adc485d8755af6a61641d197de7cfef667722580"/>
-  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="2eac5a8f931ab1c4aa41be7ac02db8a821df6efc"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="95faf8d85851de4a87d351b424c8c2f3cde3aa5b"/>
   <project name="platform/system/qcom" path="system/qcom" revision="1cdab258b15258b7f9657da70e6f06ebd5a2fc25"/>
   <project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="4ae5df252123591d5b941191790e7abed1bce5a4"/>
   <project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="ce18b47b4a4f93a581d672bbd5cb6d12fe796ca9"/>
 </manifest>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
-        "git_revision": "0017f2bbc63781a5409644b664d80ebaa1543653", 
+        "git_revision": "7a91c16bfa348be8b25e09719178efa051512988", 
         "remote": "https://git.mozilla.org/releases/gaia.git", 
         "branch": ""
     }, 
-    "revision": "2f6fbd430b0ee8042f103c52e4ead2d87f37e22e", 
+    "revision": "61047a7d0f14b8c435f7a5f8f3283f024b5518be", 
     "repo_path": "integration/gaia-central"
 }
--- a/b2g/config/nexus-4/sources.xml
+++ b/b2g/config/nexus-4/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="4efd19d199ae52656604f794c5a77518400220fd">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
@@ -125,17 +125,17 @@
   <project name="platform/system/netd" path="system/netd" revision="56112dd7b811301b718d0643a82fd5cac9522073"/>
   <project name="platform/system/security" path="system/security" revision="f48ff68fedbcdc12b570b7699745abb6e7574907"/>
   <project name="platform/system/vold" path="system/vold" revision="8de05d4a52b5a91e7336e6baa4592f945a6ddbea"/>
   <default remote="caf" revision="refs/tags/android-4.3_r2.1" sync-j="4"/>
   <!-- Nexus 4 specific things -->
   <project name="device-mako" path="device/lge/mako" remote="b2g" revision="78d17f0c117f0c66dd55ee8d5c5dde8ccc93ecba"/>
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="3a9a17613cc685aa232432566ad6cc607eab4ec1"/>
   <project name="device/lge/mako-kernel" path="device/lge/mako-kernel" revision="d1729e53d71d711c8fde25eab8728ff2b9b4df0e"/>
-  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="2eac5a8f931ab1c4aa41be7ac02db8a821df6efc"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="95faf8d85851de4a87d351b424c8c2f3cde3aa5b"/>
   <project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="7d33aaf740bbf6c7c6e9c34a92b371eda311b66b"/>
   <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
   <project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="0e1929fa3aa38bf9d40e9e953d619fab8164c82e"/>
   <project name="platform/hardware/qcom/audio" path="hardware/qcom/audio" revision="b0a528d839cfd9d170d092fe3743b5252b4243a6"/>
   <project name="platform/hardware/qcom/bt" path="hardware/qcom/bt" revision="380945eaa249a2dbdde0daa4c8adb8ca325edba6"/>
   <project name="platform/hardware/qcom/display" path="hardware/qcom/display" revision="6f3b0272cefaffeaed2a7d2bb8f633059f163ddc"/>
   <project name="platform/hardware/qcom/keymaster" path="hardware/qcom/keymaster" revision="16da8262c997a5a0d797885788a64a0771b26910"/>
   <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="689b476ba3eb46c34b81343295fe144a0e81a18e"/>
--- a/b2g/config/nexus-5-l/sources.xml
+++ b/b2g/config/nexus-5-l/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="52775e03a2d8532429dff579cb2cd56718e488c3">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="0017f2bbc63781a5409644b664d80ebaa1543653"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="7a91c16bfa348be8b25e09719178efa051512988"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2e85143db5d5f6edc4c2b97263c02b558fee757e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c42985975f2bbc42859b9136ed348186d989b93d"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="dc71d1dd75366780c713010a6be48bf8fead2379"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5c53c636b768f7d3ed3747aecc2b7fecf3a36894"/>
   <!-- Stock Android things -->
   <project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="50d1ca4ab8add54523b7bc692860d57e8ee4c0d1"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="fb3845864573857677f9b500040a8f011eaf5078"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" revision="354496e8eddd28c743d8e02c02eeab02958367e6"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" revision="b37c91354272b7413a0dc058b7445e677921d39e"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" revision="a227c92e0170bcf2296a63386956946b0dd78ca7"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" revision="884626610186b6dbea52cec5194b1c4bcfe1cb98"/>
   <project groups="pdk,linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" path="prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" revision="29f9b82faa1af9730f52e933dca848546cbea84c"/>
@@ -152,10 +152,10 @@
   <project name="platform/hardware/qcom/display" path="hardware/qcom/display" revision="0a21f566d8c9b01b9754d639e13358bdcb6c7650"/>
   <project name="platform/hardware/qcom/keymaster" path="hardware/qcom/keymaster" revision="028649652cd8f8f18cfb47d34bd78c435eb030ca"/>
   <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="758a80fbb178b5663d4edbb46944b2dc553cb1ca"/>
   <project name="platform/hardware/qcom/msm8x74" path="hardware/qcom/msm8x74" revision="aa0124820e22302149b1f2db603a9a72f1972527"/>
   <project name="platform/hardware/qcom/power" path="hardware/qcom/power" revision="37499eb89f31233135ca73b830b067ab24dc1be2"/>
   <project name="platform/hardware/qcom/sensors" path="hardware/qcom/sensors" revision="3724fd91ef5183684d97e2bf1d7ff948faabe090"/>
   <project name="platform/hardware/qcom/wlan" path="hardware/qcom/wlan" revision="2e54754cc0529d26ccac37ed291600048adbf6c0"/>
   <project name="platform/hardware/ril" path="hardware/ril" revision="71dfa8228ad0d6cdf6bac0426ac59404ab74b7f3"/>
-  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="2eac5a8f931ab1c4aa41be7ac02db8a821df6efc"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="95faf8d85851de4a87d351b424c8c2f3cde3aa5b"/>
 </manifest>
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -446,16 +446,18 @@
 @RESPATH@/components/NetworkManager.js
 @RESPATH@/components/NetworkManager.manifest
 @RESPATH@/components/NetworkService.js
 @RESPATH@/components/NetworkService.manifest
 @RESPATH@/components/NetworkStatsManager.js
 @RESPATH@/components/NetworkStatsManager.manifest
 @RESPATH@/components/NetworkStatsServiceProxy.js
 @RESPATH@/components/NetworkStatsServiceProxy.manifest
+@RESPATH@/components/TetheringService.js
+@RESPATH@/components/TetheringService.manifest
 @RESPATH@/components/WifiWorker.js
 @RESPATH@/components/WifiWorker.manifest
 #endif // MOZ_WIDGET_GONK
 
 ; Tethering
 #ifdef MOZ_WIDGET_GONK
 @RESPATH@/components/TetheringManager.js
 @RESPATH@/components/TetheringManager.manifest
--- a/dom/bluetooth/bluedroid/BluetoothHALHelpers.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHALHelpers.cpp
@@ -35,18 +35,19 @@ Convert(ConvertNamedValue& aIn, bt_prope
 {
   nsresult rv = Convert(aIn.mNamedValue.name(), aOut.type);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   if (aIn.mNamedValue.value().type() == BluetoothValue::Tuint32_t) {
     // Set discoverable timeout
-    aOut.val =
-      reinterpret_cast<void*>(aIn.mNamedValue.value().get_uint32_t());
+    aOut.val = const_cast<void*>(static_cast<const void*>(
+      &(aIn.mNamedValue.value().get_uint32_t())));
+      aOut.len = sizeof(uint32_t);
   } else if (aIn.mNamedValue.value().type() == BluetoothValue::TnsString) {
     // Set name
     aIn.mStringValue =
       NS_ConvertUTF16toUTF8(aIn.mNamedValue.value().get_nsString());
     aOut.val =
       const_cast<void*>(static_cast<const void*>(aIn.mStringValue.get()));
     aOut.len = strlen(static_cast<char*>(aOut.val));
   } else if (aIn.mNamedValue.value().type() == BluetoothValue::Tbool) {
--- a/dom/bluetooth2/bluedroid/BluetoothHALHelpers.cpp
+++ b/dom/bluetooth2/bluedroid/BluetoothHALHelpers.cpp
@@ -35,18 +35,19 @@ Convert(ConvertNamedValue& aIn, bt_prope
 {
   nsresult rv = Convert(aIn.mNamedValue.name(), aOut.type);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   if (aIn.mNamedValue.value().type() == BluetoothValue::Tuint32_t) {
     // Set discoverable timeout
-    aOut.val =
-      reinterpret_cast<void*>(aIn.mNamedValue.value().get_uint32_t());
+    aOut.val = const_cast<void*>(static_cast<const void*>(
+      &(aIn.mNamedValue.value().get_uint32_t())));
+      aOut.len = sizeof(uint32_t);
   } else if (aIn.mNamedValue.value().type() == BluetoothValue::TnsString) {
     // Set name
     aIn.mStringValue =
       NS_ConvertUTF16toUTF8(aIn.mNamedValue.value().get_nsString());
     aOut.val =
       const_cast<void*>(static_cast<const void*>(aIn.mStringValue.get()));
     aOut.len = strlen(static_cast<char*>(aOut.val));
   } else if (aIn.mNamedValue.value().type() == BluetoothValue::Tbool) {
--- a/dom/nfc/MozIsoDepTech.cpp
+++ b/dom/nfc/MozIsoDepTech.cpp
@@ -31,16 +31,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MozIsoDepTech)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MozIsoDepTech)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MozIsoDepTech)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
+const NFCTechType MozIsoDepTech::mTechnology = NFCTechType::ISO_DEP;
+
 /* static */
 already_AddRefed<MozIsoDepTech>
 MozIsoDepTech::Constructor(const GlobalObject& aGlobal,
                            MozNFCTag& aNFCTag,
                            ErrorResult& aRv)
 {
   ErrorResult rv;
   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
--- a/dom/nfc/MozIsoDepTech.h
+++ b/dom/nfc/MozIsoDepTech.h
@@ -40,15 +40,15 @@ public:
 
 private:
   MozIsoDepTech(nsPIDOMWindow* aWindow, MozNFCTag& aNFCTag);
   virtual ~MozIsoDepTech();
 
   nsRefPtr<nsPIDOMWindow> mWindow;
   nsRefPtr<MozNFCTag> mTag;
 
-  static const NFCTechType mTechnology = NFCTechType::ISO_DEP;
+  static const NFCTechType mTechnology;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif  // mozilla_dom_nfc_MozIsoDepTech_h__
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -76,16 +76,52 @@ const NFC_IPC_MSG_ENTRIES = [
   { permission: "nfc-manager",
     messages: ["NFC:CheckP2PRegistration",
                "NFC:NotifyUserAcceptedP2P",
                "NFC:NotifySendFileStatus",
                "NFC:ChangeRFState",
                "NFC:SetFocusApp"] }
 ];
 
+// Should be consistent with NfcRequestType defined in NfcOptions.webidl.
+const NfcRequestType = {
+  CHANGE_RF_STATE: "changeRFState",
+  READ_NDEF: "readNDEF",
+  WRITE_NDEF: "writeNDEF",
+  MAKE_READ_ONLY: "makeReadOnly",
+  FORMAT: "format",
+  TRANSCEIVE: "transceive"
+};
+
+// Should be consistent with NfcResponseType defined in NfcOptions.webidl.
+const NfcResponseType = {
+  CHANGE_RF_STATE_RSP: "changeRFStateRsp",
+  READ_NDEF_RSP: "readNDEFRsp",
+  WRITE_NDEF_RSP: "writeNDEFRsp",
+  MAKE_READ_ONLY_RSP: "makeReadOnlyRsp",
+  FORMAT_RSP: "formatRsp",
+  TRANSCEIVE_RSP: "transceiveRsp",
+};
+
+const EventMsgTable = {};
+EventMsgTable[NfcResponseType.CHANGE_RF_STATE_RSP] = "NFC:ChangeRFStateResponse";
+EventMsgTable[NfcResponseType.READ_NDEF_RSP] = "NFC:ReadNDEFResponse";
+EventMsgTable[NfcResponseType.WRITE_NDEF_RSP] = "NFC:WriteNDEFResponse";
+EventMsgTable[NfcResponseType.MAKE_READ_ONLY_RSP] = "NFC:MakeReadOnlyResponse";
+EventMsgTable[NfcResponseType.FORMAT_RSP] = "NFC:FormatResponse";
+EventMsgTable[NfcResponseType.TRANSCEIVE_RSP] = "NFC:TransceiveResponse";
+
+// Should be consistent with NfcNotificationType defined in NfcOptions.webidl.
+const NfcNotificationType = {
+  INITIALIZED: "initialized",
+  TECH_DISCOVERED: "techDiscovered",
+  TECH_LOST: "techLost",
+  HCI_EVENT_TRANSACTION: "hciEventTransaction"
+};
+
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageBroadcaster");
 XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
                                    "@mozilla.org/system-message-internal;1",
                                    "nsISystemMessagesInternal");
 XPCOMUtils.defineLazyServiceGetter(this, "UUIDGenerator",
                                     "@mozilla.org/uuid-generator;1",
@@ -236,16 +272,24 @@ XPCOMUtils.defineLazyGetter(this, "gMess
         debug("Peer already lost or " + appId + " is not a registered PeerReadytarget");
         return;
       }
 
       this.notifyDOMEvent(target, {event: NFC.PEER_EVENT_READY,
                                    sessionToken: sessionToken});
     },
 
+    notifySendFileStatus: function notifySendFileStatus(message) {
+      if (message.data.status) {
+        message.data.errorMsg =
+            this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
+      }
+      this.nfc.sendFileStatusResponse(message.data);
+    },
+
     callDefaultFoundHandler: function callDefaultFoundHandler(message) {
       let sysMsg = new NfcTechDiscoveredSysMsg(message.sessionToken,
                                                message.isP2P,
                                                message.records || null);
       gSystemMessenger.broadcastMessage("nfc-manager-tech-discovered", sysMsg);
     },
 
     callDefaultLostHandler: function callDefaultLostHandler(message) {
@@ -341,22 +385,17 @@ XPCOMUtils.defineLazyGetter(this, "gMess
           this.checkP2PRegistration(message);
           return null;
         case "NFC:NotifyUserAcceptedP2P":
           this.notifyUserAcceptedP2P(message.data.appId);
           return null;
         case "NFC:NotifySendFileStatus":
           // Upon receiving the status of sendFile operation, send the response
           // to appropriate content process.
-          message.data.type = "NotifySendFileStatusResponse";
-          if (message.data.status) {
-            message.data.errorMsg =
-              this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
-          }
-          this.nfc.sendNfcResponse(message.data);
+          this.notifySendFileStatus(message);
           return null;
         case "NFC:CallDefaultFoundHandler":
           this.callDefaultFoundHandler(message.data);
           return null;
         case "NFC:CallDefaultLostHandler":
           this.callDefaultLostHandler(message.data);
           return null;
         default:
@@ -477,25 +516,43 @@ Nfc.prototype = {
    *        An optional message object to send.
    */
   sendToNfcService: function sendToNfcService(nfcMessageType, message) {
     message = message || {};
     message.type = nfcMessageType;
     this.nfcService.sendCommand(message);
   },
 
+  sendFileStatusResponse: function sendFileStatusResponse(message) {
+    let target = this.getTargetByRequestId(message.requestId);
+    if (!target) {
+      return;
+    }
+
+    target.sendAsyncMessage("NFC:NotifySendFileStatusResponse", message);
+  },
+
   sendNfcResponse: function sendNfcResponse(message) {
-    let target = this.targetsByRequestId[message.requestId];
+    let target = this.getTargetByRequestId(message.requestId);
     if (!target) {
-      debug("No target for requestId: " + message.requestId);
       return;
     }
-    delete this.targetsByRequestId[message.requestId];
+
+    target.sendAsyncMessage(EventMsgTable[message.type], message);
+  },
 
-    target.sendAsyncMessage("NFC:" + message.type, message);
+  getTargetByRequestId: function getTargetByRequestId(requestId) {
+    let target = this.targetsByRequestId[requestId];
+    if (!target) {
+      debug("No target for requestId: " + requestId);
+      return null;
+    }
+    delete this.targetsByRequestId[requestId];
+
+    return target;
   },
 
   /**
    * Send Error response to content. This is used only
    * in case of discovering an error in message received from
    * content process.
    *
    * @param message
@@ -517,22 +574,22 @@ Nfc.prototype = {
 
   /**
    * Process the incoming message from the NFC Service.
    */
   onEvent: function onEvent(event) {
     let message = Cu.cloneInto(event, this);
     DEBUG && debug("Received message from NFC Service: " + JSON.stringify(message));
 
+    message.type = message.rspType || message.ntfType;
     switch (message.type) {
-      case "InitializedNotification":
+      case NfcNotificationType.INITIALIZED:
         // Do nothing.
         break;
-      case "TechDiscoveredNotification":
-        message.type = "techDiscovered";
+      case NfcNotificationType.TECH_DISCOVERED:
         // Update the upper layers with a session token (alias)
         message.sessionToken =
           SessionHelper.registerSession(message.sessionId, message.isP2P);
         // Do not expose the actual session to the content
         let sessionId = message.sessionId;
         delete message.sessionId;
 
         if (SessionHelper.isP2PSession(sessionId)) {
@@ -543,45 +600,43 @@ Nfc.prototype = {
             gMessageManager.callDefaultFoundHandler(message);
           } else {
             gMessageManager.onPeerEvent(NFC.PEER_EVENT_FOUND, message.sessionToken);
           }
         } else {
           gMessageManager.onTagFound(message);
         }
         break;
-      case "TechLostNotification":
-        message.type = "techLost";
-
+      case NfcNotificationType.TECH_LOST:
         // Update the upper layers with a session token (alias)
         message.sessionToken = SessionHelper.getToken(message.sessionId);
         if (SessionHelper.isP2PSession(message.sessionId)) {
           gMessageManager.onPeerEvent(NFC.PEER_EVENT_LOST, message.sessionToken);
         } else {
           gMessageManager.onTagLost(message.sessionToken);
         }
 
         SessionHelper.unregisterSession(message.sessionId);
         break;
-     case "HCIEventTransactionNotification":
+      case NfcNotificationType.HCI_EVENT_TRANSACTION:
         this.notifyHCIEventTransaction(message);
         break;
-     case "ChangeRFStateResponse":
+      case NfcResponseType.CHANGE_RF_STATE_RSP:
         this.sendNfcResponse(message);
 
         if (!message.errorMsg) {
           this.rfState = message.rfState;
           gMessageManager.onRFStateChanged(this.rfState);
         }
         break;
-      case "ReadNDEFResponse": // Fall through.
-      case "MakeReadOnlyResponse":
-      case "FormatResponse":
-      case "TransceiveResponse":
-      case "WriteNDEFResponse":
+      case NfcResponseType.READ_NDEF_RSP: // Fall through.
+      case NfcResponseType.WRITE_NDEF_RSP:
+      case NfcResponseType.MAKE_READ_ONLY_RSP:
+      case NfcResponseType.FORMAT_RSP:
+      case NfcResponseType.TRANSCEIVE_RSP:
         this.sendNfcResponse(message);
         break;
       default:
         throw new Error("Don't know about this message type: " + message.type);
     }
   },
 
   // HCI Event Transaction
@@ -612,33 +667,33 @@ Nfc.prototype = {
            "NFC:SendFile",
            "NFC:QueryInfo"].indexOf(message.name) == -1) {
       // Update the current sessionId before sending to the NFC service.
       message.data.sessionId = SessionHelper.getId(message.data.sessionToken);
     }
 
     switch (message.name) {
       case "NFC:ChangeRFState":
-        this.sendToNfcService("changeRFState", message.data);
+        this.sendToNfcService(NfcRequestType.CHANGE_RF_STATE, message.data);
         break;
       case "NFC:ReadNDEF":
-        this.sendToNfcService("readNDEF", message.data);
+        this.sendToNfcService(NfcRequestType.READ_NDEF, message.data);
         break;
       case "NFC:WriteNDEF":
         message.data.isP2P = SessionHelper.isP2PSession(message.data.sessionId);
-        this.sendToNfcService("writeNDEF", message.data);
+        this.sendToNfcService(NfcRequestType.WRITE_NDEF, message.data);
         break;
       case "NFC:MakeReadOnly":
-        this.sendToNfcService("makeReadOnly", message.data);
+        this.sendToNfcService(NfcRequestType.MAKE_READ_ONLY, message.data);
         break;
       case "NFC:Format":
-        this.sendToNfcService("format", message.data);
+        this.sendToNfcService(NfcRequestType.FORMAT, message.data);
         break;
       case "NFC:Transceive":
-        this.sendToNfcService("transceive", message.data);
+        this.sendToNfcService(NfcRequestType.TRANSCEIVE, message.data);
         break;
       case "NFC:SendFile":
         // Chrome process is the arbitrator / mediator between
         // system app (content process) that issued nfc 'sendFile' operation
         // and system app that handles the system message :
         // 'nfc-manager-send-file'. System app subsequently handover's
         // the data to alternate carrier's (BT / WiFi) 'sendFile' interface.
 
--- a/dom/nfc/gonk/NfcGonkMessage.h
+++ b/dom/nfc/gonk/NfcGonkMessage.h
@@ -5,41 +5,16 @@
 #ifndef NfcGonkMessage_h
 #define NfcGonkMessage_h
 
 namespace mozilla {
 
 #define NFCD_MAJOR_VERSION 1
 #define NFCD_MINOR_VERSION 21
 
-enum NfcRequest {
-  ChangeRFStateReq,
-  ReadNDEFReq,
-  WriteNDEFReq,
-  MakeReadOnlyReq,
-  FormatReq,
-  TransceiveReq,
-};
-
-enum NfcResponse {
-  ChangeRFStateRsp,
-  ReadNDEFRsp,
-  WriteNDEFRsp,
-  MakeReadOnlyRsp,
-  FormatRsp,
-  TransceiveRsp,
-};
-
-enum NfcNotification {
-  Initialized,
-  TechDiscovered,
-  TechLost,
-  HCIEventTransaction,
-};
-
 enum NfcTechlogy {
   NDEF = 0,
   NDEFWritable,
   NDEFFormattable,
   P2P,
 };
 
 enum NfcErrorCode {
--- a/dom/nfc/gonk/NfcMessageHandler.cpp
+++ b/dom/nfc/gonk/NfcMessageHandler.cpp
@@ -12,206 +12,191 @@
 
 #include <android/log.h>
 #define NMH_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "NfcMessageHandler", args)
 
 using namespace android;
 using namespace mozilla;
 using namespace mozilla::dom;
 
-static const char* kChangeRFStateRequest = "changeRFState";
-static const char* kReadNDEFRequest = "readNDEF";
-static const char* kWriteNDEFRequest = "writeNDEF";
-static const char* kMakeReadOnlyRequest = "makeReadOnly";
-static const char* kFormatRequest = "format";
-static const char* kTransceiveRequest = "transceive";
-
-static const char* kChangeRFStateResponse = "ChangeRFStateResponse";
-static const char* kReadNDEFResponse = "ReadNDEFResponse";
-static const char* kWriteNDEFResponse = "WriteNDEFResponse";
-static const char* kMakeReadOnlyResponse = "MakeReadOnlyResponse";
-static const char* kFormatResponse = "FormatResponse";
-static const char* kTransceiveResponse = "TransceiveResponse";
-
-static const char* kInitializedNotification = "InitializedNotification";
-static const char* kTechDiscoveredNotification = "TechDiscoveredNotification";
-static const char* kTechLostNotification = "TechLostNotification";
-static const char* kHCIEventTransactionNotification =
-                     "HCIEventTransactionNotification";
-
 bool
 NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions)
 {
   bool result;
-  const char* type = NS_ConvertUTF16toUTF8(aOptions.mType).get();
-
-  if (!strcmp(type, kChangeRFStateRequest)) {
-    result = ChangeRFStateRequest(aParcel, aOptions);
-  } else if (!strcmp(type, kReadNDEFRequest)) {
-    result = ReadNDEFRequest(aParcel, aOptions);
-  } else if (!strcmp(type, kWriteNDEFRequest)) {
-    result = WriteNDEFRequest(aParcel, aOptions);
-  } else if (!strcmp(type, kMakeReadOnlyRequest)) {
-    result = MakeReadOnlyRequest(aParcel, aOptions);
-  } else if (!strcmp(type, kFormatRequest)) {
-    result = FormatRequest(aParcel, aOptions);
-  } else if (!strcmp(type, kTransceiveRequest)) {
-    result = TransceiveRequest(aParcel, aOptions);
-  } else {
-    result = false;
-  }
+  switch (aOptions.mType) {
+    case NfcRequestType::ChangeRFState:
+      result = ChangeRFStateRequest(aParcel, aOptions);
+      break;
+    case NfcRequestType::ReadNDEF:
+      result = ReadNDEFRequest(aParcel, aOptions);
+      break;
+    case NfcRequestType::WriteNDEF:
+      result = WriteNDEFRequest(aParcel, aOptions);
+      break;
+    case NfcRequestType::MakeReadOnly:
+      result = MakeReadOnlyRequest(aParcel, aOptions);
+      break;
+    case NfcRequestType::Format:
+      result = FormatRequest(aParcel, aOptions);
+      break;
+    case NfcRequestType::Transceive:
+      result = TransceiveRequest(aParcel, aOptions);
+      break;
+    default:
+      result = false;
+      break;
+  };
 
   return result;
 }
 
 bool
 NfcMessageHandler::Unmarshall(const Parcel& aParcel, EventOptions& aOptions)
 {
   mozilla::unused << htonl(aParcel.readInt32());  // parcel size
   int32_t type = aParcel.readInt32();
-  bool isNotification = type >> 31;
+  bool isNtf = type >> 31;
   int32_t msgType = type & ~(1 << 31);
 
-  return isNotification ? ProcessNotification(msgType, aParcel, aOptions) :
-                          ProcessResponse(msgType, aParcel, aOptions);
+  return isNtf ? ProcessNotification(msgType, aParcel, aOptions) :
+                 ProcessResponse(msgType, aParcel, aOptions);
 }
 
 bool
 NfcMessageHandler::ProcessResponse(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
 {
   bool result;
-  switch (aType) {
-    case NfcResponse::ChangeRFStateRsp:
+  aOptions.mRspType = static_cast<NfcResponseType>(aType);
+  switch (aOptions.mRspType) {
+    case NfcResponseType::ChangeRFStateRsp:
       result = ChangeRFStateResponse(aParcel, aOptions);
       break;
-    case NfcResponse::ReadNDEFRsp:
+    case NfcResponseType::ReadNDEFRsp:
       result = ReadNDEFResponse(aParcel, aOptions);
       break;
-    case NfcResponse::WriteNDEFRsp: // Fall through.
-    case NfcResponse::MakeReadOnlyRsp:
-    case NfcResponse::FormatRsp:
-      result = GeneralResponse(aType, aParcel, aOptions);
+    case NfcResponseType::WriteNDEFRsp: // Fall through.
+    case NfcResponseType::MakeReadOnlyRsp:
+    case NfcResponseType::FormatRsp:
+      result = GeneralResponse(aParcel, aOptions);
       break;
-    case NfcResponse::TransceiveRsp:
+    case NfcResponseType::TransceiveRsp:
       result = TransceiveResponse(aParcel, aOptions);
       break;
     default:
       result = false;
   }
 
   return result;
 }
 
 bool
 NfcMessageHandler::ProcessNotification(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
 {
   bool result;
-  switch (aType) {
-    case NfcNotification::Initialized:
+  aOptions.mNtfType = static_cast<NfcNotificationType>(aType);
+  switch (aOptions.mNtfType) {
+    case NfcNotificationType::Initialized:
       result = InitializeNotification(aParcel, aOptions);
       break;
-    case NfcNotification::TechDiscovered:
+    case NfcNotificationType::TechDiscovered:
       result = TechDiscoveredNotification(aParcel, aOptions);
       break;
-    case NfcNotification::TechLost:
+    case NfcNotificationType::TechLost:
       result = TechLostNotification(aParcel, aOptions);
       break;
-    case NfcNotification::HCIEventTransaction:
+    case NfcNotificationType::HciEventTransaction:
       result = HCIEventTransactionNotification(aParcel, aOptions);
       break;
     default:
       result = false;
       break;
   }
 
   return result;
 }
 
 bool
-NfcMessageHandler::GeneralResponse(const int32_t aResponse, const Parcel& aParcel, EventOptions& aOptions)
+NfcMessageHandler::GeneralResponse(const Parcel& aParcel, EventOptions& aOptions)
 {
-  const char* type;
-  switch (aResponse) {
-    case NfcResponse::WriteNDEFRsp:
-      type = kWriteNDEFResponse;
-      break;
-    case NfcResponse::MakeReadOnlyRsp:
-      type = kMakeReadOnlyResponse;
-      break;
-    case NfcResponse::FormatRsp:
-      type = kFormatResponse;
-      break;
-    default:
-      NMH_LOG("Nfcd, unknown general aResponse %d", aResponse);
-      return false;
-  }
-
-  aOptions.mType = NS_ConvertUTF8toUTF16(type);
   aOptions.mErrorCode = aParcel.readInt32();
   aOptions.mSessionId = aParcel.readInt32();
 
   NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
   aOptions.mRequestId = mRequestIdQueue[0];
   mRequestIdQueue.RemoveElementAt(0);
   return true;
 }
 
 bool
 NfcMessageHandler::ChangeRFStateRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
-  aParcel.writeInt32(NfcRequest::ChangeRFStateReq);
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::ChangeRFState));
   aParcel.writeInt32(aOptions.mRfState);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
 NfcMessageHandler::ChangeRFStateResponse(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kChangeRFStateResponse);
   aOptions.mErrorCode = aParcel.readInt32();
   NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
   aOptions.mRequestId = mRequestIdQueue[0];
   mRequestIdQueue.RemoveElementAt(0);
 
   aOptions.mRfState = aParcel.readInt32();
   return true;
 }
 
 bool
 NfcMessageHandler::ReadNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
-  aParcel.writeInt32(NfcRequest::ReadNDEFReq);
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::ReadNDEF));
   aParcel.writeInt32(aOptions.mSessionId);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
 NfcMessageHandler::ReadNDEFResponse(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kReadNDEFResponse);
   aOptions.mErrorCode = aParcel.readInt32();
   aOptions.mSessionId = aParcel.readInt32();
 
   NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
   aOptions.mRequestId = mRequestIdQueue[0];
   mRequestIdQueue.RemoveElementAt(0);
 
   if (aOptions.mErrorCode == NfcErrorCode::Success) {
     ReadNDEFMessage(aParcel, aOptions);
   }
 
   return true;
 }
 
 bool
+NfcMessageHandler::TransceiveRequest(Parcel& aParcel, const CommandOptions& aOptions)
+{
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::Transceive));
+  aParcel.writeInt32(aOptions.mSessionId);
+  aParcel.writeInt32(aOptions.mTechnology);
+
+  uint32_t length = aOptions.mCommand.Length();
+  aParcel.writeInt32(length);
+
+  void* data = aParcel.writeInplace(length);
+  memcpy(data, aOptions.mCommand.Elements(), length);
+
+  mRequestIdQueue.AppendElement(aOptions.mRequestId);
+  return true;
+}
+
+bool
 NfcMessageHandler::TransceiveResponse(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kTransceiveResponse);
   aOptions.mErrorCode = aParcel.readInt32();
   aOptions.mSessionId = aParcel.readInt32();
 
   NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
   aOptions.mRequestId = mRequestIdQueue[0];
   mRequestIdQueue.RemoveElementAt(0);
 
   if (aOptions.mErrorCode == NfcErrorCode::Success) {
@@ -219,80 +204,61 @@ NfcMessageHandler::TransceiveResponse(co
   }
 
   return true;
 }
 
 bool
 NfcMessageHandler::WriteNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
-  aParcel.writeInt32(NfcRequest::WriteNDEFReq);
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::WriteNDEF));
   aParcel.writeInt32(aOptions.mSessionId);
   aParcel.writeInt32(aOptions.mIsP2P);
   WriteNDEFMessage(aParcel, aOptions);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
 NfcMessageHandler::MakeReadOnlyRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
-  aParcel.writeInt32(NfcRequest::MakeReadOnlyReq);
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::MakeReadOnly));
   aParcel.writeInt32(aOptions.mSessionId);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
 NfcMessageHandler::FormatRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
-  aParcel.writeInt32(NfcRequest::FormatReq);
+  aParcel.writeInt32(static_cast<int32_t>(NfcRequestType::Format));
   aParcel.writeInt32(aOptions.mSessionId);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
-NfcMessageHandler::TransceiveRequest(Parcel& aParcel, const CommandOptions& aOptions)
-{
-  aParcel.writeInt32(NfcRequest::TransceiveReq);
-  aParcel.writeInt32(aOptions.mSessionId);
-  aParcel.writeInt32(aOptions.mTechnology);
-
-  uint32_t length = aOptions.mCommand.Length();
-  aParcel.writeInt32(length);
-
-  void* data = aParcel.writeInplace(length);
-  memcpy(data, aOptions.mCommand.Elements(), length);
-
-  mRequestIdQueue.AppendElement(aOptions.mRequestId);
-  return true;
-}
-
-bool
 NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kInitializedNotification);
   aOptions.mStatus = aParcel.readInt32();
   aOptions.mMajorVersion = aParcel.readInt32();
   aOptions.mMinorVersion = aParcel.readInt32();
 
   if (aOptions.mMajorVersion != NFCD_MAJOR_VERSION ||
       aOptions.mMinorVersion != NFCD_MINOR_VERSION) {
     NMH_LOG("NFCD version mismatched. majorVersion: %d, minorVersion: %d",
             aOptions.mMajorVersion, aOptions.mMinorVersion);
   }
 
   return true;
 }
 
 bool
 NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kTechDiscoveredNotification);
   aOptions.mSessionId = aParcel.readInt32();
   aOptions.mIsP2P = aParcel.readInt32();
 
   int32_t techCount = aParcel.readInt32();
   aOptions.mTechList.AppendElements(
     static_cast<const uint8_t*>(aParcel.readInplace(techCount)), techCount);
 
   int32_t idCount = aParcel.readInt32();
@@ -313,26 +279,23 @@ NfcMessageHandler::TechDiscoveredNotific
   }
 
   return true;
 }
 
 bool
 NfcMessageHandler::TechLostNotification(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kTechLostNotification);
   aOptions.mSessionId = aParcel.readInt32();
   return true;
 }
 
 bool
 NfcMessageHandler::HCIEventTransactionNotification(const Parcel& aParcel, EventOptions& aOptions)
 {
-  aOptions.mType = NS_ConvertUTF8toUTF16(kHCIEventTransactionNotification);
-
   aOptions.mOriginType = aParcel.readInt32();
   aOptions.mOriginIndex = aParcel.readInt32();
 
   int32_t aidLength = aParcel.readInt32();
   aOptions.mAid.AppendElements(
     static_cast<const uint8_t*>(aParcel.readInplace(aidLength)), aidLength);
 
   int32_t payloadLength = aParcel.readInt32();
--- a/dom/nfc/gonk/NfcMessageHandler.h
+++ b/dom/nfc/gonk/NfcMessageHandler.h
@@ -20,17 +20,17 @@ class EventOptions;
 class NfcMessageHandler
 {
 public:
   bool Marshall(android::Parcel& aParcel, const CommandOptions& aOptions);
   bool Unmarshall(const android::Parcel& aParcel, EventOptions& aOptions);
 
 private:
   bool ProcessResponse(int32_t aType, const android::Parcel& aParcel, EventOptions& aOptions);
-  bool GeneralResponse(int32_t aResponse, const android::Parcel& aParcel, EventOptions& aOptions);
+  bool GeneralResponse(const android::Parcel& aParcel, EventOptions& aOptions);
   bool ChangeRFStateRequest(android::Parcel& aParcel, const CommandOptions& options);
   bool ChangeRFStateResponse(const android::Parcel& aParcel, EventOptions& aOptions);
   bool ReadNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
   bool ReadNDEFResponse(const android::Parcel& aParcel, EventOptions& aOptions);
   bool WriteNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
   bool MakeReadOnlyRequest(android::Parcel& aParcel, const CommandOptions& options);
   bool FormatRequest(android::Parcel& aParcel, const CommandOptions& options);
   bool TransceiveRequest(android::Parcel& aParcel, const CommandOptions& options);
--- a/dom/nfc/gonk/NfcOptions.h
+++ b/dom/nfc/gonk/NfcOptions.h
@@ -78,37 +78,40 @@ struct CommandOptions
 
       mRecords.AppendElement(record);
     }
 
 #undef COPY_FIELD
 #undef COPY_OPT_FIELD
   }
 
-  nsString mType;
+  dom::NfcRequestType mType;
   int32_t mSessionId;
   nsString mRequestId;
   int32_t mRfState;
   int32_t mTechType;
   bool mIsP2P;
   nsTArray<NDEFRecordStruct> mRecords;
   int32_t mTechnology;
   nsTArray<uint8_t> mCommand;
 };
 
 struct EventOptions
 {
   EventOptions()
-    : mType(EmptyString()), mStatus(-1), mErrorCode(-1), mSessionId(-1), mRequestId(EmptyString()),
+    : mRspType(dom::NfcResponseType::EndGuard_),
+      mNtfType(dom::NfcNotificationType::EndGuard_),
+      mStatus(-1), mErrorCode(-1), mSessionId(-1), mRequestId(EmptyString()),
       mMajorVersion(-1), mMinorVersion(-1), mIsP2P(-1),
       mTagType(-1), mMaxNDEFSize(-1), mIsReadOnly(-1), mIsFormatable(-1), mRfState(-1),
       mOriginType(-1), mOriginIndex(-1)
   {}
 
-  nsString mType;
+  dom::NfcResponseType mRspType;
+  dom::NfcNotificationType mNtfType;
   int32_t mStatus;
   int32_t mErrorCode;
   int32_t mSessionId;
   nsString mRequestId;
   int32_t mMajorVersion;
   int32_t mMinorVersion;
   nsTArray<uint8_t> mTechList;
   nsTArray<uint8_t> mTagId;
--- a/dom/nfc/gonk/NfcService.cpp
+++ b/dom/nfc/gonk/NfcService.cpp
@@ -93,17 +93,25 @@ public:
 #define COPY_FIELD(prop) event.prop = mEvent.prop;
 
 #define COPY_OPT_FIELD(prop, defaultValue)           \
     if (mEvent.prop != defaultValue) {               \
       event.prop.Construct();                        \
       event.prop.Value() = mEvent.prop;              \
     }
 
-    COPY_FIELD(mType)
+    COPY_OPT_FIELD(mRspType, NfcResponseType::EndGuard_)
+    COPY_OPT_FIELD(mNtfType, NfcNotificationType::EndGuard_)
+
+    // Only one of rspType and ntfType should be used.
+    MOZ_ASSERT(((mEvent.mRspType != NfcResponseType::EndGuard_) ||
+                (mEvent.mNtfType != NfcNotificationType::EndGuard_)) &&
+               ((mEvent.mRspType == NfcResponseType::EndGuard_) ||
+                (mEvent.mNtfType == NfcNotificationType::EndGuard_)));
+
     COPY_OPT_FIELD(mRequestId, EmptyString())
     COPY_OPT_FIELD(mStatus, -1)
     COPY_OPT_FIELD(mSessionId, -1)
     COPY_OPT_FIELD(mMajorVersion, -1)
     COPY_OPT_FIELD(mMinorVersion, -1)
 
     if (mEvent.mRfState != -1) {
       event.mRfState.Construct();
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -13,109 +13,43 @@ Cu.import("resource://gre/modules/system
 Cu.import("resource://gre/modules/Promise.jsm");
 
 const NETWORKMANAGER_CONTRACTID = "@mozilla.org/network/manager;1";
 const NETWORKMANAGER_CID =
   Components.ID("{33901e46-33b8-11e1-9869-f46d04d25bcc}");
 
 const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
 
-XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
-                                   "@mozilla.org/settingsService;1",
-                                   "nsISettingsService");
 XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
   return Cc["@mozilla.org/parentprocessmessagemanager;1"]
          .getService(Ci.nsIMessageBroadcaster);
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
                                    "nsIDNSService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
                                    "@mozilla.org/network/service;1",
                                    "nsINetworkService");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
-                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
-                                   "nsIMobileConnectionService");
-
 const TOPIC_INTERFACE_REGISTERED     = "network-interface-registered";
 const TOPIC_INTERFACE_UNREGISTERED   = "network-interface-unregistered";
 const TOPIC_ACTIVE_CHANGED           = "network-active-changed";
-const TOPIC_MOZSETTINGS_CHANGED      = "mozsettings-changed";
 const TOPIC_PREF_CHANGED             = "nsPref:changed";
 const TOPIC_XPCOM_SHUTDOWN           = "xpcom-shutdown";
 const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
 const PREF_MANAGE_OFFLINE_STATUS     = "network.gonk.manage-offline-status";
 
-const POSSIBLE_USB_INTERFACE_NAME = "rndis0,usb0";
-const DEFAULT_USB_INTERFACE_NAME  = "rndis0";
-const DEFAULT_3G_INTERFACE_NAME   = "rmnet0";
-const DEFAULT_WIFI_INTERFACE_NAME = "wlan0";
-
-// The kernel's proc entry for network lists.
-const KERNEL_NETWORK_ENTRY = "/sys/class/net";
-
-const TETHERING_TYPE_WIFI = "WiFi";
-const TETHERING_TYPE_USB  = "USB";
-
-const WIFI_FIRMWARE_AP            = "AP";
-const WIFI_FIRMWARE_STATION       = "STA";
-const WIFI_SECURITY_TYPE_NONE     = "open";
-const WIFI_SECURITY_TYPE_WPA_PSK  = "wpa-psk";
-const WIFI_SECURITY_TYPE_WPA2_PSK = "wpa2-psk";
-const WIFI_CTRL_INTERFACE         = "wl0.1";
-
-const NETWORK_INTERFACE_UP   = "up";
-const NETWORK_INTERFACE_DOWN = "down";
-
-const TETHERING_STATE_ONGOING = "ongoing";
-const TETHERING_STATE_IDLE    = "idle";
-const TETHERING_STATE_ACTIVE  = "active";
-
-// Settings DB path for USB tethering.
-const SETTINGS_USB_ENABLED             = "tethering.usb.enabled";
-const SETTINGS_USB_IP                  = "tethering.usb.ip";
-const SETTINGS_USB_PREFIX              = "tethering.usb.prefix";
-const SETTINGS_USB_DHCPSERVER_STARTIP  = "tethering.usb.dhcpserver.startip";
-const SETTINGS_USB_DHCPSERVER_ENDIP    = "tethering.usb.dhcpserver.endip";
-const SETTINGS_USB_DNS1                = "tethering.usb.dns1";
-const SETTINGS_USB_DNS2                = "tethering.usb.dns2";
-
-// Settings DB path for WIFI tethering.
-const SETTINGS_WIFI_DHCPSERVER_STARTIP = "tethering.wifi.dhcpserver.startip";
-const SETTINGS_WIFI_DHCPSERVER_ENDIP   = "tethering.wifi.dhcpserver.endip";
-
-// Settings DB patch for dun required setting.
-const SETTINGS_DUN_REQUIRED = "tethering.dun.required";
-
-// Default value for USB tethering.
-const DEFAULT_USB_IP                   = "192.168.0.1";
-const DEFAULT_USB_PREFIX               = "24";
-const DEFAULT_USB_DHCPSERVER_STARTIP   = "192.168.0.10";
-const DEFAULT_USB_DHCPSERVER_ENDIP     = "192.168.0.30";
-
-const DEFAULT_DNS1                     = "8.8.8.8";
-const DEFAULT_DNS2                     = "8.8.4.4";
-
-const DEFAULT_WIFI_DHCPSERVER_STARTIP  = "192.168.1.10";
-const DEFAULT_WIFI_DHCPSERVER_ENDIP    = "192.168.1.30";
-
 const IPV4_ADDRESS_ANY                 = "0.0.0.0";
 const IPV6_ADDRESS_ANY                 = "::0";
 
 const IPV4_MAX_PREFIX_LENGTH           = 32;
 const IPV6_MAX_PREFIX_LENGTH           = 128;
 
-const SETTINGS_DATA_DEFAULT_SERVICE_ID = "ril.data.defaultServiceId";
-const MOBILE_DUN_CONNECT_TIMEOUT       = 30000;
-const MOBILE_DUN_RETRY_INTERVAL        = 5000;
-const MOBILE_DUN_MAX_RETRIES           = 5;
-
 // Connection Type for Network Information API
 const CONNECTION_TYPE_CELLULAR  = 0;
 const CONNECTION_TYPE_BLUETOOTH = 1;
 const CONNECTION_TYPE_ETHERNET  = 2;
 const CONNECTION_TYPE_WIFI      = 3;
 const CONNECTION_TYPE_OTHER     = 4;
 const CONNECTION_TYPE_NONE      = 5;
 
@@ -174,72 +108,26 @@ NetworkInterfaceLinks.prototype = {
 
 /**
  * This component watches for network interfaces changing state and then
  * adjusts routes etc. accordingly.
  */
 function NetworkManager() {
   this.networkInterfaces = {};
   this.networkInterfaceLinks = {};
-  Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
-  Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
 
   try {
     this._manageOfflineStatus =
       Services.prefs.getBoolPref(PREF_MANAGE_OFFLINE_STATUS);
   } catch(ex) {
     // Ignore.
   }
   Services.prefs.addObserver(PREF_MANAGE_OFFLINE_STATUS, this, false);
-
-  // Possible usb tethering interfaces for different gonk platform.
-  this.possibleInterface = POSSIBLE_USB_INTERFACE_NAME.split(",");
-
-  this._dataDefaultServiceId = 0;
-
-  // Default values for internal and external interfaces.
-  this._tetheringInterface = Object.create(null);
-  this._tetheringInterface[TETHERING_TYPE_USB] = {
-    externalInterface: DEFAULT_3G_INTERFACE_NAME,
-    internalInterface: DEFAULT_USB_INTERFACE_NAME
-  };
-  this._tetheringInterface[TETHERING_TYPE_WIFI] = {
-    externalInterface: DEFAULT_3G_INTERFACE_NAME,
-    internalInterface: DEFAULT_WIFI_INTERFACE_NAME
-  };
-
-  this.initTetheringSettings();
+  Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
 
-  let settingsLock = gSettingsService.createLock();
-  // Read the default service id for data call.
-  settingsLock.get(SETTINGS_DATA_DEFAULT_SERVICE_ID, this);
-  // Read usb tethering data from settings DB.
-  settingsLock.get(SETTINGS_USB_IP, this);
-  settingsLock.get(SETTINGS_USB_PREFIX, this);
-  settingsLock.get(SETTINGS_USB_DHCPSERVER_STARTIP, this);
-  settingsLock.get(SETTINGS_USB_DHCPSERVER_ENDIP, this);
-  settingsLock.get(SETTINGS_USB_DNS1, this);
-  settingsLock.get(SETTINGS_USB_DNS2, this);
-  settingsLock.get(SETTINGS_USB_ENABLED, this);
-
-  // Read wifi tethering data from settings DB.
-  settingsLock.get(SETTINGS_WIFI_DHCPSERVER_STARTIP, this);
-  settingsLock.get(SETTINGS_WIFI_DHCPSERVER_ENDIP, this);
-
-  this._usbTetheringSettingsToRead = [SETTINGS_USB_IP,
-                                      SETTINGS_USB_PREFIX,
-                                      SETTINGS_USB_DHCPSERVER_STARTIP,
-                                      SETTINGS_USB_DHCPSERVER_ENDIP,
-                                      SETTINGS_USB_DNS1,
-                                      SETTINGS_USB_DNS2,
-                                      SETTINGS_USB_ENABLED,
-                                      SETTINGS_WIFI_DHCPSERVER_STARTIP,
-                                      SETTINGS_WIFI_DHCPSERVER_ENDIP];
-
-  this.wantConnectionEvent = null;
   this.setAndConfigureActive();
 
   ppmm.addMessageListener('NetworkInterfaceList:ListInterface', this);
 
   // Used in resolveHostname().
   defineLazyRegExp(this, "REGEXP_IPV4", "^\\d{1,3}(?:\\.\\d{1,3}){3}$");
   defineLazyRegExp(this, "REGEXP_IPV6", "^[\\da-fA-F]{4}(?::[\\da-fA-F]{4}){7}$");
 }
@@ -253,33 +141,24 @@ NetworkManager.prototype = {
                                          Ci.nsISupportsWeakReference,
                                          Ci.nsIObserver,
                                          Ci.nsISettingsServiceCallback]),
 
   // nsIObserver
 
   observe: function(subject, topic, data) {
     switch (topic) {
-      case TOPIC_MOZSETTINGS_CHANGED:
-        if ("wrappedJSObject" in subject) {
-          subject = subject.wrappedJSObject;
-        }
-        this.handle(subject.key, subject.value);
-        break;
       case TOPIC_PREF_CHANGED:
         this._manageOfflineStatus =
           Services.prefs.getBoolPref(PREF_MANAGE_OFFLINE_STATUS);
         debug(PREF_MANAGE_OFFLINE_STATUS + " has changed to " + this._manageOfflineStatus);
         break;
       case TOPIC_XPCOM_SHUTDOWN:
         Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
-        Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
-
-        this.dunConnectTimer.cancel();
-        this.dunRetryTimer.cancel();
+        Services.prefs.removeObserver(PREF_MANAGE_OFFLINE_STATUS, this);
         break;
     }
   },
 
   receiveMessage: function(aMsg) {
     switch (aMsg.name) {
       case "NetworkInterfaceList:ListInterface": {
         let excludeMms = aMsg.json.excludeMms;
@@ -339,21 +218,16 @@ NetworkManager.prototype = {
     let networkId = this.getNetworkId(network);
     if (networkId in this.networkInterfaces) {
       throw Components.Exception("Network with that type already registered!",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     this.networkInterfaces[networkId] = network;
     this.networkInterfaceLinks[networkId] = new NetworkInterfaceLinks();
 
-    if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
-      debug("Force setting " + SETTINGS_DUN_REQUIRED + " to true.");
-      this.tetheringSettings[SETTINGS_DUN_REQUIRED] = true;
-    }
-
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_REGISTERED, null);
     debug("Network '" + networkId + "' registered.");
   },
 
   _addSubnetRoutes: function(network) {
     let ips = {};
     let prefixLengths = {};
     let length = network.getAddresses(ips, prefixLengths);
@@ -416,18 +290,16 @@ NetworkManager.prototype = {
 
           // Update data connection when Wifi connected/disconnected
           if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
             for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
               this.mRil.getRadioInterface(i).updateRILNetworkInterface();
             }
           }
 
-          this.onConnectionChanged(network);
-
           // Probing the public network accessibility after routing table is ready
           CaptivePortalDetectionHelper
             .notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
 
           // Notify outer modules like MmsService to start the transaction after
           // the configuration of the network interface is done.
           Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
                                        this.convertConnectionType(network));
@@ -490,33 +362,26 @@ NetworkManager.prototype = {
     // This is for in case a network gets unregistered without being
     // DISCONNECTED.
     if (this.isNetworkTypeMobile(network.type)) {
       this._cleanupAllHostRoutes(networkId);
     }
 
     delete this.networkInterfaces[networkId];
 
-    if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
-      this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
-        libcutils.property_get("ro.tethering.dun_required") === "1";
-    }
-
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
     debug("Network '" + networkId + "' unregistered.");
   },
 
   _manageOfflineStatus: true,
 
   networkInterfaces: null,
 
   networkInterfaceLinks: null,
 
-  _dataDefaultServiceId: null,
-
   _preferredNetworkType: DEFAULT_PREFERRED_NETWORK_TYPE,
   get preferredNetworkType() {
     return this._preferredNetworkType;
   },
   set preferredNetworkType(val) {
     if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
          Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
       throw "Invalid network type";
@@ -888,579 +753,16 @@ NetworkManager.prototype = {
     switch (network.type) {
       case Ci.nsINetworkInterface.NETWORK_TYPE_WIFI:
         return CONNECTION_TYPE_WIFI;
       case Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE:
         return CONNECTION_TYPE_CELLULAR;
     }
   },
 
-  // nsISettingsServiceCallback
-
-  tetheringSettings: {},
-
-  initTetheringSettings: function() {
-    this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
-    this.tetheringSettings[SETTINGS_USB_IP] = DEFAULT_USB_IP;
-    this.tetheringSettings[SETTINGS_USB_PREFIX] = DEFAULT_USB_PREFIX;
-    this.tetheringSettings[SETTINGS_USB_DHCPSERVER_STARTIP] = DEFAULT_USB_DHCPSERVER_STARTIP;
-    this.tetheringSettings[SETTINGS_USB_DHCPSERVER_ENDIP] = DEFAULT_USB_DHCPSERVER_ENDIP;
-    this.tetheringSettings[SETTINGS_USB_DNS1] = DEFAULT_DNS1;
-    this.tetheringSettings[SETTINGS_USB_DNS2] = DEFAULT_DNS2;
-
-    this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_STARTIP] = DEFAULT_WIFI_DHCPSERVER_STARTIP;
-    this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_ENDIP]   = DEFAULT_WIFI_DHCPSERVER_ENDIP;
-
-    this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
-      libcutils.property_get("ro.tethering.dun_required") === "1";
-  },
-
-  _usbTetheringRequestCount: 0,
-
-  handle: function(aName, aResult) {
-    switch(aName) {
-      case SETTINGS_DATA_DEFAULT_SERVICE_ID:
-        this._dataDefaultServiceId = aResult || 0;
-        debug("'_dataDefaultServiceId' is now " + this._dataDefaultServiceId);
-        break;
-      case SETTINGS_USB_ENABLED:
-        this._oldUsbTetheringEnabledState = this.tetheringSettings[SETTINGS_USB_ENABLED];
-      case SETTINGS_USB_IP:
-      case SETTINGS_USB_PREFIX:
-      case SETTINGS_USB_DHCPSERVER_STARTIP:
-      case SETTINGS_USB_DHCPSERVER_ENDIP:
-      case SETTINGS_USB_DNS1:
-      case SETTINGS_USB_DNS2:
-      case SETTINGS_WIFI_DHCPSERVER_STARTIP:
-      case SETTINGS_WIFI_DHCPSERVER_ENDIP:
-        if (aResult !== null) {
-          this.tetheringSettings[aName] = aResult;
-        }
-        debug("'" + aName + "'" + " is now " + this.tetheringSettings[aName]);
-        let index = this._usbTetheringSettingsToRead.indexOf(aName);
-
-        if (index != -1) {
-          this._usbTetheringSettingsToRead.splice(index, 1);
-        }
-
-        if (this._usbTetheringSettingsToRead.length) {
-          debug("We haven't read completely the usb Tethering data from settings db.");
-          break;
-        }
-
-        if (this._oldUsbTetheringEnabledState === this.tetheringSettings[SETTINGS_USB_ENABLED]) {
-          debug("No changes for SETTINGS_USB_ENABLED flag. Nothing to do.");
-          this.handlePendingWifiTetheringRequest();
-          break;
-        }
-
-        this._usbTetheringRequestCount++;
-        if (this._usbTetheringRequestCount === 1) {
-          if (this._wifiTetheringRequestOngoing) {
-            debug('USB tethering request is blocked by ongoing wifi tethering request.');
-          } else {
-            this.handleLastUsbTetheringRequest();
-          }
-        }
-        break;
-    };
-  },
-
-  handleError: function(aErrorMessage) {
-    debug("There was an error while reading Tethering settings.");
-    this.tetheringSettings = {};
-    this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
-  },
-
-  getNetworkInterface: function(type, serviceId) {
-    for each (let network in this.networkInterfaces) {
-      if (network.type == type) {
-        try {
-          if (network instanceof Ci.nsIRilNetworkInterface) {
-            let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
-            if (rilNetwork.serviceId != serviceId) {
-              continue;
-            }
-          }
-        } catch (e) {}
-        return network;
-      }
-    }
-    return null;
-  },
-
-  _usbTetheringAction: TETHERING_STATE_IDLE,
-
-  _usbTetheringSettingsToRead: [],
-
-  _oldUsbTetheringEnabledState: null,
-
-  // External and internal interface name.
-  _tetheringInterface: null,
-
-  handleLastUsbTetheringRequest: function() {
-    debug('handleLastUsbTetheringRequest... ' + this._usbTetheringRequestCount);
-
-    if (this._usbTetheringRequestCount === 0) {
-      if (this.wantConnectionEvent) {
-        if (this.tetheringSettings[SETTINGS_USB_ENABLED]) {
-          this.wantConnectionEvent.call(this);
-        }
-        this.wantConnectionEvent = null;
-      }
-      this.handlePendingWifiTetheringRequest();
-      return;
-    }
-
-    // Cancel the accumlated count to 1 since we only care about the
-    // last state.
-    this._usbTetheringRequestCount = 1;
-    this.handleUSBTetheringToggle(this.tetheringSettings[SETTINGS_USB_ENABLED]);
-    this.wantConnectionEvent = null;
-  },
-
-  handlePendingWifiTetheringRequest: function() {
-    if (this._pendingWifiTetheringRequestArgs) {
-      this.setWifiTethering.apply(this, this._pendingWifiTetheringRequestArgs);
-      this._pendingWifiTetheringRequestArgs = null;
-    }
-  },
-
-  dunConnectTimer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
-  /**
-   * Callback when dun connection fails to connect within timeout.
-   */
-  onDunConnectTimerTimeout: function() {
-    while (this._pendingTetheringRequests.length > 0) {
-      debug("onDunConnectTimerTimeout: callback without network info.");
-      let callback = this._pendingTetheringRequests.shift();
-      if (typeof callback === 'function') {
-        callback();
-      }
-    }
-  },
-
-  dunRetryTimes: 0,
-  dunRetryTimer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
-  setupDunConnection: function() {
-    this.dunRetryTimer.cancel();
-    let connection =
-      gMobileConnectionService.getItemByServiceId(this._dataDefaultServiceId);
-    let data = connection && connection.data;
-    if (data && data.state === "registered") {
-      let ril = this.mRil.getRadioInterface(this._dataDefaultServiceId);
-
-      this.dunRetryTimes = 0;
-      ril.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
-      this.dunConnectTimer.cancel();
-      this.dunConnectTimer.
-        initWithCallback(this.onDunConnectTimerTimeout.bind(this),
-                         MOBILE_DUN_CONNECT_TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
-      return;
-    }
-
-    if (this.dunRetryTimes++ >= this.MOBILE_DUN_MAX_RETRIES) {
-      debug("setupDunConnection: max retries reached.");
-      this.dunRetryTimes = 0;
-      // same as dun connect timeout.
-      this.onDunConnectTimerTimeout();
-      return;
-    }
-
-    debug("Data not ready, retry dun after " + MOBILE_DUN_RETRY_INTERVAL + " ms.");
-    this.dunRetryTimer.
-      initWithCallback(this.setupDunConnection.bind(this),
-                       MOBILE_DUN_RETRY_INTERVAL, Ci.nsITimer.TYPE_ONE_SHOT);
-  },
-
-  _pendingTetheringRequests: [],
-  _dunActiveUsers: 0,
-  handleDunConnection: function(enable, callback) {
-    debug("handleDunConnection: " + enable);
-    let dun = this.getNetworkInterface(
-      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN, this._dataDefaultServiceId);
-
-    if (!enable) {
-      this._dunActiveUsers--;
-      if (this._dunActiveUsers > 0) {
-        debug("Dun still needed by others, do not disconnect.")
-        return;
-      }
-
-      this.dunRetryTimes = 0;
-      this.dunRetryTimer.cancel();
-      this.dunConnectTimer.cancel();
-      this._pendingTetheringRequests = [];
-
-      if (dun && (dun.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
-        this.mRil.getRadioInterface(this._dataDefaultServiceId)
-          .deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
-      }
-      return;
-    }
-
-    this._dunActiveUsers++;
-    if (!dun || (dun.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
-      debug("DUN data call inactive, setup dun data call!")
-      this._pendingTetheringRequests.push(callback);
-      this.dunRetryTimes = 0;
-      this.setupDunConnection();
-
-      return;
-    }
-    this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = dun.name;
-    callback(dun);
-  },
-
-  handleUSBTetheringToggle: function(enable) {
-    debug("handleUSBTetheringToggle: " + enable);
-    if (enable &&
-        (this._usbTetheringAction === TETHERING_STATE_ONGOING ||
-         this._usbTetheringAction === TETHERING_STATE_ACTIVE)) {
-      debug("Usb tethering already connecting/connected.");
-      this._usbTetheringRequestCount = 0;
-      this.handlePendingWifiTetheringRequest();
-      return;
-    }
-
-    if (!enable &&
-        this._usbTetheringAction === TETHERING_STATE_IDLE) {
-      debug("Usb tethering already disconnected.");
-      this._usbTetheringRequestCount = 0;
-      this.handlePendingWifiTetheringRequest();
-      return;
-    }
-
-    if (!enable) {
-      this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
-      gNetworkService.enableUsbRndis(false, this.enableUsbRndisResult.bind(this));
-      return;
-    }
-
-    this.tetheringSettings[SETTINGS_USB_ENABLED] = true;
-    this._usbTetheringAction = TETHERING_STATE_ONGOING;
-
-    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
-      this.handleDunConnection(true, function(network) {
-        if (!network){
-          this.usbTetheringResultReport("Dun connection failed");
-          return;
-        }
-        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = network.name;
-        gNetworkService.enableUsbRndis(true, this.enableUsbRndisResult.bind(this));
-      }.bind(this));
-      return;
-    }
-
-    if (this.active) {
-      this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = this.active.name;
-    } else {
-      let mobile = this.getNetworkInterface(
-        Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
-      if (mobile && mobile.name) {
-        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = mobile.name;
-      }
-    }
-    gNetworkService.enableUsbRndis(true, this.enableUsbRndisResult.bind(this));
-  },
-
-  getUSBTetheringParameters: function(enable, tetheringinterface) {
-    let interfaceIp;
-    let prefix;
-    let wifiDhcpStartIp;
-    let wifiDhcpEndIp;
-    let usbDhcpStartIp;
-    let usbDhcpEndIp;
-    let dns1;
-    let dns2;
-    let internalInterface = tetheringinterface.internalInterface;
-    let externalInterface = tetheringinterface.externalInterface;
-
-    interfaceIp = this.tetheringSettings[SETTINGS_USB_IP];
-    prefix = this.tetheringSettings[SETTINGS_USB_PREFIX];
-    wifiDhcpStartIp = this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_STARTIP];
-    wifiDhcpEndIp = this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_ENDIP];
-    usbDhcpStartIp = this.tetheringSettings[SETTINGS_USB_DHCPSERVER_STARTIP];
-    usbDhcpEndIp = this.tetheringSettings[SETTINGS_USB_DHCPSERVER_ENDIP];
-    dns1 = this.tetheringSettings[SETTINGS_USB_DNS1];
-    dns2 = this.tetheringSettings[SETTINGS_USB_DNS2];
-
-    // Using the default values here until application support these settings.
-    if (interfaceIp == "" || prefix == "" ||
-        wifiDhcpStartIp == "" || wifiDhcpEndIp == "" ||
-        usbDhcpStartIp == "" || usbDhcpEndIp == "") {
-      debug("Invalid subnet information.");
-      return null;
-    }
-
-    return {
-      ifname: internalInterface,
-      ip: interfaceIp,
-      prefix: prefix,
-      wifiStartIp: wifiDhcpStartIp,
-      wifiEndIp: wifiDhcpEndIp,
-      usbStartIp: usbDhcpStartIp,
-      usbEndIp: usbDhcpEndIp,
-      dns1: dns1,
-      dns2: dns2,
-      internalIfname: internalInterface,
-      externalIfname: externalInterface,
-      enable: enable,
-      link: enable ? NETWORK_INTERFACE_UP : NETWORK_INTERFACE_DOWN
-    };
-  },
-
-  notifyError: function(resetSettings, callback, msg) {
-    if (resetSettings) {
-      let settingsLock = gSettingsService.createLock();
-      // Disable wifi tethering with a useful error message for the user.
-      settingsLock.set("tethering.wifi.enabled", false, null, msg);
-    }
-
-    debug("setWifiTethering: " + (msg ? msg : "success"));
-
-    if (callback) {
-      // Callback asynchronously to avoid netsted toggling.
-      Services.tm.currentThread.dispatch(() => {
-        callback.wifiTetheringEnabledChange(msg);
-      }, Ci.nsIThread.DISPATCH_NORMAL);
-    }
-  },
-
-  _wifiTetheringRequestOngoing: false,
-  enableWifiTethering: function(enable, config, callback) {
-    // Fill in config's required fields.
-    config.ifname         = this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface;
-    config.internalIfname = this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface;
-    config.externalIfname = this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface;
-
-    this._wifiTetheringRequestOngoing = true;
-    gNetworkService.setWifiTethering(enable, config, (function(error) {
-      // Disconnect dun on error or when wifi tethering is disabled.
-      if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
-          (!enable || error)) {
-        this.handleDunConnection(false);
-      }
-
-      let resetSettings = error;
-      debug('gNetworkService.setWifiTethering finished');
-      this.notifyError(resetSettings, callback, error);
-      this._wifiTetheringRequestOngoing = false;
-      if (this._usbTetheringRequestCount > 0) {
-        debug('Perform pending USB tethering requests.');
-        this.handleLastUsbTetheringRequest();
-      }
-    }).bind(this));
-  },
-
-  _pendingWifiTetheringRequestArgs: null,
-  // Enable/disable WiFi tethering by sending commands to netd.
-  setWifiTethering: function(enable, network, config, callback) {
-    debug("setWifiTethering: " + enable);
-    if (!network) {
-      this.notifyError(true, callback, "invalid network information");
-      return;
-    }
-
-    if (!config) {
-      this.notifyError(true, callback, "invalid configuration");
-      return;
-    }
-
-    if (this._usbTetheringRequestCount > 0) {
-      // If there's still pending usb tethering request, save
-      // the request params and redo |setWifiTethering| on
-      // usb tethering task complete.
-      debug('USB tethering request is being processed. Queue this wifi tethering request.');
-      this._pendingWifiTetheringRequestArgs = Array.prototype.slice.call(arguments);
-      debug('Pending args: ' + JSON.stringify(this._pendingWifiTetheringRequestArgs));
-      return;
-    }
-
-    if (!enable) {
-      this.enableWifiTethering(false, config, callback);
-      return;
-    }
-
-    this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface = network.name;
-
-    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
-      this.handleDunConnection(true, function(config, callback, network) {
-        if (!network) {
-          this.notifyError(true, callback, "Dun connection failed");
-          return;
-        }
-        this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = network.name;
-        this.enableWifiTethering(true, config, callback);
-      }.bind(this, config, callback));
-      return;
-    }
-
-    let mobile = this.getNetworkInterface(
-      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
-    // Update the real interface name
-    if (mobile && mobile.name) {
-      this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = mobile.name;
-    }
-
-    this.enableWifiTethering(true, config, callback);
-  },
-
-  // Enable/disable USB tethering by sending commands to netd.
-  setUSBTethering: function(enable, tetheringInterface, callback) {
-    let params = this.getUSBTetheringParameters(enable, tetheringInterface);
-
-    if (params === null) {
-      gNetworkService.enableUsbRndis(false, function() {
-        this.usbTetheringResultReport("Invalid parameters");
-      });
-      return;
-    }
-
-    gNetworkService.setUSBTethering(enable, params, callback);
-  },
-
-  getUsbInterface: function() {
-    // Find the rndis interface.
-    for (let i = 0; i < this.possibleInterface.length; i++) {
-      try {
-        let file = new FileUtils.File(KERNEL_NETWORK_ENTRY + "/" +
-                                      this.possibleInterface[i]);
-        if (file.exists()) {
-          return this.possibleInterface[i];
-        }
-      } catch (e) {
-        debug("Not " + this.possibleInterface[i] + " interface.");
-      }
-    }
-    debug("Can't find rndis interface in possible lists.");
-    return DEFAULT_USB_INTERFACE_NAME;
-  },
-
-  enableUsbRndisResult: function(success, enable) {
-    if (success) {
-      // If enable is false, don't find usb interface cause it is already down,
-      // just use the internal interface in settings.
-      if (enable) {
-        this._tetheringInterface[TETHERING_TYPE_USB].internalInterface = this.getUsbInterface();
-      }
-      this.setUSBTethering(enable,
-                           this._tetheringInterface[TETHERING_TYPE_USB],
-                           this.usbTetheringResultReport.bind(this, enable));
-    } else {
-      this.usbTetheringResultReport(enable, "enableUsbRndisResult failure");
-      throw new Error("failed to set USB Function to adb");
-    }
-  },
-
-  usbTetheringResultReport: function(enable, error) {
-    this._usbTetheringRequestCount--;
-
-    let settingsLock = gSettingsService.createLock();
-
-    debug('usbTetheringResultReport callback. enable: ' + enable + ', error: ' + error);
-
-    // Disable tethering settings when fail to enable it.
-    if (error) {
-      this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
-      settingsLock.set("tethering.usb.enabled", false, null);
-      // Skip others request when we found an error.
-      this._usbTetheringRequestCount = 0;
-      this._usbTetheringAction = TETHERING_STATE_IDLE;
-      if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
-        this.handleDunConnection(false);
-      }
-    } else {
-      if (enable) {
-        this._usbTetheringAction = TETHERING_STATE_ACTIVE;
-      } else {
-        this._usbTetheringAction = TETHERING_STATE_IDLE;
-        if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
-          this.handleDunConnection(false);
-        }
-      }
-
-      this.handleLastUsbTetheringRequest();
-    }
-  },
-
-  onConnectionChangedReport: function(success, externalIfname) {
-    debug("onConnectionChangedReport result: success " + success);
-
-    if (success) {
-      // Update the external interface.
-      this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = externalIfname;
-      debug("Change the interface name to " + externalIfname);
-    }
-  },
-
-  onConnectionChanged: function(network) {
-    if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
-      debug("We are only interested in CONNECTED event");
-      return;
-    }
-
-    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
-        network.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
-      this.dunConnectTimer.cancel();
-      debug("DUN data call connected, process callbacks.");
-      while (this._pendingTetheringRequests.length > 0) {
-        let callback = this._pendingTetheringRequests.shift();
-        if (typeof callback === 'function') {
-          callback(network);
-        }
-      }
-      return;
-    }
-
-    if (!this.tetheringSettings[SETTINGS_USB_ENABLED]) {
-      debug("Usb tethering settings is not enabled");
-      return;
-    }
-
-    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
-        network.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN &&
-        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
-        network.name) {
-      debug("Dun required and dun interface is the same");
-      return;
-    }
-
-    if (this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
-        this.active.name) {
-      debug("The active interface is the same");
-      return;
-    }
-
-    let previous = {
-      internalIfname: this._tetheringInterface[TETHERING_TYPE_USB].internalInterface,
-      externalIfname: this._tetheringInterface[TETHERING_TYPE_USB].externalInterface
-    };
-
-    let current = {
-      internalIfname: this._tetheringInterface[TETHERING_TYPE_USB].internalInterface,
-      externalIfname: network.name
-    };
-
-    let callback = (function() {
-      // Update external network interface.
-      debug("Update upstream interface to " + network.name);
-      gNetworkService.updateUpStream(previous, current, this.onConnectionChangedReport.bind(this));
-    }).bind(this);
-
-    if (this._usbTetheringAction === TETHERING_STATE_ONGOING) {
-      debug("Postpone the event and handle it when state is idle.");
-      this.wantConnectionEvent = callback;
-      return;
-    }
-    this.wantConnectionEvent = null;
-
-    callback.call(this);
-  },
-
   _setDefaultRouteAndDNS: function(network, oldInterface) {
     gNetworkService.setDefaultRoute(network, oldInterface, function(success) {
       if (!success) {
         gNetworkService.destroyNetwork(network, function() {});
         return;
       }
       gNetworkService.setDNS(network, function(result) {
         gNetworkService.setNetworkProxy(network);
new file mode 100644
--- /dev/null
+++ b/dom/system/gonk/TetheringService.js
@@ -0,0 +1,822 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+"use strict";
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/FileUtils.jsm");
+Cu.import("resource://gre/modules/systemlibs.js");
+
+const TETHERINGSERVICE_CONTRACTID = "@mozilla.org/tethering/service;1";
+const TETHERINGSERVICE_CID =
+  Components.ID("{527a4121-ee5a-4651-be9c-f46f59cf7c01}");
+
+XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
+                                   "@mozilla.org/network/manager;1",
+                                   "nsINetworkManager");
+
+XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
+                                   "@mozilla.org/network/service;1",
+                                   "nsINetworkService");
+
+XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
+                                   "@mozilla.org/settingsService;1",
+                                   "nsISettingsService");
+
+XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
+                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
+                                   "nsIMobileConnectionService");
+
+XPCOMUtils.defineLazyGetter(this, "gRil", function() {
+  try {
+    return Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
+  } catch (e) {}
+
+  return null;
+});
+
+const TOPIC_INTERFACE_REGISTERED     = "network-interface-registered";
+const TOPIC_INTERFACE_UNREGISTERED   = "network-interface-unregistered";
+const TOPIC_MOZSETTINGS_CHANGED      = "mozsettings-changed";
+const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
+const TOPIC_XPCOM_SHUTDOWN           = "xpcom-shutdown";
+
+const POSSIBLE_USB_INTERFACE_NAME = "rndis0,usb0";
+const DEFAULT_USB_INTERFACE_NAME  = "rndis0";
+const DEFAULT_3G_INTERFACE_NAME   = "rmnet0";
+const DEFAULT_WIFI_INTERFACE_NAME = "wlan0";
+
+// The kernel's proc entry for network lists.
+const KERNEL_NETWORK_ENTRY = "/sys/class/net";
+
+const TETHERING_TYPE_WIFI = "WiFi";
+const TETHERING_TYPE_USB  = "USB";
+
+const WIFI_FIRMWARE_AP            = "AP";
+const WIFI_FIRMWARE_STATION       = "STA";
+const WIFI_SECURITY_TYPE_NONE     = "open";
+const WIFI_SECURITY_TYPE_WPA_PSK  = "wpa-psk";
+const WIFI_SECURITY_TYPE_WPA2_PSK = "wpa2-psk";
+const WIFI_CTRL_INTERFACE         = "wl0.1";
+
+const NETWORK_INTERFACE_UP   = "up";
+const NETWORK_INTERFACE_DOWN = "down";
+
+const TETHERING_STATE_ONGOING = "ongoing";
+const TETHERING_STATE_IDLE    = "idle";
+const TETHERING_STATE_ACTIVE  = "active";
+
+// Settings DB path for USB tethering.
+const SETTINGS_USB_ENABLED             = "tethering.usb.enabled";
+const SETTINGS_USB_IP                  = "tethering.usb.ip";
+const SETTINGS_USB_PREFIX              = "tethering.usb.prefix";
+const SETTINGS_USB_DHCPSERVER_STARTIP  = "tethering.usb.dhcpserver.startip";
+const SETTINGS_USB_DHCPSERVER_ENDIP    = "tethering.usb.dhcpserver.endip";
+const SETTINGS_USB_DNS1                = "tethering.usb.dns1";
+const SETTINGS_USB_DNS2                = "tethering.usb.dns2";
+
+// Settings DB path for WIFI tethering.
+const SETTINGS_WIFI_DHCPSERVER_STARTIP = "tethering.wifi.dhcpserver.startip";
+const SETTINGS_WIFI_DHCPSERVER_ENDIP   = "tethering.wifi.dhcpserver.endip";
+
+// Settings DB patch for dun required setting.
+const SETTINGS_DUN_REQUIRED = "tethering.dun.required";
+
+// Default value for USB tethering.
+const DEFAULT_USB_IP                   = "192.168.0.1";
+const DEFAULT_USB_PREFIX               = "24";
+const DEFAULT_USB_DHCPSERVER_STARTIP   = "192.168.0.10";
+const DEFAULT_USB_DHCPSERVER_ENDIP     = "192.168.0.30";
+
+const DEFAULT_DNS1                     = "8.8.8.8";
+const DEFAULT_DNS2                     = "8.8.4.4";
+
+const DEFAULT_WIFI_DHCPSERVER_STARTIP  = "192.168.1.10";
+const DEFAULT_WIFI_DHCPSERVER_ENDIP    = "192.168.1.30";
+
+const SETTINGS_DATA_DEFAULT_SERVICE_ID = "ril.data.defaultServiceId";
+const MOBILE_DUN_CONNECT_TIMEOUT       = 30000;
+const MOBILE_DUN_RETRY_INTERVAL        = 5000;
+const MOBILE_DUN_MAX_RETRIES           = 5;
+
+let DEBUG = false;
+// Read debug setting from pref.
+try {
+  let debugPref = Services.prefs.getBoolPref("network.debugging.enabled");
+  DEBUG = DEBUG || debugPref;
+} catch (e) {}
+
+let debug;
+if (DEBUG) {
+  debug = function(s) {
+    dump("-*- TetheringService: " + s + "\n");
+  };
+} else {
+  debug = function(s) {};
+}
+
+function TetheringService() {
+  Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
+  Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
+  Services.obs.addObserver(this, TOPIC_CONNECTION_STATE_CHANGED, false);
+  Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, false);
+  Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, false);
+
+  this._dataDefaultServiceId = 0;
+
+  // Possible usb tethering interfaces for different gonk platform.
+  this.possibleInterface = POSSIBLE_USB_INTERFACE_NAME.split(",");
+
+  // Default values for internal and external interfaces.
+  this._tetheringInterface = {};
+  this._tetheringInterface[TETHERING_TYPE_USB] = {
+    externalInterface: DEFAULT_3G_INTERFACE_NAME,
+    internalInterface: DEFAULT_USB_INTERFACE_NAME
+  };
+  this._tetheringInterface[TETHERING_TYPE_WIFI] = {
+    externalInterface: DEFAULT_3G_INTERFACE_NAME,
+    internalInterface: DEFAULT_WIFI_INTERFACE_NAME
+  };
+
+  this.tetheringSettings = {};
+  this.initTetheringSettings();
+
+  let settingsLock = gSettingsService.createLock();
+  // Read the default service id for data call.
+  settingsLock.get(SETTINGS_DATA_DEFAULT_SERVICE_ID, this);
+
+  // Read usb tethering data from settings DB.
+  settingsLock.get(SETTINGS_USB_IP, this);
+  settingsLock.get(SETTINGS_USB_PREFIX, this);
+  settingsLock.get(SETTINGS_USB_DHCPSERVER_STARTIP, this);
+  settingsLock.get(SETTINGS_USB_DHCPSERVER_ENDIP, this);
+  settingsLock.get(SETTINGS_USB_DNS1, this);
+  settingsLock.get(SETTINGS_USB_DNS2, this);
+  settingsLock.get(SETTINGS_USB_ENABLED, this);
+
+  // Read wifi tethering data from settings DB.
+  settingsLock.get(SETTINGS_WIFI_DHCPSERVER_STARTIP, this);
+  settingsLock.get(SETTINGS_WIFI_DHCPSERVER_ENDIP, this);
+
+  this._usbTetheringSettingsToRead = [SETTINGS_USB_IP,
+                                      SETTINGS_USB_PREFIX,
+                                      SETTINGS_USB_DHCPSERVER_STARTIP,
+                                      SETTINGS_USB_DHCPSERVER_ENDIP,
+                                      SETTINGS_USB_DNS1,
+                                      SETTINGS_USB_DNS2,
+                                      SETTINGS_USB_ENABLED,
+                                      SETTINGS_WIFI_DHCPSERVER_STARTIP,
+                                      SETTINGS_WIFI_DHCPSERVER_ENDIP];
+
+  this.wantConnectionEvent = null;
+
+  this.dunConnectTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+
+  this.dunRetryTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+
+  this._pendingTetheringRequests = [];
+}
+TetheringService.prototype = {
+  classID:   TETHERINGSERVICE_CID,
+  classInfo: XPCOMUtils.generateCI({classID: TETHERINGSERVICE_CID,
+                                    contractID: TETHERINGSERVICE_CONTRACTID,
+                                    classDescription: "Tethering Service",
+                                    interfaces: [Ci.nsITetheringService]}),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsITetheringService,
+                                         Ci.nsISupportsWeakReference,
+                                         Ci.nsIObserver,
+                                         Ci.nsISettingsServiceCallback]),
+
+  // Flag to record the default client id for data call.
+  _dataDefaultServiceId: null,
+
+  // Number of usb tehering requests to be processed.
+  _usbTetheringRequestCount: 0,
+
+  // Usb tethering state.
+  _usbTetheringAction: TETHERING_STATE_IDLE,
+
+  // Tethering settings.
+  tetheringSettings: null,
+
+  // Tethering settings need to be read from settings DB.
+  _usbTetheringSettingsToRead: null,
+
+  // Previous usb tethering enabled state.
+  _oldUsbTetheringEnabledState: null,
+
+  // External and internal interface name.
+  _tetheringInterface: null,
+
+  // Dun connection timer.
+  dunConnectTimer: null,
+
+  // Dun connection retry times.
+  dunRetryTimes: 0,
+
+  // Dun retry timer.
+  dunRetryTimer: null,
+
+  // Pending tethering request to handle after dun is connected.
+  _pendingTetheringRequests: null,
+
+  // Flag to indicate wether wifi tethering is being processed.
+  _wifiTetheringRequestOngoing: false,
+
+  // Arguments for pending wifi tethering request.
+  _pendingWifiTetheringRequestArgs: null,
+
+  // nsIObserver
+
+  observe: function(aSubject, aTopic, aData) {
+    let network;
+
+    switch(aTopic) {
+      case TOPIC_MOZSETTINGS_CHANGED:
+        if ("wrappedJSObject" in aSubject) {
+          aSubject = aSubject.wrappedJSObject;
+        }
+        this.handle(aSubject.key, aSubject.value);
+        break;
+      case TOPIC_CONNECTION_STATE_CHANGED:
+        network = aSubject.QueryInterface(Ci.nsINetworkInterface);
+        debug("Network " + network.type + "/" + network.name +
+              " changed state to " + network.state);
+        this.onConnectionChanged(network);
+        break;
+      case TOPIC_INTERFACE_REGISTERED:
+        network = aSubject.QueryInterface(Ci.nsINetworkInterface);
+        if (network &&
+            network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
+          debug("Force setting " + SETTINGS_DUN_REQUIRED + " to true.");
+          this.tetheringSettings[SETTINGS_DUN_REQUIRED] = true;
+        }
+        break;
+      case TOPIC_INTERFACE_UNREGISTERED:
+        network = aSubject.QueryInterface(Ci.nsINetworkInterface);
+        if (network &&
+            network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
+          this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
+          libcutils.property_get("ro.tethering.dun_required") === "1";
+        }
+        break;
+      case TOPIC_XPCOM_SHUTDOWN:
+        Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
+        Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
+        Services.obs.removeObserver(this, TOPIC_CONNECTION_STATE_CHANGED);
+        Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
+        Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
+
+        this.dunConnectTimer.cancel();
+        this.dunRetryTimer.cancel();
+        break;
+    }
+  },
+
+  // nsISettingsServiceCallback
+
+  handle: function(aName, aResult) {
+    switch(aName) {
+      case SETTINGS_DATA_DEFAULT_SERVICE_ID:
+        this._dataDefaultServiceId = aResult || 0;
+        debug("'_dataDefaultServiceId' is now " + this._dataDefaultServiceId);
+        break;
+      case SETTINGS_USB_ENABLED:
+        this._oldUsbTetheringEnabledState = this.tetheringSettings[SETTINGS_USB_ENABLED];
+      case SETTINGS_USB_IP:
+      case SETTINGS_USB_PREFIX:
+      case SETTINGS_USB_DHCPSERVER_STARTIP:
+      case SETTINGS_USB_DHCPSERVER_ENDIP:
+      case SETTINGS_USB_DNS1:
+      case SETTINGS_USB_DNS2:
+      case SETTINGS_WIFI_DHCPSERVER_STARTIP:
+      case SETTINGS_WIFI_DHCPSERVER_ENDIP:
+        if (aResult !== null) {
+          this.tetheringSettings[aName] = aResult;
+        }
+        debug("'" + aName + "'" + " is now " + this.tetheringSettings[aName]);
+        let index = this._usbTetheringSettingsToRead.indexOf(aName);
+
+        if (index != -1) {
+          this._usbTetheringSettingsToRead.splice(index, 1);
+        }
+
+        if (this._usbTetheringSettingsToRead.length) {
+          debug("We haven't read completely the usb Tethering data from settings db.");
+          break;
+        }
+
+        if (this._oldUsbTetheringEnabledState === this.tetheringSettings[SETTINGS_USB_ENABLED]) {
+          debug("No changes for SETTINGS_USB_ENABLED flag. Nothing to do.");
+          this.handlePendingWifiTetheringRequest();
+          break;
+        }
+
+        this._usbTetheringRequestCount++;
+        if (this._usbTetheringRequestCount === 1) {
+          if (this._wifiTetheringRequestOngoing) {
+            debug('USB tethering request is blocked by ongoing wifi tethering request.');
+          } else {
+            this.handleLastUsbTetheringRequest();
+          }
+        }
+        break;
+    };
+  },
+
+  handleError: function(aErrorMessage) {
+    debug("There was an error while reading Tethering settings.");
+    this.tetheringSettings = {};
+    this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
+  },
+
+  initTetheringSettings: function() {
+    this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
+    this.tetheringSettings[SETTINGS_USB_IP] = DEFAULT_USB_IP;
+    this.tetheringSettings[SETTINGS_USB_PREFIX] = DEFAULT_USB_PREFIX;
+    this.tetheringSettings[SETTINGS_USB_DHCPSERVER_STARTIP] = DEFAULT_USB_DHCPSERVER_STARTIP;
+    this.tetheringSettings[SETTINGS_USB_DHCPSERVER_ENDIP] = DEFAULT_USB_DHCPSERVER_ENDIP;
+    this.tetheringSettings[SETTINGS_USB_DNS1] = DEFAULT_DNS1;
+    this.tetheringSettings[SETTINGS_USB_DNS2] = DEFAULT_DNS2;
+
+    this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_STARTIP] = DEFAULT_WIFI_DHCPSERVER_STARTIP;
+    this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_ENDIP]   = DEFAULT_WIFI_DHCPSERVER_ENDIP;
+
+    this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
+      libcutils.property_get("ro.tethering.dun_required") === "1";
+  },
+
+  getNetworkInterface: function(aType, aServiceId) {
+    for each (let network in gNetworkManager.networkInterfaces) {
+      if (network.type == aType) {
+        try {
+          if (network instanceof Ci.nsIRilNetworkInterface) {
+            let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
+            if (rilNetwork.serviceId != aServiceId) {
+              continue;
+            }
+          }
+        } catch (e) {}
+        return network;
+      }
+    }
+    return null;
+  },
+
+  handleLastUsbTetheringRequest: function() {
+    debug('handleLastUsbTetheringRequest... ' + this._usbTetheringRequestCount);
+
+    if (this._usbTetheringRequestCount === 0) {
+      if (this.wantConnectionEvent) {
+        if (this.tetheringSettings[SETTINGS_USB_ENABLED]) {
+          this.wantConnectionEvent.call(this);
+        }
+        this.wantConnectionEvent = null;
+      }
+      this.handlePendingWifiTetheringRequest();
+      return;
+    }
+
+    // Cancel the accumlated count to 1 since we only care about the
+    // last state.
+    this._usbTetheringRequestCount = 1;
+    this.handleUSBTetheringToggle(this.tetheringSettings[SETTINGS_USB_ENABLED]);
+    this.wantConnectionEvent = null;
+  },
+
+  handlePendingWifiTetheringRequest: function() {
+    if (this._pendingWifiTetheringRequestArgs) {
+      this.setWifiTethering.apply(this, this._pendingWifiTetheringRequestArgs);
+      this._pendingWifiTetheringRequestArgs = null;
+    }
+  },
+
+  /**
+   * Callback when dun connection fails to connect within timeout.
+   */
+  onDunConnectTimerTimeout: function() {
+    while (this._pendingTetheringRequests.length > 0) {
+      debug("onDunConnectTimerTimeout: callback without network info.");
+      let callback = this._pendingTetheringRequests.shift();
+      if (typeof callback === 'function') {
+        callback();
+      }
+    }
+  },
+
+  setupDunConnection: function() {
+    this.dunRetryTimer.cancel();
+    let connection =
+      gMobileConnectionService.getItemByServiceId(this._dataDefaultServiceId);
+    let data = connection && connection.data;
+    if (data && data.state === "registered") {
+      let ril = gRil.getRadioInterface(this._dataDefaultServiceId);
+
+      this.dunRetryTimes = 0;
+      ril.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
+      this.dunConnectTimer.cancel();
+      this.dunConnectTimer.
+        initWithCallback(this.onDunConnectTimerTimeout.bind(this),
+                         MOBILE_DUN_CONNECT_TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
+      return;
+    }
+
+    if (this.dunRetryTimes++ >= this.MOBILE_DUN_MAX_RETRIES) {
+      debug("setupDunConnection: max retries reached.");
+      this.dunRetryTimes = 0;
+      // same as dun connect timeout.
+      this.onDunConnectTimerTimeout();
+      return;
+    }
+
+    debug("Data not ready, retry dun after " + MOBILE_DUN_RETRY_INTERVAL + " ms.");
+    this.dunRetryTimer.
+      initWithCallback(this.setupDunConnection.bind(this),
+                       MOBILE_DUN_RETRY_INTERVAL, Ci.nsITimer.TYPE_ONE_SHOT);
+  },
+
+  _dunActiveUsers: 0,
+  handleDunConnection: function(aEnable, aCallback) {
+    debug("handleDunConnection: " + aEnable);
+    let dun = this.getNetworkInterface(
+      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN, this._dataDefaultServiceId);
+
+    if (!aEnable) {
+      this._dunActiveUsers--;
+      if (this._dunActiveUsers > 0) {
+        debug("Dun still needed by others, do not disconnect.")
+        return;
+      }
+
+      this.dunRetryTimes = 0;
+      this.dunRetryTimer.cancel();
+      this.dunConnectTimer.cancel();
+      this._pendingTetheringRequests = [];
+
+      if (dun && (dun.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
+        gRil.getRadioInterface(this._dataDefaultServiceId)
+          .deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
+      }
+      return;
+    }
+
+    this._dunActiveUsers++;
+    if (!dun || (dun.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
+      debug("DUN data call inactive, setup dun data call!")
+      this._pendingTetheringRequests.push(aCallback);
+      this.dunRetryTimes = 0;
+      this.setupDunConnection();
+
+      return;
+    }
+
+    this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = dun.name;
+    aCallback(dun);
+  },
+
+  handleUSBTetheringToggle: function(aEnable) {
+    debug("handleUSBTetheringToggle: " + aEnable);
+    if (aEnable &&
+        (this._usbTetheringAction === TETHERING_STATE_ONGOING ||
+         this._usbTetheringAction === TETHERING_STATE_ACTIVE)) {
+      debug("Usb tethering already connecting/connected.");
+      this._usbTetheringRequestCount = 0;
+      this.handlePendingWifiTetheringRequest();
+      return;
+    }
+
+    if (!aEnable &&
+        this._usbTetheringAction === TETHERING_STATE_IDLE) {
+      debug("Usb tethering already disconnected.");
+      this._usbTetheringRequestCount = 0;
+      this.handlePendingWifiTetheringRequest();
+      return;
+    }
+
+    if (!aEnable) {
+      this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
+      gNetworkService.enableUsbRndis(false, this.enableUsbRndisResult.bind(this));
+      return;
+    }
+
+    this.tetheringSettings[SETTINGS_USB_ENABLED] = true;
+    this._usbTetheringAction = TETHERING_STATE_ONGOING;
+
+    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
+      this.handleDunConnection(true, (aNetwork) => {
+        if (!aNetwork){
+          this.usbTetheringResultReport(aEnable, "Dun connection failed");
+          return;
+        }
+        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = aNetwork.name;
+        gNetworkService.enableUsbRndis(true, this.enableUsbRndisResult.bind(this));
+      });
+      return;
+    }
+
+    if (gNetworkManager.active) {
+      this._tetheringInterface[TETHERING_TYPE_USB].externalInterface =
+        gNetworkManager.active.name;
+    } else {
+      let mobile = this.getNetworkInterface(
+        Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
+      if (mobile && mobile.name) {
+        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = mobile.name;
+      }
+    }
+    gNetworkService.enableUsbRndis(true, this.enableUsbRndisResult.bind(this));
+  },
+
+  getUSBTetheringParameters: function(aEnable, aTetheringInterface) {
+    let interfaceIp = this.tetheringSettings[SETTINGS_USB_IP];
+    let prefix = this.tetheringSettings[SETTINGS_USB_PREFIX];
+    let wifiDhcpStartIp = this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_STARTIP];
+    let wifiDhcpEndIp = this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_ENDIP];
+    let usbDhcpStartIp = this.tetheringSettings[SETTINGS_USB_DHCPSERVER_STARTIP];
+    let usbDhcpEndIp = this.tetheringSettings[SETTINGS_USB_DHCPSERVER_ENDIP];
+    let dns1 = this.tetheringSettings[SETTINGS_USB_DNS1];
+    let dns2 = this.tetheringSettings[SETTINGS_USB_DNS2];
+    let internalInterface = aTetheringInterface.internalInterface;
+    let externalInterface = aTetheringInterface.externalInterface;
+
+    // Using the default values here until application support these settings.
+    if (interfaceIp == "" || prefix == "" ||
+        wifiDhcpStartIp == "" || wifiDhcpEndIp == "" ||
+        usbDhcpStartIp == "" || usbDhcpEndIp == "") {
+      debug("Invalid subnet information.");
+      return null;
+    }
+
+    return {
+      ifname: internalInterface,
+      ip: interfaceIp,
+      prefix: prefix,
+      wifiStartIp: wifiDhcpStartIp,
+      wifiEndIp: wifiDhcpEndIp,
+      usbStartIp: usbDhcpStartIp,
+      usbEndIp: usbDhcpEndIp,
+      dns1: dns1,
+      dns2: dns2,
+      internalIfname: internalInterface,
+      externalIfname: externalInterface,
+      enable: aEnable,
+      link: aEnable ? NETWORK_INTERFACE_UP : NETWORK_INTERFACE_DOWN
+    };
+  },
+
+  notifyError: function(aResetSettings, aCallback, aMsg) {
+    if (aResetSettings) {
+      let settingsLock = gSettingsService.createLock();
+      // Disable wifi tethering with a useful error message for the user.
+      settingsLock.set("tethering.wifi.enabled", false, null, aMsg);
+    }
+
+    debug("setWifiTethering: " + (aMsg ? aMsg : "success"));
+
+    if (aCallback) {
+      // Callback asynchronously to avoid netsted toggling.
+      Services.tm.currentThread.dispatch(() => {
+        aCallback.wifiTetheringEnabledChange(aMsg);
+      }, Ci.nsIThread.DISPATCH_NORMAL);
+    }
+  },
+
+  enableWifiTethering: function(aEnable, aConfig, aCallback) {
+    // Fill in config's required fields.
+    aConfig.ifname         = this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface;
+    aConfig.internalIfname = this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface;
+    aConfig.externalIfname = this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface;
+
+    this._wifiTetheringRequestOngoing = true;
+    gNetworkService.setWifiTethering(aEnable, aConfig, (aError) => {
+      // Disconnect dun on error or when wifi tethering is disabled.
+      if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
+          (!aEnable || aError)) {
+        this.handleDunConnection(false);
+      }
+
+      let resetSettings = aError;
+      debug('gNetworkService.setWifiTethering finished');
+      this.notifyError(resetSettings, aCallback, aError);
+      this._wifiTetheringRequestOngoing = false;
+      if (this._usbTetheringRequestCount > 0) {
+        debug('Perform pending USB tethering requests.');
+        this.handleLastUsbTetheringRequest();
+      }
+    });
+  },
+
+  // Enable/disable WiFi tethering by sending commands to netd.
+  setWifiTethering: function(aEnable, aNetwork, aConfig, aCallback) {
+    debug("setWifiTethering: " + aEnable);
+    if (!aNetwork) {
+      this.notifyError(true, aCallback, "invalid network information");
+      return;
+    }
+
+    if (!aConfig) {
+      this.notifyError(true, aCallback, "invalid configuration");
+      return;
+    }
+
+    if (this._usbTetheringRequestCount > 0) {
+      // If there's still pending usb tethering request, save
+      // the request params and redo |setWifiTethering| on
+      // usb tethering task complete.
+      debug('USB tethering request is being processed. Queue this wifi tethering request.');
+      this._pendingWifiTetheringRequestArgs = Array.prototype.slice.call(arguments);
+      debug('Pending args: ' + JSON.stringify(this._pendingWifiTetheringRequestArgs));
+      return;
+    }
+
+    if (!aEnable) {
+      this.enableWifiTethering(false, aConfig, aCallback);
+      return;
+    }
+
+    this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface = aNetwork.name;
+
+    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
+      this.handleDunConnection(true, (aNetwork) => {
+        if (!aNetwork) {
+          this.notifyError(true, aCallback, "Dun connection failed");
+          return;
+        }
+        this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = aNetwork.name;
+        this.enableWifiTethering(true, aConfig, aCallback);
+      });
+      return;
+    }
+
+    let mobile = this.getNetworkInterface(
+      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
+    // Update the real interface name
+    if (mobile && mobile.name) {
+      this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = mobile.name;
+    }
+
+    this.enableWifiTethering(true, aConfig, aCallback);
+  },
+
+  // Enable/disable USB tethering by sending commands to netd.
+  setUSBTethering: function(aEnable, aTetheringInterface, aCallback) {
+    let params = this.getUSBTetheringParameters(aEnable, aTetheringInterface);
+
+    if (params === null) {
+      gNetworkService.enableUsbRndis(false, function() {
+        this.usbTetheringResultReport(aEnable, "Invalid parameters");
+      });
+      return;
+    }
+
+    gNetworkService.setUSBTethering(aEnable, params, aCallback);
+  },
+
+  getUsbInterface: function() {
+    // Find the rndis interface.
+    for (let i = 0; i < this.possibleInterface.length; i++) {
+      try {
+        let file = new FileUtils.File(KERNEL_NETWORK_ENTRY + "/" +
+                                      this.possibleInterface[i]);
+        if (file.exists()) {
+          return this.possibleInterface[i];
+        }
+      } catch (e) {
+        debug("Not " + this.possibleInterface[i] + " interface.");
+      }
+    }
+    debug("Can't find rndis interface in possible lists.");
+    return DEFAULT_USB_INTERFACE_NAME;
+  },
+
+  enableUsbRndisResult: function(aSuccess, aEnable) {
+    if (aSuccess) {
+      // If enable is false, don't find usb interface cause it is already down,
+      // just use the internal interface in settings.
+      if (aEnable) {
+        this._tetheringInterface[TETHERING_TYPE_USB].internalInterface =
+          this.getUsbInterface();
+      }
+      this.setUSBTethering(aEnable,
+                           this._tetheringInterface[TETHERING_TYPE_USB],
+                           this.usbTetheringResultReport.bind(this, aEnable));
+    } else {
+      this.usbTetheringResultReport(aEnable, "enableUsbRndisResult failure");
+      throw new Error("failed to set USB Function to adb");
+    }
+  },
+
+  usbTetheringResultReport: function(aEnable, aError) {
+    this._usbTetheringRequestCount--;
+
+    let settingsLock = gSettingsService.createLock();
+
+    debug('usbTetheringResultReport callback. enable: ' + aEnable +
+          ', error: ' + aError);
+
+    // Disable tethering settings when fail to enable it.
+    if (aError) {
+      this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
+      settingsLock.set("tethering.usb.enabled", false, null);
+      // Skip others request when we found an error.
+      this._usbTetheringRequestCount = 0;
+      this._usbTetheringAction = TETHERING_STATE_IDLE;
+      if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
+        this.handleDunConnection(false);
+      }
+    } else {
+      if (aEnable) {
+        this._usbTetheringAction = TETHERING_STATE_ACTIVE;
+      } else {
+        this._usbTetheringAction = TETHERING_STATE_IDLE;
+        if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
+          this.handleDunConnection(false);
+        }
+      }
+
+      this.handleLastUsbTetheringRequest();
+    }
+  },
+
+  onConnectionChangedReport: function(aSuccess, aExternalIfname) {
+    debug("onConnectionChangedReport result: success " + aSuccess);
+
+    if (aSuccess) {
+      // Update the external interface.
+      this._tetheringInterface[TETHERING_TYPE_USB].externalInterface =
+        aExternalIfname;
+      debug("Change the interface name to " + aExternalIfname);
+    }
+  },
+
+  onConnectionChanged: function(aNetwork) {
+    if (aNetwork.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
+      debug("We are only interested in CONNECTED event");
+      return;
+    }
+
+    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
+        aNetwork.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
+      this.dunConnectTimer.cancel();
+      debug("DUN data call connected, process callbacks.");
+      while (this._pendingTetheringRequests.length > 0) {
+        let callback = this._pendingTetheringRequests.shift();
+        if (typeof callback === 'function') {
+          callback(aNetwork);
+        }
+      }
+      return;
+    }
+
+    if (!this.tetheringSettings[SETTINGS_USB_ENABLED]) {
+      debug("Usb tethering settings is not enabled");
+      return;
+    }
+
+    if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
+        aNetwork.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN &&
+        this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
+        aNetwork.name) {
+      debug("Dun required and dun interface is the same");
+      return;
+    }
+
+    if (this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
+        gNetworkManager.active.name) {
+      debug("The active interface is the same");
+      return;
+    }
+
+    let previous = {
+      internalIfname: this._tetheringInterface[TETHERING_TYPE_USB].internalInterface,
+      externalIfname: this._tetheringInterface[TETHERING_TYPE_USB].externalInterface
+    };
+
+    let current = {
+      internalIfname: this._tetheringInterface[TETHERING_TYPE_USB].internalInterface,
+      externalIfname: aNetwork.name
+    };
+
+    let callback = (() => {
+      // Update external network interface.
+      debug("Update upstream interface to " + aNetwork.name);
+      gNetworkService.updateUpStream(previous, current,
+                                     this.onConnectionChangedReport.bind(this));
+    });
+
+    if (this._usbTetheringAction === TETHERING_STATE_ONGOING) {
+      debug("Postpone the event and handle it when state is idle.");
+      this.wantConnectionEvent = callback;
+      return;
+    }
+    this.wantConnectionEvent = null;
+
+    callback.call(this);
+  },
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TetheringService]);
new file mode 100644
--- /dev/null
+++ b/dom/system/gonk/TetheringService.manifest
@@ -0,0 +1,4 @@
+# TetheringService.js
+component {527a4121-ee5a-4651-be9c-f46f59cf7c01} TetheringService.js
+contract @mozilla.org/tethering/service;1 {527a4121-ee5a-4651-be9c-f46f59cf7c01}
+category profile-after-change TetheringService @mozilla.org/tethering/service;1
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -16,16 +16,17 @@
 
 XPIDL_SOURCES += [
     'nsIAudioManager.idl',
     'nsINetworkInterfaceListService.idl',
     'nsINetworkManager.idl',
     'nsINetworkService.idl',
     'nsINetworkWorker.idl',
     'nsISystemWorkerManager.idl',
+    'nsITetheringService.idl',
     'nsIVolume.idl',
     'nsIVolumeMountLock.idl',
     'nsIVolumeService.idl',
     'nsIVolumeStat.idl',
     'nsIWorkerHolder.idl',
 ]
 
 XPIDL_MODULE = 'dom_system_gonk'
@@ -70,16 +71,18 @@ if CONFIG['ENABLE_TESTS']:
     XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
 
 EXTRA_COMPONENTS += [
     'NetworkInterfaceListService.js',
     'NetworkInterfaceListService.manifest',
     'NetworkManager.manifest',
     'NetworkService.js',
     'NetworkService.manifest',
+    'TetheringService.js',
+    'TetheringService.manifest',
 ]
 EXTRA_PP_COMPONENTS += [
     'NetworkManager.js',
 ]
 EXTRA_JS_MODULES += [
     'systemlibs.js',
 ]
 
--- a/dom/system/gonk/nsINetworkManager.idl
+++ b/dom/system/gonk/nsINetworkManager.idl
@@ -1,16 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsISupports.idl"
 
-interface nsIWifiTetheringCallback;
-
 /**
  * Information about networks that is exposed to network manager API consumers.
  */
 [scriptable, uuid(cb62ae03-6bda-43ff-9560-916d60203d33)]
 interface nsINetworkInterface : nsISupports
 {
   const long NETWORK_STATE_UNKNOWN = -1;
   const long NETWORK_STATE_CONNECTING = 0;
@@ -92,17 +90,17 @@ interface nsINetworkInterface : nsISuppo
    */
   void getDnses([optional] out unsigned long count,
                 [array, size_is(count), retval] out wstring dnses);
 };
 
 /**
  * Manage network interfaces.
  */
-[scriptable, uuid(19822018-2454-11e4-baa7-2b5894f0af6f)]
+[scriptable, uuid(b0ab71bf-4b38-4796-8a3c-4141255f4259)]
 interface nsINetworkManager : nsISupports
 {
   /**
    * Register the given network interface with the network manager.
    *
    * Consumers will be notified with the 'network-interface-registered'
    * observer notification.
    *
@@ -176,33 +174,16 @@ interface nsINetworkManager : nsISupport
    *
    * @param network
    *        Network to route all network traffic to. If this is null,
    *        a previous override is canceled.
    */
   long overrideActive(in nsINetworkInterface network);
 
   /**
-   * Enable or disable Wifi Tethering
-   *
-   * @param enabled
-   *        Boolean that indicates whether tethering should be enabled (true) or disabled (false).
-   * @param network
-   *        The Wifi network interface with at least name of network interface.
-   * @param config
-   *        The Wifi Tethering configuration from settings db.
-   * @param callback
-   *        Callback function used to report status to WifiManager.
-   */
-  void setWifiTethering(in boolean enabled,
-                        in nsINetworkInterface networkInterface,
-                        in jsval config,
-                        in nsIWifiTetheringCallback callback);
-
-  /**
    * Add host route to the specified network into routing table.
    *
    * @param network
    *        The network interface where the host to be routed to.
    * @param host
    *        The host to be added.
    *        The host will be resolved in advance if it's not an ip-address.
    *
new file mode 100644
--- /dev/null
+++ b/dom/system/gonk/nsITetheringService.idl
@@ -0,0 +1,30 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 "nsISupports.idl"
+
+interface nsINetworkInterface;
+interface nsIWifiTetheringCallback;
+
+[scriptable, uuid(80d65940-bd99-458f-8529-e438c7348087)]
+interface nsITetheringService : nsISupports
+{
+  /**
+   * Enable or disable Wifi Tethering
+   *
+   * @param enabled
+   *        Boolean that indicates whether tethering should be enabled (true) or
+   *        disabled (false).
+   * @param networkInterface
+   *        The Wifi network interface with at least name of network interface.
+   * @param config
+   *        The Wifi Tethering configuration from settings db.
+   * @param callback
+   *        Callback function used to report status to WifiManager.
+   */
+  void setWifiTethering(in boolean enabled,
+                        in nsINetworkInterface networkInterface,
+                        in jsval config,
+                        in nsIWifiTetheringCallback callback);
+};
\ No newline at end of file
--- a/dom/webidl/NfcOptions.webidl
+++ b/dom/webidl/NfcOptions.webidl
@@ -3,37 +3,72 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 enum RFState {
   "idle",
   "listen",
   "discovery"
 };
 
+/**
+ * Type of the Request used in NfcCommandOptions.
+ */
+enum NfcRequestType {
+  "changeRFState",
+  "readNDEF",
+  "writeNDEF",
+  "makeReadOnly",
+  "format",
+  "transceive"
+};
+
+/**
+ * Type of the Response used in NfcEventOptions.
+ */
+enum NfcResponseType {
+  "changeRFStateRsp",
+  "readNDEFRsp",
+  "writeNDEFRsp",
+  "makeReadOnlyRsp",
+  "formatRsp",
+  "transceiveRsp",
+};
+
+/**
+ * Type of the Notification used in NfcEventOptions.
+ */
+enum NfcNotificationType {
+  "initialized",
+  "techDiscovered",
+  "techLost",
+  "hciEventTransaction"
+};
+
 dictionary NfcCommandOptions
 {
-  DOMString type = "";
+  required NfcRequestType type;
 
   long sessionId;
-  DOMString requestId = "";
+  required DOMString requestId;
 
   RFState rfState;
 
   long techType;
 
   boolean isP2P;
   sequence<MozNDEFRecordOptions> records;
 
   NFCTechType technology;
   Uint8Array command;
 };
 
 dictionary NfcEventOptions
 {
-  DOMString type = "";
+  NfcResponseType rspType;
+  NfcNotificationType ntfType;
 
   long status;
   NfcErrorMessage errorMsg;
   long sessionId;
   DOMString requestId;
 
   long majorVersion;
   long minorVersion;
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -92,16 +92,20 @@ XPCOMUtils.defineLazyServiceGetter(this,
 XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
                                    "@mozilla.org/network/service;1",
                                    "nsINetworkService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
                                    "@mozilla.org/settingsService;1",
                                    "nsISettingsService");
 
+XPCOMUtils.defineLazyServiceGetter(this, "gTetheringService",
+                                   "@mozilla.org/tethering/service;1",
+                                   "nsITetheringService");
+
 // A note about errors and error handling in this file:
 // The libraries that we use in this file are intended for C code. For
 // C code, it is natural to return -1 for errors and 0 for success.
 // Therefore, the code that interacts directly with the worker uses this
 // convention (note: command functions do get boolean results since the
 // command always succeeds and we do a string/boolean check for the
 // expected results).
 var WifiManager = (function() {
@@ -1131,18 +1135,18 @@ var WifiManager = (function() {
           wifiCommand.hostapdGetStations(function(result) {
             notify("stationinfoupdate", {station: result});
           });
         }
 
         function doStartWifiTethering() {
           cancelWaitForDriverReadyTimer();
           WifiNetworkInterface.name = libcutils.property_get("wifi.tethering.interface", manager.ifname);
-          gNetworkManager.setWifiTethering(enabled, WifiNetworkInterface,
-                                           configuration, function(result) {
+          gTetheringService.setWifiTethering(enabled, WifiNetworkInterface,
+                                             configuration, function(result) {
             if (result) {
               manager.tetheringState = "UNINITIALIZED";
             } else {
               manager.tetheringState = "COMPLETED";
               wifiCommand.connectToHostapd(function(result) {
                 if (result) {
                   return;
                 }
@@ -1159,18 +1163,18 @@ var WifiManager = (function() {
 
         // Driver startup on certain platforms takes longer than it takes
         // for us to return from loadDriver, so wait 2 seconds before
         // turning on Wifi tethering.
         createWaitForDriverReadyTimer(doStartWifiTethering);
       });
     } else {
       cancelWifiHotspotStatusTimer();
-      gNetworkManager.setWifiTethering(enabled, WifiNetworkInterface,
-                                       configuration, function(result) {
+      gTetheringService.setWifiTethering(enabled, WifiNetworkInterface,
+                                         configuration, function(result) {
         // Should we fire a dom event if we fail to set wifi tethering  ?
         debug("Disable Wifi tethering result: " + (result ? result : "successfully"));
         // Unload wifi driver even if we fail to control wifi tethering.
         unloadDriver(WIFI_FIRMWARE_AP, function(status) {
           if (status < 0) {
             debug("Fail to unload wifi driver");
           }
           manager.tetheringState = "UNINITIALIZED";
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -399,16 +399,17 @@ class MachCommands(MachCommandBase):
     def __init__(self, context):
         MachCommandBase.__init__(self, context)
 
         for attr in ('b2g_home', 'device_name'):
             setattr(self, attr, getattr(context, attr, None))
 
     @Command('xpcshell-test', category='testing',
         description='Run XPCOM Shell tests (API direct unit testing)',
+        conditions=[lambda *args: True],
         parser=_parser)
     @CommandArgument('test_paths', default='all', nargs='*', metavar='TEST',
         help='Test to run. Can be specified as a single JS file, a directory, '
              'or omitted. If omitted, the entire test suite is executed.')
     @CommandArgument('--verbose', '-v', action='store_true',
         help='Provide full output from each test process.')
     @CommandArgument("--debugger", default=None, metavar='DEBUGGER',
                      help = "Run xpcshell under the given debugger.")