Bug 709567 - B2G SMS: RIL to DOM plumbing for incoming SMS. r=qDot

This commit is contained in:
Philipp von Weitershausen 2011-12-24 06:02:51 +01:00
parent 91bd0d3fe4
commit a98dc4996f

View File

@ -409,7 +409,7 @@ let Buf = {
try { try {
this.processParcel(); this.processParcel();
} catch (ex) { } catch (ex) {
if (DEBUG) debug("Parcel handling threw " + ex); if (DEBUG) debug("Parcel handling threw " + ex + "\n" + ex.stack);
} }
// Ensure that the whole parcel was consumed. // Ensure that the whole parcel was consumed.
@ -685,6 +685,22 @@ let RIL = {
Buf.sendParcel(); Buf.sendParcel();
}, },
/**
* Acknowledge the receipt and handling of an SMS.
*
* @param success
* Boolean indicating whether the message was successfuly handled.
* @param cause
* SMS_* constant indicating the reason for unsuccessful handling.
*/
acknowledgeSMS: function acknowledgeSMS(success, cause) {
let token = Buf.newParcel(REQUEST_SMS_ACKNOWLEDGE);
Buf.writeUint32(2);
Buf.writeUint32(success ? 1 : 0);
Buf.writeUint32(cause);
Buf.sendParcel();
},
/** /**
* Start a DTMF Tone. * Start a DTMF Tone.
* *
@ -876,7 +892,9 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] = null;
RIL[REQUEST_SET_CALL_FORWARD] = null; RIL[REQUEST_SET_CALL_FORWARD] = null;
RIL[REQUEST_QUERY_CALL_WAITING] = null; RIL[REQUEST_QUERY_CALL_WAITING] = null;
RIL[REQUEST_SET_CALL_WAITING] = null; RIL[REQUEST_SET_CALL_WAITING] = null;
RIL[REQUEST_SMS_ACKNOWLEDGE] = null; RIL[REQUEST_SMS_ACKNOWLEDGE] = function REQUEST_SMS_ACKNOWLEDGE() {
Phone.onAcknowledgeSMS();
};
RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI() { RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI() {
let imei = Buf.readString(); let imei = Buf.readString();
Phone.onIMEI(imei); Phone.onIMEI(imei);
@ -973,9 +991,17 @@ RIL[UNSOLICITED_RESPONSE_CALL_STATE_CHANGED] = function UNSOLICITED_RESPONSE_CAL
RIL[UNSOLICITED_RESPONSE_NETWORK_STATE_CHANGED] = function UNSOLICITED_RESPONSE_NETWORK_STATE_CHANGED() { RIL[UNSOLICITED_RESPONSE_NETWORK_STATE_CHANGED] = function UNSOLICITED_RESPONSE_NETWORK_STATE_CHANGED() {
Phone.onNetworkStateChanged(); Phone.onNetworkStateChanged();
}; };
RIL[UNSOLICITED_RESPONSE_NEW_SMS] = null; RIL[UNSOLICITED_RESPONSE_NEW_SMS] = function UNSOLICITED_RESPONSE_NEW_SMS(length) {
RIL[UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT] = null; Phone.onNewSMS(length);
RIL[UNSOLICITED_RESPONSE_NEW_SMS_ON_SIM] = null; };
RIL[UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT] = function UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT(length) {
let info = Buf.readStringList();
Phone.onNewSMSStatusReport(info);
};
RIL[UNSOLICITED_RESPONSE_NEW_SMS_ON_SIM] = function UNSOLICITED_RESPONSE_NEW_SMS_ON_SIM(length) {
let info = Buf.readUint32List();
Phone.onNewSMSOnSIM(message);
};
RIL[UNSOLICITED_ON_USSD] = null; RIL[UNSOLICITED_ON_USSD] = null;
RIL[UNSOLICITED_ON_USSD_REQUEST] = null; RIL[UNSOLICITED_ON_USSD_REQUEST] = null;
RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = null; RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = null;
@ -1313,6 +1339,50 @@ let Phone = {
//TODO //TODO
}, },
onNewSMS: function onNewSMS(payloadLength) {
if (!payloadLength) {
if (DEBUG) debug("Received empty SMS!");
//TODO: should we acknowledge the SMS here? maybe only after multiple
//failures.
return;
}
// An SMS is a string, but we won't read it as such, so let's read the
// string length and then defer to PDU parsing helper.
let messageStringLength = Buf.readUint32();
debug("Got new SMS, length " + messageStringLength);
let message = GsmPDUHelper.readMessage();
debug(message);
// Read string delimiters. See Buf.readString().
let delimiter = Buf.readUint16();
if (!(messageStringLength & 1)) {
delimiter |= Buf.readUint16();
}
if (DEBUG) {
if (delimiter != 0) {
debug("Something's wrong, found string delimiter: " + delimiter);
}
}
message.type = "sms-received";
this.sendDOMMessage(message);
//TODO: this might be a lie? do we want to wait for the mainthread to
// report back?
RIL.acknowledgeSMS(true, SMS_HANDLED);
},
onNewSMSStatusReport: function onNewSMSStatusReport(info) {
//TODO
},
onNewSMSOnSIM: function onNewSMSOnSIM(info) {
//TODO
},
onAcknowledgeSMS: function onAcknowledgeSMS() {
},
/** /**
* Outgoing requests to the RIL. These can be triggered from the * Outgoing requests to the RIL. These can be triggered from the
* main thread via messages that look like this: * main thread via messages that look like this: