Merge m-c to inbound.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 20 May 2013 11:29:37 -0400
changeset 143891 1919510d5436179ca5a9f2c087a1d0e83a1bfabe
parent 143890 e0e9b99639f82c956a6eaf2d2195dc61e97a0faf (current diff)
parent 143866 cc5c6e1b214783a27bc6fbcdda68f4260ab9433a (diff)
child 143892 4236b11635084000d9921be88d4c45d53979bf5a
child 143921 1f1f058843cca1efd8745eebfe2f9ee7c05591be
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c to inbound.
--- a/dom/alarm/AlarmDB.jsm
+++ b/dom/alarm/AlarmDB.jsm
@@ -134,25 +134,23 @@ AlarmDB.prototype = {
    */
   getAll: function getAll(aManifestURL, aSuccessCb, aErrorCb) {
     debug("getAll()");
 
     this.newTxn(
       "readonly",
       ALARMSTORE_NAME,
       function txnCb(aTxn, aStore) {
-        if (!aTxn.result)
+        if (!aTxn.result) {
           aTxn.result = [];
+        }
 
-        aStore.mozGetAll().onsuccess = function setTxnResult(aEvent) {
-          aEvent.target.result.forEach(function addAlarm(aAlarm) {
-            if (!aManifestURL || aManifestURL == aAlarm.manifestURL)
-              aTxn.result.push(aAlarm);
-          });
-
+        let index = aStore.index("manifestURL");
+        index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
+          aTxn.result = aEvent.target.result;
           debug("Request successful. Record count: " + aTxn.result.length);
         };
       },
       aSuccessCb,
       aErrorCb
     );
   }
 };
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -24,17 +24,17 @@
 #include "nsIObserverService.h"
 #include "nsIDOMFile.h"
 #include "nsIFile.h"
 #include "nsIInputStream.h"
 #include "nsIMIMEService.h"
 #include "nsIOutputStream.h"
 #include "nsNetUtil.h"
 
