зеркало из https://github.com/mozilla/gecko-dev.git
Bug 733331 - Part 2: Update enabledGsmTableTuples when MCC changes in SmsService.js and fix segmentChars in SmsSegmentHelper.jsm. r=btseng
This commit is contained in:
Родитель
4c21ba9df2
Коммит
644da0a93b
|
@ -122,10 +122,9 @@ this.SmsSegmentHelper = {
|
|||
*
|
||||
* |enabledGsmTableTuples|:
|
||||
* List of tuples of national language identifier pairs.
|
||||
* TODO: Support static/runtime settings, see bug 733331.
|
||||
* |segmentRef16Bit|:
|
||||
* Use 16-bit reference number for concatenated outgoint messages.
|
||||
* TODO: Support static/runtime settings, see bug 733331.
|
||||
* TODO: Support static/runtime settings, see bug 1019443.
|
||||
*/
|
||||
enabledGsmTableTuples: [
|
||||
[RIL.PDU_NL_IDENTIFIER_DEFAULT, RIL.PDU_NL_IDENTIFIER_DEFAULT],
|
||||
|
@ -162,8 +161,8 @@ this.SmsSegmentHelper = {
|
|||
if ((bodySeptets + headerSeptets) > segmentSeptets) {
|
||||
headerLen += this.segmentRef16Bit ? 6 : 5;
|
||||
headerSeptets = Math.ceil((headerLen + 1) * 8 / 7);
|
||||
segmentSeptets -= headerSeptets;
|
||||
}
|
||||
segmentSeptets -= headerSeptets;
|
||||
|
||||
let segments = Math.ceil(bodySeptets / segmentSeptets);
|
||||
let userDataSeptets = bodySeptets + headerSeptets * segments;
|
||||
|
@ -423,4 +422,4 @@ this.SmsSegmentHelper = {
|
|||
}
|
||||
};
|
||||
|
||||
this.EXPORTED_SYMBOLS = [ 'SmsSegmentHelper' ];
|
||||
this.EXPORTED_SYMBOLS = [ 'SmsSegmentHelper' ];
|
||||
|
|
|
@ -21,6 +21,7 @@ const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
|||
const kPrefDefaultServiceId = "dom.sms.defaultServiceId";
|
||||
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
|
||||
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
|
||||
const kPrefLastKnownSimMcc = "ril.lastKnownSimMcc";
|
||||
|
||||
const kDiskSpaceWatcherObserverTopic = "disk-space-watcher";
|
||||
|
||||
|
@ -55,6 +56,10 @@ XPCOMUtils.defineLazyGetter(this, "gRadioInterfaces", function() {
|
|||
XPCOMUtils.defineLazyGetter(this, "gSmsSegmentHelper", function() {
|
||||
let ns = {};
|
||||
Cu.import("resource://gre/modules/SmsSegmentHelper.jsm", ns);
|
||||
|
||||
// Initialize enabledGsmTableTuples from current MCC.
|
||||
ns.SmsSegmentHelper.enabledGsmTableTuples = getEnabledGsmTableTuplesFromMcc();
|
||||
|
||||
return ns.SmsSegmentHelper;
|
||||
});
|
||||
|
||||
|
@ -111,6 +116,7 @@ function SmsService() {
|
|||
|
||||
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
||||
Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
|
||||
Services.prefs.addObserver(kPrefLastKnownSimMcc, this, false);
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
Services.obs.addObserver(this, kDiskSpaceWatcherObserverTopic, false);
|
||||
}
|
||||
|
@ -1055,6 +1061,10 @@ SmsService.prototype = {
|
|||
else if (aData === kPrefDefaultServiceId) {
|
||||
this.smsDefaultServiceId = this._getDefaultServiceId();
|
||||
}
|
||||
else if ( aData === kPrefLastKnownSimMcc) {
|
||||
gSmsSegmentHelper.enabledGsmTableTuples =
|
||||
getEnabledGsmTableTuplesFromMcc();
|
||||
}
|
||||
break;
|
||||
case kDiskSpaceWatcherObserverTopic:
|
||||
if (DEBUG) {
|
||||
|
@ -1074,4 +1084,26 @@ SmsService.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get enabled GSM national language locking shift / single shift table pairs
|
||||
* for current SIM MCC.
|
||||
*
|
||||
* @return a list of pairs of national language identifiers for locking shift
|
||||
* table and single shfit table, respectively.
|
||||
*/
|
||||
function getEnabledGsmTableTuplesFromMcc() {
|
||||
let mcc;
|
||||
try {
|
||||
mcc = Services.prefs.getCharPref(kPrefLastKnownSimMcc);
|
||||
} catch (e) {}
|
||||
let tuples = [[RIL.PDU_NL_IDENTIFIER_DEFAULT,
|
||||
RIL.PDU_NL_IDENTIFIER_DEFAULT]];
|
||||
let extraTuples = RIL.PDU_MCC_NL_TABLE_TUPLES_MAPPING[mcc];
|
||||
if (extraTuples) {
|
||||
tuples = tuples.concat(extraTuples);
|
||||
}
|
||||
|
||||
return tuples;
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsService]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче