Backout b760e37130cd to bbddc71e0b6a for accidental push
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 23 Mar 2015 16:34:37 -0400
changeset 204743 3390c69aa9f05f30fa930eb50aa8762237ebef53
parent 204742 bbddc71e0b6a428371ccbd06330c1b6fce03fbed
child 204744 e5a746852904b5bdcd299bc333945cff36fad3ab
push id726
push userryanvm@gmail.com
push dateMon, 23 Mar 2015 20:35:46 +0000
treeherdermozilla-b2g32_v2_0@e5a746852904 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone32.0
backs outb760e37130cd4b64615bb2f432654cf8d76b2bdd
Backout b760e37130cd to bbddc71e0b6a for accidental push
b2g/components/ProcessGlobal.js
b2g/components/RecoveryService.js
content/media/MediaDecoderStateMachine.cpp
content/media/omx/OmxDecoder.cpp
content/media/webrtc/MediaEngineWebRTC.h
content/media/webrtc/MediaEngineWebRTCVideo.cpp
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/BluetoothService.h
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothDBusService.cpp
dom/bluetooth/bluez/BluetoothDBusService.h
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.h
dom/browser-element/BrowserElementChildPreload.js
dom/browser-element/mochitest/browserElement_Alert.js
dom/camera/GonkCameraControl.cpp
dom/camera/GonkCameraControl.h
dom/icc/tests/marionette/test_icc_info.js
dom/icc/tests/marionette/test_stk_display_text.js
dom/icc/tests/marionette/test_stk_refresh.js
dom/icc/tests/marionette/test_stk_send_dtmf.js
dom/icc/tests/marionette/test_stk_send_sms.js
dom/icc/tests/marionette/test_stk_send_ss.js
dom/icc/tests/marionette/test_stk_send_ussd.js
dom/inputmethod/Keyboard.jsm
dom/inputmethod/MozKeyboard.js
dom/inputmethod/mochitest/file_inputmethod_1043828.html
dom/inputmethod/mochitest/mochitest.ini
dom/inputmethod/mochitest/test_bug1043828.html
dom/mobileconnection/tests/marionette/manifest.ini
dom/mobileconnection/tests/marionette/test_mobile_networks.js
dom/mobileconnection/tests/marionette/test_mobile_operator_names_plmnlist.js
dom/mobilemessage/src/gonk/MmsService.js
dom/network/src/NetworkStatsDB.jsm
dom/speakermanager/SpeakerManager.cpp
dom/speakermanager/SpeakerManagerService.cpp
dom/speakermanager/SpeakerManagerService.h
dom/src/geolocation/nsGeolocation.cpp
dom/system/NetworkGeolocationProvider.js
dom/system/gonk/AudioManager.cpp
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/GonkGPSGeolocationProvider.h
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/android_audio/AudioSystem.h
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_cellbroadcast_config.js
dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js
dom/system/gonk/tests/test_ril_worker_icc_ICCIOHelper.js
dom/system/gonk/tests/test_ril_worker_icc_ICCPDUHelper.js
dom/system/gonk/tests/test_ril_worker_icc_ICCRecordHelper.js
dom/system/gonk/tests/test_ril_worker_icc_ICCUtilsHelper.js
dom/system/gonk/tests/test_ril_worker_icc_SimRecordHelper.js
dom/system/gonk/tests/test_ril_worker_ssn.js
dom/system/gonk/tests/test_ril_worker_stk.js
dom/telephony/Telephony.cpp
dom/telephony/Telephony.h
dom/telephony/TelephonyCallGroup.cpp
dom/telephony/TelephonyCallGroup.h
dom/telephony/TelephonyCallId.h
dom/telephony/TelephonyCallback.cpp
dom/telephony/TelephonyCallback.h
dom/telephony/TelephonyDialCallback.cpp
dom/telephony/TelephonyDialCallback.h
dom/telephony/gonk/TelephonyService.js
dom/telephony/ipc/PTelephony.ipdl
dom/telephony/ipc/PTelephonyRequest.ipdl
dom/telephony/ipc/TelephonyChild.cpp
dom/telephony/ipc/TelephonyChild.h
dom/telephony/ipc/TelephonyIPCService.cpp
dom/telephony/ipc/TelephonyParent.cpp
dom/telephony/ipc/TelephonyParent.h
dom/telephony/moz.build
dom/telephony/nsITelephonyService.idl
dom/telephony/test/marionette/head.js
dom/telephony/test/marionette/manifest.ini
dom/telephony/test/marionette/test_conference_two_hangup_all.js
dom/voicemail/test/marionette/pdu_builder.js
dom/voicemail/test/marionette/test_voicemail_statuschanged.js
dom/webidl/MozIccManager.webidl
dom/webidl/MozStkCommandEvent.webidl
dom/webidl/TelephonyCallGroup.webidl
dom/wifi/WifiProxyService.cpp
dom/wifi/WifiProxyService.h
dom/wifi/WifiWorker.js
gfx/layers/GrallocImages.cpp
gfx/thebes/gfxFT2FontList.cpp
layout/base/tests/bidi_numeral_test.js
layout/base/tests/bug441782-1-ref.html
layout/base/tests/bug441782-1.html
layout/base/tests/bug441782-2-ref.html
layout/base/tests/bug441782-2.html
layout/base/tests/bug441782-3-ref.html
layout/base/tests/bug441782-3.html
layout/base/tests/bug441782-4-ref.html
layout/base/tests/bug441782-4.html
layout/base/tests/bug441782-5-ref.html
layout/base/tests/bug441782-5.html
layout/base/tests/bug467672-1-ref.html
layout/base/tests/bug467672-1.html
layout/base/tests/bug467672-2-ref.html
layout/base/tests/bug467672-2.html
layout/base/tests/bug467672-3-ref.html
layout/base/tests/bug467672-3.html
layout/base/tests/bug467672-4-ref.html
layout/base/tests/bug467672-4.html
layout/base/tests/bug467672-5-ref.html
layout/base/tests/bug467672-5.html
layout/base/tests/bug570378-arabic-1-ref.html
layout/base/tests/bug570378-arabic-1.html
layout/base/tests/bug570378-arabic-2-ref.html
layout/base/tests/bug570378-arabic-2.html
layout/base/tests/bug570378-arabic-3-ref.html
layout/base/tests/bug570378-arabic-3.html
layout/base/tests/bug570378-arabic-4-ref.html
layout/base/tests/bug570378-arabic-4.html
layout/base/tests/bug570378-arabic-5-ref.html
layout/base/tests/bug570378-arabic-5.html
layout/base/tests/bug570378-persian-1-ref.html
layout/base/tests/bug570378-persian-1.html
layout/base/tests/bug570378-persian-2-ref.html
layout/base/tests/bug570378-persian-2.html
layout/base/tests/bug570378-persian-3-ref.html
layout/base/tests/bug570378-persian-3.html
layout/base/tests/bug570378-persian-4-ref.html
layout/base/tests/bug570378-persian-4.html
layout/base/tests/bug570378-persian-5-ref.html
layout/base/tests/bug570378-persian-5.html
layout/base/tests/mochitest.ini
layout/base/tests/test_bug441782-1a.html
layout/base/tests/test_bug441782-1b.html
layout/base/tests/test_bug441782-1c.html
layout/base/tests/test_bug441782-1d.html
layout/base/tests/test_bug441782-1e.html
layout/base/tests/test_bug441782-2a.html
layout/base/tests/test_bug441782-2b.html
layout/base/tests/test_bug441782-2c.html
layout/base/tests/test_bug441782-2d.html
layout/base/tests/test_bug441782-2e.html
layout/base/tests/test_bug441782-3a.html
layout/base/tests/test_bug441782-3b.html
layout/base/tests/test_bug441782-3c.html
layout/base/tests/test_bug441782-3d.html
layout/base/tests/test_bug441782-3e.html
layout/base/tests/test_bug441782-4a.html
layout/base/tests/test_bug441782-4b.html
layout/base/tests/test_bug441782-4c.html
layout/base/tests/test_bug441782-4d.html
layout/base/tests/test_bug441782-4e.html
layout/base/tests/test_bug441782-5a.html
layout/base/tests/test_bug441782-5b.html
layout/base/tests/test_bug441782-5c.html
layout/base/tests/test_bug441782-5d.html
layout/base/tests/test_bug441782-5e.html
layout/base/tests/test_bug467672-1a.html
layout/base/tests/test_bug467672-1b.html
layout/base/tests/test_bug467672-1c.html
layout/base/tests/test_bug467672-1d.html
layout/base/tests/test_bug467672-1e.html
layout/base/tests/test_bug467672-1f.html
layout/base/tests/test_bug467672-1g.html
layout/base/tests/test_bug467672-2a.html
layout/base/tests/test_bug467672-2b.html
layout/base/tests/test_bug467672-2c.html
layout/base/tests/test_bug467672-2d.html
layout/base/tests/test_bug467672-2e.html
layout/base/tests/test_bug467672-2f.html
layout/base/tests/test_bug467672-2g.html
layout/base/tests/test_bug467672-3a.html
layout/base/tests/test_bug467672-3b.html
layout/base/tests/test_bug467672-3c.html
layout/base/tests/test_bug467672-3d.html
layout/base/tests/test_bug467672-3e.html
layout/base/tests/test_bug467672-3f.html
layout/base/tests/test_bug467672-3g.html
layout/base/tests/test_bug467672-4a.html
layout/base/tests/test_bug467672-4b.html
layout/base/tests/test_bug467672-4c.html
layout/base/tests/test_bug467672-4d.html
layout/base/tests/test_bug467672-4e.html
layout/base/tests/test_bug467672-4f.html
layout/base/tests/test_bug467672-4g.html
layout/base/tests/test_bug467672-5a.html
layout/base/tests/test_bug467672-5b.html
layout/base/tests/test_bug467672-5c.html
layout/base/tests/test_bug467672-5d.html
layout/base/tests/test_bug467672-5e.html
layout/base/tests/test_bug467672-5f.html
layout/base/tests/test_bug467672-5g.html
layout/base/tests/test_bug570378-arabic-1a.html
layout/base/tests/test_bug570378-arabic-1b.html
layout/base/tests/test_bug570378-arabic-1c.html
layout/base/tests/test_bug570378-arabic-1d.html
layout/base/tests/test_bug570378-arabic-1e.html
layout/base/tests/test_bug570378-arabic-2a.html
layout/base/tests/test_bug570378-arabic-2b.html
layout/base/tests/test_bug570378-arabic-2c.html
layout/base/tests/test_bug570378-arabic-2d.html
layout/base/tests/test_bug570378-arabic-2e.html
layout/base/tests/test_bug570378-arabic-3a.html
layout/base/tests/test_bug570378-arabic-3b.html
layout/base/tests/test_bug570378-arabic-3c.html
layout/base/tests/test_bug570378-arabic-3d.html
layout/base/tests/test_bug570378-arabic-3e.html
layout/base/tests/test_bug570378-arabic-4a.html
layout/base/tests/test_bug570378-arabic-4b.html
layout/base/tests/test_bug570378-arabic-4c.html
layout/base/tests/test_bug570378-arabic-4d.html
layout/base/tests/test_bug570378-arabic-4e.html
layout/base/tests/test_bug570378-arabic-5a.html
layout/base/tests/test_bug570378-arabic-5b.html
layout/base/tests/test_bug570378-arabic-5c.html
layout/base/tests/test_bug570378-arabic-5d.html
layout/base/tests/test_bug570378-arabic-5e.html
layout/base/tests/test_bug570378-persian-1a.html
layout/base/tests/test_bug570378-persian-1b.html
layout/base/tests/test_bug570378-persian-1c.html
layout/base/tests/test_bug570378-persian-1d.html
layout/base/tests/test_bug570378-persian-1e.html
layout/base/tests/test_bug570378-persian-1f.html
layout/base/tests/test_bug570378-persian-1g.html
layout/base/tests/test_bug570378-persian-2a.html
layout/base/tests/test_bug570378-persian-2b.html
layout/base/tests/test_bug570378-persian-2c.html
layout/base/tests/test_bug570378-persian-2d.html
layout/base/tests/test_bug570378-persian-2e.html
layout/base/tests/test_bug570378-persian-2f.html
layout/base/tests/test_bug570378-persian-2g.html
layout/base/tests/test_bug570378-persian-3a.html
layout/base/tests/test_bug570378-persian-3b.html
layout/base/tests/test_bug570378-persian-3c.html
layout/base/tests/test_bug570378-persian-3d.html
layout/base/tests/test_bug570378-persian-3e.html
layout/base/tests/test_bug570378-persian-3f.html
layout/base/tests/test_bug570378-persian-3g.html
layout/base/tests/test_bug570378-persian-4a.html
layout/base/tests/test_bug570378-persian-4b.html
layout/base/tests/test_bug570378-persian-4c.html
layout/base/tests/test_bug570378-persian-4d.html
layout/base/tests/test_bug570378-persian-4e.html
layout/base/tests/test_bug570378-persian-4f.html
layout/base/tests/test_bug570378-persian-4g.html
layout/base/tests/test_bug570378-persian-5a.html
layout/base/tests/test_bug570378-persian-5b.html
layout/base/tests/test_bug570378-persian-5c.html
layout/base/tests/test_bug570378-persian-5d.html
layout/base/tests/test_bug570378-persian-5e.html
layout/base/tests/test_bug570378-persian-5f.html
layout/base/tests/test_bug570378-persian-5g.html
layout/reftests/bidi/numeral/arabic-1-ref.html
layout/reftests/bidi/numeral/arabic-1.html
layout/reftests/bidi/numeral/arabic-2-ref.html
layout/reftests/bidi/numeral/arabic-2.html
layout/reftests/bidi/numeral/arabic-3-ref.html
layout/reftests/bidi/numeral/arabic-3.html
layout/reftests/bidi/numeral/arabic-4-ref.html
layout/reftests/bidi/numeral/arabic-4.html
layout/reftests/bidi/numeral/arabic-5-ref.html
layout/reftests/bidi/numeral/arabic-5.html
layout/reftests/bidi/numeral/bug441782-1-ref.html
layout/reftests/bidi/numeral/bug441782-1.html
layout/reftests/bidi/numeral/bug441782-2-ref.html
layout/reftests/bidi/numeral/bug441782-2.html
layout/reftests/bidi/numeral/bug441782-3-ref.html
layout/reftests/bidi/numeral/bug441782-3.html
layout/reftests/bidi/numeral/bug441782-4-ref.html
layout/reftests/bidi/numeral/bug441782-4.html
layout/reftests/bidi/numeral/bug441782-5-ref.html
layout/reftests/bidi/numeral/bug441782-5.html
layout/reftests/bidi/numeral/bug467672-1-ref.html
layout/reftests/bidi/numeral/bug467672-1.html
layout/reftests/bidi/numeral/bug467672-2-ref.html
layout/reftests/bidi/numeral/bug467672-2.html
layout/reftests/bidi/numeral/bug467672-3-ref.html
layout/reftests/bidi/numeral/bug467672-3.html
layout/reftests/bidi/numeral/bug467672-4-ref.html
layout/reftests/bidi/numeral/bug467672-4.html
layout/reftests/bidi/numeral/bug467672-5-ref.html
layout/reftests/bidi/numeral/bug467672-5.html
layout/reftests/bidi/numeral/persian-1-ref.html
layout/reftests/bidi/numeral/persian-1.html
layout/reftests/bidi/numeral/persian-2-ref.html
layout/reftests/bidi/numeral/persian-2.html
layout/reftests/bidi/numeral/persian-3-ref.html
layout/reftests/bidi/numeral/persian-3.html
layout/reftests/bidi/numeral/persian-4-ref.html
layout/reftests/bidi/numeral/persian-4.html
layout/reftests/bidi/numeral/persian-5-ref.html
layout/reftests/bidi/numeral/persian-5.html
layout/reftests/bidi/numeral/reftest.list
layout/reftests/bidi/reftest.list
modules/libpref/src/init/all.js
netwerk/protocol/rtsp/rtsp/RTSPConnectionHandler.h
security/sandbox/linux/SandboxFilter.cpp
widget/gonk/GonkPermission.cpp
widget/gonk/nsLookAndFeel.cpp
--- a/b2g/components/ProcessGlobal.js
+++ b/b2g/components/ProcessGlobal.js
@@ -28,17 +28,17 @@ Cu.import("resource://gre/modules/CSPUti
 function debug(msg) {
   log(msg);
 }
 function log(msg) {
   // This file implements console.log(), so use dump().
   //dump('ProcessGlobal: ' + msg + '\n');
 }
 
-const gFactoryResetFile = "__post_reset_cmd__";
+const gFactoryResetFile = "/persist/__post_reset_cmd__";
 
 function ProcessGlobal() {}
 ProcessGlobal.prototype = {
   classID: Components.ID('{1a94c87a-5ece-4d11-91e1-d29c29f21b28}'),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 
   wipeDir: function(path) {
@@ -68,38 +68,30 @@ ProcessGlobal.prototype = {
         this.wipeDir(params[1]);
       }
     });
   },
 
   cleanupAfterFactoryReset: function() {
     log("cleanupAfterWipe start");
 
-    Cu.import("resource://gre/modules/osfile.jsm");
-    let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
-    dir.initWithPath("/persist");
-    var postResetFile = dir.exists() ?
-                        OS.Path.join("/persist", gFactoryResetFile):
-                        OS.Path.join("/cache", gFactoryResetFile);
     let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
-    file.initWithPath(postResetFile);
+    file.initWithPath(gFactoryResetFile);
     if (!file.exists()) {
       debug("Nothing to wipe.")
       return;
     }
 
-    let promise = OS.File.read(postResetFile);
+    Cu.import("resource://gre/modules/osfile.jsm");
+    let promise = OS.File.read(gFactoryResetFile);
     promise.then(
       (array) => {
         file.remove(false);
         let decoder = new TextDecoder();
         this.processWipeFile(decoder.decode(array));
-      },
-      function onError(error) {
-        debug("Error: " + error);
       }
     );
 
     log("cleanupAfterWipe end.");
   },
 
   observe: function pg_observe(subject, topic, data) {
     switch (topic) {
--- a/b2g/components/RecoveryService.js
+++ b/b2g/components/RecoveryService.js
@@ -44,17 +44,17 @@ let librecovery = (function() {
     FotaUpdateStatus:    FotaUpdateStatus,
     getFotaUpdateStatus: library.declare("getFotaUpdateStatus",
                                          ctypes.default_abi,
                                          ctypes.int,
                                          FotaUpdateStatus.ptr)
   };
 })();
 
-const gFactoryResetFile = "__post_reset_cmd__";
+const gFactoryResetFile = "/persist/__post_reset_cmd__";
 
 #endif
 
 function RecoveryService() {}
 
 RecoveryService.prototype = {
   classID: RECOVERYSERVICE_CID,
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIRecoveryService]),
@@ -90,29 +90,22 @@ RecoveryService.prototype = {
       for (let i = 0; i < volNames.length; i++) {
         let name = volNames.queryElementAt(i, Ci.nsISupportsString);
         let volume = volumeService.getVolumeByName(name.data);
         log("Got volume: " + name.data + " at " + volume.mountPoint);
         text += "wipe " + volume.mountPoint + "\n";
       }
 
       Cu.import("resource://gre/modules/osfile.jsm");
-      let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
-      dir.initWithPath("/persist");
-      var postResetFile = dir.exists() ?
-                          OS.Path.join("/persist", gFactoryResetFile):
-                          OS.Path.join("/cache", gFactoryResetFile);
       let encoder = new TextEncoder();
       let array = encoder.encode(text);
-      let promise = OS.File.writeAtomic(postResetFile, array,
-                                        { tmpPath: postResetFile + ".tmp" });
+      let promise = OS.File.writeAtomic(gFactoryResetFile, array,
+                                        { tmpPath: gFactoryResetFile + ".tmp" });
 
-      promise.then(doReset, function onError(error) {
-        log("Error: " + error);
-      });
+      promise.then(doReset);
     } else {
       doReset();
     }
 #endif
     throw Cr.NS_ERROR_FAILURE;
   },
 
   installFotaUpdate: function RS_installFotaUpdate(updatePath) {
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -2006,26 +2006,17 @@ void MediaDecoderStateMachine::DecodeSee
          }
       }
 
       // Setup timestamp state.
       if (seekTime == mEndTime) {
         newCurrentTime = mAudioStartTime = seekTime;
       } else if (HasAudio()) {
         AudioData* audio = AudioQueue().PeekFront();
-        // Though we adjust the newCurrentTime in audio-based, and supplemented
-        // by video. For better UX, should NOT bind the slide position to
-        // the first audio data timestamp directly.
-        // While seeking to a position where there's only either audio or video, or
-        // seeking to a position lies before audio or video, we need to check if
-        // seekTime is bounded in suitable duration. See Bug 1112438.
-        int64_t videoStart = video ? video->mTime : seekTime;
-        int64_t audioStart = audio ? audio->mTime : seekTime;
-        newCurrentTime = mAudioStartTime =
-          std::min(std::min(audioStart, videoStart), seekTime);
+        newCurrentTime = mAudioStartTime = audio ? audio->mTime : seekTime;
       } else {
         newCurrentTime = video ? video->mTime : seekTime;
       }
       mPlayDuration = newCurrentTime - mStartTime;
 
       if (HasVideo()) {
         if (video) {
           {
--- a/content/media/omx/OmxDecoder.cpp
+++ b/content/media/omx/OmxDecoder.cpp
@@ -790,60 +790,56 @@ bool OmxDecoder::ReadVideo(VideoFrame *a
     } else {
       seekMode = MediaSource::ReadOptions::SEEK_NEXT_SYNC;
     }
 
     bool findNextBuffer = true;
     while (findNextBuffer) {
       options.setSeekTo(aTimeUs, seekMode);
       findNextBuffer = false;
-      if (mIsVideoSeeking) {
-        err = mVideoSource->read(&mVideoBuffer, &options);
+      err = mVideoSource->read(&mVideoBuffer, &options);
+      {
         Mutex::Autolock autoLock(mSeekLock);
         mIsVideoSeeking = false;
         PostReleaseVideoBuffer(nullptr, FenceHandle());
       }
-      else {
-	err = mVideoSource->read(&mVideoBuffer);
-      }
-
       // If there is no next Keyframe, jump to the previous key frame.
       if (err == ERROR_END_OF_STREAM && seekMode == MediaSource::ReadOptions::SEEK_NEXT_SYNC) {
         seekMode = MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
         findNextBuffer = true;
         {
           Mutex::Autolock autoLock(mSeekLock);
           mIsVideoSeeking = true;
         }
         continue;
       } else if (err != OK) {
         ALOG("Unexpected error when seeking to %lld", aTimeUs);
         break;
       }
-      // For some codecs, the length of first decoded frame after seek is 0.
-      // Need to ignore it and continue to find the next one
       if (mVideoBuffer->range_length() == 0) {
-        PostReleaseVideoBuffer(mVideoBuffer, FenceHandle());
+        ReleaseVideoBuffer();
         findNextBuffer = true;
+        {
+          Mutex::Autolock autoLock(mSeekLock);
+          mIsVideoSeeking = true;
+        }
       }
     }
     aDoSeek = false;
   } else {
     err = mVideoSource->read(&mVideoBuffer);
   }
 
   aFrame->mSize = 0;
 
   if (err == OK) {
     int64_t timeUs;
     int32_t unreadable;
     int32_t keyFrame;
 
-    size_t length = mVideoBuffer->range_length();
-
     if (!mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs) ) {
       NS_WARNING("OMX decoder did not return frame time");
       return false;
     }
 
     if (!mVideoBuffer->meta_data()->findInt32(kKeyIsSyncFrame, &keyFrame)) {
       keyFrame = 0;
     }
@@ -870,29 +866,30 @@ bool OmxDecoder::ReadVideo(VideoFrame *a
       aFrame->mRotation = mVideoRotation;
       aFrame->mTimeUs = timeUs;
       aFrame->mKeyFrame = keyFrame;
       aFrame->Y.mWidth = mVideoWidth;
       aFrame->Y.mHeight = mVideoHeight;
       // Release to hold video buffer in OmxDecoder more.
       // MediaBuffer's ref count is changed from 2 to 1.
       ReleaseVideoBuffer();
-    } else if (length > 0) {
+    } else if (mVideoBuffer->range_length() > 0) {
       char *data = static_cast<char *>(mVideoBuffer->data()) + mVideoBuffer->range_offset();
+      size_t length = mVideoBuffer->range_length();
 
       if (unreadable) {
         LOG(PR_LOG_DEBUG, "video frame is unreadable");
       }
 
       if (!ToVideoFrame(aFrame, timeUs, data, length, keyFrame)) {
         return false;
       }
     }
-    // Check if this frame is valid or not. If not, skip it.
-    if ((aKeyframeSkip && timeUs < aTimeUs) || length == 0) {
+
+    if (aKeyframeSkip && timeUs < aTimeUs) {
       aFrame->mShouldSkip = true;
     }
     mVideoLastFrameTime = timeUs;
   }
   else if (err == INFO_FORMAT_CHANGED) {
     // If the format changed, update our cached info.
     if (!SetVideoFormat()) {
       return false;
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -181,17 +181,16 @@ public:
   void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType);
 
   void AllocImpl();
   void DeallocImpl();
   void StartImpl(webrtc::CaptureCapability aCapability);
   void StopImpl();
   void SnapshotImpl();
   void RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight);
-  uint32_t ConvertPixelFormatToFOURCC(int aFormat);
   void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
 #endif
 
   // This runnable is for creating a temporary file on the main thread.
   NS_IMETHODIMP
   Run()
   {
     nsCOMPtr<nsIFile> tmp;
--- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp
@@ -844,32 +844,16 @@ MediaEngineWebRTCVideoSource::OnTakePict
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
   mLastCapture =
     static_cast<nsIDOMFile*>(new nsDOMMemoryFile(static_cast<void*>(aData),
                                                  static_cast<uint64_t>(aLength),
                                                  aMimeType));
   mCallbackMonitor.Notify();
 }
 
-uint32_t
-MediaEngineWebRTCVideoSource::ConvertPixelFormatToFOURCC(int aFormat)
-{
-  switch (aFormat) {
-  case HAL_PIXEL_FORMAT_YCrCb_420_SP:
-    return libyuv::FOURCC_NV21;
-  case HAL_PIXEL_FORMAT_YV12:
-    return libyuv::FOURCC_YV12;
-  default: {
-    LOG((" xxxxx Unknown pixel format %d", aFormat));
-    MOZ_ASSERT(false, "Unknown pixel format.");
-    return libyuv::FOURCC_ANY;
-    }
-  }
-}
-
 void
 MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) {
   layers::GrallocImage *nativeImage = static_cast<layers::GrallocImage*>(aImage);
   android::sp<android::GraphicBuffer> graphicBuffer = nativeImage->GetGraphicBuffer();
   void *pMem = nullptr;
   uint32_t size = aWidth * aHeight * 3 / 2;
 
   graphicBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_MASK, &pMem);
@@ -895,17 +879,17 @@ MediaEngineWebRTCVideoSource::RotateImag
   libyuv::ConvertToI420(srcPtr, size,
                         dstPtr, dstWidth,
                         dstPtr + (dstWidth * dstHeight), half_width,
                         dstPtr + (dstWidth * dstHeight * 5 / 4), half_width,
                         0, 0,
                         aWidth, aHeight,
                         aWidth, aHeight,
                         static_cast<libyuv::RotationMode>(mRotation),
-                        ConvertPixelFormatToFOURCC(graphicBuffer->getPixelFormat()));
+                        libyuv::FOURCC_NV21);
   graphicBuffer->unlock();
 
   const uint8_t lumaBpp = 8;
   const uint8_t chromaBpp = 4;
 
   layers::PlanarYCbCrData data;
   data.mYChannel = dstPtr;
   data.mYSize = IntSize(dstWidth, dstHeight);
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -337,23 +337,16 @@ AudioChannelService::GetState(AudioChann
   }
 
   bool oldElementHidden = data->mElementHidden;
   // Update visibility.
   data->mElementHidden = aElementHidden;
 
   data->mState = GetStateInternal(data->mChannel, CONTENT_PROCESS_ID_MAIN,
                                 aElementHidden, oldElementHidden);
-  #ifdef MOZ_WIDGET_GONK
-    bool active = AnyAudioChannelIsActive();
-    for (uint32_t i = 0; i < mSpeakerManager.Length(); i++) {
-      mSpeakerManager[i]->SetAudioChannelActive(active);
-    }
-  #endif
-
   return data->mState;
 }
 
 AudioChannelState
 AudioChannelService::GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
                                       bool aElementHidden,
                                       bool aElementWasHidden)
 {
@@ -373,21 +366,16 @@ AudioChannelService::GetStateInternal(Au
 
   SendAudioChannelChangedNotification(aChildID);
 
   // Let play any visible audio channel.
   if (!aElementHidden) {
     if (CheckVolumeFadedCondition(newType, aElementHidden)) {
       return AUDIO_CHANNEL_STATE_FADED;
     }
-    if (PlayingHigherPriorityChannelExists(aChannel,
-                                           aElementWasHidden,
-                                           aElementHidden)) {
-      return AUDIO_CHANNEL_STATE_MUTED;
-    }
     return CheckTelephonyPolicy(aChannel, aChildID);
   }
 
   // We are not visible, maybe we have to mute.
   if (newType == AUDIO_CHANNEL_INT_NORMAL_HIDDEN ||
       (newType == AUDIO_CHANNEL_INT_CONTENT_HIDDEN &&
        // One process can have multiple content channels; and during the
        // transition from foreground to background, its content channels will be
@@ -1069,26 +1057,8 @@ AudioChannelService::UnregisterTelephony
       }
 
       return;
     }
   }
 
   MOZ_ASSERT(false, "This should not happen.");
 }
-
-bool
-AudioChannelService::PlayingHigherPriorityChannelExists(AudioChannel aChannel,
-                                                        bool aElementWasHidden,
-                                                        bool aElementHidden)
-{
-  // The audio from background to foreground should always be playable.
-  if (aElementWasHidden && !aElementHidden) {
-    return false;
-  }
-  // The notification audio only results in faded, not muted.
-  else if (mCurrentHigherChannel == (int32_t) AudioChannel::Notification ||
-           mCurrentHigherChannel == (int32_t) AudioChannel::Publicnotification) {
-    return false;
-  } else {
-    return mCurrentHigherChannel > (int32_t) aChannel;
-  }
-}
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -214,21 +214,16 @@ protected:
   static PLDHashOperator
   CountWindowEnumerator(AudioChannelAgent* aAgent,
                         AudioChannelAgentData* aUnused,
                         void *aPtr);
 
   // This returns the number of agents from this aWindow.
   uint32_t CountWindow(nsIDOMWindow* aWindow);
 
-  bool
-  PlayingHigherPriorityChannelExists(AudioChannel aChannel,
-                                     bool aElementWasHidden,
-                                     bool aElementHidden);
-
   nsClassHashtable< nsPtrHashKey<AudioChannelAgent>, AudioChannelAgentData > mAgents;
 #ifdef MOZ_WIDGET_GONK
   nsTArray<SpeakerManagerService*>  mSpeakerManager;
 #endif
   nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
 
   int32_t mCurrentHigherChannel;
   int32_t mCurrentVisibleHigherChannel;
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -610,19 +610,16 @@ BluetoothService::HandleSettingsChanged(
 
     if (!value.isBoolean()) {
       MOZ_ASSERT(false, "Expecting a boolean for 'bluetooth.debugging.enabled'!");
       return NS_ERROR_UNEXPECTED;
     }
 
     SWITCH_BT_DEBUG(value.toBoolean());
 
-    // Enable/disable HCI snoop log
-    sBluetoothService->ConfigHciDumpLog(value.toBoolean());
-
     return NS_OK;
   }
 
   // Second, check if the string is BLUETOOTH_ENABLED_SETTING
   if (!JS_StringEqualsAscii(cx, key.toString(), BLUETOOTH_ENABLED_SETTING, &match)) {
     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     return NS_ERROR_OUT_OF_MEMORY;
   }
--- a/dom/bluetooth/BluetoothService.h
+++ b/dom/bluetooth/BluetoothService.h
@@ -352,22 +352,16 @@ protected:
    * variables, so not static. Guaranteed to be called outside of main thread.
    *
    * @return NS_OK on correct startup, NS_ERROR_FAILURE otherwise
    */
   virtual nsresult
   StopInternal() = 0;
 
   /**
-   * Enable/disable snoop log
-   */
-  virtual void
-  ConfigHciDumpLog(bool aEnabled) = 0;
-
-  /**
    * Called when XPCOM first creates this service.
    */
   virtual nsresult
   HandleStartup();
 
   /**
    * Called when the startup settings check has completed.
    */
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -176,17 +176,17 @@ public:
 
     NS_ENSURE_TRUE(sBtAvrcpInterface, NS_OK);
     sBtAvrcpInterface->get_element_attr_rsp(mNumAttr, attrs);
 
     return NS_OK;
   }
 private:
   uint8_t mNumAttr;
-  nsAutoArrayPtr<btrc_media_attr_t> mPlayerAttrs;
+  btrc_media_attr_t* mPlayerAttrs;
 };
 
 class UpdatePassthroughCmdTask : public nsRunnable
 {
 public:
   UpdatePassthroughCmdTask(const nsAString& aName)
     : mName(aName)
   {
@@ -330,22 +330,17 @@ AvrcpGetPlayStatusCallback()
  * aNumAttr: It represents the number of attributes requested in aPlayerAttrs
  * aPlayerAttrs: It represents Attribute Ids
  */
 static void
 AvrcpGetElementAttrCallback(uint8_t aNumAttr, btrc_media_attr_t* aPlayerAttrs)
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  btrc_media_attr_t* attrs = new btrc_media_attr_t[aNumAttr];
-  for (uint8_t i = 0; i < aNumAttr; ++i) {
-    attrs[i] = aPlayerAttrs[i];
-  }
-
-  NS_DispatchToMainThread(new UpdateElementAttrsTask(aNumAttr, attrs));
+  NS_DispatchToMainThread(new UpdateElementAttrsTask(aNumAttr, aPlayerAttrs));
 }
 
 /*
  * Callback for register notification (Play state change/track change/...)
  * To reply RegisterNotification INTERIM response
  * See AVRCP 1.3 Spec 25.2
  * aParam: It only valids if event_id is BTRC_EVT_PLAY_POS_CHANGED,
  * which is playback interval time
@@ -796,26 +791,18 @@ BluetoothA2dpManager::HandleSinkProperty
    */
 
   const nsString& name = arr[0].name();
   NS_ENSURE_TRUE_VOID(name.EqualsLiteral("State"));
 
   const BluetoothValue& value = arr[0].value();
   MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
   SinkState newState = StatusStringToSinkState(value.get_nsString());
-
-  /**
-   * Ensure newState:
-   * - is not SINK_UNKNOWN, and
-   * - differs from mSinkState OR mSinkState is default sink state
-   * (in case bluetooth stack does not update intermediate SINK_CONNECTING state).
-   */
-  bool isDefaultSinkState = (mSinkState == SINK_DISCONNECTED);
-  NS_ENSURE_TRUE_VOID(newState != SinkState::SINK_UNKNOWN &&
-                     (newState != mSinkState || isDefaultSinkState));
+  NS_ENSURE_TRUE_VOID((newState != SinkState::SINK_UNKNOWN) &&
+                      (newState != mSinkState));
 
   SinkState prevState = mSinkState;
   mSinkState = newState;
 
   switch(mSinkState) {
     case SinkState::SINK_CONNECTING:
       // case 1: Either an incoming or outgoing connection attempt ongoing
       MOZ_ASSERT(prevState == SinkState::SINK_DISCONNECTED);
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -240,22 +240,16 @@ ClassToIcon(uint32_t aClass, nsAString& 
       }
       if (aClass & 0x20) {
         aRetIcon.AssignLiteral("camera-photo");
         break;
       }
       break;
   }
 
-  // Bug 1082454, in case multiple major services classes, force to support A2DP
-  // SNK device if rendering bit presented. See also: Bug 1075321
-  if (HAS_RENDERING(aClass)) {
-    aRetIcon.AssignLiteral("audio-card");
-  }
-
   if (aRetIcon.IsEmpty()) {
     if (HAS_AUDIO(aClass)) {
       /**
        * Property 'Icon' may be missed due to CoD of major class is TOY(0x08).
        * But we need to assign Icon as audio-card if service class is 'Audio'.
        * This is for PTS test case TC_AG_COD_BV_02_I. As HFP specification
        * defines that service class is 'Audio' can be considered as HFP HF.
        */
@@ -453,28 +447,17 @@ public:
 
   NS_IMETHOD
   Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (sRequestedDeviceCountArray.IsEmpty()) {
       // This is possible because the callback would be called after turning
-      // Bluetooth on, or simply remote device properties get updated.
-      // See also bug 1076553 for new API fix
-      BluetoothValue value = mProps;
-      BluetoothSignal signal(NS_LITERAL_STRING("DeviceFound"),
-                             NS_LITERAL_STRING(KEY_ADAPTER), value);
-      nsRefPtr<DistributeBluetoothSignalTask>
-        t = new DistributeBluetoothSignalTask(signal);
-
-      if (NS_FAILED(NS_DispatchToMainThread(t))) {
-        BT_WARNING("Failed to dispatch to main thread!");
-      }
-
+      // Bluetooth on.
       return NS_OK;
     }
 
     // Update to registered BluetoothDevice objects
     BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
                            mRemoteDeviceBdAddress, mProps);
     nsRefPtr<DistributeBluetoothSignalTask>
       t = new DistributeBluetoothSignalTask(signal);
@@ -1418,32 +1401,16 @@ ConnectDisconnect(bool aConnect, const n
 
 const bt_interface_t*
 BluetoothServiceBluedroid::GetBluetoothInterface()
 {
   return sBtInterface;
 }
 
 void
-BluetoothServiceBluedroid::ConfigHciDumpLog(bool aEnabled)
-{
-#if ANDROID_VERSION >= 19
-  if(!sBtInterface) {
-    BT_LOGR("sBtInterface is null");
-  }
-
-  BT_LOGR("Config HCI dump: %d", aEnabled);
-  int ret = sBtInterface->config_hci_snoop_log(aEnabled);
-  if (ret != BT_STATUS_SUCCESS) {
-    BT_LOGR("Fail to ConfigHciDumpLog");
-  }
-#endif
-}
-
-void
 BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
                                    uint32_t aCod,
                                    uint16_t aServiceUuid,
                                    BluetoothReplyRunnable* aRunnable)
 {
   ConnectDisconnect(true, aDeviceAddress, aRunnable, aServiceUuid, aCod);
 }
 
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
@@ -76,19 +76,16 @@ public:
   virtual bool
   SetAuthorizationInternal(const nsAString& aDeviceAddress, bool aAllow,
                            BluetoothReplyRunnable* aRunnable);
 
   virtual nsresult
   PrepareAdapterInternal();
 
   virtual void
-  ConfigHciDumpLog(bool aEnabled);
-
-  virtual void
   Connect(const nsAString& aDeviceAddress,
           uint32_t aCod,
           uint16_t aServiceUuid,
           BluetoothReplyRunnable* aRunnable);
 
   virtual bool
   IsConnected(uint16_t aProfileId);
 
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -747,22 +747,16 @@ BluetoothSocket::ReceiveSocketInfo(nsAut
   if (mReceivedSocketInfoLength == FIRST_SOCKET_INFO_MSG_LENGTH) {
     // 1st message: [channel:4]
     int32_t channel = ReadInt32(aMessage->mData, &offset);
     BT_LOGR("channel %d", channel);
 
     // If this is server socket, read header of next message for client fd
     mImpl->mReadMsgForClientFd = mIsServer;
   } else if (mReceivedSocketInfoLength == TOTAL_SOCKET_INFO_LENGTH) {
-    if (aMessage->mSize == TOTAL_SOCKET_INFO_LENGTH) {
-      // Some bluetooth stacks send socket info as a single
-      // 20-byte message so we read from last 16 bytes only.
-      offset = FIRST_SOCKET_INFO_MSG_LENGTH;
-    }
-
     // 2nd message: [size:2][bd address:6][channel:4][connection status:4]
     int16_t size = ReadInt16(aMessage->mData, &offset);
     ReadBdAddress(aMessage->mData, &offset, mDeviceAddress);
     int32_t channel = ReadInt32(aMessage->mData, &offset);
     int32_t connectionStatus = ReadInt32(aMessage->mData, &offset);
 
     BT_LOGR("size %d channel %d remote addr %s status %d",
       size, channel, NS_ConvertUTF16toUTF8(mDeviceAddress).get(), connectionStatus);
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -195,22 +195,16 @@ static bthf_callbacks_t sBluetoothHfpCal
 static bool
 IsValidDtmf(const char aChar) {
   // Valid DTMF: [*#0-9ABCD]
   return (aChar == '*' || aChar == '#') ||
          (aChar >= '0' && aChar <= '9') ||
          (aChar >= 'A' && aChar <= 'D');
 }
 
-static bool
-IsSupportedChld(const int aChld) {
-  // We currently only support CHLD=0~3.
-  return (aChld >= 0 && aChld <= 3);
-}
-
 class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD
   Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
   {
@@ -619,23 +613,16 @@ BluetoothHfpManager::ProcessDtmfCmd(char
   message += aDtmf;
   BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                       NS_ConvertUTF8toUTF16(message));
 }
 
 void
 BluetoothHfpManager::ProcessAtChld(bthf_chld_type_t aChld)
 {
-  if (!IsSupportedChld((int)aChld)) {
-    // We currently don't support Enhanced Call Control.
-    // AT+CHLD=1x and AT+CHLD=2x will be ignored
-    SendResponse(BTHF_AT_RESPONSE_ERROR);
-    return;
-  }
-
   nsAutoCString message("CHLD=");
   message.AppendInt((int)aChld);
   BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                       NS_ConvertUTF8toUTF16(message));
 
   SendResponse(BTHF_AT_RESPONSE_OK);
 }
 
@@ -654,29 +641,23 @@ void BluetoothHfpManager::ProcessDialCal
   if (message.IsEmpty()) {
     mDialingRequestProcessed = false;
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                         NS_LITERAL_STRING("BLDN"));
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN);
   } else if (message[0] == '>') {
     mDialingRequestProcessed = false;
     nsAutoCString newMsg("ATD");
-
-    int end = message.FindChar(';');
-    newMsg += StringHead(message, (end < 0) ? message.Length() : end);
-
+    newMsg += StringHead(message, message.Length() - 1);
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                         NS_ConvertUTF8toUTF16(newMsg));
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN);
   } else {
     nsAutoCString newMsg("ATD");
-
-    int end = message.FindChar(';');
-    newMsg += StringHead(message, (end < 0) ? message.Length() : end);
-
+    newMsg += StringHead(message, message.Length() - 1);
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                         NS_ConvertUTF8toUTF16(newMsg));
     SendResponse(BTHF_AT_RESPONSE_OK);
   }
 }
 
 void
 BluetoothHfpManager::ProcessAtCnum()
--- a/dom/bluetooth/bluez/BluetoothDBusService.cpp
+++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp
@@ -2156,22 +2156,16 @@ public:
 
     Task* task = new StartDBusConnectionTask(connection);
     DispatchToDBusThread(task);
 
     return NS_OK;
   }
 };
 
-void
-BluetoothDBusService::ConfigHciDumpLog(bool aEnabled)
-{
-  // Only available for BT HAL interface
-}
-
 nsresult
 BluetoothDBusService::StartInternal()
 {
   nsRefPtr<nsRunnable> runnable = new StartBluetoothRunnable();
   nsresult rv = DispatchToBtThread(runnable);
   if (NS_FAILED(rv)) {
     BT_WARNING("Failed to dispatch to BT thread!");
   }
--- a/dom/bluetooth/bluez/BluetoothDBusService.h
+++ b/dom/bluetooth/bluez/BluetoothDBusService.h
@@ -174,19 +174,16 @@ public:
 
   virtual nsresult
   SendSinkMessage(const nsAString& aDeviceAddresses,
                   const nsAString& aMessage) MOZ_OVERRIDE;
 
   virtual nsresult
   SendInputMessage(const nsAString& aDeviceAddresses,
                    const nsAString& aMessage) MOZ_OVERRIDE;
-
-  virtual void ConfigHciDumpLog(bool aEnabled) MOZ_OVERRIDE;
-
 private:
   nsresult SendGetPropertyMessage(const nsAString& aPath,
                                   const char* aInterface,
                                   void (*aCB)(DBusMessage *, void *),
                                   BluetoothReplyRunnable* aRunnable);
 
   nsresult SendDiscoveryMessage(const char* aMessageName,
                                 BluetoothReplyRunnable* aRunnable);
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -384,22 +384,16 @@ BluetoothServiceChildProcess::StartInter
 }
 
 nsresult
 BluetoothServiceChildProcess::StopInternal()
 {
   MOZ_CRASH("This should never be called!");
 }
 
-void
-BluetoothServiceChildProcess::ConfigHciDumpLog(bool aEnabled)
-{
-  MOZ_CRASH("This should never be called!");
-}
-
 bool
 BluetoothServiceChildProcess::IsConnected(uint16_t aServiceUuid)
 {
   MOZ_CRASH("This should never be called!");
 }
 
 nsresult
 BluetoothServiceChildProcess::SendSinkMessage(const nsAString& aDeviceAddresses,
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
@@ -202,19 +202,16 @@ private:
   // This method should never be called.
   virtual nsresult
   StartInternal() MOZ_OVERRIDE;
 
   // This method should never be called.
   virtual nsresult
   StopInternal() MOZ_OVERRIDE;
 
-  virtual void
-  ConfigHciDumpLog(bool aEnabled) MOZ_OVERRIDE;
-
   bool
   IsSignalRegistered(const nsAString& aNodeName) {
     return !!mBluetoothSignalObserverTable.Get(aNodeName);
   }
 };
 
 END_BLUETOOTH_NAMESPACE
 
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -382,20 +382,16 @@ BrowserElementChild.prototype = {
               "while in nested event loop.");
         break;
       }
 
       thread.processNextEvent(/* mayWait = */ true);
     }
     debug("Nested event loop - finish");
 
-    if (win.modalDepth == 0) {
-      delete this._windowIDDict[outerWindowID];
-    }
-
     // If we exited the loop because the inner window changed, then bail on the
     // modal prompt.
     if (innerWindowID !== this._tryGetInnerWindowID(win)) {
       throw Components.Exception("Modal state aborted by navigation",
                                  Cr.NS_ERROR_NOT_AVAILABLE);
     }
 
     let returnValue = win.modalReturnValue;
@@ -418,16 +414,17 @@ BrowserElementChild.prototype = {
           ", returnValue=" + returnValue + ")");
 
     if (!this._windowIDDict[outerID]) {
       debug("recvStopWaiting: No record of outer window ID " + outerID);
       return;
     }
 
     let win = this._windowIDDict[outerID].get();
+    delete this._windowIDDict[outerID];
 
     if (!win) {
       debug("recvStopWaiting, but window is gone\n");
       return;
     }
 
     if (innerID !== this._tryGetInnerWindowID(win)) {
       debug("recvStopWaiting, but inner ID has changed\n");
--- a/dom/browser-element/mochitest/browserElement_Alert.js
+++ b/dom/browser-element/mochitest/browserElement_Alert.js
@@ -119,165 +119,31 @@ function test4() {
   iframe.addEventListener("mozbrowsershowmodalprompt", test5);
 
   var script = 'data:,content.alert("test4");';
   mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
 }
 
 // test4 is a mozbrowsershowmodalprompt listener.
 function test5(e) {
-  iframe.removeEventListener('mozbrowsershowmodalprompt', test5);
+  iframe.removeEventListener('mozbrowsershowmodalprompt', test4);
 
   is(e.detail.message, 'test4');
   e.preventDefault(); // cause the page to block.
 
   SimpleTest.executeSoon(test5a);
 }
 
 function test5a() {
   iframe.addEventListener('mozbrowserloadend', test5b);
   iframe.src = browserElementTestHelpers.emptyPage2;
 }
 
 function test5b() {
   iframe.removeEventListener('mozbrowserloadend', test5b);
-  SimpleTest.executeSoon(test6);
-}
-
-// Test nested alerts
-var promptBlockers = [];
-function test6() {
-  iframe.addEventListener("mozbrowsershowmodalprompt", test6a);
-
-  var script = 'data:,\
-    this.testState = 0; \
-    content.alert(1); \
-    this.testState = 3; \
-  ';
-  mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
-}
-
-function test6a(e) {
-  iframe.removeEventListener("mozbrowsershowmodalprompt", test6a);
-
-  is(e.detail.message, '1');
-  e.preventDefault(); // cause the alert to block.
-  promptBlockers.push(e);
-
-  SimpleTest.executeSoon(test6b);
-}
-
-function test6b() {
-  var script = 'data:,\
-    if (this.testState === 0) { \
-      sendAsyncMessage("test-success", "1: Correct testState"); \
-    } \
-    else { \
-      sendAsyncMessage("test-fail", "1: Wrong testState: " + this.testState); \
-    }';
-  mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
-  numPendingChildTests++;
-
-  waitForPendingTests(test6c);
-}
-
-function test6c() {
-  iframe.addEventListener("mozbrowsershowmodalprompt", test6d);
-
-  var script = 'data:,\
-    this.testState = 1; \
-    content.alert(2); \
-    this.testState = 2; \
-  ';
-  mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
-}
-
-function test6d(e) {
-  iframe.removeEventListener("mozbrowsershowmodalprompt", test6d);
-
-  is(e.detail.message, '2');
-  e.preventDefault(); // cause the alert to block.
-  promptBlockers.push(e);
-
-  SimpleTest.executeSoon(test6e);
-}
-
-function test6e() {
-  var script = 'data:,\
-    if (this.testState === 1) { \
-      sendAsyncMessage("test-success", "2: Correct testState"); \
-    } \
-    else { \
-      sendAsyncMessage("test-fail", "2: Wrong testState: " + this.testState); \
-    }';
-  mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
-  numPendingChildTests++;
-
-  waitForPendingTests(test6f);
-}
-
-function test6f() {
-  var e = promptBlockers.pop();
-  // Now unblock the iframe and check that the script completed.
-  e.detail.unblock();
-
-  var script2 = 'data:,\
-    if (this.testState === 2) { \
-      sendAsyncMessage("test-success", "3: Correct testState"); \
-    } \
-    else { \
-      sendAsyncMessage("test-try-again", "3: Wrong testState (for now): " + this.testState); \
-    }';
-
-  // Urgh.  e.unblock() didn't necessarily unblock us immediately, so we have
-  // to spin and wait.
-  function onTryAgain() {
-    SimpleTest.executeSoon(function() {
-      //dump('onTryAgain\n');
-      mm.loadFrameScript(script2, /* allowDelayedLoad = */ false);
-    });
-  }
-
-  mm.addMessageListener('test-try-again', onTryAgain);
-  numPendingChildTests++;
-
-  onTryAgain();
-  waitForPendingTests(test6g);
-}
-
-function test6g() {
-  var e = promptBlockers.pop();
-  // Now unblock the iframe and check that the script completed.
-  e.detail.unblock();
-
-  var script2 = 'data:,\
-    if (this.testState === 3) { \
-      sendAsyncMessage("test-success", "4: Correct testState"); \
-    } \
-    else { \
-      sendAsyncMessage("test-try-again", "4: Wrong testState (for now): " + this.testState); \
-    }';
-
-  // Urgh.  e.unblock() didn't necessarily unblock us immediately, so we have
-  // to spin and wait.
-  function onTryAgain() {
-    SimpleTest.executeSoon(function() {
-      //dump('onTryAgain\n');
-      mm.loadFrameScript(script2, /* allowDelayedLoad = */ false);
-    });
-  }
-
-  mm.addMessageListener('test-try-again', onTryAgain);
-  numPendingChildTests++;
-
-  onTryAgain();
-  waitForPendingTests(test6h);
-}
-
-function test6h() {
   SimpleTest.finish();
 }
 
 var prevNumPendingTests = null;
 function waitForPendingTests(next) {
   if (numPendingChildTests !== prevNumPendingTests) {
     dump("Waiting for end; " + numPendingChildTests + " pending tests\n");
     prevNumPendingTests = numPendingChildTests;
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -64,17 +64,16 @@ nsGonkCameraControl::nsGonkCameraControl
   : mCameraId(aCameraId)
   , mLastPictureSize({0, 0})
   , mLastThumbnailSize({0, 0})
   , mPreviewFps(30)
   , mResumePreviewAfterTakingPicture(false) // XXXmikeh - see bug 950102
   , mFlashSupported(false)
   , mLuminanceSupported(false)
   , mAutoFlashModeOverridden(false)
-  , mSeparateVideoAndPreviewSizesSupported(false)
   , mDeferConfigUpdate(0)
   , mMediaProfiles(nullptr)
   , mRecorder(nullptr)
   , mRecorderMonitor("GonkCameraControl::mRecorder.Monitor")
   , mProfileManager(nullptr)
   , mRecorderProfile(nullptr)
   , mVideoFile(nullptr)
   , mReentrantMonitor("GonkCameraControl::OnTakePictureMonitor")
@@ -163,16 +162,17 @@ nsGonkCameraControl::Initialize()
   int areas;
   mParams.Get(CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS, areas);
   mCurrentConfiguration.mMaxMeteringAreas = areas != -1 ? areas : 0;
   mParams.Get(CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS, areas);
   mCurrentConfiguration.mMaxFocusAreas = areas != -1 ? areas : 0;
 
   mParams.Get(CAMERA_PARAM_PICTURE_SIZE, mLastPictureSize);
   mParams.Get(CAMERA_PARAM_PREVIEWSIZE, mCurrentConfiguration.mPreviewSize);
+  mParams.Get(CAMERA_PARAM_VIDEOSIZE, mLastRecorderSize);
 
   nsString luminance; // check for support
   mParams.Get(CAMERA_PARAM_LUMINANCE, luminance);
   mLuminanceSupported = !luminance.IsEmpty();
 
   nsString flashMode;
   mParams.Get(CAMERA_PARAM_FLASHMODE, flashMode);
   mFlashSupported = !flashMode.IsEmpty();
@@ -180,39 +180,29 @@ nsGonkCameraControl::Initialize()
   DOM_CAMERA_LOGI(" - maximum metering areas:        %u\n", mCurrentConfiguration.mMaxMeteringAreas);
   DOM_CAMERA_LOGI(" - maximum focus areas:           %u\n", mCurrentConfiguration.mMaxFocusAreas);
   DOM_CAMERA_LOGI(" - default picture size:          %u x %u\n",
     mLastPictureSize.width, mLastPictureSize.height);
   DOM_CAMERA_LOGI(" - default thumbnail size:        %u x %u\n",
     mLastThumbnailSize.width, mLastThumbnailSize.height);
   DOM_CAMERA_LOGI(" - default preview size:          %u x %u\n",
     mCurrentConfiguration.mPreviewSize.width, mCurrentConfiguration.mPreviewSize.height);
+  DOM_CAMERA_LOGI(" - default video recorder size:   %u x %u\n",
+    mLastRecorderSize.width, mLastRecorderSize.height);
   DOM_CAMERA_LOGI(" - default picture file format:   %s\n",
     NS_ConvertUTF16toUTF8(mFileFormat).get());
   DOM_CAMERA_LOGI(" - luminance reporting:           %ssupported\n",
     mLuminanceSupported ? "" : "NOT ");
   if (mFlashSupported) {
     DOM_CAMERA_LOGI(" - flash:                         supported, default mode '%s'\n",
       NS_ConvertUTF16toUTF8(flashMode).get());
   } else {
     DOM_CAMERA_LOGI(" - flash:                         NOT supported\n");
   }
 
-  nsAutoTArray<Size, 16> sizes;
-  mParams.Get(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, sizes);
-  if (sizes.Length() > 0) {
-    mSeparateVideoAndPreviewSizesSupported = true;
-    DOM_CAMERA_LOGI(" - support for separate preview and video sizes\n");
-    mParams.Get(CAMERA_PARAM_VIDEOSIZE, mLastRecorderSize);
-    DOM_CAMERA_LOGI(" - default video recorder size:   %u x %u\n",
-      mLastRecorderSize.width, mLastRecorderSize.height);
-  } else {
-    mLastRecorderSize = mCurrentConfiguration.mPreviewSize;
-  }
-
   return NS_OK;
 }
 
 nsGonkCameraControl::~nsGonkCameraControl()
 {
   DOM_CAMERA_LOGT("%s:%d : this=%p, mCameraHw = %p\n", __func__, __LINE__, this, mCameraHw.get());
 
   StopImpl();
@@ -251,16 +241,19 @@ nsGonkCameraControl::SetConfigurationInt
     }
   }
 
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mCurrentConfiguration.mMode = aConfig.mMode;
   mCurrentConfiguration.mRecorderProfile = aConfig.mRecorderProfile;
+  if (aConfig.mMode == kVideoMode) {
+    mCurrentConfiguration.mPreviewSize = mLastRecorderSize;
+  }
 
   OnConfigurationChange();
   return NS_OK;
 }
 
 nsresult
 nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig)
 {
@@ -313,16 +306,32 @@ nsGonkCameraControl::SetPictureConfigura
   DOM_CAMERA_LOGI("picture mode preview: wanted %ux%u, got %ux%u (%u fps)\n",
     aConfig.mPreviewSize.width, aConfig.mPreviewSize.height,
     mCurrentConfiguration.mPreviewSize.width, mCurrentConfiguration.mPreviewSize.height,
     mPreviewFps);
 
   return NS_OK;
 }
 
+nsresult
+nsGonkCameraControl::SetVideoConfiguration(const Configuration& aConfig)
+{
+  DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
+
+  nsresult rv = SetupVideoMode(aConfig.mRecorderProfile);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  DOM_CAMERA_LOGI("video mode preview: profile '%s', got %ux%u (%u fps)\n",
+    NS_ConvertUTF16toUTF8(aConfig.mRecorderProfile).get(),
+    mLastRecorderSize.width, mLastRecorderSize.height,
+    mPreviewFps);
+
+  return rv;
+}
+
 // Parameter management.
 nsresult
 nsGonkCameraControl::PushParameters()
 {
   uint32_t dcu = mDeferConfigUpdate;
   if (dcu > 0) {
     DOM_CAMERA_LOGI("Defering config update (nest level %u)\n", dcu);
     return NS_OK;
@@ -381,18 +390,22 @@ nsGonkCameraControl::SetAndPush(uint32_t
   }
   return PushParameters();
 }
 
 // Array-of-Size parameter accessor.
 nsresult
 nsGonkCameraControl::Get(uint32_t aKey, nsTArray<Size>& aSizes)
 {
-  if (aKey == CAMERA_PARAM_SUPPORTED_VIDEOSIZES &&
-      !mSeparateVideoAndPreviewSizesSupported) {
+  if (aKey == CAMERA_PARAM_SUPPORTED_VIDEOSIZES) {
+    nsresult rv = mParams.Get(aKey, aSizes);
+    if (aSizes.Length() != 0) {
+      return rv;
+    }
+    DOM_CAMERA_LOGI("Camera doesn't support video independent of the preview\n");
     aKey = CAMERA_PARAM_SUPPORTED_PREVIEWSIZES;
   }
 
   return mParams.Get(aKey, aSizes);
 }
 
 // Array-of-doubles parameter accessor.
 nsresult
@@ -1267,40 +1280,31 @@ nsGonkCameraControl::SetPreviewSize(cons
   Size best;
   rv  = GetSupportedSize(aSize, previewSizes, best);
   if (NS_FAILED(rv)) {
     DOM_CAMERA_LOGE("Failed to find a supported preview size, requested size %dx%d",
         aSize.width, aSize.height);
     return rv;
   }
 
-  if (mSeparateVideoAndPreviewSizesSupported) {
-    // Some camera drivers will ignore our preview size if it's larger
-    // than the currently set video recording size, so we need to set
-    // the video size here as well, just in case.
-    if (best.width > mLastRecorderSize.width || best.height > mLastRecorderSize.height) {
-      SetVideoSize(best);
-    }
-  } else {
-    mLastRecorderSize = best;
+  // Some camera drivers will ignore our preview size if it's larger
+  // than the currently set video recording size, so we need to set
+  // the video size here as well, just in case.
+  if (best.width > mLastRecorderSize.width || best.height > mLastRecorderSize.height) {
+    SetVideoSize(best);
   }
   mCurrentConfiguration.mPreviewSize = best;
   return Set(CAMERA_PARAM_PREVIEWSIZE, best);
 }
 
 nsresult
 nsGonkCameraControl::SetVideoSize(const Size& aSize)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
 
-  if (!mSeparateVideoAndPreviewSizesSupported) {
-    DOM_CAMERA_LOGE("Camera does not support setting separate video size\n");
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-  
   nsTArray<Size> videoSizes;
   nsresult rv = Get(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, videoSizes);
   if (NS_FAILED(rv)) {
     DOM_CAMERA_LOGE("Camera failed to return any video sizes (0x%x)\n", rv);
     return rv;
   }
 
   Size best;
@@ -1362,24 +1366,25 @@ nsGonkCameraControl::GetSupportedSize(co
         rv = NS_OK;
       }
     }
   }
   return rv;
 }
 
 nsresult
-nsGonkCameraControl::SetVideoConfiguration(const Configuration& aConfig)
+nsGonkCameraControl::SetupVideoMode(const nsAString& aProfile)
 {
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
 
   // read preferences for camcorder
   mMediaProfiles = MediaProfiles::getInstance();
 
-  nsAutoCString profile = NS_ConvertUTF16toUTF8(aConfig.mRecorderProfile);
+  nsAutoCString profile = NS_ConvertUTF16toUTF8(aProfile);
+  // XXXkhuey are we leaking?
   mRecorderProfile = GetGonkRecorderProfileManager().take()->Get(profile.get());
   if (!mRecorderProfile) {
     DOM_CAMERA_LOGE("Recorder profile '%s' is not supported\n", profile.get());
     return NS_ERROR_INVALID_ARG;
   }
 
   const GonkRecorderVideoProfile* video = mRecorderProfile->GetGonkVideoProfile();
   int width = video->GetWidth();
@@ -1394,43 +1399,31 @@ nsGonkCameraControl::SetVideoConfigurati
   PullParametersImpl();
 
   Size size;
   size.width = static_cast<uint32_t>(width);
   size.height = static_cast<uint32_t>(height);
 
   {
     ICameraControlParameterSetAutoEnter set(this);
-    nsresult rv;
-
-    if (mSeparateVideoAndPreviewSizesSupported) {
-      // The camera supports two video streams: a low(er) resolution preview
-      // stream and and a potentially high(er) resolution stream for encoding. 
-      rv = SetVideoSize(size);
-      if (NS_FAILED(rv)) {
-        DOM_CAMERA_LOGE("Failed to set video mode video size (0x%x)\n", rv);
-        return rv;
-      }
 
-      // The video size must be set first, before the preview size, because
-      // some platforms have a dependency between the two.
-      rv = SetPreviewSize(aConfig.mPreviewSize);
-      if (NS_FAILED(rv)) {
-        DOM_CAMERA_LOGE("Failed to set video mode preview size (0x%x)\n", rv);
-        return rv;
-      }
-    } else {
-      // The camera only supports a single video stream: in this case, we set
-      // the preview size to be the desired video recording size, and ignore
-      // the specified preview size.
-      rv = SetPreviewSize(size);
-      if (NS_FAILED(rv)) {
-        DOM_CAMERA_LOGE("Failed to set video mode preview size (0x%x)\n", rv);
-        return rv;
-      }
+    // The camera interface allows for hardware to provide two video
+    //  streams, a low resolution preview and a potentially high resolution
+    //  stream for encoding. For now we don't use this and set preview and video
+    //  size to the same thing.
+    nsresult rv = SetVideoSize(size);
+    if (NS_FAILED(rv)) {
+      DOM_CAMERA_LOGE("Failed to set video mode video size (0x%x)\n", rv);
+      return rv;
+    }
+
+    rv = SetPreviewSize(size);
+    if (NS_FAILED(rv)) {
+      DOM_CAMERA_LOGE("Failed to set video mode preview size (0x%x)\n", rv);
+      return rv;
     }
 
     rv = Set(CAMERA_PARAM_PREVIEWFRAMERATE, fps);
     if (NS_FAILED(rv)) {
       DOM_CAMERA_LOGE("Failed to set video mode frame rate (0x%x)\n", rv);
       return rv;
     }
   }
--- a/dom/camera/GonkCameraControl.h
+++ b/dom/camera/GonkCameraControl.h
@@ -121,16 +121,17 @@ protected:
   virtual nsresult PushParametersImpl() MOZ_OVERRIDE;
   virtual nsresult PullParametersImpl() MOZ_OVERRIDE;
   virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() MOZ_OVERRIDE;
   already_AddRefed<GonkRecorderProfileManager> GetGonkRecorderProfileManager();
 
   nsresult SetupRecording(int aFd, int aRotation, uint64_t aMaxFileSizeBytes,
                           uint64_t aMaxVideoLengthMs);
   nsresult SetupRecordingFlash(bool aAutoEnableLowLightTorch);
+  nsresult SetupVideoMode(const nsAString& aProfile);
   nsresult SetPreviewSize(const Size& aSize);
   nsresult SetVideoSize(const Size& aSize);
   nsresult PausePreview();
   nsresult GetSupportedSize(const Size& aSize, const nsTArray<Size>& supportedSizes, Size& best);
 
   friend class SetPictureSize;
   friend class SetThumbnailSize;
   nsresult SetPictureSize(const Size& aSize);
@@ -147,17 +148,16 @@ protected:
   Size                      mLastPictureSize;
   Size                      mLastThumbnailSize;
   Size                      mLastRecorderSize;
   uint32_t                  mPreviewFps;
   bool                      mResumePreviewAfterTakingPicture;
   bool                      mFlashSupported;
   bool                      mLuminanceSupported;
   bool                      mAutoFlashModeOverridden;
-  bool                      mSeparateVideoAndPreviewSizesSupported;
   Atomic<uint32_t>          mDeferConfigUpdate;
   GonkCameraParameters      mParams;
 
   nsRefPtr<mozilla::layers::ImageContainer> mImageContainer;
 
   android::MediaProfiles*   mMediaProfiles;
   nsRefPtr<android::GonkRecorder> mRecorder;
   // Touching mRecorder happens inside this monitor because the destructor
--- a/dom/icc/tests/marionette/test_icc_info.js
+++ b/dom/icc/tests/marionette/test_icc_info.js
@@ -57,16 +57,56 @@ taskHelper.push(function basicTest() {
     // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
     // in requestCdmaSubscription()
     is(iccInfo.prlVersion, 1);
   }
 
   taskHelper.runNext();
 });
 
+/* Test Gsm display condition change */
+taskHelper.push(function testGsmDisplayConditionChange() {
+  function testSPN(mcc, mnc, expectedIsDisplayNetworkNameRequired,
+                   expectedIsDisplaySpnRequired, callback) {
+    icc.addEventListener("iccinfochange", function handler() {
+      icc.removeEventListener("iccinfochange", handler);
+      is(icc.iccInfo.isDisplayNetworkNameRequired,
+         expectedIsDisplayNetworkNameRequired);
+      is(icc.iccInfo.isDisplaySpnRequired,
+         expectedIsDisplaySpnRequired);
+      // operatorchange will be ignored if we send commands too soon.
+      window.setTimeout(callback, 100);
+    });
+    // Send emulator command to change network mcc and mnc.
+    setEmulatorMccMnc(mcc, mnc);
+  }
+
+  let testCases = [
+    // [MCC, MNC, isDisplayNetworkNameRequired, isDisplaySpnRequired]
+    [123, 456, false, true], // Not in HPLMN.
+    [234, 136,  true, true], // Not in HPLMN, but in PLMN specified in SPDI.
+    [123, 456, false, true], // Not in HPLMN. Triggering iccinfochange
+    [466,  92,  true, true], // Not in HPLMN, but in another PLMN specified in SPDI.
+    [123, 456, false, true], // Not in HPLMN. Triggering iccinfochange
+    [310, 260,  true, true], // inside HPLMN.
+  ];
+
+  // Ignore this test if device is not in gsm mode.
+  if (!(icc.iccInfo instanceof Ci.nsIDOMMozGsmIccInfo)) {
+    taskHelper.runNext();
+    return;
+  }
+
+  (function do_call(index) {
+    let next = index < (testCases.length - 1) ? do_call.bind(null, index + 1) : taskHelper.runNext.bind(taskHelper);
+    testCases[index].push(next);
+    testSPN.apply(null, testCases[index]);
+  })(0);
+});
+
 /* Test iccInfo when card becomes undetected */
 taskHelper.push(function testCardIsNotReady() {
   // Turn off radio.
   setRadioEnabled(false);
   icc.addEventListener("iccinfochange", function oniccinfochange() {
     // Expect iccInfo changes to null
     if (icc.iccInfo === null) {
       icc.removeEventListener("iccinfochange", oniccinfochange);
--- a/dom/icc/tests/marionette/test_stk_display_text.js
+++ b/dom/icc/tests/marionette/test_stk_display_text.js
@@ -84,129 +84,11 @@ let tests = [
   {command: "d0198103012180820281028D0A043130205365636F6E648402010A",
    func: testDisplayText,
    expect: {name: "display_text_cmd_11",
             commandQualifier: 0x80,
             text: "10 Second",
             userClear: true,
             duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND,
                        timeInterval: 0x0A}}},
-  {command: "D026810301210082028102" +
-            "8D" +
-            "1B" +
-            "00" + // 7BIT
-            "D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
-            "0E8687C158A09B304905",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_12",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x00, 7BIT"}},
-  {command: "D029810301210082028102" +
-            "8D" +
-            "1E" +
-            "04" + // 8BIT
-            "546F6F6C6B697420546573742047524F" +
-            "55503A307830302C2038424954",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_13",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x00, 8BIT"}},
-  {command: "D046810301210082028102" +
-            "8D" +
-            "3B" +
-            "08" + // UCS2
-            "0054006F006F006C006B006900740020" +
-            "0054006500730074002000470052004F" +
-            "00550050003A0030007800300030002C" +
-            "00200055004300530032",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_14",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x00, UCS2"}},
-  {command: "D026810301210082028102" +
-            "8D" +
-            "1B" +
-            "12" + // 7BIT + Class 2
-            "D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
-            "0E868FC158A09B304905",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_15",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x10, 7BIT"}},
-  {command: "D029810301210082028102" +
-            "8D" +
-            "1E" +
-            "16" + // 8BIT + Class 2
-            "546F6F6C6B697420546573742047524F" +
-            "55503A307831302C2038424954",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_16",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x10, 8BIT"}},
-  {command: "D046810301210082028102" +
-            "8D" +
-            "3B" +
-            "1A" + // UCS2 + Class 2
-            "0054006F006F006C006B006900740020" +
-            "0054006500730074002000470052004F" +
-            "00550050003A0030007800310030002C" +
-            "00200055004300530032",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_17",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0x10, UCS2"}},
-  {command: "D026810301210082028102" +
-            "8D" +
-            "1B" +
-            "F2" + // 7BIT + Class 2
-            "D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
-            "0E8637C258A09B304905",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_18",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0xF0, 7BIT"}},
-  {command: "D029810301210082028102" +
-            "8D" +
-            "1E" +
-            "F6" + // 8BIT + Class 2
-            "546F6F6C6B697420546573742047524F" +
-            "55503A307846302C2038424954",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_19",
-            commandQualifier: 0x00,
-            text: "Toolkit Test GROUP:0xF0, 8BIT"}},
-  // Bug 1088573: this test case is to ensure that we provide |length| argument
-  // in |integer| format to GsmPDUHelper.readSeptetsToString().
-  {command: "D0" +
-            "81" + // 2-byte length encoded:
-            "FC" + // 252
-            "810301210082028102" +
-            "8D" +
-            "81" + // 2-byte length encoded:
-            "F0" + // 240
-            "00" + // 7BIT
-            "C332A85D9ECFC3E732685E068DDF6DF8" +
-            "7B5E0691CB20D96D061A87E5E131BD2C" +
-            "2FCF416537A8FD269741E3771B2E2FCF" +
-            "E76517685806B5CBF379F85C0695E774" +
-            "50D86C4E8FD165D0BC2E07C1D9F579BA" +
-            "5C97CF41E5B13CEC9E83CA7490BB0C22" +
-            "BFD374103C3C0795E9F232882E7FBBE3" +
-            "F5B20B24BBCD40E5391DC42E83DCEFB6" +
-            "585E06B5C3F874BBDE0691CBA071581E" +
-            "1ED3CBF2F21C14369BD3637458CC2EBB" +
-            "40C3329D5E0699DFEE313DFD76BBC3EC" +
-            "34BD0C0A83CAF432280C87CBDF757BB9" +
-            "0C8287E5207619346D1E73A0783D0D9A" +
-            "9FCA733A885C96BFEBEC32280C9A6689" +
-            "CE621654768382D529551A64268B2E",
-   func: testDisplayText,
-   expect: {name: "display_text_cmd_20",
-            commandQualifier: 0x00,
-            text: "Ce message se compose de 273 caracteres en mode " +
-                  "compresse. Ce message est affiche sur plusieurs " +
-                  "ecrans et ne doit pas etre tronque. 273 est le " +
-                  "nombre maximum de caracteres affichable. Cette " +
-                  "fonctionnalite a ete approuvee par le SMG9 qui s'est " +
-                  "deroule a SYDNEY en AUSTRALIE."}},
 ];
 
 runNextTest();