-#define TARGET_SUBDIR "downloads/bluetooth/"
+#define TARGET_SUBDIR "Download/Bluetooth/"
 
 USING_BLUETOOTH_NAMESPACE
 using namespace mozilla;
 using namespace mozilla::ipc;
 
 class BluetoothOppManagerObserver : public nsIObserver
 {
 public:
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -746,17 +746,17 @@ BluetoothService::Observe(nsISupports* a
 
   MOZ_ASSERT(false, "BluetoothService got unexpected topic!");
   return NS_ERROR_UNEXPECTED;
 }
 
 void
 BluetoothService::Notify(const BluetoothSignal& aData)
 {
-  nsString type;
+  nsString type = NS_LITERAL_STRING("bluetooth-pairing-request");
 
   JSContext* cx = nsContentUtils::GetSafeJSContext();
   NS_ASSERTION(!::JS_IsExceptionPending(cx),
                "Shouldn't get here when an exception is pending!");
 
   JSAutoRequest jsar(cx);
   JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
   if (!obj) {
@@ -767,46 +767,42 @@ BluetoothService::Notify(const Bluetooth
   if (!SetJsObject(cx, aData.value(), obj)) {
     NS_WARNING("Failed to set properties of system message!");
     return;
   }
 
   BT_LOG("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   if (aData.name().EqualsLiteral("RequestConfirmation")) {
-    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
+    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 4,
       "RequestConfirmation: Wrong length of parameters");
-    type.AssignLiteral("bluetooth-requestconfirmation");
   } else if (aData.name().EqualsLiteral("RequestPinCode")) {
-    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 2,
+    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
       "RequestPinCode: Wrong length of parameters");
-    type.AssignLiteral("bluetooth-requestpincode");
   } else if (aData.name().EqualsLiteral("RequestPasskey")) {
-    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 2,
+    NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
       "RequestPinCode: Wrong length of parameters");
-    type.AssignLiteral("bluetooth-requestpasskey");
   } else if (aData.name().EqualsLiteral("Authorize")) {
     NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 2,
       "Authorize: Wrong length of parameters");
     type.AssignLiteral("bluetooth-authorize");
   } else if (aData.name().EqualsLiteral("Cancel")) {
     NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 0,
       "Cancel: Wrong length of parameters");
     type.AssignLiteral("bluetooth-cancel");
   } else if (aData.name().EqualsLiteral("PairedStatusChanged")) {
     NS_ASSERTION(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 1,
       "PairedStatusChagned: Wrong length of parameters");
     type.AssignLiteral("bluetooth-pairedstatuschanged");
   } else {
-#ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling service signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
     NS_WARNING(warningMsg.get());
-#endif
+    return;
   }
 
   nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
     do_GetService("@mozilla.org/system-message-internal;1");
   NS_ENSURE_TRUE_VOID(systemMessenger);
 
   systemMessenger->BroadcastMessage(type, OBJECT_TO_JSVAL(obj));
 }
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -515,16 +515,19 @@ AgentEventFilter(DBusConnection *conn, D
                                DBUS_TYPE_INVALID)) {
       BT_WARNING("%s: Invalid arguments: RequestConfirmation()", __FUNCTION__);
       errorStr.AssignLiteral("Invalid arguments: RequestConfirmation()");
     } else {
       parameters.AppendElement(BluetoothNamedValue(
                                  NS_LITERAL_STRING("path"),
                                  NS_ConvertUTF8toUTF16(objectPath)));
       parameters.AppendElement(BluetoothNamedValue(
+                                 NS_LITERAL_STRING("method"),
+                                 NS_LITERAL_STRING("confirmation")));
+      parameters.AppendElement(BluetoothNamedValue(
                                  NS_LITERAL_STRING("passkey"),
                                  passkey));
 
       KeepDBusPairingMessage(GetAddressFromObjectPath(
                                NS_ConvertUTF8toUTF16(objectPath)), msg);
 
       BluetoothSignal signal(signalName, signalPath, parameters);
 
@@ -548,16 +551,19 @@ AgentEventFilter(DBusConnection *conn, D
                                DBUS_TYPE_INVALID)) {
       BT_WARNING("%s: Invalid arguments for RequestPinCode() method",
                  __FUNCTION__);
       errorStr.AssignLiteral("Invalid arguments for RequestPinCode() method");
     } else {
       parameters.AppendElement(BluetoothNamedValue(
                                  NS_LITERAL_STRING("path"),
                                  NS_ConvertUTF8toUTF16(objectPath)));
+      parameters.AppendElement(BluetoothNamedValue(
+                                 NS_LITERAL_STRING("method"),
+                                 NS_LITERAL_STRING("pincode")));
 
       KeepDBusPairingMessage(GetAddressFromObjectPath(
                                NS_ConvertUTF8toUTF16(objectPath)), msg);
 
       BluetoothSignal signal(signalName, signalPath, parameters);
 
       // Fire a Device properties fetcher at the main thread
       nsRefPtr<DevicePropertiesSignalHandler> b =
@@ -579,16 +585,19 @@ AgentEventFilter(DBusConnection *conn, D
                                DBUS_TYPE_INVALID)) {
       BT_WARNING("%s: Invalid arguments for RequestPasskey() method",
                  __FUNCTION__);
       errorStr.AssignLiteral("Invalid arguments for RequestPasskey() method");
     } else {
       parameters.AppendElement(BluetoothNamedValue(
                                  NS_LITERAL_STRING("path"),
                                  NS_ConvertUTF8toUTF16(objectPath)));
+      parameters.AppendElement(BluetoothNamedValue(
+                                 NS_LITERAL_STRING("method"),
+                                 NS_LITERAL_STRING("passkey")));
 
       KeepDBusPairingMessage(GetAddressFromObjectPath(
                                NS_ConvertUTF8toUTF16(objectPath)), msg);
 
       BluetoothSignal signal(signalName, signalPath, parameters);
 
       // Fire a Device properties fetcher at the main thread
       nsRefPtr<DevicePropertiesSignalHandler> b =
@@ -1843,67 +1852,53 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
-    BluetoothValue v = mSignal.value();
-    if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue ||
-        v.get_ArrayOfBluetoothNamedValue().Length() == 0) {
-      NS_WARNING("Invalid value type for GetDeviceProperties() method");
-      return NS_ERROR_FAILURE;
-    }
-
     const InfallibleTArray<BluetoothNamedValue>& arr =
