From 1f535daca81cb1dfe9a9bc8b0c1792308a13d680 Mon Sep 17 00:00:00 2001
From: Carol Yang <cyang@codeaurora.org>
Date: Wed, 30 Mar 2016 14:58:42 -0700
Subject: [PATCH] Patches to compile H5OS with Android M

Change-Id: I24fac944efd4818edca9a330de6f51bd5b7aed2e
---
 .../0001-toybox-Remove-libselinux-usage.patch | 144 ++++++++
 ...IR-when-trying-to-create-a-symbolic-.patch |  27 ++
 .../0002-Ignore-missing-bower-error.patch     |  35 ++
 ...Fix-webrtc-compilation-for-android-m.patch |  51 +++
 ...-Apply-fixes-in-BT-to-compile-with-M.patch | 325 ++++++++++++++++++
 ...Remove-dummy-pthread_fork-definition.patch |  34 ++
 6 files changed, 616 insertions(+)
 create mode 100644 patch/all/external/toybox/0001-toybox-Remove-libselinux-usage.patch
 create mode 100644 patch/all/gaia/0001-Do-not-use-B2G_DIR-when-trying-to-create-a-symbolic-.patch
 create mode 100644 patch/all/gaia/0002-Ignore-missing-bower-error.patch
 create mode 100644 patch/all/gecko/0001-Fix-webrtc-compilation-for-android-m.patch
 create mode 100644 patch/all/gecko/0002-Apply-fixes-in-BT-to-compile-with-M.patch
 create mode 100644 patch/all/gecko/0003-Remove-dummy-pthread_fork-definition.patch

