Bug 804851 - Add telephony mock object to avoid Contacts app errors on B2G Desktop. r=gwagner
authorChris Peterson <cpeterson@mozilla.com>
Tue, 23 Oct 2012 15:09:29 -0700
changeset 111262 eb06e830422de45f2653953db62cf592acb54aee
parent 111261 d5ca3152fcdec4bde38aa3dafcecab4bfa66c6d2
child 111263 fdbf73f25fba517c4d02bc711124fa1c840248f6
push id16974
push usercpeterson@mozilla.com
push dateWed, 24 Oct 2012 17:42:13 +0000
treeherdermozilla-inbound@eb06e830422d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs804851
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 804851 - Add telephony mock object to avoid Contacts app errors on B2G Desktop. r=gwagner
dom/contacts/fallback/ContactService.jsm
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -17,19 +17,28 @@ Cu.import("resource://gre/modules/XPCOMU
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/ContactDB.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageListenerManager");
 
 XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
-  return Cc["@mozilla.org/telephony/system-worker-manager;1"].
-           getService(Ci.nsIInterfaceRequestor).
-           getInterface(Ci.nsIRadioInterfaceLayer);
+  let telephony = Cc["@mozilla.org/telephony/system-worker-manager;1"];
+  if (!telephony) {
+    // Return a mock RIL because B2G Desktop build does not support telephony.
+    return {
+      getICCContacts: function(aContactType, aCallback) {
+        aCallback("!telephony", null, null);
+      }
+    };
+  }
+  return telephony.
+         getService(Ci.nsIInterfaceRequestor).
+         getInterface(Ci.nsIRadioInterfaceLayer);
 });
 
 let myGlobal = this;
 
 let DOMContactManager = {
   init: function() {
     if (DEBUG) debug("Init");
     this._messages = ["Contacts:Find", "Contacts:Clear", "Contact:Save", "Contact:Remove", "Contacts:GetSimContacts"];