Merge b2ginbound to central, a=merge
authorWes Kocher <wkocher@mozilla.com>
Fri, 17 Jul 2015 18:07:14 -0700
changeset 253539 d317a93e5161438a0e464169bc72311f6d30c1f1
parent 253530 e2f2eb9ecca0a08887bb8d173d2458cdb7653307 (current diff)
parent 253538 385b21e441024468002e4c00805fecf5ac6bff4a (diff)
child 253540 762fa42058cac3c5d8e76dec3949554b1aa72ed6
child 253553 b0f982865190763e139d8716c9cd5610539b850b
child 253578 011665af8da26d44545c1f44a290629d1f1849ae
child 253600 a16bd0e1eb67a52a64214f228cde6d01af7be33c
push id29068
push userkwierso@gmail.com
push dateSat, 18 Jul 2015 01:07:16 +0000
treeherdermozilla-central@d317a93e5161 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone42.0a1
first release with
nightly linux32
d317a93e5161 / 42.0a1 / 20150718030211 / files
nightly linux64
d317a93e5161 / 42.0a1 / 20150718030211 / files
nightly mac
d317a93e5161 / 42.0a1 / 20150718030211 / files
nightly win32
d317a93e5161 / 42.0a1 / 20150718030211 / files
nightly win64
d317a93e5161 / 42.0a1 / 20150718030211 / 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 b2ginbound to central, a=merge
--- a/b2g/config/aries/sources.xml
+++ b/b2g/config/aries/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="e862ab9177af664f00b4522e2350f4cb13866d73">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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"/>
@@ -105,17 +105,17 @@
   <project name="platform/libcore" path="libcore" revision="baf7d8068dd501cfa338d3a8b1b87216d6ce0571"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="50c4430e32849530ced32680fd6ee98963b3f7ac"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="23404f05422c6bf3c39573325a4f4909167671b4"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="6a1bb59af65b6485b1090522f66fac95c3f9e22c"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="69d524e80cdf3981006627c65ac85f3a871238a3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="576f57b6510de59c08568b53c0fb60588be8689e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/netd" path="system/netd" revision="a6531f7befb49b1c81bc0de7e51c5482b308e1c5"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
   <project name="platform/system/vold" path="system/vold" revision="42fa2a0f14f965970a4b629a176bbd2666edf017"/>
   <project name="platform/external/curl" path="external/curl" revision="e68addd988448959ea8157c5de637346b4180c33"/>
   <project name="platform/external/icu4c" path="external/icu4c" revision="d3ec7428eb276db43b7ed0544e09344a6014806c"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="76c4bf4bc430a1b8317f2f21ef735867733e50cc"/>
--- 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="e862ab9177af664f00b4522e2350f4cb13866d73">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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"/>
@@ -110,17 +110,17 @@
   <project name="platform/libcore" path="libcore" revision="e195beab082c09217318fc19250caeaf4c1bd800"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="feeb36c2bd4adfe285f98f5de92e0f3771b2c115"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="23404f05422c6bf3c39573325a4f4909167671b4"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="6a1bb59af65b6485b1090522f66fac95c3f9e22c"/>
   <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="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="10e78a05252b3de785f88c2d0b9ea8a428009c50"/>
   <project name="platform/system/media" path="system/media" revision="188b3e51e0a2ce1e16dc8067edef7be3d2365ad9"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <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="fe12a9e2268da653d1cd4c39ec89a42211d22f25"/>
   <!--original fetch url was http://sprdsource.spreadtrum.com:8085/b2g/android-->
   <remote fetch="https://git.mozilla.org/external/sprd-aosp" name="sprd-aosp"/>
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -14,17 +14,17 @@
   <!--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="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8bc59310552179f9a8bc6cdd0188e2475df52fb7"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9d0e5057ee5404a31ec1bf76131cb11336a7c3b6"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="34ea6163f9f0e0122fb0bb03607eccdca31ced7a"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
--- 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="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <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"/>
@@ -112,17 +112,17 @@
   <project name="platform/libnativehelper" path="libnativehelper" revision="4792069e90385889b0638e97ae62c67cdf274e22"/>
   <project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
   <project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="02c32feb2fe97037be0ac4dace3a6a5025ac895d"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform_system_core" path="system/core" remote="b2g" revision="542d1f59dc331b472307e5bd043101d14d5a3a3e"/>
   <project name="platform/system/extras" path="system/extras" revision="18c1180e848e7ab8691940481f5c1c8d22c37b3e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/media" path="system/media" revision="d90b836f66bf1d9627886c96f3a2d9c3007fbb80"/>
   <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"/>
--- 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="e862ab9177af664f00b4522e2350f4cb13866d73">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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"/>
@@ -110,17 +110,17 @@
   <project name="platform/libcore" path="libcore" revision="9877ade9617bb0db6e59aa2a54719a9bc92600f3"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="46c96ace65eb1ccab05bf15b9bf8e53e443039af"/>
   <project name="platform/ndk" path="ndk" revision="cb5519af32ae7b4a9c334913a612462ecd04c5d0"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="23404f05422c6bf3c39573325a4f4909167671b4"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="6aa61f8557a22039a30b42b7f283996381fd625d"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="6a1bb59af65b6485b1090522f66fac95c3f9e22c"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="b562b01c93de9578d5db537b6a602a38e1aaa0ce"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="387f03e815f57d536dd922706db1622bddba8d81"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="5356165f67f4a81c2ef28671c13697f1657590df"/>
   <project name="platform/system/media" path="system/media" revision="be0e2fe59a8043fa5200f75697df9220a99abe9d"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/netd" path="system/netd" revision="36704b0da24debcab8090156568ac236315036bb"/>
   <project name="platform/system/security" path="system/security" revision="583374f69f531ba68fc3dcbff1f74893d2a96406"/>
   <project name="platform/system/vold" path="system/vold" revision="d4455b8cf361f8353e8aebac15ffd64b4aedd2b9"/>
   <project name="platform/external/icu4c" path="external/icu4c" remote="aosp" revision="b4c6379528887dc25ca9991a535a8d92a61ad6b6"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="f3cedd7fd9b1649aa5107d466be9078bb7602af6"/>
--- 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="61e82f99bb8bc78d52b5717e9a2481ec7267fa33">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
   <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="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
   <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="8af5ff6f5dced9eb5a8127459df6c75d24342204"/>
   <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="30915518fa7ea07166efedc191a4f40aef516fe7"/>
   <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="96eee58e3389fb05a835310d6a06a6ba4486097a"/>
   <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="7c8a46698171aa2e0be09edb43d15a6acf832770"/>
   <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="24b2038be8a636fd4a5d21f0abae1e466b07bcf7"/>