--- a/dom/icc/tests/marionette/test_stk_refresh.js
+++ b/dom/icc/tests/marionette/test_stk_refresh.js
@@ -7,19 +7,19 @@ function testRefresh(command, expect) {
   log("STK CMD " + JSON.stringify(command));
   is(command.typeOfCommand, iccManager.STK_CMD_REFRESH, expect.name);
   is(command.commandQualifier, expect.commandQualifier, expect.name);
 
   runNextTest();
 }
 
 let tests = [
-  {command: "d0108103010102820281829205013f002fe2",
+  {command: "d0108103010101820281829205013f002fe2",
    func: testRefresh,
    expect: {name: "refresh_cmd_1",
-            commandQualifier: 0x02}},
+            commandQualifier: 0x01}},
   {command: "d009810301010482028182",
    func: testRefresh,
    expect: {name: "refresh_cmd_2",
             commandQualifier: 0x04}}
 ];
 
 runNextTest();
--- a/dom/icc/tests/marionette/test_stk_send_dtmf.js
+++ b/dom/icc/tests/marionette/test_stk_send_dtmf.js
@@ -2,178 +2,189 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_HEAD_JS = "stk_helper.js";
 
 function testSendDTMF(command, expect) {
   log("STK CMD " + JSON.stringify(command));
   is(command.typeOfCommand, iccManager.STK_CMD_SEND_DTMF, expect.name);
   is(command.commandQualifier, expect.commandQualifier, expect.name);
-  is(command.options.text, expect.text, expect.name);
+  if (command.options.text) {
+    is(command.options.text, expect.text, expect.name);
+  }
 
   runNextTest();
 }
 
 let tests = [
   {command: "d01b810301140082028183850953656e642044544d46ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_1_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_1",
             commandQualifier: 0x00,
             text: "Send DTMF"}},
-  {command: "d010810301140082028183ac052143658709",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_1_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d0138103011400820281838500ac06c1cccccccc2c",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_2_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_2",
             commandQualifier: 0x00,
             text: ""}},
-  {command: "d011810301140082028183ac06c1cccccccc2c",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_2_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d01d810301140082028183850a42617369632049636f6eac02c1f29e020001",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_3_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_3",
             commandQualifier: 0x00,
             text: "Basic Icon"}},
-  {command: "d011810301140082028183ac02c1f29e020001",
+  {command: "d01b810301140082028183850953656e642044544d46ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_3_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_dtmf_cmd_4",
+            commandQualifier: 0x00,
+            text: "Send DTMF"}},
   {command: "d01c810301140082028183850953656e642044544d46ac02c1f29e020101",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_4_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_5",
             commandQualifier: 0x00,
             text: "Send DTMF"}},
-  {command: "d011810301140082028183ac02c1f29e020101",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_4_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d028810301140082028183851980041704140420041004120421042204120423041904220415ac02c1f2",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_5_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_6",
             commandQualifier: 0x00,
             text: "ЗДРАВСТВУЙТЕ"}},
-  {command: "d00d810301140082028183ac02c1f2",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_5_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b00b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_6_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_7",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b00b4",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_6_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_7_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_8",
             commandQualifier: 0x00,
             text: "Send DTMF 2"}},
-  // send_dtmf_cmd_7_without_alpha_identifier has the same pdu as
-  // send_dtmf_cmd_1_without_alpha_identifier.
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b01b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_8_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_9",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b01b4",
+  {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_8_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_dtmf_cmd_10",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d00400b002b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_9_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_11",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d00400b002b4",
+  {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_9_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_dtmf_cmd_12",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b04b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_10_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_13",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b04b4",
-   func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_10_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_11_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_14",
             commandQualifier: 0x00,
             text: "Send DTMF 2"}},
-  // send_dtmf_cmd_11_without_alpha_identifier has the same pdu as
-  // send_dtmf_cmd_6_without_alpha_identifier.
   {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_12_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_15",
             commandQualifier: 0x00,
             text: "Send DTMF 3"}},
-  // send_dtmf_cmd_12_without_alpha_identifier has the same pdu as
-  // send_dtmf_cmd_1_without_alpha_identifier.
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b08b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_13_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_16",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b08b4",
+  {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_13_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_dtmf_cmd_17",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
+  {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_18",
+            commandQualifier: 0x00,
+            text: "Send DTMF 3"}},
   {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b10b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_14_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_19",
+            commandQualifier: 0x00,
+            text: "Send DTMF 1"}},
+  {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_20",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
+  {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_21",
+            commandQualifier: 0x00,
+            text: "Send DTMF 3"}},
+  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b20b4",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_22",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b10b4",
+  {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_23",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
+  {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_14_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b20b4",
+   expect: {name: "send_dtmf_cmd_24",
+            commandQualifier: 0x00,
+            text: "Send DTMF 3"}},
+  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b40b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_15_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_25",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b20b4",
+  {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_26",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
+  {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_15_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b40b4",
+   expect: {name: "send_dtmf_cmd_27",
+            commandQualifier: 0x00,
+            text: "Send DTMF 3"}},
+  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b80b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_16_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_28",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b40b4",
+  {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
+   func: testSendDTMF,
+   expect: {name: "send_dtmf_cmd_29",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
+  {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_16_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b80b4",
+   expect: {name: "send_dtmf_cmd_30",
+            commandQualifier: 0x00,
+            text: "Send DTMF 3"}},
+  {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b00b4",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_17_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_31",
             commandQualifier: 0x00,
             text: "Send DTMF 1"}},
-  {command: "d016810301140082028183ac052143658709d004000b80b4",
+  {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_17_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_dtmf_cmd_32",
+            commandQualifier: 0x00,
+            text: "Send DTMF 2"}},
   {command: "d0148103011400820281838505804f60597dac02c1f2",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_18_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_33",
             commandQualifier: 0x00,
             text: "你好"}},
-  // send_dtmf_cmd_18_without_alpha_identifier has the same pdu as
-  // send_dtmf_cmd_5_without_alpha_identifier.
   {command: "d01281030114008202818385038030ebac02c1f2",
    func: testSendDTMF,
-   expect: {name: "send_dtmf_cmd_19_with_alpha_identifier",
+   expect: {name: "send_dtmf_cmd_34",
             commandQualifier: 0x00,
             text: "ル"}}
-  // send_dtmf_cmd_19_without_alpha_identifier has the same pdu as
-  // send_dtmf_cmd_5_without_alpha_identifier.
 ];
 
 runNextTest();
--- a/dom/icc/tests/marionette/test_stk_send_sms.js
+++ b/dom/icc/tests/marionette/test_stk_send_sms.js
@@ -2,264 +2,239 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_HEAD_JS = "stk_helper.js";
 
 function testSendSMS(command, expect) {
   log("STK CMD " + JSON.stringify(command));
   is(command.typeOfCommand, iccManager.STK_CMD_SEND_SMS, expect.name);
   is(command.commandQualifier, expect.commandQualifier, expect.name);
-  is(command.options.text, expect.title, expect.name);
+  if (command.options.text) {
+    is(command.options.text, expect.title, expect.name);
+  }
 
   runNextTest();
 }
 
 let tests = [
   {command: "d037810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_1_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_1",
             commandQualifier: 0x00,
             title: "Send SM"}},
-  {command: "d02e81030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_1_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d032810301130182028183850753656e6420534d86099111223344556677f88b130100099110325476f840f40753656e6420534d",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_2_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_2",
             commandQualifier: 0x01,
             title: "Send SM"}},
-  {command: "d02981030113018202818386099111223344556677f88b130100099110325476f840f40753656e6420534d",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_2_without_alpha_identifier",
-            commandQualifier: 0x01}},
   {command: "d03d810301130082028183850d53686f7274204d65737361676586099111223344556677f88b180100099110325476f840f00d53f45b4e0735cbf379f85c06",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_3_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_3",
             commandQualifier: 0x00,
             title: "Short Message"}},
-  {command: "d02e81030113008202818386099111223344556677f88b180100099110325476f840f00d53f45b4e0735cbf379f85c06",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_3_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d081fd810301130182028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052501144657374696e6174696f6e114164647265737386099111223344556677f88b81ac0100099110325476f840f4a054776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e7370",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_4_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_4",
             commandQualifier: 0x01,
             title: "The address data object holds the RP_Destination_Address"}},
-  {command: "d081c381030113018202818386099111223344556677f88b81ac0100099110325476f840f4a054776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e7370",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_4_without_alpha_identifier",
-            commandQualifier: 0x01}},
   {command: "d081e9810301130082028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052502044657374696e6174696f6e204164647265737386099111223344556677f88b81980100099110325476f840f0a0d4fb1b44cfc3cb7350585e0691cbe6b4bb4cd6815aa020688e7ecbe9a076793e0f9fcb20fa1b242e83e665371d447f83e8e832c85da6dfdff23528ed0685dda06973da9a5685cd2415d42ecfe7e17399057acb41613768da9cb686cf6633e82482dae5f93c7c2eb3407774595e06d1d165507d5e9683c8617a18340ebb41e232081e9ecfcb64105d1e76cfe1",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_5_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_5",
             commandQualifier: 0x00,
             title: "The address data object holds the RP Destination Address"}},
-  {command: "d081af81030113008202818386099111223344556677f88b81980100099110325476f840f0a0d4fb1b44cfc3cb7350585e0691cbe6b4bb4cd6815aa020688e7ecbe9a076793e0f9fcb20fa1b242e83e665371d447f83e8e832c85da6dfdff23528ed0685dda06973da9a5685cd2415d42ecfe7e17399057acb41613768da9cb686cf6633e82482dae5f93c7c2eb3407774595e06d1d165507d5e9683c8617a18340ebb41e232081e9ecfcb64105d1e76cfe1",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_5_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d081fd8103011300820281838581e654776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e73706172656e746c793b202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954208b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_6_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_6",
             commandQualifier: 0x00,
             title: "Two types are defined: - A short message to be sent to the network in an SMS-SUBMIT message, or an SMS-COMMAND message, where the user data can be passed transparently; - A short message to be sent to the network in an SMS-SUBMIT "}},
-  {command: "d0148103011300820281838b09010002911040f00120",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_6_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d030810301130082028183850086099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_7_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_7",
             commandQualifier: 0x00,
             title: ""}},
-  // send_sms_cmd_7_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_1_without_alpha_identifier.
   {command: "d05581030113008202818385198004170414042004100412042104220412042304190422041586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_8_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_8",
             commandQualifier: 0x00,
             title: "ЗДРАВСТВУЙТЕ"}},
-  {command: "d03a81030113008202818386099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_8_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d04b810301130082028183850f810c089794a09092a1a292a399a29586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_9_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_9",
             commandQualifier: 0x00,
             title: "ЗДРАВСТВУЙТЕ"}},
-  // send_sms_cmd_9_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_8_without_alpha_identifier.
+  {command: "d04c8103011300820281838510820c041087849080829192829389928586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_9",
+            commandQualifier: 0x00,
+            title: "ЗДРАВСТВУЙТЕ"}},
   {command: "d03b81030113008202818385074e4f2049434f4e86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167659e020001",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_10_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_10",
             commandQualifier: 0x00,
             title: "NO ICON"}},
-  {command: "d03281030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d6573736167659e020001",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_10_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d03b810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167651e020101",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_11_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_11",
             commandQualifier: 0x00,
             title: "Send SM"}},
-  {command: "d03281030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d6573736167651e020101",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_11_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001000b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_12_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_12",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001000b4",
+  {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_12_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_sms_cmd_13",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001001b4",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_14",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
   {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_13_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_15",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001002b4",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_16",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_17",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_sms_cmd_18_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_6_without_alpha_identifier.
-  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001001b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001004b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_14_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_18",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001001b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_19",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_14_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001002b4",
+   expect: {name: "send_sms_cmd_20",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001008b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_15_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_21",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001002b4",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_15_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001004b4",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_16_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001004b4",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_16_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_17_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_22",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_sms_cmd_17_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_12_without_alpha_identifier.
   {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_18_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_23",
             commandQualifier: 0x00,
             title: "Text Attribute 3"}},
-  // send_sms_cmd_18_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_6_without_alpha_identifier.
-  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001008b4",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_19_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001008b4",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_19_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001010b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_20_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_24",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001010b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_20_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_sms_cmd_25",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_26",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001020b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_21_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_27",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001020b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_21_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_sms_cmd_28",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_29",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001040b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_22_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_30",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001040b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_22_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_sms_cmd_31",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_32",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001080b4",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_23_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_33",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d01a8103011300820281838b09010002911040f00120d004001080b4",
+  {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_34",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_23_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_sms_cmd_35",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001000b4",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_36",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
+   func: testSendSMS,
+   expect: {name: "send_sms_cmd_37",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
   {command: "d02d8103011300820281838505804e2d4e0086099111223344556677f88b100100099110325476f84008044e2d4e00",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_24_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_38",
             commandQualifier: 0x00,
             title: "中一"}},
-  {command: "d02681030113008202818386099111223344556677f88b100100099110325476f84008044e2d4e00",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_24_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02d810301130082028183850581029cad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_25_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_39",
             commandQualifier: 0x00,
             title: "中一"}},
-  // send_sms_cmd_25_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_24_without_alpha_identifier.
   {command: "d02e810301130082028183850682024e00ad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_26_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_40",
             commandQualifier: 0x00,
             title: "中一"}},
-  // send_sms_cmd_26_without_alpha_identifier has the same pdu as
-  // send_sms_cmd_24_without_alpha_identifier.
   {command: "d0358103011300820281838509800038003030eb003086099111223344556677f88b140100099110325476f84008080038003030eb0031",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_27_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_41",
             commandQualifier: 0x00,
             title: "80ル0"}},
-  {command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0031",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_27_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d03381030113008202818385078104613831eb3186099111223344556677f88b140100099110325476f84008080038003030eb0032",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_28_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_42",
             commandQualifier: 0x00,
             title: "81ル1"}},
-  {command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0032",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_28_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d0348103011300820281838508820430a03832cb3286099111223344556677f88b140100099110325476f84008080038003030eb0033",
    func: testSendSMS,
-   expect: {name: "send_sms_cmd_29_with_alpha_identifier",
+   expect: {name: "send_sms_cmd_43",
             commandQualifier: 0x00,
-            title: "82ル2"}},
-  {command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0033",
-   func: testSendSMS,
-   expect: {name: "send_sms_cmd_29_without_alpha_identifier",
-            commandQualifier: 0x00}}
+            title: "82ル2"}}
 ];
 
 runNextTest();
--- a/dom/icc/tests/marionette/test_stk_send_ss.js
+++ b/dom/icc/tests/marionette/test_stk_send_ss.js
@@ -2,201 +2,199 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_HEAD_JS = "stk_helper.js";
 
 function testSendSS(command, expect) {
   log("STK CMD " + JSON.stringify(command));
   is(command.typeOfCommand, iccManager.STK_CMD_SEND_SS, expect.name);
   is(command.commandQualifier, expect.commandQualifier, expect.name);
-  is(command.options.text, expect.title, expect.name);
+  if (command.options.text) {
+    is(command.options.text, expect.title, expect.name);
+  }
 
   runNextTest();
 }
 
 let tests = [
   {command: "d029810301110082028183850c43616c6c20466f7277617264891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_1_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_1",
             commandQualifier: 0x00,
             title: "Call Forward"}},
-  {command: "d01b810301110082028183891091aa120a214365870921436587a901fb",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_1_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02d810301110082028183850c43616c6c20466f7277617264891491aa120a21436587092143658709214365a711fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_2_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_2",
             commandQualifier: 0x00,
             title: "Call Forward"}},
-  {command: "d01f810301110082028183891491aa120a21436587092143658709214365a711fb",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_2_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d081fd8103011100820281838581eb4576656e20696620746865204669786564204469616c6c696e67204e756d626572207365727669636520697320656e61626c65642c2074686520737570706c656d656e74617279207365727669636520636f6e74726f6c20737472696e6720696e636c7564656420696e207468652053454e442053532070726f61637469766520636f6d6d616e64207368616c6c206e6f7420626520636865636b656420616761696e73742074686f7365206f66207468652046444e206c6973742e2055706f6e20726563656976696e67207468697320636f6d6d616e642c20746865204d45207368616c6c20646563698904ffba13fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_3_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_3",
             commandQualifier: 0x00,
             title: "Even if the Fixed Dialling Number service is enabled, the supplementary service control string included in the SEND SS proactive command shall not be checked against those of the FDN list. Upon receiving this command, the ME shall deci"}},
-  {command: "d00f8103011100820281838904ffba13fb",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_3_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d01d8103011100820281838500891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_4_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_4",
             commandQualifier: 0x00,
             title: ""}},
-  // send_ss_cmd_4_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
   {command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020001",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_5_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_5",
             commandQualifier: 0x00,
             title: "Basic Icon"}},
-  {command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020001",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_5_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02c810301110082028183850b436f6c6f75722049636f6e891091aa120a214365870921436587a901fb9e020002",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_6_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_6",
             commandQualifier: 0x00,
             title: "Colour Icon"}},
-  {command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020002",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_6_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020101",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_7_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_7",
             commandQualifier: 0x00,
             title: "Basic Icon"}},
-  {command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020101",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_7_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d036810301110082028183851980041704140420041004120421042204120423041904220415891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_8_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_8",
             commandQualifier: 0x00,
             title: "ЗДРАВСТВУЙТЕ"}},
-  // send_ss_cmd_8_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
   {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_9_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_9",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_10",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001001b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_11",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001000b4",
+  {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_9_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ss_cmd_12",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001002b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_13",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
   {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_10_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_14",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_ss_cmd_10_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
-  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001001b4",
+  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001004b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_15",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_11_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_16",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_17",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001008b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_18",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001001b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_11_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001002b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_12_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001002b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_12_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001004b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_13_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001004b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_13_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_14_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_19",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_ss_cmd_14_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_9_without_alpha_identifier.
   {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_15_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_20",
             commandQualifier: 0x00,
             title: "Text Attribute 3"}},
-  // send_ss_cmd_15_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
-  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001008b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_16_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001008b4",
-   func: testSendSS,
-   expect: {name: "send_ss_cmd_16_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001010b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_17_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_21",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001010b4",
+  {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_17_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ss_cmd_22",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_23",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001020b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_18_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_24",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001020b4",
+  {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_18_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ss_cmd_25",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_26",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001040b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_19_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_27",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001040b4",
+  {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_19_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ss_cmd_28",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_29",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001080b4",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_20_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_30",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001080b4",
+  {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_31",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_20_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ss_cmd_32",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001000b4",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_33",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
+   func: testSendSS,
+   expect: {name: "send_ss_cmd_34",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
   {command: "d0228103011100820281838505804f60597d891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_21_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_35",
             commandQualifier: 0x00,
             title: "你好"}},
-  // send_ss_cmd_21_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
   {command: "d02081030111008202818385038030eb891091aa120a214365870921436587a901fb",
    func: testSendSS,
-   expect: {name: "send_ss_cmd_22_with_alpha_identifier",
+   expect: {name: "send_ss_cmd_36",
             commandQualifier: 0x00,
-            title: "ル"}},
-  // send_ss_cmd_22_without_alpha_identifier has the same pdu as
-  // send_ss_cmd_1_without_alpha_identifier.
+            title: "ル"}}
 ];
 
 runNextTest();
--- a/dom/icc/tests/marionette/test_stk_send_ussd.js
+++ b/dom/icc/tests/marionette/test_stk_send_ussd.js
@@ -2,208 +2,204 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_HEAD_JS = "stk_helper.js";
 
 function testSendUSSD(command, expect) {
   log("STK CMD " + JSON.stringify(command));
   is(command.typeOfCommand, iccManager.STK_CMD_SEND_USSD, expect.name);
   is(command.commandQualifier, expect.commandQualifier, expect.name);
-  is(command.options.text, expect.title, expect.name);
+  if (command.options.text) {
+    is(command.options.text, expect.title, expect.name);
+  }
 
   runNextTest();
 }
 
 let tests = [
   {command: "d050810301120082028183850a372d62697420555353448a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_1_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_1",
             commandQualifier: 0x00,
             title: "7-bit USSD"}},
-  {command: "d0448103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_1_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d058810301120082028183850a382d62697420555353448a41444142434445464748494a4b4c4d4e4f505152535455565758595a2d6162636465666768696a6b6c6d6e6f707172737475767778797a2d31323334353637383930",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_2_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_2",
             commandQualifier: 0x00,
             title: "8-bit USSD"}},
-  {command: "d04c8103011200820281838a41444142434445464748494a4b4c4d4e4f505152535455565758595a2d6162636465666768696a6b6c6d6e6f707172737475767778797a2d31323334353637383930",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_2_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d02f81030112008202818385095543533220555353448a1948041704140420041004120421042204120423041904220415",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_3_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_3",
             commandQualifier: 0x00,
             title: "UCS2 USSD"}},
-  {command: "d0248103011200820281838a1948041704140420041004120421042204120423041904220415",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_3_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d081fd8103011200820281838581b66f6e636520612052454c4541534520434f4d504c455445206d65737361676520636f6e7461696e696e672074686520555353442052657475726e20526573756c74206d657373616765206e6f7420636f6e7461696e696e6720616e206572726f7220686173206265656e2072656365697665642066726f6d20746865206e6574776f726b2c20746865204d45207368616c6c20696e666f726d207468652053494d20746861742074686520636f6d6d616e64206861738a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_4_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_4",
             commandQualifier: 0x00,
             title: "once a RELEASE COMPLETE message containing the USSD Return Result message not containing an error has been received from the network, the ME shall inform the SIM that the command has"}},
-  // send_ussd_cmd_4_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
   {command: "d04681030112008202818385008a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_5_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_5",
          commandQualifier: 0x00,
          title: ""}},
-  // send_ussd_cmd_5_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
   {command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020001",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_6_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_6",
+            commandQualifier: 0x00,
+            title: "Basic Icon"}},
+  {command: "d054810301120082028183850a436f6c6f722049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020002",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_7",
+            commandQualifier: 0x00,
+            title: "Color Icon"}},
+  {command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_8",
             commandQualifier: 0x00,
             title: "Basic Icon"}},
-  {command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020001",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_6_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d054810301120082028183850a436f6c6f722049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020002",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_7_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Color Icon"}},
-  {command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020002",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_7_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_8_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Basic Icon"}},
-  {command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_8_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d05f8103011200820281838519800417041404200410041204210422041204230419042204158a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_9_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_9",
             commandQualifier: 0x00,
             title: "ЗДРАВСТВУЙТЕ"}},
-  // send_ussd_cmd_9_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
   {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_10_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_10",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_11",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_12",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_10_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_11_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_13",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_ussd_cmd_11_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
-  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_14",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_12_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_15",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_16",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_12_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_13_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_17",
             commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
+            title: "Text Attribute 2"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_13_without_alpha_identifier",
-            commandQualifier: 0x00}},
-  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
+   expect: {name: "send_ussd_cmd_18",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_14_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_19",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_14_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_15_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_20",
             commandQualifier: 0x00,
             title: "Text Attribute 2"}},
-  // send_ussd_cmd_15_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_10_with_alpha_identifier.
   {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_16_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_21",
             commandQualifier: 0x00,
             title: "Text Attribute 3"}},
-  // send_ussd_cmd_16_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
-  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_17_with_alpha_identifier",
-            commandQualifier: 0x00,
-            title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
-   func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_17_without_alpha_identifier",
-            commandQualifier: 0x00}},
   {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001010b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_18_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_22",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001010b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_18_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ussd_cmd_23",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_24",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001020b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_19_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_25",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001020b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_19_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ussd_cmd_26",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_27",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001040b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_20_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_28",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001040b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_20_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ussd_cmd_29",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_30",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
   {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001080b4",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_21_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_31",
             commandQualifier: 0x00,
             title: "Text Attribute 1"}},
-  {command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001080b4",
+  {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_32",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_21_without_alpha_identifier",
-            commandQualifier: 0x00}},
+   expect: {name: "send_ussd_cmd_33",
+            commandQualifier: 0x00,
+            title: "Text Attribute 3"}},
+  {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_34",
+            commandQualifier: 0x00,
+            title: "Text Attribute 1"}},
+  {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
+   func: testSendUSSD,
+   expect: {name: "send_ussd_cmd_35",
+            commandQualifier: 0x00,
+            title: "Text Attribute 2"}},
   {command: "d04b8103011200820281838505804f60597d8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_22_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_36",
             commandQualifier: 0x00,
             title: "你好"}},
-  // send_ussd_cmd_22_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
   {command: "d04981030112008202818385038030eb8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
    func: testSendUSSD,
-   expect: {name: "send_ussd_cmd_23_with_alpha_identifier",
+   expect: {name: "send_ussd_cmd_37",
             commandQualifier: 0x00,
-            title: "ル"}},
-  // send_ussd_cmd_23_without_alpha_identifier has the same pdu as
-  // send_ussd_cmd_1_without_alpha_identifier.
+            title: "ル"}}
 ];
 
 runNextTest();
--- a/dom/inputmethod/Keyboard.jsm
+++ b/dom/inputmethod/Keyboard.jsm
@@ -15,20 +15,18 @@ Cu.import("resource://gre/modules/XPCOMU
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
   "@mozilla.org/parentprocessmessagemanager;1", "nsIMessageBroadcaster");
 
 XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
                                   "resource://gre/modules/SystemAppProxy.jsm");
 
 this.Keyboard = {
-  _formMM: null,      // The current web page message manager.
-  _keyboardMM: null,  // The keyboard app message manager.
-  _keyboardID: -1,    // The keyboard app's ID number. -1 = invalid
-  _nextKeyboardID: 0, // The ID number counter.
+  _formMM: null,     // The current web page message manager.
+  _keyboardMM: null, // The keyboard app message manager.
   _systemMessageName: [
     'SetValue', 'RemoveFocus', 'SetSelectedOption', 'SetSelectedOptions'
   ],
 
   _messageNames: [
     'RemoveFocus',
     'SetSelectionRange', 'ReplaceSurroundingText', 'ShowInputMethodPicker',
     'SwitchToNextInputMethod', 'HideInputMethod',
@@ -146,30 +144,16 @@ this.Keyboard = {
       if (!isKeyboardRegistration && !testing &&
           !mm.assertPermission(perm)) {
         dump("Keyboard message " + msg.name +
         " from a content process with no '" + perm + "' privileges.");
         return;
       }
     }
 
-    // we don't process kb messages (other than register)
-    // if they come from a kb that we're currently not regsitered for.
-    // this decision is made with the kbID kept by us and kb app
-    let kbID = null;
-    if ('kbID' in msg.data) {
-      kbID = msg.data.kbID;
-    }
-
-    if (0 === msg.name.indexOf('Keyboard:') &&
-        ('Keyboard:Register' !== msg.name && this._keyboardID !== kbID)
-       ) {
-      return;
-    }
-
     switch (msg.name) {
       case 'Forms:Input':
         this.handleFocusChange(msg);
         break;
       case 'Forms:SelectionChange':
       case 'Forms:GetText:Result:OK':
       case 'Forms:GetText:Result:Error':
       case 'Forms:SetSelectionRange:Result:OK':
@@ -223,32 +207,19 @@ this.Keyboard = {
       case 'Keyboard:SetComposition':
         this.setComposition(msg);
         break;
       case 'Keyboard:EndComposition':
         this.endComposition(msg);
         break;
       case 'Keyboard:Register':
         this._keyboardMM = mm;
-        if (kbID !== null) {
-          // keyboard identifies itself, use its kbID
-          // this msg would be async, so no need to return
-          this._keyboardID = kbID;
-        }else{
-          // generate the id for the keyboard
-          this._keyboardID = this._nextKeyboardID;
-          this._nextKeyboardID++;
-          // this msg is sync,
-          // and we want to return the id back to inputmethod
-          return this._keyboardID;
-        }
         break;
       case 'Keyboard:Unregister':
         this._keyboardMM = null;
-        this._keyboardID = -1;
         break;
     }
   },
 
   forwardEvent: function keyboardForwardEvent(newEventName, msg) {
     this.formMM = msg.target.QueryInterface(Ci.nsIFrameLoaderOwner)
                             .frameLoader.messageManager;
 
--- a/dom/inputmethod/MozKeyboard.js
+++ b/dom/inputmethod/MozKeyboard.js
@@ -8,98 +8,52 @@ const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-  "@mozilla.org/childprocessmessagemanager;1", "nsISyncMessageSender");
+  "@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender");
 
 XPCOMUtils.defineLazyServiceGetter(this, "tm",
   "@mozilla.org/thread-manager;1", "nsIThreadManager");
 
 /*
- * A WeakMap to map input method iframe window to its active status and kbID.
+ * A WeakMap to map input method iframe window to its active status.
  */
 let WindowMap = {
-  // WeakMap of <window, object> pairs.
+  // WeakMap of <window, boolean> pairs.
   _map: null,
 
   /*
    * Check if the given window is active.
    */
   isActive: function(win) {
     if (!this._map || !win) {
       return false;
     }
-
-    let obj = this._map.get(win);
-    if (obj && 'active' in obj) {
-      return obj.active;
-    }else{
-      return false;
-    }
+    return this._map.get(win) || false;
   },
 
   /*
    * Set the active status of the given window.
    */
   setActive: function(win, isActive) {
     if (!win) {
       return;
     }
     if (!this._map) {
       this._map = new WeakMap();
     }
-    if (!this._map.has(win)) {
-      this._map.set(win, {});
-    }
-    this._map.get(win).active = isActive;
-  },
-
-  /*
-   * Get the keyboard ID (assigned by Keyboard.ksm) of the given window.
-   */
-  getKbID: function(win) {
-    if (!this._map || !win) {
-      return null;
-    }
-
-    let obj = this._map.get(win);
-    if (obj && 'kbID' in obj) {
-      return obj.kbID;
-    }else{
-      return null;
-    }
-  },
-
-  /*
-   * Set the keyboard ID (assigned by Keyboard.ksm) of the given window.
-   */
-  setKbID: function(win, kbID) {
-    if (!win) {
-      return;
-    }
-    if (!this._map) {
-      this._map = new WeakMap();
-    }
-    if (!this._map.has(win)) {
-      this._map.set(win, {});
-    }
-    this._map.get(win).kbID = kbID;
+    this._map.set(win, isActive);
   }
 };
 
-let cpmmSendAsyncMessageWithKbID = function (self, msg, data) {
-  data.kbID = WindowMap.getKbID(self._window);
-  cpmm.sendAsyncMessage(msg, data);
-};
-
 /**
  * ==============================================
  * InputMethodManager
  * ==============================================
  */
 function MozInputMethodManager(win) {
   this._window = win;
 }
@@ -111,38 +65,38 @@ MozInputMethodManager.prototype = {
   classID: Components.ID("{7e9d7280-ef86-11e2-b778-0800200c9a66}"),
 
   QueryInterface: XPCOMUtils.generateQI([]),
 
   showAll: function() {
     if (!WindowMap.isActive(this._window)) {
       return;
     }
-    cpmmSendAsyncMessageWithKbID(this, 'Keyboard:ShowInputMethodPicker', {});
+    cpmm.sendAsyncMessage('Keyboard:ShowInputMethodPicker', {});
   },
 
   next: function() {
     if (!WindowMap.isActive(this._window)) {
       return;
     }
-    cpmmSendAsyncMessageWithKbID(this, 'Keyboard:SwitchToNextInputMethod', {});
+    cpmm.sendAsyncMessage('Keyboard:SwitchToNextInputMethod', {});
   },
 
   supportsSwitching: function() {
     if (!WindowMap.isActive(this._window)) {
       return false;
     }
     return this._supportsSwitching;
   },
 
   hide: function() {
     if (!WindowMap.isActive(this._window)) {
       return;
     }
-    cpmmSendAsyncMessageWithKbID(this, 'Keyboard:RemoveFocus', {});
+    cpmm.sendAsyncMessage('Keyboard:RemoveFocus', {});
   }
 };
 
 /**
  * ==============================================
  * InputMethod
  * ==============================================
  */
@@ -302,33 +256,21 @@ MozInputMethod.prototype = {
 
     WindowMap.setActive(this._window, isActive);
 
     if (isActive) {
       // Activate current input method.
       // If there is already an active context, then this will trigger
       // a GetContext:Result:OK event, and we can initialize ourselves.
       // Otherwise silently ignored.
-
-      // get keyboard ID from Keyboard.jsm,
-      // or if we already have it, get it from our map
-      // Note: if we need to get it from Keyboard.jsm,
-      // we have to use a synchronous message
-      var kbID = WindowMap.getKbID(this._window);
-      if (kbID !== null) {
-        cpmmSendAsyncMessageWithKbID(this, 'Keyboard:Register', {});
-      }else{
-        let res = cpmm.sendSyncMessage('Keyboard:Register', {});
-        WindowMap.setKbID(this._window, res[0]);
-      }
-
-      cpmmSendAsyncMessageWithKbID(this, 'Keyboard:GetContext', {});
+      cpmm.sendAsyncMessage('Keyboard:Register', {});
+      cpmm.sendAsyncMessage("Keyboard:GetContext", {});
     } else {
       // Deactive current input method.
-      cpmmSendAsyncMessageWithKbID(this, 'Keyboard:Unregister', {});
+      cpmm.sendAsyncMessage('Keyboard:Unregister', {});
       if (this._inputcontext) {
         this.setInputContext(null);
       }
     }
   },
 
   setValue: function(value) {
     this._ensureIsSystem();
@@ -542,17 +484,17 @@ MozInputContext.prototype = {
 
   get lang() {
     return this._context.lang;
   },
 
   getText: function ic_getText(offset, length) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:GetText', {
+      cpmm.sendAsyncMessage('Keyboard:GetText', {
         contextId: self._contextId,
         requestId: resolverId,
         offset: offset,
         length: length
       });
     });
   },
 
@@ -570,17 +512,17 @@ MozInputContext.prototype = {
 
   get textAfterCursor() {
     return this._context.textAfterCursor;
   },
 
   setSelectionRange: function ic_setSelectionRange(start, length) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:SetSelectionRange', {
+      cpmm.sendAsyncMessage("Keyboard:SetSelectionRange", {
         contextId: self._contextId,
         requestId: resolverId,
         selectionStart: start,
         selectionEnd: start + length
       });
     });
   },
 
@@ -598,61 +540,61 @@ MozInputContext.prototype = {
 
   set onselectionchange(handler) {
     this.__DOM_IMPL__.setEventHandler("onselectionchange", handler);
   },
 
   replaceSurroundingText: function ic_replaceSurrText(text, offset, length) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:ReplaceSurroundingText', {
+      cpmm.sendAsyncMessage('Keyboard:ReplaceSurroundingText', {
         contextId: self._contextId,
         requestId: resolverId,
         text: text,
         offset: offset || 0,
         length: length || 0
       });
     });
   },
 
   deleteSurroundingText: function ic_deleteSurrText(offset, length) {
     return this.replaceSurroundingText(null, offset, length);
   },
 
   sendKey: function ic_sendKey(keyCode, charCode, modifiers, repeat) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:SendKey', {
+      cpmm.sendAsyncMessage('Keyboard:SendKey', {
         contextId: self._contextId,
         requestId: resolverId,
         keyCode: keyCode,
         charCode: charCode,
         modifiers: modifiers,
         repeat: repeat
       });
     });
   },
 
   setComposition: function ic_setComposition(text, cursor, clauses) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:SetComposition', {
+      cpmm.sendAsyncMessage('Keyboard:SetComposition', {
         contextId: self._contextId,
         requestId: resolverId,
         text: text,
         cursor: cursor || text.length,
         clauses: clauses || null
       });
     });
   },
 
   endComposition: function ic_endComposition(text) {
     let self = this;
     return this._sendPromise(function(resolverId) {
-      cpmmSendAsyncMessageWithKbID(self, 'Keyboard:EndComposition', {
+      cpmm.sendAsyncMessage('Keyboard:EndComposition', {
         contextId: self._contextId,
         requestId: resolverId,
         text: text || ''
       });
     });
   },
 
   _sendPromise: function(callback) {
deleted file mode 100644
--- a/dom/inputmethod/mochitest/file_inputmethod_1043828.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<html>
-<body>
-</body>
-</html>
--- a/dom/inputmethod/mochitest/mochitest.ini
+++ b/dom/inputmethod/mochitest/mochitest.ini
@@ -1,20 +1,18 @@
 [DEFAULT]
 # Not supported on Android, bug 983015 for B2G emulator
 skip-if = (toolkit == 'android' || toolkit == 'gonk') || e10s
 support-files =
   inputmethod_common.js
   file_inputmethod.html
-  file_inputmethod_1043828.html
   file_test_app.html
   file_test_sendkey_cancel.html
   file_test_sms_app.html
 
 [test_basic.html]
 [test_bug944397.html]
 [test_bug949059.html]
 [test_bug953044.html]
 [test_bug960946.html]
 [test_bug978918.html]
-[test_bug1043828.html]
 [test_delete_focused_element.html]
 [test_sendkey_cancel.html]
deleted file mode 100644
--- a/dom/inputmethod/mochitest/test_bug1043828.html
+++ /dev/null
@@ -1,183 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1043828
--->
-<head>
-  <title>Basic test for Switching Keyboards.</title>
-  <script type="application/javascript;version=1.7" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript;version=1.7" src="inputmethod_common.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1043828">Mozilla Bug 1043828</a>
-<p id="display"></p>
-<pre id="test">
-<script class="testbody" type="application/javascript;version=1.7">
-
-inputmethod_setup(function() {
-  runTest();
-});
-
-// The KB frame script running in Keyboard B.
-function kbFrameScript() {
-  function tryGetText() {
-    var ctx = content.navigator.mozInputMethod.inputcontext;
-    if (ctx) {
-      var p = ctx.getText();
-      p.then(function(){
-        sendAsyncMessage('test:InputMethod:getText:Resolve');
-      }, function(e){
-        sendAsyncMessage('test:InputMethod:getText:Reject');
-      });
-    }else{
-      dump("Could not get inputcontext") ;
-    }
-  }
-
-  addMessageListener('test:InputMethod:getText:Do', function(){
-    tryGetText();
-  });
-}
-
-function runTest() {
-  let app, keyboardA, keyboardB;
-  let getTextPromise;
-  let mmKeyboardA, mmKeyboardB;
-
-  /**
-   * Test flow:
-   * 1. Create two keyboard iframes & a mozbrowser iframe with a text field in it & focus the text
-   *    field.
-   * 2. Set keyboard frame A as active input. Wait 200ms.
-   * 3. Set keyboard frame B as active input. Wait 200ms.
-   * 4. Set keyboard frame A as inactive. Wait 200ms.
-   * 5. Allow frame b to use getText() with inputcontext to get the content from the text field
-   *    iframe. Wait 200ms.
-   * [Test would succeed if the Promise returned by getText() resolves correctly.
-   *  Test would fail if otherwise]
-   */
-
-  let path = location.pathname;
-  let basePath = location.protocol + '//' + location.host +
-               path.substring(0, path.lastIndexOf('/'));
-
-  const WAIT_TIME = 200;
-
-  // STEP 1: Create the frames.
-  function step1() {
-    // app
-    app = document.createElement('iframe');
-    app.src = basePath + '/file_test_app.html';
-    app.setAttribute('mozbrowser', true);
-    document.body.appendChild(app);
-
-    // keyboards
-    keyboardA = document.createElement('iframe');
-    keyboardA.setAttribute('mozbrowser', true);
-    document.body.appendChild(keyboardA);
-
-    keyboardB = document.createElement('iframe');
-    keyboardB.setAttribute('mozbrowser', true);
-    document.body.appendChild(keyboardB);
-
-    // simulate two different keyboard apps
-    let imeUrl = basePath + '/file_inputmethod_1043828.html';
-
-    SpecialPowers.pushPermissions([{
-      type: 'input',
-      allow: true,
-      context: imeUrl
-    }], function() {
-      keyboardA.src = imeUrl;
-      keyboardB.src = imeUrl;
-
-      var handler = {
-        handleEvent: function(){
-          keyboardB.removeEventListener('mozbrowserloadend', this);
-
-          mmKeyboardB = SpecialPowers.getBrowserFrameMessageManager(keyboardB);
-
-          mmKeyboardB.loadFrameScript('data:,(' + kbFrameScript.toString() + ')();', false);
-
-          mmKeyboardB.addMessageListener('test:InputMethod:getText:Resolve', function() {
-            ok(true, 'getText() was resolved');
-            inputmethod_cleanup();
-          });
-
-          mmKeyboardB.addMessageListener('test:InputMethod:getText:Reject', function() {
-            ok(false, 'getText() was rejected');
-            inputmethod_cleanup();
-          });
-
-          setTimeout(function(){
-            step2();
-          }, WAIT_TIME);
-        }
-      };
-
-      keyboardB.addEventListener('mozbrowserloadend', handler);
-    });
-  }
-
-  // STEP 2: Set keyboard A active
-  function step2() {
-    let req = keyboardA.setInputMethodActive(true);
-
-    req.onsuccess = function(){
-      setTimeout(function(){
-        step3();
-      }, WAIT_TIME);
-    };
-
-    req.onerror = function(){
-      ok(false, 'setInputMethodActive failed: ' + this.error.name);
-      inputmethod_cleanup();
-    };
-  }
-
-  // STEP 3: Set keyboard B active
-  function step3() {
-    let req = keyboardB.setInputMethodActive(true);
-
-    req.onsuccess = function(){
-      setTimeout(function(){
-        step4();
-      }, WAIT_TIME);
-    };
-
-    req.onerror = function(){
-      ok(false, 'setInputMethodActive failed: ' + this.error.name);
-      inputmethod_cleanup();
-    };
-  }
-
-  // STEP 4: Set keyboard A inactive
-  function step4() {
-    let req = keyboardA.setInputMethodActive(false);
-
-    req.onsuccess = function(){
-      setTimeout(function(){
-        step5();
-      }, WAIT_TIME);
-    };
-
-    req.onerror = function(){
-      ok(false, 'setInputMethodActive failed: ' + this.error.name);
-      inputmethod_cleanup();
-    };
-  }
-
-  // STEP 5: getText
-  function step5() {
-    mmKeyboardB.sendAsyncMessage('test:InputMethod:getText:Do');
-  }
-
-  step1();
-}
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/mobileconnection/tests/marionette/manifest.ini
+++ b/dom/mobileconnection/tests/marionette/manifest.ini
@@ -2,17 +2,16 @@
 b2g = true
 browser = false
 qemu = true
 
 [test_mobile_networks.js]
 [test_mobile_voice_state.js]
 [test_mobile_voice_location.js]
 [test_mobile_operator_names.js]
-disabled = 1088504
 [test_mobile_operator_names_plmnlist.js]
 [test_mobile_operator_names_roaming.js]
 [test_mobile_preferred_network_type.js]
 [test_mobile_preferred_network_type_radio_off.js]
 [test_mobile_data_connection.js]
 [test_mobile_data_location.js]
 [test_mobile_data_state.js]
 [test_mobile_mmi.js]
--- a/dom/mobileconnection/tests/marionette/test_mobile_networks.js
+++ b/dom/mobileconnection/tests/marionette/test_mobile_networks.js
@@ -2,23 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // getNetworks() can take some time..
 MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = "head.js";
 
 function isHomeNetwork(network) {
   is(network.longName, "Android");
-  // Connection info contains empty short name due to CPHS ONSF, otherwise,
-  // Android is expected.
-  if (network.shortName) {
-    is(network.shortName, "Android");
-  } else {
-    is(network.shortName, "");
-  }
+  is(network.shortName, "Android");
   is(network.mcc, "310");
   is(network.mnc, "260");
 }
 
 function isRoamingNetwork(network) {
   is(network.longName, "TelKila");
   is(network.shortName, "TelKila");
   is(network.mcc, "310");
--- a/dom/mobileconnection/tests/marionette/test_mobile_operator_names_plmnlist.js
+++ b/dom/mobileconnection/tests/marionette/test_mobile_operator_names_plmnlist.js
@@ -66,59 +66,48 @@ startTestCommon(function() {
       // will be triggered.
       isnot(TEST_CELL_ID, cid, "A different test cell id than used currently.");
 
       // In following tests, we use different longName/shortName to ensure
       // network name is always re-calculated in RIL worker.
       return Promise.resolve()
 
         // If MCC/MNC doesn't match any, report given home network name.
-        .then(() => test("Foo1", "Bar1", "123", "456", 0x0000, TEST_CELL_ID,
-                         "Android", ""))
-        .then(() => test("Foo2", "Bar2", "123", "456", 0x0001, TEST_CELL_ID,
-                         "Android", ""))
-        .then(() => test("Foo3", "Bar3", "123", "456", 0x0002, TEST_CELL_ID,
-                         "Android", ""))
-        .then(() => test("Foo4", "Bar4", "123", "456", 0x0010, TEST_CELL_ID,
-                         "Android", ""))
-        .then(() => test("Foo5", "Bar5", "123", "456", 0x0011, TEST_CELL_ID,
-                         "Android", ""))
-        .then(() => test("Foo6", "Bar6", "123", "456", 0xFFFE, TEST_CELL_ID,
-                         "Android", ""))
+        .then(() => test("Foo1", "Bar1", "123", "456", 0x0000, TEST_CELL_ID))
+        .then(() => test("Foo2", "Bar2", "123", "456", 0x0001, TEST_CELL_ID))
+        .then(() => test("Foo3", "Bar3", "123", "456", 0x0002, TEST_CELL_ID))
+        .then(() => test("Foo4", "Bar4", "123", "456", 0x0010, TEST_CELL_ID))
+        .then(() => test("Foo5", "Bar5", "123", "456", 0x0011, TEST_CELL_ID))
+        .then(() => test("Foo6", "Bar6", "123", "456", 0xFFFE, TEST_CELL_ID))
 
         // Full ranged network.  Report network name from PNN.
         .then(() => test("Foo1", "Bar1", "001", "01", 0x0000, TEST_CELL_ID,
                          "Test1", "Test1"))
         .then(() => test("Foo2", "Bar2", "001", "01", 0x0001, TEST_CELL_ID,
                          "Test1", "Test1"))
         .then(() => test("Foo3", "Bar3", "001", "01", 0xFFFE, TEST_CELL_ID,
                          "Test1", "Test1"))
 
         // Ranged network.  Report network name from PNN if lac is inside the
         // inclusive range 0x01..0x10.
-        .then(() => test("Foo1", "Bar1", "001", "02", 0x0000, TEST_CELL_ID,
-                         "Android", ""))
+        .then(() => test("Foo1", "Bar1", "001", "02", 0x0000, TEST_CELL_ID))
         .then(() => test("Foo2", "Bar2", "001", "02", 0x0001, TEST_CELL_ID,
                          "Test2", ""))
         .then(() => test("Foo3", "Bar3", "001", "02", 0x0002, TEST_CELL_ID,
                          "Test2", ""))
         .then(() => test("Foo4", "Bar4", "001", "02", 0x0010, TEST_CELL_ID,
                          "Test2", ""))
-        .then(() => test("Foo5", "Bar5", "001", "02", 0xFFFE, TEST_CELL_ID,
-                         "Android", ""))
+        .then(() => test("Foo5", "Bar5", "001", "02", 0xFFFE, TEST_CELL_ID))
 
         // Single entry network.  Report network name from PNN if lac matches.
-        .then(() => test("Foo1", "Bar1", "001", "03", 0x0000, TEST_CELL_ID,
-                         "Android", ""))
+        .then(() => test("Foo1", "Bar1", "001", "03", 0x0000, TEST_CELL_ID))
         .then(() => test("Foo2", "Bar2", "001", "03", 0x0011, TEST_CELL_ID,
                          "Test3", ""))
-        .then(() => test("Foo3", "Bar3", "001", "03", 0xFFFE, TEST_CELL_ID,
-                         "Android", ""))
+        .then(() => test("Foo3", "Bar3", "001", "03", 0xFFFE, TEST_CELL_ID))
 
         // Test if we match MNC "01" and "001" correctly.
         .then(() => test("Foo1", "Bar1", "001", "001", 0x0012, TEST_CELL_ID,
                          "Test4", ""))
 
         // Reset back to initial values.
-        .then(() => test(longName, shortName, mcc, mnc, lac, cid,
-                         "Android", ""));
+        .then(() => test(longName, shortName, mcc, mnc, lac, cid));
     });
 });
--- a/dom/mobilemessage/src/gonk/MmsService.js
+++ b/dom/mobilemessage/src/gonk/MmsService.js
@@ -1203,16 +1203,22 @@ function SendTransaction(mmsConnection, 
   let phoneNumber = mmsConnection.getPhoneNumber();
   let from = (phoneNumber) ? { address: phoneNumber, type: "PLMN" } : null;
   msg.headers["from"] = from;
 
   msg.headers["date"] = new Date();
   msg.headers["x-mms-message-class"] = "personal";
   msg.headers["x-mms-expiry"] = 7 * 24 * 60 * 60;
   msg.headers["x-mms-priority"] = 129;
+  try {
+    msg.headers["x-mms-read-report"] =
+      Services.prefs.getBoolPref("dom.mms.requestReadReport");
+  } catch (e) {
+    msg.headers["x-mms-read-report"] = true;
+  }
   msg.headers["x-mms-delivery-report"] = requestDeliveryReport;
 
   if (!gMmsTransactionHelper.checkMaxValuesParameters(msg)) {
     //We should notify end user that the header format is wrong.
     if (DEBUG) debug("Check max values parameters fail.");
     throw new Error("Check max values parameters fail.");
   }
 
@@ -2170,22 +2176,16 @@ MmsService.prototype = {
     aMessage["sender"] = aMmsConnection.getPhoneNumber();
     aMessage["iccId"] = aMmsConnection.getIccId();
     try {
       aMessage["deliveryStatusRequested"] =
         Services.prefs.getBoolPref("dom.mms.requestStatusReport");
     } catch (e) {
       aMessage["deliveryStatusRequested"] = false;
     }
-    try {
-      headers["x-mms-read-report"] =
-        Services.prefs.getBoolPref("dom.mms.requestReadReport");
-    } catch (e) {
-      headers["x-mms-read-report"] = false;
-    }
 
     if (DEBUG) debug("createSavableFromParams: aMessage: " +
                      JSON.stringify(aMessage));
 
     return isAddrValid ? Ci.nsIMobileMessageCallback.SUCCESS_NO_ERROR
                        : Ci.nsIMobileMessageCallback.INVALID_ADDRESS_ERROR;
   },
 
--- a/dom/network/src/NetworkStatsDB.jsm
+++ b/dom/network/src/NetworkStatsDB.jsm
@@ -387,48 +387,26 @@ NetworkStatsDB.prototype = {
       let range = IDBKeyRange.bound(lowerFilter, upperFilter, false, false);
 
       let request = aStore.openCursor(range, 'prev');
       request.onsuccess = function onsuccess(event) {
         let cursor = event.target.result;
         if (!cursor) {
           // Empty, so save first element.
 
-          if (!isAccumulative) {
-            this._saveStats(aTxn, aStore, stats);
-            return;
-          }
-
           // There could be a time delay between the point when the network
           // interface comes up and the point when the database is initialized.
           // In this short interval some traffic data are generated but are not
           // registered by the first sample.
-          stats.rxBytes = stats.rxTotalBytes;
-          stats.txBytes = stats.txTotalBytes;
+          if (isAccumulative) {
+            stats.rxBytes = stats.rxTotalBytes;
+            stats.txBytes = stats.txTotalBytes;
+          }
 
-          // However, if the interface is not switched on after the database is
-          // initialized (dual sim use case) stats should be set to 0.
-          let req = aStore.index("network").openKeyCursor(null, "nextunique");
-          req.onsuccess = function onsuccess(event) {
-            let cursor = event.target.result;
-            if (cursor) {
-              if (cursor.key[1] == stats.network[1]) {
-                stats.rxBytes = 0;
-                stats.txBytes = 0;
-                this._saveStats(aTxn, aStore, stats);
-                return;
-              }
-
-              cursor.continue();
-              return;
-            }
-
-            this._saveStats(aTxn, aStore, stats);
-          }.bind(this);
-
+          this._saveStats(aTxn, aStore, stats);
           return;
         }
 
         // There are old samples
         if (DEBUG) {
           debug("Last value " + JSON.stringify(cursor.value));
         }
 
--- a/dom/speakermanager/SpeakerManager.cpp
+++ b/dom/speakermanager/SpeakerManager.cpp
@@ -207,19 +207,19 @@ SpeakerManager::HandleEvent(nsIDOMEvent*
     }
   }
   return NS_OK;
 }
 
 void
 SpeakerManager::SetAudioChannelActive(bool isActive)
 {
-  if (mForcespeaker) {
+  if (!isActive && !mVisible) {
     SpeakerManagerService *service =
       SpeakerManagerService::GetSpeakerManagerService();
     if (service) {
-      service->ForceSpeaker(isActive, mVisible);
+      service->ForceSpeaker(false, mVisible);
     }
   }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/speakermanager/SpeakerManagerService.cpp
+++ b/dom/speakermanager/SpeakerManagerService.cpp
@@ -59,36 +59,36 @@ SpeakerManagerService::Shutdown()
   }
 }
 
 NS_IMPL_ISUPPORTS(SpeakerManagerService, nsIObserver)
 
 void
 SpeakerManagerService::ForceSpeaker(bool aEnable, uint64_t aChildId)
 {
-  TurnOnSpeaker(aEnable);
+  TuruOnSpeaker(aEnable);
   if (aEnable) {
     mSpeakerStatusSet.Put(aChildId);
   }
   Notify();
   return;
 }
 
 void
 SpeakerManagerService::ForceSpeaker(bool aEnable, bool aVisible)
 {
   // b2g main process without oop
-  TurnOnSpeaker(aEnable && aVisible);
+  TuruOnSpeaker(aEnable && aVisible);
   mVisible = aVisible;
   mOrgSpeakerStatus = aEnable;
   Notify();
 }
 
 void
-SpeakerManagerService::TurnOnSpeaker(bool aOn)
+SpeakerManagerService::TuruOnSpeaker(bool aOn)
 {
   nsCOMPtr<nsIAudioManager> audioManager = do_GetService(NS_AUDIOMANAGER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(audioManager);
   int32_t phoneState;
   audioManager->GetPhoneState(&phoneState);
   int32_t forceuse = (phoneState == nsIAudioManager::PHONE_STATE_IN_CALL ||
     phoneState == nsIAudioManager::PHONE_STATE_IN_COMMUNICATION)
     ? nsIAudioManager::USE_COMMUNICATION : nsIAudioManager::USE_MEDIA;
@@ -134,39 +134,38 @@ void
 SpeakerManagerService::SetAudioChannelActive(bool aIsActive)
 {
   if (!aIsActive && !mVisible) {
     ForceSpeaker(!mOrgSpeakerStatus, mVisible);
   }
 }
 
 NS_IMETHODIMP
-SpeakerManagerService::Observe(nsISupports* aSubject,
-                               const char* aTopic,
-                               const char16_t* aData)
+SpeakerManagerService::Observe(nsISupports* aSubject, const char* 
+                               aTopic, const char16_t* aData)
 {
   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"),
                                              &childID);
     if (NS_SUCCEEDED(rv)) {
         // If the audio has paused by audiochannel,
         // the enable flag should be false and don't need to handle.
         if (mSpeakerStatusSet.Contains(childID)) {
-          TurnOnSpeaker(false);
+          TuruOnSpeaker(false);
           mSpeakerStatusSet.Remove(childID);
         }
         if (mOrgSpeakerStatus) {
-          TurnOnSpeaker(!mOrgSpeakerStatus);
+          TuruOnSpeaker(!mOrgSpeakerStatus);
           mOrgSpeakerStatus = false;
         }
     } else {
       NS_WARNING("ipc:content-shutdown message without childID property");
     }
   }
   return NS_OK;
 }
--- a/dom/speakermanager/SpeakerManagerService.h
+++ b/dom/speakermanager/SpeakerManagerService.h
@@ -46,17 +46,17 @@ public:
 
 protected:
   SpeakerManagerService();
 
   virtual ~SpeakerManagerService();
   // Notify to UA if device speaker status changed
   virtual void Notify();
 
-  void TurnOnSpeaker(bool aEnable);
+  void TuruOnSpeaker(bool aEnable);
 
   nsTArray<nsRefPtr<SpeakerManager> > mRegisteredSpeakerManagers;
   // Set for remember all the child speaker status
   nsCheapSet<nsUint64HashKey> mSpeakerStatusSet;
   // The Speaker status assign by UA
   bool mOrgSpeakerStatus;
 
   bool mVisible;
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -501,27 +501,16 @@ nsGeolocationRequest::StopTimeoutTimer()
 void
 nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
 {
   if (mShutdown) {
     // Ignore SendLocationEvents issued before we were cleared.
     return;
   }
 
-  if (mOptions && mOptions->mMaximumAge > 0) {
-    DOMTimeStamp positionTime_ms;
-    aPosition->GetTimestamp(&positionTime_ms);
-    const uint32_t maximumAge_ms = mOptions->mMaximumAge;
-    const bool isTooOld =
-        DOMTimeStamp(PR_Now() / PR_USEC_PER_MSEC - maximumAge_ms) > positionTime_ms;
-    if (isTooOld) {
-      return;
-    }
-  }
-
   nsRefPtr<Position> wrapped, cachedWrapper = mLocator->GetCachedPosition();
   if (cachedWrapper && aPosition == cachedWrapper->GetWrappedGeoPosition()) {
     wrapped = cachedWrapper;
   } else if (aPosition) {
     nsCOMPtr<nsIDOMGeoPositionCoords> coords;
     aPosition->GetCoords(getter_AddRefs(coords));
     if (coords) {
       wrapped = new Position(ToSupports(mLocator), aPosition);
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -409,30 +409,29 @@ WifiGeoPositionProvider.prototype = {
     try {
       let radioService = Cc["@mozilla.org/ril;1"]
                     .getService(Ci.nsIRadioInterfaceLayer);
       let numInterfaces = radioService.numRadioInterfaces;
       let result = [];
       for (let i = 0; i < numInterfaces; i++) {
         LOG("Looking for SIM in slot:" + i + " of " + numInterfaces);
         let radio = radioService.getRadioInterface(i);
+        let iccInfo = radio.rilContext.iccInfo;
         let cell = radio.rilContext.voice.cell;
         let type = radio.rilContext.voice.type;
-        let network = radio.rilContext.voice.network;
 
-        if (network && cell && type) {
+        if (iccInfo && cell && type) {
           if (type === "gsm" || type === "gprs" || type === "edge") {
             type = "gsm";
           } else {
             type = "wcdma";
           }
-
           result.push({ radio: type,
-                      mobileCountryCode: network.mcc,
-                      mobileNetworkCode: network.mnc,
+                      mobileCountryCode: iccInfo.mcc,
+                      mobileNetworkCode: iccInfo.mnc,
                       locationAreaCode: cell.gsmLocationAreaCode,
                       cellId: cell.gsmCellId });
         }
       }
       return result;
     } catch (e) {
       return null;
     }
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -619,21 +619,16 @@ AudioManager::SetForceForUse(int32_t aUs
 {
   if (static_cast<
              status_t (*)(audio_policy_force_use_t, audio_policy_forced_cfg_t)
              >(AudioSystem::setForceUse)) {
     // Dynamically resolved the ICS signature.
     status_t status = AudioSystem::setForceUse(
                         (audio_policy_force_use_t)aUsage,
                         (audio_policy_forced_cfg_t)aForce);
-
-    if (aUsage == AUDIO_POLICY_FORCE_FOR_MEDIA) {
-      AudioSystem::setForceUse(AUDIO_POLICY_FORCE_FOR_PROPRIETARY, (audio_policy_forced_cfg_t)aForce);
-    }
-
     return status ? NS_ERROR_FAILURE : NS_OK;
   }
 
   NS_NOTREACHED("Doesn't support force routing on GB version");
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
@@ -648,49 +643,30 @@ AudioManager::GetForceForUse(int32_t aUs
 
   NS_NOTREACHED("Doesn't support force routing on GB version");
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
 AudioManager::GetFmRadioAudioEnabled(bool *aFmRadioAudioEnabled)
 {
-#if ANDROID_VERSION < 17
   *aFmRadioAudioEnabled = IsDeviceOn(AUDIO_DEVICE_OUT_FM);
-#else
-  *aFmRadioAudioEnabled = IsDeviceOn(AUDIO_DEVICE_IN_FM);
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AudioManager::SetFmRadioAudioEnabled(bool aFmRadioAudioEnabled)
 {
   if (static_cast<
       status_t (*) (AudioSystem::audio_devices, AudioSystem::device_connection_state, const char *)
       >(AudioSystem::setDeviceConnectionState)) {
-#if ANDROID_VERSION < 17
     AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_FM,
       aFmRadioAudioEnabled ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
       AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
-#else
-    AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_FM,
-      aFmRadioAudioEnabled ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
-      AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
-#endif
     InternalSetAudioRoutes(GetCurrentSwitchState(SWITCH_HEADPHONES));
-
-    if (aFmRadioAudioEnabled) {
-      String8 cmd("AudioSetFmDigitalEnable=1");
-      AudioSystem::setParameters(0, cmd);
-    } else {
-      String8 cmd("AudioSetFmDigitalEnable=0");
-      AudioSystem::setParameters(0, cmd);
-    }
-
     // sync volume with music after powering on fm radio
     if (aFmRadioAudioEnabled) {
       int32_t volIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
       SetStreamVolumeIndex(AUDIO_STREAM_FM, volIndex);
       mCurrentStreamVolumeTbl[AUDIO_STREAM_FM] = volIndex;
     }
     return NS_OK;
   } else {
@@ -700,18 +676,20 @@ AudioManager::SetFmRadioAudioEnabled(boo
 
 NS_IMETHODIMP
 AudioManager::SetAudioChannelVolume(int32_t aChannel, int32_t aIndex) {
   nsresult status;
 
   switch (static_cast<AudioChannel>(aChannel)) {
     case AudioChannel::Content:
       // sync FMRadio's volume with content channel.
-      status = SetStreamVolumeIndex(AUDIO_STREAM_FM, aIndex);
-      NS_ENSURE_SUCCESS(status, status);
+      if (IsDeviceOn(AUDIO_DEVICE_OUT_FM)) {
+        status = SetStreamVolumeIndex(AUDIO_STREAM_FM, aIndex);
+        NS_ENSURE_SUCCESS(status, status);
+      }
       status = SetStreamVolumeIndex(AUDIO_STREAM_MUSIC, aIndex);
       NS_ENSURE_SUCCESS(status, status);
       status = SetStreamVolumeIndex(AUDIO_STREAM_SYSTEM, aIndex);
       break;
     case AudioChannel::Notification:
       status = SetStreamVolumeIndex(AUDIO_STREAM_NOTIFICATION, aIndex);
       NS_ENSURE_SUCCESS(status, status);
       status = SetStreamVolumeIndex(AUDIO_STREAM_RING, aIndex);
@@ -805,17 +783,17 @@ AudioManager::SetStreamVolumeIndex(int32
               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 = AudioSystem::getDevicesForStream(AUDIO_STREAM_FM);
+    device = AUDIO_DEVICE_OUT_FM;
   }
 
   if (device != 0) {
     status = AudioSystem::setStreamVolumeIndex(
                static_cast<audio_stream_type_t>(aStream),
                aIndex,
                device);
     return status ? NS_ERROR_FAILURE : NS_OK;
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -9,43 +9,37 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
-#include "GonkGPSGeolocationProvider.h"
-
 #include <pthread.h>
 #include <hardware/gps.h>
 
-#include "mozilla/Constants.h"
+#include "GonkGPSGeolocationProvider.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
-#include "nsContentUtils.h"
 #include "nsGeoPosition.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINetworkManager.h"
 #include "nsIObserverService.h"
 #include "nsJSUtils.h"
-#include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
+#include "nsContentUtils.h"
 #include "prtime.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMIccInfo.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionProvider.h"
 #include "nsIMobileCellInfo.h"
-#include "nsIMobileNetworkInfo.h"
 #include "nsIRadioInterfaceLayer.h"
-#include "nsRadioInterfaceLayer.h"
 #endif
 
 #define SETTING_DEBUG_ENABLED "geolocation.debugging.enabled"
 
 #ifdef AGPS_TYPE_INVALID
 #define AGPS_HAVE_DUAL_APN
 #endif
 
@@ -80,18 +74,18 @@ GonkGPSGeolocationProvider::LocationCall
   class UpdateLocationEvent : public nsRunnable {
   public:
     UpdateLocationEvent(nsGeoPosition* aPosition)
       : mPosition(aPosition)
     {}
     NS_IMETHOD Run() {
       nsRefPtr<GonkGPSGeolocationProvider> provider =
         GonkGPSGeolocationProvider::GetSingleton();
+      provider->mLastGPSDerivedLocationTime = PR_Now();
       nsCOMPtr<nsIGeolocationUpdate> callback = provider->mLocationCallback;
-      provider->mLastGPSPosition = mPosition;
       if (callback) {
         callback->Update(mPosition);
       }
       return NS_OK;
     }
   private:
     nsRefPtr<nsGeoPosition> mPosition;
   };
@@ -100,24 +94,17 @@ GonkGPSGeolocationProvider::LocationCall
 
   nsRefPtr<nsGeoPosition> somewhere = new nsGeoPosition(location->latitude,
                                                         location->longitude,
                                                         location->altitude,
                                                         location->accuracy,
                                                         location->accuracy,
                                                         location->bearing,
                                                         location->speed,
-                                                        PR_Now() / PR_USEC_PER_MSEC);
-  // Note above: Can't use location->timestamp as the time from the satellite is a
-  // minimum of 16 secs old (see http://leapsecond.com/java/gpsclock.htm).
-  // All code from this point on expects the gps location to be timestamped with the
-  // current time, most notably: the geolocation service which respects maximumAge
-  // set in the DOM JS.
-
-
+                                                        location->timestamp);
   NS_DispatchToMainThread(new UpdateLocationEvent(somewhere));
 }
 
 void
 GonkGPSGeolocationProvider::StatusCallback(GpsStatus* status)
 {
 }
 
@@ -343,57 +330,39 @@ GonkGPSGeolocationProvider::GetDataConne
 }
 
 void
 GonkGPSGeolocationProvider::SetAGpsDataConn(nsAString& aApn)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mAGpsInterface);
 
-  bool hasUpdateNetworkAvailability = false;
-  if (mAGpsRilInterface->size >= sizeof(AGpsRilInterface) &&
-      mAGpsRilInterface->update_network_availability) {
-    hasUpdateNetworkAvailability = true;
-  }
-
   int32_t connectionState = GetDataConnectionState();
-  NS_ConvertUTF16toUTF8 apn(aApn);
   if (connectionState == nsINetworkInterface::NETWORK_STATE_CONNECTED) {
-    // The definition of availability is
-    // 1. The device is connected to the home network
-    // 2. The device is connected to a foreign network and data
-    //    roaming is enabled
-    // RIL turns on/off data connection automatically when the data
-    // roaming setting changes.
-    if (hasUpdateNetworkAvailability) {
-      mAGpsRilInterface->update_network_availability(true, apn.get());
-    }
+    NS_ConvertUTF16toUTF8 apn(aApn);
 #ifdef AGPS_HAVE_DUAL_APN
     mAGpsInterface->data_conn_open(AGPS_TYPE_SUPL,
                                    apn.get(),
                                    AGPS_APN_BEARER_IPV4);
 #else
     mAGpsInterface->data_conn_open(apn.get());
 #endif
   } else if (connectionState == nsINetworkInterface::NETWORK_STATE_DISCONNECTED) {
-    if (hasUpdateNetworkAvailability) {
-      mAGpsRilInterface->update_network_availability(false, apn.get());
-    }
 #ifdef AGPS_HAVE_DUAL_APN
     mAGpsInterface->data_conn_closed(AGPS_TYPE_SUPL);
 #else
     mAGpsInterface->data_conn_closed();
 #endif
   }
 }
 
 #endif // MOZ_B2G_RIL
 
 void
-GonkGPSGeolocationProvider::RequestSettingValue(const char* aKey)
+GonkGPSGeolocationProvider::RequestSettingValue(char* aKey)
 {
   MOZ_ASSERT(aKey);
   nsCOMPtr<nsISettingsService> ss = do_GetService("@mozilla.org/settingsService;1");
   if (!ss) {
     MOZ_ASSERT(ss);
     return;
   }
   nsCOMPtr<nsISettingsServiceLock> lock;
@@ -474,88 +443,73 @@ void
 GonkGPSGeolocationProvider::SetReferenceLocation()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mRadioInterface) {
     return;
   }
 
+  nsCOMPtr<nsIRilContext> rilCtx;
+  mRadioInterface->GetRilContext(getter_AddRefs(rilCtx));
+
   AGpsRefLocation location;
 
   // TODO: Bug 772750 - get mobile connection technology from rilcontext
   location.type = AGPS_REF_LOCATION_TYPE_UMTS_CELLID;
 
-  nsCOMPtr<nsIMobileConnectionProvider> connection =
-    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
-  NS_ENSURE_TRUE_VOID(connection);
-
-  nsCOMPtr<nsIMobileConnectionInfo> voice;
-  // TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
-  // MultiSIM configuration
-  connection->GetVoiceConnectionInfo(0 /* Client Id */, getter_AddRefs(voice));
-
-  if (voice) {
-    nsCOMPtr<nsIMobileNetworkInfo> networkInfo;
-    voice->GetNetwork(getter_AddRefs(networkInfo));
-    if (networkInfo) {
+  if (rilCtx) {
+    nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
+    rilCtx->GetIccInfo(getter_AddRefs(iccInfo));
+    if (iccInfo) {
       nsresult result;
       nsAutoString mcc, mnc;
 
-      networkInfo->GetMcc(mcc);
-      networkInfo->GetMnc(mnc);
+      iccInfo->GetMcc(mcc);
+      iccInfo->GetMnc(mnc);
 
       location.u.cellID.mcc = mcc.ToInteger(&result);
       if (result != NS_OK) {
         NS_WARNING("Cannot parse mcc to integer");
         location.u.cellID.mcc = 0;
       }
 
       location.u.cellID.mnc = mnc.ToInteger(&result);
       if (result != NS_OK) {
         NS_WARNING("Cannot parse mnc to integer");
         location.u.cellID.mnc = 0;
       }
-    } else {
-      NS_WARNING("Cannot get mobile network info.");
-      location.u.cellID.mcc = 0;
-      location.u.cellID.mnc = 0;
     }
-
-    nsCOMPtr<nsIMobileCellInfo> cell;
-    voice->GetCell(getter_AddRefs(cell));
-    if (cell) {
-      int32_t lac;
-      int64_t cid;
-
-      cell->GetGsmLocationAreaCode(&lac);
-      // The valid range of LAC is 0x0 to 0xffff which is defined in
-      // hardware/ril/include/telephony/ril.h
-      if (lac >= 0x0 && lac <= 0xffff) {
-        location.u.cellID.lac = lac;
-      }
+    nsCOMPtr<nsIMobileConnectionInfo> voice;
+    rilCtx->GetVoice(getter_AddRefs(voice));
+    if (voice) {
+      nsCOMPtr<nsIMobileCellInfo> cell;
+      voice->GetCell(getter_AddRefs(cell));
+      if (cell) {
+        int32_t lac;
+        int64_t cid;
 
-      cell->GetGsmCellId(&cid);
-      // The valid range of cell id is 0x0 to 0xffffffff which is defined in
-      // hardware/ril/include/telephony/ril.h
-      if (cid >= 0x0 && cid <= 0xffffffff) {
-        location.u.cellID.cid = cid;
+        cell->GetGsmLocationAreaCode(&lac);
+        // The valid range of LAC is 0x0 to 0xffff which is defined in
+        // hardware/ril/include/telephony/ril.h
+        if (lac >= 0x0 && lac <= 0xffff) {
+          location.u.cellID.lac = lac;
+        }
+
+        cell->GetGsmCellId(&cid);
+        // The valid range of cell id is 0x0 to 0xffffffff which is defined in
+        // hardware/ril/include/telephony/ril.h
+        if (cid >= 0x0 && cid <= 0xffffffff) {
+          location.u.cellID.cid = cid;
+        }
       }
-    } else {
-      NS_WARNING("Cannot get mobile gell info.");
-      location.u.cellID.lac = -1;
-      location.u.cellID.cid = -1;
     }
-  } else {
-    NS_WARNING("Cannot get mobile connection info.");
-    return;
-  }
-
-  if (mAGpsRilInterface) {
-    mAGpsRilInterface->set_ref_location(&location, sizeof(location));
+    if (mAGpsRilInterface) {
+      mAGpsRilInterface->set_ref_location(&location, sizeof(location));
+    }
   }
 }
 
 #endif // MOZ_B2G_RIL
 
 void
 GonkGPSGeolocationProvider::InjectLocation(double latitude,
                                            double longitude,
@@ -719,82 +673,51 @@ GonkGPSGeolocationProvider::NetworkLocat
     return NS_ERROR_FAILURE;
   }
 
   double lat, lon, acc;
   coords->GetLatitude(&lat);
   coords->GetLongitude(&lon);
   coords->GetAccuracy(&acc);
 
-  double delta = -1.0;
+  double delta = MAXFLOAT;
 
   static double sLastMLSPosLat = 0;
   static double sLastMLSPosLon = 0;
 
   if (0 != sLastMLSPosLon || 0 != sLastMLSPosLat) {
     // Use spherical law of cosines to calculate difference
     // Not quite as correct as the Haversine but simpler and cheaper
     // Should the following be a utility function? Others might need this calc.
-    const double radsInDeg = M_PI / 180.0;
+    const double radsInDeg = 3.14159265 / 180.0;
     const double rNewLat = lat * radsInDeg;
     const double rNewLon = lon * radsInDeg;
     const double rOldLat = sLastMLSPosLat * radsInDeg;
     const double rOldLon = sLastMLSPosLon * radsInDeg;
     // WGS84 equatorial radius of earth = 6378137m
-    double cosDelta = (sin(rNewLat) * sin(rOldLat)) +
-                      (cos(rNewLat) * cos(rOldLat) * cos(rOldLon - rNewLon));
-    if (cosDelta > 1.0) {
-      cosDelta = 1.0;
-    } else if (cosDelta < -1.0) {
-      cosDelta = -1.0;
-    }
-    delta = acos(cosDelta) * 6378137;
+    delta = acos( (sin(rNewLat) * sin(rOldLat)) +
+                  (cos(rNewLat) * cos(rOldLat) * cos(rOldLon - rNewLon)) )
+                  * 6378137;
   }
 
   sLastMLSPosLat = lat;
   sLastMLSPosLon = lon;
 
   // if the MLS coord change is smaller than this arbitrarily small value
   // assume the MLS coord is unchanged, and stick with the GPS location
   const double kMinMLSCoordChangeInMeters = 10;
 
-  DOMTimeStamp time_ms = 0;
-  if (provider->mLastGPSPosition) {
-    provider->mLastGPSPosition->GetTimestamp(&time_ms);
-  }
-  const int64_t diff_ms = (PR_Now() / PR_USEC_PER_MSEC) - time_ms;
-
-  // We want to distinguish between the GPS being inactive completely
-  // and temporarily inactive. In the former case, we would use a low
-  // accuracy network location; in the latter, we only want a network
-  // location that appears to updating with movement.
-
-  const bool isGPSFullyInactive = diff_ms > 1000 * 60 * 2; // two mins
-  const bool isGPSTempInactive = diff_ms > 1000 * 10; // 10 secs
-
-  if (provider->mLocationCallback) {
-    if (isGPSFullyInactive ||
-       (isGPSTempInactive && delta > kMinMLSCoordChangeInMeters))
-    {
-      if (gGPSDebugging) {
-        nsContentUtils::LogMessageToConsole("geo: Using MLS, GPS age:%fs, MLS Delta:%fm\n",
-                                            diff_ms / 1000.0, delta);
-      }
-      provider->mLocationCallback->Update(position);
-    } else if (provider->mLastGPSPosition) {
-      if (gGPSDebugging) {
-        nsContentUtils::LogMessageToConsole("geo: Using old GPS age:%fs\n",
-                                            diff_ms / 1000.0);
-      }
-
-      // This is a fallback case so that the GPS provider responds with its last
-      // location rather than waiting for a more recent GPS or network location.
-      // The service decides if the location is too old, not the provider.
-      provider->mLocationCallback->Update(provider->mLastGPSPosition);
-    }
+  // if we haven't seen anything from the GPS device for 10s,
+  // use this network derived location.
+  const int kMaxGPSDelayBeforeConsideringMLS = 10000;
+  int64_t diff = PR_Now() - provider->mLastGPSDerivedLocationTime;
+  if (provider->mLocationCallback && diff > kMaxGPSDelayBeforeConsideringMLS
+      && delta > kMinMLSCoordChangeInMeters)
+  {
+    provider->mLocationCallback->Update(position);
   }
 
   provider->InjectLocation(lat, lon, acc);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::NetworkLocationUpdate::LocationUpdatePending()
@@ -830,16 +753,17 @@ GonkGPSGeolocationProvider::Startup()
   if (mNetworkLocationProvider) {
     nsresult rv = mNetworkLocationProvider->Startup();
     if (NS_SUCCEEDED(rv)) {
       nsRefPtr<NetworkLocationUpdate> update = new NetworkLocationUpdate();
       mNetworkLocationProvider->Watch(update);
     }
   }
 
+  mLastGPSDerivedLocationTime = 0;
   mStarted = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Watch(nsIGeolocationUpdate* aCallback)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -886,84 +810,29 @@ GonkGPSGeolocationProvider::ShutdownGPS(
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::SetHighAccuracy(bool)
 {
   return NS_OK;
 }
 
-namespace {
-int
-ConvertToGpsNetworkType(int aNetworkInterfaceType)
-{
-  switch (aNetworkInterfaceType) {
-    case nsINetworkInterface::NETWORK_TYPE_WIFI:
-      return AGPS_RIL_NETWORK_TYPE_WIFI;
-    case nsINetworkInterface::NETWORK_TYPE_MOBILE:
-      return AGPS_RIL_NETWORK_TYPE_MOBILE;
-    case nsINetworkInterface::NETWORK_TYPE_MOBILE_MMS:
-      return AGPS_RIL_NETWORK_TYPE_MOBILE_MMS;
-    case nsINetworkInterface::NETWORK_TYPE_MOBILE_SUPL:
-      return AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL;
-    case nsINetworkInterface::NETWORK_TYPE_MOBILE_DUN:
-      return AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN;
-    default:
-      NS_WARNING(nsPrintfCString("Unknown network type mapping %d",
-                                 aNetworkInterfaceType).get());
-      return -1;
-  }
-}
-} // anonymous namespace
-
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
                                     const char* aTopic,
                                     const char16_t* aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
 #ifdef MOZ_B2G_RIL
   if (!strcmp(aTopic, kNetworkConnStateChangedTopic)) {
-    nsCOMPtr<nsINetworkInterface> iface = do_QueryInterface(aSubject);
+    nsCOMPtr<nsIRilNetworkInterface> iface = do_QueryInterface(aSubject);
     if (!iface) {
       return NS_OK;
     }
-    nsCOMPtr<nsIRilNetworkInterface> rilface = do_QueryInterface(aSubject);
-    if (mAGpsRilInterface && mAGpsRilInterface->update_network_state) {
-      int32_t state;
-      int32_t type;
-      iface->GetState(&state);
-      iface->GetType(&type);
-      bool connected = (state == nsINetworkInterface::NETWORK_STATE_CONNECTED);
-      bool roaming = false;
-      int gpsNetworkType = ConvertToGpsNetworkType(type);
-      if (gpsNetworkType >= 0) {
-        if (rilface && mRadioInterface) {
-          nsCOMPtr<nsIRilContext> rilCtx;
-          mRadioInterface->GetRilContext(getter_AddRefs(rilCtx));
-          if (rilCtx) {
-            nsCOMPtr<nsIMobileConnectionInfo> voice;
-            rilCtx->GetVoice(getter_AddRefs(voice));
-            if (voice) {
-              voice->GetRoaming(&roaming);
-            }
-          }
-        }
-        mAGpsRilInterface->update_network_state(
-          connected,
-          gpsNetworkType,
-          roaming,
-          /* extra_info = */ nullptr);
-      }
-    }
-    // No data connection
-    if (!rilface) {
-      return NS_OK;
-    }
 
     RequestSettingValue("ril.supl.apn");
   }
 #endif
 
   return NS_OK;
 }
 
--- a/dom/system/gonk/GonkGPSGeolocationProvider.h
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.h
@@ -16,17 +16,16 @@
 
 #ifndef GonkGPSGeolocationProvider_h
 #define GonkGPSGeolocationProvider_h
 
 #include <hardware/gps.h> // for GpsInterface
 #include "nsCOMPtr.h"
 #include "nsIGeolocationProvider.h"
 #include "nsIObserver.h"
-#include "nsIDOMGeoPosition.h"
 #ifdef MOZ_B2G_RIL
 #include "nsIRadioInterfaceLayer.h"
 #endif
 #include "nsISettingsService.h"
 
 class nsIThread;
 
 #define GONK_GPS_GEOLOCATION_PROVIDER_CID \
@@ -75,17 +74,17 @@ private:
   static AGpsCallbacks mAGPSCallbacks;
   static AGpsRilCallbacks mAGPSRILCallbacks;
 #endif
 
   void Init();
   void StartGPS();
   void ShutdownGPS();
   void InjectLocation(double latitude, double longitude, float accuracy);
-  void RequestSettingValue(const char* aKey);
+  void RequestSettingValue(char* aKey);
 #ifdef MOZ_B2G_RIL
   void SetupAGPS();
   int32_t GetDataConnectionState();
   void SetAGpsDataConn(nsAString& aApn);
   void RequestDataConnection();
   void ReleaseDataConnection();
   void RequestSetID(uint32_t flags);
   void SetReferenceLocation();
@@ -107,19 +106,19 @@ private:
 
   const GpsInterface* mGpsInterface;
 #ifdef MOZ_B2G_RIL
   const AGpsInterface* mAGpsInterface;
   const AGpsRilInterface* mAGpsRilInterface;
   nsCOMPtr<nsIRadioInterface> mRadioInterface;
 #endif
   nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
+  PRTime mLastGPSDerivedLocationTime;
   nsCOMPtr<nsIThread> mInitThread;
   nsCOMPtr<nsIGeolocationProvider> mNetworkLocationProvider;
-  nsCOMPtr<nsIDOMGeoPosition> mLastGPSPosition;
 
   class NetworkLocationUpdate : public nsIGeolocationUpdate
   {
     public:
       NS_DECL_ISUPPORTS
       NS_DECL_NSIGEOLOCATIONUPDATE
 
       NetworkLocationUpdate() {}
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -790,32 +790,36 @@ XPCOMUtils.defineLazyGetter(this, "gData
       if (!this.isSwitchingDataClientId() ||
           clientId != this._currentDataClientId) {
         return;
       }
 
       let connHandler = this._connectionHandlers[this._currentDataClientId];
       if (connHandler.allDataDisconnected() &&
           typeof this._pendingDataCallRequest === "function") {
+        if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND) {
+          let radioInterface = connHandler.radioInterface;
+          radioInterface.setDataRegistration(false);
+        }
         if (DEBUG) {
-          this.debug("All data calls disconnected, process pending data settings.");
+          this.debug("All data calls disconnected, setup pending data call.");
         }
         this._pendingDataCallRequest();
         this._pendingDataCallRequest = null;
       }
     },
 
     _handleDataClientIdChange: function(newDefault) {
       if (this._dataDefaultClientId === newDefault) {
          return;
       }
       this._dataDefaultClientId = newDefault;
 
-      // This is to handle boot up stage.
       if (this._currentDataClientId == -1) {
+        // This is to handle boot up stage.
         this._currentDataClientId = this._dataDefaultClientId;
         let connHandler = this._connectionHandlers[this._currentDataClientId];
         let radioInterface = connHandler.radioInterface;
         if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND ||
             RILQUIRKS_SUBSCRIPTION_CONTROL) {
           radioInterface.setDataRegistration(true);
         }
         if (this._dataEnabled) {
@@ -829,56 +833,63 @@ XPCOMUtils.defineLazyGetter(this, "gData
 
       let oldConnHandler = this._connectionHandlers[this._currentDataClientId];
       let oldIface = oldConnHandler.radioInterface;
       let oldSettings = oldConnHandler.dataCallSettings;
       let newConnHandler = this._connectionHandlers[this._dataDefaultClientId];
       let newIface = newConnHandler.radioInterface;
       let newSettings = newConnHandler.dataCallSettings;
 
-      let applyPendingDataSettings = (function() {
+      if (!this._dataEnabled) {
         if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND ||
             RILQUIRKS_SUBSCRIPTION_CONTROL) {
-          oldIface.setDataRegistration(false)
-            .then(() => {
-              if (this._dataEnabled) {
-                newSettings.oldEnabled = newSettings.enabled;
-                newSettings.enabled = true;
-              }
-              this._currentDataClientId = this._dataDefaultClientId;
-              return newIface.setDataRegistration(true);
-            })
-            .then(() => newConnHandler.updateRILNetworkInterface());
-          return;
-        }
-
-        if (this._dataEnabled) {
-          newSettings.oldEnabled = newSettings.enabled;
-          newSettings.enabled = true;
+          oldIface.setDataRegistration(false);
+          newIface.setDataRegistration(true);
         }
         this._currentDataClientId = this._dataDefaultClientId;
-        newConnHandler.updateRILNetworkInterface();
-      }).bind(this);
-
-      if (this._dataEnabled) {
-        oldSettings.oldEnabled = oldSettings.enabled;
-        oldSettings.enabled = false;
+        return;
       }
 
+      oldSettings.oldEnabled = oldSettings.enabled;
+      oldSettings.enabled = false;
+
       if (oldConnHandler.anyDataConnected()) {
-        this._pendingDataCallRequest = applyPendingDataSettings;
+        this._pendingDataCallRequest = function () {
+          if (DEBUG) {
+            this.debug("Executing pending data call request.");
+          }
+          if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND ||
+              RILQUIRKS_SUBSCRIPTION_CONTROL) {
+            newIface.setDataRegistration(true);
+          }
+          newSettings.oldEnabled = newSettings.enabled;
+          newSettings.enabled = this._dataEnabled;
+
+          this._currentDataClientId = this._dataDefaultClientId;
+          newConnHandler.updateRILNetworkInterface();
+        };
+
         if (DEBUG) {
           this.debug("_handleDataClientIdChange: existing data call(s) active" +
                      ", wait for them to get disconnected.");
         }
         oldConnHandler.deactivateDataCalls();
         return;
       }
 
-      applyPendingDataSettings();
+      newSettings.oldEnabled = newSettings.enabled;
+      newSettings.enabled = true;
+
+      this._currentDataClientId = this._dataDefaultClientId;
+      if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND ||
+          RILQUIRKS_SUBSCRIPTION_CONTROL) {
+        oldIface.setDataRegistration(false);
+        newIface.setDataRegistration(true);
+      }
+      newConnHandler.updateRILNetworkInterface();
     },
 
     _shutdown: function() {
       for (let handler of this._connectionHandlers) {
         handler.shutdown();
       }
       this._connectionHandlers = null;
       Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
@@ -1065,22 +1076,16 @@ DataConnectionHandler.prototype = {
   // Data calls setting.
   dataCallSettings: null,
   dataNetworkInterfaces: null,
   _dataCalls: null,
 
   // Apn settings to be setup after data call are cleared.
   _pendingApnSettings: null,
 
-  // Cache if voice and data concurrent is allowed.
-  _isConcurrentAllowed: false,
-
-  // Cached phone state.
-  _phoneState: RIL.GECKO_PHONE_STATE_IDLE,
-
   debug: function(s) {
     dump("-*- DataConnectionHandler[" + this.clientId + "]: " + s + "\n");
   },
 
   shutdown: function() {
     // Shutdown all RIL network interfaces
     this.dataNetworkInterfaces.forEach(function(networkInterface) {
       gNetworkManager.unregisterNetworkInterface(networkInterface);
@@ -1115,35 +1120,27 @@ DataConnectionHandler.prototype = {
         return Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS;
       case "dun":
         return Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN;
       default:
         return Ci.nsINetworkInterface.NETWORK_TYPE_UNKNOWN;
      }
   },
 
-  _compareDataCallOptions: function(dataCall, newDataCall) {
-    return dataCall.apnProfile.apn == newDataCall.apn &&
-           dataCall.apnProfile.user == newDataCall.user &&
-           dataCall.apnProfile.password == newDataCall.passwd &&
-           dataCall.chappap == newDataCall.chappap &&
-           dataCall.pdptype == newDataCall.pdptype;
-  },
-
   _deliverDataCallMessage: function(name, args) {
     for (let i = 0; i < this._dataCalls.length; i++) {
       let datacall = this._dataCalls[i];
-      // Send message only to the DataCall that matches the data call options.
+      // Send message only to the DataCall that matches apn.
       // Currently, args always contain only one datacall info.
-      if (!this._compareDataCallOptions(datacall, args[0])) {
+      if (!args[0].apn || args[0].apn != datacall.apnProfile.apn) {
         continue;
       }
       // Do not deliver message to DataCall that contains cid but mistmaches
       // with the cid in the current message.
-      if (args[0].cid !== undefined && datacall.linkInfo.cid != null &&
+      if (args[0].cid && datacall.linkInfo.cid &&
           args[0].cid != datacall.linkInfo.cid) {
         continue;
       }
 
       try {
         let handler = datacall[name];
         if (typeof handler !== "function") {
           throw new Error("No handler for " + name);
@@ -1349,25 +1346,16 @@ DataConnectionHandler.prototype = {
     if (networkInterface.enabled && wifi_active) {
       if (DEBUG) {
         this.debug("Disconnect data call when Wifi is connected.");
       }
       networkInterface.disconnect();
       return;
     }
 
-    if (networkInterface.enabled && !this._isConcurrentAllowed &&
-        this._phoneState !== RIL.GECKO_PHONE_STATE_IDLE) {
-      if (DEBUG) {
-        this.debug("Disconnect data call when it cannot coexist with voice call.");
-      }
-      networkInterface.disconnect();
-      return;
-    }
-
     if (!this.dataCallSettings.enabled || defaultDataCallConnected) {
       if (DEBUG) {
         this.debug("Data call settings: nothing to do.");
       }
       return;
     }
     if (dataInfo.roaming && !this.dataCallSettings.roamingEnabled) {
       if (DEBUG) {
@@ -1380,23 +1368,16 @@ DataConnectionHandler.prototype = {
         this.debug("Don't connect data call when Wifi is connected.");
       }
       return;
     }
     if (this._pendingApnSettings) {
       if (DEBUG) this.debug("We're changing apn settings, ignore any changes.");
       return;
     }
-    if (!this._isConcurrentAllowed &&
-        this._phoneState !== RIL.GECKO_PHONE_STATE_IDLE) {
-      if (DEBUG) {
-        this.debug("Don't connect data call when it cannot coexist with voice call.");
-      }
-      return;
-    }
 
     let detailedRadioState = rilContext.detailedRadioState;
     if (gRadioEnabledController.isDeactivatingDataCalls() ||
         detailedRadioState == RIL.GECKO_DETAILED_RADIOSTATE_ENABLING ||
         detailedRadioState == RIL.GECKO_DETAILED_RADIOSTATE_DISABLING) {
       // We're changing the radio power currently, ignore any changes.
       return;
     }
@@ -1463,29 +1444,20 @@ DataConnectionHandler.prototype = {
 
   /**
    * Handle data errors.
    */
   handleDataCallError: function(message) {
     // Notify data call error only for data APN
     let networkInterface = this.dataNetworkInterfaces.get("default");
     if (networkInterface && networkInterface.enabled) {
-      let dataCall = networkInterface.dataCall;
-      // If there is a cid, compare cid; otherwise it is probably an error on
-      // data call setup.
-      if (message.cid !== undefined) {
-        if (message.cid == dataCall.linkInfo.cid) {
-          gMessageManager.sendMobileConnectionMessage("RIL:DataError",
-                                                      this.clientId, message);
-        }
-      } else {
-        if (this._compareDataCallOptions(dataCall, message)) {
-          gMessageManager.sendMobileConnectionMessage("RIL:DataError",
-                                                      this.clientId, message);
-        }
+      let apnSetting = networkInterface.apnSetting;
+      if (message.apn == apnSetting.apn) {
+        gMessageManager.sendMobileConnectionMessage("RIL:DataError",
+                                                    this.clientId, message);
       }
     }
 
     this._deliverDataCallMessage("dataCallError", [message]);
   },
 
   /**
    * Handle data call state changes.
@@ -1513,35 +1485,16 @@ DataConnectionHandler.prototype = {
         this.updateRILNetworkInterface();
       }
 
       if (gDataConnectionManager.isSwitchingDataClientId()) {
         gDataConnectionManager.notifyDataCallStateChange(this.clientId);
       }
     }
   },
-
-  notifyDataChanged: function(aDataInfo) {
-    let type = aDataInfo.type;
-    this._isConcurrentAllowed =
-      (RIL.GECKO_RADIO_TECH.indexOf(type) >= RIL.NETWORK_CREG_TECH_UMTS);
-    if (DEBUG) {
-      this.debug("notifyDataChanged: radioTech=" + type +
-                 ", _isConcurrentAllowed=" + this._isConcurrentAllowed);
-    }
-    this.updateRILNetworkInterface();
-  },
-
-  notifyPhoneStateChanged: function(aState) {
-    if (DEBUG) {
-      this.debug("notifyPhoneStateChanged: " + aState);
-    }
-    this._phoneState = aState;
-    this.updateRILNetworkInterface();
-  },
 };
 
 function RadioInterfaceLayer() {
   let workerMessenger = new WorkerMessenger();
   workerMessenger.init();
   this.setWorkerDebugFlag = workerMessenger.setDebugFlag.bind(workerMessenger);
 
   let numIfaces = this.numRadioInterfaces;
@@ -2127,19 +2080,16 @@ RadioInterface.prototype = {
       case "cdmaCallWaiting":
         gTelephonyService.notifyCdmaCallWaiting(this.clientId, message.waitingCall);
         break;
       case "suppSvcNotification":
         gTelephonyService.notifySupplementaryService(this.clientId,
                                                       message.callIndex,
                                                       message.notification);
         break;
-      case "phoneStateChanged":
-        connHandler.notifyPhoneStateChanged(message.state);
-        break;
       case "datacallerror":
         connHandler.handleDataCallError(message);
         break;
       case "datacallstatechange":
         let addresses = [];
         for (let i = 0; i < message.addresses.length; i++) {
           let [address, prefixLength] = message.addresses[i].split("/");
           // From AOSP hardware/ril/include/telephony/ril.h, that address prefix
@@ -2471,17 +2421,16 @@ RadioInterface.prototype = {
     }
 
     if (!batch) {
       gMessageManager.sendMobileConnectionMessage("RIL:DataInfoChanged",
                                                   this.clientId, dataInfo);
     }
 
     let connHandler = gDataConnectionManager.getConnectionHandler(this.clientId);
-    connHandler.notifyDataChanged(dataInfo);
     connHandler.updateRILNetworkInterface();
   },
 
   getPreferredNetworkType: function(target, message) {
     this.workerMessenger.send("getPreferredNetworkType", message, (function(response) {
       target.sendAsyncMessage("RIL:GetPreferredNetworkType", {
         clientId: this.clientId,
         data: response
@@ -2496,35 +2445,20 @@ RadioInterface.prototype = {
         clientId: this.clientId,
         data: response
       });
       return false;
     }).bind(this));
   },
 
   setCellBroadcastSearchList: function(newSearchList) {
-    function isEqual(newSearchList, oldSearchList) {
-      function getSearchString(aSearchList, aProp) {
-        if (typeof aSearchList === "string" ||
-            aSearchList instanceof String) {
-          return aSearchList;
-        }
-        // convert undefined to "";
-        return (aSearchList && aSearchList[aProp]) || "";
-      }
-
-      let newGsm = getSearchString(newSearchList, "gsm");
-      let oldGsm = getSearchString(oldSearchList, "gsm");
-      let newCdma = getSearchString(newSearchList, "cdma");
-      let oldCdma = getSearchString(oldSearchList, "cdma");
-
-      return (newGsm == oldGsm) && (newCdma == oldCdma);
-    }
-
-    if (isEqual(newSearchList, this._cellBroadcastSearchList)) {
+    if ((newSearchList == this._cellBroadcastSearchList) ||
+          (newSearchList && this._cellBroadcastSearchList &&
+            newSearchList.gsm == this._cellBroadcastSearchList.gsm &&
+            newSearchList.cdma == this._cellBroadcastSearchList.cdma)) {
       return;
     }
 
     this.workerMessenger.send("setCellBroadcastSearchList",
                               { searchList: newSearchList },
                               (function callback(response) {
       if (!response.success) {
         let lock = gSettingsService.createLock();
@@ -2642,25 +2576,17 @@ RadioInterface.prototype = {
       return;
     }
     this.rilContext.detailedRadioState = state;
     gMessageManager.sendMobileConnectionMessage("RIL:RadioStateChanged",
                                                 this.clientId, state);
   },
 
   setDataRegistration: function(attach) {
-    let deferred = Promise.defer();
-    this.workerMessenger.send("setDataRegistration",
-                              {attach: attach},
-                              (function(response) {
-      // Always resolve to proceed with the following steps.
-      deferred.resolve(response.errorMsg ? response.errorMsg : null);
-    }).bind(this));
-
-    return deferred.promise;
+    this.workerMessenger.send("setDataRegistration", {attach: attach});
   },
 
   /**
    * TODO: Bug 911713 - B2G NetworkManager: Move policy control logic to
    *                    NetworkManager
    */
   updateRILNetworkInterface: function() {
     let connHandler = gDataConnectionManager.getConnectionHandler(this.clientId);
@@ -4398,22 +4324,16 @@ DataCall.prototype = {
   timer: null,
 
   // APN failed connections. Retry counter
   apnRetryCounter: 0,
 
   // Array to hold RILNetworkInterfaces that requested this DataCall.
   requestedNetworkIfaces: null,
 
-  // Holds the pdp type sent to ril worker.
-  pdptype: null,
-
-  // Holds the authentication type sent to ril worker.
-  chappap: null,
-
   dataCallError: function(message) {
     if (DEBUG) this.debug("Data call error on APN: " + message.apn);
     this.state = RIL.GECKO_NETWORK_STATE_DISCONNECTED;
     this.retry();
   },
 
   dataCallStateChanged: function(datacall) {
     if (DEBUG) {
@@ -4522,42 +4442,31 @@ DataCall.prototype = {
       if (this.requestedNetworkIfaces[i].type == type) {
         return true;
       }
     }
     return false;
   },
 
   canHandleApn: function(apnSetting) {
-    let isIdentical = this.apnProfile.apn == apnSetting.apn &&
-                      (this.apnProfile.user || '') == (apnSetting.user || '') &&
-                      (this.apnProfile.password || '') == (apnSetting.password || '') &&
-                      (this.apnProfile.authType || '') == (apnSetting.authtype || '');
-
-    if (RILQUIRKS_HAVE_IPV6) {
-      isIdentical = isIdentical &&
-                    (this.apnProfile.protocol || '') == (apnSetting.protocol || '') &&
-                    (this.apnProfile.roaming_protocol || '') == (apnSetting.roaming_protocol || '');
-    }
-
-    return isIdentical;
+    // TODO: compare authtype?
+    return (this.apnProfile.apn == apnSetting.apn &&
+            (this.apnProfile.user || '') == (apnSetting.user || '') &&
+            (this.apnProfile.password || '') == (apnSetting.password || ''));
   },
 
   reset: function() {
     this.linkInfo.cid = null;
     this.linkInfo.ifname = null;
     this.linkInfo.ips = [];
     this.linkInfo.prefixLengths = [];
     this.linkInfo.dnses = [];
     this.linkInfo.gateways = [];
 
     this.state = RIL.GECKO_NETWORK_STATE_UNKNOWN;
-
-    this.chappap = null;
-    this.pdptype = null;
   },
 
   connect: function(networkInterface) {
     if (DEBUG) this.debug("connect: " + networkInterface.type);
 
     if (this.requestedNetworkIfaces.indexOf(networkInterface) == -1) {
       this.requestedNetworkIfaces.push(networkInterface);
     }
@@ -4590,42 +4499,38 @@ DataCall.prototype = {
     let dataInfo = radioInterface.rilContext.data;
     if (dataInfo.state != RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED ||
         dataInfo.type == RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN) {
       return;
     }
 
     let radioTechType = dataInfo.type;
     let radioTechnology = RIL.GECKO_RADIO_TECH.indexOf(radioTechType);
-    let authType = RIL.RIL_DATACALL_AUTH_TO_GECKO.indexOf(this.apnProfile.authType);
+    let authType = RIL.RIL_DATACALL_AUTH_TO_GECKO.indexOf(this.apnProfile.authtype);
     // Use the default authType if the value in database is invalid.
     // For the case that user might not select the authentication type.
     if (authType == -1) {
       if (DEBUG) {
         this.debug("Invalid authType " + this.apnProfile.authtype);
       }
       authType = RIL.RIL_DATACALL_AUTH_TO_GECKO.indexOf(RIL.GECKO_DATACALL_AUTH_DEFAULT);
     }
-    this.chappap = authType;
-
     let pdpType = RIL.GECKO_DATACALL_PDP_TYPE_IP;
     if (RILQUIRKS_HAVE_IPV6) {
       pdpType = !radioInterface.rilContext.data.roaming
               ? this.apnProfile.protocol
               : this.apnProfile.roaming_protocol;
       if (RIL.RIL_DATACALL_PDP_TYPES.indexOf(pdpType) < 0) {
         if (DEBUG) {
           this.debug("Invalid pdpType '" + pdpType + "', using '" +
                      RIL.GECKO_DATACALL_PDP_TYPE_DEFAULT + "'");
         }
         pdpType = RIL.GECKO_DATACALL_PDP_TYPE_DEFAULT;
       }
     }
-    this.pdptype = pdpType;
-
     radioInterface.sendWorkerMessage("setupDataCall", {
       radioTech: radioTechnology,
       apn: this.apnProfile.apn,
       user: this.apnProfile.user,
       passwd: this.apnProfile.password,
       chappap: authType,
       pdptype: pdpType
     });
--- a/dom/system/gonk/android_audio/AudioSystem.h
+++ b/dom/system/gonk/android_audio/AudioSystem.h
@@ -55,19 +55,16 @@ typedef enum {
 } audio_policy_forced_cfg_t;
 
 /* usages used for audio_policy->set_force_use() */
 typedef enum {
     AUDIO_POLICY_FORCE_FOR_COMMUNICATION,
     AUDIO_POLICY_FORCE_FOR_MEDIA,
     AUDIO_POLICY_FORCE_FOR_RECORD,
     AUDIO_POLICY_FORCE_FOR_DOCK,
-    AUDIO_POLICY_FORCE_FOR_SYSTEM,
-
-    AUDIO_POLICY_FORCE_FOR_PROPRIETARY,
 
     AUDIO_POLICY_FORCE_USE_CNT,
     AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1,
 } audio_policy_force_use_t;
 
 typedef enum {
     AUDIO_STREAM_DEFAULT          = -1,
     AUDIO_STREAM_VOICE_CALL       = 0,
@@ -393,17 +390,16 @@ enum {
     AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x200,
     AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x400,
     AUDIO_DEVICE_IN_USB_ACCESSORY         = AUDIO_DEVICE_BIT_IN | 0x800,
     AUDIO_DEVICE_IN_USB_DEVICE            = AUDIO_DEVICE_BIT_IN | 0x1000,
     AUDIO_DEVICE_IN_ANC_HEADSET           = AUDIO_DEVICE_BIT_IN | 0x2000,
     AUDIO_DEVICE_IN_PROXY                 = AUDIO_DEVICE_BIT_IN | 0x4000,
     AUDIO_DEVICE_IN_FM_RX                 = AUDIO_DEVICE_BIT_IN | 0x8000,
     AUDIO_DEVICE_IN_FM_RX_A2DP            = AUDIO_DEVICE_BIT_IN | 0x10000,
-    AUDIO_DEVICE_IN_FM                    = AUDIO_DEVICE_BIT_IN | 0x1000000,
     AUDIO_DEVICE_IN_DEFAULT               = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT,
 
     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 |
@@ -839,17 +835,16 @@ public:
     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_devices_t getDevicesForStream(audio_stream_type_t stream);
 
     static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
     static status_t registerEffect(effect_descriptor_t *desc,
                                     audio_io_handle_t output,
                                     uint32_t strategy,
                                     int session,
                                     int id);
     static status_t unregisterEffect(int id);
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -483,32 +483,24 @@ this.TOA_UNKNOWN = 0x81;
 this.CALL_PRESENTATION_ALLOWED = 0;
 this.CALL_PRESENTATION_RESTRICTED = 1;
 this.CALL_PRESENTATION_UNKNOWN = 2;
 this.CALL_PRESENTATION_PAYPHONE = 3;
 
 // Call forwarding actions, see TS 27.007 7.11 "mode"
 this.CALL_FORWARD_ACTION_QUERY_STATUS = 2;
 
-this.GECKO_PHONE_STATE_IDLE = "idle";
-this.GECKO_PHONE_STATE_RINGING = "ringing";
-this.GECKO_PHONE_STATE_INCALL = "incall";
-
 // ICC commands, see TS 27.007 +CRSM commands
 this.ICC_COMMAND_SEEK = 0xa2;
 this.ICC_COMMAND_READ_BINARY = 0xb0;
 this.ICC_COMMAND_READ_RECORD = 0xb2;
 this.ICC_COMMAND_GET_RESPONSE = 0xc0;
 this.ICC_COMMAND_UPDATE_BINARY = 0xd6;
 this.ICC_COMMAND_UPDATE_RECORD = 0xdc;
 
-// CPHS SIM constants
-this.ICC_EF_ONS = 0x6f14;
-this.ICC_EF_ONSF = 0x6f18;
-
 // ICC constants, GSM SIM file ids from TS 51.011
 this.ICC_EF_ICCID  = 0x2fe2;
 this.ICC_EF_IMG    = 0x4f20;
 this.ICC_EF_PBR    = 0x4f30;
 this.ICC_EF_PLMNsel = 0x6f30; // PLMN for SIM
 this.ICC_EF_SST    = 0x6f38;
 this.ICC_EF_UST    = 0x6f38; // For USIM
 this.ICC_EF_ADN    = 0x6f3a;
@@ -1228,22 +1220,21 @@ this.STK_SUPPORTED_TERMINAL_PROFILE = [
   0x00, // 16, Screen effects
   0x00, // 17, BIP supported transport interface
   0x00, // 18, RFU
   0x00, // 19, RFU
   0x00, // 20, RFU
 ];
 
 /**
- * ICC Services Table.
+ * (U)SIM Services.
  *
  * @see 3GPP TS 51.011 10.3.7 (SIM) and 3GPP TS 31.102 4.2.8 (USIM).
  */
 this.GECKO_ICC_SERVICES = {
-  // @see 3GPP TS 51.011 10.3.7 (SIM).
   sim: {
     ADN: 2,
     FDN: 3,
     PLMNSEL: 7,
     MSISDN: 9,
     CBMI: 14,
     SPN: 17,
     SDN: 18,
@@ -1252,38 +1243,35 @@ this.GECKO_ICC_SERVICES = {
     CBMIR: 30,
     BDN: 31,
     PNN: 51,
     OPL: 52,
     MDN: 53,
     MWIS: 54,
     SPDI: 56
   },
-  // @see 3GPP TS 31.102 4.2.8 (USIM).
   usim: {
     FDN: 2,
     SDN: 4,
     BDN: 6,
     CBMI: 15,
     CBMIR: 16,
     SPN: 19,
     MSISDN: 21,
     DATA_DOWNLOAD_SMS_PP: 28,
     DATA_DOWNLOAD_SMS_CB: 29,
     PNN: 45,
     OPL: 46,
     MDN: 47,
     MWIS: 48,
     SPDI: 51
   },
-  // @see 3GPP2 C.S0023-D 3.4.18 (RUIM).
   ruim: {
     ENHANCED_PHONEBOOK: 6,
-    SPN: 17,
-    SDN: 18
+    SPN: 17
   }
 };
 
 /**
  * Cell Broadcast constants
  */
 
 this.CB_FORMAT_GSM  = 0;
@@ -2420,85 +2408,35 @@ this.DATACALL_FAIL_ERROR_UNSPECIFIED = 0
 
 // Keep consistent with nsINetworkManager.NETWORK_STATE_*.
 this.GECKO_NETWORK_STATE_UNKNOWN = -1;
 this.GECKO_NETWORK_STATE_CONNECTING = 0;
 this.GECKO_NETWORK_STATE_CONNECTED = 1;
 this.GECKO_NETWORK_STATE_DISCONNECTING = 2;
 this.GECKO_NETWORK_STATE_DISCONNECTED = 3;
 
-// 3GPP 24.008 Annex H.
 this.CALL_FAIL_UNOBTAINABLE_NUMBER = 1;
-this.CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3;
-this.CALL_FAIL_CHANNEL_UNACCEPTABLE = 6;
-this.CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8;
 this.CALL_FAIL_NORMAL = 16;
 this.CALL_FAIL_BUSY = 17;
 this.CALL_FAIL_NO_USER_RESPONDING = 18;
 this.CALL_FAIL_USER_ALERTING = 19;
 this.CALL_FAIL_CALL_REJECTED = 21;
 this.CALL_FAIL_NUMBER_CHANGED = 22;
-this.CALL_FAIL_CALL_REJECTED_DESTINATION_FEATURE = 24;
 this.CALL_FAIL_CALL_PRE_EMPTION = 25;
 this.CALL_FAIL_DEST_OUT_OF_ORDER = 27;
 this.CALL_FAIL_INVALID_FORMAT = 28;
 this.CALL_FAIL_FACILITY_REJECTED = 29;
-this.CALL_FAIL_RESPONSE_TO_STATUS_ENQUIRY = 30;
-this.CALL_FAIL_NORMAL_UNSPECIFIED = 31;
 this.CALL_FAIL_CONGESTION = 34;
 this.CALL_FAIL_NETWORK_OUT_OF_ORDER = 38;
 this.CALL_FAIL_NETWORK_TEMP_FAILURE = 41;
-this.CALL_FAIL_SWITCHING_EQUIP_CONGESTION = 42;
-this.CALL_FAIL_ACCESS_INFO_DISCARDED = 43;
-this.CALL_FAIL_REQUESTED_CHANNEL_NOT_AVAILABLE = 44;
-this.CALL_FAIL_RESOURCE_UNAVAILABLE = 47;
-this.CALL_FAIL_QOS_UNAVAILABLE = 49;
-this.CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50;
-this.CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55;
-this.CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57;
-this.CALL_FAIL_BEARER_CAPABILITY_NOT_AVAILABLE = 58;
-this.CALL_FAIL_SERVICE_NOT_AVAILABLE = 63;
-this.CALL_FAIL_BEARER_NOT_IMPLEMENTED = 65;
 this.CALL_FAIL_ACM_LIMIT_EXCEEDED = 68;
-this.CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69;
-this.CALL_FAIL_UNRESTRICTED_BEARER_NOT_AVAILABLE = 70;
-this.CALL_FAIL_SERVICE_NOT_IMPLEMENTED = 79;
-this.CALL_FAIL_INVALID_TRANSACTION_ID = 81;
-this.CALL_FAIL_USER_NOT_CUG_MEMBER = 87;
-this.CALL_FAIL_INCOMPATIBLE_DESTINATION = 88;
-this.CALL_FAIL_INVALID_TRANSIT_NETWORK_SELECTION = 91;
-this.CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95;
-this.CALL_FAIL_INVALID_MANDATORY_INFO = 96;
-this.CALL_FAIL_MESSAGE_TYPE_NOT_IMPLEMENTED = 97;
-this.CALL_FAIL_MESSAGE_TYPE_INCOMPATIBLE_PROTOCOL_STATE = 98;
-this.CALL_FAIL_INFO_ELEMENT_NOT_IMPLEMENTED = 99;
-this.CALL_FAIL_CONDITIONAL_IE_ERROR = 100;
-this.CALL_FAIL_MESSAGE_INCOMPABITLE_PROTOCOL_STATE = 101;
-this.CALL_FAIL_RECOVERY_ON_TIMER_EXPIRY = 102;
-this.CALL_FAIL_PROTOCOL_ERROR = 111;
-this.CALL_FAIL_INTERWORKING = 127;
-// AOSP ril.h
 this.CALL_FAIL_CALL_BARRED = 240;
 this.CALL_FAIL_FDN_BLOCKED = 241;
 this.CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242;
 this.CALL_FAIL_IMEI_NOT_ACCEPTED = 243;
-this.CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244; // STK Call Control
-this.CALL_FAIL_DIAL_MODIFIED_TO_SS = 245;
-this.CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246;
-this.CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000;
-this.CALL_FAIL_CDMA_DROP = 1001;
-this.CALL_FAIL_CDMA_INTERCEPT = 1002;
-this.CALL_FAIL_CDMA_REORDER = 1003;
-this.CALL_FAIL_CDMA_SO_REJECT = 1004;
-this.CALL_FAIL_CDMA_RETRY_ORDER = 1005;
-this.CALL_FAIL_CDMA_ACCESS_FAILURE = 1006;
-this.CALL_FAIL_CDMA_PREEMPTED = 1007;
-this.CALL_FAIL_CDMA_NOT_EMERGENCY = 1008; // For non-emergency number dialed
-                                          // during emergency callback mode
-this.CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009;
 this.CALL_FAIL_ERROR_UNSPECIFIED = 0xffff;
 
 // Other Gecko-specific constants
 this.GECKO_RADIOSTATE_UNAVAILABLE   = null;
 this.GECKO_RADIOSTATE_OFF           = "off";
 this.GECKO_RADIOSTATE_READY         = "ready";
 
 this.GECKO_DETAILED_RADIOSTATE_UNKNOWN    = null;
@@ -2625,149 +2563,58 @@ NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_UNKNOWN] = GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_REGISTERED_ROAMING] = GECKO_MOBILE_CONNECTION_STATE_REGISTERED;
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_NOT_SEARCHING_EMERGENCY_CALLS] = GECKO_MOBILE_CONNECTION_STATE_NOTSEARCHING;
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_SEARCHING_EMERGENCY_CALLS] = GECKO_MOBILE_CONNECTION_STATE_SEARCHING;
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_DENIED_EMERGENCY_CALLS] = GECKO_MOBILE_CONNECTION_STATE_DENIED;
 NETWORK_CREG_TO_GECKO_MOBILE_CONNECTION_STATE[NETWORK_CREG_STATE_UNKNOWN_EMERGENCY_CALLS] = GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
 
 
-this.GECKO_CALL_ERROR_BAD_NUMBER = "BadNumberError";
-this.GECKO_CALL_ERROR_NO_ROUTE_TO_DESTINATION = "NoRouteToDestinationError";
-this.GECKO_CALL_ERROR_CHANNEL_UNACCEPTABLE = "ChannelUnacceptableError";
-this.GECKO_CALL_ERROR_OPERATOR_DETERMINED_BARRING = "OperatorDeterminedBarringError";
-this.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING = "NormalCallClearingError";
-this.GECKO_CALL_ERROR_BUSY = "BusyError";
-this.GECKO_CALL_ERROR_NO_USER_RESPONDING = "NoUserRespondingError";
-this.GECKO_CALL_ERROR_USER_ALERTING = "UserAlertingNoAnswerError";
-this.GECKO_CALL_ERROR_REJECTED = "CallRejectedError";
-this.GECKO_CALL_ERROR_NUMBER_CHANGED = "NumberChangedError";
-this.GECKO_CALL_ERROR_REJECTED_DETINATION_FEATURE = "CallRejectedDestinationFeature";
-this.GECKO_CALL_ERROR_PRE_EMPTION = "PreEmptionError";
-this.GECKO_CALL_ERROR_DEST_OUT_OF_ORDER = "DestinationOutOfOrderError";
-this.GECKO_CALL_ERROR_INVALID_NUMBER_FORMAT = "InvalidNumberFormatError";
-this.GECKO_CALL_ERROR_FACILITY_REJECTED = "FacilityRejectedError";
-this.GECKO_CALL_ERROR_RESPONSE_TO_STATUS_ENQUIRY = "ResponseToStatusEnquiryError";
-this.GECKO_CALL_ERROR_CONGESTION = "CongestionError";
-this.GECKO_CALL_ERROR_NETWORK_OUT_OF_ORDER = "NetworkOutOfOrderError";
-this.GECKO_CALL_ERROR_NETWORK_TEMP_FAILURE = "NetworkTempFailureError";
-this.GECKO_CALL_ERROR_SWITCHING_EQUIP_CONGESTION = "SwitchingEquipCongestionError";
-this.GECKO_CALL_ERROR_ACCESS_INFO_DISCARDED = "AccessInfoDiscardedError";
-this.GECKO_CALL_ERROR_REQUESTED_CHANNEL_NOT_AVAILABLE = "RequestedChannelNotAvailableError";
-this.GECKO_CALL_ERROR_RESOURCE_UNAVAILABLE = "ResourceUnavailableError";
-this.GECKO_CALL_ERROR_QOS_UNAVAILABLE = "QosUnavailableError";
-this.GECKO_CALL_ERROR_REQUESTED_FACILITY_NOT_SUBSCRIBED = "RequestedFacilityNotSubscribedError";
-this.GECKO_CALL_ERROR_INCOMING_CALLS_BARRED_WITHIN_CUG = "IncomingCallsBarredWithinCugError";
-this.GECKO_CALL_ERROR_BEARER_CAPABILITY_NOT_AUTHORIZED = "BearerCapabilityNotAuthorizedError";
-this.GECKO_CALL_ERROR_BEARER_CAPABILITY_NOT_AVAILABLE = "BearerCapabilityNotAvailableError";
-this.GECKO_CALL_ERROR_BEARER_NOT_IMPLEMENTED = "BearerNotImplementedError";
-this.GECKO_CALL_ERROR_SERVICE_NOT_AVAILABLE = "ServiceNotAvailableError";
+this.GECKO_CALL_ERROR_BAD_NUMBER             = "BadNumberError";
+this.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING   = "NormalCallClearingError";
+this.GECKO_CALL_ERROR_BUSY                   = "BusyError";
+this.GECKO_CALL_ERROR_NO_USER_RESPONDING     = "NoUserRespondingError";
+this.GECKO_CALL_ERROR_USER_ALERTING          = "UserAlertingNoAnswerError";
+this.GECKO_CALL_ERROR_REJECTED               = "CallRejectedError";
+this.GECKO_CALL_ERROR_NUMBER_CHANGED         = "NumberChangedError";
+this.GECKO_CALL_ERROR_PRE_EMPTION            = "PreEmptionError";
+this.GECKO_CALL_ERROR_DEST_OUT_OF_ORDER      = "DestinationOutOfOrderError";
+this.GECKO_CALL_ERROR_INVALID_NUMBER_FORMAT  = "InvalidNumberFormatError";
+this.GECKO_CALL_ERROR_FACILITY_REJECTED      = "FacilityRejectedError";
+this.GECKO_CALL_ERROR_CONGESTION             = "CongestionError";
+this.GECKO_CALL_ERROR_NETWORK_OUT_OF_ORDER   = "NetworkOutOfOrderError";
+this.GECKO_CALL_ERROR_NETWORK_TEMP_FAILURE   = "NetworkTempFailureError";
 this.GECKO_CALL_ERROR_INCOMING_CALL_EXCEEDED = "IncomingCallExceededError";
-this.GECKO_CALL_ERROR_REQUESTED_FACILITY_NOT_IMPLEMENTED = "RequestedFacilityNotImplementedError";
-this.GECKO_CALL_ERROR_UNRESTRICTED_BEARER_NOT_AVAILABLE = "UnrestrictedBearerNotAvailableError";
-this.GECKO_CALL_ERROR_SERVICE_NOT_IMPLEMENTED = "ServiceNotImplementedError";
-this.GECKO_CALL_ERROR_INVALID_TRANSACTION_ID = "InvalidTransactionIdError";
-this.GECKO_CALL_ERROR_USER_NOT_CUG_MEMBER = "NotCugMemberError";
-this.GECKO_CALL_ERROR_INCOMPATIBLE_DESTINATION = "IncompatibleDestinationError";
-this.GECKO_CALL_ERROR_INVALID_TRANSIT_NETWORK_SELECTION = "InvalidTransitNetworkSelectionError";
-this.GECKO_CALL_ERROR_SEMANTICALLY_INCORRECT_MESSAGE = "SemanticallyIncorrectMessageError";
-this.GECKO_CALL_ERROR_INVALID_MANDATORY_INFO = "InvalidMandatoryInfoError";
-this.GECKO_CALL_ERROR_MESSAGE_TYPE_NOT_IMPLEMENTED = "MessageTypeNotImplementedError";
-this.GECKO_CALL_ERROR_MESSAGE_TYPE_INCOMPATIBLE_PROTOCOL_STATE = "MessageTypeIncompatibleProtocolStateError";
-this.GECKO_CALL_ERROR_INFO_ELEMENT_NOT_IMPLEMENTED = "InfoElementNotImplementedError";
-this.GECKO_CALL_ERROR_CONDITIONAL_IE = "ConditionalIeError";
-this.GECKO_CALL_ERROR_MESSAGE_INCOMPATIBLE_PROTOCOL_STATE = "MessageIncompatibleProtocolStateError";
-this.GECKO_CALL_ERROR_RECOVERY_ON_TIMER_EXPIRY = "RecoveryOnTimerExpiryError";
-this.GECKO_CALL_ERROR_PROTOCOL = "ProtocolError";
-this.GECKO_CALL_ERROR_INTERWORKING = "InterworkingError";
-this.GECKO_CALL_ERROR_BARRED = "BarredError";
-this.GECKO_CALL_ERROR_FDN_BLOCKED = "FDNBlockedError";
-this.GECKO_CALL_ERROR_SUBSCRIBER_UNKNOWN = "SubscriberUnknownError";
-this.GECKO_CALL_ERROR_DEVICE_NOT_ACCEPTED = "DeviceNotAcceptedError";
-this.GECKO_CALL_ERROR_MODIFIED_TO_DIAL_FAILED = "ModifiedDialError";
-this.GECKO_CALL_ERROR_CDMA_LOCKED_UNTIL_POWER_CYCLE = "CdmaLockedUntilPowerCycleError";
-this.GECKO_CALL_ERROR_CDMA_DROP = "CdmaDropError";
-this.GECKO_CALL_ERROR_CDMA_INTERCEPT = "CdmaInterceptError";
-this.GECKO_CALL_ERROR_CDMA_REORDER = "CdmaReorderError";
-this.GECKO_CALL_ERROR_CDMA_SO_REJECT = "CdmaSoRejectError";
-this.GECKO_CALL_ERROR_CDMA_RETRY_ORDER = "CdmaRetryOrderError";
-this.GECKO_CALL_ERROR_CDMA_ACCESS_FAILURE = "CdmaAcessError";
-this.GECKO_CALL_ERROR_CDMA_PREEMPTED = "CdmaPreemptedError";
-this.GECKO_CALL_ERROR_CDMA_NOT_EMERGENCY = "CdmaNotEmergencyError";
-this.GECKO_CALL_ERROR_CDMA_ACCESS_BLOCKED = "CdmaAccessBlockedError";
-this.GECKO_CALL_ERROR_UNSPECIFIED = "UnspecifiedError";
+this.GECKO_CALL_ERROR_BARRED                 = "BarredError";
+this.GECKO_CALL_ERROR_FDN_BLOCKED            = "FDNBlockedError";
+this.GECKO_CALL_ERROR_SUBSCRIBER_UNKNOWN     = "SubscriberUnknownError";
+this.GECKO_CALL_ERROR_DEVICE_NOT_ACCEPTED    = "DeviceNotAcceptedError";
+this.GECKO_CALL_ERROR_UNSPECIFIED            = "UnspecifiedError";
 
 this.RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR = {};
 RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_UNOBTAINABLE_NUMBER] = GECKO_CALL_ERROR_BAD_NUMBER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NO_ROUTE_TO_DESTINATION] = GECKO_CALL_ERROR_NO_ROUTE_TO_DESTINATION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CHANNEL_UNACCEPTABLE] = GECKO_CALL_ERROR_CHANNEL_UNACCEPTABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_OPERATOR_DETERMINED_BARRING] = GECKO_CALL_ERROR_OPERATOR_DETERMINED_BARRING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NORMAL] = GECKO_CALL_ERROR_NORMAL_CALL_CLEARING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BUSY] = GECKO_CALL_ERROR_BUSY;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NO_USER_RESPONDING] = GECKO_CALL_ERROR_NO_USER_RESPONDING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_USER_ALERTING] = GECKO_CALL_ERROR_USER_ALERTING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_REJECTED] = GECKO_CALL_ERROR_REJECTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NUMBER_CHANGED] = GECKO_CALL_ERROR_NUMBER_CHANGED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_REJECTED_DESTINATION_FEATURE] = GECKO_CALL_ERROR_REJECTED_DETINATION_FEATURE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_PRE_EMPTION] = GECKO_CALL_ERROR_PRE_EMPTION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_DEST_OUT_OF_ORDER] = GECKO_CALL_ERROR_DEST_OUT_OF_ORDER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INVALID_FORMAT] = GECKO_CALL_ERROR_INVALID_NUMBER_FORMAT;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_FACILITY_REJECTED] = GECKO_CALL_ERROR_FACILITY_REJECTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_RESPONSE_TO_STATUS_ENQUIRY] = GECKO_CALL_ERROR_RESPONSE_TO_STATUS_ENQUIRY;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NORMAL_UNSPECIFIED] = GECKO_CALL_ERROR_NORMAL_CALL_CLEARING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CONGESTION] = GECKO_CALL_ERROR_CONGESTION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NETWORK_OUT_OF_ORDER] = GECKO_CALL_ERROR_NETWORK_OUT_OF_ORDER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NETWORK_TEMP_FAILURE] = GECKO_CALL_ERROR_NETWORK_TEMP_FAILURE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_SWITCHING_EQUIP_CONGESTION] = GECKO_CALL_ERROR_SWITCHING_EQUIP_CONGESTION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_ACCESS_INFO_DISCARDED] = GECKO_CALL_ERROR_ACCESS_INFO_DISCARDED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_REQUESTED_CHANNEL_NOT_AVAILABLE] = GECKO_CALL_ERROR_REQUESTED_CHANNEL_NOT_AVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_RESOURCE_UNAVAILABLE] = GECKO_CALL_ERROR_RESOURCE_UNAVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_QOS_UNAVAILABLE] = GECKO_CALL_ERROR_QOS_UNAVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED] = GECKO_CALL_ERROR_REQUESTED_FACILITY_NOT_SUBSCRIBED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG] = GECKO_CALL_ERROR_INCOMING_CALLS_BARRED_WITHIN_CUG;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED] = GECKO_CALL_ERROR_BEARER_CAPABILITY_NOT_AUTHORIZED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BEARER_CAPABILITY_NOT_AVAILABLE] = GECKO_CALL_ERROR_BEARER_CAPABILITY_NOT_AVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_SERVICE_NOT_AVAILABLE] = GECKO_CALL_ERROR_SERVICE_NOT_AVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BEARER_NOT_IMPLEMENTED] = GECKO_CALL_ERROR_BEARER_NOT_IMPLEMENTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_ACM_LIMIT_EXCEEDED] = GECKO_CALL_ERROR_INCOMING_CALL_EXCEEDED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED] = GECKO_CALL_ERROR_REQUESTED_FACILITY_NOT_IMPLEMENTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_UNRESTRICTED_BEARER_NOT_AVAILABLE] = GECKO_CALL_ERROR_UNRESTRICTED_BEARER_NOT_AVAILABLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_SERVICE_NOT_IMPLEMENTED] = GECKO_CALL_ERROR_SERVICE_NOT_IMPLEMENTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INVALID_TRANSACTION_ID] = GECKO_CALL_ERROR_INVALID_TRANSACTION_ID;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_USER_NOT_CUG_MEMBER] = GECKO_CALL_ERROR_USER_NOT_CUG_MEMBER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INCOMPATIBLE_DESTINATION] = GECKO_CALL_ERROR_INCOMPATIBLE_DESTINATION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INVALID_TRANSIT_NETWORK_SELECTION] = GECKO_CALL_ERROR_INVALID_TRANSIT_NETWORK_SELECTION;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE] = GECKO_CALL_ERROR_SEMANTICALLY_INCORRECT_MESSAGE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INVALID_MANDATORY_INFO] = GECKO_CALL_ERROR_INVALID_MANDATORY_INFO;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_MESSAGE_TYPE_NOT_IMPLEMENTED] = GECKO_CALL_ERROR_MESSAGE_TYPE_NOT_IMPLEMENTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_MESSAGE_TYPE_INCOMPATIBLE_PROTOCOL_STATE] = GECKO_CALL_ERROR_MESSAGE_TYPE_INCOMPATIBLE_PROTOCOL_STATE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INFO_ELEMENT_NOT_IMPLEMENTED] = GECKO_CALL_ERROR_INFO_ELEMENT_NOT_IMPLEMENTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CONDITIONAL_IE_ERROR] = GECKO_CALL_ERROR_CONDITIONAL_IE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_MESSAGE_INCOMPABITLE_PROTOCOL_STATE] = GECKO_CALL_ERROR_MESSAGE_INCOMPATIBLE_PROTOCOL_STATE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_RECOVERY_ON_TIMER_EXPIRY] = GECKO_CALL_ERROR_RECOVERY_ON_TIMER_EXPIRY;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_PROTOCOL_ERROR] = GECKO_CALL_ERROR_PROTOCOL;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INTERWORKING] = GECKO_CALL_ERROR_INTERWORKING;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_BARRED] = GECKO_CALL_ERROR_BARRED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_FDN_BLOCKED] = GECKO_CALL_ERROR_FDN_BLOCKED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NORMAL]              = GECKO_CALL_ERROR_NORMAL_CALL_CLEARING;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BUSY]                = GECKO_CALL_ERROR_BUSY;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NO_USER_RESPONDING]  = GECKO_CALL_ERROR_NO_USER_RESPONDING;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_USER_ALERTING]       = GECKO_CALL_ERROR_USER_ALERTING;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_REJECTED]       = GECKO_CALL_ERROR_REJECTED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NUMBER_CHANGED]      = GECKO_CALL_ERROR_NUMBER_CHANGED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_PRE_EMPTION]    = GECKO_CALL_ERROR_PRE_EMPTION;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_DEST_OUT_OF_ORDER]   = GECKO_CALL_ERROR_DEST_OUT_OF_ORDER;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_INVALID_FORMAT]      = GECKO_CALL_ERROR_INVALID_NUMBER_FORMAT;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_FACILITY_REJECTED]   = GECKO_CALL_ERROR_FACILITY_REJECTED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CONGESTION]          = GECKO_CALL_ERROR_CONGESTION;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NETWORK_OUT_OF_ORDER]= GECKO_CALL_ERROR_NETWORK_OUT_OF_ORDER;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_NETWORK_TEMP_FAILURE]= GECKO_CALL_ERROR_NETWORK_TEMP_FAILURE;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_ACM_LIMIT_EXCEEDED]  = GECKO_CALL_ERROR_INCOMING_CALL_EXCEEDED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CALL_BARRED]         = GECKO_CALL_ERROR_BARRED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_FDN_BLOCKED]         = GECKO_CALL_ERROR_FDN_BLOCKED;
 RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_IMSI_UNKNOWN_IN_VLR] = GECKO_CALL_ERROR_SUBSCRIBER_UNKNOWN;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_IMEI_NOT_ACCEPTED] = GECKO_CALL_ERROR_DEVICE_NOT_ACCEPTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_DIAL_MODIFIED_TO_USSD] = GECKO_CALL_ERROR_MODIFIED_TO_DIAL_FAILED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_DIAL_MODIFIED_TO_SS] = GECKO_CALL_ERROR_MODIFIED_TO_DIAL_FAILED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_DIAL_MODIFIED_TO_DIAL] = GECKO_CALL_ERROR_MODIFIED_TO_DIAL_FAILED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE] = GECKO_CALL_ERROR_CDMA_LOCKED_UNTIL_POWER_CYCLE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_DROP] = GECKO_CALL_ERROR_CDMA_DROP;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_INTERCEPT] = GECKO_CALL_ERROR_CDMA_INTERCEPT;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_REORDER] = GECKO_CALL_ERROR_CDMA_REORDER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_SO_REJECT] = GECKO_CALL_ERROR_CDMA_SO_REJECT;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_RETRY_ORDER] = GECKO_CALL_ERROR_CDMA_RETRY_ORDER;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_ACCESS_FAILURE] = GECKO_CALL_ERROR_CDMA_ACCESS_FAILURE;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_PREEMPTED] = GECKO_CALL_ERROR_CDMA_PREEMPTED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_NOT_EMERGENCY] = GECKO_CALL_ERROR_CDMA_NOT_EMERGENCY;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_CDMA_ACCESS_BLOCKED] = GECKO_CALL_ERROR_CDMA_ACCESS_BLOCKED;
-RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_ERROR_UNSPECIFIED] = GECKO_CALL_ERROR_UNSPECIFIED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_IMEI_NOT_ACCEPTED]   = GECKO_CALL_ERROR_DEVICE_NOT_ACCEPTED;
+RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_ERROR_UNSPECIFIED]   = GECKO_CALL_ERROR_UNSPECIFIED;
 
 this.GECKO_DATACALL_ERROR_OPERATOR_BARRED               = "OperatorBarredError";
 this.GECKO_DATACALL_ERROR_INSUFFICIENT_RESOURCES        = "InsufficientResourcesError";
 this.GECKO_DATACALL_ERROR_MISSING_UKNOWN_APN            = "MissingUnknownAPNError";
 this.GECKO_DATACALL_ERROR_UNKNOWN_PDP_ADDRESS_TYPE      = "UnknownPDPAddressTypeError";
 this.GECKO_DATACALL_ERROR_USER_AUTHENTICATION           = "UserAuthenticationError";
 this.GECKO_DATACALL_ERROR_ACTIVATION_REJECT_GGSN        = "ActivationRejectGGSNError";
 this.GECKO_DATACALL_ERROR_ACTIVATION_REJECT_UNSPECIFIED = "ActivationRejectUnspecifiedError";
@@ -2909,20 +2756,16 @@ this.MMI_SC_IMEI = "06";
 
 // MMI called line presentation service codes
 this.MMI_SC_CLIP = "30";
 this.MMI_SC_CLIR = "31";
 
 // MMI call waiting service code
 this.MMI_SC_CALL_WAITING = "43";
 
