mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge b-i to m-c
This commit is contained in:
commit
d364bc4d01
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"revision": "0818ccb401e793689adda5b6253e52fdeccba2f9",
|
||||
"revision": "1adfbae4582a2cebf4b35c822044299aa8dd1026",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf497b7adfaa4c087d492acf7f143a61b5ec08e9"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae90f9b322509ee09fbd3963bd23e142845613ab"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -1557,47 +1557,14 @@ DataConnectionHandler.prototype = {
|
||||
};
|
||||
|
||||
function RadioInterfaceLayer() {
|
||||
let options = {
|
||||
debug: debugPref,
|
||||
cellBroadcastDisabled: false,
|
||||
clirMode: RIL.CLIR_DEFAULT,
|
||||
quirks: {
|
||||
callstateExtraUint32:
|
||||
libcutils.property_get("ro.moz.ril.callstate_extra_int", "false") === "true",
|
||||
v5Legacy:
|
||||
libcutils.property_get("ro.moz.ril.v5_legacy", "true") === "true",
|
||||
requestUseDialEmergencyCall:
|
||||
libcutils.property_get("ro.moz.ril.dial_emergency_call", "false") === "true",
|
||||
simAppStateExtraFields:
|
||||
libcutils.property_get("ro.moz.ril.simstate_extra_field", "false") === "true",
|
||||
extraUint2ndCall:
|
||||
libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") == "true",
|
||||
haveQueryIccLockRetryCount:
|
||||
libcutils.property_get("ro.moz.ril.query_icc_count", "false") == "true",
|
||||
sendStkProfileDownload:
|
||||
libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") == "true",
|
||||
dataRegistrationOnDemand:
|
||||
libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true"
|
||||
},
|
||||
rilEmergencyNumbers: libcutils.property_get("ril.ecclist") ||
|
||||
libcutils.property_get("ro.ril.ecclist")
|
||||
};
|
||||
|
||||
try {
|
||||
options.cellBroadcastDisabled =
|
||||
Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
|
||||
} catch(e) {}
|
||||
|
||||
try {
|
||||
options.clirMode = Services.prefs.getIntPref(kPrefClirModePreference);
|
||||
} catch(e) {}
|
||||
let workerMessenger = new WorkerMessenger();
|
||||
workerMessenger.init();
|
||||
|
||||
let numIfaces = this.numRadioInterfaces;
|
||||
if (DEBUG) debug(numIfaces + " interfaces");
|
||||
this.radioInterfaces = [];
|
||||
for (let clientId = 0; clientId < numIfaces; clientId++) {
|
||||
options.clientId = clientId;
|
||||
this.radioInterfaces.push(new RadioInterface(options));
|
||||
this.radioInterfaces.push(new RadioInterface(clientId, workerMessenger));
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
@ -1672,25 +1639,17 @@ XPCOMUtils.defineLazyGetter(RadioInterfaceLayer.prototype,
|
||||
return 1;
|
||||
});
|
||||
|
||||
function WorkerMessenger(radioInterface, options) {
|
||||
function WorkerMessenger() {
|
||||
// Initial owning attributes.
|
||||
this.radioInterface = radioInterface;
|
||||
this.radioInterfaces = [];
|
||||
this.tokenCallbackMap = {};
|
||||
|
||||
// Add a convenient alias to |radioInterface.debug()|.
|
||||
this.debug = radioInterface.debug.bind(radioInterface);
|
||||
|
||||
if (DEBUG) this.debug("Starting RIL Worker[" + options.clientId + "]");
|
||||
this.worker = new ChromeWorker("resource://gre/modules/ril_worker.js");
|
||||
this.worker.onerror = this.onerror.bind(this);
|
||||
this.worker.onmessage = this.onmessage.bind(this);
|
||||
|
||||
this.send("setInitialOptions", options);
|
||||
|
||||
gSystemWorkerManager.registerRilWorker(options.clientId, this.worker);
|
||||
}
|
||||
WorkerMessenger.prototype = {
|
||||
radioInterface: null,
|
||||
radioInterfaces: null,
|
||||
worker: null,
|
||||
|
||||
// This gets incremented each time we send out a message.
|
||||
@ -1699,9 +1658,53 @@ WorkerMessenger.prototype = {
|
||||
// Maps tokens we send out with messages to the message callback.
|
||||
tokenCallbackMap: null,
|
||||
|
||||
init: function() {
|
||||
let options = {
|
||||
debug: DEBUG,
|
||||
cellBroadcastDisabled: false,
|
||||
clirMode: RIL.CLIR_DEFAULT,
|
||||
quirks: {
|
||||
callstateExtraUint32:
|
||||
libcutils.property_get("ro.moz.ril.callstate_extra_int", "false") === "true",
|
||||
v5Legacy:
|
||||
libcutils.property_get("ro.moz.ril.v5_legacy", "true") === "true",
|
||||
requestUseDialEmergencyCall:
|
||||
libcutils.property_get("ro.moz.ril.dial_emergency_call", "false") === "true",
|
||||
simAppStateExtraFields:
|
||||
libcutils.property_get("ro.moz.ril.simstate_extra_field", "false") === "true",
|
||||
extraUint2ndCall:
|
||||
libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") == "true",
|
||||
haveQueryIccLockRetryCount:
|
||||
libcutils.property_get("ro.moz.ril.query_icc_count", "false") == "true",
|
||||
sendStkProfileDownload:
|
||||
libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") == "true",
|
||||
dataRegistrationOnDemand:
|
||||
libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true"
|
||||
},
|
||||
rilEmergencyNumbers: libcutils.property_get("ril.ecclist") ||
|
||||
libcutils.property_get("ro.ril.ecclist")
|
||||
};
|
||||
|
||||
try {
|
||||
options.cellBroadcastDisabled =
|
||||
Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
|
||||
} catch(e) {}
|
||||
|
||||
try {
|
||||
options.clirMode = Services.prefs.getIntPref(kPrefClirModePreference);
|
||||
} catch(e) {}
|
||||
|
||||
this.send(null, "setInitialOptions", options);
|
||||
},
|
||||
|
||||
debug: function(aClientId, aMessage) {
|
||||
// We use the same debug subject with RadioInterface's here.
|
||||
dump("-*- RadioInterface[" + aClientId + "]: " + aMessage + "\n");
|
||||
},
|
||||
|
||||
onerror: function(event) {
|
||||
if (DEBUG) {
|
||||
this.debug("Got an error: " + event.filename + ":" +
|
||||
this.debug("X", "Got an error: " + event.filename + ":" +
|
||||
event.lineno + ": " + event.message + "\n");
|
||||
}
|
||||
event.preventDefault();
|
||||
@ -1712,20 +1715,26 @@ WorkerMessenger.prototype = {
|
||||
*/
|
||||
onmessage: function(event) {
|
||||
let message = event.data;
|
||||
let clientId = message.rilMessageClientId;
|
||||
if (clientId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
this.debug("Received message from worker: " + JSON.stringify(message));
|
||||
this.debug(clientId, "Received message from worker: " + JSON.stringify(message));
|
||||
}
|
||||
|
||||
let token = message.rilMessageToken;
|
||||
if (token == null) {
|
||||
// That's an unsolicited message. Pass to RadioInterface directly.
|
||||
this.radioInterface.handleUnsolicitedWorkerMessage(message);
|
||||
let radioInterface = this.radioInterfaces[clientId];
|
||||
radioInterface.handleUnsolicitedWorkerMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
let callback = this.tokenCallbackMap[message.rilMessageToken];
|
||||
if (!callback) {
|
||||
if (DEBUG) this.debug("Ignore orphan token: " + message.rilMessageToken);
|
||||
if (DEBUG) this.debug(clientId, "Ignore orphan token: " + message.rilMessageToken);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1733,7 +1742,7 @@ WorkerMessenger.prototype = {
|
||||
try {
|
||||
keep = callback(message);
|
||||
} catch(e) {
|
||||
if (DEBUG) this.debug("callback throws an exception: " + e);
|
||||
if (DEBUG) this.debug(clientId, "callback throws an exception: " + e);
|
||||
}
|
||||
|
||||
if (!keep) {
|
||||
@ -1741,6 +1750,16 @@ WorkerMessenger.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
registerClient: function(aClientId, aRadioInterface) {
|
||||
if (DEBUG) this.debug(aClientId, "Starting RIL Worker");
|
||||
|
||||
// Keep a reference so that we can dispatch unsolicited messages to it.
|
||||
this.radioInterfaces[aClientId] = aRadioInterface;
|
||||
|
||||
this.send(null, "registerClient", { clientId: aClientId });
|
||||
gSystemWorkerManager.registerRilWorker(aClientId, this.worker);
|
||||
},
|
||||
|
||||
/**
|
||||
* Send arbitrary message to worker.
|
||||
*
|
||||
@ -1756,9 +1775,10 @@ WorkerMessenger.prototype = {
|
||||
* value true to keep current token-callback mapping and wait for
|
||||
* another worker reply, or false to remove the mapping.
|
||||
*/
|
||||
send: function(rilMessageType, message, callback) {
|
||||
send: function(clientId, rilMessageType, message, callback) {
|
||||
message = message || {};
|
||||
|
||||
message.rilMessageClientId = clientId;
|
||||
message.rilMessageToken = this.token;
|
||||
this.token++;
|
||||
|
||||
@ -1789,11 +1809,11 @@ WorkerMessenger.prototype = {
|
||||
*
|
||||
* @TODO: Bug 815526 - deprecate RILContentHelper.
|
||||
*/
|
||||
sendWithIPCMessage: function(msg, rilMessageType, ipcType) {
|
||||
this.send(rilMessageType, msg.json.data, (function(reply) {
|
||||
sendWithIPCMessage: function(clientId, msg, rilMessageType, ipcType) {
|
||||
this.send(clientId, rilMessageType, msg.json.data, (function(reply) {
|
||||
ipcType = ipcType || msg.name;
|
||||
msg.target.sendAsyncMessage(ipcType, {
|
||||
clientId: this.radioInterface.clientId,
|
||||
clientId: clientId,
|
||||
data: reply
|
||||
});
|
||||
return false;
|
||||
@ -1801,9 +1821,14 @@ WorkerMessenger.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function RadioInterface(options) {
|
||||
this.clientId = options.clientId;
|
||||
this.workerMessenger = new WorkerMessenger(this, options);
|
||||
function RadioInterface(aClientId, aWorkerMessenger) {
|
||||
this.clientId = aClientId;
|
||||
this.workerMessenger = {
|
||||
send: aWorkerMessenger.send.bind(aWorkerMessenger, aClientId),
|
||||
sendWithIPCMessage:
|
||||
aWorkerMessenger.sendWithIPCMessage.bind(aWorkerMessenger, aClientId),
|
||||
};
|
||||
aWorkerMessenger.registerClient(aClientId, this);
|
||||
|
||||
this.supportedNetworkTypes = this.getSupportedNetworkTypes();
|
||||
|
||||
@ -1896,7 +1921,7 @@ RadioInterface.prototype = {
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISettingsServiceCallback]),
|
||||
|
||||
// A private WorkerMessenger instance.
|
||||
// A private wrapped WorkerMessenger instance.
|
||||
workerMessenger: null,
|
||||
|
||||
debug: function(s) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,15 +43,11 @@ function newWorker(custom_ns) {
|
||||
onmessage: undefined,
|
||||
onerror: undefined,
|
||||
|
||||
CLIENT_ID: 0,
|
||||
DEBUG: true
|
||||
};
|
||||
// The 'self' variable in a worker points to the worker's own namespace.
|
||||
worker_ns.self = worker_ns;
|
||||
|
||||
// systemlibs.js utilizes ctypes for loading native libraries.
|
||||
Cu.import("resource://gre/modules/ctypes.jsm", worker_ns);
|
||||
|
||||
// Copy the custom definitions over.
|
||||
for (let key in custom_ns) {
|
||||
worker_ns[key] = custom_ns[key];
|
||||
@ -76,6 +72,9 @@ function newWorker(custom_ns) {
|
||||
// Load the RIL worker itself.
|
||||
worker_ns.importScripts("ril_worker.js");
|
||||
|
||||
// Register at least one client.
|
||||
worker_ns.ContextPool.registerClient({ clientId: 0 });
|
||||
|
||||
return worker_ns;
|
||||
}
|
||||
|
||||
|
@ -15,18 +15,19 @@ const NEW_PIN = "1234";
|
||||
*/
|
||||
function newUint8Worker() {
|
||||
let worker = newWorker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let index = 0; // index for read
|
||||
let buf = [];
|
||||
|
||||
worker.Buf.writeUint8 = function(value) {
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
buf.push(value);
|
||||
};
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
|
||||
@ -37,7 +38,8 @@ function newUint8Worker() {
|
||||
|
||||
add_test(function test_change_call_barring_password() {
|
||||
let worker = newUint8Worker();
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
|
||||
function do_test(facility, pin, newPin) {
|
||||
buf.sendParcel = function fakeSendParcel () {
|
||||
@ -55,7 +57,7 @@ add_test(function test_change_call_barring_password() {
|
||||
};
|
||||
|
||||
let options = {facility: facility, pin: pin, newPin: newPin};
|
||||
worker.RIL.changeCallBarringPassword(options);
|
||||
context.RIL.changeCallBarringPassword(options);
|
||||
}
|
||||
|
||||
do_test(ICC_CB_FACILITY_BA_ALL, PIN, NEW_PIN);
|
||||
@ -73,15 +75,16 @@ add_test(function test_check_change_call_barring_password_result() {
|
||||
}
|
||||
});
|
||||
|
||||
worker.RIL.changeCallBarringPassword =
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
context.RIL.changeCallBarringPassword =
|
||||
function fakeChangeCallBarringPassword(options) {
|
||||
barringPasswordOptions = options;
|
||||
worker.RIL[REQUEST_CHANGE_BARRING_PASSWORD](0, {
|
||||
context.RIL[REQUEST_CHANGE_BARRING_PASSWORD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
}
|
||||
|
||||
worker.RIL.changeCallBarringPassword({pin: PIN, newPin: NEW_PIN});
|
||||
context.RIL.changeCallBarringPassword({pin: PIN, newPin: NEW_PIN});
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -31,15 +31,15 @@ function add_test_incoming_parcel(parcel, handler) {
|
||||
[0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
// supports only requests less or equal than UINT8_MAX(255).
|
||||
let buf = worker.Buf;
|
||||
let buf = context.Buf;
|
||||
let request = parcel[buf.PARCEL_SIZE_SIZE + buf.UINT32_SIZE];
|
||||
worker.RIL[request] = function ril_request_handler() {
|
||||
handler(worker);
|
||||
worker.postMessage();
|
||||
context.RIL[request] = function ril_request_handler() {
|
||||
handler.apply(this, arguments);
|
||||
};
|
||||
|
||||
worker.onRILMessage(parcel);
|
||||
worker.onRILMessage(0, parcel);
|
||||
|
||||
// end of incoming parcel's trip, let's do next test.
|
||||
run_next_test();
|
||||
@ -48,28 +48,30 @@ function add_test_incoming_parcel(parcel, handler) {
|
||||
|
||||
// Test normal parcel handling.
|
||||
add_test_incoming_parcel(null,
|
||||
function test_normal_parcel_handling(worker) {
|
||||
function test_normal_parcel_handling() {
|
||||
let self = this;
|
||||
do_check_throws(function normal_handler() {
|
||||
// reads exactly the same size, should not throw anything.
|
||||
worker.Buf.readInt32();
|
||||
self.context.Buf.readInt32();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Test parcel under read.
|
||||
add_test_incoming_parcel(null,
|
||||
function test_parcel_under_read(worker) {
|
||||
function test_parcel_under_read() {
|
||||
let self = this;
|
||||
do_check_throws(function under_read_handler() {
|
||||
// reads less than parcel size, should not throw.
|
||||
worker.Buf.readUint16();
|
||||
self.context.Buf.readUint16();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Test parcel over read.
|
||||
add_test_incoming_parcel(null,
|
||||
function test_parcel_over_read(worker) {
|
||||
let buf = worker.Buf;
|
||||
function test_parcel_over_read() {
|
||||
let buf = this.context.Buf;
|
||||
|
||||
// read all data available
|
||||
while (buf.readAvailable > 0) {
|
||||
@ -94,8 +96,9 @@ add_test(function test_incoming_parcel_buffer_overwritten() {
|
||||
}
|
||||
});
|
||||
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
// A convenient alias.
|
||||
let buf = worker.Buf;
|
||||
let buf = context.Buf;
|
||||
|
||||
// Allocate an array of specified size and set each of its elements to value.
|
||||
function calloc(length, value) {
|
||||
@ -108,7 +111,7 @@ add_test(function test_incoming_parcel_buffer_overwritten() {
|
||||
|
||||
// Do nothing in handleParcel().
|
||||
let request = worker.REQUEST_VOICE_REGISTRATION_STATE;
|
||||
worker.RIL[request] = null;
|
||||
context.RIL[request] = null;
|
||||
|
||||
// Prepare two parcels, whose sizes are both smaller than the incoming buffer
|
||||
// size but larger when combined, to trigger the bug.
|
||||
@ -128,7 +131,7 @@ add_test(function test_incoming_parcel_buffer_overwritten() {
|
||||
|
||||
// First, send an incomplete pA and verifies related data pointer:
|
||||
let p1 = pA.subarray(0, pA.length - 1);
|
||||
worker.onRILMessage(p1);
|
||||
worker.onRILMessage(0, p1);
|
||||
// The parcel should not have been processed.
|
||||
do_check_eq(buf.readAvailable, 0);
|
||||
// buf.currentParcelSize should have been set because incoming data has more
|
||||
@ -144,7 +147,7 @@ add_test(function test_incoming_parcel_buffer_overwritten() {
|
||||
let p2 = new Uint8Array(1 + pB.length);
|
||||
p2.set(pA.subarray(pA.length - 1), 0);
|
||||
p2.set(pB, 1);
|
||||
worker.onRILMessage(p2);
|
||||
worker.onRILMessage(0, p2);
|
||||
// The parcels should have been both consumed.
|
||||
do_check_eq(buf.readAvailable, 0);
|
||||
// No parcel data remains.
|
||||
@ -160,8 +163,8 @@ add_test(function test_incoming_parcel_buffer_overwritten() {
|
||||
|
||||
// Test Buf.readUint8Array.
|
||||
add_test_incoming_parcel(null,
|
||||
function test_buf_readUint8Array(worker) {
|
||||
let buf = worker.Buf;
|
||||
function test_buf_readUint8Array() {
|
||||
let buf = this.context.Buf;
|
||||
|
||||
let u8array = buf.readUint8Array(1);
|
||||
do_check_eq(u8array instanceof Uint8Array, true);
|
||||
|
@ -23,15 +23,16 @@ function newWorkerWithParcel(parcelBuf) {
|
||||
let index = 0; // index for read
|
||||
let buf = parcelBuf;
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.readUint16 = function() {
|
||||
context.Buf.readUint16 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.readInt32 = function() {
|
||||
context.Buf.readInt32 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
@ -50,7 +51,8 @@ add_test(function test_display() {
|
||||
0x09, // length: 9
|
||||
0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6E, 0x66,
|
||||
0x6F, 0x00]);
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.CdmaPDUHelper;
|
||||
let record = helper.decodeInformationRecord();
|
||||
|
||||
do_check_eq(record.display, "Test Info");
|
||||
@ -72,7 +74,8 @@ add_test(function test_extended_display() {
|
||||
0x9B, // Text
|
||||
0x09, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6E,
|
||||
0x66, 0x6F, 0x00]);
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.CdmaPDUHelper;
|
||||
let record = helper.decodeInformationRecord();
|
||||
|
||||
do_check_eq(record.extendedDisplay.indicator, 1);
|
||||
@ -103,7 +106,8 @@ add_test(function test_mixed() {
|
||||
0x9B, // Text
|
||||
0x09, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6E,
|
||||
0x66, 0x6F, 0x00]);
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.CdmaPDUHelper;
|
||||
let record = helper.decodeInformationRecord();
|
||||
|
||||
do_check_eq(record.display, "Test Info");
|
||||
|
@ -33,13 +33,14 @@ add_test(function test_ril_worker_GsmPDUHelper_readCbDataCodingScheme() {
|
||||
}
|
||||
});
|
||||
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
function test_dcs(dcs, encoding, language, hasLanguageIndicator, messageClass) {
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return dcs;
|
||||
};
|
||||
|
||||
let msg = {};
|
||||
worker.GsmPDUHelper.readCbDataCodingScheme(msg);
|
||||
context.GsmPDUHelper.readCbDataCodingScheme(msg);
|
||||
|
||||
do_check_eq(msg.dcs, dcs);
|
||||
do_check_eq(msg.encoding, encoding);
|
||||
@ -49,12 +50,12 @@ add_test(function test_ril_worker_GsmPDUHelper_readCbDataCodingScheme() {
|
||||
}
|
||||
|
||||
function test_dcs_throws(dcs) {
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return dcs;
|
||||
};
|
||||
|
||||
do_check_throws(function() {
|
||||
worker.GsmPDUHelper.readCbDataCodingScheme({});
|
||||
context.GsmPDUHelper.readCbDataCodingScheme({});
|
||||
}, "Unsupported CBS data coding scheme: " + dcs);
|
||||
}
|
||||
|
||||
@ -142,12 +143,13 @@ add_test(function test_ril_worker_GsmPDUHelper_readGsmCbData() {
|
||||
}
|
||||
});
|
||||
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
function test_data(options, expected) {
|
||||
let readIndex = 0;
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return options[3][readIndex++];
|
||||
};
|
||||
worker.Buf.readUint8Array = function(length) {
|
||||
context.Buf.readUint8Array = function(length) {
|
||||
let array = new Uint8Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
array[i] = this.readUint8();
|
||||
@ -160,7 +162,7 @@ add_test(function test_ril_worker_GsmPDUHelper_readGsmCbData() {
|
||||
language: options[1],
|
||||
hasLanguageIndicator: options[2]
|
||||
};
|
||||
worker.GsmPDUHelper.readGsmCbData(msg, options[3].length);
|
||||
context.GsmPDUHelper.readGsmCbData(msg, options[3].length);
|
||||
|
||||
do_check_eq(msg.body, expected[0]);
|
||||
do_check_eq(msg.data == null, expected[1] == null);
|
||||
@ -218,7 +220,8 @@ add_test(function test_ril_worker__checkCellBroadcastMMISettable() {
|
||||
}
|
||||
});
|
||||
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
function test(from, to, expected) {
|
||||
do_check_eq(expected, ril._checkCellBroadcastMMISettable(from, to));
|
||||
@ -268,7 +271,8 @@ add_test(function test_ril_worker__mergeCellBroadcastConfigs() {
|
||||
}
|
||||
});
|
||||
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
function test(olist, from, to, expected) {
|
||||
let result = ril._mergeCellBroadcastConfigs(olist, from, to);
|
||||
|
@ -16,27 +16,28 @@ add_test(function test_ril_worker_cellbroadcast_activate() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
let parcelTypes = [];
|
||||
let org_newParcel = worker.Buf.newParcel;
|
||||
worker.Buf.newParcel = function(type, options) {
|
||||
let org_newParcel = context.Buf.newParcel;
|
||||
context.Buf.newParcel = function(type, options) {
|
||||
parcelTypes.push(type);
|
||||
org_newParcel.apply(this, arguments);
|
||||
};
|
||||
|
||||
function setup(isCdma) {
|
||||
worker.RIL._isCdma = isCdma;
|
||||
worker.RIL.cellBroadcastDisabled = false;
|
||||
worker.RIL.mergedCellBroadcastConfig = [1, 2, 4, 7]; // 1, 4-6
|
||||
context.RIL._isCdma = isCdma;
|
||||
context.RIL.cellBroadcastDisabled = false;
|
||||
context.RIL.mergedCellBroadcastConfig = [1, 2, 4, 7]; // 1, 4-6
|
||||
parcelTypes = [];
|
||||
}
|
||||
|
||||
function test(isCdma, expectedRequest) {
|
||||
setup(isCdma);
|
||||
worker.RIL.setCellBroadcastDisabled({disabled: true});
|
||||
context.RIL.setCellBroadcastDisabled({disabled: true});
|
||||
// Makesure that request parcel is sent out.
|
||||
do_check_neq(parcelTypes.indexOf(expectedRequest), -1);
|
||||
do_check_eq(worker.RIL.cellBroadcastDisabled, true);
|
||||
do_check_eq(context.RIL.cellBroadcastDisabled, true);
|
||||
}
|
||||
|
||||
test(false, REQUEST_GSM_SMS_BROADCAST_ACTIVATION);
|
||||
@ -55,6 +56,7 @@ add_test(function test_ril_worker_cellbroadcast_config() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
function U32ArrayFromParcelArray(pa) {
|
||||
do_print(pa);
|
||||
@ -82,8 +84,8 @@ add_test(function test_ril_worker_cellbroadcast_config() {
|
||||
do_check_eq(u32Parcel.slice(3).toString(), expected);
|
||||
};
|
||||
|
||||
worker.RIL._isCdma = isCdma;
|
||||
worker.RIL.setSmsBroadcastConfig(configs);
|
||||
context.RIL._isCdma = isCdma;
|
||||
context.RIL.setSmsBroadcastConfig(configs);
|
||||
|
||||
// Makesure that request parcel is sent out.
|
||||
do_check_true(found);
|
||||
@ -113,12 +115,13 @@ add_test(function test_ril_worker_cellbroadcast_merge_config() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
function test(isCdma, configs, expected) {
|
||||
worker.RIL._isCdma = isCdma;
|
||||
worker.RIL.cellBroadcastConfigs = configs;
|
||||
worker.RIL._mergeAllCellBroadcastConfigs();
|
||||
do_check_eq(worker.RIL.mergedCellBroadcastConfig.toString(), expected);
|
||||
context.RIL._isCdma = isCdma;
|
||||
context.RIL.cellBroadcastConfigs = configs;
|
||||
context.RIL._mergeAllCellBroadcastConfigs();
|
||||
do_check_eq(context.RIL.mergedCellBroadcastConfig.toString(), expected);
|
||||
}
|
||||
|
||||
let configs = {
|
||||
|
@ -16,7 +16,8 @@ function toaFromString(number) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
return worker.RIL._toaFromString(number);
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
return context.RIL._toaFromString(number);
|
||||
}
|
||||
|
||||
add_test(function test_toaFromString_empty() {
|
||||
@ -73,14 +74,15 @@ function _getWorker() {
|
||||
add_test(function test_setCallForward_unconditional() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
context.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
context.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setCallForward({
|
||||
context.RIL.setCallForward({
|
||||
action: Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_REGISTRATION,
|
||||
reason: Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_UNCONDITIONAL,
|
||||
serviceClass: ICC_SERVICE_CLASS_VOICE,
|
||||
@ -99,23 +101,24 @@ add_test(function test_setCallForward_unconditional() {
|
||||
add_test(function test_queryCallForwardStatus_unconditional() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
context.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
context.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.Buf.readString = function fakeReadString() {
|
||||
context.Buf.readString = function fakeReadString() {
|
||||
return "+34666222333";
|
||||
};
|
||||
|
||||
worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
context.Buf.int32Array = [
|
||||
0, // rules.timeSeconds
|
||||
145, // rules.toa
|
||||
49, // rules.serviceClass
|
||||
@ -123,12 +126,12 @@ add_test(function test_queryCallForwardStatus_unconditional() {
|
||||
1, // rules.active
|
||||
1 // rulesLength
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
context.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryCallForwardStatus({
|
||||
context.RIL.queryCallForwardStatus({
|
||||
action: Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_QUERY_STATUS,
|
||||
reason: Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_UNCONDITIONAL,
|
||||
serviceClass: ICC_SERVICE_CLASS_VOICE,
|
||||
|
@ -29,22 +29,23 @@ function _getWorker() {
|
||||
add_test(function test_queryCLIP_provisioned() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // CLIP provisioned.
|
||||
1 // Length.
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CLIP](1, {
|
||||
context.RIL[REQUEST_QUERY_CLIP](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryCLIP({});
|
||||
context.RIL.queryCLIP({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -57,22 +58,23 @@ add_test(function test_queryCLIP_provisioned() {
|
||||
add_test(function test_getCLIP_error_generic_failure_invalid_length() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // CLIP provisioned.
|
||||
0 // Length.
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CLIP](1, {
|
||||
context.RIL[REQUEST_QUERY_CLIP](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryCLIP({});
|
||||
context.RIL.queryCLIP({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
|
@ -38,15 +38,16 @@ function _getWorker() {
|
||||
add_test(function test_setCLIR_success() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCLIR = function fakeSetCLIR(options) {
|
||||
worker.RIL[REQUEST_SET_CLIR](0, {
|
||||
context.RIL.setCLIR = function fakeSetCLIR(options) {
|
||||
context.RIL[REQUEST_SET_CLIR](0, {
|
||||
rilMessageType: "setCLIR",
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setCLIR({
|
||||
context.RIL.setCLIR({
|
||||
clirMode: CLIR_DEFAULT
|
||||
});
|
||||
|
||||
@ -61,15 +62,16 @@ add_test(function test_setCLIR_success() {
|
||||
add_test(function test_setCLIR_generic_failure() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCLIR = function fakeSetCLIR(options) {
|
||||
worker.RIL[REQUEST_SET_CLIR](0, {
|
||||
context.RIL.setCLIR = function fakeSetCLIR(options) {
|
||||
context.RIL[REQUEST_SET_CLIR](0, {
|
||||
rilMessageType: "setCLIR",
|
||||
rilRequestError: ERROR_GENERIC_FAILURE
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setCLIR({
|
||||
context.RIL.setCLIR({
|
||||
clirMode: CLIR_DEFAULT
|
||||
});
|
||||
|
||||
@ -84,25 +86,26 @@ add_test(function test_setCLIR_generic_failure() {
|
||||
add_test(function test_getCLIR_n0_m1() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.getCLIR = function fakeGetCLIR(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.getCLIR = function fakeGetCLIR(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // Presentation indicator is used according to the subscription
|
||||
// of the CLIR service.
|
||||
0, // CLIR provisioned in permanent mode.
|
||||
2 // Length.
|
||||
];
|
||||
worker.RIL[REQUEST_GET_CLIR](1, {
|
||||
context.RIL[REQUEST_GET_CLIR](1, {
|
||||
rilMessageType: "setCLIR",
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.getCLIR({});
|
||||
context.RIL.getCLIR({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -116,25 +119,26 @@ add_test(function test_getCLIR_n0_m1() {
|
||||
add_test(function test_getCLIR_error_generic_failure_invalid_length() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.getCLIR = function fakeGetCLIR(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.getCLIR = function fakeGetCLIR(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // Presentation indicator is used according to the subscription
|
||||
// of the CLIR service.
|
||||
0, // CLIR provisioned in permanent mode.
|
||||
0 // Length (invalid one).
|
||||
];
|
||||
worker.RIL[REQUEST_GET_CLIR](1, {
|
||||
context.RIL[REQUEST_GET_CLIR](1, {
|
||||
rilMessageType: "setCLIR",
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.getCLIR({});
|
||||
context.RIL.getCLIR({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
|
@ -29,14 +29,15 @@ function _getWorker() {
|
||||
add_test(function test_setCallWaiting_success() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
context.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
context.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setCallWaiting({
|
||||
context.RIL.setCallWaiting({
|
||||
enabled: true
|
||||
});
|
||||
|
||||
@ -51,14 +52,15 @@ add_test(function test_setCallWaiting_success() {
|
||||
add_test(function test_setCallWaiting_generic_failure() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
context.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
context.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
rilRequestError: ERROR_GENERIC_FAILURE
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setCallWaiting({
|
||||
context.RIL.setCallWaiting({
|
||||
enabled: true
|
||||
});
|
||||
|
||||
@ -73,23 +75,24 @@ add_test(function test_setCallWaiting_generic_failure() {
|
||||
add_test(function test_queryCallWaiting_success_enabled_true() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // serviceClass
|
||||
1, // enabled
|
||||
1 // length
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
context.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryCallWaiting({});
|
||||
context.RIL.queryCallWaiting({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -103,23 +106,24 @@ add_test(function test_queryCallWaiting_success_enabled_true() {
|
||||
add_test(function test_queryCallWaiting_success_enabled_false() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
context.Buf.int32Array = [
|
||||
1, // serviceClass
|
||||
0, // enabled
|
||||
1 // length
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
context.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryCallWaiting({});
|
||||
context.RIL.queryCallWaiting({});
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
|
@ -56,14 +56,15 @@ function fireTimeout() {
|
||||
add_test(function test_enter_emergencyCbMode() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
// Do it twice. Should always send the event.
|
||||
for (let i = 0; i < 2; ++i) {
|
||||
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
context.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
// Should store the mode.
|
||||
do_check_eq(worker.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(context.RIL._isInEmergencyCbMode, true);
|
||||
|
||||
// Should notify change.
|
||||
do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange");
|
||||
@ -71,7 +72,7 @@ add_test(function test_enter_emergencyCbMode() {
|
||||
do_check_eq(postedMessage.timeoutMs, TIMEOUT_VALUE);
|
||||
|
||||
// Should start timer.
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
@ -80,20 +81,21 @@ add_test(function test_enter_emergencyCbMode() {
|
||||
add_test(function test_exit_emergencyCbMode() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
worker.RIL[UNSOLICITED_EXIT_EMERGENCY_CALLBACK_MODE]();
|
||||
context.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
context.RIL[UNSOLICITED_EXIT_EMERGENCY_CALLBACK_MODE]();
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
// Should store the mode.
|
||||
do_check_eq(worker.RIL._isInEmergencyCbMode, false);
|
||||
do_check_eq(context.RIL._isInEmergencyCbMode, false);
|
||||
|
||||
// Should notify change.
|
||||
do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange");
|
||||
do_check_eq(postedMessage.active, false);
|
||||
|
||||
// Should clear timer.
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
@ -101,13 +103,14 @@ add_test(function test_exit_emergencyCbMode() {
|
||||
add_test(function test_request_exit_emergencyCbMode_when_timeout() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(worker.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
context.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(context.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
|
||||
let parcelTypes = [];
|
||||
worker.Buf.newParcel = function(type, options) {
|
||||
context.Buf.newParcel = function(type, options) {
|
||||
parcelTypes.push(type);
|
||||
};
|
||||
|
||||
@ -115,7 +118,7 @@ add_test(function test_request_exit_emergencyCbMode_when_timeout() {
|
||||
fireTimeout();
|
||||
|
||||
// Should clear timeout event.
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
|
||||
// Check indeed sent out REQUEST_EXIT_EMERGENCY_CALLBACK_MODE.
|
||||
do_check_neq(parcelTypes.indexOf(REQUEST_EXIT_EMERGENCY_CALLBACK_MODE), -1);
|
||||
@ -126,22 +129,23 @@ add_test(function test_request_exit_emergencyCbMode_when_timeout() {
|
||||
add_test(function test_request_exit_emergencyCbMode_when_dial() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(worker.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
context.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(context.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
|
||||
let parcelTypes = [];
|
||||
worker.Buf.newParcel = function(type, options) {
|
||||
context.Buf.newParcel = function(type, options) {
|
||||
parcelTypes.push(type);
|
||||
};
|
||||
|
||||
// Dial non-emergency call.
|
||||
worker.RIL.dial({number: "0912345678",
|
||||
context.RIL.dial({number: "0912345678",
|
||||
isDialEmergency: false});
|
||||
|
||||
// Should clear timeout event.
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
|
||||
// Check indeed sent out REQUEST_EXIT_EMERGENCY_CALLBACK_MODE.
|
||||
do_check_neq(parcelTypes.indexOf(REQUEST_EXIT_EMERGENCY_CALLBACK_MODE), -1);
|
||||
@ -152,25 +156,26 @@ add_test(function test_request_exit_emergencyCbMode_when_dial() {
|
||||
add_test(function test_request_exit_emergencyCbMode_explicitly() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(worker.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
context.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
|
||||
do_check_eq(context.RIL._isInEmergencyCbMode, true);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
|
||||
|
||||
let parcelTypes = [];
|
||||
worker.Buf.newParcel = function(type, options) {
|
||||
context.Buf.newParcel = function(type, options) {
|
||||
parcelTypes.push(type);
|
||||
};
|
||||
|
||||
worker.RIL.handleChromeMessage({rilMessageType: "exitEmergencyCbMode"});
|
||||
worker.RIL[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE](1, {
|
||||
context.RIL.handleChromeMessage({rilMessageType: "exitEmergencyCbMode"});
|
||||
context.RIL[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE](1, {
|
||||
rilMessageType: "exitEmergencyCbMode",
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
// Should clear timeout event.
|
||||
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, null);
|
||||
|
||||
// Check indeed sent out REQUEST_EXIT_EMERGENCY_CALLBACK_MODE.
|
||||
do_check_neq(parcelTypes.indexOf(REQUEST_EXIT_EMERGENCY_CALLBACK_MODE), -1);
|
||||
|
@ -15,15 +15,16 @@ function newUint8Worker() {
|
||||
let index = 0; // index for read
|
||||
let buf = [];
|
||||
|
||||
worker.Buf.writeUint8 = function(value) {
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
buf.push(value);
|
||||
};
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
|
||||
@ -37,8 +38,9 @@ function newUint8Worker() {
|
||||
*/
|
||||
add_test(function test_read_icc_ucs2_string() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
|
||||
// 0x80
|
||||
let text = "TEST";
|
||||
@ -76,8 +78,9 @@ add_test(function test_read_icc_ucs2_string() {
|
||||
*/
|
||||
add_test(function test_read_dialling_number() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
let str = "123456789";
|
||||
|
||||
helper.readHexOctet = function() {
|
||||
@ -101,8 +104,9 @@ add_test(function test_read_dialling_number() {
|
||||
*/
|
||||
add_test(function test_read_8bit_unpacked_to_string() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
|
||||
@ -166,8 +170,9 @@ add_test(function test_read_8bit_unpacked_to_string() {
|
||||
*/
|
||||
add_test(function test_write_string_to_8bit_unpacked() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
// Length of trailing 0xff.
|
||||
@ -212,8 +217,9 @@ add_test(function test_write_string_to_8bit_unpacked() {
|
||||
*/
|
||||
add_test(function test_write_string_to_8bit_unpacked_with_max_octets_written() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
|
||||
@ -251,8 +257,9 @@ add_test(function test_write_string_to_8bit_unpacked_with_max_octets_written() {
|
||||
*/
|
||||
add_test(function test_read_alpha_identifier() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
|
||||
// UCS2: 0x80
|
||||
let text = "TEST";
|
||||
@ -295,8 +302,9 @@ add_test(function test_read_alpha_identifier() {
|
||||
*/
|
||||
add_test(function test_write_alpha_identifier() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
// Length of trailing 0xff.
|
||||
let ffLen = 2;
|
||||
|
||||
@ -341,9 +349,10 @@ add_test(function test_write_alpha_identifier() {
|
||||
*/
|
||||
add_test(function test_read_alpha_id_dialling_number() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
let buf = context.Buf;
|
||||
const recordSize = 32;
|
||||
|
||||
function testReadAlphaIdDiallingNumber(contact) {
|
||||
@ -381,7 +390,8 @@ add_test(function test_read_alpha_id_dialling_number() {
|
||||
*/
|
||||
add_test(function test_write_alpha_id_dialling_number() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.ICCPDUHelper;
|
||||
const recordSize = 32;
|
||||
|
||||
// Write a normal contact.
|
||||
@ -443,7 +453,8 @@ add_test(function test_write_alpha_id_dialling_number() {
|
||||
*/
|
||||
add_test(function test_write_dialling_number() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.ICCPDUHelper;
|
||||
|
||||
// with +
|
||||
let number = "+123456";
|
||||
@ -470,8 +481,9 @@ add_test(function test_write_dialling_number() {
|
||||
*/
|
||||
add_test(function test_read_number_with_length() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
let number = "123456789";
|
||||
|
||||
iccHelper.readDiallingNumber = function(numLen) {
|
||||
@ -493,8 +505,9 @@ add_test(function test_read_number_with_length() {
|
||||
*/
|
||||
add_test(function test_write_number_with_length() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
|
||||
function test(number, expectedNumber) {
|
||||
expectedNumber = expectedNumber || number;
|
||||
@ -537,7 +550,8 @@ add_test(function test_write_number_with_length() {
|
||||
*/
|
||||
add_test(function test_write_timestamp() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
|
||||
// current date
|
||||
let dateInput = new Date();
|
||||
@ -576,7 +590,8 @@ add_test(function test_write_timestamp() {
|
||||
*/
|
||||
add_test(function test_octect_BCD() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
|
||||
// 23
|
||||
let number = 23;
|
||||
@ -606,13 +621,15 @@ add_test(function test_octect_BCD() {
|
||||
*/
|
||||
add_test(function test_is_icc_service_available() {
|
||||
let worker = newUint8Worker();
|
||||
let ICCUtilsHelper = worker.ICCUtilsHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ICCUtilsHelper = context.ICCUtilsHelper;
|
||||
let RIL = context.RIL;
|
||||
|
||||
function test_table(sst, geckoService, simEnabled, usimEnabled) {
|
||||
worker.RIL.iccInfoPrivate.sst = sst;
|
||||
worker.RIL.appType = CARD_APPTYPE_SIM;
|
||||
RIL.iccInfoPrivate.sst = sst;
|
||||
RIL.appType = CARD_APPTYPE_SIM;
|
||||
do_check_eq(ICCUtilsHelper.isICCServiceAvailable(geckoService), simEnabled);
|
||||
worker.RIL.appType = CARD_APPTYPE_USIM;
|
||||
RIL.appType = CARD_APPTYPE_USIM;
|
||||
do_check_eq(ICCUtilsHelper.isICCServiceAvailable(geckoService), usimEnabled);
|
||||
}
|
||||
|
||||
@ -628,7 +645,8 @@ add_test(function test_is_icc_service_available() {
|
||||
*/
|
||||
add_test(function test_is_gsm_8bit_alphabet() {
|
||||
let worker = newUint8Worker();
|
||||
let ICCUtilsHelper = worker.ICCUtilsHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ICCUtilsHelper = context.ICCUtilsHelper;
|
||||
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
|
||||
|
||||
@ -644,8 +662,9 @@ add_test(function test_is_gsm_8bit_alphabet() {
|
||||
*/
|
||||
add_test(function test_icc_get_card_lock_state_fdn() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let buf = context.Buf;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Request Type.
|
||||
@ -681,8 +700,9 @@ add_test(function test_icc_get_card_lock_state_fdn() {
|
||||
|
||||
add_test(function test_get_network_name_from_icc() {
|
||||
let worker = newUint8Worker();
|
||||
let RIL = worker.RIL;
|
||||
let ICCUtilsHelper = worker.ICCUtilsHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let ICCUtilsHelper = context.ICCUtilsHelper;
|
||||
|
||||
function testGetNetworkNameFromICC(operatorData, expectedResult) {
|
||||
let result = ICCUtilsHelper.getNetworkNameFromICC(operatorData.mcc,
|
||||
@ -780,8 +800,9 @@ add_test(function test_path_id_for_spid_and_spn() {
|
||||
postMessage: function(message) {
|
||||
// Do nothing
|
||||
}});
|
||||
let RIL = worker.RIL;
|
||||
let ICCFileHelper = worker.ICCFileHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let ICCFileHelper = context.ICCFileHelper;
|
||||
|
||||
// Test SIM
|
||||
RIL.appType = CARD_APPTYPE_SIM;
|
||||
@ -804,7 +825,8 @@ add_test(function test_path_id_for_spid_and_spn() {
|
||||
*/
|
||||
add_test(function test_parse_pbr_tlvs() {
|
||||
let worker = newUint8Worker();
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
|
||||
let pbrTlvs = [
|
||||
{tag: ICC_USIM_TYPE1_TAG,
|
||||
@ -842,7 +864,7 @@ add_test(function test_parse_pbr_tlvs() {
|
||||
},
|
||||
];
|
||||
|
||||
let pbr = worker.ICCUtilsHelper.parsePbrTlvs(pbrTlvs);
|
||||
let pbr = context.ICCUtilsHelper.parsePbrTlvs(pbrTlvs);
|
||||
do_check_eq(pbr.adn.fileId, 0x4F3a);
|
||||
do_check_eq(pbr.iap.fileId, 0x4F25);
|
||||
do_check_eq(pbr.pbc.fileId, 0x4F09);
|
||||
@ -860,8 +882,9 @@ add_test(function test_parse_pbr_tlvs() {
|
||||
*/
|
||||
add_test(function test_load_linear_fixed_ef() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
io.getResponse = function fakeGetResponse(options) {
|
||||
// When recordSize is provided, loadLinearFixedEF should call iccIO directly.
|
||||
@ -882,8 +905,9 @@ add_test(function test_load_linear_fixed_ef() {
|
||||
*/
|
||||
add_test(function test_load_linear_fixed_ef() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
io.getResponse = function fakeGetResponse(options) {
|
||||
do_check_true(true);
|
||||
@ -904,10 +928,11 @@ add_test(function test_load_linear_fixed_ef() {
|
||||
*/
|
||||
add_test(function test_read_pbr() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let record = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
let pbr_1 = [
|
||||
@ -970,10 +995,11 @@ add_test(function test_read_pbr() {
|
||||
*/
|
||||
add_test(function test_read_email() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let record = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
let recordSize;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
@ -1027,20 +1053,21 @@ add_test(function test_update_email() {
|
||||
const fileId = 0x4f50;
|
||||
const NUM_TESTS = 2;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
let ril = context.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let ioHelper = context.ICCIOHelper;
|
||||
let pbr = {email: {fileId: fileId, fileType: ICC_USIM_TYPE1_TAG},
|
||||
adn: {sfi: 1}};
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function(options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.pathId = context.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
@ -1115,10 +1142,11 @@ add_test(function test_update_email() {
|
||||
*/
|
||||
add_test(function test_read_anr() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let record = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
let recordSize;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
@ -1169,20 +1197,21 @@ add_test(function test_update_anr() {
|
||||
const fileId = 0x4f11;
|
||||
const NUM_TESTS = 2;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
let ril = context.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let ioHelper = context.ICCIOHelper;
|
||||
let pbr = {anr0: {fileId: fileId, fileType: ICC_USIM_TYPE1_TAG},
|
||||
adn: {sfi: 1}};
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function(options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.pathId = context.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
@ -1259,10 +1288,11 @@ add_test(function test_update_anr() {
|
||||
*/
|
||||
add_test(function test_read_iap() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let record = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
let recordSize;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
@ -1317,17 +1347,18 @@ add_test(function test_update_iap() {
|
||||
const recordNumber = 1;
|
||||
const fileId = 0x4f17;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let ril = context.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let ioHelper = context.ICCIOHelper;
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function(options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.pathId = context.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
@ -1390,11 +1421,12 @@ add_test(function test_update_iap() {
|
||||
*/
|
||||
add_test(function test_update_adn_like() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let io = worker.ICCIOHelper;
|
||||
let pdu = worker.ICCPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let record = context.ICCRecordHelper;
|
||||
let io = context.ICCIOHelper;
|
||||
let pdu = context.ICCPDUHelper;
|
||||
let buf = context.Buf;
|
||||
|
||||
ril.appType = CARD_APPTYPE_SIM;
|
||||
const recordSize = 0x20;
|
||||
@ -1402,7 +1434,7 @@ add_test(function test_update_adn_like() {
|
||||
|
||||
// Override.
|
||||
io.updateLinearFixedEF = function(options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.pathId = context.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
@ -1472,10 +1504,11 @@ add_test(function test_update_adn_like() {
|
||||
*/
|
||||
add_test(function test_find_free_record_id() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
function writeRecord (record) {
|
||||
// Write data size
|
||||
@ -1529,13 +1562,15 @@ add_test(function test_find_free_record_id() {
|
||||
*/
|
||||
add_test(function test_read_icc_contacts() {
|
||||
let worker = newUint8Worker();
|
||||
let record = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let record = context.ICCRecordHelper;
|
||||
let contactHelper = context.ICCContactHelper;
|
||||
let ril = context.RIL;
|
||||
|
||||
function do_test(aSimType, aContactType, aExpectedContact, aEnhancedPhoneBook) {
|
||||
worker.RIL.appType = aSimType;
|
||||
worker.RIL._isCdma = (aSimType === CARD_APPTYPE_RUIM);
|
||||
worker.RIL.iccInfoPrivate.cst = (aEnhancedPhoneBook) ?
|
||||
ril.appType = aSimType;
|
||||
ril._isCdma = (aSimType === CARD_APPTYPE_RUIM);
|
||||
ril.iccInfoPrivate.cst = (aEnhancedPhoneBook) ?
|
||||
[0x0, 0x0C, 0x0, 0x0, 0x0]:
|
||||
[0x0, 0x00, 0x0, 0x0, 0x0];
|
||||
|
||||
@ -1640,15 +1675,16 @@ add_test(function test_update_icc_contact() {
|
||||
const ANR0_RECORD_ID = 30;
|
||||
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let contactHelper = context.ICCContactHelper;
|
||||
let ril = context.RIL;
|
||||
|
||||
function do_test(aSimType, aContactType, aContact, aPin2, aFileType, aEnhancedPhoneBook) {
|
||||
worker.RIL.appType = aSimType;
|
||||
worker.RIL._isCdma = (aSimType === CARD_APPTYPE_RUIM);
|
||||
worker.RIL.iccInfoPrivate.cst = (aEnhancedPhoneBook) ?
|
||||
[0x0, 0x0C, 0x0, 0x0, 0x0]:
|
||||
[0x0, 0x00, 0x0, 0x0, 0x0];
|
||||
ril.appType = aSimType;
|
||||
ril._isCdma = (aSimType === CARD_APPTYPE_RUIM);
|
||||
ril.iccInfoPrivate.cst = (aEnhancedPhoneBook) ? [0x0, 0x0C, 0x0, 0x0, 0x0]
|
||||
: [0x0, 0x00, 0x0, 0x0, 0x0];
|
||||
|
||||
recordHelper.readPBR = function(onsuccess, onerror) {
|
||||
if (aFileType === ICC_USIM_TYPE1_TAG) {
|
||||
@ -1793,8 +1829,9 @@ add_test(function test_update_icc_contact_with_remove_type1_attr() {
|
||||
const ANR0_RECORD_ID = 30;
|
||||
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let contactHelper = context.ICCContactHelper;
|
||||
|
||||
recordHelper.updateADNLike = function(fileId, contact, pin2, onsuccess, onerror) {
|
||||
onsuccess();
|
||||
@ -1866,8 +1903,9 @@ add_test(function test_update_icc_contact_with_remove_type1_attr() {
|
||||
*/
|
||||
add_test(function test_find_free_icc_contact_sim() {
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let contactHelper = context.ICCContactHelper;
|
||||
// Correct record Id starts with 1, so put a null element at index 0.
|
||||
let records = [null];
|
||||
const MAX_RECORDS = 3;
|
||||
@ -1916,8 +1954,9 @@ add_test(function test_find_free_icc_contact_sim() {
|
||||
*/
|
||||
add_test(function test_find_free_icc_contact_usim() {
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let recordHelper = context.ICCRecordHelper;
|
||||
let contactHelper = context.ICCContactHelper;
|
||||
const ADN1_FILE_ID = 0x6f3a;
|
||||
const ADN2_FILE_ID = 0x6f3b;
|
||||
const MAX_RECORDS = 3;
|
||||
@ -1968,7 +2007,8 @@ add_test(function test_find_free_icc_contact_usim() {
|
||||
*/
|
||||
add_test(function test_error_message_read_icc_contact () {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
function do_test(options, expectedErrorMsg) {
|
||||
ril.sendChromeMessage = function(message) {
|
||||
@ -1997,7 +2037,8 @@ add_test(function test_error_message_read_icc_contact () {
|
||||
*/
|
||||
add_test(function test_error_message_update_icc_contact() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
const ICCID = "123456789";
|
||||
ril.iccInfo.iccid = ICCID;
|
||||
@ -2023,12 +2064,12 @@ add_test(function test_error_message_update_icc_contact() {
|
||||
do_test({contactType: "fdn", contact: {contactId: ICCID + "1"}}, GECKO_ERROR_SIM_PIN2);
|
||||
|
||||
// Error 5, No free record found in EF_ADN.
|
||||
let record = worker.ICCRecordHelper;
|
||||
let record = context.ICCRecordHelper;
|
||||
record.readPBR = function(onsuccess, onerror) {
|
||||
onsuccess([{adn: {fileId: 0x4f3a}}]);
|
||||
};
|
||||
|
||||
let io = worker.ICCIOHelper;
|
||||
let io = context.ICCIOHelper;
|
||||
io.loadLinearFixedEF = function(options) {
|
||||
options.totalRecords = 1;
|
||||
options.p1 = 1;
|
||||
@ -2063,9 +2104,10 @@ add_test(function test_error_message_update_icc_contact() {
|
||||
|
||||
add_test(function test_personalization_state() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
worker.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
|
||||
function testPersonalization(cardPersoState, geckoCardState) {
|
||||
let iccStatus = {
|
||||
@ -2105,9 +2147,10 @@ add_test(function test_personalization_state() {
|
||||
*/
|
||||
add_test(function test_card_app_state() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
worker.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
|
||||
function testCardAppState(cardAppState, geckoCardState) {
|
||||
let iccStatus = {
|
||||
@ -2144,9 +2187,10 @@ add_test(function test_card_app_state() {
|
||||
*/
|
||||
add_test(function test_icc_permanent_blocked() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
|
||||
worker.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
|
||||
|
||||
function testPermanentBlocked(pin1_replaced, universalPINState, pin1) {
|
||||
let iccStatus = {
|
||||
@ -2182,11 +2226,12 @@ add_test(function test_icc_permanent_blocked() {
|
||||
*/
|
||||
add_test(function test_set_icc_card_lock_facility_lock() {
|
||||
let worker = newUint8Worker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
worker.RILQUIRKS_V5_LEGACY = false;
|
||||
let aid = "123456789";
|
||||
let ril = worker.RIL;
|
||||
let ril = context.RIL;
|
||||
ril.aid = aid;
|
||||
let buf = worker.Buf;
|
||||
let buf = context.Buf;
|
||||
|
||||
let GECKO_CARDLOCK_TO_FACILITIY_LOCK = {};
|
||||
GECKO_CARDLOCK_TO_FACILITIY_LOCK[GECKO_CARDLOCK_PIN] = ICC_CB_FACILITY_SIM;
|
||||
@ -2243,8 +2288,9 @@ add_test(function test_set_icc_card_lock_facility_lock() {
|
||||
*/
|
||||
add_test(function test_unlock_card_lock_corporateLocked() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let buf = context.Buf;
|
||||
const pin = "12345678";
|
||||
const puk = "12345678";
|
||||
|
||||
@ -2292,7 +2338,8 @@ add_test(function test_unlock_card_lock_corporateLocked() {
|
||||
*/
|
||||
add_test(function test_mcc_mnc_parsing() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.ICCUtilsHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.ICCUtilsHelper;
|
||||
|
||||
function do_test(imsi, mncLength, expectedMcc, expectedMnc) {
|
||||
let result = helper.parseMccMncFromImsi(imsi, mncLength);
|
||||
@ -2327,11 +2374,12 @@ add_test(function test_mcc_mnc_parsing() {
|
||||
*/
|
||||
add_test(function test_reading_ad_and_parsing_mcc_mnc() {
|
||||
let worker = newUint8Worker();
|
||||
let record = worker.SimRecordHelper;
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let record = context.SimRecordHelper;
|
||||
let helper = context.GsmPDUHelper;
|
||||
let ril = context.RIL;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
function do_test(mncLengthInEf, imsi, expectedMcc, expectedMnc) {
|
||||
ril.iccInfoPrivate.imsi = imsi;
|
||||
@ -2374,11 +2422,12 @@ add_test(function test_reading_ad_and_parsing_mcc_mnc() {
|
||||
|
||||
add_test(function test_reading_optional_efs() {
|
||||
let worker = newUint8Worker();
|
||||
let record = worker.SimRecordHelper;
|
||||
let gsmPdu = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let record = context.SimRecordHelper;
|
||||
let gsmPdu = context.GsmPDUHelper;
|
||||
let ril = context.RIL;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
function buildSST(supportedEf) {
|
||||
let sst = [];
|
||||
@ -2464,9 +2513,10 @@ add_test(function test_reading_optional_efs() {
|
||||
*/
|
||||
add_test(function test_fetch_sim_recodes() {
|
||||
let worker = newWorker();
|
||||
let RIL = worker.RIL;
|
||||
let iccRecord = worker.ICCRecordHelper;
|
||||
let simRecord = worker.SimRecordHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let iccRecord = context.ICCRecordHelper;
|
||||
let simRecord = context.SimRecordHelper;
|
||||
|
||||
function testFetchSimRecordes(expectCalled) {
|
||||
let ifCalled = [];
|
||||
@ -2501,10 +2551,11 @@ add_test(function test_fetch_sim_recodes() {
|
||||
|
||||
add_test(function test_fetch_icc_recodes() {
|
||||
let worker = newWorker();
|
||||
let RIL = worker.RIL;
|
||||
let iccRecord = worker.ICCRecordHelper;
|
||||
let simRecord = worker.SimRecordHelper;
|
||||
let ruimRecord = worker.RuimRecordHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let iccRecord = context.ICCRecordHelper;
|
||||
let simRecord = context.SimRecordHelper;
|
||||
let ruimRecord = context.RuimRecordHelper;
|
||||
let fetchTag = 0x00;
|
||||
|
||||
simRecord.fetchSimRecords = function() {
|
||||
@ -2535,10 +2586,11 @@ add_test(function test_fetch_icc_recodes() {
|
||||
*/
|
||||
add_test(function test_read_mwis() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let recordHelper = worker.SimRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let recordHelper = context.SimRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
let mwisData;
|
||||
let postedMessage;
|
||||
|
||||
@ -2604,18 +2656,19 @@ add_test(function test_read_mwis() {
|
||||
*/
|
||||
add_test(function test_update_mwis() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let ril = context.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
ril.iccInfoPrivate.mwis = [0x00, 0x00, 0x00, 0x00, 0x00];
|
||||
let recordHelper = worker.SimRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let recordHelper = context.SimRecordHelper;
|
||||
let buf = context.Buf;
|
||||
let ioHelper = context.ICCIOHelper;
|
||||
let recordSize = ril.iccInfoPrivate.mwis.length;
|
||||
let recordNum = 1;
|
||||
|
||||
ioHelper.updateLinearFixedEF = function(options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.pathId = context.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
@ -2736,18 +2789,19 @@ add_test(function test_read_new_sms_on_sim() {
|
||||
return _worker;
|
||||
},
|
||||
fakeWokerBuffer: function() {
|
||||
let context = _worker.ContextPool._contexts[0];
|
||||
let index = 0; // index for read
|
||||
let buf = [];
|
||||
_worker.Buf.writeUint8 = function(value) {
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
buf.push(value);
|
||||
};
|
||||
_worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
_worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
_worker.Buf.getReadAvailable = function() {
|
||||
context.Buf.getReadAvailable = function() {
|
||||
return buf.length - index;
|
||||
};
|
||||
}
|
||||
@ -2756,8 +2810,9 @@ add_test(function test_read_new_sms_on_sim() {
|
||||
|
||||
let workerHelper = newSmsOnSimWorkerHelper();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.ICCIOHelper.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
context.ICCIOHelper.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
// SimStatus: Unread, SMSC:+0123456789, Sender: +9876543210, Text: How are you?
|
||||
let SimSmsPduHex = "0306911032547698040A9189674523010000208062917314080CC8F71D14969741F977FD07"
|
||||
// In 4.2.25 EF_SMS Short Messages of 3GPP TS 31.102:
|
||||
@ -2770,7 +2825,7 @@ add_test(function test_read_new_sms_on_sim() {
|
||||
|
||||
workerHelper.fakeWokerBuffer();
|
||||
|
||||
worker.Buf.writeString(SimSmsPduHex);
|
||||
context.Buf.writeString(SimSmsPduHex);
|
||||
|
||||
options.recordSize = 176; // Record length is fixed to 176 bytes.
|
||||
if (options.callback) {
|
||||
@ -2799,7 +2854,7 @@ add_test(function test_read_new_sms_on_sim() {
|
||||
}
|
||||
|
||||
function do_test() {
|
||||
worker.onRILMessage(newSmsOnSimParcel());
|
||||
worker.onRILMessage(0, newSmsOnSimParcel());
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -2820,8 +2875,9 @@ add_test(function test_read_new_sms_on_sim() {
|
||||
*/
|
||||
add_test(function test_fcp_template_for_transparent_structure() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
|
||||
let tag_test = [
|
||||
0x62,
|
||||
@ -2857,8 +2913,9 @@ add_test(function test_fcp_template_for_transparent_structure() {
|
||||
*/
|
||||
add_test(function test_fcp_template_for_linear_fixed_structure() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
|
||||
let tag_test = [
|
||||
0x62,
|
||||
@ -2893,9 +2950,10 @@ add_test(function test_fcp_template_for_linear_fixed_structure() {
|
||||
|
||||
add_test(function test_icc_io_get_response_for_transparent_structure() {
|
||||
let worker = newUint8Worker();
|
||||
let buf = worker.Buf;
|
||||
let iccioHelper = worker.ICCIOHelper;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let iccioHelper = context.ICCIOHelper;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
let responseArray = [
|
||||
// SIM response.
|
||||
@ -2927,9 +2985,10 @@ add_test(function test_icc_io_get_response_for_transparent_structure() {
|
||||
|
||||
add_test(function test_icc_io_get_response_for_linear_fixed_structure() {
|
||||
let worker = newUint8Worker();
|
||||
let buf = worker.Buf;
|
||||
let iccioHelper = worker.ICCIOHelper;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let iccioHelper = context.ICCIOHelper;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
let responseArray = [
|
||||
// SIM response.
|
||||
|
@ -16,7 +16,8 @@ function parseMMI(mmi) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
return worker.RIL._parseMMI(mmi);
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
return context.RIL._parseMMI(mmi);
|
||||
}
|
||||
|
||||
function getWorker() {
|
||||
@ -42,11 +43,12 @@ function getWorker() {
|
||||
function testSendMMI(mmi, error) {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
do_print("worker.postMessage " + worker.postMessage);
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({rilMessageType: "sendMMI", mmi: mmi});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({rilMessageType: "sendMMI", mmi: mmi});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -371,25 +373,26 @@ add_test(function test_sendMMI_invalid() {
|
||||
add_test(function test_sendMMI_short_code() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
let ussdOptions;
|
||||
|
||||
worker.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
context.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
ussdOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
context.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "**"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
do_check_eq(ussdOptions.ussd, "**");
|
||||
do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
|
||||
do_check_true(postedMessage.success);
|
||||
do_check_true(worker.RIL._ussdSession);
|
||||
do_check_true(context.RIL._ussdSession);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
@ -403,15 +406,16 @@ add_test(function test_sendMMI_dial_string() {
|
||||
function setCallForwardSuccess(mmi) {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
context.RIL.setCallForward = function fakeSetCallForward(options) {
|
||||
context.RIL[REQUEST_SET_CALL_FORWARD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: mmi});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: mmi});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -434,17 +438,18 @@ add_test(function test_sendMMI_call_forwarding_deactivation() {
|
||||
add_test(function test_sendMMI_call_forwarding_interrogation() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.Buf.readString = function fakeReadString() {
|
||||
context.Buf.readString = function fakeReadString() {
|
||||
return "+34666222333";
|
||||
};
|
||||
|
||||
worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
context.Buf.int32Array = [
|
||||
0, // rules.timeSeconds
|
||||
145, // rules.toa
|
||||
49, // rules.serviceClass
|
||||
@ -452,13 +457,13 @@ add_test(function test_sendMMI_call_forwarding_interrogation() {
|
||||
1, // rules.active
|
||||
1 // rulesLength
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
context.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*#21#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*#21#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -476,19 +481,20 @@ add_test(function test_sendMMI_call_forwarding_interrogation() {
|
||||
add_test(function test_sendMMI_call_forwarding_interrogation_no_rules() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
worker.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
context.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
|
||||
context.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*#21#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*#21#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -544,15 +550,16 @@ add_test(function test_sendMMI_call_forwarding_CFAllConditional() {
|
||||
add_test(function test_sendMMI_change_PIN() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.changeICCPIN = function fakeChangeICCPIN(options) {
|
||||
worker.RIL[REQUEST_ENTER_SIM_PIN](0, {
|
||||
context.RIL.changeICCPIN = function fakeChangeICCPIN(options) {
|
||||
context.RIL[REQUEST_ENTER_SIM_PIN](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**04*1234*4567*4567#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "**04*1234*4567*4567#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -589,15 +596,16 @@ add_test(function test_sendMMI_change_PIN_new_PIN_mismatch() {
|
||||
add_test(function test_sendMMI_change_PIN2() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.changeICCPIN2 = function fakeChangeICCPIN2(options){
|
||||
worker.RIL[REQUEST_ENTER_SIM_PIN2](0, {
|
||||
context.RIL.changeICCPIN2 = function fakeChangeICCPIN2(options){
|
||||
context.RIL[REQUEST_ENTER_SIM_PIN2](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**042*1234*4567*4567#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "**042*1234*4567*4567#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -634,15 +642,16 @@ add_test(function test_sendMMI_change_PIN2_new_PIN2_mismatch() {
|
||||
add_test(function test_sendMMI_unblock_PIN() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.enterICCPUK = function fakeEnterICCPUK(options){
|
||||
worker.RIL[REQUEST_ENTER_SIM_PUK](0, {
|
||||
context.RIL.enterICCPUK = function fakeEnterICCPUK(options){
|
||||
context.RIL[REQUEST_ENTER_SIM_PUK](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**05*1234*4567*4567#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "**05*1234*4567*4567#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -679,15 +688,16 @@ add_test(function test_sendMMI_unblock_PIN_new_PIN_mismatch() {
|
||||
add_test(function test_sendMMI_unblock_PIN2() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.enterICCPUK2 = function fakeEnterICCPUK2(options){
|
||||
worker.RIL[REQUEST_ENTER_SIM_PUK2](0, {
|
||||
context.RIL.enterICCPUK2 = function fakeEnterICCPUK2(options){
|
||||
context.RIL[REQUEST_ENTER_SIM_PUK2](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**052*1234*4567*4567#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "**052*1234*4567*4567#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -724,16 +734,17 @@ add_test(function test_sendMMI_unblock_PIN2_new_PIN_mismatch() {
|
||||
add_test(function test_sendMMI_get_IMEI() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let mmiOptions;
|
||||
|
||||
worker.RIL.getIMEI = function getIMEI(options){
|
||||
context.RIL.getIMEI = function getIMEI(options){
|
||||
mmiOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
context.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_SUCCESS,
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.sendMMI({mmi: "*#06#"});
|
||||
context.RIL.sendMMI({mmi: "*#06#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -747,16 +758,17 @@ add_test(function test_sendMMI_get_IMEI() {
|
||||
add_test(function test_sendMMI_get_IMEI_error() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let mmiOptions;
|
||||
|
||||
worker.RIL.getIMEI = function getIMEI(options){
|
||||
context.RIL.getIMEI = function getIMEI(options){
|
||||
mmiOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
context.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_RADIO_NOT_AVAILABLE,
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.sendMMI({mmi: "*#06#"});
|
||||
context.RIL.sendMMI({mmi: "*#06#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -770,21 +782,22 @@ add_test(function test_sendMMI_get_IMEI_error() {
|
||||
add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32List = function fakeReadUint32List() {
|
||||
context.Buf.readInt32List = function fakeReadUint32List() {
|
||||
return [1];
|
||||
};
|
||||
|
||||
worker.RIL.queryICCFacilityLock =
|
||||
context.RIL.queryICCFacilityLock =
|
||||
function fakeQueryICCFacilityLock(options){
|
||||
worker.RIL[REQUEST_QUERY_FACILITY_LOCK](1, {
|
||||
context.RIL[REQUEST_QUERY_FACILITY_LOCK](1, {
|
||||
rilMessageType: "sendMMI",
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*#33#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*#33#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -800,20 +813,21 @@ add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() {
|
||||
add_test(function test_sendMMI_call_barring_BAIC_activation() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let mmiOptions;
|
||||
|
||||
worker.RIL.setICCFacilityLock =
|
||||
context.RIL.setICCFacilityLock =
|
||||
function fakeSetICCFacilityLock(options){
|
||||
mmiOptions = options;
|
||||
worker.RIL[REQUEST_SET_FACILITY_LOCK](0, {
|
||||
context.RIL[REQUEST_SET_FACILITY_LOCK](0, {
|
||||
rilMessageType: "sendMMI",
|
||||
procedure: MMI_PROCEDURE_ACTIVATION,
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*33#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*33#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -827,20 +841,21 @@ add_test(function test_sendMMI_call_barring_BAIC_activation() {
|
||||
add_test(function test_sendMMI_call_barring_BAIC_deactivation() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let mmiOptions;
|
||||
|
||||
worker.RIL.setICCFacilityLock =
|
||||
context.RIL.setICCFacilityLock =
|
||||
function fakeSetICCFacilityLock(options){
|
||||
mmiOptions = options;
|
||||
worker.RIL[REQUEST_SET_FACILITY_LOCK](0, {
|
||||
context.RIL[REQUEST_SET_FACILITY_LOCK](0, {
|
||||
rilMessageType: "sendMMI",
|
||||
procedure: MMI_PROCEDURE_DEACTIVATION,
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "#33#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "#33#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -860,24 +875,25 @@ add_test(function test_sendMMI_call_barring_BAIC_procedure_not_supported() {
|
||||
add_test(function test_sendMMI_USSD() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ussdOptions;
|
||||
|
||||
worker.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
context.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
ussdOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
context.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*123#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*123#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
do_check_eq(ussdOptions.ussd, "*123#");
|
||||
do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
|
||||
do_check_true(postedMessage.success);
|
||||
do_check_true(worker.RIL._ussdSession);
|
||||
do_check_true(context.RIL._ussdSession);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
@ -885,24 +901,25 @@ add_test(function test_sendMMI_USSD() {
|
||||
add_test(function test_sendMMI_USSD_error() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ussdOptions;
|
||||
|
||||
worker.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
context.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
ussdOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
context.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_GENERIC_FAILURE
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*123#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*123#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
do_check_eq(ussdOptions.ussd, "*123#");
|
||||
do_check_eq (postedMessage.errorMsg, GECKO_ERROR_GENERIC_FAILURE);
|
||||
do_check_false(postedMessage.success);
|
||||
do_check_false(worker.RIL._ussdSession);
|
||||
do_check_false(context.RIL._ussdSession);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
@ -910,15 +927,16 @@ add_test(function test_sendMMI_USSD_error() {
|
||||
function setCallWaitingSuccess(mmi) {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
worker.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
context.RIL.setCallWaiting = function fakeSetCallWaiting(options) {
|
||||
context.RIL[REQUEST_SET_CALL_WAITING](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: mmi});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: mmi});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
@ -953,24 +971,25 @@ add_test(function test_sendMMI_call_waiting_erasure() {
|
||||
add_test(function test_sendMMI_call_waiting_interrogation() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32 = function fakeReadUint32() {
|
||||
return worker.Buf.int32Array.pop();
|
||||
context.Buf.readInt32 = function fakeReadUint32() {
|
||||
return context.Buf.int32Array.pop();
|
||||
};
|
||||
|
||||
worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
worker.Buf.int32Array = [
|
||||
context.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
|
||||
context.Buf.int32Array = [
|
||||
7, // serviceClass
|
||||
1, // enabled
|
||||
2 // length
|
||||
];
|
||||
worker.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
context.RIL[REQUEST_QUERY_CALL_WAITING](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "*#43#"});
|
||||
context.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
context.RIL.sendMMI({mmi: "*#43#"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
|
||||
|
@ -12,18 +12,19 @@ function run_test() {
|
||||
*/
|
||||
function newUint8Worker() {
|
||||
let worker = newWorker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let index = 0; // index for read
|
||||
let buf = [];
|
||||
|
||||
worker.Buf.writeUint8 = function(value) {
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
buf.push(value);
|
||||
};
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
|
||||
@ -37,12 +38,13 @@ function newUint8Worker() {
|
||||
*/
|
||||
add_test(function test_is_ruim_service_available() {
|
||||
let worker = newWorker();
|
||||
worker.RIL._isCdma = true;
|
||||
worker.RIL.appType = CARD_APPTYPE_RUIM;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
context.RIL._isCdma = true;
|
||||
context.RIL.appType = CARD_APPTYPE_RUIM;
|
||||
|
||||
function test_table(cst, geckoService, enabled) {
|
||||
worker.RIL.iccInfoPrivate.cst = cst;
|
||||
do_check_eq(worker.ICCUtilsHelper.isICCServiceAvailable(geckoService),
|
||||
context.RIL.iccInfoPrivate.cst = cst;
|
||||
do_check_eq(context.ICCUtilsHelper.isICCServiceAvailable(geckoService),
|
||||
enabled);
|
||||
}
|
||||
|
||||
@ -59,8 +61,9 @@ add_test(function test_is_ruim_service_available() {
|
||||
*/
|
||||
add_test(function test_ruim_file_path_id() {
|
||||
let worker = newWorker();
|
||||
let RIL = worker.RIL;
|
||||
let ICCFileHelper = worker.ICCFileHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let ICCFileHelper = context.ICCFileHelper;
|
||||
|
||||
RIL.appType = CARD_APPTYPE_RUIM;
|
||||
do_check_eq(ICCFileHelper.getEFPath(ICC_EF_CSIM_CST),
|
||||
@ -71,8 +74,9 @@ add_test(function test_ruim_file_path_id() {
|
||||
|
||||
add_test(function test_fetch_ruim_recodes() {
|
||||
let worker = newWorker();
|
||||
let RIL = worker.RIL;
|
||||
let ruimHelper = worker.RuimRecordHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let ruimHelper = context.RuimRecordHelper;
|
||||
|
||||
function testFetchRuimRecordes(expectCalled) {
|
||||
let ifCalled = [];
|
||||
@ -115,9 +119,10 @@ add_test(function test_fetch_ruim_recodes() {
|
||||
*/
|
||||
add_test(function test_decode_imsi_value() {
|
||||
let worker = newUint8Worker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
function testDecodeImsiValue(encoded, length, expect) {
|
||||
let decoded = worker.RuimRecordHelper.decodeIMSIValue(encoded, length);
|
||||
let decoded = context.RuimRecordHelper.decodeIMSIValue(encoded, length);
|
||||
|
||||
do_check_eq(expect, decoded);
|
||||
}
|
||||
@ -145,9 +150,10 @@ add_test(function test_decode_imsi_value() {
|
||||
*/
|
||||
add_test(function test_get_imsi_m() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
function testDecodeImsi(encodedImsi, expectedImsi) {
|
||||
io.loadTransparentEF = function fakeLoadTransparentEF(options) {
|
||||
@ -167,8 +173,8 @@ add_test(function test_get_imsi_m() {
|
||||
}
|
||||
};
|
||||
|
||||
worker.RuimRecordHelper.getIMSI_M();
|
||||
let imsi = worker.RIL.iccInfoPrivate.imsi;
|
||||
context.RuimRecordHelper.getIMSI_M();
|
||||
let imsi = context.RIL.iccInfoPrivate.imsi;
|
||||
|
||||
do_check_eq(expectedImsi, imsi)
|
||||
}
|
||||
@ -187,9 +193,10 @@ add_test(function test_get_imsi_m() {
|
||||
*/
|
||||
add_test(function test_read_cdmahome() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
let cdmaHome = [0xc1, 0x34, 0xff, 0xff, 0x00];
|
||||
@ -214,8 +221,8 @@ add_test(function test_read_cdmahome() {
|
||||
};
|
||||
|
||||
function testCdmaHome(expectedSystemIds, expectedNetworkIds) {
|
||||
worker.RuimRecordHelper.readCDMAHome();
|
||||
let cdmaHome = worker.RIL.cdmaHome;
|
||||
context.RuimRecordHelper.readCDMAHome();
|
||||
let cdmaHome = context.RIL.cdmaHome;
|
||||
for (let i = 0; i < expectedSystemIds.length; i++) {
|
||||
do_check_eq(cdmaHome.systemId[i], expectedSystemIds[i]);
|
||||
do_check_eq(cdmaHome.networkId[i], expectedNetworkIds[i]);
|
||||
@ -234,9 +241,10 @@ add_test(function test_read_cdmahome() {
|
||||
*/
|
||||
add_test(function test_read_cdmaspn() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let buf = context.Buf;
|
||||
let io = context.ICCIOHelper;
|
||||
|
||||
function testReadSpn(file, expectedSpn, expectedDisplayCondition) {
|
||||
io.loadTransparentEF = function fakeLoadTransparentEF(options) {
|
||||
@ -256,9 +264,9 @@ add_test(function test_read_cdmaspn() {
|
||||
}
|
||||
};
|
||||
|
||||
worker.RuimRecordHelper.readSPN();
|
||||
do_check_eq(worker.RIL.iccInfo.spn, expectedSpn);
|
||||
do_check_eq(worker.RIL.iccInfoPrivate.spnDisplayCondition,
|
||||
context.RuimRecordHelper.readSPN();
|
||||
do_check_eq(context.RIL.iccInfo.spn, expectedSpn);
|
||||
do_check_eq(context.RIL.iccInfoPrivate.spnDisplayCondition,
|
||||
expectedDisplayCondition);
|
||||
}
|
||||
|
||||
@ -297,8 +305,9 @@ add_test(function test_cdma_spn_display_condition() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let RIL = worker.RIL;
|
||||
let ICCUtilsHelper = worker.ICCUtilsHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let RIL = context.RIL;
|
||||
let ICCUtilsHelper = context.ICCUtilsHelper;
|
||||
|
||||
// Set cdma.
|
||||
RIL._isCdma = true;
|
||||
|
@ -118,8 +118,9 @@ function newWriteHexOctetAsUint8Worker() {
|
||||
}
|
||||
});
|
||||
|
||||
worker.GsmPDUHelper.writeHexOctet = function(value) {
|
||||
worker.Buf.writeUint8(value);
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
context.GsmPDUHelper.writeHexOctet = function(value) {
|
||||
context.Buf.writeUint8(value);
|
||||
};
|
||||
|
||||
return worker;
|
||||
@ -139,7 +140,7 @@ function add_test_receiving_sms(expected, pdu) {
|
||||
|
||||
do_print("expect: " + expected);
|
||||
do_print("pdu: " + pdu);
|
||||
worker.onRILMessage(newSmsParcel(pdu));
|
||||
worker.onRILMessage(0, newSmsParcel(pdu));
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
@ -154,8 +155,9 @@ function test_receiving_7bit_alphabets(lst, sst) {
|
||||
}
|
||||
let ril = test_receiving_7bit_alphabets__ril;
|
||||
let worker = test_receiving_7bit_alphabets__worker;
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
let buf = context.Buf;
|
||||
|
||||
function get7bitRawBytes(expected) {
|
||||
buf.outgoingIndex = 0;
|
||||
@ -183,11 +185,12 @@ function test_receiving_7bit_alphabets(lst, sst) {
|
||||
|
||||
function test_receiving_ucs2_alphabets(text) {
|
||||
let worker = test_receiving_7bit_alphabets__worker;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
|
||||
function getUCS2RawBytes(expected) {
|
||||
buf.outgoingIndex = 0;
|
||||
worker.GsmPDUHelper.writeUCS2String(expected);
|
||||
context.GsmPDUHelper.writeUCS2String(expected);
|
||||
|
||||
let subArray = buf.outgoingBytes.subarray(0, buf.outgoingIndex);
|
||||
return Array.slice(subArray);
|
||||
@ -220,8 +223,9 @@ test_receiving_ucs2_alphabets(ucs2str);
|
||||
// Bug 820220: B2G SMS: wrong order and truncated content in multi-part messages
|
||||
add_test(function test_sendSMS_UCS2_without_langIndex_langShiftIndex_defined() {
|
||||
let worker = newWriteHexOctetAsUint8Worker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.sendParcel = function() {
|
||||
context.Buf.sendParcel = function() {
|
||||
// Each sendParcel() call represents one outgoing segment of a multipart
|
||||
// SMS message. Here, we have the first segment send, so it's "Hello "
|
||||
// only.
|
||||
@ -242,7 +246,7 @@ add_test(function test_sendSMS_UCS2_without_langIndex_langShiftIndex_defined() {
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
worker.RIL.sendSMS({
|
||||
context.RIL.sendSMS({
|
||||
number: "1",
|
||||
segmentMaxSeq: 2,
|
||||
fullBody: "Hello World!",
|
||||
|
@ -190,10 +190,11 @@ function pduToParcelData(cdmaPduHelper, pdu) {
|
||||
add_test(function test_processCdmaSmsStatusReport() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
function test_StatusReport(errorClass, msgStatus) {
|
||||
let msgId = 0;
|
||||
let sentSmsMap = worker.RIL._pendingSentSmsMap;
|
||||
let sentSmsMap = context.RIL._pendingSentSmsMap;
|
||||
|
||||
sentSmsMap[msgId] = {};
|
||||
|
||||
@ -226,7 +227,7 @@ add_test(function test_processCdmaSmsStatusReport() {
|
||||
msgStatus: msgStatus
|
||||
};
|
||||
|
||||
worker.RIL._processCdmaSmsStatusReport(message);
|
||||
context.RIL._processCdmaSmsStatusReport(message);
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -263,8 +264,9 @@ add_test(function test_processCdmaSmsStatusReport() {
|
||||
add_test(function test_processCdmaSmsWapPush() {
|
||||
let workerHelper = _getWorker(),
|
||||
worker = workerHelper.worker,
|
||||
bitBufferHelper = worker.BitBufferHelper,
|
||||
cdmaPduHelper = worker.CdmaPDUHelper;
|
||||
context = worker.ContextPool._contexts[0],
|
||||
bitBufferHelper = context.BitBufferHelper,
|
||||
cdmaPduHelper = context.CdmaPDUHelper;
|
||||
|
||||
function test_CdmaSmsWapPdu(wdpData, reversed) {
|
||||
let orig_address = "0987654321",
|
||||
@ -293,7 +295,7 @@ add_test(function test_processCdmaSmsWapPush() {
|
||||
data: hexStringToBytes(hexString) })
|
||||
};
|
||||
|
||||
worker.onRILMessage(newSmsParcel(cdmaPduHelper, pdu));
|
||||
worker.onRILMessage(0, newSmsParcel(cdmaPduHelper, pdu));
|
||||
}
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
@ -19,11 +19,12 @@ add_test(function test_CdmaPDUHelper_encodeUserDataReplyOption() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
let testDataBuffer = [];
|
||||
worker.BitBufferHelper.startWrite(testDataBuffer);
|
||||
context.BitBufferHelper.startWrite(testDataBuffer);
|
||||
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let helper = context.CdmaPDUHelper;
|
||||
helper.encodeUserDataReplyOption({requestStatusReport: true});
|
||||
|
||||
let expectedDataBuffer = [PDU_CDMA_MSG_USERDATA_REPLY_OPTION, 0x01, 0x40];
|
||||
@ -49,11 +50,12 @@ add_test(function test_CdmaPDUHelper_decodeUserDataMsgStatus() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let helper = context.CdmaPDUHelper;
|
||||
function test_MsgStatus(octet) {
|
||||
let testDataBuffer = [octet];
|
||||
worker.BitBufferHelper.startRead(testDataBuffer);
|
||||
context.BitBufferHelper.startRead(testDataBuffer);
|
||||
let result = helper.decodeUserDataMsgStatus();
|
||||
|
||||
do_check_eq(result.errorClass, octet >>> 6);
|
||||
@ -85,10 +87,11 @@ add_test(function test_CdmaPDUHelper_decodeCdmaPDUMsg_Shift_jis() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
let helper = worker.CdmaPDUHelper;
|
||||
let helper = context.CdmaPDUHelper;
|
||||
function test_decodePDUMsg(testDataBuffer, expected, encoding, msgType, msgBodySize) {
|
||||
worker.BitBufferHelper.startRead(testDataBuffer);
|
||||
context.BitBufferHelper.startRead(testDataBuffer);
|
||||
let result = helper.decodeCdmaPDUMsg(encoding, msgType, msgBodySize);
|
||||
do_check_eq(result, expected);
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ add_test(function test_GsmPDUHelper_readDataCodingScheme() {
|
||||
}
|
||||
});
|
||||
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
function test_dcs(dcs, encoding, messageClass, mwi) {
|
||||
helper.readHexOctet = function() {
|
||||
return dcs;
|
||||
@ -159,7 +160,8 @@ add_test(function test_GsmPDUHelper_writeStringAsSeptets() {
|
||||
}
|
||||
});
|
||||
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
helper.resetOctetWritten = function() {
|
||||
helper.octetsWritten = 0;
|
||||
};
|
||||
@ -196,10 +198,10 @@ add_test(function test_GsmPDUHelper_readAddress() {
|
||||
postMessage: function(message) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
function test_address(addrHex, addrString) {
|
||||
let uint16Array = [];
|
||||
let ix = 0;
|
||||
@ -207,7 +209,7 @@ add_test(function test_GsmPDUHelper_readAddress() {
|
||||
uint16Array[i] = addrHex[i].charCodeAt();
|
||||
}
|
||||
|
||||
worker.Buf.readUint16 = function(){
|
||||
context.Buf.readUint16 = function(){
|
||||
if(ix >= uint16Array.length) {
|
||||
do_throw("out of range in uint16Array");
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ add_test(function test_RadioInterface__countGsm7BitSeptets() {
|
||||
}
|
||||
});
|
||||
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let helper = context.GsmPDUHelper;
|
||||
helper.resetOctetWritten = function() {
|
||||
helper.octetsWritten = 0;
|
||||
};
|
||||
|
@ -29,6 +29,7 @@ function _getWorker() {
|
||||
add_test(function test_notification() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
function Call(callIndex, number) {
|
||||
this.callIndex = callIndex;
|
||||
@ -69,7 +70,7 @@ add_test(function test_notification() {
|
||||
do_print('Test case info: ' + JSON.stringify(testInfo));
|
||||
|
||||
// Set current calls.
|
||||
worker.RIL._processCalls(calls);
|
||||
context.RIL._processCalls(calls);
|
||||
|
||||
let notificationInfo = {
|
||||
notificationType: 1, // MT
|
||||
@ -79,7 +80,7 @@ add_test(function test_notification() {
|
||||
number: number
|
||||
};
|
||||
|
||||
worker.RIL._processSuppSvcNotification(notificationInfo);
|
||||
context.RIL._processSuppSvcNotification(notificationInfo);
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
do_check_eq(postedMessage.rilMessageType, 'suppSvcNotification');
|
||||
@ -87,7 +88,7 @@ add_test(function test_notification() {
|
||||
do_check_eq(postedMessage.callIndex, resultCallIndex);
|
||||
|
||||
// Clear all existed calls.
|
||||
worker.RIL._processCalls(null);
|
||||
context.RIL._processCalls(null);
|
||||
}
|
||||
|
||||
testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null,
|
||||
|
@ -14,16 +14,17 @@ function newUint8Worker() {
|
||||
let worker = newWorker();
|
||||
let index = 0; // index for read
|
||||
let buf = [];
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.writeUint8 = function(value) {
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
buf.push(value);
|
||||
};
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
|
||||
@ -36,22 +37,23 @@ function newUint8SupportOutgoingIndexWorker() {
|
||||
let worker = newWorker();
|
||||
let index = 4; // index for read
|
||||
let buf = [0, 0, 0, 0]; // Preserved parcel size
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.writeUint8 = function(value) {
|
||||
if (worker.Buf.outgoingIndex >= buf.length) {
|
||||
context.Buf.writeUint8 = function(value) {
|
||||
if (context.Buf.outgoingIndex >= buf.length) {
|
||||
buf.push(value);
|
||||
} else {
|
||||
buf[worker.Buf.outgoingIndex] = value;
|
||||
buf[context.Buf.outgoingIndex] = value;
|
||||
}
|
||||
|
||||
worker.Buf.outgoingIndex++;
|
||||
context.Buf.outgoingIndex++;
|
||||
};
|
||||
|
||||
worker.Buf.readUint8 = function() {
|
||||
context.Buf.readUint8 = function() {
|
||||
return buf[index++];
|
||||
};
|
||||
|
||||
worker.Buf.seekIncoming = function(offset) {
|
||||
context.Buf.seekIncoming = function(offset) {
|
||||
index += offset;
|
||||
};
|
||||
|
||||
@ -66,8 +68,9 @@ function newUint8SupportOutgoingIndexWorker() {
|
||||
*/
|
||||
add_test(function test_if_send_stk_terminal_profile() {
|
||||
let worker = newUint8Worker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let profileSend = false;
|
||||
worker.RIL.sendStkTerminalProfile = function(data) {
|
||||
context.RIL.sendStkTerminalProfile = function(data) {
|
||||
profileSend = true;
|
||||
};
|
||||
|
||||
@ -80,7 +83,7 @@ add_test(function test_if_send_stk_terminal_profile() {
|
||||
};
|
||||
worker.RILQUIRKS_SEND_STK_PROFILE_DOWNLOAD = false;
|
||||
|
||||
worker.RIL._processICCStatus(iccStatus);
|
||||
context.RIL._processICCStatus(iccStatus);
|
||||
|
||||
do_check_eq(profileSend, false);
|
||||
|
||||
@ -92,8 +95,9 @@ add_test(function test_if_send_stk_terminal_profile() {
|
||||
*/
|
||||
add_test(function test_send_stk_terminal_profile() {
|
||||
let worker = newUint8Worker();
|
||||
let ril = worker.RIL;
|
||||
let buf = worker.Buf;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let ril = context.RIL;
|
||||
let buf = context.Buf;
|
||||
|
||||
ril.sendStkTerminalProfile(STK_SUPPORTED_TERMINAL_PROFILE);
|
||||
|
||||
@ -112,8 +116,9 @@ add_test(function test_send_stk_terminal_profile() {
|
||||
*/
|
||||
add_test(function test_stk_terminal_response() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -171,7 +176,7 @@ add_test(function test_stk_terminal_response() {
|
||||
input: "Mozilla",
|
||||
resultCode: STK_RESULT_OK
|
||||
};
|
||||
worker.RIL.sendStkTerminalResponse(response);
|
||||
context.RIL.sendStkTerminalResponse(response);
|
||||
});
|
||||
|
||||
// Test ComprehensionTlvHelper
|
||||
@ -181,8 +186,9 @@ add_test(function test_stk_terminal_response() {
|
||||
*/
|
||||
add_test(function test_write_location_info_tlv() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let tlvHelper = worker.ComprehensionTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let tlvHelper = context.ComprehensionTlvHelper;
|
||||
|
||||
// Test with 2-digit mnc, and gsmCellId obtained from UMTS network.
|
||||
let loc = {
|
||||
@ -270,8 +276,9 @@ add_test(function test_write_location_info_tlv() {
|
||||
*/
|
||||
add_test(function test_write_disconnecting_cause() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let tlvHelper = worker.ComprehensionTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let tlvHelper = context.ComprehensionTlvHelper;
|
||||
|
||||
tlvHelper.writeCauseTlv(RIL_ERROR_TO_GECKO_ERROR[ERROR_GENERIC_FAILURE]);
|
||||
let tag = pduHelper.readHexOctet();
|
||||
@ -291,7 +298,8 @@ add_test(function test_write_disconnecting_cause() {
|
||||
*/
|
||||
add_test(function test_get_size_of_length_octets() {
|
||||
let worker = newUint8Worker();
|
||||
let tlvHelper = worker.ComprehensionTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let tlvHelper = context.ComprehensionTlvHelper;
|
||||
|
||||
let length = 0x70;
|
||||
do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 1);
|
||||
@ -313,8 +321,9 @@ add_test(function test_get_size_of_length_octets() {
|
||||
*/
|
||||
add_test(function test_write_length() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let tlvHelper = worker.ComprehensionTlvHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let tlvHelper = context.ComprehensionTlvHelper;
|
||||
|
||||
let length = 0x70;
|
||||
tlvHelper.writeLength(length);
|
||||
@ -347,9 +356,10 @@ add_test(function test_write_length() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_search_next_tag() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let tag_test = [
|
||||
0xD0,
|
||||
@ -389,9 +399,10 @@ add_test(function test_stk_proactive_command_search_next_tag() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_refresh() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let refresh_1 = [
|
||||
0xD0,
|
||||
@ -422,9 +433,10 @@ add_test(function test_stk_proactive_command_refresh() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_play_tone() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let tone_1 = [
|
||||
0xD0,
|
||||
@ -464,9 +476,10 @@ add_test(function test_stk_proactive_command_play_tone() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_poll_interval() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let poll_1 = [
|
||||
0xD0,
|
||||
@ -498,9 +511,10 @@ add_test(function test_stk_proactive_command_poll_interval() {
|
||||
*/
|
||||
add_test(function test_read_septets_to_string() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let display_text_1 = [
|
||||
0xd0,
|
||||
@ -529,9 +543,10 @@ add_test(function test_read_septets_to_string() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_event_list() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let event_1 = [
|
||||
0xD0,
|
||||
@ -565,10 +580,11 @@ add_test(function test_stk_proactive_command_event_list() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_get_input() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let stkCmdHelper = worker.StkCommandParamsFactory;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
let stkCmdHelper = context.StkCommandParamsFactory;
|
||||
|
||||
let get_input_1 = [
|
||||
0xD0,
|
||||
@ -633,9 +649,10 @@ add_test(function test_stk_proactive_command_get_input() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_more_time() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
let more_time_1 = [
|
||||
0xD0,
|
||||
@ -662,10 +679,11 @@ add_test(function test_stk_proactive_command_more_time() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_select_item() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let stkFactory = worker.StkCommandParamsFactory;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
let stkFactory = context.StkCommandParamsFactory;
|
||||
|
||||
let select_item_1 = [
|
||||
0xD0,
|
||||
@ -749,10 +767,11 @@ add_test(function test_stk_proactive_command_select_item() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_set_up_menu() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let stkFactory = worker.StkCommandParamsFactory;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
let stkFactory = context.StkCommandParamsFactory;
|
||||
|
||||
let set_up_menu_1 = [
|
||||
0xD0,
|
||||
@ -832,10 +851,11 @@ add_test(function test_stk_proactive_command_set_up_menu() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_set_up_call() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let cmdFactory = worker.StkCommandParamsFactory;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
let cmdFactory = context.StkCommandParamsFactory;
|
||||
|
||||
let set_up_call_1 = [
|
||||
0xD0,
|
||||
@ -869,9 +889,10 @@ add_test(function test_stk_proactive_command_set_up_call() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_timer_management() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
// Timer Management - Start
|
||||
let timer_management_1 = [
|
||||
@ -931,9 +952,10 @@ add_test(function test_stk_proactive_command_timer_management() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_provide_local_information() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
// Verify IMEI
|
||||
let local_info_1 = [
|
||||
@ -979,9 +1001,10 @@ add_test(function test_stk_proactive_command_provide_local_information() {
|
||||
*/
|
||||
add_test(function test_stk_proactive_command_open_channel() {
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let berHelper = worker.BerTlvHelper;
|
||||
let stkHelper = worker.StkProactiveCmdHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let berHelper = context.BerTlvHelper;
|
||||
let stkHelper = context.StkProactiveCmdHelper;
|
||||
|
||||
// Open Channel
|
||||
let open_channel = [
|
||||
@ -1083,8 +1106,9 @@ add_test(function test_stk_proactive_command_open_channel() {
|
||||
*/
|
||||
add_test(function test_stk_event_download_location_status() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -1153,7 +1177,7 @@ add_test(function test_stk_event_download_location_status() {
|
||||
gsmCellId: 0
|
||||
}
|
||||
};
|
||||
worker.RIL.sendStkEventDownload({
|
||||
context.RIL.sendStkEventDownload({
|
||||
event: event
|
||||
});
|
||||
});
|
||||
@ -1165,9 +1189,10 @@ add_test(function test_stk_event_download_location_status() {
|
||||
*/
|
||||
add_test(function test_stk_event_download_language_selection() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let iccHelper = worker.ICCPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
let iccHelper = context.ICCPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -1214,7 +1239,7 @@ add_test(function test_stk_event_download_language_selection() {
|
||||
eventType: STK_EVENT_TYPE_LANGUAGE_SELECTION,
|
||||
language: "zh"
|
||||
};
|
||||
worker.RIL.sendStkEventDownload({
|
||||
context.RIL.sendStkEventDownload({
|
||||
event: event
|
||||
});
|
||||
});
|
||||
@ -1224,8 +1249,9 @@ add_test(function test_stk_event_download_language_selection() {
|
||||
*/
|
||||
add_test(function test_stk_event_download_user_activity() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -1262,7 +1288,7 @@ add_test(function test_stk_event_download_user_activity() {
|
||||
let event = {
|
||||
eventType: STK_EVENT_TYPE_USER_ACTIVITY
|
||||
};
|
||||
worker.RIL.sendStkEventDownload({
|
||||
context.RIL.sendStkEventDownload({
|
||||
event: event
|
||||
});
|
||||
});
|
||||
@ -1272,8 +1298,9 @@ add_test(function test_stk_event_download_user_activity() {
|
||||
*/
|
||||
add_test(function test_stk_event_download_idle_screen_available() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -1310,7 +1337,7 @@ add_test(function test_stk_event_download_idle_screen_available() {
|
||||
let event = {
|
||||
eventType: STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE
|
||||
};
|
||||
worker.RIL.sendStkEventDownload({
|
||||
context.RIL.sendStkEventDownload({
|
||||
event: event
|
||||
});
|
||||
});
|
||||
@ -1320,8 +1347,9 @@ add_test(function test_stk_event_download_idle_screen_available() {
|
||||
*/
|
||||
add_test(function test_stk_event_download_browser_termination() {
|
||||
let worker = newUint8SupportOutgoingIndexWorker();
|
||||
let buf = worker.Buf;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let buf = context.Buf;
|
||||
let pduHelper = context.GsmPDUHelper;
|
||||
|
||||
buf.sendParcel = function() {
|
||||
// Type
|
||||
@ -1367,7 +1395,7 @@ add_test(function test_stk_event_download_browser_termination() {
|
||||
eventType: STK_EVENT_TYPE_BROWSER_TERMINATION,
|
||||
terminationCause: STK_BROWSER_TERMINATION_CAUSE_USER
|
||||
};
|
||||
worker.RIL.sendStkEventDownload({
|
||||
context.RIL.sendStkEventDownload({
|
||||
event: event
|
||||
});
|
||||
});
|
||||
|
@ -29,14 +29,15 @@ function _getWorker() {
|
||||
add_test(function test_setVoicePrivacyMode_success() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
||||
worker.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
||||
context.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
||||
context.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setVoicePrivacyMode({
|
||||
context.RIL.setVoicePrivacyMode({
|
||||
enabled: true
|
||||
});
|
||||
|
||||
@ -50,14 +51,15 @@ add_test(function test_setVoicePrivacyMode_success() {
|
||||
add_test(function test_setVoicePrivacyMode_generic_failure() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
||||
worker.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
||||
context.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
||||
context.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
||||
rilRequestError: ERROR_GENERIC_FAILURE
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.setVoicePrivacyMode({
|
||||
context.RIL.setVoicePrivacyMode({
|
||||
enabled: true
|
||||
});
|
||||
|
||||
@ -71,18 +73,19 @@ add_test(function test_setVoicePrivacyMode_generic_failure() {
|
||||
add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32List = function fakeReadUint32List() {
|
||||
context.Buf.readInt32List = function fakeReadUint32List() {
|
||||
return [1];
|
||||
};
|
||||
|
||||
worker.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
||||
worker.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
||||
context.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
||||
context.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryVoicePrivacyMode();
|
||||
context.RIL.queryVoicePrivacyMode();
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
@ -94,18 +97,19 @@ add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
|
||||
add_test(function test_queryVoicePrivacyMode_success_enabled_false() {
|
||||
let workerHelper = _getWorker();
|
||||
let worker = workerHelper.worker;
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
|
||||
worker.Buf.readInt32List = function fakeReadUint32List() {
|
||||
context.Buf.readInt32List = function fakeReadUint32List() {
|
||||
return [0];
|
||||
};
|
||||
|
||||
worker.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
||||
worker.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
||||
context.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
||||
context.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
};
|
||||
|
||||
worker.RIL.queryVoicePrivacyMode();
|
||||
context.RIL.queryVoicePrivacyMode();
|
||||
|
||||
let postedMessage = workerHelper.postedMessage;
|
||||
|
||||
|
@ -144,6 +144,22 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
|
||||
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
|
||||
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
// Check whether |postRILMessage| has been defined. No one but this class
|
||||
// should ever define |postRILMessage| in a RIL worker, so we call to
|
||||
// |JS_LookupProperty| instead of |JS_GetProperty| here.
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
if (!JS_LookupProperty(aCx, workerGlobal, "postRILMessage", &val)) {
|
||||
JS_ReportPendingException(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
// |JS_LookupProperty| could still return JS_TRUE with an "undefined"
|
||||
// |postRILMessage|, so we have to make sure that with an additional call
|
||||
// to |JS_TypeOfValue|.
|
||||
if (JSTYPE_FUNCTION == JS_TypeOfValue(aCx, val)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!JS_DefineFunction(aCx, workerGlobal,
|
||||
"postRILMessage", PostToRIL, 2, 0);
|
||||
}
|
||||
@ -151,13 +167,16 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
|
||||
class DispatchRILEvent : public WorkerTask
|
||||
{
|
||||
public:
|
||||
DispatchRILEvent(UnixSocketRawData* aMessage)
|
||||
: mMessage(aMessage)
|
||||
DispatchRILEvent(unsigned long aClient,
|
||||
UnixSocketRawData* aMessage)
|
||||
: mClientId(aClient)
|
||||
, mMessage(aMessage)
|
||||
{ }
|
||||
|
||||
virtual bool RunTask(JSContext *aCx);
|
||||
|
||||
private:
|
||||
unsigned long mClientId;
|
||||
nsAutoPtr<UnixSocketRawData> mMessage;
|
||||
};
|
||||
|
||||
@ -166,15 +185,18 @@ DispatchRILEvent::RunTask(JSContext *aCx)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewUint8Array(aCx, mMessage->mSize));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
JS::Rooted<JS::Value> arrayVal(aCx, JS::ObjectValue(*array));
|
||||
|
||||
memcpy(JS_GetArrayBufferViewData(array), mMessage->mData, mMessage->mSize);
|
||||
|
||||
JS::AutoValueArray<2> args(aCx);
|
||||
args[0].setNumber((uint32_t)mClientId);
|
||||
args[1].setObject(*array);
|
||||
|
||||
JS::Rooted<JS::Value> rval(aCx);
|
||||
return JS_CallFunctionName(aCx, obj, "onRILMessage", arrayVal, &rval);
|
||||
return JS_CallFunctionName(aCx, obj, "onRILMessage", args, &rval);
|
||||
}
|
||||
|
||||
class RilConnector : public mozilla::ipc::UnixSocketConnector
|
||||
@ -354,7 +376,7 @@ RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(aMessage.forget()));
|
||||
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aMessage.forget()));
|
||||
mDispatcher->PostTask(dre);
|
||||
}
|
||||
|
||||
|
@ -5,213 +5,213 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "GonkMemoryPressureMonitoring.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsMemoryPressure.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "base/message_loop.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG(args...) \
|
||||
__android_log_print(ANDROID_LOG_INFO, "GonkMemoryPressure" , ## args)
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
#include "ipc/Nuwa.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* MemoryPressureWatcher watches sysfs from its own thread to notice when the
|
||||
* system is under memory pressure. When we observe memory pressure, we use
|
||||
* MemoryPressureRunnable to notify observers that they should release memory.
|
||||
*
|
||||
* When the system is under memory pressure, we don't want to constantly fire
|
||||
* memory-pressure events. So instead, we try to detect when sysfs indicates
|
||||
* that we're no longer under memory pressure, and only then start firing events
|
||||
* again.
|
||||
*
|
||||
* (This is a bit problematic because we can't poll() to detect when we're no
|
||||
* longer under memory pressure; instead we have to periodically read the sysfs
|
||||
* node. If we remain under memory pressure for a long time, this means we'll
|
||||
* continue waking up to read from the node for a long time, potentially wasting
|
||||
* battery life. Hopefully we don't hit this case in practice! We write to
|
||||
* logcat each time we go around this loop so it's at least noticable.)
|
||||
*
|
||||
* Shutting down safely is a bit of a chore. XPCOM won't shut down until all
|
||||
* threads exit, so we need to exit the Run() method below on shutdown. But our
|
||||
* thread might be blocked in one of two situations: We might be poll()'ing the
|
||||
* sysfs node waiting for memory pressure to occur, or we might be asleep
|
||||
* waiting to read() the sysfs node to see if we're no longer under memory
|
||||
* pressure.
|
||||
*
|
||||
* To let us wake up from the poll(), we poll() not just the sysfs node but also
|
||||
* a pipe, which we write to on shutdown. To let us wake up from sleeping
|
||||
* between read()s, we sleep by Wait()'ing on a monitor, which we notify on
|
||||
* shutdown.
|
||||
*/
|
||||
class MemoryPressureWatcher
|
||||
: public nsIRunnable
|
||||
, public nsIObserver
|
||||
//
|
||||
// MemoryPressureWatcher watches on the I/O thread for changes to the
|
||||
// lowmemkiller's sysfs interface. If the system runs low on memory,
|
||||
// MemoryPressureWatcher sends a MemoryPressureEvent, removes itself
|
||||
// from the I/O loop, and schedules a PollTask to re-start polling
|
||||
// after a timeout has been reached.
|
||||
//
|
||||
// The PollTask is allocated by MemoryPressureWatcher and handed over
|
||||
// to the I/O loop, which then owns the object and deletes it after it
|
||||
// ran. We cannot allocate the object dynamically, because the system
|
||||
// is already low on memory. Instead we overload the new and delete
|
||||
// operators for PollTask to hand-out statically allocated memory.
|
||||
// There can only be at most one instance of PollTask at a time, so
|
||||
// we can re-use the same memory on each allocation.
|
||||
//
|
||||
// There is a separate observer for shutdown events. When the system
|
||||
// shuts down, it sends a task to the I/O thread for removing the
|
||||
// watcher. If a PollTask is pending, it gets canceled. We cannot
|
||||
// delete it at this point, because it's owned by the I/O loop.
|
||||
//
|
||||
class MemoryPressureWatcher : public MessageLoopForIO::Watcher
|
||||
{
|
||||
public:
|
||||
MemoryPressureWatcher()
|
||||
: mMonitor("MemoryPressureWatcher")
|
||||
, mShuttingDown(false)
|
||||
class PollTask : public CancelableTask
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
nsresult Init()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
NS_ENSURE_STATE(os);
|
||||
|
||||
// The observer service holds us alive.
|
||||
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, /* holdsWeak */ false);
|
||||
|
||||
// While we're under memory pressure, we periodically read()
|
||||
// notify_trigger_active to try and see when we're no longer under memory
|
||||
// pressure. mPollMS indicates how many milliseconds we wait between those
|
||||
// read()s.
|
||||
mPollMS = Preferences::GetUint("gonk.systemMemoryPressureRecoveryPollMS",
|
||||
/* default */ 5000);
|
||||
|
||||
int pipes[2];
|
||||
NS_ENSURE_STATE(!pipe(pipes));
|
||||
mShutdownPipeRead = pipes[0];
|
||||
mShutdownPipeWrite = pipes[1];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
|
||||
LOG("Observed XPCOM shutdown.");
|
||||
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
mShuttingDown = true;
|
||||
mMonitor.Notify();
|
||||
|
||||
int rv;
|
||||
do {
|
||||
// Write something to the pipe; doesn't matter what.
|
||||
uint32_t dummy = 0;
|
||||
rv = write(mShutdownPipeWrite, &dummy, sizeof(dummy));
|
||||
} while(rv == -1 && errno == EINTR);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (IsNuwaProcess()) {
|
||||
NS_ASSERTION(NuwaMarkCurrentThread != nullptr,
|
||||
"NuwaMarkCurrentThread is undefined!");
|
||||
NuwaMarkCurrentThread(nullptr, nullptr);
|
||||
public:
|
||||
PollTask(MemoryPressureWatcher* aWatcher)
|
||||
: mWatcher(aWatcher)
|
||||
{
|
||||
MOZ_ASSERT(mWatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
int lowMemFd = open("/sys/kernel/mm/lowmemkiller/notify_trigger_active",
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
NS_ENSURE_STATE(lowMemFd != -1);
|
||||
ScopedClose autoClose(lowMemFd);
|
||||
static void* operator new(size_t aSize);
|
||||
static void operator delete(void* aMem, size_t aSize);
|
||||
|
||||
nsresult rv = CheckForMemoryPressure(lowMemFd, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
void Run() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current());
|
||||
|
||||
while (true) {
|
||||
// Wait for a notification on lowMemFd or for data to be written to
|
||||
// mShutdownPipeWrite. (poll(lowMemFd, POLLPRI) blocks until we're under
|
||||
// memory pressure.)
|
||||
struct pollfd pollfds[2];
|
||||
pollfds[0].fd = lowMemFd;
|
||||
pollfds[0].events = POLLPRI;
|
||||
pollfds[1].fd = mShutdownPipeRead;
|
||||
pollfds[1].events = POLLIN;
|
||||
if (mWatcher) {
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mWatcher->GetIOLoop());
|
||||
mWatcher->StartWatching();
|
||||
}
|
||||
}
|
||||
|
||||
int pollRv;
|
||||
do {
|
||||
pollRv = poll(pollfds, ArrayLength(pollfds), /* timeout */ -1);
|
||||
} while (pollRv == -1 && errno == EINTR);
|
||||
void Cancel() MOZ_OVERRIDE
|
||||
{
|
||||
mWatcher = nullptr;
|
||||
}
|
||||
|
||||
if (pollfds[1].revents) {
|
||||
// Something was written to our shutdown pipe; we're outta here.
|
||||
LOG("shutting down (1)");
|
||||
return NS_OK;
|
||||
private:
|
||||
MemoryPressureWatcher* mWatcher;
|
||||
};
|
||||
|
||||
template <size_t Size> class PollTaskAllocator
|
||||
{
|
||||
public:
|
||||
void* Alloc()
|
||||
{
|
||||
MOZ_ASSERT(!sAllocated);
|
||||
sAllocated = true;
|
||||
return mMem;
|
||||
}
|
||||
void Release(void* aMem)
|
||||
{
|
||||
MOZ_ASSERT(mMem == aMem);
|
||||
MOZ_ASSERT(sAllocated);
|
||||
sAllocated = false;
|
||||
}
|
||||
|
||||
private:
|
||||
static bool sAllocated;
|
||||
unsigned char mMem[Size];
|
||||
};
|
||||
|
||||
MemoryPressureWatcher(MessageLoop* aIOLoop, uint32_t aPollMS)
|
||||
: mFd(-1)
|
||||
, mIOLoop(aIOLoop)
|
||||
, mPollTask(nullptr)
|
||||
, mPollMS(aPollMS)
|
||||
, mMemoryPressure(false)
|
||||
{
|
||||
MOZ_ASSERT(mIOLoop);
|
||||
}
|
||||
|
||||
virtual ~MemoryPressureWatcher()
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
|
||||
MOZ_ASSERT(mFd == -1);
|
||||
}
|
||||
|
||||
MessageLoop* GetIOLoop () const
|
||||
{
|
||||
return mIOLoop;
|
||||
}
|
||||
|
||||
nsresult Open()
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
|
||||
|
||||
int fd;
|
||||
|
||||
do {
|
||||
fd = open("/sys/kernel/mm/lowmemkiller/notify_trigger_active",
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
|
||||
if (NS_WARN_IF(fd == -1)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
mFd = fd;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
|
||||
|
||||
if (NS_WARN_IF(mFd == -1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int res;
|
||||
|
||||
do {
|
||||
res = close(mFd);
|
||||
} while (res == -1 && errno == EINTR);
|
||||
|
||||
NS_WARN_IF(res == -1);
|
||||
mFd = -1;
|
||||
}
|
||||
|
||||
void StartWatching()
|
||||
{
|
||||
MessageLoopForIO* ioLoop = MessageLoopForIO::current();
|
||||
MOZ_ASSERT(ioLoop == mIOLoop);
|
||||
ioLoop->WatchFileDescriptor(mFd, true, MessageLoopForIO::WATCH_READ,
|
||||
&mReadWatcher, this);
|
||||
mPollTask = nullptr;
|
||||
}
|
||||
|
||||
void StopWatching()
|
||||
{
|
||||
if (mPollTask) {
|
||||
mPollTask->Cancel();
|
||||
}
|
||||
mReadWatcher.StopWatchingFileDescriptor();
|
||||
}
|
||||
|
||||
virtual void OnFileCanWriteWithoutBlocking(int aFd) MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
|
||||
NS_WARNING("Must not write to memory monitor");
|
||||
}
|
||||
|
||||
virtual void OnFileCanReadWithoutBlocking(int aFd) MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
|
||||
|
||||
bool memoryPressure;
|
||||
nsresult rv = CheckForMemoryPressure(memoryPressure);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (memoryPressure) {
|
||||
LOG("Memory pressure detected.");
|
||||
StopWatching();
|
||||
if (mMemoryPressure) {
|
||||
rv = NS_DispatchMemoryPressure(MemPressure_Ongoing);
|
||||
} else {
|
||||
rv = NS_DispatchMemoryPressure(MemPressure_New);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If pollfds[1] isn't happening, pollfds[0] ought to be!
|
||||
if (!(pollfds[0].revents & POLLPRI)) {
|
||||
LOG("Unexpected revents value after poll(): %d. "
|
||||
"Shutting down GonkMemoryPressureMonitoring.", pollfds[0].revents);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// POLLPRI on lowMemFd indicates that we're in a low-memory situation. We
|
||||
// could read lowMemFd to double-check, but we've observed that the read
|
||||
// sometimes completes after the memory-pressure event is over, so let's
|
||||
// just believe the result of poll().
|
||||
|
||||
// We use low-memory-no-forward because each process has its own watcher
|
||||
// and thus there is no need for the main process to forward this event.
|
||||
rv = NS_DispatchMemoryPressure(MemPressure_New);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Manually check lowMemFd until we observe that memory pressure is over.
|
||||
// We won't fire any more low-memory events until we observe that
|
||||
// we're no longer under pressure. Instead, we fire low-memory-ongoing
|
||||
// events, which cause processes to keep flushing caches but will not
|
||||
// trigger expensive GCs and other attempts to save memory that are
|
||||
// likely futile at this point.
|
||||
bool memoryPressure;
|
||||
do {
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
// We need to check mShuttingDown before we wait here, in order to
|
||||
// catch a shutdown signal sent after we poll()'ed mShutdownPipeRead
|
||||
// above but before we started waiting on the monitor. But we don't
|
||||
// need to check after we wait, because we'll either do another
|
||||
// iteration of this inner loop, in which case we'll check
|
||||
// mShuttingDown, or we'll exit this loop and do another iteration
|
||||
// of the outer loop, in which case we'll check the shutdown pipe.
|
||||
if (mShuttingDown) {
|
||||
LOG("shutting down (2)");
|
||||
return NS_OK;
|
||||
}
|
||||
mMonitor.Wait(PR_MillisecondsToInterval(mPollMS));
|
||||
}
|
||||
|
||||
LOG("Checking to see if memory pressure is over.");
|
||||
rv = CheckForMemoryPressure(lowMemFd, &memoryPressure);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (memoryPressure) {
|
||||
rv = NS_DispatchMemoryPressure(MemPressure_Ongoing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
continue;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
// While we're under memory pressure, we periodically read()
|
||||
// notify_trigger_active to try and see when we're no longer under
|
||||
// memory pressure. mPollMS indicates how many milliseconds we wait
|
||||
// between those read()s.
|
||||
mPollTask = new PollTask(this);
|
||||
mIOLoop->PostDelayedTask(FROM_HERE, mPollTask, mPollMS);
|
||||
} else if (mMemoryPressure) {
|
||||
LOG("Memory pressure is over.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
mMemoryPressure = memoryPressure;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -222,38 +222,138 @@ private:
|
||||
*
|
||||
* We don't expect this method to block.
|
||||
*/
|
||||
nsresult CheckForMemoryPressure(int aLowMemFd, bool* aOut)
|
||||
nsresult CheckForMemoryPressure(bool& aOut)
|
||||
{
|
||||
if (aOut) {
|
||||
*aOut = false;
|
||||
}
|
||||
aOut = false;
|
||||
|
||||
lseek(aLowMemFd, 0, SEEK_SET);
|
||||
off_t off = lseek(mFd, 0, SEEK_SET);
|
||||
if (NS_WARN_IF(off)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
char buf[2];
|
||||
int nread;
|
||||
do {
|
||||
nread = read(aLowMemFd, buf, sizeof(buf));
|
||||
nread = read(mFd, buf, sizeof(buf));
|
||||
} while(nread == -1 && errno == EINTR);
|
||||
NS_ENSURE_STATE(nread == 2);
|
||||
if (NS_WARN_IF(nread != 2)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// The notify_trigger_active sysfs node should contain either "0\n" or
|
||||
// "1\n". The latter indicates memory pressure.
|
||||
if (aOut) {
|
||||
*aOut = buf[0] == '1' && buf[1] == '\n';
|
||||
}
|
||||
aOut = buf[0] == '1' && buf[1] == '\n';
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Monitor mMonitor;
|
||||
int mFd;
|
||||
MessageLoop* mIOLoop;
|
||||
MessageLoopForIO::FileDescriptorWatcher mReadWatcher;
|
||||
PollTask* mPollTask;
|
||||
uint32_t mPollMS;
|
||||
bool mShuttingDown;
|
||||
|
||||
ScopedClose mShutdownPipeRead;
|
||||
ScopedClose mShutdownPipeWrite;
|
||||
bool mMemoryPressure;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(MemoryPressureWatcher, nsIRunnable, nsIObserver);
|
||||
static
|
||||
MemoryPressureWatcher::PollTaskAllocator<sizeof(MemoryPressureWatcher::PollTask)>
|
||||
sPollTaskAllocator;
|
||||
|
||||
template<>
|
||||
bool
|
||||
MemoryPressureWatcher::PollTaskAllocator<sizeof(MemoryPressureWatcher::PollTask)>::sAllocated(false);
|
||||
|
||||
void*
|
||||
MemoryPressureWatcher::PollTask::operator new(size_t aSize)
|
||||
{
|
||||
return sPollTaskAllocator.Alloc();
|
||||
}
|
||||
|
||||
void
|
||||
MemoryPressureWatcher::PollTask::operator delete(void* aMem, size_t aSize)
|
||||
{
|
||||
sPollTaskAllocator.Release(aMem);
|
||||
}
|
||||
|
||||
// Initializes MemoryPressureWatcher on I/O thread
|
||||
//
|
||||
class InitMemoryPressureWatcherTask : public Task
|
||||
{
|
||||
public:
|
||||
InitMemoryPressureWatcherTask(MemoryPressureWatcher* aWatcher)
|
||||
: mWatcher(aWatcher)
|
||||
{
|
||||
MOZ_ASSERT(mWatcher);
|
||||
}
|
||||
|
||||
void Run() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mWatcher->GetIOLoop());
|
||||
|
||||
nsresult rv = mWatcher->Open();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
mWatcher->StartWatching();
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPressureWatcher* mWatcher;
|
||||
};
|
||||
|
||||
// Releases MemoryPressureWatcher on I/O thread
|
||||
//
|
||||
class ShutdownMemoryPressureWatcherTask : public Task
|
||||
{
|
||||
public:
|
||||
ShutdownMemoryPressureWatcherTask(MemoryPressureWatcher* aWatcher)
|
||||
: mWatcher(aWatcher)
|
||||
{
|
||||
MOZ_ASSERT(mWatcher);
|
||||
}
|
||||
|
||||
void Run() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == mWatcher->GetIOLoop());
|
||||
|
||||
mWatcher->StopWatching();
|
||||
mWatcher->Close();
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoPtr<MemoryPressureWatcher> mWatcher;
|
||||
};
|
||||
|
||||
// Closes MemoryPressureWatcher on shutdown
|
||||
//
|
||||
class ShutdownObserver : public nsIObserver
|
||||
{
|
||||
public:
|
||||
ShutdownObserver(MemoryPressureWatcher* aWatcher)
|
||||
: mWatcher(aWatcher)
|
||||
{
|
||||
MOZ_ASSERT(mWatcher);
|
||||
}
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID));
|
||||
LOG("Observed XPCOM shutdown.");
|
||||
|
||||
Task* task = new ShutdownMemoryPressureWatcherTask(mWatcher);
|
||||
mWatcher->GetIOLoop()->PostTask(FROM_HERE, task);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPressureWatcher* mWatcher;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(ShutdownObserver, nsIObserver);
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@ -262,13 +362,22 @@ namespace mozilla {
|
||||
void
|
||||
InitGonkMemoryPressureMonitoring()
|
||||
{
|
||||
// memoryPressureWatcher is held alive by the observer service.
|
||||
nsRefPtr<MemoryPressureWatcher> memoryPressureWatcher =
|
||||
new MemoryPressureWatcher();
|
||||
NS_ENSURE_SUCCESS_VOID(memoryPressureWatcher->Init());
|
||||
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
|
||||
uint32_t pollMS =
|
||||
Preferences::GetUint("gonk.systemMemoryPressureRecoveryPollMS", 5000);
|
||||
MemoryPressureWatcher* watcher = new MemoryPressureWatcher(ioLoop, pollMS);
|
||||
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
NS_NewThread(getter_AddRefs(thread), memoryPressureWatcher);
|
||||
// Start watcher on I/O thread
|
||||
Task* task = new InitMemoryPressureWatcherTask(watcher);
|
||||
watcher->GetIOLoop()->PostTask(FROM_HERE, task);
|
||||
|
||||
// Install shutdown observer
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (NS_WARN_IF(!os)) {
|
||||
return;
|
||||
}
|
||||
nsRefPtr<ShutdownObserver> observer = new ShutdownObserver(watcher);
|
||||
os->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user