-      v.get_ArrayOfBluetoothNamedValue();
-    NS_ASSERTION(arr[0].name().EqualsLiteral("path"),
-                 "failed to get object path");
-    NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
-                 "failed to get_nsString");
+      mSignal.value().get_ArrayOfBluetoothNamedValue();
     nsString devicePath = arr[0].value().get_nsString();
 
     BluetoothValue prop;
-    if (!GetPropertiesInternal(devicePath, DBUS_DEVICE_IFACE, prop)) {
-      NS_WARNING("Getting properties failed!");
-      return NS_ERROR_FAILURE;
-    }
-    InfallibleTArray<BluetoothNamedValue>& properties =
-      prop.get_ArrayOfBluetoothNamedValue();
+    bool rv = GetPropertiesInternal(devicePath, DBUS_DEVICE_IFACE, prop);
+    NS_ENSURE_TRUE(rv, NS_ERROR_FAILURE);
 
     // Return original dbus message parameters and also device name
     // for agent events "RequestConfirmation", "RequestPinCode",
     // and "RequestPasskey"
     InfallibleTArray<BluetoothNamedValue>& parameters =
-      v.get_ArrayOfBluetoothNamedValue();
+      mSignal.value().get_ArrayOfBluetoothNamedValue();
 
     // Replace object path with device address
     nsString address = GetAddressFromObjectPath(devicePath);
     parameters[0].name().AssignLiteral("address");
     parameters[0].value() = address;
 
+    InfallibleTArray<BluetoothNamedValue>& properties =
+      prop.get_ArrayOfBluetoothNamedValue();
     uint8_t i;
     for (i = 0; i < properties.Length(); i++) {
       // Append device name
       if (properties[i].name().EqualsLiteral("Name")) {
         properties[i].name().AssignLiteral("name");
         parameters.AppendElement(properties[i]);
-        mSignal.value() = parameters;
         break;
       }
     }
-    NS_ASSERTION(i != properties.Length(), "failed to get device name");
+    MOZ_ASSERT(i != properties.Length(), "failed to get device name");
 
     nsRefPtr<DistributeBluetoothSignalTask> t =
       new DistributeBluetoothSignalTask(mSignal);
     if (NS_FAILED(NS_DispatchToMainThread(t))) {
-       NS_WARNING("Failed to dispatch to main thread!");
-       return NS_ERROR_FAILURE;
+      NS_WARNING("Failed to dispatch to main thread!");
+      return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
   }
 
 private:
   BluetoothSignal mSignal;
 };
