From fca0d639fbcd0c30169c80261781005510390d09 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Fri, 31 Oct 2014 15:15:47 +0800 Subject: [PATCH] Bug 1092013 - Part 1: mozMobileConnection.data.cell is reset to `null` unexpectedly in MobileConnectionService. r=hsinyi --- .../gonk/MobileConnectionService.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dom/mobileconnection/gonk/MobileConnectionService.js b/dom/mobileconnection/gonk/MobileConnectionService.js index 962bc05a187..cdc3bdfa713 100644 --- a/dom/mobileconnection/gonk/MobileConnectionService.js +++ b/dom/mobileconnection/gonk/MobileConnectionService.js @@ -478,6 +478,12 @@ MobileConnectionProvider.prototype = { return true; }, + /** + * The design of this updating function is to update the attribute in + * |aDestInfo| *only if* new data (e.g. aSrcInfo) contains the same attribute. + * Thus, for the attribute in |aDestInfo| that isn't showed in |aSrcInfo|, it + * should just keep the original value unchanged. + */ _updateConnectionInfo: function(aDestInfo, aSrcInfo) { let isUpdated = false; for (let key in aSrcInfo) { @@ -502,15 +508,13 @@ MobileConnectionProvider.prototype = { } else { aDestInfo.network = this._operatorInfo; - if (aSrcInfo.cell == null) { - if (aDestInfo.cell != null) { - isUpdated = true; - aDestInfo.cell = null; - } - } else { - if (aDestInfo.cell == null) { + // If no new cell data is passed, we should just keep the original cell + // data unchanged. + if (aSrcInfo.cell) { + if (!aDestInfo.cell) { aDestInfo.cell = new MobileCellInfo(); } + isUpdated = this._updateInfo(aDestInfo.cell, aSrcInfo.cell) || isUpdated; } } @@ -520,6 +524,12 @@ MobileConnectionProvider.prototype = { return isUpdated; }, + /** + * The design of this updating function is to update the attribute in + * |aDestInfo| *only if* new data (e.g. aSrcInfo) contains the same attribute. + * Thus, for the attribute in |aDestInfo| that isn't showed in |aSrcInfo|, it + * should just keep the original value unchanged. + */ _updateInfo: function(aDestInfo, aSrcInfo) { let isUpdated = false; for (let key in aSrcInfo) {