Bug 926302 - 2.a/3: refactor preference/settings names. r=gene
authorVicamo Yang <vyang@mozilla.com>
Thu, 24 Oct 2013 16:14:59 +0800
changeset 165924 f90977536aa96e810c743339817696b03c904e0d
parent 165923 29149aa9eded76bf3aada7a483edfcf48bcd7048
child 165925 2cf48b7c7a99872473b6cb721d26f49d5627b47a
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgene
bugs926302
milestone27.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 926302 - 2.a/3: refactor preference/settings names. r=gene
dom/mobilemessage/src/gonk/MmsService.js
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
dom/telephony/gonk/TelephonyProvider.js
--- a/dom/mobilemessage/src/gonk/MmsService.js
+++ b/dom/mobilemessage/src/gonk/MmsService.js
@@ -28,19 +28,18 @@ try {
 const kSmsSendingObserverTopic           = "sms-sending";
 const kSmsSentObserverTopic              = "sms-sent";
 const kSmsFailedObserverTopic            = "sms-failed";
 const kSmsReceivedObserverTopic          = "sms-received";
 const kSmsRetrievingObserverTopic        = "sms-retrieving";
 const kSmsDeliverySuccessObserverTopic   = "sms-delivery-success";
 const kSmsDeliveryErrorObserverTopic     = "sms-delivery-error";
 
+const NS_XPCOM_SHUTDOWN_OBSERVER_ID      = "xpcom-shutdown";
 const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
-const kXpcomShutdownObserverTopic        = "xpcom-shutdown";
-const kPrefenceChangedObserverTopic      = "nsPref:changed";
 const kMobileMessageDeletedObserverTopic = "mobile-message-deleted";
 
 // HTTP status codes:
 // @see http://tools.ietf.org/html/rfc2616#page-39
 const HTTP_STATUS_OK = 200;
 
 // Non-standard HTTP status for internal use.
 const _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS = 0;
@@ -54,27 +53,28 @@ const _MMS_ERROR_MESSAGE_DELETED = -1;
 const _MMS_ERROR_RADIO_DISABLED = -2;
 const _MMS_ERROR_NO_SIM_CARD = -3;
 
 const CONFIG_SEND_REPORT_NEVER       = 0;
 const CONFIG_SEND_REPORT_DEFAULT_NO  = 1;
 const CONFIG_SEND_REPORT_DEFAULT_YES = 2;
 const CONFIG_SEND_REPORT_ALWAYS      = 3;
 
+const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
+
 const TIME_TO_BUFFER_MMS_REQUESTS    = 30000;
 const PREF_TIME_TO_RELEASE_MMS_CONNECTION =
   Services.prefs.getIntPref("network.gonk.ms-release-mms-connection");
 
-const PREF_RETRIEVAL_MODE      = 'dom.mms.retrieval_mode';
+const kPrefRetrievalMode       = 'dom.mms.retrieval_mode';
 const RETRIEVAL_MODE_MANUAL    = "manual";
 const RETRIEVAL_MODE_AUTOMATIC = "automatic";
 const RETRIEVAL_MODE_AUTOMATIC_HOME = "automatic-home";
 const RETRIEVAL_MODE_NEVER     = "never";
 
-
 //Internal const values.
 const DELIVERY_RECEIVED       = "received";
 const DELIVERY_NOT_DOWNLOADED = "not-downloaded";
 const DELIVERY_SENDING        = "sending";
 const DELIVERY_SENT           = "sent";
 const DELIVERY_ERROR          = "error";
 
 const DELIVERY_STATUS_SUCCESS        = "success";
@@ -192,17 +192,17 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
       if (this.connected) {
         gRadioInterface.deactivateDataCallByType("mms");
       }
     },
 
     init: function init() {
       Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic,
                                false);
-      Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false);
+      Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
       this.settings.forEach(function(name) {
         Services.prefs.addObserver(name, this, false);
       }, this);
 
       try {
         this.mmsc = Services.prefs.getCharPref("ril.mms.mmsc");
         this.proxy = Services.prefs.getCharPref("ril.mms.mmsproxy");
         this.port = Services.prefs.getIntPref("ril.mms.mmsport");
@@ -336,20 +336,19 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
     clearMmsProxySettings: function clearMmsProxySettings() {
       this.mmsc = null;
       this.proxy = null;
       this.port = null;
       this.proxyInfo = null;
     },
 
     shutdown: function shutdown() {
+      Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
-      this.settings.forEach(function(name) {
-        Services.prefs.removeObserver(name, this);
-      }, this);
+
       this.connectTimer.cancel();
       this.flushPendingCallbacks(_HTTP_STATUS_RADIO_DISABLED);
       this.disconnectTimer.cancel();
       this.onDisconnectTimerTimeout();
     },
 
     // nsIObserver
 
@@ -365,17 +364,17 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
           }
 
           if (DEBUG) debug("Got the MMS network connected! Resend the buffered " +
                            "MMS requests: number: " + this.pendingCallbacks.length);
           this.connectTimer.cancel();
           this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS)
           break;
         }
-        case kPrefenceChangedObserverTopic: {
+        case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID: {
           if (data == "ril.radio.disabled") {
             try {
               this.radioDisabled = Services.prefs.getBoolPref("ril.radio.disabled");
             } catch (e) {
               if (DEBUG) debug("Updating preference 'ril.radio.disabled' fails.");
               this.radioDisabled = false;
             }
             return;
@@ -399,18 +398,17 @@ XPCOMUtils.defineLazyGetter(this, "gMmsC
             }
           } catch (e) {
             if (DEBUG) debug("Failed to update the MMS proxy settings from the" +
                              "preference.");
             this.clearMmsProxySettings();
           }
           break;
         }
-        case kXpcomShutdownObserverTopic: {
-          Services.obs.removeObserver(this, kXpcomShutdownObserverTopic);
+        case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
           this.shutdown();
         }
       }
     }
   };
   conn.init();
 
   return conn;