@@ -1983,23 +1978,40 @@ private:
   nsTArray<nsString> mDeviceAddresses;
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
   FilterFunc mFilterFunc;
 };
 
 nsresult
 BluetoothDBusService::GetDevicePropertiesInternal(const BluetoothSignal& aSignal)
 {
-  NS_ASSERTION(NS_IsMainThread(), "Must be called from main thread!");
+  MOZ_ASSERT(NS_IsMainThread());
 
   if (!mConnection || !gThreadConnection) {
     NS_ERROR("Bluetooth service not started yet!");
     return NS_ERROR_FAILURE;
   }
 
+  BluetoothValue v = aSignal.value();
+  if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue ||
+      v.get_ArrayOfBluetoothNamedValue().Length() == 0) {
+    NS_WARNING("Invalid value type for GetDevicePropertiesInternal() method");
+    return NS_ERROR_FAILURE;
+  }
+
+  const InfallibleTArray<BluetoothNamedValue>& arr =
+    v.get_ArrayOfBluetoothNamedValue();
+
+  // Device object path should be put in the first element
+  if (!arr[0].name().EqualsLiteral("path") ||
+      arr[0].value().type() != BluetoothValue::TnsString) {
+    NS_WARNING("Invalid object path for GetDevicePropertiesInternal() method");
+    return NS_ERROR_FAILURE;
+  }
+
   nsRefPtr<nsRunnable> func(new BluetoothDevicePropertiesRunnable(aSignal));
   if (NS_FAILED(mBluetoothCommandThread->Dispatch(func, NS_DISPATCH_NORMAL))) {
     NS_WARNING("Cannot dispatch task!");
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
--- a/dom/messages/SystemMessagePermissionsChecker.jsm
+++ b/dom/messages/SystemMessagePermissionsChecker.jsm
@@ -50,16 +50,19 @@ this.SystemMessagePermissionsTable = {
     "bluetooth": []
   },
   "bluetooth-pairedstatuschanged": {
     "bluetooth": []
   },
   "bluetooth-hfp-status-changed": {
     "bluetooth": []
   },
+  "bluetooth-pairing-request": {
+    "bluetooth": []
+  },
   "bluetooth-opp-transfer-complete": {
     "bluetooth": []
   },
   "bluetooth-opp-update-progress": {
     "bluetooth": []
   },
   "bluetooth-opp-receiving-file-confirmation": {
     "bluetooth": []
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -74,17 +74,21 @@ public:
       InternalSetAudioRoutes(SWITCH_STATE_HEADSET);
     else if (sHeadsetState & AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
       InternalSetAudioRoutes(SWITCH_STATE_HEADPHONE);
     else
       InternalSetAudioRoutes(SWITCH_STATE_OFF);
 
     int32_t phoneState = nsIAudioManager::PHONE_STATE_INVALID;
     am->GetPhoneState(&phoneState);
+#if ANDROID_VERSION < 17
     AudioSystem::setPhoneState(phoneState);
+#else
+    AudioSystem::setPhoneState(static_cast<audio_mode_t>(phoneState));
+#endif
 
     AudioSystem::get_audio_flinger();
     return NS_OK;
   }
 };
 
 static void
 BinderDeadCallback(status_t aErr)
@@ -252,18 +256,26 @@ AudioManager::AudioManager() : mPhoneSta
   }
 
   for (int 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
-  AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(AUDIO_STREAM_ENFORCED_AUDIBLE),
-                                    sMaxStreamVolumeTbl[AUDIO_STREAM_ENFORCED_AUDIBLE]);
+#if ANDROID_VERSION < 17
+  AudioSystem::setStreamVolumeIndex(
+    static_cast<audio_stream_type_t>(AUDIO_STREAM_ENFORCED_AUDIBLE),
+    sMaxStreamVolumeTbl[AUDIO_STREAM_ENFORCED_AUDIBLE]);
+#else
+  AudioSystem::setStreamVolumeIndex(
+    static_cast<audio_stream_type_t>(AUDIO_STREAM_ENFORCED_AUDIBLE),
+    sMaxStreamVolumeTbl[AUDIO_STREAM_ENFORCED_AUDIBLE],
+    AUDIO_DEVICE_OUT_SPEAKER);
+#endif
 
   AudioSystem::setErrorCallback(BinderDeadCallback);
 }
 
 AudioManager::~AudioManager() {
   UnregisterSwitchObserver(SWITCH_HEADPHONES, mObserver);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -345,17 +357,21 @@ AudioManager::GetPhoneState(int32_t* aSt
 
 NS_IMETHODIMP
 AudioManager::SetPhoneState(int32_t aState)
 {
   if (mPhoneState == aState) {
     return NS_OK;
   }
 
+#if ANDROID_VERSION < 17
   if (AudioSystem::setPhoneState(aState)) {
+#else
+  if (AudioSystem::setPhoneState(static_cast<audio_mode_t>(aState))) {
+#endif
     return NS_ERROR_FAILURE;
   }
 
   mPhoneState = aState;
 
   if (mPhoneAudioAgent) {
     mPhoneAudioAgent->StopPlaying();
     mPhoneAudioAgent = nullptr;
@@ -446,34 +462,68 @@ AudioManager::SetFmRadioAudioEnabled(boo
       >(AudioSystem::setDeviceConnectionState)) {
     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 = 0;
-      AudioSystem::getStreamVolumeIndex(static_cast<audio_stream_type_t>(AUDIO_STREAM_MUSIC), &volIndex);
-      AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(AUDIO_STREAM_FM), volIndex);
+#if ANDROID_VERSION < 17
+      AudioSystem::getStreamVolumeIndex(
+        static_cast<audio_stream_type_t>(AUDIO_STREAM_MUSIC),
+        &volIndex);
+      AudioSystem::setStreamVolumeIndex(
+        static_cast<audio_stream_type_t>(AUDIO_STREAM_FM),
+        volIndex);
+#else
+      AudioSystem::getStreamVolumeIndex(
+        static_cast<audio_stream_type_t>(AUDIO_STREAM_MUSIC),
+        &volIndex,
+        AUDIO_DEVICE_OUT_DEFAULT);
+      AudioSystem::setStreamVolumeIndex(
+        static_cast<audio_stream_type_t>(AUDIO_STREAM_FM),
+        volIndex,
+        AUDIO_DEVICE_OUT_SPEAKER);
+#endif
       mCurrentStreamVolumeTbl[AUDIO_STREAM_FM] = volIndex;
     }
     return NS_OK;
   } else {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
 
 NS_IMETHODIMP
 AudioManager::SetStreamVolumeIndex(int32_t aStream, int32_t aIndex) {
+#if ANDROID_VERSION < 17
   status_t status =
-    AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(aStream), aIndex);
+    AudioSystem::setStreamVolumeIndex(
+      static_cast<audio_stream_type_t>(aStream),
+      aIndex);
+#else
+  status_t status =
+    AudioSystem::setStreamVolumeIndex(
+      static_cast<audio_stream_type_t>(aStream),
+      aIndex,
+      AUDIO_DEVICE_OUT_SPEAKER);
+#endif
 
   // sync fm volume with music stream type
   if (aStream == AUDIO_STREAM_MUSIC && IsDeviceOn(AUDIO_DEVICE_OUT_FM)) {
-    AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(AUDIO_STREAM_FM), aIndex);
+#if ANDROID_VERSION < 17
+    AudioSystem::setStreamVolumeIndex(
+      static_cast<audio_stream_type_t>(AUDIO_STREAM_FM),
+      aIndex);
+#else
+    AudioSystem::setStreamVolumeIndex(
+      static_cast<audio_stream_type_t>(AUDIO_STREAM_FM),
+      aIndex,
+      AUDIO_DEVICE_OUT_SPEAKER);
+#endif
     mCurrentStreamVolumeTbl[AUDIO_STREAM_FM] = aIndex;
   }
   mCurrentStreamVolumeTbl[aStream] = aIndex;
 
   return status ? NS_ERROR_FAILURE : NS_OK;
 }
 
 NS_IMETHODIMP
--- a/dom/system/gonk/android_audio/AudioSystem.h
+++ b/dom/system/gonk/android_audio/AudioSystem.h
@@ -218,16 +218,29 @@ typedef enum {
                                AUDIO_CHANNEL_IN_PRESSURE |
                                AUDIO_CHANNEL_IN_X_AXIS |
                                AUDIO_CHANNEL_IN_Y_AXIS |
                                AUDIO_CHANNEL_IN_Z_AXIS |
                                AUDIO_CHANNEL_IN_VOICE_UPLINK |
                                AUDIO_CHANNEL_IN_VOICE_DNLINK),
 } audio_channels_t;
 
+#if ANDROID_VERSION >= 17
+typedef enum {
+    AUDIO_MODE_INVALID          = -2,
+    AUDIO_MODE_CURRENT          = -1,
+    AUDIO_MODE_NORMAL           = 0,
+    AUDIO_MODE_RINGTONE         = 1,
+    AUDIO_MODE_IN_CALL          = 2,
+    AUDIO_MODE_IN_COMMUNICATION = 3,
+
+    AUDIO_MODE_CNT,
+    AUDIO_MODE_MAX              = AUDIO_MODE_CNT - 1,
+} audio_mode_t;
+#endif
 #endif
 
 typedef enum {
     /* output devices */      
     AUDIO_DEVICE_OUT_EARPIECE                  = 0x1,
     AUDIO_DEVICE_OUT_SPEAKER                   = 0x2,
     AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4,
     AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8,
@@ -295,17 +308,23 @@ typedef enum {
                                AUDIO_DEVICE_IN_AUX_DIGITAL |
                                AUDIO_DEVICE_IN_VOICE_CALL |
                                AUDIO_DEVICE_IN_BACK_MIC |
                                AUDIO_DEVICE_IN_ANC_HEADSET |
                                AUDIO_DEVICE_IN_FM_RX |
                                AUDIO_DEVICE_IN_FM_RX_A2DP |
                                AUDIO_DEVICE_IN_DEFAULT),
     AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
+#if ANDROID_VERSION < 17
 } audio_devices_t;
+#else
+};
+
+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,
@@ -645,16 +664,19 @@ public:
     };
 
     //
     // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
     //
     static status_t setDeviceConnectionState(audio_devices device, device_connection_state state, const char *device_address);
     static device_connection_state getDeviceConnectionState(audio_devices device, const char *device_address);
     static status_t setPhoneState(int state);