-// MMI service code for registration new password as defined in TS 22.030 6.5.4
-this.MMI_SC_CHANGE_PASSWORD = "03";
-this.MMI_ZZ_BARRING_SERVICE = "330";
-
 // MMI call barring service codes
 this.MMI_SC_BAOC = "33";
 this.MMI_SC_BAOIC = "331";
 this.MMI_SC_BAOICxH = "332";
 this.MMI_SC_BAIC = "35";
 this.MMI_SC_BAICr = "351";
 this.MMI_SC_BA_ALL = "330";
 this.MMI_SC_BA_MO = "333";
@@ -2945,35 +2788,31 @@ this.MMI_KS_SC_CALL_FORWARDING = "scCall
 this.MMI_KS_SC_CLIP = "scClip";
 this.MMI_KS_SC_CLIR = "scClir";
 this.MMI_KS_SC_PWD = "scPwd";
 this.MMI_KS_SC_CALL_WAITING = "scCallWaiting";
 this.MMI_KS_SC_PIN = "scPin";
 this.MMI_KS_SC_PIN2 = "scPin2";
 this.MMI_KS_SC_PUK = "scPuk";
 this.MMI_KS_SC_PUK2 = "scPuk2";
-this.MMI_KS_SC_CHANGE_PASSWORD = "scChangePassword";
 this.MMI_KS_SC_IMEI = "scImei";
 this.MMI_KS_SC_USSD = "scUssd";
 
 // MMI error messages key strings.
 this.MMI_ERROR_KS_ERROR = "emMmiError";
 this.MMI_ERROR_KS_NOT_SUPPORTED = "emMmiErrorNotSupported";
 this.MMI_ERROR_KS_INVALID_ACTION = "emMmiErrorInvalidAction";
 this.MMI_ERROR_KS_MISMATCH_PIN = "emMmiErrorMismatchPin";
-this.MMI_ERROR_KS_MISMATCH_PASSWORD = "emMmiErrorMismatchPassword";
 this.MMI_ERROR_KS_BAD_PIN = "emMmiErrorBadPin";
 this.MMI_ERROR_KS_BAD_PUK = "emMmiErrorBadPuk";
 this.MMI_ERROR_KS_INVALID_PIN = "emMmiErrorInvalidPin";
-this.MMI_ERROR_KS_INVALID_PASSWORD = "emMmiErrorInvalidPassword";
 this.MMI_ERROR_KS_NEEDS_PUK = "emMmiErrorNeedsPuk";
 this.MMI_ERROR_KS_SIM_BLOCKED = "emMmiErrorSimBlocked";
 
 // MMI status message.