@@ -122,17 +122,17 @@
   <project name="platform/libcore" path="libcore" revision="bdec7d684c083760bef7bc4ba2429cceccaaf7d0"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="27bcc086236cedd31c056303e255c6d0ea3d4a50"/>
   <project name="platform/ndk" path="ndk" revision="42e85f81cc6c74af145056ee80b06e520cccb9a7"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="f105a2d852c988fb1aa16a1e758ca7f93dd54fe9"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="1d080491f26dfdfd76d5bbc3e6b40c660e8565af"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="2c0d193349c55337e37196a7f2d5cef37753ed3e"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="61a10cbd19d6b7fc052a8cb92dfa1b37b93754f3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="9e892a67a01671f312c76b0880dedaa6ba478148"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="47fa016e2248b80aebd5928402c7409f8e0ca64e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/media" path="system/media" revision="70bfebc66d9c6a4c614a8c7efde90e8e7e1d8641"/>
   <project name="platform/system/netd" path="system/netd" revision="d113f0ceefa9ce29eb3c86e2d23c7417a70b4048"/>
   <project name="platform/system/security" path="system/security" revision="94e1617f6f2bc2286d005e79cffa6bf0721b06b3"/>
   <project name="platform/system/vold" path="system/vold" revision="c065e301e38ea0c241164e2a373e1ecefbeaf2ec"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="e372b6a77f71c8f9fbbf6f8adbfa7bf8ef45dc60"/>
   <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="04e26ebdc36ca83f4ee3e9e2082b3fcf04c5b971"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -14,17 +14,17 @@
   <!--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="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8bc59310552179f9a8bc6cdd0188e2475df52fb7"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9d0e5057ee5404a31ec1bf76131cb11336a7c3b6"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="34ea6163f9f0e0122fb0bb03607eccdca31ced7a"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
--- 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="e862ab9177af664f00b4522e2350f4cb13866d73">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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"/>
@@ -104,17 +104,17 @@
   <project name="platform/libcore" path="libcore" revision="baf7d8068dd501cfa338d3a8b1b87216d6ce0571"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="50c4430e32849530ced32680fd6ee98963b3f7ac"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="23404f05422c6bf3c39573325a4f4909167671b4"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="6a1bb59af65b6485b1090522f66fac95c3f9e22c"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="69d524e80cdf3981006627c65ac85f3a871238a3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="576f57b6510de59c08568b53c0fb60588be8689e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/netd" path="system/netd" revision="a6531f7befb49b1c81bc0de7e51c5482b308e1c5"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
   <project name="platform/system/vold" path="system/vold" revision="42fa2a0f14f965970a4b629a176bbd2666edf017"/>
   <project name="platform/external/curl" path="external/curl" revision="e68addd988448959ea8157c5de637346b4180c33"/>
   <project name="platform/external/icu4c" path="external/icu4c" revision="d3ec7428eb276db43b7ed0544e09344a6014806c"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="76c4bf4bc430a1b8317f2f21ef735867733e50cc"/>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
-        "git_revision": "8c009877aff6b8b2f4a60756e2d09c0182393721", 
+        "git_revision": "3fac3ed7b8c887351098ffc677769ddc36abb3d0", 
         "remote": "https://git.mozilla.org/releases/gaia.git", 
         "branch": ""
     }, 
-    "revision": "494ef969c9ddbf15fc8a094c2da7bc46d08b1fc3", 
+    "revision": "1a91ed6e76994d6279bd2cf81ba1416e86aa2014", 
     "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="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <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"/>
@@ -112,17 +112,17 @@
   <project name="platform/libnativehelper" path="libnativehelper" revision="4792069e90385889b0638e97ae62c67cdf274e22"/>
   <project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
   <project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="02c32feb2fe97037be0ac4dace3a6a5025ac895d"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform_system_core" path="system/core" remote="b2g" revision="542d1f59dc331b472307e5bd043101d14d5a3a3e"/>
   <project name="platform/system/extras" path="system/extras" revision="18c1180e848e7ab8691940481f5c1c8d22c37b3e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/media" path="system/media" revision="d90b836f66bf1d9627886c96f3a2d9c3007fbb80"/>
   <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"/>
--- 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="61e82f99bb8bc78d52b5717e9a2481ec7267fa33">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="8c009877aff6b8b2f4a60756e2d09c0182393721"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="3fac3ed7b8c887351098ffc677769ddc36abb3d0"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="c490ae41c67f892232599f4ef049467a922b613e"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
   <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="503fde923fd32bf81b59ca29eee69d67ade37d37"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f48264d4da9680b6e02c9d0459ac273308e21daf"/>
   <!-- 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="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
   <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="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
   <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="8af5ff6f5dced9eb5a8127459df6c75d24342204"/>
   <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="30915518fa7ea07166efedc191a4f40aef516fe7"/>
   <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="96eee58e3389fb05a835310d6a06a6ba4486097a"/>
   <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="7c8a46698171aa2e0be09edb43d15a6acf832770"/>
   <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="24b2038be8a636fd4a5d21f0abae1e466b07bcf7"/>
@@ -122,17 +122,17 @@
   <project name="platform/libcore" path="libcore" revision="bdec7d684c083760bef7bc4ba2429cceccaaf7d0"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="27bcc086236cedd31c056303e255c6d0ea3d4a50"/>
   <project name="platform/ndk" path="ndk" revision="42e85f81cc6c74af145056ee80b06e520cccb9a7"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="f105a2d852c988fb1aa16a1e758ca7f93dd54fe9"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="1d080491f26dfdfd76d5bbc3e6b40c660e8565af"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="2c0d193349c55337e37196a7f2d5cef37753ed3e"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="61a10cbd19d6b7fc052a8cb92dfa1b37b93754f3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="9e892a67a01671f312c76b0880dedaa6ba478148"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="9afc4e0e3e883f3a22a5eb94470d50f4b1cfe5c5"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="3f6ccfc6bc73e28765d70bbe5c277a6276472b08"/>
   <project name="platform/system/extras" path="system/extras" revision="47fa016e2248b80aebd5928402c7409f8e0ca64e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="3c5405863d2002f665ef2b901abb3853c420129b"/>
   <project name="platform/system/media" path="system/media" revision="70bfebc66d9c6a4c614a8c7efde90e8e7e1d8641"/>
   <project name="platform/system/netd" path="system/netd" revision="d113f0ceefa9ce29eb3c86e2d23c7417a70b4048"/>
   <project name="platform/system/security" path="system/security" revision="94e1617f6f2bc2286d005e79cffa6bf0721b06b3"/>
   <project name="platform/system/vold" path="system/vold" revision="c065e301e38ea0c241164e2a373e1ecefbeaf2ec"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="e372b6a77f71c8f9fbbf6f8adbfa7bf8ef45dc60"/>
   <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="04e26ebdc36ca83f4ee3e9e2082b3fcf04c5b971"/>
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -22,19 +22,17 @@
 #include "nsHashPropertyBag.h"
 #include "nsComponentManagerUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/dom/SettingChangeNotificationBinding.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "nsJSUtils.h"
-#include "nsIAudioManager.h"
 #include "SpeakerManagerService.h"
-#define NS_AUDIOMANAGER_CONTRACTID "@mozilla.org/telephony/audiomanager;1"
 #endif
 
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 
@@ -454,57 +452,17 @@ AudioChannelService::AnyAudioChannelIsAc
 
 NS_IMETHODIMP
 AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic,
                              const char16_t* aData)
 {
   if (!strcmp(aTopic, "xpcom-shutdown")) {
     mWindows.Clear();
     Shutdown();
-  }
-
-#ifdef MOZ_WIDGET_GONK
-  // To process the volume control on each audio channel according to
-  // change of settings
-  else if (!strcmp(aTopic, "mozsettings-changed")) {
-    RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
-    if (!WrappedJSToDictionary(aSubject, setting)) {
-      return NS_OK;
-    }
-    if (!StringBeginsWith(setting.mKey, NS_LITERAL_STRING("audio.volume."))) {
-      return NS_OK;
-    }
-    if (!setting.mValue.isNumber()) {
-      return NS_OK;
-    }
-
-    nsCOMPtr<nsIAudioManager> audioManager = do_GetService(NS_AUDIOMANAGER_CONTRACTID);
-    NS_ENSURE_TRUE(audioManager, NS_OK);
-
-    int32_t index = setting.mValue.toNumber();
-    if (setting.mKey.EqualsLiteral("audio.volume.content")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content, index);
-    } else if (setting.mKey.EqualsLiteral("audio.volume.notification")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Notification, index);
-    } else if (setting.mKey.EqualsLiteral("audio.volume.alarm")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Alarm, index);
-    } else if (setting.mKey.EqualsLiteral("audio.volume.telephony")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Telephony, index);
-    } else if (!setting.mKey.EqualsLiteral("audio.volume.bt_sco")) {
-      // bt_sco is not a valid audio channel so we manipulate it in
-      // AudioManager.cpp. And the others should not be used.
-      // We didn't use MOZ_CRASH or MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE here
-      // because any web content who has permission of mozSettings can set any
-      // names then it can be easy to crash the B2G.
-      NS_WARNING("unexpected audio channel for volume control");
-    }
-  }
-#endif
-
-  else if (!strcmp(aTopic, "outer-window-destroyed")) {
+  } else if (!strcmp(aTopic, "outer-window-destroyed")) {
     nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(aSubject);
     NS_ENSURE_TRUE(wrapper, NS_ERROR_FAILURE);
 
     uint64_t outerID;
     nsresult rv = wrapper->GetData(&outerID);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
@@ -533,19 +491,17 @@ AudioChannelService::Observe(nsISupports
     }
 
 #ifdef MOZ_WIDGET_GONK
     bool active = AnyAudioChannelIsActive();
     for (uint32_t i = 0; i < mSpeakerManager.Length(); i++) {
       mSpeakerManager[i]->SetAudioChannelActive(active);
     }
 #endif
-  }
-
-  else if (!strcmp(aTopic, "ipc:content-shutdown")) {
+  } else if (!strcmp(aTopic, "ipc:content-shutdown")) {
     nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
     if (!props) {
       NS_WARNING("ipc:content-shutdown message without property bag as subject");
       return NS_OK;
     }
 
     uint64_t childID = 0;
     nsresult rv = props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"),
--- a/dom/html/nsBrowserElement.cpp
+++ b/dom/html/nsBrowserElement.cpp
@@ -498,18 +498,17 @@ nsBrowserElement::GetAllowedAudioChannel
                  nsTArray<nsRefPtr<BrowserElementAudioChannel>>& aAudioChannels,
                  ErrorResult& aRv)
 {
   aAudioChannels.Clear();
 
   // If empty, it means that this is the first call of this method.
   if (mBrowserElementAudioChannels.IsEmpty()) {
     nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
-    if (!frameLoader) {
-      aRv.Throw(NS_ERROR_FAILURE);
+    if (NS_WARN_IF(!frameLoader)) {
       return;
     }
 
     bool isBrowserOrApp;
     aRv = frameLoader->GetOwnerIsBrowserOrAppFrame(&isBrowserOrApp);
     if (NS_WARN_IF(aRv.Failed())) {
       return;
     }
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -57,21 +57,22 @@ using namespace mozilla::dom::bluetooth;
 #define HEADPHONES_STATUS_HEADSET     MOZ_UTF16("headset")
 #define HEADPHONES_STATUS_HEADPHONE   MOZ_UTF16("headphone")
 #define HEADPHONES_STATUS_OFF         MOZ_UTF16("off")
 #define HEADPHONES_STATUS_UNKNOWN     MOZ_UTF16("unknown")
 #define HEADPHONES_STATUS_CHANGED     "headphones-status-changed"
 #define MOZ_SETTINGS_CHANGE_ID        "mozsettings-changed"
 #define AUDIO_CHANNEL_PROCESS_CHANGED "audio-channel-process-changed"
 #define AUDIO_POLICY_SERVICE_NAME     "media.audio_policy"
+#define SETTINGS_SERVICE              "@mozilla.org/settingsService;1"
 
 static void BinderDeadCallback(status_t aErr);
 static void InternalSetAudioRoutes(SwitchState aState);
 // Refer AudioService.java from Android
-static int sMaxStreamVolumeTbl[AUDIO_STREAM_CNT] = {
+static uint32_t sMaxStreamVolumeTbl[AUDIO_STREAM_CNT] = {
   5,   // voice call
   15,  // system
   15,  // ring
   15,  // music
   15,  // alarm
   15,  // notification
   15,  // BT SCO
   15,  // enforced audible
@@ -88,41 +89,82 @@ static const int kBtSampleRate = 8000;
 static bool sSwitchDone = true;
 #ifdef MOZ_B2G_BT
 static bool sA2dpSwitchDone = true;
 #endif
 
 namespace mozilla {
 namespace dom {
 namespace gonk {
+static VolumeData gVolumeData[VOLUME_TOTAL_NUMBER] = {
+  {"audio.volume.content",      VOLUME_MEDIA},
+  {"audio.volume.notification", VOLUME_NOTIFICATION},
+  {"audio.volume.alarm",        VOLUME_ALARM},
+  {"audio.volume.telephony",    VOLUME_TELEPHONY},
+  {"audio.volume.bt_sco",       VOLUME_BLUETOOTH_SCO}
+};
+
+class AudioProfileData final
+{
+public:
+  explicit AudioProfileData(AudioOutputProfiles aProfile)
+    : mProfile(aProfile)
+    , mActive(false)
+  {
+    for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+      mVolumeTable.AppendElement(0);
+    }
+  };
+
+  AudioOutputProfiles GetProfile() const
+  {
+    return mProfile;
+  }
+
+  void SetActive(bool aActive)
+  {
+    mActive = aActive;
+  }
+
+  bool GetActive() const
+  {
+    return mActive;
+  }
+
+  nsTArray<uint32_t> mVolumeTable;
+private:
+  const AudioOutputProfiles mProfile;
+  bool mActive;
+};
+
 class RecoverTask : public nsRunnable
 {
 public:
   RecoverTask() {}
   NS_IMETHODIMP Run() {
     nsCOMPtr<nsIAudioManager> amService = do_GetService(NS_AUDIOMANAGER_CONTRACTID);
     NS_ENSURE_TRUE(amService, NS_OK);
     AudioManager *am = static_cast<AudioManager *>(amService.get());
 
-    int attempt;
+    uint32_t attempt;
     for (attempt = 0; attempt < 50; attempt++) {
       if (defaultServiceManager()->checkService(String16(AUDIO_POLICY_SERVICE_NAME)) != 0) {
         break;
       }
 
       LOG("AudioPolicyService is dead! attempt=%d", attempt);
       usleep(1000 * 200);
     }
 
     MOZ_RELEASE_ASSERT(attempt < 50);
 
-    for (int loop = 0; loop < AUDIO_STREAM_CNT; loop++) {
+    for (uint32_t loop = 0; loop < AUDIO_STREAM_CNT; ++loop) {
       AudioSystem::initStreamVolume(static_cast<audio_stream_type_t>(loop), 0,
                                    sMaxStreamVolumeTbl[loop]);
-      int32_t index;
+      uint32_t index;
       am->GetStreamVolumeIndex(loop, &index);
       am->SetStreamVolumeIndex(loop, index);
     }
 
     if (sHeadsetState & AUDIO_DEVICE_OUT_WIRED_HEADSET)
       InternalSetAudioRoutes(SWITCH_STATE_HEADSET);
     else if (sHeadsetState & AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
       InternalSetAudioRoutes(SWITCH_STATE_HEADPHONE);
@@ -146,41 +188,32 @@ class AudioChannelVolInitCallback final 
 {
 public:
   NS_DECL_ISUPPORTS
 
   AudioChannelVolInitCallback() {}
 
   NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
   {
-    nsCOMPtr<nsIAudioManager> audioManager =
-      do_GetService(NS_AUDIOMANAGER_CONTRACTID);
     NS_ENSURE_TRUE(aResult.isInt32(), NS_OK);
-
-    int32_t volIndex = aResult.toInt32();
-    if (aName.EqualsLiteral("audio.volume.content")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content,
-                                          volIndex);
-    } else if (aName.EqualsLiteral("audio.volume.notification")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Notification,
-                                          volIndex);
-    } else if (aName.EqualsLiteral("audio.volume.alarm")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Alarm,
-                                          volIndex);
-    } else if (aName.EqualsLiteral("audio.volume.telephony")) {
-      audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Telephony,
-                                          volIndex);
-    } else if (aName.EqualsLiteral("audio.volume.bt_sco")) {
-      static_cast<AudioManager *>(audioManager.get())->SetStreamVolumeIndex(
-        AUDIO_STREAM_BLUETOOTH_SCO, volIndex);
-    } else {
-      MOZ_ASSERT_UNREACHABLE("unexpected audio channel for initializing "
-                             "volume control");
+    nsRefPtr<AudioManager> audioManager = AudioManager::GetInstance();
+    MOZ_ASSERT(audioManager);
+    uint32_t volIndex = aResult.toInt32();
+    for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+      if (aName.EqualsASCII(gVolumeData[idx].mChannelName)) {
+        uint32_t category = gVolumeData[idx].mCategory;
+        nsresult rv = audioManager->ValidateVolumeIndex(category, volIndex);
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
+        audioManager->InitProfilesVolume(gVolumeData[idx].mCategory, volIndex);
+        return NS_OK;
+      }
     }
-
+    NS_WARNING("unexpected event name for initializing volume control");
     return NS_OK;
   }
 
   NS_IMETHOD HandleError(const nsAString& aName)
   {
     LOG("AudioChannelVolInitCallback::HandleError: %s\n",
       NS_ConvertUTF16toUTF8(aName).get());
     return NS_OK;
@@ -298,35 +331,40 @@ AudioManager::HandleBluetoothStatusChang
     AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
 
   if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
     if (audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
       String8 cmd;
       cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
       AudioSystem::setParameters(0, cmd);
       SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_BT_SCO);
+      SwitchProfileData(DEVICE_BLUETOOTH, true);
     } else {
       int32_t force;
       GetForceForUse(nsIAudioManager::USE_COMMUNICATION, &force);
-      if (force == nsIAudioManager::FORCE_BT_SCO)
+      if (force == nsIAudioManager::FORCE_BT_SCO) {
         SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_NONE);
+      }
+      SwitchProfileData(DEVICE_BLUETOOTH, false);
     }
   } else if (!strcmp(aTopic, BLUETOOTH_A2DP_STATUS_CHANGED_ID)) {
     if (audioState == AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE && sA2dpSwitchDone) {
       MessageLoop::current()->PostDelayedTask(
         FROM_HERE, NewRunnableFunction(&ProcessDelayedA2dpRoute, audioState, aAddress), 1000);
       sA2dpSwitchDone = false;
+      SwitchProfileData(DEVICE_BLUETOOTH, false);
     } else {
       AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,
                                             audioState, aAddress.get());
       String8 cmd("bluetooth_enabled=true");
       AudioSystem::setParameters(0, cmd);
       cmd.setTo("A2dpSuspended=false");
       AudioSystem::setParameters(0, cmd);
       sA2dpSwitchDone = true;
+      SwitchProfileData(DEVICE_BLUETOOTH, true);
 #if ANDROID_VERSION >= 17
       if (AudioSystem::getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_NO_BT_A2DP) {
         SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NONE);
       }
 #endif
     }
     sBluetoothA2dpEnabled = audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE;
   } else if (!strcmp(aTopic, BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
@@ -382,34 +420,37 @@ AudioManager::Observe(nsISupports* aSubj
     return NS_OK;
   }
 
   else if (!strcmp(aTopic, AUDIO_CHANNEL_PROCESS_CHANGED)) {
     HandleAudioChannelProcessChanged();
     return NS_OK;
   }
 
-  // To process the volume control on each audio channel according to
+  // To process the volume control on each volume categories according to
   // change of settings
   else if (!strcmp(aTopic, MOZ_SETTINGS_CHANGE_ID)) {
     RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
     if (!WrappedJSToDictionary(aSubject, setting)) {
       return NS_OK;
     }
-    if (!setting.mKey.EqualsASCII("audio.volume.bt_sco")) {
+    if (!StringBeginsWith(setting.mKey, NS_LITERAL_STRING("audio.volume."))) {
       return NS_OK;
     }
     if (!setting.mValue.isNumber()) {
       return NS_OK;
     }
 
-    int32_t index = setting.mValue.toNumber();
-    SetStreamVolumeIndex(AUDIO_STREAM_BLUETOOTH_SCO, index);
-
-    return NS_OK;
+    uint32_t volIndex = setting.mValue.toNumber();
+    for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+      if (setting.mKey.EqualsASCII(gVolumeData[idx].mChannelName)) {
+        SetVolumeByCategory(gVolumeData[idx].mCategory, volIndex);
+        return NS_OK;
+      }
+    }
   }
 
   NS_WARNING("Unexpected topic in AudioManager");
   return NS_ERROR_FAILURE;
 }
 
 static void
 NotifyHeadphonesStatus(SwitchState aState)
@@ -434,19 +475,21 @@ public:
   HeadphoneSwitchObserver(AudioManager* aAudioManager)
   : mAudioManager(aAudioManager) { }
   void Notify(const SwitchEvent& aEvent) {
     NotifyHeadphonesStatus(aEvent.status());
     // When user pulled out the headset, a delay of routing here can avoid the leakage of audio from speaker.
     if (aEvent.status() == SWITCH_STATE_OFF && sSwitchDone) {
       MessageLoop::current()->PostDelayedTask(
         FROM_HERE, NewRunnableFunction(&ProcessDelayedAudioRoute, SWITCH_STATE_OFF), 1000);
+      mAudioManager->SwitchProfileData(DEVICE_HEADSET, false);
       sSwitchDone = false;
     } else if (aEvent.status() != SWITCH_STATE_OFF) {
       InternalSetAudioRoutes(aEvent.status());
+      mAudioManager->SwitchProfileData(DEVICE_HEADSET, true);
       sSwitchDone = true;
     }
     // Handle the coexistence of a2dp / headset device, latest one wins.
 #if ANDROID_VERSION >= 17
     int32_t forceUse = 0;
     mAudioManager->GetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, &forceUse);
     if (aEvent.status() != SWITCH_STATE_OFF && sBluetoothA2dpEnabled) {
       mAudioManager->SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NO_BT_A2DP);
@@ -466,39 +509,38 @@ AudioManager::AudioManager()
   , mMuteCallToRIL(false)
 #endif
 {
   RegisterSwitchObserver(SWITCH_HEADPHONES, mObserver);
 
   InternalSetAudioRoutes(GetCurrentSwitchState(SWITCH_HEADPHONES));
   NotifyHeadphonesStatus(GetCurrentSwitchState(SWITCH_HEADPHONES));
 
-  for (int loop = 0; loop < AUDIO_STREAM_CNT; loop++) {
+  for (uint32_t loop = 0; loop < AUDIO_STREAM_CNT; ++loop) {
     AudioSystem::initStreamVolume(static_cast<audio_stream_type_t>(loop), 0,
                                   sMaxStreamVolumeTbl[loop]);
     mCurrentStreamVolumeTbl[loop] = sMaxStreamVolumeTbl[loop];
   }
   // Force publicnotification to output at maximal volume
   SetStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,
                        sMaxStreamVolumeTbl[AUDIO_STREAM_ENFORCED_AUDIBLE]);
+  CreateAudioProfilesData();
 
   // Get the initial volume index from settings DB during boot up.
   nsCOMPtr<nsISettingsService> settingsService =
     do_GetService("@mozilla.org/settingsService;1");
   NS_ENSURE_TRUE_VOID(settingsService);
   nsCOMPtr<nsISettingsServiceLock> lock;
   nsresult rv = settingsService->CreateLock(nullptr, getter_AddRefs(lock));
   NS_ENSURE_SUCCESS_VOID(rv);
   nsCOMPtr<nsISettingsServiceCallback> callback = new AudioChannelVolInitCallback();
   NS_ENSURE_TRUE_VOID(callback);
-  lock->Get("audio.volume.content", callback);
-  lock->Get("audio.volume.notification", callback);
-  lock->Get("audio.volume.alarm", callback);
-  lock->Get("audio.volume.telephony", callback);
-  lock->Get("audio.volume.bt_sco", callback);
+  for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+    lock->Get(gVolumeData[idx].mChannelName, callback);
+  }
 
   // Gecko only control stream volume not master so set to default value
   // directly.
   AudioSystem::setMasterVolume(1.0);
   AudioSystem::setErrorCallback(BinderDeadCallback);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(obs);
@@ -705,183 +747,405 @@ NS_IMETHODIMP
 AudioManager::SetFmRadioAudioEnabled(bool aFmRadioAudioEnabled)
 {
   AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_FM,
     aFmRadioAudioEnabled ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
     AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
   InternalSetAudioRoutes(GetCurrentSwitchState(SWITCH_HEADPHONES));
   // sync volume with music after powering on fm radio
   if (aFmRadioAudioEnabled) {
-    int32_t volIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
+    uint32_t volIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
     SetStreamVolumeIndex(AUDIO_STREAM_FM, volIndex);
     mCurrentStreamVolumeTbl[AUDIO_STREAM_FM] = volIndex;
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
-AudioManager::SetAudioChannelVolume(int32_t aChannel, int32_t aIndex) {
+nsresult
+AudioManager::ValidateVolumeIndex(uint32_t aCategory, uint32_t aIndex) const
+{
+  uint32_t maxIndex = GetMaxVolumeByCategory(aCategory);
+  if (aIndex < 0 || aIndex > maxIndex) {
+    return NS_ERROR_FAILURE;
+  }
+  return NS_OK;
+}
+
+nsresult
+AudioManager::SetVolumeByCategory(uint32_t aCategory, uint32_t aIndex)
+{
   nsresult status;
-
-  switch (static_cast<AudioChannel>(aChannel)) {
-    case AudioChannel::Content:
+  switch (static_cast<AudioVolumeCategories>(aCategory)) {
+    case VOLUME_MEDIA:
       // sync FMRadio's volume with content channel.
       if (IsDeviceOn(AUDIO_DEVICE_OUT_FM)) {
         status = SetStreamVolumeIndex(AUDIO_STREAM_FM, aIndex);
-        NS_ENSURE_SUCCESS(status, status);
+        if (NS_WARN_IF(NS_FAILED(status))) {
+          return status;
+        }
       }
       status = SetStreamVolumeIndex(AUDIO_STREAM_MUSIC, aIndex);
-      NS_ENSURE_SUCCESS(status, status);
+      if (NS_WARN_IF(NS_FAILED(status))) {
+        return status;
+      }
       status = SetStreamVolumeIndex(AUDIO_STREAM_SYSTEM, aIndex);
       break;
-    case AudioChannel::Notification:
+    case VOLUME_NOTIFICATION:
       status = SetStreamVolumeIndex(AUDIO_STREAM_NOTIFICATION, aIndex);
-      NS_ENSURE_SUCCESS(status, status);
+      if (NS_WARN_IF(NS_FAILED(status))) {
+        return status;
+      }
       status = SetStreamVolumeIndex(AUDIO_STREAM_RING, aIndex);
       break;
-    case AudioChannel::Alarm:
+    case VOLUME_ALARM:
       status = SetStreamVolumeIndex(AUDIO_STREAM_ALARM, aIndex);
       break;
-    case AudioChannel::Telephony:
+    case VOLUME_TELEPHONY:
       status = SetStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, aIndex);
+    case VOLUME_BLUETOOTH_SCO:
+      status = SetStreamVolumeIndex(AUDIO_STREAM_BLUETOOTH_SCO, aIndex);
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
+  return status;
+}
 
+uint32_t
+AudioManager::GetVolumeByCategory(uint32_t aCategory) const
+{
+  switch (static_cast<AudioVolumeCategories>(aCategory)) {
+    case VOLUME_MEDIA:
+      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
+                 mCurrentStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
+      return mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
+    case VOLUME_NOTIFICATION:
+      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
+                 mCurrentStreamVolumeTbl[AUDIO_STREAM_RING]);
+      return mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
+    case VOLUME_ALARM:
+      return mCurrentStreamVolumeTbl[AUDIO_STREAM_ALARM];
+    case VOLUME_TELEPHONY:
+      return mCurrentStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
+    case VOLUME_BLUETOOTH_SCO:
+      return mCurrentStreamVolumeTbl[AUDIO_STREAM_BLUETOOTH_SCO];
+    default:
+      NS_WARNING("Can't get volume from error volume category.");
+      return 0;
+  }
+}
+
+uint32_t
+AudioManager::GetMaxVolumeByCategory(uint32_t aCategory) const
+{
+  switch (static_cast<AudioVolumeCategories>(aCategory)) {
+    case VOLUME_MEDIA:
+      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
+                 sMaxStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
+      return sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC];
+    case VOLUME_NOTIFICATION:
+      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
+                 sMaxStreamVolumeTbl[AUDIO_STREAM_RING]);
+      return sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
+    case VOLUME_ALARM:
+      return sMaxStreamVolumeTbl[AUDIO_STREAM_ALARM];
+    case VOLUME_TELEPHONY:
+      return sMaxStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
+    case VOLUME_BLUETOOTH_SCO:
+      return sMaxStreamVolumeTbl[AUDIO_STREAM_BLUETOOTH_SCO];
+    default:
+      NS_WARNING("Can't get max volume from error volume category.");
+      return 0;
+  }
+}
+
+NS_IMETHODIMP
+AudioManager::SetAudioChannelVolume(uint32_t aChannel, uint32_t aIndex)
+{
+  nsresult status;
+  AudioVolumeCategories category = (mPresentProfile == DEVICE_BLUETOOTH) ?
+                                    VOLUME_BLUETOOTH_SCO : VOLUME_TELEPHONY;
+  switch (static_cast<AudioChannel>(aChannel)) {
+    case AudioChannel::Normal:
+    case AudioChannel::Content:
+      status = SetVolumeByCategory(VOLUME_MEDIA, aIndex);
+      break;
+    case AudioChannel::Notification:
+    case AudioChannel::Ringer:
+    case AudioChannel::Publicnotification:
+      status = SetVolumeByCategory(VOLUME_NOTIFICATION, aIndex);
+      break;
+    case AudioChannel::Alarm:
+      status = SetVolumeByCategory(VOLUME_ALARM, aIndex);
+      break;
+    case AudioChannel::Telephony:
+      status = SetVolumeByCategory(category, aIndex);
+      break;
+    default:
+      return NS_ERROR_INVALID_ARG;
+  }
   return status;
 }
 
 NS_IMETHODIMP
-AudioManager::GetAudioChannelVolume(int32_t aChannel, int32_t* aIndex) {
+AudioManager::GetAudioChannelVolume(uint32_t aChannel, uint32_t* aIndex)
+{
   if (!aIndex) {
     return NS_ERROR_NULL_POINTER;
   }
-
+  AudioVolumeCategories category = (mPresentProfile == DEVICE_BLUETOOTH) ?
+                                    VOLUME_BLUETOOTH_SCO : VOLUME_TELEPHONY;
   switch (static_cast<AudioChannel>(aChannel)) {
+    case AudioChannel::Normal:
     case AudioChannel::Content:
-      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
-                 mCurrentStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
-      *aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
+      *aIndex = GetVolumeByCategory(VOLUME_MEDIA);
       break;
     case AudioChannel::Notification:
-      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
-                 mCurrentStreamVolumeTbl[AUDIO_STREAM_RING]);
-      *aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
+    case AudioChannel::Ringer:
+    case AudioChannel::Publicnotification:
+      *aIndex = GetVolumeByCategory(VOLUME_NOTIFICATION);
       break;
     case AudioChannel::Alarm:
-      *aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_ALARM];
+      *aIndex = GetVolumeByCategory(VOLUME_ALARM);
       break;
     case AudioChannel::Telephony:
-      *aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
+      *aIndex = GetVolumeByCategory(category);
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
-AudioManager::GetMaxAudioChannelVolume(int32_t aChannel, int32_t* aMaxIndex) {
+AudioManager::GetMaxAudioChannelVolume(uint32_t aChannel, uint32_t* aMaxIndex)
+{
   if (!aMaxIndex) {
     return NS_ERROR_NULL_POINTER;
   }
-
-  int32_t stream;
+  AudioVolumeCategories category = (mPresentProfile == DEVICE_BLUETOOTH) ?
+                                    VOLUME_BLUETOOTH_SCO : VOLUME_TELEPHONY;
   switch (static_cast<AudioChannel>(aChannel)) {
+    case AudioChannel::Normal:
     case AudioChannel::Content:
-      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
-                 sMaxStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
-      stream = AUDIO_STREAM_MUSIC;
+      *aMaxIndex = GetMaxVolumeByCategory(VOLUME_MEDIA);
       break;
     case AudioChannel::Notification:
-      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
-                 sMaxStreamVolumeTbl[AUDIO_STREAM_RING]);
-      stream = AUDIO_STREAM_NOTIFICATION;
+    case AudioChannel::Ringer:
+    case AudioChannel::Publicnotification:
+      *aMaxIndex = GetMaxVolumeByCategory(VOLUME_NOTIFICATION);
       break;
     case AudioChannel::Alarm:
-      stream = AUDIO_STREAM_ALARM;
+      *aMaxIndex = GetMaxVolumeByCategory(VOLUME_ALARM);
       break;
     case AudioChannel::Telephony:
-      stream = AUDIO_STREAM_VOICE_CALL;
+      *aMaxIndex = GetMaxVolumeByCategory(category);
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
-
-  *aMaxIndex = sMaxStreamVolumeTbl[stream];
-   return NS_OK;
+  return NS_OK;
 }
 
 nsresult
-AudioManager::SetStreamVolumeIndex(int32_t aStream, int32_t aIndex) {
+AudioManager::SetStreamVolumeIndex(int32_t aStream, uint32_t aIndex) {
   if (aIndex < 0 || aIndex > sMaxStreamVolumeTbl[aStream]) {
     return NS_ERROR_INVALID_ARG;
   }
-
   mCurrentStreamVolumeTbl[aStream] = aIndex;
   status_t status;
 #if ANDROID_VERSION < 17
    status = AudioSystem::setStreamVolumeIndex(
               static_cast<audio_stream_type_t>(aStream),
               aIndex);
    return status ? NS_ERROR_FAILURE : NS_OK;
 #else
-  int device = 0;
-
-  if (aStream == AUDIO_STREAM_BLUETOOTH_SCO) {
-    device = AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
-  } else if (aStream == AUDIO_STREAM_FM) {
-    device = AUDIO_DEVICE_OUT_FM;
-  }
-
-  if (device != 0) {
+  if (aStream == AUDIO_STREAM_FM) {
     status = AudioSystem::setStreamVolumeIndex(
                static_cast<audio_stream_type_t>(aStream),
                aIndex,
-               device);
+               AUDIO_DEVICE_OUT_FM);
     return status ? NS_ERROR_FAILURE : NS_OK;
   }
 
-  status = AudioSystem::setStreamVolumeIndex(
+  if (mPresentProfile == DEVICE_PRIMARY) {
+    status = AudioSystem::setStreamVolumeIndex(
+            static_cast<audio_stream_type_t>(aStream),
+            aIndex,
+            AUDIO_DEVICE_OUT_SPEAKER);
+    status += AudioSystem::setStreamVolumeIndex(
+            static_cast<audio_stream_type_t>(aStream),
+            aIndex,
+            AUDIO_DEVICE_OUT_EARPIECE);
+  } else if (mPresentProfile == DEVICE_HEADSET) {
+    status = AudioSystem::setStreamVolumeIndex(
+              static_cast<audio_stream_type_t>(aStream),
+              aIndex,
+              AUDIO_DEVICE_OUT_WIRED_HEADSET);
+    status += AudioSystem::setStreamVolumeIndex(
+              static_cast<audio_stream_type_t>(aStream),
+              aIndex,
+              AUDIO_DEVICE_OUT_WIRED_HEADPHONE);
+  } else if (mPresentProfile == DEVICE_BLUETOOTH) {
+    status = AudioSystem::setStreamVolumeIndex(
              static_cast<audio_stream_type_t>(aStream),
              aIndex,
              AUDIO_DEVICE_OUT_BLUETOOTH_A2DP);
-  status += AudioSystem::setStreamVolumeIndex(
-              static_cast<audio_stream_type_t>(aStream),
-              aIndex,
-              AUDIO_DEVICE_OUT_SPEAKER);
-  status += AudioSystem::setStreamVolumeIndex(
-              static_cast<audio_stream_type_t>(aStream),
-              aIndex,
-              AUDIO_DEVICE_OUT_WIRED_HEADSET);
-  status += AudioSystem::setStreamVolumeIndex(
-              static_cast<audio_stream_type_t>(aStream),
-              aIndex,
-              AUDIO_DEVICE_OUT_WIRED_HEADPHONE);
-  status += AudioSystem::setStreamVolumeIndex(
-              static_cast<audio_stream_type_t>(aStream),
-              aIndex,
-              AUDIO_DEVICE_OUT_EARPIECE);
-  status += AudioSystem::setStreamVolumeIndex(
+    status += AudioSystem::setStreamVolumeIndex(
               static_cast<audio_stream_type_t>(aStream),
               aIndex,
               AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
-
+  } else {
+    NS_WARNING("Can't set stream volume on error profile!");
+  }
   return status ? NS_ERROR_FAILURE : NS_OK;
 #endif
 }
 
 nsresult
-AudioManager::GetStreamVolumeIndex(int32_t aStream, int32_t *aIndex) {
+AudioManager::GetStreamVolumeIndex(int32_t aStream, uint32_t *aIndex) {
   if (!aIndex) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (aStream <= AUDIO_STREAM_DEFAULT || aStream >= AUDIO_STREAM_MAX) {
     return NS_ERROR_INVALID_ARG;
   }
 
   *aIndex = mCurrentStreamVolumeTbl[aStream];
 
   return NS_OK;
 }
+
+AudioProfileData*
+AudioManager::FindAudioProfileData(AudioOutputProfiles aProfile)
+{
+  uint32_t profilesNum = mAudioProfiles.Length();
+  MOZ_ASSERT(profilesNum == DEVICE_TOTAL_NUMBER, "Error profile numbers!");
+  for (uint32_t idx = 0; idx < profilesNum; ++idx) {
+    if (mAudioProfiles[idx]->GetProfile() == aProfile) {
+      return mAudioProfiles[idx];
+    }
+  }
+  NS_WARNING("Can't find audio profile data");
+  return nullptr;
+}
+
+void
+AudioManager::SendVolumeChangeNotification(AudioProfileData* aProfileData)
+{
+  MOZ_ASSERT(aProfileData);
+  nsresult rv;
+  nsCOMPtr<nsISettingsService> service = do_GetService(SETTINGS_SERVICE, &rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return;
+  }
+
+  nsCOMPtr<nsISettingsServiceLock> lock;
+  rv = service->CreateLock(nullptr, getter_AddRefs(lock));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return;
+  }
+
+  // Send events to update the Gaia volume
+  mozilla::AutoSafeJSContext cx;
+  JS::Rooted<JS::Value> value(cx);
+  for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+    value.setInt32(aProfileData->mVolumeTable[gVolumeData[idx].mCategory]);
+    lock->Set(gVolumeData[idx].mChannelName, value, nullptr, nullptr);
+  }
+}
+
+void
+AudioManager::CreateAudioProfilesData()
+{
+  MOZ_ASSERT(mAudioProfiles.IsEmpty(), "mAudioProfiles should be empty!");
+  for (uint32_t idx = 0; idx < DEVICE_TOTAL_NUMBER; ++idx) {
+    AudioProfileData* profile = new AudioProfileData(static_cast<AudioOutputProfiles>(idx));
+    mAudioProfiles.AppendElement(profile);
+  }
+  UpdateProfileState(DEVICE_PRIMARY, true);
+}
+
+void
+AudioManager::InitProfilesVolume(uint32_t aCategory, uint32_t aIndex)
+{
+  uint32_t profilesNum = mAudioProfiles.Length();
+  MOZ_ASSERT(profilesNum == DEVICE_TOTAL_NUMBER, "Error profile numbers!");
+  for (uint32_t idx = 0; idx < profilesNum; ++idx) {
+    mAudioProfiles[idx]->mVolumeTable[aCategory] = aIndex;
+  }
+  SetVolumeByCategory(aCategory, aIndex);
+}
+
+void
+AudioManager::SwitchProfileData(AudioOutputProfiles aProfile,
+                                bool aActive)
+{
+  MOZ_ASSERT(DEVICE_PRIMARY <= aProfile &&
+             aProfile < DEVICE_TOTAL_NUMBER, "Error profile type!");
+
+  // Save the present profile volume data.
+  AudioOutputProfiles oldProfile = mPresentProfile;
+  AudioProfileData* profileData = FindAudioProfileData(oldProfile);
+  MOZ_ASSERT(profileData);
+  UpdateVolumeToProfile(profileData);
+  UpdateProfileState(aProfile, aActive);
+
+  AudioOutputProfiles newProfile = mPresentProfile;
+  if (oldProfile == newProfile) {
+    return;
+  }
+
+  // Update new profile volume data and send the changing event.
+  profileData = FindAudioProfileData(newProfile);
+  MOZ_ASSERT(profileData);
+  UpdateVolumeFromProfile(profileData);
+  SendVolumeChangeNotification(profileData);
+}
+
+void
+AudioManager::UpdateProfileState(AudioOutputProfiles aProfile, bool aActive)
+{
+  MOZ_ASSERT(DEVICE_PRIMARY <= aProfile && aProfile < DEVICE_TOTAL_NUMBER,
+             "Error profile type!");
+  if (aProfile == DEVICE_PRIMARY && !aActive) {
+    NS_WARNING("Can't turn off the primary profile!");
+    return;
+  }
+
+  mAudioProfiles[aProfile]->SetActive(aActive);
+  if (aActive) {
+    mPresentProfile = aProfile;
+    return;
+  }
+
+  // The primary profile has the lowest priority. We will check whether there
+  // are other profiles. The bluetooth and headset have the same priotity.
+  uint32_t profilesNum = mAudioProfiles.Length();
+  MOZ_ASSERT(profilesNum == DEVICE_TOTAL_NUMBER, "Error profile numbers!");
+  for (uint32_t idx = profilesNum - 1; idx >= 0; --idx) {
+    if (mAudioProfiles[idx]->GetActive()) {
+      mPresentProfile = static_cast<AudioOutputProfiles>(idx);
+      break;
+    }
+  }
+}
+
+void
+AudioManager::UpdateVolumeToProfile(AudioProfileData* aProfileData)
+{
+  MOZ_ASSERT(aProfileData);
+  for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+    uint32_t volume = GetVolumeByCategory(gVolumeData[idx].mCategory);
+    aProfileData->mVolumeTable[gVolumeData[idx].mCategory] = volume;
+  }
+}
+
+void
+AudioManager::UpdateVolumeFromProfile(AudioProfileData* aProfileData)
+{
+  MOZ_ASSERT(aProfileData);
+  for (uint32_t idx = 0; idx < VOLUME_TOTAL_NUMBER; ++idx) {
+    SetVolumeByCategory(gVolumeData[idx].mCategory,
+                        aProfileData->mVolumeTable[gVolumeData[idx].mCategory]);
+  }
+}
\ No newline at end of file
--- a/dom/system/gonk/AudioManager.h
+++ b/dom/system/gonk/AudioManager.h
@@ -31,54 +31,125 @@
 namespace mozilla {
 namespace hal {
 class SwitchEvent;
 typedef Observer<SwitchEvent> SwitchObserver;
 } // namespace hal
 
 namespace dom {
 namespace gonk {
+
+/**
+ * FxOS can remeber the separate volume settings on difference output profiles.
+ * (1) Primary : speaker, receiver
+ * (2) Headset : wired headphone/headset
+ * (3) Bluetooth : BT SCO/A2DP devices
+ **/
+enum AudioOutputProfiles {
+  DEVICE_PRIMARY      = 0,
+  DEVICE_HEADSET      = 1,
+  DEVICE_BLUETOOTH    = 2,
+  DEVICE_TOTAL_NUMBER = 3,
+};
+
+/**
+ * We have five sound volume settings from UX spec,
+ * You can see more informations in Bug1068219.
+ * (1) Media : music, video, FM ...
+ * (2) Notification : ringer, notification ...
+ * (3) Alarm : alarm
+ * (4) Telephony : GSM call, WebRTC call
+ * (5) Bluetooth SCO : SCO call
+ **/
+enum AudioVolumeCategories {
+  VOLUME_MEDIA         = 0,
+  VOLUME_NOTIFICATION  = 1,
+  VOLUME_ALARM         = 2,
+  VOLUME_TELEPHONY     = 3,
+  VOLUME_BLUETOOTH_SCO = 4,
+  VOLUME_TOTAL_NUMBER  = 5,
+};
+
+struct VolumeData {
+  const char* mChannelName;
+  uint32_t mCategory;
+};
+
 class RecoverTask;
 class AudioChannelVolInitCallback;
+class AudioProfileData;
+
 class AudioManager final : public nsIAudioManager
                          , public nsIObserver
 {
 public:
   static already_AddRefed<AudioManager> GetInstance();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIAUDIOMANAGER
   NS_DECL_NSIOBSERVER
 
   // When audio backend is dead, recovery task needs to read all volume
   // settings then set back into audio backend.
   friend class RecoverTask;
   friend class AudioChannelVolInitCallback;
 
+  // Open or close the specific profile
+  void SwitchProfileData(AudioOutputProfiles aProfile, bool aActive);
+
+  // Validate whether the volume index is within the range
+  nsresult ValidateVolumeIndex(uint32_t aCategory, uint32_t aIndex) const;
+
 protected:
   int32_t mPhoneState;
-  int mCurrentStreamVolumeTbl[AUDIO_STREAM_CNT];
+  uint32_t mCurrentStreamVolumeTbl[AUDIO_STREAM_CNT];
 
-  nsresult SetStreamVolumeIndex(int32_t aStream, int32_t aIndex);
-  nsresult GetStreamVolumeIndex(int32_t aStream, int32_t *aIndex);
+  nsresult SetStreamVolumeIndex(int32_t aStream, uint32_t aIndex);
+  nsresult GetStreamVolumeIndex(int32_t aStream, uint32_t *aIndex);
 
 private:
   nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
   nsCOMPtr<nsIAudioChannelAgent>          mPhoneAudioAgent;
 #ifdef MOZ_B2G_RIL
   bool                                    mMuteCallToRIL;
   // mIsMicMuted is only used for toggling mute call to RIL.
   bool                                    mIsMicMuted;
 #endif
+  nsTArray<nsAutoPtr<AudioProfileData>>   mAudioProfiles;
+  AudioOutputProfiles mPresentProfile;
 
   void HandleBluetoothStatusChanged(nsISupports* aSubject,
                                     const char* aTopic,
                                     const nsCString aAddress);
   void HandleAudioChannelProcessChanged();
 
+  void CreateAudioProfilesData();
+
+  // Init the volume setting from the init setting callback
+  void InitProfilesVolume(uint32_t aCatogory, uint32_t aIndex);
+
+  // Update volume data of profiles
+  void UpdateVolumeToProfile(AudioProfileData* aProfileData);
+
+  // Apply the volume data to device
+  void UpdateVolumeFromProfile(AudioProfileData* aProfileData);
+
+  // Send the volume changing event to Gaia
+  void SendVolumeChangeNotification(AudioProfileData* aProfileData);
+
+  // Update the mPresentProfile and profiles active status
+  void UpdateProfileState(AudioOutputProfiles aProfile, bool aActive);
+
+  // Volume control functions
+  nsresult SetVolumeByCategory(uint32_t aCategory, uint32_t aIndex);
+  uint32_t GetVolumeByCategory(uint32_t aCategory) const;
+  uint32_t GetMaxVolumeByCategory(uint32_t aCategory) const;
+
+  AudioProfileData* FindAudioProfileData(AudioOutputProfiles aProfile);
+
   AudioManager();
   ~AudioManager();
 };
 
 } /* namespace gonk */
 } /* namespace dom */
 } /* namespace mozilla */
 
--- a/dom/system/gonk/android_audio/AudioSystem.h
+++ b/dom/system/gonk/android_audio/AudioSystem.h
@@ -234,17 +234,17 @@ typedef enum {
     AUDIO_MODE_CNT,
     AUDIO_MODE_MAX              = AUDIO_MODE_CNT - 1,
 } audio_mode_t;
 #endif
 #endif
 
 #if ANDROID_VERSION < 17
 typedef enum {
-    /* output devices */      
+    /* output devices */
     AUDIO_DEVICE_OUT_EARPIECE                  = 0x1,
     AUDIO_DEVICE_OUT_SPEAKER                   = 0x2,
     AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4,
     AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8,
     AUDIO_DEVICE_OUT_BLUETOOTH_SCO             = 0x10,
     AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET     = 0x20,
     AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT      = 0x40,
     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP            = 0x80,
@@ -294,17 +294,17 @@ typedef enum {
     AUDIO_DEVICE_IN_WIRED_HEADSET         = 0x1000000,
     AUDIO_DEVICE_IN_AUX_DIGITAL           = 0x2000000,
     AUDIO_DEVICE_IN_VOICE_CALL            = 0x4000000,
     AUDIO_DEVICE_IN_BACK_MIC              = 0x8000000,
     AUDIO_DEVICE_IN_ANC_HEADSET           = 0x10000000,
     AUDIO_DEVICE_IN_FM_RX                 = 0x20000000,
     AUDIO_DEVICE_IN_FM_RX_A2DP            = 0x40000000,
     AUDIO_DEVICE_IN_DEFAULT               = 0x80000000,
-    
+
     AUDIO_DEVICE_IN_ALL     = (AUDIO_DEVICE_IN_COMMUNICATION |
                                AUDIO_DEVICE_IN_AMBIENT |
                                AUDIO_DEVICE_IN_BUILTIN_MIC |
                                AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
                                AUDIO_DEVICE_IN_WIRED_HEADSET |
                                AUDIO_DEVICE_IN_AUX_DIGITAL |
                                AUDIO_DEVICE_IN_VOICE_CALL |
                                AUDIO_DEVICE_IN_BACK_MIC |
@@ -545,17 +545,17 @@ enum {
 typedef uint32_t audio_devices_t;
 #endif
 
 /* device connection states used for audio_policy->set_device_connection_state()
  *  */
 typedef enum {
     AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
     AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
-    
+
     AUDIO_POLICY_DEVICE_STATE_CNT,
     AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1,
 } audio_policy_dev_state_t;
 
 namespace android {
 
 typedef void (*audio_error_callback)(status_t err);
 typedef int audio_io_handle_t;
--- a/dom/system/gonk/nsIAudioManager.idl
+++ b/dom/system/gonk/nsIAudioManager.idl
@@ -1,15 +1,15 @@
 /* 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"
 
-[scriptable, builtinclass, uuid(60da41b4-cdc2-11e2-8a91-10bf48d64bd4)]
+[scriptable, builtinclass, uuid(df31c280-1ef1-11e5-867f-0800200c9a66)]
 interface nsIAudioManager : nsISupports
 {
   /**
    * Microphone muted?
    */
   attribute boolean microphoneMuted;
 
   /**
@@ -47,13 +47,17 @@ interface nsIAudioManager : nsISupports
   const long USE_COMMUNICATION     = 0;
   const long USE_MEDIA             = 1;
   const long USE_RECORD            = 2;
   const long USE_DOCK              = 3;
 
   void setForceForUse(in long usage, in long force);
   long getForceForUse(in long usage);
 
-  /* The range of volume index is from 0 to N. Ex: 0 ~ 15 */
-  void setAudioChannelVolume(in long channel, in long index);
-  long getAudioChannelVolume(in long channel);
-  long getMaxAudioChannelVolume(in long channel);
+  /**
+   * These functions would be used when we enable the new volume control API
+   * (mozAudioChannelManager). The range of volume index is from 0 to N.
+   * More details on : https://gist.github.com/evanxd/41d8e2d91c5201a42bfa
+   */
+  void setAudioChannelVolume(in unsigned long channel, in unsigned long index);
+  unsigned long getAudioChannelVolume(in unsigned long channel);
+  unsigned long getMaxAudioChannelVolume(in unsigned long channel);
 };