@@ -752,28 +750,28 @@ CancellableTransaction.prototype = {
   // Keep a reference to the callback when calling
   // |[Send|Retrieve]Transaction.run(callback)|.
   runCallback: null,
 
   isObserversAdded: false,
 
   registerRunCallback: function registerRunCallback(callback) {
     if (!this.isObserversAdded) {
-      Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false);
+      Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
       Services.obs.addObserver(this, kMobileMessageDeletedObserverTopic, false);
       this.isObserversAdded = true;
     }
 
     this.runCallback = callback;
     this.isCancelled = false;
   },
 
   removeObservers: function removeObservers() {
     if (this.isObserversAdded) {
-      Services.obs.removeObserver(this, kXpcomShutdownObserverTopic);
+      Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       Services.obs.removeObserver(this, kMobileMessageDeletedObserverTopic);
       this.isObserversAdded = false;
     }
   },
 
   runCallbackIfValid: function runCallbackIfValid(mmsStatus, msg) {
     this.removeObservers();
 
@@ -806,17 +804,17 @@ CancellableTransaction.prototype = {
       this.cancellable = null;
     }
   },
 
   // nsIObserver
 
   observe: function observe(subject, topic, data) {
     switch (topic) {
-      case kXpcomShutdownObserverTopic: {
+      case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
         this.cancelRunning();
         break;
       }
       case kMobileMessageDeletedObserverTopic: {
         data = JSON.parse(data);
         if (data.id != this.cancellableId) {
           return;
         }
@@ -1579,17 +1577,17 @@ MmsService.prototype = {
           && aMessageRecord) {
         if (DEBUG) debug("We already got the NotificationIndication with transactionId = "
                          + transactionId + " before.");
         return;
       }
 
       let retrievalMode = RETRIEVAL_MODE_MANUAL;
       try {
-        retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE);
+        retrievalMode = Services.prefs.getCharPref(kPrefRetrievalMode);
       } catch (e) {}
 
       let savableMessage = this.convertIntermediateToSavable(notification, retrievalMode);
 
       gMobileMessageDatabaseService
         .saveReceivedMessage(savableMessage,
                              this.saveReceivedMessageCallback.bind(this,
                                                                    retrievalMode,
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -20,32 +20,25 @@ const {classes: Cc, interfaces: Ci, util
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 Cu.import("resource://gre/modules/ObjectWrapper.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var RIL = {};
 Cu.import("resource://gre/modules/ril_consts.js", RIL);
 
-// set to true to in ril_consts.js to see debug messages
-var DEBUG = RIL.DEBUG_CONTENT_HELPER;
+const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
+
+const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
 
-// Read debug setting from pref
-try {
-  let debugPref = Services.prefs.getBoolPref("ril.debugging.enabled");
-  DEBUG = RIL.DEBUG_CONTENT_HELPER || debugPref;
-} catch (e) {}
+const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
 
-let debug;
-if (DEBUG) {
-  debug = function (s) {
-    dump("-*- RILContentHelper: " + s + "\n");
-  };
-} else {
-  debug = function (s) {};
+let DEBUG;
+function debug(s) {
+  dump("-*- RILContentHelper: " + s + "\n");
 }
 
 const RILCONTENTHELPER_CID =
   Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
 const GSMICCINFO_CID =
   Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}");
 const CDMAICCINFO_CID =
   Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}");
@@ -444,28 +437,33 @@ IccCardLockError.prototype = {
   __init: function(lockType, errorMsg, retryCount) {
     this.__DOM_IMPL__.init(errorMsg);
     this.lockType = lockType;
     this.retryCount = retryCount;
   },
 };
 
 function RILContentHelper() {
+  this.updateDebugFlag();
+
   this.rilContext = {
     cardState:            RIL.GECKO_CARDSTATE_UNKNOWN,
     networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
     iccInfo:              null,
     voiceConnectionInfo:  new MobileConnectionInfo(),
     dataConnectionInfo:   new MobileConnectionInfo()
   };
   this.voicemailInfo = new VoicemailInfo();
 
   this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
   this._windowsMap = [];
-  Services.obs.addObserver(this, "xpcom-shutdown", false);
+
+  Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
+
+  Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
 }
 
 RILContentHelper.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
                                          Ci.nsICellBroadcastProvider,
                                          Ci.nsIVoicemailProvider,
@@ -475,16 +473,23 @@ RILContentHelper.prototype = {
   classID:   RILCONTENTHELPER_CID,
   classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
                                     classDescription: "RILContentHelper",
                                     interfaces: [Ci.nsIMobileConnectionProvider,
                                                  Ci.nsICellBroadcastProvider,
                                                  Ci.nsIVoicemailProvider,
                                                  Ci.nsIIccProvider]}),
 
+  updateDebugFlag: function updateDebugFlag() {
+    try {
+      DEBUG = RIL.DEBUG_CONTENT_HELPER ||
+              Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
+    } catch (e) {}
+  },
+
   // An utility function to copy objects.
   updateInfo: function updateInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
     }
   },
 
   updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
@@ -1399,19 +1404,27 @@ RILContentHelper.prototype = {
 
   unregisterIccMsg: function unregisterIccMsg(listener) {
     this.unregisterListener("_iccListeners", listener);
   },
 
   // nsIObserver
 
   observe: function observe(subject, topic, data) {
-    if (topic == "xpcom-shutdown") {
-      this.destroyDOMRequestHelper();
-      Services.obs.removeObserver(this, "xpcom-shutdown");
+    switch (topic) {
+      case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
+        if (data == kPrefRilDebuggingEnabled) {
+          this.updateDebugFlag();
+        }
+        break;
+
+      case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
+        this.destroyDOMRequestHelper();
+        Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
+        break;
     }
   },
 
   // nsIMessageListener
 
   fireRequestSuccess: function fireRequestSuccess(requestId, result) {
     let request = this.takeRequest(requestId);
     if (!request) {
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -47,36 +47,40 @@ const RADIOINTERFACE_CID =
   Components.ID("{6a7c91f0-a2b3-4193-8562-8969296c0b54}");
 const RILNETWORKINTERFACE_CID =
   Components.ID("{3bdd52a9-3965-4130-b569-0ac5afed045e}");
 const GSMICCINFO_CID =
   Components.ID("{d90c4261-a99d-47bc-8b05-b057bb7e8f8a}");
 const CDMAICCINFO_CID =
   Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}");
 
+const NS_XPCOM_SHUTDOWN_OBSERVER_ID      = "xpcom-shutdown";
 const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
 const kSmsReceivedObserverTopic          = "sms-received";
 const kSilentSmsReceivedObserverTopic    = "silent-sms-received";
 const kSmsSendingObserverTopic           = "sms-sending";
 const kSmsSentObserverTopic              = "sms-sent";
 const kSmsFailedObserverTopic            = "sms-failed";
 const kSmsDeliverySuccessObserverTopic   = "sms-delivery-success";
 const kSmsDeliveryErrorObserverTopic     = "sms-delivery-error";
 const kMozSettingsChangedObserverTopic   = "mozsettings-changed";
 const kSysMsgListenerReadyObserverTopic  = "system-message-listener-ready";
 const kSysClockChangeObserverTopic       = "system-clock-change";
 const kScreenStateChangedTopic           = "screen-state-changed";
-const kClockAutoUpdateEnabled            = "time.clock.automatic-update.enabled";
-const kClockAutoUpdateAvailable          = "time.clock.automatic-update.available";
-const kTimezoneAutoUpdateEnabled         = "time.timezone.automatic-update.enabled";
-const kTimezoneAutoUpdateAvailable       = "time.timezone.automatic-update.available";
-const kCellBroadcastSearchList           = "ril.cellbroadcast.searchlist";
-const kCellBroadcastDisabled             = "ril.cellbroadcast.disabled";
-const kPrefenceChangedObserverTopic      = "nsPref:changed";
-const kClirModePreference                = "ril.clirMode";
+
+const kSettingsCellBroadcastSearchList = "ril.cellbroadcast.searchlist";
+const kSettingsClockAutoUpdateEnabled = "time.clock.automatic-update.enabled";
+const kSettingsClockAutoUpdateAvailable = "time.clock.automatic-update.available";
+const kSettingsTimezoneAutoUpdateEnabled = "time.timezone.automatic-update.enabled";
+const kSettingsTimezoneAutoUpdateAvailable = "time.timezone.automatic-update.available";
+
+const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
+
+const kPrefCellBroadcastDisabled = "ril.cellbroadcast.disabled";
+const kPrefClirModePreference = "ril.clirMode";
 
 const DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED = "received";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENDING  = "sending";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENT     = "sent";
 const DOM_MOBILE_MESSAGE_DELIVERY_ERROR    = "error";
 
 const RADIO_POWER_OFF_TIMEOUT = 30000;
 const SMS_HANDLED_WAKELOCK_TIMEOUT = 5000;
@@ -204,25 +208,25 @@ XPCOMUtils.defineLazyGetter(this, "gMess
     topics: [],
 
     targetMessageQueue: [],
     ready: false,
 
     init: function init(ril) {
       this.ril = ril;
 
-      Services.obs.addObserver(this, "xpcom-shutdown", false);
+      Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
       Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
       this._registerMessageListeners();
     },
 
     _shutdown: function _shutdown() {
       this.ril = null;
 
-      Services.obs.removeObserver(this, "xpcom-shutdown");
+      Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       this._unregisterMessageListeners();
     },
 
     _registerMessageListeners: function _registerMessageListeners() {
       ppmm.addMessageListener("child-process-shutdown", this);
       for (let msgname of RIL_IPC_MOBILECONNECTION_MSG_NAMES) {
         ppmm.addMessageListener(msgname, this);
       }
@@ -426,17 +430,17 @@ XPCOMUtils.defineLazyGetter(this, "gMess
      */
 
     observe: function observe(subject, topic, data) {
       switch (topic) {
         case kSysMsgListenerReadyObserverTopic:
           Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
           this._resendQueuedTargetMessage();
           break;
-        case "xpcom-shutdown":
+        case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
           this._shutdown();
           break;
       }
     },
 
     sendMobileConnectionMessage: function sendMobileConnectionMessage(message, clientId, data) {
       this._sendTargetMessage("mobileconnection", message, {
         clientId: clientId,
@@ -519,21 +523,21 @@ function RadioInterfaceLayer() {
   let options = {
     debug: debugPref,
     cellBroadcastDisabled: false,
     clirMode: RIL.CLIR_DEFAULT
   };
 
   try {
     options.cellBroadcastDisabled =
-      Services.prefs.getBoolPref(kCellBroadcastDisabled);
+      Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
   } catch(e) {}
 
   try {
-    options.clirMode = Services.prefs.getIntPref(kClirModePreference);
+    options.clirMode = Services.prefs.getIntPref(kPrefClirModePreference);
   } catch(e) {}
 
   let numIfaces = this.numRadioInterfaces;
   debug(numIfaces + " interfaces");
   this.radioInterfaces = [];
   for (let clientId = 0; clientId < numIfaces; clientId++) {
     options.clientId = clientId;
     this.radioInterfaces.push(new RadioInterface(options));
@@ -776,40 +780,40 @@ function RadioInterface(options) {
 
   // Read the APN data from the settings DB.
   lock.get("ril.data.roaming_enabled", this);
   lock.get("ril.data.enabled", this);
   lock.get("ril.data.apnSettings", this);
 
   // Read the 'time.clock.automatic-update.enabled' setting to see if
   // we need to adjust the system clock time by NITZ or SNTP.
-  lock.get(kClockAutoUpdateEnabled, this);
+  lock.get(kSettingsClockAutoUpdateEnabled, this);
 
   // Read the 'time.timezone.automatic-update.enabled' setting to see if
   // we need to adjust the system timezone by NITZ.
-  lock.get(kTimezoneAutoUpdateEnabled, this);
+  lock.get(kSettingsTimezoneAutoUpdateEnabled, this);
 
   // Set "time.clock.automatic-update.available" to false when starting up.
   this.setClockAutoUpdateAvailable(false);
 
   // Set "time.timezone.automatic-update.available" to false when starting up.
   this.setTimezoneAutoUpdateAvailable(false);
 
   // Read the Cell Broadcast Search List setting, string of integers or integer
   // ranges separated by comma, to set listening channels.
-  lock.get(kCellBroadcastSearchList, this);
-
-  Services.obs.addObserver(this, "xpcom-shutdown", false);
+  lock.get(kSettingsCellBroadcastSearchList, this);
+
+  Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
   Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
   Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
   Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
   Services.obs.addObserver(this, kScreenStateChangedTopic, false);
 
   Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic, false);
-  Services.prefs.addObserver(kCellBroadcastDisabled, this, false);
+  Services.prefs.addObserver(kPrefCellBroadcastDisabled, this, false);
 
   this.portAddressedSmsApps = {};
   this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this);
 
   this._sntp = new Sntp(this.setClockBySntp.bind(this),
                         Services.prefs.getIntPref('network.sntp.maxRetryCount'),
                         Services.prefs.getIntPref('network.sntp.refreshPeriod'),
                         Services.prefs.getIntPref('network.sntp.timeout'),
@@ -1331,17 +1335,17 @@ RadioInterface.prototype = {
       return;
     }
 
     this.workerMessenger.send("setCellBroadcastSearchList",
                               { searchListStr: newSearchListStr },
                               (function callback(response) {
       if (!response.success) {
         let lock = gSettingsService.createLock();
-        lock.set(kCellBroadcastSearchList,
+        lock.set(kSettingsCellBroadcastSearchList,
                  this._cellBroadcastSearchListStr, null);
       } else {
         this._cellBroadcastSearchListStr = response.searchListStr;
       }
 
       return false;
     }).bind(this));
   },
@@ -1963,25 +1967,25 @@ RadioInterface.prototype = {
     this._deliverDataCallCallback("receiveDataCallList",
                                   [message.datacalls, message.datacalls.length]);
   },
 
   /**
    * Set the setting value of "time.clock.automatic-update.available".
    */
   setClockAutoUpdateAvailable: function setClockAutoUpdateAvailable(value) {
-    gSettingsService.createLock().set(kClockAutoUpdateAvailable, value, null,
+    gSettingsService.createLock().set(kSettingsClockAutoUpdateAvailable, value, null,
                                       "fromInternalSetting");
   },
 
   /**
    * Set the setting value of "time.timezone.automatic-update.available".
    */
   setTimezoneAutoUpdateAvailable: function setTimezoneAutoUpdateAvailable(value) {
-    gSettingsService.createLock().set(kTimezoneAutoUpdateAvailable, value, null,
+    gSettingsService.createLock().set(kSettingsTimezoneAutoUpdateAvailable, value, null,
                                       "fromInternalSetting");
   },
 
   /**
    * Set the system clock by NITZ.
    */
   setClockByNitz: function setClockByNitz(message) {
     // To set the system clock time. Note that there could be a time diff
@@ -2147,42 +2151,41 @@ RadioInterface.prototype = {
         Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
         this._sysMsgListenerReady = true;
         this._ensureRadioState();
         break;
       case kMozSettingsChangedObserverTopic:
         let setting = JSON.parse(data);
         this.handleSettingsChange(setting.key, setting.value, setting.message);
         break;
-      case kPrefenceChangedObserverTopic:
-        if (data === kCellBroadcastDisabled) {
+      case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
+        if (data === kPrefCellBroadcastDisabled) {
           let value = false;
           try {
-            value = Services.prefs.getBoolPref(kCellBroadcastDisabled);
+            value = Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
           } catch(e) {}
           this.workerMessenger.send("setCellBroadcastDisabled",
                                     { disabled: value });
         }
         break;
-      case "xpcom-shutdown":
+      case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
         // Cancel the timer of the CPU wake lock for handling the received SMS.
         this._cancelSmsHandledWakeLockTimer();
 
         // Shutdown all RIL network interfaces
         for each (let apnSetting in this.apnSettings.byAPN) {
           if (apnSetting.iface) {
             apnSetting.iface.shutdown();
           }
         }
-        Services.obs.removeObserver(this, "xpcom-shutdown");
+        Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
         Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
         Services.obs.removeObserver(this, kSysClockChangeObserverTopic);
         Services.obs.removeObserver(this, kScreenStateChangedTopic);
         Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
-        Services.prefs.removeObserver(kCellBroadcastDisabled, this);
         break;
       case kSysClockChangeObserverTopic:
         let offset = parseInt(data, 10);
         if (this._lastNitzMessage) {
           this._lastNitzMessage.receiveTimeInMS += offset;
         }
         this._sntp.updateOffset(offset);
         break;
@@ -2235,31 +2238,31 @@ RadioInterface.prototype = {
   _sntp: null,
 
   // Cell Broadcast settings values.
   _cellBroadcastSearchListStr: null,
 
   handleSettingsChange: function handleSettingsChange(aName, aResult, aMessage) {
     // Don't allow any content processes to modify the setting
     // "time.clock.automatic-update.available" except for the chrome process.
-    if (aName === kClockAutoUpdateAvailable &&
+    if (aName === kSettingsClockAutoUpdateAvailable &&
         aMessage !== "fromInternalSetting") {
       let isClockAutoUpdateAvailable = this._lastNitzMessage !== null ||
                                        this._sntp.isAvailable();
       if (aResult !== isClockAutoUpdateAvailable) {
         debug("Content processes cannot modify 'time.clock.automatic-update.available'. Restore!");
         // Restore the setting to the current value.
         this.setClockAutoUpdateAvailable(isClockAutoUpdateAvailable);
       }
     }
 
     // Don't allow any content processes to modify the setting
     // "time.timezone.automatic-update.available" except for the chrome
     // process.
-    if (aName === kTimezoneAutoUpdateAvailable &&
+    if (aName === kSettingsTimezoneAutoUpdateAvailable &&
         aMessage !== "fromInternalSetting") {
       let isTimezoneAutoUpdateAvailable = this._lastNitzMessage !== null;
       if (aResult !== isTimezoneAutoUpdateAvailable) {
         if (DEBUG) {
           this.debug("Content processes cannot modify 'time.timezone.automatic-update.available'. Restore!");
         }
         // Restore the setting to the current value.
         this.setTimezoneAutoUpdateAvailable(isTimezoneAutoUpdateAvailable);
@@ -2301,17 +2304,17 @@ RadioInterface.prototype = {
         break;
       case "ril.data.apnSettings":
         if (DEBUG) this.debug("'ril.data.apnSettings' is now " + JSON.stringify(aResult));
         if (aResult) {
           this.updateApnSettings(aResult);
           this.updateRILNetworkInterface();
         }
         break;
-      case kClockAutoUpdateEnabled:
+      case kSettingsClockAutoUpdateEnabled:
         this._clockAutoUpdateEnabled = aResult;
         if (!this._clockAutoUpdateEnabled) {
           break;
         }
 
         // Set the latest cached NITZ time if it's available.
         if (this._lastNitzMessage) {
           this.setClockByNitz(this._lastNitzMessage);
@@ -2321,29 +2324,29 @@ RadioInterface.prototype = {
           if (!this._sntp.isExpired()) {
             this.setClockBySntp(this._sntp.getOffset());
           } else {
             // Or refresh the SNTP.
             this._sntp.request();
           }
         }
         break;
-      case kTimezoneAutoUpdateEnabled:
+      case kSettingsTimezoneAutoUpdateEnabled:
         this._timezoneAutoUpdateEnabled = aResult;
 
         if (this._timezoneAutoUpdateEnabled) {
           // Apply the latest cached NITZ for timezone if it's available.
           if (this._timezoneAutoUpdateEnabled && this._lastNitzMessage) {
             this.setTimezoneByNitz(this._lastNitzMessage);
           }
         }
         break;
-      case kCellBroadcastSearchList:
+      case kSettingsCellBroadcastSearchList:
         if (DEBUG) {
-          this.debug("'" + kCellBroadcastSearchList + "' is now " + aResult);
+          this.debug("'" + kSettingsCellBroadcastSearchList + "' is now " + aResult);
         }
         this.setCellBroadcastSearchList(aResult);
         break;
     }
   },
 
   handleError: function handleError(aErrorMessage) {
     if (DEBUG) this.debug("There was an error while reading RIL settings.");
@@ -2376,20 +2379,20 @@ RadioInterface.prototype = {
   _sendCfStateChanged: function _sendCfStateChanged(message) {
     gMessageManager.sendMobileConnectionMessage("RIL:CfStateChanged",
                                                 this.clientId, message);
   },
 
   _updateCallingLineIdRestrictionPref:
     function _updateCallingLineIdRestrictionPref(mode) {
     try {
-      Services.prefs.setIntPref(kClirModePreference, mode);
+      Services.prefs.setIntPref(kPrefClirModePreference, mode);
       Services.prefs.savePrefFile(null);
       if (DEBUG) {
-        this.debug(kClirModePreference + " pref is now " + mode);
+        this.debug(kPrefClirModePreference + " pref is now " + mode);
       }
     } catch (e) {}
   },
 
   sendMMI: function sendMMI(target, message) {
     if (DEBUG) this.debug("SendMMI " + JSON.stringify(message));
     this.workerMessenger.send("sendMMI", message, (function(response) {
       if (response.isSetCallForward) {
--- a/dom/telephony/gonk/TelephonyProvider.js
+++ b/dom/telephony/gonk/TelephonyProvider.js
@@ -13,18 +13,21 @@ Cu.import("resource://gre/modules/Servic
 var RIL = {};
 Cu.import("resource://gre/modules/ril_consts.js", RIL);
 
 const GONK_TELEPHONYPROVIDER_CONTRACTID =
   "@mozilla.org/telephony/gonktelephonyprovider;1";
 const GONK_TELEPHONYPROVIDER_CID =
   Components.ID("{67d26434-d063-4d28-9f48-5b3189788155}");
 
-const kPrefenceChangedObserverTopic = "nsPref:changed";
-const kXpcomShutdownObserverTopic   = "xpcom-shutdown";
+const NS_XPCOM_SHUTDOWN_OBSERVER_ID   = "xpcom-shutdown";
+
+const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
+
+const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
 
 const nsIAudioManager = Ci.nsIAudioManager;
 const nsITelephonyProvider = Ci.nsITelephonyProvider;
 
 const CALL_WAKELOCK_TIMEOUT = 5000;
 
 let DEBUG;
 function debug(s) {
@@ -79,18 +82,19 @@ XPCOMUtils.defineLazyGetter(this, "gPhon
   return ns.PhoneNumberUtils;
 });
 
 function TelephonyProvider() {
   this._listeners = [];
 
   this._updateDebugFlag();
 
-  Services.obs.addObserver(this, kPrefenceChangedObserverTopic, false);
-  Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false);
+  Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
+
+  Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
 }
 TelephonyProvider.prototype = {
   classID: GONK_TELEPHONYPROVIDER_CID,
   classInfo: XPCOMUtils.generateCI({classID: GONK_TELEPHONYPROVIDER_CID,
                                     contractID: GONK_TELEPHONYPROVIDER_CONTRACTID,
                                     classDescription: "TelephonyProvider",
                                     interfaces: [Ci.nsITelephonyProvider,
                                                  Ci.nsIGonkTelephonyProvider],
@@ -260,17 +264,17 @@ TelephonyProvider.prototype = {
     }
 
     return false;
   },
 
   _updateDebugFlag: function _updateDebugFlag() {
     try {
       DEBUG = RIL.DEBUG_RIL ||
-              Services.prefs.getBoolPref("ril.debugging.enabled");
+              Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
     } catch (e) {}
   },
 
   /**
    * nsITelephonyProvider interface.
    */
 
   registerListener: function(aListener) {
@@ -501,26 +505,25 @@ TelephonyProvider.prototype = {
   },
 
   /**
    * nsIObserver interface.
    */
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
-      case kPrefenceChangedObserverTopic:
-        if (aData === "ril.debugging.enabled") {
+      case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
+        if (aData === kPrefRilDebuggingEnabled) {
           this._updateDebugFlag();
         }
         break;
 
-      case kXpcomShutdownObserverTopic:
+      case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
         // Cancel the timer for the call-ring wake lock.
         this._cancelCallRingWakeLockTimer();
 
-        Services.obs.removeObserver(this, kPrefenceChangedObserverTopic);
-        Services.obs.removeObserver(this, kXpcomShutdownObserverTopic);
+        Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
         break;
     }
   }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelephonyProvider]);