-this.MMI_SM_KS_PASSWORD_CHANGED = "smPasswordChanged";
 this.MMI_SM_KS_PIN_CHANGED = "smPinChanged";
 this.MMI_SM_KS_PIN2_CHANGED = "smPin2Changed";
 this.MMI_SM_KS_PIN_UNBLOCKED = "smPinUnblocked";
 this.MMI_SM_KS_PIN2_UNBLOCKED = "smPin2Unblocked";
 this.MMI_SM_KS_SERVICE_ENABLED = "smServiceEnabled";
 this.MMI_SM_KS_SERVICE_ENABLED_FOR = "smServiceEnabledFor";
 this.MMI_SM_KS_SERVICE_DISABLED = "smServiceDisabled";
 this.MMI_SM_KS_SERVICE_REGISTERED = "smServiceRegistered";
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -226,17 +226,16 @@ BufObject.prototype = {
 
 const TELEPHONY_REQUESTS = [
   REQUEST_GET_CURRENT_CALLS,
   REQUEST_ANSWER,
   REQUEST_CONFERENCE,
   REQUEST_DIAL,
   REQUEST_DIAL_EMERGENCY_CALL,
   REQUEST_HANGUP,
-  REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,
   REQUEST_HANGUP_WAITING_OR_BACKGROUND,
   REQUEST_SEPARATE_CONNECTION,
   REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE,
   REQUEST_UDUB
 ];
 
 function TelephonyRequestEntry(request, action, options) {
   this.request = request;
@@ -272,16 +271,21 @@ TelephonyRequestQueue.prototype = {
     return -1;
   },
 
   _startQueue: function(queue) {
     if (queue.length === 0) {
       return;
     }
 
+    // We only need to keep one entry for queryQueue.
+    if (queue === this.queryQueue) {
+      queue.splice(1, queue.length - 1);
+    }
+
     this.currentQueue = queue;
     for (let entry of queue) {
       this._executeEntry(entry);
     }
   },
 
   _executeEntry: function(entry) {
     if (DEBUG) this.debug("execute " + this._getRequestName(entry.request));
@@ -355,17 +359,17 @@ TelephonyRequestQueue.prototype = {
  * via post messages. It maintains state about the radio, ICC, calls, etc.
  * and acts upon state changes accordingly.
  */
 function RilObject(aContext) {
   this.context = aContext;
 
   this.telephonyRequestQueue = new TelephonyRequestQueue(this);
   this.currentCalls = {};
-  this.currentConferenceState = CALL_STATE_UNKNOWN;
+  this.currentConference = {state: null, participants: {}};
   this.currentDataCalls = {};
   this._pendingSentSmsMap = {};
   this.pendingNetworkType = {};
   this._receivedSmsCbPagesMap = {};
 
   // Init properties that are only initialized once.
   this.v5Legacy = RILQUIRKS_V5_LEGACY;
   this.cellBroadcastDisabled = RIL_CELLBROADCAST_DISABLED;
@@ -382,19 +386,19 @@ RilObject.prototype = {
   v5Legacy: null,
 
   /**
    * Valid calls.
    */
   currentCalls: null,
 
   /**
-   * Call state of current conference group.
-   */
-  currentConferenceState: null,
+   * Existing conference call and its participants.
+   */
+  currentConference: null,
 
   /**
    * Existing data calls.
    */
   currentDataCalls: null,
 
   /**
    * Outgoing messages waiting for SMS-STATUS-REPORT.
@@ -559,18 +563,16 @@ RilObject.prototype = {
     };
     this.mergedCellBroadcastConfig = null;
 
     /**
      * A successful dialing request.
      * { options: options of the corresponding dialing request }
      */
     this.pendingMO = null;
-
-    this.phoneState = GECKO_PHONE_STATE_IDLE;
   },
 
   /**
    * Parse an integer from a string, falling back to a default value
    * if the the provided value is not a string or does not contain a valid
    * number.
    *
    * @param string
@@ -1130,103 +1132,16 @@ RilObject.prototype = {
         this.appType, options.contactType, contact, options.pin2, onsuccess, onerror);
     } else {
       ICCContactHelper.addICCContact(
         this.appType, options.contactType, contact, options.pin2, onsuccess, onerror);
     }
   },
 
   /**
-   * PLMN name display priority: EONS > ONS > NITZ (done by rild) > PLMN.
-   *
-   * @return true if PLMN name is overridden, false otherwise.
-   */
-  overrideNetworkName: function() {
-    if (!this.operator) {
-      return false;
-    }
-
-    if (this.overrideEonsNetworkName()) {
-      if (DEBUG) {
-        this.context.debug("Network name is overridden by EONS");
-      }
-      return true;
-    } else if (this.overrideOnsNetworkName()) {
-      if (DEBUG) {
-        this.context.debug("Network name is overridden by ONS");
-      }
-      return true;
-    }
-
-    return false;
-  },
-
-  /**
-   * Check if operator name needs to be overriden by current voiceRegistrationState
-   * , EFOPL and EFPNN. See 3GPP TS 31.102 clause 4.2.58 EFPNN and 4.2.59 EFOPL
-   *  for detail.
-   *
-   * @return true if operator name is overridden, false otherwise.
-   */
-  overrideEonsNetworkName: function() {
-    // We won't get network name using PNN and OPL if voice registration isn't
-    // ready.
-    if (!this.voiceRegistrationState.cell ||
-        this.voiceRegistrationState.cell.gsmLocationAreaCode == -1) {
-      return false;
-    }
-
-    let ICCUtilsHelper = this.context.ICCUtilsHelper;
-    let networkName = ICCUtilsHelper.getNetworkNameFromICC(
-      this.operator.mcc,
-      this.operator.mnc,
-      this.voiceRegistrationState.cell.gsmLocationAreaCode);
-
-    if (!networkName) {
-      return false;
-    }
-
-    if (DEBUG) {
-      this.context.debug("Operator names will be overriden: " +
-                         "longName = " + networkName.fullName + ", " +
-                         "shortName = " + networkName.shortName);
-    }
-
-    this.operator.longName = networkName.fullName;
-    this.operator.shortName = networkName.shortName;
-
-    this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator);
-    return true;
-  },
-
-  /**
-   * Check if operator name needs to be overriden by current voiceRegistrationState
-   * , CPHS Operator Name String and Operator Name Shortform. See B.4.1.2
-   * Network Operator Namefor detail.
-   *
-   * @return true if operator name is overridden, false otherwise.
-   */
-  overrideOnsNetworkName: function() {
-    if (!this.iccInfo.ons) {
-      return false;
-    }
-
-    // If ONS exists, only replace alpha long/short while under HPLMN.
-    if (!this.voiceRegistrationState.roaming) {
-      this.operator.longName = this.iccInfo.ons;
-      this.operator.shortName = this.iccInfo.ons_short_form || "";
-
-      this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator);
-      return true;
-    }
-
-    return false;
-  },
-
-  /**
    * Request the phone's radio to be enabled or disabled.
    *
    * @param enabled
    *        Boolean indicating the desired state.
    */
   setRadioEnabled: function(options) {
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_RADIO_POWER, options);
@@ -1593,23 +1508,23 @@ RilObject.prototype = {
     Buf.newParcel(REQUEST_SET_NETWORK_SELECTION_MANUAL, options);
     Buf.writeString(numeric);
     Buf.sendParcel();
   },
 
   /**
    * Get current calls.
    */
-  getCurrentCalls: function(options) {
+  getCurrentCalls: function() {
     this.telephonyRequestQueue.push(REQUEST_GET_CURRENT_CALLS,
-                                    this.sendRilRequestGetCurrentCalls, options);
-  },
-
-  sendRilRequestGetCurrentCalls: function(options) {
-    this.context.Buf.simpleRequest(REQUEST_GET_CURRENT_CALLS, options);
+                                    this.sendRilRequestGetCurrentCalls, null);
+  },
+
+  sendRilRequestGetCurrentCalls: function() {
+    this.context.Buf.simpleRequest(REQUEST_GET_CURRENT_CALLS);
   },
 
   /**
    * Get the signal strength.
    */
   getSignalStrength: function() {
     this.context.Buf.simpleRequest(REQUEST_SIGNAL_STRENGTH);
   },
@@ -1811,63 +1726,23 @@ RilObject.prototype = {
   sendRilRequestHangUp: function(callIndex) {
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_HANGUP);
     Buf.writeInt32(1);
     Buf.writeInt32(callIndex);
     Buf.sendParcel();
   },
 
-  sendHangUpForegroundRequest: function(options) {
-    for each (let currentCall in this.currentCalls) {
-      if (currentCall.state == CALL_STATE_ACTIVE) {
-        currentCall.hangUpLocal = true;
-      }
-    }
-
-    this.telephonyRequestQueue.push(REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,
-                                    this.sendRilRequestHangUpForeground,
-                                    options);
-  },
-
-  sendRilRequestHangUpForeground: function(options) {
-    this.context.Buf.simpleRequest(REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,
-                                   options);
-  },
-
-  sendHangUpBackgroundRequest: function(options) {
-    let waitingCalls = [];
-    let heldCalls = [];
-
-    for each (let currentCall in this.currentCalls) {
-      switch (currentCall.state) {
-        case CALL_STATE_WAITING:
-          waitingCalls.push(currentCall);
-          break;
-        case CALL_STATE_HOLDING:
-          heldCalls.push(currentCall);
-          break;
-      }
-    }
-
-    // When both a held and a waiting call exist, the request shall apply to
-    // the waiting call.
-    if (waitingCalls.length) {
-      waitingCalls.forEach(call => call.hangUpLocal = true);
-    } else {
-      heldCalls.forEach(call => call.hangUpLocal = true);
-    }
-
+  sendHangUpBackgroundRequest: function() {
     this.telephonyRequestQueue.push(REQUEST_HANGUP_WAITING_OR_BACKGROUND,
-                                    this.sendRilRequestHangUpWaiting, options);
-  },
-
-  sendRilRequestHangUpWaiting: function(options) {
-    this.context.Buf.simpleRequest(REQUEST_HANGUP_WAITING_OR_BACKGROUND,
-                                   options);
+                                   this.sendRilRequestHangUpWaiting, null);
+  },
+
+  sendRilRequestHangUpWaiting: function() {
+    this.context.Buf.simpleRequest(REQUEST_HANGUP_WAITING_OR_BACKGROUND);
   },
 
   /**
    * Mute or unmute the radio.
    *
    * @param mute
    *        Boolean to indicate whether to mute or unmute the radio.
    */
@@ -1991,21 +1866,34 @@ RilObject.prototype = {
     if (this._isCdma) {
       options.featureStr = "";
       this.sendCdmaFlashCommand(options);
     } else if (call.state == CALL_STATE_HOLDING) {
       this.sendSwitchWaitingRequest();
     }
   },
 
+  // Flag indicating whether user has requested making a conference call.
+  _hasConferenceRequest: false,
+
   conferenceCall: function(options) {
     if (this._isCdma) {
       options.featureStr = "";
       this.sendCdmaFlashCommand(options);
     } else {
+      // Only accept one conference request at a time..
+      if (this._hasConferenceRequest) {
+        options.success = false;
+        options.errorName = "addError";
+        options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
+        this.sendChromeMessage(options);
+        return;
+      }
+
+      this._hasConferenceRequest = true;
       this.telephonyRequestQueue.push(REQUEST_CONFERENCE,
                                       this.sendRilRequestConference, options);
     }
   },
 
   sendRilRequestConference: function(options) {
     this.context.Buf.simpleRequest(REQUEST_CONFERENCE, options);
   },
@@ -2033,37 +1921,16 @@ RilObject.prototype = {
   sendRilRequestSeparateConnection: function(options) {
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_SEPARATE_CONNECTION, options);
     Buf.writeInt32(1);
     Buf.writeInt32(options.callIndex);
     Buf.sendParcel();
   },
 
-  hangUpConference: function(options) {
-    if (this._isCdma) {
-      // In cdma, ril only maintains one call index.
-      let call = this.currentCalls[1];
-      if (!call) {
-        options.success = false;
-        options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
-        this.sendChromeMessage(options);
-        return;
-      }
-      call.hangUpLocal = true;
-      this.sendHangUpRequest(1);
-    } else {
-      if (this.currentConferenceState === CALL_STATE_ACTIVE) {
-        this.sendHangUpForegroundRequest(options);
-      } else {
-        this.sendHangUpBackgroundRequest(options);
-      }
-    }
-  },
-
   holdConference: function() {
     if (this._isCdma) {
       return;
     }
 
     this.sendSwitchWaitingRequest();
   },
 
@@ -2232,19 +2099,18 @@ RilObject.prototype = {
 
   setGsmSmsBroadcastConfig: function(config) {
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
 
     let numConfigs = config ? config.length / 2 : 0;
     Buf.writeInt32(numConfigs);
     for (let i = 0; i < config.length;) {
-      // convert [from, to) to [from, to - 1]
       Buf.writeInt32(config[i++]);
-      Buf.writeInt32(config[i++] - 1);
+      Buf.writeInt32(config[i++]);
       Buf.writeInt32(0x00);
       Buf.writeInt32(0xFF);
       Buf.writeInt32(1);
     }
 
     Buf.sendParcel();
   },
 
@@ -2449,17 +2315,17 @@ RilObject.prototype = {
    *        Boolean value indicating attach or detach.
    */
   setDataRegistration: function(options) {
     this._attachDataRegistration = options.attach;
 
     if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND) {
       let request = options.attach ? RIL_REQUEST_GPRS_ATTACH :
                                      RIL_REQUEST_GPRS_DETACH;
-      this.context.Buf.simpleRequest(request, options);
+      this.context.Buf.simpleRequest(request);
     } else if (RILQUIRKS_SUBSCRIPTION_CONTROL && options.attach) {
       this.context.Buf.simpleRequest(REQUEST_SET_DATA_SUBSCRIPTION, options);
     }
   },
 
   /**
    * Get failure casue code for the most recently failed PDP context.
    */
@@ -2634,43 +2500,16 @@ RilObject.prototype = {
           mmi.sic.length < 4 || mmi.sic.length > 8) {
         _sendMMIError(MMI_ERROR_KS_INVALID_PIN, mmiServiceCode);
         return false;
       }
 
       return true;
     }
 
-    function _isValidChangePasswordRequest(mmiServiceCode) {
-      if (mmi.procedure !== MMI_PROCEDURE_REGISTRATION &&
-          mmi.procedure !== MMI_PROCEDURE_ACTIVATION) {
-        _sendMMIError(MMI_ERROR_KS_INVALID_ACTION, mmiServiceCode);
-        return false;
-      }
-
-      if (mmi.sia !== "" && mmi.sia !== MMI_ZZ_BARRING_SERVICE) {
-        _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED, mmiServiceCode);
-        return false;
-      }
-
-      let validPassword = si => /^[0-9]{4}$/.test(si);
-      if (!validPassword(mmi.sib) || !validPassword(mmi.sic) ||
-          !validPassword(mmi.pwd)) {
-        _sendMMIError(MMI_ERROR_KS_INVALID_PASSWORD, mmiServiceCode);
-        return false;
-      }
-
-      if (mmi.sic != mmi.pwd) {
-        _sendMMIError(MMI_ERROR_KS_MISMATCH_PASSWORD, mmiServiceCode);
-        return false;
-      }
-
-      return true;
-    }
-
     let _isRadioAvailable = (function(mmiServiceCode) {
       if (this.radioState !== GECKO_RADIOSTATE_READY) {
         _sendMMIError(GECKO_ERROR_RADIO_NOT_AVAILABLE, mmiServiceCode);
         return false;
       }
       return true;
     }).bind(this);
 
@@ -2839,29 +2678,16 @@ RilObject.prototype = {
           default:
             _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED, MMI_KS_SC_CLIR);
             return;
         }
         options.isSetCLIR = true;
         this.setCLIR(options);
         return;
 
-      // Change call barring password
-      case MMI_SC_CHANGE_PASSWORD:
-        if (!_isRadioAvailable(MMI_KS_SC_CHANGE_PASSWORD) ||
-            !_isValidChangePasswordRequest(MMI_KS_SC_CHANGE_PASSWORD)) {
-          return;
-        }
-
-        options.mmiServiceCode = MMI_KS_SC_CHANGE_PASSWORD;
-        options.pin = mmi.sib;
-        options.newPin = mmi.sic;
-        this.changeCallBarringPassword(options);
-        return;
-
       // Call barring
       case MMI_SC_BAOC:
       case MMI_SC_BAOIC:
       case MMI_SC_BAOICxH:
       case MMI_SC_BAIC:
       case MMI_SC_BAICr:
       case MMI_SC_BA_ALL:
       case MMI_SC_BA_MO:
@@ -3086,17 +2912,16 @@ RilObject.prototype = {
   },
 
   /**
    * Send STK terminal response.
    *
    * @param command
    * @param deviceIdentities
    * @param resultCode
-   * @param [optional] additionalInformation
    * @param [optional] itemIdentifier
    * @param [optional] input
    * @param [optional] isYesNo
    * @param [optional] hasConfirmed
    * @param [optional] localInfo
    * @param [optional] timer
    */
   sendStkTerminalResponse: function(response) {
@@ -3142,69 +2967,75 @@ RilObject.prototype = {
     GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_DEVICE_ID);
     GsmPDUHelper.writeHexOctet(2);
     GsmPDUHelper.writeHexOctet(STK_DEVICE_ID_ME);
     GsmPDUHelper.writeHexOctet(STK_DEVICE_ID_SIM);
 
     // Result
     GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_RESULT |
                                COMPREHENSIONTLV_FLAG_CR);
-    if ("additionalInformation" in response) {
-      // In |12.12 Result| TS 11.14, the length of additional information is
-      // varied and all possible values are addressed in 12.12.1-11 of TS 11.14
-      // and 8.12.1-13 in TS 31.111.
-      // However,
-      // 1. Only SEND SS requires info with more than 1 octet.
-      // 2. In rild design, SEND SS is expected to be handled by modem and
-      //    UNSOLICITED_STK_EVENT_NOTIFY will be sent to application layer to
-      //    indicate appropriate messages to users. TR is not required in this
-      //    case.
-      // Hence, we simplify the structure of |additionalInformation| to a
-      // numeric value instead of a octet array.
-      GsmPDUHelper.writeHexOctet(2);
-      GsmPDUHelper.writeHexOctet(response.resultCode);
-      GsmPDUHelper.writeHexOctet(response.additionalInformation);
-    } else {
-      GsmPDUHelper.writeHexOctet(1);
-      GsmPDUHelper.writeHexOctet(response.resultCode);
-    }
+    GsmPDUHelper.writeHexOctet(1);
+    GsmPDUHelper.writeHexOctet(response.resultCode);
 
     // Item Identifier
     if (response.itemIdentifier != null) {
       GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_ITEM_ID |
                                  COMPREHENSIONTLV_FLAG_CR);
       GsmPDUHelper.writeHexOctet(1);
       GsmPDUHelper.writeHexOctet(response.itemIdentifier);
     }
 
     // No need to process Text data if user requests help information.
     if (response.resultCode != STK_RESULT_HELP_INFO_REQUIRED) {
       let text;
-      let coding = command.options.isUCS2 ?
-                       STK_TEXT_CODING_UCS2 :
-                       (command.options.isPacked ?
-                          STK_TEXT_CODING_GSM_7BIT_PACKED :
-                          STK_TEXT_CODING_GSM_8BIT);
       if (response.isYesNo !== undefined) {
-        // Tag: GET_INKEY
+        // GET_INKEY
         // When the ME issues a successful TERMINAL RESPONSE for a GET INKEY
         // ("Yes/No") command with command qualifier set to "Yes/No", it shall
         // supply the value '01' when the answer is "positive" and the value
         // '00' when the answer is "negative" in the Text string data object.
+        text = response.isYesNo ? 0x01 : 0x00;
+      } else {
+        text = response.input;
+      }
+
+      if (text) {
         GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_TEXT_STRING |
                                    COMPREHENSIONTLV_FLAG_CR);
-        // Length: 2
-        GsmPDUHelper.writeHexOctet(2);
-        // Value: Coding, Yes/No.
+
+        // 2nd mark for text length
+        Buf.startCalOutgoingSize(function(size) {
+          // Text length is in number of hexOctets, which costs 4 uint8 per hexOctet.
+          GsmPDUHelper.writeHexOctet(size / 4);
+        });
+
+        let coding = command.options.isUCS2 ?
+                       STK_TEXT_CODING_UCS2 :
+                       (command.options.isPacked ?
+                          STK_TEXT_CODING_GSM_7BIT_PACKED :
+                          STK_TEXT_CODING_GSM_8BIT);
         GsmPDUHelper.writeHexOctet(coding);
-        GsmPDUHelper.writeHexOctet(response.isYesNo ? 0x01 : 0x00);
-      } else {
-        if (response.input !== undefined) {
-            ComprehensionTlvHelper.writeTextStringTlv(response.input, coding);
-        }
+
+        // Write Text String.
+        switch (coding) {
+          case STK_TEXT_CODING_UCS2:
+            GsmPDUHelper.writeUCS2String(text);
+            break;
+          case STK_TEXT_CODING_GSM_7BIT_PACKED:
+            GsmPDUHelper.writeStringAsSeptets(text, 0, 0, 0);
+            break;
+          case STK_TEXT_CODING_GSM_8BIT:
+            for (let i = 0; i < text.length; i++) {
+              GsmPDUHelper.writeHexOctet(text.charCodeAt(i));
+            }
+            break;
+        }
+
+        // Calculate and write text length to 2nd mark
+        Buf.stopCalOutgoingSize();
       }
     }
 
     // Local Information
     if (response.localInfo) {
       let localInfo = response.localInfo;
 
       // Location Infomation
@@ -4089,226 +3920,213 @@ RilObject.prototype = {
         // According to ril.h, the operator fields will be NULL when the operator
         // is not currently registered. We can avoid trying to parse the numeric
         // tuple in that case.
         if (DEBUG) {
           this.context.debug("Operator is currently unregistered");
         }
       }
 
-      this.operator.longName = longName;
-      this.operator.shortName = shortName;
-
       let ICCUtilsHelper = this.context.ICCUtilsHelper;
+      let networkName;
+      // We won't get network name using PNN and OPL if voice registration isn't ready
+      if (this.voiceRegistrationState.cell &&
+          this.voiceRegistrationState.cell.gsmLocationAreaCode != -1) {
+        networkName = ICCUtilsHelper.getNetworkNameFromICC(
+          this.operator.mcc,
+          this.operator.mnc,
+          this.voiceRegistrationState.cell.gsmLocationAreaCode);
+      }
+
+      if (networkName) {
+        if (DEBUG) {
+          this.context.debug("Operator names will be overriden: " +
+                             "longName = " + networkName.fullName + ", " +
+                             "shortName = " + networkName.shortName);
+        }
+
+        this.operator.longName = networkName.fullName;
+        this.operator.shortName = networkName.shortName;
+      } else {
+        this.operator.longName = longName;
+        this.operator.shortName = shortName;
+      }
+
       if (ICCUtilsHelper.updateDisplayCondition()) {
         ICCUtilsHelper.handleICCInfoChange();
       }
-
-      // NETWORK_INFO_OPERATOR message will be sent out by overrideNetworkName
-      // itself if operator name is overridden after checking, or we have to
-      // do it by ourself.
-      if (!this.overrideNetworkName()) {
-        this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator);
-      }
-    }
-  },
-
-  /**
-   * Classify new calls into three groups: (removed, remained, added).
-   */
-  _classifyCalls: function(newCalls) {
-    newCalls = newCalls || {};
-
-    let removedCalls = [];
-    let remainedCalls = [];
-    let addedCalls = [];
-
+      this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator);
+    }
+  },
+
+  /**
+   * Helpers for processing call state and handle the active call.
+   */
+  _processCalls: function(newCalls) {
+    let conferenceChanged = false;
+    let clearConferenceRequest = false;
+
+    // Go through the calls we currently have on file and see if any of them
+    // changed state. Remove them from the newCalls map as we deal with them
+    // so that only new calls remain in the map after we're done.
     for each (let currentCall in this.currentCalls) {
-      let newCall = newCalls[currentCall.callIndex];
+      let newCall;
+      if (newCalls) {
+        newCall = newCalls[currentCall.callIndex];
+        delete newCalls[currentCall.callIndex];
+      }
+
+      // Call is no longer reported by the radio. Remove from our map and send
+      // disconnected state change.
       if (!newCall) {
-        removedCalls.push(currentCall);
+        if (this.currentConference.participants[currentCall.callIndex]) {
+          conferenceChanged = true;
+        }
+        this._removeVoiceCall(currentCall,
+                              currentCall.hangUpLocal ?
+                                GECKO_CALL_ERROR_NORMAL_CALL_CLEARING : null);
+        continue;
+      }
+
+      // Call is still valid.
+      if (newCall.state == currentCall.state &&
+          newCall.isMpty == currentCall.isMpty) {
+        continue;
+      }
+
+      // State has changed.
+      if (newCall.state == CALL_STATE_INCOMING &&
+          currentCall.state == CALL_STATE_WAITING) {
+        // Update the call internally but we don't notify chrome since these two
+        // states are viewed as the same one there.
+        currentCall.state = newCall.state;
+        continue;
+      }
+
+      if (!currentCall.started && newCall.state == CALL_STATE_ACTIVE) {
+        currentCall.started = new Date().getTime();
+      }
+
+      if (currentCall.isMpty == newCall.isMpty &&
+          newCall.state != currentCall.state) {
+        currentCall.state = newCall.state;
+        if (currentCall.isConference) {
+          conferenceChanged = true;
+        }
+        this._handleChangedCallState(currentCall);
+        continue;
+      }
+
+      // '.isMpty' becomes false when the conference call is put on hold.
+      // We need to introduce additional 'isConference' to correctly record the
+      // real conference status
+
+      // Update a possible conference participant when .isMpty changes.
+      if (!currentCall.isMpty && newCall.isMpty) {
+        if (this._hasConferenceRequest) {
+          conferenceChanged = true;
+          clearConferenceRequest = true;
+          currentCall.state = newCall.state;
+          currentCall.isMpty = newCall.isMpty;
+          currentCall.isConference = true;
+          this.currentConference.participants[currentCall.callIndex] = currentCall;
+          this._handleChangedCallState(currentCall);
+        } else if (currentCall.isConference) {
+          // The case happens when resuming a held conference call.
+          conferenceChanged = true;
+          currentCall.state = newCall.state;
+          currentCall.isMpty = newCall.isMpty;
+          this.currentConference.participants[currentCall.callIndex] = currentCall;
+          this._handleChangedCallState(currentCall);
+        } else {
+          // Weird. This sometimes happens when we switch two calls, but it is
+          // not a conference call.
+          currentCall.state = newCall.state;
+          this._handleChangedCallState(currentCall);
+        }
+      } else if (currentCall.isMpty && !newCall.isMpty) {
+        if (!this.currentConference.participants[newCall.callIndex]) {
+          continue;
+        }
+
+        // '.isMpty' of a conference participant is set to false by rild when
+        // the conference call is put on hold. We don't actually know if the call
+        // still attends the conference until updating all calls finishes. We
+        // cache it for further determination.
+        if (newCall.state != CALL_STATE_HOLDING) {
+          delete this.currentConference.participants[newCall.callIndex];
+          currentCall.state = newCall.state;
+          currentCall.isMpty = newCall.isMpty;
+          currentCall.isConference = false;
+          conferenceChanged = true;
+          this._handleChangedCallState(currentCall);
+          continue;
+        }
+
+        if (!this.currentConference.cache) {
+          this.currentConference.cache = {};
+        }
+        this.currentConference.cache[currentCall.callIndex] = newCall;
+        currentCall.state = newCall.state;
+        currentCall.isMpty = newCall.isMpty;
+        conferenceChanged = true;
+      }
+    }
+
+    // We have a successful dialing request. Check whether we could find a new
+    // call for it.
+    if (this.pendingMO) {
+      let options = this.pendingMO.options;
+      this.pendingMO = null;
+
+      // Find the callIndex of the new outgoing call.
+      let callIndex = -1;
+      for (let i in newCalls) {
+        if (newCalls[i].state !== CALL_STATE_INCOMING) {
+          callIndex = newCalls[i].callIndex;
+          break;
+        }
+      }
+
+      if (callIndex === -1) {
+        // The call doesn't exist.
+        options.success = false;
+        options.errorMsg = GECKO_CALL_ERROR_UNSPECIFIED;
+        this.sendChromeMessage(options);
       } else {
-        remainedCalls.push(newCall);
-        delete newCalls[currentCall.callIndex];
+        options.success = true;
+        options.callIndex = callIndex;
+        this.sendChromeMessage(options);
       }
     }
 
     // Go through any remaining calls that are new to us.
     for each (let newCall in newCalls) {
-      if (newCall.isVoice) {
-        addedCalls.push(newCall);
-      }
-    }
-
-    return [removedCalls, remainedCalls, addedCalls];
-  },
-
-  /**
-   * Check the calls in addedCalls and assign an appropriate one to pendingMO.
-   * Also update the |isEmergency| on that call.
-   */
-  _assignPendingMO: function(addedCalls) {
-    let options = this.pendingMO.options;
-    this.pendingMO = null;
-
-    for (let call of addedCalls) {
-      if (call.state !== CALL_STATE_INCOMING) {
-        call.isEmergency = this._isEmergencyNumber(options.number);
-        options.success = true;
-        options.callIndex = call.callIndex;
-        this.sendChromeMessage(options);
-        return;
-      }
-    }
-
-    // The call doesn't exist.
-    options.success = false;
-    options.errorMsg = GECKO_CALL_ERROR_UNSPECIFIED;
-    this.sendChromeMessage(options);
-  },
-
-  /**
-   * Check the currentCalls and identify the conference group.
-   * Return the conference state and the group as a set.
-   */
-  _detectConference: function() {
-    // There are some difficuties to identify the conference by |.isMpty| so we
-    // don't rely on this flag.
-    //  - |.isMpty| becomes false when the conference call is put on hold.
-    //  - |.isMpty| may remain true when other participants left the conference.
-
-    // All the calls in the conference should have the same state and it is
-    // either ACTIVE or HOLDING. That means, if we find a group of call with
-    // the same state and its size is larger than 2, it must be a conference.
-    let activeCalls = new Set();
-    let holdingCalls = new Set();
-
-    for each (let call in this.currentCalls) {
-      if (call.state === CALL_STATE_ACTIVE) {
-        activeCalls.add(call);
-      } else if (call.state === CALL_STATE_HOLDING) {
-        holdingCalls.add(call);
-      }
-    }
-
-    if (activeCalls.size >= 2) {
-      return [CALL_STATE_ACTIVE, activeCalls];
-    } else if (holdingCalls.size >= 2) {
-      return [CALL_STATE_HOLDING, holdingCalls];
-    }
-
-    return [CALL_STATE_UNKNOWN, new Set()];
-  },
-
-  /**
-   * Helpers for processing call state changes.
-   */
-  _processCalls: function(newCalls, forceUpdate, failCause) {
-    // Let's get the failCause first if there are removed calls. Otherwise, we
-    // need to trigger another async request when removing call and it cause
-    // the order of callDisconnected and conferenceCallStateChanged
-    // unpredictable.
-    if (failCause === undefined) {
-      for each (let currentCall in this.currentCalls) {
-        if (!newCalls[currentCall.callIndex] && !currentCall.hangUpLocal) {
-          this.getFailCauseCode((function(newCalls, forceUpdate, failCause) {
-            this._processCalls(newCalls, forceUpdate, failCause);
-          }).bind(this, newCalls, forceUpdate));
-          return;
-        }
-      }
-    }
-
-    let [removedCalls, remainedCalls, addedCalls] =
-      this._classifyCalls(newCalls);
-
-    // Handle removed calls.
-    // Only remove it from the map here. Notify callDisconnected later.
-    for (let call of removedCalls) {
-      delete this.currentCalls[call.callIndex];
-      call.failCause = call.hangUpLocal ? GECKO_CALL_ERROR_NORMAL_CALL_CLEARING
-                                        : failCause;
-    }
-
-    let changedCalls = new Set();
-
-    // Handle remained calls.
-    for (let newCall of remainedCalls) {
-      let oldCall = this.currentCalls[newCall.callIndex];
-      if (oldCall.state == newCall.state && !forceUpdate) {
+      if (!newCall.isVoice) {
         continue;
       }
 
-      if (oldCall.state == CALL_STATE_WAITING &&
-          newCall.state == CALL_STATE_INCOMING && !forceUpdate) {
-        // Update the call internally but we don't notify chrome since these two
-        // states are viewed as the same one there.
-        oldCall.state = newCall.state;
-        continue;
-      }
-
-      if (!oldCall.started && newCall.state == CALL_STATE_ACTIVE) {
-        oldCall.started = new Date().getTime();
-      }
-
-      oldCall.state = newCall.state;
-      oldCall.number =
-        this._formatInternationalNumber(newCall.number, newCall.toa);
-      oldCall.isEmergency = this._isEmergencyNumber(oldCall.number);
-      changedCalls.add(oldCall);
-    }
-
-    // Handle pendingMO.
-    if (this.pendingMO) {
-      this._assignPendingMO(addedCalls);
-    }
-
-    // Handle added calls.
-    for (let call of addedCalls) {
-      this._addVoiceCall(call);
-      changedCalls.add(call);
-    }
-
-    // Detect conference and update isConference flag.
-    let [newConferenceState, conference] = this._detectConference();
-    for each (let call in this.currentCalls) {
-      let isConference = conference.has(call);
-      if (call.isConference != isConference) {
-        call.isConference = isConference;
-        changedCalls.add(call);
-      }
-    }
-
-    // Update audio state. We have to send this message before callStateChange
-    // and callDisconnected to make sure that the audio state is ready first.
-    this.sendChromeMessage({
-      rilMessageType: "audioStateChanged",
-      state: this._detectAudioState()
-    });
-
-    // Notify call disconnected.
-    for (let call of removedCalls) {
-      this._handleDisconnectedCall(call);
-    }
-
-    // Notify call state change.
-    for (let call of changedCalls) {
-      this._handleChangedCallState(call);
-    }
-
-    // Notify conference state change.
-    if (this.currentConferenceState != newConferenceState || forceUpdate) {
-      this.currentConferenceState = newConferenceState;
-      let message = {rilMessageType: "conferenceCallStateChanged",
-                     state: newConferenceState};
-      this.sendChromeMessage(message);
-    }
-
-    // Update phone state according to calls.
-    this._updatePhoneState();
+      if (newCall.isMpty) {
+        conferenceChanged = true;
+      }
+
+      this._addNewVoiceCall(newCall);
+    }
+
+    if (clearConferenceRequest) {
+      this._hasConferenceRequest = false;
+    }
+    if (conferenceChanged) {
+      this._ensureConference();
+    }
+
+    // Update audio state.
+    let message = {rilMessageType: "audioStateChanged",
+                   state: this._detectAudioState()};
+    this.sendChromeMessage(message);
   },
 
   _detectAudioState: function() {
     let callNum = Object.keys(this.currentCalls).length;
     if (!callNum) {
       return AUDIO_STATE_NO_CALL;
     }
 
@@ -4316,34 +4134,106 @@ RilObject.prototype = {
     if (callNum == 1 &&
         this.currentCalls[firstIndex].state == CALL_STATE_INCOMING) {
       return AUDIO_STATE_INCOMING;
     }
 
     return AUDIO_STATE_IN_CALL;
   },
 
-  // Format international numbers appropriately.
-  _formatInternationalNumber: function(number, toa) {
-    if (number && toa == TOA_INTERNATIONAL && number[0] != "+") {
-      number = "+" + number;
-    }
-
-    return number;
-  },
-
-  _addVoiceCall: function(newCall) {
-    newCall.number = this._formatInternationalNumber(newCall.number, newCall.toa);
-    newCall.isEmergency = this._isEmergencyNumber(newCall.number);
-    newCall.isOutgoing = !newCall.isMT;
-    newCall.isConference = false;
-
+  _addNewVoiceCall: function(newCall) {
+    // Format international numbers appropriately.
+    if (newCall.number && newCall.toa == TOA_INTERNATIONAL &&
+        newCall.number[0] != "+") {
+      newCall.number = "+" + newCall.number;
+    }
+
+    if (newCall.state == CALL_STATE_INCOMING) {
+      newCall.isOutgoing = false;
+    } else if (newCall.state == CALL_STATE_DIALING) {
+      newCall.isOutgoing = true;
+    }
+
+    // Set flag for outgoing emergency call.
+    newCall.isEmergency = newCall.isOutgoing &&
+      this._isEmergencyNumber(newCall.number);
+
+    // Set flag for conference.
+    newCall.isConference = newCall.isMpty ? true : false;
+
+    // Add to our map.
+    if (newCall.isMpty) {
+      this.currentConference.participants[newCall.callIndex] = newCall;
+    }
+    this._handleChangedCallState(newCall);
     this.currentCalls[newCall.callIndex] = newCall;
   },
 
+  _removeVoiceCall: function(removedCall, failCause) {
+    if (this.currentConference.participants[removedCall.callIndex]) {
+      removedCall.isConference = false;
+      delete this.currentConference.participants[removedCall.callIndex];
+      delete this.currentCalls[removedCall.callIndex];
+      // We don't query the fail cause here as it triggers another asynchrouns
+      // request that leads to a problem of updating all conferece participants
+      // in one task.
+      this._handleDisconnectedCall(removedCall);
+    } else {
+      delete this.currentCalls[removedCall.callIndex];
+      if (failCause) {
+        removedCall.failCause = failCause;
+        this._handleDisconnectedCall(removedCall);
+      } else {
+        this.getFailCauseCode((function(call, failCause) {
+          call.failCause = failCause;
+          this._handleDisconnectedCall(call);
+        }).bind(this, removedCall));
+      }
+    }
+  },
+
+  _ensureConference: function() {
+    let oldState = this.currentConference.state;
+    let remaining = Object.keys(this.currentConference.participants);
+
+    if (remaining.length == 1) {
+      // Remove that if only does one remain in a conference call.
+      let call = this.currentCalls[remaining[0]];
+      call.isConference = false;
+      this._handleChangedCallState(call);
+      delete this.currentConference.participants[call.callIndex];
+    } else if (remaining.length > 1) {
+      for each (let call in this.currentConference.cache) {
+        call.isConference = true;
+        this.currentConference.participants[call.callIndex] = call;
+        this.currentCalls[call.callIndex] = call;
+        this._handleChangedCallState(call);
+      }
+    }
+    delete this.currentConference.cache;
+
+    // Update the conference call's state.
+    let state = CALL_STATE_UNKNOWN;
+    for each (let call in this.currentConference.participants) {
+      if (state != CALL_STATE_UNKNOWN && state != call.state) {
+        // Each participant should have the same state, otherwise something
+        // wrong happens.
+        state = CALL_STATE_UNKNOWN;
+        break;
+      }
+      state = call.state;
+    }
+    if (oldState != state) {
+      this.currentConference.state = state;
+      let message = {rilMessageType: "conferenceCallStateChanged",
+                     state: state};
+      this.sendChromeMessage(message);
+    }
+  },
+
   _handleChangedCallState: function(changedCall) {
     let message = {rilMessageType: "callStateChange",
                    call: changedCall};
     this.sendChromeMessage(message);
   },
 
   _handleDisconnectedCall: function(disconnectedCall) {
     let message = {rilMessageType: "callDisconnected",
@@ -4358,37 +4248,16 @@ RilObject.prototype = {
     if (errorCode == ERROR_GENERIC_FAILURE) {
       message.errorMsg = RIL_ERROR_TO_GECKO_ERROR[errorCode];
     } else {
       message.errorMsg = RIL_DATACALL_FAILCAUSE_TO_GECKO_DATACALL_ERROR[errorCode];
     }
     this.sendChromeMessage(message);
   },
 
-  _updatePhoneState: function() {
-    let phoneState = this.phoneState;
-    let callIndexes = Object.keys(this.currentCalls);
-
-    if (callIndexes.length === 0) {
-      this.phoneState = GECKO_PHONE_STATE_IDLE;
-    } else if (callIndexes.length === 1 &&
-               this.currentCalls[callIndexes[0]].state === CALL_STATE_INCOMING) {
-      this.phoneState = GECKO_PHONE_STATE_RINGING;
-    } else {
-      this.phoneState = GECKO_PHONE_STATE_INCALL;
-    }
-
-    if (this.phoneState !== phoneState) {
-      this.sendChromeMessage({
-        rilMessageType: "phoneStateChanged",
-        state: this.phoneState
-      });
-    }
-  },
-
   /**
    * @return "deactivate" if <ifname> changes or one of the currentDataCall
    *         addresses is missing in updatedDataCall, or "identical" if no
    *         changes found, or "changed" otherwise.
    */
   _compareDataCallLink: function(updatedDataCall, currentDataCall) {
     // If network interface is changed, report as "deactivate".
     if (updatedDataCall.ifname != currentDataCall.ifname) {
@@ -4428,18 +4297,20 @@ RilObject.prototype = {
     return "identical";
   },
 
   _processDataCallList: function(datacalls, newDataCallOptions) {
     // Check for possible PDP errors: We check earlier because the datacall
     // can be removed if is the same as the current one.
     for each (let newDataCall in datacalls) {
       if (newDataCall.status != DATACALL_FAIL_NONE) {
-        this._sendDataCallError(newDataCallOptions || newDataCall,
-                                newDataCall.status);
+        if (newDataCallOptions) {
+          newDataCall.apn = newDataCallOptions.apn;
+        }
+        this._sendDataCallError(newDataCall, newDataCall.status);
       }
     }
 
     for each (let currentDataCall in this.currentDataCalls) {
       let updatedDataCall;
       if (datacalls) {
         updatedDataCall = datacalls[currentDataCall.cid];
         delete datacalls[currentDataCall.cid];
@@ -5545,24 +5416,16 @@ RilObject.prototype = {
     // STK_CMD_MORE_TIME need not to propagate event to chrome.
     if (cmdDetails.typeOfCommand == STK_CMD_MORE_TIME) {
       this.sendStkTerminalResponse({
         command: cmdDetails,
         resultCode: STK_RESULT_OK});
       return;
     }
 
-    // See 3GPP TS 11.14, 6.4.22 SET UP IDLE MODE TEXT
-    // Also see Bug 1106449 for short term work around.
-    if (cmdDetails.typeOfCommand === STK_CMD_REFRESH &&
-        cmdDetails.commandQualifier === STK_REFRESH_FILE_CHANGE ) {
-      this.context.StkCommandParamsFactory.createParam(cmdDetails, ctlvs);
-      return;
-    }
-
     cmdDetails.rilMessageType = "stkcommand";
     cmdDetails.options =
       this.context.StkCommandParamsFactory.createParam(cmdDetails, ctlvs);
     this.sendChromeMessage(cmdDetails);
   },
 
   /**
    * Send messages to the main thread.
@@ -5663,16 +5526,20 @@ RilObject.prototype[REQUEST_GET_CURRENT_
 
   let Buf = this.context.Buf;
   let calls_length = 0;
   // The RIL won't even send us the length integer if there are no active calls.
   // So only read this integer if the parcel actually has it.
   if (length) {
     calls_length = Buf.readInt32();
   }
+  if (!calls_length) {
+    this._processCalls(null);
+    return;
+  }
 
   let calls = {};
   for (let i = 0; i < calls_length; i++) {
     let call = {};
 
     // Extra uint32 field to get correct callIndex and rest of call data for
     // call waiting feature.
     if (RILQUIRKS_EXTRA_UINT32_2ND_CALL && i > 0) {
@@ -5702,18 +5569,17 @@ RilObject.prototype[REQUEST_GET_CURRENT_
         type:     Buf.readInt32(),
         dcs:      Buf.readInt32(),
         userData: null //XXX TODO byte array?!?
       };
     }
 
     calls[call.callIndex] = call;
   }
-
-  this._processCalls(calls, options.forceUpdate);
+  this._processCalls(calls);
 };
 RilObject.prototype[REQUEST_DIAL] = function REQUEST_DIAL(length, options) {
   if (options.rilRequestError === 0) {
     this.pendingMO = {options: options};
   } else {
     this.getFailCauseCode((function(options, failCause) {
       options.success = false;
       options.errorMsg = failCause;
@@ -5734,58 +5600,62 @@ RilObject.prototype[REQUEST_GET_IMSI] = 
     this.context.debug("IMSI: " + this.iccInfoPrivate.imsi);
   }
 
   options.rilMessageType = "iccimsi";
   options.imsi = this.iccInfoPrivate.imsi;
   this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_HANGUP] = function REQUEST_HANGUP(length, options) {
-  options.success = options.rilRequestError === 0;
-  options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-  this.sendChromeMessage(options);
+  if (options.rilRequestError) {
+    return;
+  }
+
+  this.getCurrentCalls();
 };
 RilObject.prototype[REQUEST_HANGUP_WAITING_OR_BACKGROUND] = function REQUEST_HANGUP_WAITING_OR_BACKGROUND(length, options) {
-  RilObject.prototype[REQUEST_HANGUP].call(this, length, options);
-};
+  if (options.rilRequestError) {
+    return;
+  }
+
+  this.getCurrentCalls();
+};
+// TODO Bug 1012599: This one is not used.
 RilObject.prototype[REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND] = function REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND(length, options) {
-  RilObject.prototype[REQUEST_HANGUP].call(this, length, options);
+  if (options.rilRequestError) {
+    return;
+  }
+
+  this.getCurrentCalls();
 };
 RilObject.prototype[REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE] = function REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE(length, options) {
-  options.success = (options.rilRequestError === 0);
-  if (!options.success) {
-    this.getCurrentCalls({ forceUpdate: true });
-  }
+  if (options.rilRequestError) {
+    return;
+  }
+
+  this.getCurrentCalls();
 };
 RilObject.prototype[REQUEST_CONFERENCE] = function REQUEST_CONFERENCE(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
+    this._hasConferenceRequest = false;
     options.errorName = "addError";
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
   this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_UDUB] = function REQUEST_UDUB(length, options) {
 };
 RilObject.prototype[REQUEST_LAST_CALL_FAIL_CAUSE] = function REQUEST_LAST_CALL_FAIL_CAUSE(length, options) {
   let Buf = this.context.Buf;
   let num = length ? Buf.readInt32() : 0;
-  let failCause = null;
-
-  if (num) {
-    let causeNum = Buf.readInt32();
-    // To make _processCalls work as design, failCause couldn't be "undefined."
-    // See Bug 1112550 for details.
-    failCause = RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[causeNum] || null;
-  }
-  if (DEBUG) this.context.debug("Last call fail cause: " + failCause);
-
+  let failCause = num ? RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[Buf.readInt32()] : null;
   if (options.callback) {
     options.callback(failCause);
   }
 };
 RilObject.prototype[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options) {
   this._receivedNetworkInfo(NETWORK_INFO_SIGNAL);
 
   if (options.rilRequestError) {
@@ -5913,48 +5783,32 @@ RilObject.prototype[REQUEST_SETUP_DATA_C
     this.getDataCallList();
     return;
   }
   // Pass `options` along. That way we retain the APN and other info about
   // how the data call was set up.
   this[REQUEST_DATA_CALL_LIST](length, options);
 };
 RilObject.prototype[REQUEST_SIM_IO] = function REQUEST_SIM_IO(length, options) {
-  if (options.rilRequestError) {
-    if (options.onerror) {
-      options.onerror(RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError] ||
-                      GECKO_ERROR_GENERIC_FAILURE);
-    }
+  let ICCIOHelper = this.context.ICCIOHelper;
+  if (!length) {
+    ICCIOHelper.processICCIOError(options);
     return;
   }
 
+  // Don't need to read rilRequestError since we can know error status from
+  // sw1 and sw2.
   let Buf = this.context.Buf;
   options.sw1 = Buf.readInt32();
   options.sw2 = Buf.readInt32();
-
-  // See 3GPP TS 11.11, clause 9.4.1 for operation success results.
-  if (options.sw1 !== ICC_STATUS_NORMAL_ENDING &&
-      options.sw1 !== ICC_STATUS_NORMAL_ENDING_WITH_EXTRA &&
-      options.sw1 !== ICC_STATUS_WITH_SIM_DATA &&
-      options.sw1 !== ICC_STATUS_WITH_RESPONSE_DATA) {
-    if (DEBUG) {
-      this.context.debug("ICC I/O Error EF id = 0x" + options.fileId.toString(16) +
-                         ", command = 0x" + options.command.toString(16) +
-                         ", sw1 = 0x" + options.sw1.toString(16) +
-                         ", sw2 = 0x" + options.sw2.toString(16));
-    }
-    if (options.onerror) {
-      // We can get fail cause from sw1/sw2 (See TS 11.11 clause 9.4.1 and
-      // ISO 7816-4 clause 6). But currently no one needs this information,
-      // so simply reports "GenericFailure" for now.
-      options.onerror(GECKO_ERROR_GENERIC_FAILURE);
-    }
+  if (options.sw1 != ICC_STATUS_NORMAL_ENDING) {
+    ICCIOHelper.processICCIOError(options);
     return;
   }
-  this.context.ICCIOHelper.processICCIO(options);
+  ICCIOHelper.processICCIO(options);
 };
 RilObject.prototype[REQUEST_SEND_USSD] = function REQUEST_SEND_USSD(length, options) {
   if (DEBUG) {
     this.context.debug("REQUEST_SEND_USSD " + JSON.stringify(options));
   }
   options.success = (this._ussdSession = options.rilRequestError === 0);
   options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   this.sendChromeMessage(options);
@@ -6138,22 +5992,16 @@ RilObject.prototype[REQUEST_SET_CALL_FOR
   }
   this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_QUERY_CALL_WAITING] =
   function REQUEST_QUERY_CALL_WAITING(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-
-    if (options.callback) {
-      // Prevent DataCloneError when sending chrome messages.
-      delete options.callback;
-    }
-
     this.sendChromeMessage(options);
     return;
   }
 
   if (options.callback) {
     options.callback.call(this, options);
     return;
   }
@@ -6164,22 +6012,16 @@ RilObject.prototype[REQUEST_QUERY_CALL_W
                      ((Buf.readInt32() & ICC_SERVICE_CLASS_VOICE) == 0x01));
   this.sendChromeMessage(options);
 };
 
 RilObject.prototype[REQUEST_SET_CALL_WAITING] = function REQUEST_SET_CALL_WAITING(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-
-    if (options.callback) {
-      // Prevent DataCloneError when sending chrome messages.
-      delete options.callback;
-    }
-
     this.sendChromeMessage(options);
     return;
   }
 
   if (options.callback) {
     options.callback.call(this, options);
     return;
   }
@@ -6283,23 +6125,16 @@ RilObject.prototype[REQUEST_SET_FACILITY
   }
   this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_CHANGE_BARRING_PASSWORD] =
   function REQUEST_CHANGE_BARRING_PASSWORD(length, options) {
   if (options.rilRequestError) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
-
-  if (options.rilMessageType != "sendMMI") {
-    this.sendChromeMessage(options);
-    return;
-  }
-
-  options.statusMessage = MMI_SM_KS_PASSWORD_CHANGED;
   this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_SIM_OPEN_CHANNEL] = function REQUEST_SIM_OPEN_CHANNEL(length, options) {
   if (options.rilRequestError) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
@@ -6742,53 +6577,27 @@ RilObject.prototype[REQUEST_VOICE_RADIO_
                          options.rilRequestError);
     }
     return;
   }
   let radioTech = this.context.Buf.readInt32List();
   this._processRadioTech(radioTech[0]);
 };
 RilObject.prototype[REQUEST_SET_UICC_SUBSCRIPTION] = null;
-RilObject.prototype[REQUEST_SET_DATA_SUBSCRIPTION] = function REQUEST_SET_DATA_SUBSCRIPTION(length, options) {
-  if (!options.rilMessageType) {
-    // The request was made by ril_worker itself. Don't report.
-    return;
-  }
-  options.success = (options.rilRequestError === 0);
-  if (!options.success) {
-    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-  }
-  this.sendChromeMessage(options);
-};
+RilObject.prototype[REQUEST_SET_DATA_SUBSCRIPTION] = null;
 RilObject.prototype[REQUEST_GET_UNLOCK_RETRY_COUNT] = function REQUEST_GET_UNLOCK_RETRY_COUNT(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
   options.retryCount = length ? this.context.Buf.readInt32List()[0] : -1;
   this.sendChromeMessage(options);
 };
-RilObject.prototype[RIL_REQUEST_GPRS_ATTACH] = function RIL_REQUEST_GPRS_ATTACH(length, options) {
-  if (!options.rilMessageType) {
-    // The request was made by ril_worker itself. Don't report.
-    return;
-  }
-  options.success = (options.rilRequestError === 0);
-  if (!options.success) {
-    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-  }
-  this.sendChromeMessage(options);
-};
-RilObject.prototype[RIL_REQUEST_GPRS_DETACH] = function RIL_REQUEST_GPRS_DETACH(length, options) {
-  options.success = (options.rilRequestError === 0);
-  if (!options.success) {
-    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
-  }
-  this.sendChromeMessage(options);
-};
+RilObject.prototype[RIL_REQUEST_GPRS_ATTACH] = null;
+RilObject.prototype[RIL_REQUEST_GPRS_DETACH] = null;
 RilObject.prototype[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED() {
   let radioState = this.context.Buf.readInt32();
   let newState;
   if (radioState == RADIO_STATE_UNAVAILABLE) {
     newState = GECKO_RADIOSTATE_UNAVAILABLE;
   } else if (radioState == RADIO_STATE_OFF) {
     newState = GECKO_RADIOSTATE_OFF;
   } else {
@@ -6911,24 +6720,17 @@ RilObject.prototype[UNSOLICITED_RESPONSE
     });
 };
 RilObject.prototype[UNSOLICITED_ON_USSD] = function UNSOLICITED_ON_USSD() {
   let [typeCode, message] = this.context.Buf.readStringList();
   if (DEBUG) {
     this.context.debug("On USSD. Type Code: " + typeCode + " Message: " + message);
   }
 
-  let oldSession = this._ussdSession;
-
-  // Per ril.h the USSD session is assumed to persist if the type code is "1".
-  this._ussdSession = typeCode == "1";
-
-  if (!oldSession && !this._ussdSession && !message) {
-    return;
-  }
+  this._ussdSession = (typeCode != "0" && typeCode != "2");
 
   this.sendChromeMessage({rilMessageType: "ussdreceived",
                           message: message,
                           sessionEnded: !this._ussdSession});
 };
 RilObject.prototype[UNSOLICITED_ON_USSD_REQUEST] = null;
 RilObject.prototype[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED() {
   let dateString = this.context.Buf.readString();
@@ -7204,46 +7006,16 @@ GsmPDUHelperObject.prototype = {
     let array = new Uint8Array(length);
     for (let i = 0; i < length; i++) {
       array[i] = this.readHexOctet();
     }
     return array;
   },
 
   /**
-   * Helper to write data into a temporary buffer for easier length encoding when
-   * the number of octets for the length encoding is varied.
-   *
-   * @param writeFunction
-   *        Function of how the data to be written into temporary buffer.
-   *
-   * @return array of written octets.
-   **/
-  writeWithBuffer: function(writeFunction) {
-    let buf = [];
-    let writeHexOctet = this.writeHexOctet;
-    this.writeHexOctet = function(octet) {
-      buf.push(octet);
-    }
-
-    try {
-      writeFunction();
-    } catch (e) {
-      if (DEBUG) {
-        debug("Error when writeWithBuffer: " + e);
-      }
-      buf = [];
-    } finally {
-      this.writeHexOctet = writeHexOctet;
-    }
-
-    return buf;
-  },
-
-  /**
    * Convert an octet (number) to a BCD number.
    *
    * Any nibbles that are not in the BCD range count as 0.
    *
    * @param octet
    *        The octet (a number, as returned by getOctet())
    *
    * @return the corresponding BCD number.
@@ -7263,66 +7035,41 @@ GsmPDUHelperObject.prototype = {
    * @return the corresponding octet.
    */
   BCDToOctet: function(bcd) {
     bcd = Math.abs(bcd);
     return ((bcd % 10) << 4) + (Math.floor(bcd / 10) % 10);
   },
 
   /**
-   * Convert a semi-octet (number) to a GSM BCD char, or return empty
-   * string if invalid semiOctet and suppressException is set to true.
+   * Convert a semi-octet (number) to a GSM BCD char, or return empty string
+   * if invalid semiOctet and supressException is set to true.
    *
    * @param semiOctet
    *        Nibble to be converted to.
-   * @param suppressException [optional]
-   *        Suppress exception if invalid semiOctet and suppressException is set
+   * @param [optional] supressException
+   *        Supress exception if invalid semiOctet and supressException is set
    *        to true.
    *
    * @return GSM BCD char, or empty string.
    */
-  bcdChars: "0123456789",
-  semiOctetToBcdChar: function(semiOctet, suppressException) {
-    if (semiOctet >= this.bcdChars.length) {
-      if (suppressException) {
+  bcdChars: "0123456789*#,;",
+  semiOctetToBcdChar: function(semiOctet, supressException) {
+    if (semiOctet >= 14) {
+      if (supressException) {
         return "";
       } else {
         throw new RangeError();
       }
     }
 
     return this.bcdChars.charAt(semiOctet);
   },
 
   /**
-   * Convert a semi-octet (number) to a GSM extended BCD char, or return empty
-   * string if invalid semiOctet and suppressException is set to true.
-   *
-   * @param semiOctet
-   *        Nibble to be converted to.
-   * @param suppressException [optional]
-   *        Suppress exception if invalid semiOctet and suppressException is set
-   *        to true.
-   *
-   * @return GSM extended BCD char, or empty string.
-   */
-  extendedBcdChars: "0123456789*#,;",
-  semiOctetToExtendedBcdChar: function(semiOctet, suppressException) {
-    if (semiOctet >= this.extendedBcdChars.length) {
-      if (suppressException) {
-        return "";
-      } else {
-        throw new RangeError();
-      }
-    }
-
-    return this.extendedBcdChars.charAt(semiOctet);
-  },
-
-  /**
    * Read a *swapped nibble* binary coded decimal (BCD)
    *
    * @param pairs
    *        Number of nibble *pairs* to read.
    *
    * @return the decimal as a number.
    */
   readSwappedNibbleBcdNum: function(pairs) {
@@ -7342,67 +7089,38 @@ GsmPDUHelperObject.prototype = {
       }
       number *= 100;
       number += this.octetToBCD(octet);
     }
     return number;
   },
 
   /**
-   * Read a *swapped nibble* binary coded decimal (BCD) string
+   * Read a *swapped nibble* binary coded string (BCD)
    *
    * @param pairs
    *        Number of nibble *pairs* to read.
-   * @param suppressException [optional]
-   *        Suppress exception if invalid semiOctet and suppressException is set
+   * @param [optional] supressException
+   *        Supress exception if invalid semiOctet and supressException is set
    *        to true.
    *
    * @return The BCD string.
    */
-  readSwappedNibbleBcdString: function(pairs, suppressException) {
+  readSwappedNibbleBcdString: function(pairs, supressException) {
     let str = "";
     for (let i = 0; i < pairs; i++) {
       let nibbleH = this.readHexNibble();
       let nibbleL = this.readHexNibble();
       if (nibbleL == 0x0F) {
         break;
       }
 
-      str += this.semiOctetToBcdChar(nibbleL, suppressException);
+      str += this.semiOctetToBcdChar(nibbleL, supressException);
       if (nibbleH != 0x0F) {
-        str += this.semiOctetToBcdChar(nibbleH, suppressException);
-      }
-    }
-
-    return str;
-  },
-
-  /**
-   * Read a *swapped nibble* extended binary coded decimal (BCD) string
-   *
-   * @param pairs
-   *        Number of nibble *pairs* to read.
-   * @param suppressException [optional]
-   *        Suppress exception if invalid semiOctet and suppressException is set
-   *        to true.
-   *
-   * @return The BCD string.
-   */
-  readSwappedNibbleExtendedBcdString: function(pairs, suppressException) {
-    let str = "";
-    for (let i = 0; i < pairs; i++) {
-      let nibbleH = this.readHexNibble();
-      let nibbleL = this.readHexNibble();
-      if (nibbleL == 0x0F) {
-        break;
-      }
-
-      str += this.semiOctetToExtendedBcdChar(nibbleL, suppressException);
-      if (nibbleH != 0x0F) {
-        str += this.semiOctetToExtendedBcdChar(nibbleH, suppressException);
+        str += this.semiOctetToBcdChar(nibbleH, supressException);
       }
     }
 
     return str;
   },
 
   /**
    * Write numerical data as swapped nibble BCD.
@@ -7585,38 +7303,16 @@ GsmPDUHelperObject.prototype = {
       }
     }
 
     if (dataBits !== 0) {
       this.writeHexOctet(data & 0xFF);
     }
   },
 
-  writeStringAs8BitUnpacked: function(text) {
-    const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
-    const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
-
-    let len = text ? text.length : 0;
-    for (let i = 0; i < len; i++) {
-      let c = text.charAt(i);
-      let octet = langTable.indexOf(c);
-
-      if (octet == -1) {
-        octet = langShiftTable.indexOf(c);
-        if (octet == -1) {
-          // Fallback to ASCII space.
-          octet = langTable.indexOf(' ');
-        } else {
-          this.writeHexOctet(PDU_NL_EXTENDED_ESCAPE);
-        }
-      }
-      this.writeHexOctet(octet);
-    }
-  },
-
   /**
    * Read user data and decode as a UCS2 string.
    *
    * @param numOctets
    *        Number of octets to be read as UCS2 string.
    *
    * @return a string.
    */
@@ -7886,17 +7582,17 @@ GsmPDUHelperObject.prototype = {
     let toa = this.readHexOctet();
     let addr = "";
 
     if ((toa & 0xF0) == PDU_TOA_ALPHANUMERIC) {
       addr = this.readSeptetsToString(Math.floor(len * 4 / 7), 0,
           PDU_NL_IDENTIFIER_DEFAULT , PDU_NL_IDENTIFIER_DEFAULT );
       return addr;
     }
-    addr = this.readSwappedNibbleExtendedBcdString(len / 2);
+    addr = this.readSwappedNibbleBcdString(len / 2);
     if (addr.length <= 0) {
       if (DEBUG) this.context.debug("PDU error: no number provided");
       return null;
     }
     if ((toa & 0xF0) == (PDU_TOA_INTERNATIONAL)) {
       addr = '+' + addr;
     }
 
@@ -8123,22 +7819,16 @@ GsmPDUHelperObject.prototype = {
     }
 
     if (DEBUG) {
       this.context.debug("After header, " + length + " septets left of user data");
     }
 
     msg.body = null;
     msg.data = null;
-
-    if (length <= 0) {
-      // No data to read.
-      return;
-    }
-
     switch (msg.encoding) {
       case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
         // 7 bit encoding allows 140 octets, which means 160 characters
         // ((140x8) / 7 = 160 chars)
         if (length > PDU_MAX_USER_DATA_7BIT) {
           if (DEBUG) {
             this.context.debug("PDU error: user data is too long: " + length);
           }
@@ -8236,17 +7926,17 @@ GsmPDUHelperObject.prototype = {
       dt:                null, // X  X  X  X  M  X
     };
 
     // SMSC info
     let smscLength = this.readHexOctet();
     if (sms