diff --git a/patch/all/external/toybox/0001-toybox-Remove-libselinux-usage.patch b/patch/all/external/toybox/0001-toybox-Remove-libselinux-usage.patch
new file mode 100644
index 0000000..8192926
--- /dev/null
+++ b/patch/all/external/toybox/0001-toybox-Remove-libselinux-usage.patch
@@ -0,0 +1,144 @@
+From a1fb6728a53aada02986bc4aa1c4cd214062ff4b Mon Sep 17 00:00:00 2001
+From: Philippe Gravel <pgravel@codeaurora.org>
+Date: Fri, 25 Mar 2016 14:05:34 -0700
+Subject: [PATCH] Remove libselinux usage
+
+Change-Id: Ic7ec64be3179288d9c6f793dc22f4bbfbe8af807
+---
+ Android.mk          | 12 +-----------
+ generated/config.h  |  2 +-
+ generated/newtoys.h |  5 -----
+ toys/posix/ls.c     |  2 ++
+ 4 files changed, 4 insertions(+), 17 deletions(-)
+
+diff --git a/Android.mk b/Android.mk
+index 645da6d..1867683 100644
+--- a/Android.mk
++++ b/Android.mk
+@@ -60,10 +60,6 @@ LOCAL_SRC_FILES := \
+     main.c \
+     toys/android/getenforce.c \
+     toys/android/getprop.c \
+-    toys/android/load_policy.c \
+-    toys/android/restorecon.c \
+-    toys/android/runcon.c \
+-    toys/android/setenforce.c \
+     toys/android/setprop.c \
+     toys/lsb/dmesg.c \
+     toys/lsb/hostname.c \
+@@ -81,7 +77,6 @@ LOCAL_SRC_FILES := \
+     toys/other/blkid.c \
+     toys/other/blockdev.c \
+     toys/other/bzcat.c \
+-    toys/other/chcon.c \
+     toys/other/chroot.c \
+     toys/other/clear.c \
+     toys/other/dos2unix.c \
+@@ -211,7 +206,7 @@ LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
+ 
+ LOCAL_CLANG := true
+ 
+-LOCAL_SHARED_LIBRARIES := libcutils libselinux
++LOCAL_SHARED_LIBRARIES := libcutils
+ 
+ LOCAL_MODULE := toybox
+ 
+@@ -228,7 +223,6 @@ ALL_TOOLS := \
+     bzcat \
+     cal \
+     cat \
+-    chcon \
+     chgrp \
+     chmod \
+     chown \
+@@ -263,7 +257,6 @@ ALL_TOOLS := \
+     inotifyd \
+     insmod \
+     kill \
+-    load_policy \
+     ln \
+     logname \
+     losetup \
+@@ -294,15 +287,12 @@ ALL_TOOLS := \
+     pwd \
+     readlink \
+     realpath \
+-    restorecon \
+     rm \
+     rmdir \
+     rmmod \
+     route \
+-    runcon \
+     sed \
+     seq \
+-    setenforce \
+     setprop \
+     setsid \
+     sha1sum \
+diff --git a/generated/config.h b/generated/config.h
+index cc1ac50..0e7a893 100644
+--- a/generated/config.h
++++ b/generated/config.h
+@@ -520,7 +520,7 @@
+ #define USE_TOYBOX_SUID(...) __VA_ARGS__
+ #define CFG_TOYBOX_LSM_NONE 0
+ #define USE_TOYBOX_LSM_NONE(...)
+-#define CFG_TOYBOX_SELINUX 1
++#define CFG_TOYBOX_SELINUX 0
+ #define USE_TOYBOX_SELINUX(...) __VA_ARGS__
+ #define CFG_TOYBOX_SMACK 0
+ #define USE_TOYBOX_SMACK(...)
+diff --git a/generated/newtoys.h b/generated/newtoys.h
+index ebc449d..2089025 100644
+--- a/generated/newtoys.h
++++ b/generated/newtoys.h
+@@ -17,7 +17,6 @@ USE_CAT(NEWTOY(cat, "u"USE_CAT_V("vte"), TOYFLAG_BIN))
+ USE_CATV(NEWTOY(catv, USE_CATV("vte"), TOYFLAG_USR|TOYFLAG_BIN))
+ USE_SH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
+ USE_CHATTR(NEWTOY(chattr, NULL, TOYFLAG_BIN))
+-USE_CHCON(NEWTOY(chcon, "<2hvR", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_CHGRP(NEWTOY(chgrp, "<2hPLHRfv[-HLP]", TOYFLAG_BIN))
+ USE_CHMOD(NEWTOY(chmod, "<2?vRf[-vf]", TOYFLAG_BIN))
+ USE_CHOWN(OLDTOY(chown, chgrp, TOYFLAG_BIN))
+@@ -108,7 +107,6 @@ USE_KLOGD(NEWTOY(klogd, "c#<1>8n", TOYFLAG_SBIN))
+ USE_LAST(NEWTOY(last, "f:W", TOYFLAG_BIN))
+ USE_LINK(NEWTOY(link, "<2>2", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_LN(NEWTOY(ln, "<1vnfs", TOYFLAG_BIN))
+-USE_LOAD_POLICY(NEWTOY(load_policy, "<1>1", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_LOGGER(NEWTOY(logger, "st:p:", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_LOGIN(NEWTOY(login, ">1fph:", TOYFLAG_BIN))
+ USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_USR|TOYFLAG_BIN))
+@@ -169,17 +167,14 @@ USE_REALPATH(NEWTOY(realpath, "<1", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_REBOOT(NEWTOY(reboot, "n", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
+ USE_RENICE(NEWTOY(renice, "<1gpun#|", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_RESET(NEWTOY(reset, 0, TOYFLAG_USR|TOYFLAG_BIN))
+-USE_RESTORECON(NEWTOY(restorecon, "<1DFnRrv", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_REV(NEWTOY(rev, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+ USE_RFKILL(NEWTOY(rfkill, "<1>2", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_RM(NEWTOY(rm, "fiRr[-fi]", TOYFLAG_BIN))
+ USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN))
+ USE_RMMOD(NEWTOY(rmmod, "<1wf", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
+ USE_ROUTE(NEWTOY(route, "?neA:", TOYFLAG_BIN))
+-USE_RUNCON(NEWTOY(runcon, "<2", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_SED(NEWTOY(sed, "(version)e*f*inEr[+Er]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE))
+ USE_SEQ(NEWTOY(seq, "<1>3?f:s:", TOYFLAG_USR|TOYFLAG_BIN))
+-USE_SETENFORCE(NEWTOY(setenforce, "<1>1", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_SETPROP(NEWTOY(setprop, "<2>2", TOYFLAG_USR|TOYFLAG_SBIN))
+ USE_SETSID(NEWTOY(setsid, "^<1t", TOYFLAG_USR|TOYFLAG_BIN))
+ USE_SH(NEWTOY(sh, "c:i", TOYFLAG_BIN))
+diff --git a/toys/posix/ls.c b/toys/posix/ls.c
+index 35d1034..1722fc9 100644
+--- a/toys/posix/ls.c
++++ b/toys/posix/ls.c
+@@ -164,6 +164,8 @@ static unsigned seclabel(struct dirtree *dt, int pad)
+     if (pad) printf(" %*s "+(pad>0), pad, buf);
+ 
+     return len;
++  } else {
++    return 0;
+   }
+ }
+ 
+-- 
+1.8.2.1
+
diff --git a/patch/all/gaia/0001-Do-not-use-B2G_DIR-when-trying-to-create-a-symbolic-.patch b/patch/all/gaia/0001-Do-not-use-B2G_DIR-when-trying-to-create-a-symbolic-.patch
new file mode 100644
index 0000000..9d0909a
--- /dev/null
+++ b/patch/all/gaia/0001-Do-not-use-B2G_DIR-when-trying-to-create-a-symbolic-.patch
@@ -0,0 +1,27 @@
+From 70ff0243a8612ced57f44f2333cfb55b3a444e43 Mon Sep 17 00:00:00 2001
+From: Philippe Gravel <pgravel@codeaurora.org>
+Date: Wed, 24 Feb 2016 16:03:09 -0800
+Subject: [PATCH 1/2] Do not use B2G_DIR when trying to create a symbolic link
+ to apps
+
+Change-Id: I7e2f766207a81960a66e43bbc88e049ca4f4998d
+---
+ Android.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Android.mk b/Android.mk
+index 9afe675..7aabae0 100644
+--- a/Android.mk
++++ b/Android.mk
+@@ -80,7 +80,7 @@ gaia-tests-zip:
+ 
+ .PHONY: gaia-prefs
+ gaia-prefs:
+-	ln -sf $(B2G_DIR)/apps $(GAIA_PATH)/apps
++	ln -sf $(GAIA_PATH)/../apps $(GAIA_PATH)/apps
+ 	$(MAKE) -C $(GAIA_PATH) $(GAIA_MAKE_FLAGS) preferences settings
+ 
+ .PHONY: $(LOCAL_PATH)/profile.tar.gz
+-- 
+1.8.2.1
+
diff --git a/patch/all/gaia/0002-Ignore-missing-bower-error.patch b/patch/all/gaia/0002-Ignore-missing-bower-error.patch
new file mode 100644
index 0000000..4c8aca5
--- /dev/null
+++ b/patch/all/gaia/0002-Ignore-missing-bower-error.patch
@@ -0,0 +1,35 @@
+From 8a56a535d691447bf242efd92b604aaad1a67266 Mon Sep 17 00:00:00 2001
+From: Carol Yang <cyang@codeaurora.org>
+Date: Wed, 30 Mar 2016 13:40:09 -0700
+Subject: [PATCH 2/2] Ignore missing bower error
+
+Change-Id: Ie13c93aff33eafc8be1236372a0d357b349fe087
+---
+ Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 8318db5..307b1be 100644
+--- a/Makefile
++++ b/Makefile
+@@ -115,7 +115,7 @@ NOFTU?=0
+ # Disable first time ping
+ NOFTUPING?=0
+ # Disable repo sync and bower install
+-NO_NETWORK?=0
++NO_NETWORK?=1
+ # Disable fake keypad
+ FAKE_KEYPAD?=0
+ # Automatically enable remote debugger
+@@ -898,7 +898,7 @@ common-install:
+ 
+ .PHONY: pre-install
+ pre-install: babel-install
+-	@test -x "$(BOWER)" || (echo "Please install Bower (web package manager) -- http://bower.io/" && exit 1 )
++	@test -x "$(BOWER)" || (echo "Please install Bower (web package manager) -- http://bower.io/" )
+ 
+ .PHONY: babel-install
+ babel-install:
+-- 
+1.8.2.1
+
diff --git a/patch/all/gecko/0001-Fix-webrtc-compilation-for-android-m.patch b/patch/all/gecko/0001-Fix-webrtc-compilation-for-android-m.patch
new file mode 100644
index 0000000..721b23f
--- /dev/null
+++ b/patch/all/gecko/0001-Fix-webrtc-compilation-for-android-m.patch
@@ -0,0 +1,51 @@
+From 8d66e560c6a220040d7f106e67b8125452fa49bf Mon Sep 17 00:00:00 2001
+From: Indrajeet Kumar <ikumar@codeaurora.org>
+Date: Tue, 29 Mar 2016 14:12:29 -0700
+Subject: [PATCH 1/3] Fix webrtc compilation for android m
+
+Change-Id: I177b3186aecc4749ddaa0f5a8e95d751e67d7b8b
+---
+ .../trunk/webrtc/modules/audio_device/android/opensles_input.cc     | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc b/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
+index f876efc..9c31401 100644
+--- a/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
++++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
+@@ -13,6 +13,7 @@
+ #include <assert.h>
+ #include <dlfcn.h>
+ 
++#include <utils/String16.h>
+ #include "OpenSLESProvider.h"
+ #include "webrtc/modules/audio_device/android/audio_common.h"
+ #include "webrtc/modules/audio_device/android/opensles_common.h"
+@@ -443,6 +444,7 @@ void OpenSlesInput::SetupVoiceMode() {
+ 
+ void OpenSlesInput::SetupAECAndNS() {
+   bool hasAec = CheckPlatformAEC();
++  static const android::String16 webRTCPackage("WebRTC");
+   WEBRTC_TRACE(kTraceError, kTraceAudioDevice, id_, "Platform has AEC: %d", hasAec);
+   // This code should not have been enabled if this fails, because it means the
+   // software AEC has will have been disabled as well. If you hit this, you need
+@@ -465,7 +467,7 @@ void OpenSlesInput::SetupAECAndNS() {
+     if (res == SL_RESULT_SUCCESS && idSize == sizeof(sessionId)) {
+       WEBRTC_TRACE(kTraceError, kTraceAudioDevice, id_, "OpenSL sessionId: %d", sessionId);
+ 
+-      aec_ = new android::AudioEffect(FX_IID_AEC, NULL, 0, 0, 0, sessionId, 0);
++      aec_ = new android::AudioEffect(FX_IID_AEC, webRTCPackage, NULL, 0, 0, 0, sessionId, 0);
+       WEBRTC_TRACE(kTraceError, kTraceAudioDevice, id_, "OpenSL aec: %p", aec_);
+ 
+       if (aec_) {
+@@ -480,7 +482,7 @@ void OpenSlesInput::SetupAECAndNS() {
+         }
+       }
+ 
+-      ns_ = new android::AudioEffect(FX_IID_NS, NULL, 0, 0, 0, sessionId, 0);
++      ns_ = new android::AudioEffect(FX_IID_NS, webRTCPackage, NULL, 0, 0, 0, sessionId, 0);
+       WEBRTC_TRACE(kTraceError, kTraceAudioDevice, id_, "OpenSL ns: %p", ns_);
+ 
+       if (ns_) {
+-- 
+1.8.2.1
+
diff --git a/patch/all/gecko/0002-Apply-fixes-in-BT-to-compile-with-M.patch b/patch/all/gecko/0002-Apply-fixes-in-BT-to-compile-with-M.patch
new file mode 100644
index 0000000..64bd7e7
--- /dev/null
+++ b/patch/all/gecko/0002-Apply-fixes-in-BT-to-compile-with-M.patch
@@ -0,0 +1,325 @@
+From b2b14c2651bbb2e063d8caa056482a6b48180e8b Mon Sep 17 00:00:00 2001
+From: Indrajeet Kumar <ikumar@codeaurora.org>
+Date: Tue, 29 Mar 2016 14:32:17 -0700
+Subject: [PATCH 2/3] Apply fixes in BT to compile with M
+
+Change-Id: I8379715fb1abe8bfcf2ff933e919c659becec45e
+---
+ .../bluedroid/BluetoothA2dpHALInterface.cpp        |  5 ++
+ .../bluedroid/BluetoothAvrcpHALInterface.cpp       | 89 ++++++++++++++++++++++
+ .../mozapps/update/updater/automounter_gonk.cpp    |  1 +
+ widget/gonk/GonkPermission.cpp                     |  2 +-
+ 4 files changed, 96 insertions(+), 1 deletion(-)
+
+diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpHALInterface.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpHALInterface.cpp
+index 513ee14..f054d4c 100644
+--- a/dom/bluetooth/bluedroid/BluetoothA2dpHALInterface.cpp
++++ b/dom/bluetooth/bluedroid/BluetoothA2dpHALInterface.cpp
+@@ -139,7 +139,12 @@ BluetoothA2dpHALInterface::Init(
+ 
+   sA2dpNotificationHandler = aNotificationHandler;
+ 
++#if ANDROID_VERSION >= 23
++  //maxConnections = 1, multiCastState = 0
++  bt_status_t status = mInterface->init(&sCallbacks, 1, 0);
++#else
+   bt_status_t status = mInterface->init(&sCallbacks);
++#endif
+ 
+   if (aRes) {
+     DispatchBluetoothA2dpHALResult(aRes,
+diff --git a/dom/bluetooth/bluedroid/BluetoothAvrcpHALInterface.cpp b/dom/bluetooth/bluedroid/BluetoothAvrcpHALInterface.cpp
+index 4e7c606..f73e909 100644
+--- a/dom/bluetooth/bluedroid/BluetoothAvrcpHALInterface.cpp
++++ b/dom/bluetooth/bluedroid/BluetoothAvrcpHALInterface.cpp
+@@ -129,21 +129,33 @@ struct BluetoothAvrcpCallback
+ 
+ #if ANDROID_VERSION >= 18
+   static void
++#if ANDROID_VERSION >= 23
++  GetPlayStatus(bt_bdaddr_t *bd_addr)
++#else
+   GetPlayStatus()
++#endif
+   {
+     GetPlayStatusNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::GetPlayStatusNotification);
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  ListPlayerAppAttr(bt_bdaddr_t *bd_addr)
++#else
+   ListPlayerAppAttr()
++#endif
+   {
+     ListPlayerAppAttrNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::ListPlayerAppAttrNotification);
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  ListPlayerAppValues(btrc_player_attr_t aAttrId, bt_bdaddr_t *bd_addr)
++#else
+   ListPlayerAppValues(btrc_player_attr_t aAttrId)
++#endif
+   {
+     ListPlayerAppValuesNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::ListPlayerAppValuesNotification,
+@@ -151,7 +163,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  GetPlayerAppValue(uint8_t aNumAttrs, btrc_player_attr_t* aAttrs, bt_bdaddr_t *bd_addr)
++#else
+   GetPlayerAppValue(uint8_t aNumAttrs, btrc_player_attr_t* aAttrs)
++#endif
+   {
+     GetPlayerAppValueNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::GetPlayerAppValueNotification,
+@@ -159,7 +175,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  GetPlayerAppAttrsText(uint8_t aNumAttrs, btrc_player_attr_t* aAttrs, bt_bdaddr_t *bd_addr)
++#else
+   GetPlayerAppAttrsText(uint8_t aNumAttrs, btrc_player_attr_t* aAttrs)
++#endif
+   {
+     GetPlayerAppAttrsTextNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::GetPlayerAppAttrsTextNotification,
+@@ -167,7 +187,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  GetPlayerAppValuesText(uint8_t aAttrId, uint8_t aNumVals, uint8_t* aVals, bt_bdaddr_t *bd_addr)
++#else
+   GetPlayerAppValuesText(uint8_t aAttrId, uint8_t aNumVals, uint8_t* aVals)
++#endif
+   {
+     GetPlayerAppValuesTextNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::GetPlayerAppValuesTextNotification,
+@@ -175,7 +199,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  SetPlayerAppValue(btrc_player_settings_t* aVals, bt_bdaddr_t *bd_addr)
++#else
+   SetPlayerAppValue(btrc_player_settings_t* aVals)
++#endif
+   {
+     SetPlayerAppValueNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::SetPlayerAppValueNotification,
+@@ -183,7 +211,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  GetElementAttr(uint8_t aNumAttrs, btrc_media_attr_t* aAttrs, bt_bdaddr_t *bd_addr)
++#else
+   GetElementAttr(uint8_t aNumAttrs, btrc_media_attr_t* aAttrs)
++#endif
+   {
+     GetElementAttrNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::GetElementAttrNotification,
+@@ -191,7 +223,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  RegisterNotification(btrc_event_id_t aEvent, uint32_t aParam, bt_bdaddr_t *bd_addr)
++#else
+   RegisterNotification(btrc_event_id_t aEvent, uint32_t aParam)
++#endif
+   {
+     RegisterNotificationNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::RegisterNotificationNotification,
+@@ -209,7 +245,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  VolumeChange(uint8_t aVolume, uint8_t aCType, bt_bdaddr_t *bd_addr)
++#else
+   VolumeChange(uint8_t aVolume, uint8_t aCType)
++#endif
+   {
+     VolumeChangeNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::VolumeChangeNotification,
+@@ -217,7 +257,11 @@ struct BluetoothAvrcpCallback
+   }
+ 
+   static void
++#if ANDROID_VERSION >= 23
++  PassthroughCmd(int aId, int aKeyState, bt_bdaddr_t *bd_addr)
++#else
+   PassthroughCmd(int aId, int aKeyState)
++#endif
+   {
+     PassthroughCmdNotification::Dispatch(
+       &BluetoothAvrcpNotificationHandler::PassthroughCmdNotification,
+@@ -277,7 +321,12 @@ BluetoothAvrcpHALInterface::Init(
+   sAvrcpNotificationHandler = aNotificationHandler;
+ 
+ #if ANDROID_VERSION >= 18
++#if ANDROID_VERSION >= 23
++  // maxAvrcpConnections = 1
++  bt_status_t status = mInterface->init(&sCallbacks, 1);
++#else
+   bt_status_t status = mInterface->init(&sCallbacks);
++#endif // ANDROID_VERSION >= 23
+ #else
+   bt_status_t status = BT_STATUS_UNSUPPORTED;
+ #endif
+@@ -312,7 +361,11 @@ BluetoothAvrcpHALInterface::GetPlayStatusRsp(
+   btrc_play_status_t playStatus = BTRC_PLAYSTATE_STOPPED;
+ 
+   if (!(NS_FAILED(Convert(aPlayStatus, playStatus)))) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->get_play_status_rsp(playStatus, aSongLen, aSongPos, NULL);
++#else
+     status = mInterface->get_play_status_rsp(playStatus, aSongLen, aSongPos);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -339,7 +392,11 @@ BluetoothAvrcpHALInterface::ListPlayerAppAttrRsp(
+   nsAutoArrayPtr<btrc_player_attr_t> pAttrs;
+ 
+   if (NS_SUCCEEDED(Convert(pAttrsArray, pAttrs))) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->list_player_app_attr_rsp((uint8_t)aNumAttr, pAttrs, NULL);
++#else
+     status = mInterface->list_player_app_attr_rsp(aNumAttr, pAttrs);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -359,7 +416,11 @@ BluetoothAvrcpHALInterface::ListPlayerAppValueRsp(
+   int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes)
+ {
+ #if ANDROID_VERSION >= 18
++#if ANDROID_VERSION >= 23
++  bt_status_t status = mInterface->list_player_app_value_rsp(aNumVal, aPVals, NULL);
++#else
+   bt_status_t status = mInterface->list_player_app_value_rsp(aNumVal, aPVals);
++#endif
+ #else
+   bt_status_t status = BT_STATUS_UNSUPPORTED;
+ #endif
+@@ -385,7 +446,11 @@ BluetoothAvrcpHALInterface::GetPlayerAppValueRsp(
+   NS_NOTREACHED("Conversion function missing");
+ 
+   if (false /* TODO: we don't support any player app values currently */) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->get_player_app_value_rsp(&pVals, NULL);
++#else
+     status = mInterface->get_player_app_value_rsp(&pVals);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -414,7 +479,11 @@ BluetoothAvrcpHALInterface::GetPlayerAppAttrTextRsp(
+   NS_NOTREACHED("Conversion function missing");
+ 
+   if (false /* TODO: we don't support any attributes currently */) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->get_player_app_attr_text_rsp(aNumAttr, aPAttrs, NULL);
++#else
+     status = mInterface->get_player_app_attr_text_rsp(aNumAttr, aPAttrs);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -443,7 +512,11 @@ BluetoothAvrcpHALInterface::GetPlayerAppValueTextRsp(
+   NS_NOTREACHED("Conversion function missing");
+ 
+   if (false /* TODO: we don't support any values currently */) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->get_player_app_value_text_rsp(aNumVal, pVals, NULL);
++#else
+     status = mInterface->get_player_app_value_text_rsp(aNumVal, pVals);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -470,7 +543,11 @@ BluetoothAvrcpHALInterface::GetElementAttrRsp(
+   nsAutoArrayPtr<btrc_element_attr_val_t> pAttrs;
+ 
+   if (NS_SUCCEEDED(Convert(pAttrsArray, pAttrs))) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->get_element_attr_rsp(aNumAttr, pAttrs, NULL);
++#else
+     status = mInterface->get_element_attr_rsp(aNumAttr, pAttrs);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -495,7 +572,11 @@ BluetoothAvrcpHALInterface::SetPlayerAppValueRsp(
+   btrc_status_t rspStatus = BTRC_STS_BAD_CMD; // silences compiler warning
+ 
+   if (NS_SUCCEEDED(Convert(aRspStatus, rspStatus))) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->set_player_app_value_rsp(rspStatus, NULL);
++#else
+     status = mInterface->set_player_app_value_rsp(rspStatus);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -558,7 +639,11 @@ BluetoothAvrcpHALInterface::RegisterNotificationRsp(
+   if (NS_SUCCEEDED(rv) &&
+       NS_SUCCEEDED(Convert(aEvent, event)) &&
+       NS_SUCCEEDED(Convert(aType, type))) {
++#if ANDROID_VERSION >= 23
++    status = mInterface->register_notification_rsp(event, type, &param, NULL);
++#else
+     status = mInterface->register_notification_rsp(event, type, &param);
++#endif
+   } else {
+     status = BT_STATUS_PARM_INVALID;
+   }
+@@ -578,7 +663,11 @@ BluetoothAvrcpHALInterface::SetVolume(uint8_t aVolume,
+                                       BluetoothAvrcpResultHandler* aRes)
+ {
+ #if ANDROID_VERSION >= 19
++#if ANDROID_VERSION >= 23
++  bt_status_t status = mInterface->set_volume(aVolume, NULL);
++#else
+   bt_status_t status = mInterface->set_volume(aVolume);
++#endif
+ #else
+   bt_status_t status = BT_STATUS_UNSUPPORTED;
+ #endif
+diff --git a/toolkit/mozapps/update/updater/automounter_gonk.cpp b/toolkit/mozapps/update/updater/automounter_gonk.cpp
+index 3dff2a1..1cd04d7 100644
+--- a/toolkit/mozapps/update/updater/automounter_gonk.cpp
++++ b/toolkit/mozapps/update/updater/automounter_gonk.cpp
+@@ -14,6 +14,7 @@
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <unistd.h>
++#include <string.h>
+ 
+ #include "automounter_gonk.h"
+ #include "updatedefines.h"
+diff --git a/widget/gonk/GonkPermission.cpp b/widget/gonk/GonkPermission.cpp
+index 2eb4c93..0cd2d81 100644
+--- a/widget/gonk/GonkPermission.cpp
++++ b/widget/gonk/GonkPermission.cpp
+@@ -30,7 +30,7 @@
+ 
+ #undef LOG
+ #include <android/log.h>
+-#define ALOGE(args...)  __android_log_print(ANDROID_LOG_ERROR, "gonkperm" , ## args)
++//#define ALOGE(args...)  __android_log_print(ANDROID_LOG_ERROR, "gonkperm" , ## args)
+ 
+ using namespace android;
+ using namespace mozilla;
+-- 
+1.8.2.1
+
diff --git a/patch/all/gecko/0003-Remove-dummy-pthread_fork-definition.patch b/patch/all/gecko/0003-Remove-dummy-pthread_fork-definition.patch
new file mode 100644
index 0000000..66d84a6
--- /dev/null
+++ b/patch/all/gecko/0003-Remove-dummy-pthread_fork-definition.patch
@@ -0,0 +1,34 @@
+From 8453e506d543586fec24ee1eb1837af710db87b7 Mon Sep 17 00:00:00 2001
+From: Carol Yang <cyang@codeaurora.org>
+Date: Wed, 23 Mar 2016 13:22:30 -0700
+Subject: [PATCH 3/3] Remove dummy pthread_fork definition
+
+Change-Id: I0c22f9708e6ee71927c92bc8ea063098ddb19ec6
+---
+ memory/replace/logalloc/replay/Replay.cpp | 10 ----------
+ 1 file changed, 10 deletions(-)
+
+diff --git a/memory/replace/logalloc/replay/Replay.cpp b/memory/replace/logalloc/replay/Replay.cpp
+index 75db8fb..831d55c 100644
+--- a/memory/replace/logalloc/replay/Replay.cpp
++++ b/memory/replace/logalloc/replay/Replay.cpp
+@@ -298,16 +298,6 @@ void malloc_init_hard(void);
+  * implementation on Android */
+ void
+ MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag) {}
+-
+-/* mozjemalloc and jemalloc use pthread_atfork, which Android doesn't have.
+- * While gecko has one in libmozglue, the replay program can't use that.
+- * Since we're not going to fork anyways, make it a dummy function. */
+-int
+-pthread_atfork(void (*aPrepare)(void), void (*aParent)(void),
+-               void (*aChild)(void))
+-{
+-  return 0;
+-}
+ #endif
+ 
+ #ifdef MOZ_NUWA_PROCESS
+-- 
+1.8.2.1
+
-- 
GitLab