+#if ANDROID_VERSION >= 17
+    static status_t setPhoneState(audio_mode_t state);
+#endif
     static status_t setRingerMode(uint32_t mode, uint32_t mask);
 #ifdef VANILLA_ANDROID
     static status_t setForceUse(force_use usage, forced_config config);
     static forced_config getForceUse(force_use usage);
     static audio_io_handle_t getOutput(stream_type stream,
                                         uint32_t samplingRate = 0,
                                         uint32_t format = FORMAT_DEFAULT,
                                         uint32_t channels = CHANNEL_OUT_STEREO,
@@ -701,16 +723,24 @@ public:
     static status_t initStreamVolume(stream_type stream,
                                       int indexMin,
                                       int indexMax);
     static status_t initStreamVolume(audio_stream_type_t stream,
                                       int indexMin,
                                       int indexMax);
     static status_t setStreamVolumeIndex(stream_type stream, int index);
     static status_t setStreamVolumeIndex(audio_stream_type_t stream, int index);
+#if ANDROID_VERSION >= 17
+    static status_t setStreamVolumeIndex(audio_stream_type_t stream,
+                                         int index,
+                                         audio_devices_t device);
+    static status_t getStreamVolumeIndex(audio_stream_type_t stream,
+                                         int *index,
+                                         audio_devices_t device);
+#endif
     static status_t getStreamVolumeIndex(stream_type stream, int *index);
     static status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index);
 
     static uint32_t getStrategyForStream(stream_type stream);
 
     static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
     static status_t registerEffect(effect_descriptor_t *desc,
                                     audio_io_handle_t output,
--- a/dom/system/gonk/android_audio/EffectApi.h
+++ b/dom/system/gonk/android_audio/EffectApi.h
@@ -595,22 +595,24 @@ enum audio_device_e {
     DEVICE_BLUETOOTH_SCO_CARKIT = 0x40,         // bluetooth SCO car kit
     DEVICE_BLUETOOTH_A2DP = 0x80,               // generic bluetooth A2DP
     DEVICE_BLUETOOTH_A2DP_HEADPHONES = 0x100,   // bluetooth A2DP headphones
     DEVICE_BLUETOOTH_A2DP_SPEAKER = 0x200,      // bluetooth A2DP speakers
     DEVICE_AUX_DIGITAL = 0x400,                 // digital output
     DEVICE_EXTERNAL_SPEAKER = 0x800             // external speaker (stereo and High quality)
 };
 
+#if ANDROID_VERSION < 17
 // Audio mode
 enum audio_mode_e {
     AUDIO_MODE_NORMAL,      // device idle
     AUDIO_MODE_RINGTONE,    // device ringing
     AUDIO_MODE_IN_CALL      // audio call connected (VoIP or telephony)
 };
+#endif
 
 // Values for "accessMode" field of buffer_config_t:
 //   overwrite, read only, accumulate (read/modify/write)
 enum effect_buffer_access_e {
     EFFECT_BUFFER_ACCESS_WRITE,
     EFFECT_BUFFER_ACCESS_READ,
     EFFECT_BUFFER_ACCESS_ACCUMULATE