Bug 1072367 - Part 3: broadcast system message "cdma-info-rec-received" in MobileConnectionService. r=echen

This commit is contained in:
Bevis Tseng 2014-10-03 14:23:41 +08:00
Родитель 34d2697297
Коммит 4924761b67
5 изменённых файлов: 467 добавлений и 14 удалений

Просмотреть файл

@ -950,6 +950,11 @@ MobileConnectionService.prototype = {
} catch (e) {}
},
_broadcastCdmaInfoRecordSystemMessage: function(aMessage) {
// TODO: Bug 1072808, Broadcast System Message with proxy.
gSystemMessenger.broadcastMessage("cdma-info-rec-received", aMessage);
},
/**
* nsIMobileConnectionService interface.
*/
@ -1167,6 +1172,111 @@ MobileConnectionService.prototype = {
aServiceClass);
},
notifyCdmaInfoRecDisplay: function(aClientId, aDisplay) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
display: aDisplay
});
},
notifyCdmaInfoRecCalledPartyNumber: function(aClientId, aType, aPlan, aNumber,
aPi, aSi) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
calledNumber: {
type: aType,
plan: aPlan,
number: aNumber,
pi: aPi,
si: aSi
}
});
},
notifyCdmaInfoRecCallingPartyNumber: function(aClientId, aType, aPlan, aNumber,
aPi, aSi) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
callingNumber: {
type: aType,
plan: aPlan,
number: aNumber,
pi: aPi,
si: aSi
}
});
},
notifyCdmaInfoRecConnectedPartyNumber: function(aClientId, aType, aPlan, aNumber,
aPi, aSi) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
connectedNumber: {
type: aType,
plan: aPlan,
number: aNumber,
pi: aPi,
si: aSi
}
});
},
notifyCdmaInfoRecSignal: function(aClientId, aType, aAlertPitch, aSignal){
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
signal: {
type: aType,
alertPitch: aAlertPitch,
signal: aSignal
}
});
},
notifyCdmaInfoRecRedirectingNumber: function(aClientId, aType, aPlan, aNumber,
aPi, aSi, aReason) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
redirect: {
type: aType,
plan: aPlan,
number: aNumber,
pi: aPi,
si: aSi,
reason: aReason
}
});
},
notifyCdmaInfoRecLineControl: function(aClientId, aPolarityIncluded, aToggle,
aReverse, aPowerDenial) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
lineControl: {
polarityIncluded: aPolarityIncluded,
toggle: aToggle,
reverse: aReverse,
powerDenial: aPowerDenial
}
});
},
notifyCdmaInfoRecClir: function(aClientId, aCause) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
clirCause: aCause
});
},
notifyCdmaInfoRecAudioControl: function(aClientId, aUplink, aDownLink) {
this._broadcastCdmaInfoRecordSystemMessage({
clientId: aClientId,
audioControl: {
upLink: aUplink,
downLink: aDownLink
}
});
},
/**
* nsIObserver interface.
*/

Просмотреть файл

@ -9,7 +9,7 @@
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1"
%}
[scriptable, uuid(b0310517-e7f6-4fa5-a52e-fa6ff35c8fc1)]
[scriptable, uuid(2d574f0e-4a02-11e4-b1b3-cbc14b7608ce)]
interface nsIGonkMobileConnectionService : nsIMobileConnectionService
{
void notifyNetworkInfoChanged(in unsigned long clientId, in jsval networkInfo);
@ -53,4 +53,205 @@ interface nsIGonkMobileConnectionService : nsIMobileConnectionService
in DOMString number,
in unsigned short timeSeconds,
in unsigned short serviceClass);
/**
* Notify Display Info from received Cdma-Info-Record.
* See 3.7.4.1 Display in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param display
The string to be displayed.
*/
void notifyCdmaInfoRecDisplay(in unsigned long clientId,
in DOMString display);
/**
* Notify Called Party Number from received Cdma-Info-Record.
* See 3.7.4.2 Called Party Number in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param type
* The type of number. (3-bit binary)
* See Table 2.7.1.3.2.4-2 in 3GPP2 C.S0005-F.
* @param plan
* The numbering plan. (4-bit binary)
* See Table 2.7.1.3.2.4-3 in 3GPP2 C.S0005-F.
* @param number
* The string presentation of the number.
* @param pi (2-bit binary)
* The Presentation indicator of the number.
* See Table 2.7.4.4-1 in 3GPP2 C.S0005-F.
* @param si (2-bit binary)
* The Screening Indicator of the number.
* See Table 2.7.4.4-2 in 3GPP2 C.S0005-F.
*/
void notifyCdmaInfoRecCalledPartyNumber(in unsigned long clientId,
in unsigned short type,
in unsigned short plan,
in DOMString number,
in unsigned short pi,
in unsigned short si);
/**
* Notify Calling Party Number from received Cdma-Info-Record.
* See 3.7.4.3 Calling Party Number in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param type
* The type of number. (3-bit binary)
* See Table 2.7.1.3.2.4-2 in 3GPP2 C.S0005-F.
* @param plan
* The numbering plan. (4-bit binary)
* See Table 2.7.1.3.2.4-3 in 3GPP2 C.S0005-F.
* @param number
* The string presentation of the number.
* @param pi (2-bit binary)
* The Presentation indicator of the number.
* See Table 2.7.4.4-1 in 3GPP2 C.S0005-F.
* @param si (2-bit binary)
* The Screening Indicator of the number.
* See Table 2.7.4.4-2 in 3GPP2 C.S0005-F.
*/
void notifyCdmaInfoRecCallingPartyNumber(in unsigned long clientId,
in unsigned short type,
in unsigned short plan,
in DOMString number,
in unsigned short pi,
in unsigned short si);
/**
* Notify Connected Party Number from received Cdma-Info-Record.
* See 3.7.4.4 Connected Party Number in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param type
* The type of number. (3-bit binary)
* See Table 2.7.1.3.2.4-2 in 3GPP2 C.S0005-F.
* @param plan
* The numbering plan. (4-bit binary)
* See Table 2.7.1.3.2.4-3 in 3GPP2 C.S0005-F.
* @param number
* The string presentation of the number.
* @param pi (2-bit binary)
* The Presentation indicator of the number.
* See Table 2.7.4.4-1 in 3GPP2 C.S0005-F.
* @param si (2-bit binary)
* The Screening Indicator of the number.
* See Table 2.7.4.4-2 in 3GPP2 C.S0005-F.
*/
void notifyCdmaInfoRecConnectedPartyNumber(in unsigned long clientId,
in unsigned short type,
in unsigned short plan,
in DOMString number,
in unsigned short pi,
in unsigned short si);
/**
* Notify Signal Info from received Cdma-Info-Record.
* See 3.7.4.5 Signal in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param type
* The signal type. (2-bit binary)
* See Table 3.7.5.5-1 in 3GPP2 C.S0005-F.
* @param alertPitch
* The pitch of the alerting signal. (2-bit binary)
* See Table 3.7.5.5-2 in 3GPP2 C.S0005-F.
* @param signal
* The signal code. (6-bit binary)
* See Table 3.7.5.5-3, 3.7.5.5-4, 3.7.5.5-5 in 3GPP2 C.S0005-F.
*/
void notifyCdmaInfoRecSignal(in unsigned long clientId,
in unsigned short type,
in unsigned short alertPitch,
in unsigned short signal);
/**
* Notify Redirecting Number from received Cdma-Info-Record.
* See 3.7.4.11 Redirecting Number in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param type
* The type of number. (3-bit binary)
* See Table 2.7.1.3.2.4-2 in 3GPP2 C.S0005-F.
* @param plan
* The numbering plan. (4-bit binary)
* See Table 2.7.1.3.2.4-3 in 3GPP2 C.S0005-F.
* @param number
* The string presentation of the number.
* @param pi (2-bit binary)
* The Presentation indicator of the number.
* See Table 2.7.4.4-1 in 3GPP2 C.S0005-F.
* @param si (2-bit binary)
* The Screening Indicator of the number.
* See Table 2.7.4.4-2 in 3GPP2 C.S0005-F.
* @param reason (4-bit binary)
* The redirection reason.
* See Table 3.7.5.11-1 in 3GPP2 C.S0005-F.
*/
void notifyCdmaInfoRecRedirectingNumber(in unsigned long clientId,
in unsigned short type,
in unsigned short plan,
in DOMString number,
in unsigned short pi,
in unsigned short si,
in unsigned short reason);
/**
* Notify Line Control from received Cdma-Info-Record.
* See 3.7.4.15 Line Control in 3GPP2 C.S0005-F.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param polarityIncluded (1-bit)
* Polarity parameter included.
* @param toggle (1-bit)
* Toggle mode.
* @param reverse (1-bit)
* Reverse polarity.
* @param powerDenial (8-bit)
* Power denial timeout.
*/
void notifyCdmaInfoRecLineControl(in unsigned long clientId,
in unsigned short polarityIncluded,
in unsigned short toggle,
in unsigned short reverse,
in unsigned short powerDenial);
/**
* Notify CLIR from received Cdma-Info-Record.
* See 'ANNEX 1 Country-Specific Record Type for Japan' in T53.
* http://www.arib.or.jp/english/html/overview/doc/T53v6_5_pdf/5_ANNEX_v6_5.pdf
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param cause
* Reason code. (8-bit binary)
* See Table A 1.1-1 in T53.
*/
void notifyCdmaInfoRecClir(in unsigned long clientId,
in unsigned short cause);
/**
* Notify Audio Control from received Cdma-Info-Record.
*
* Note: No information from ARIB about Audio Control.
* It seems obsolete according to ANNEX 1 in T53.
* upLink/downLink are 'byte' value according to ril.h.
* Treat them as 'signed short' to preserve the flexibility when needed.
*
* @param clientId
* The ID of radioInterface where this info is notified from.
* @param upLink
* @param downLink
*/
void notifyCdmaInfoRecAudioControl(in unsigned long clientId,
in short upLink,
in short downLink);
};

Просмотреть файл

@ -396,13 +396,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function() {
}
},
sendMobileConnectionMessage: function(message, clientId, data) {
this._sendTargetMessage("mobileconnection", message, {
clientId: clientId,
data: data
});
},
sendIccMessage: function(message, clientId, data) {
this._sendTargetMessage("icc", message, {
clientId: clientId,
@ -2091,10 +2084,7 @@ RadioInterface.prototype = {
gMessageManager.sendIccMessage("RIL:StkSessionEnd", this.clientId, null);
break;
case "cdma-info-rec-received":
if (DEBUG) this.debug("cdma-info-rec-received: " + JSON.stringify(message));
message.records.forEach(function(aRecord) {
gSystemMessenger.broadcastMessage("cdma-info-rec-received", aRecord);
});
this.handleCdmaInformationRecords(message.records);
break;
default:
throw new Error("Don't know about this message type: " +
@ -2922,6 +2912,99 @@ RadioInterface.prototype = {
hasEtwsInfo ? etwsInfo.popup : false);
},
handleCdmaInformationRecords: function(aRecords) {
if (DEBUG) this.debug("cdma-info-rec-received: " + JSON.stringify(aRecords));
let clientId = this.clientId;
aRecords.forEach(function(aRecord) {
if (aRecord.display) {
gMobileConnectionService
.notifyCdmaInfoRecDisplay(clientId, aRecord.display);
return;
}
if (aRecord.calledNumber) {
gMobileConnectionService
.notifyCdmaInfoRecCalledPartyNumber(clientId,
aRecord.calledNumber.type,
aRecord.calledNumber.plan,
aRecord.calledNumber.number,
aRecord.calledNumber.pi,
aRecord.calledNumber.si);
return;
}
if (aRecord.callingNumber) {
gMobileConnectionService
.notifyCdmaInfoRecCallingPartyNumber(clientId,
aRecord.callingNumber.type,
aRecord.callingNumber.plan,
aRecord.callingNumber.number,
aRecord.callingNumber.pi,
aRecord.callingNumber.si);
return;
}
if (aRecord.connectedNumber) {
gMobileConnectionService
.notifyCdmaInfoRecConnectedPartyNumber(clientId,
aRecord.connectedNumber.type,
aRecord.connectedNumber.plan,
aRecord.connectedNumber.number,
aRecord.connectedNumber.pi,
aRecord.connectedNumber.si);
return;
}
if (aRecord.signal) {
gMobileConnectionService
.notifyCdmaInfoRecSignal(clientId,
aRecord.signal.type,
aRecord.signal.alertPitch,
aRecord.signal.signal);
return;
}
if (aRecord.redirect) {
gMobileConnectionService
.notifyCdmaInfoRecRedirectingNumber(clientId,
aRecord.redirect.type,
aRecord.redirect.plan,
aRecord.redirect.number,
aRecord.redirect.pi,
aRecord.redirect.si,
aRecord.redirect.reason);
return;
}
if (aRecord.lineControl) {
gMobileConnectionService
.notifyCdmaInfoRecLineControl(clientId,
aRecord.lineControl.polarityIncluded,
aRecord.lineControl.toggle,
aRecord.lineControl.reverse,
aRecord.lineControl.powerDenial);
return;
}
if (aRecord.clirCause) {
gMobileConnectionService
.notifyCdmaInfoRecClir(clientId,
aRecord.clirCause);
return;
}
if (aRecord.audioControl) {
gMobileConnectionService
.notifyCdmaInfoRecAudioControl(clientId,
aRecord.audioControl.upLink,
aRecord.audioControl.downLink);
return;
}
});
},
// nsIObserver
observe: function(subject, topic, data) {

Просмотреть файл

@ -10052,11 +10052,11 @@ CdmaPDUHelperObject.prototype = {
record.lineControl = {};
record.lineControl.polarityIncluded = Buf.readInt32();
record.lineControl.toggle = Buf.readInt32();
record.lineControl.recerse = Buf.readInt32();
record.lineControl.reverse = Buf.readInt32();
record.lineControl.powerDenial = Buf.readInt32();
break;
case PDU_CDMA_INFO_REC_TYPE_T53_CLIR:
record.cause = Buf.readInt32();
record.clirCause = Buf.readInt32();
break;
case PDU_CDMA_INFO_REC_TYPE_T53_AUDIO_CONTROL:
record.audioControl = {};

Просмотреть файл

@ -173,3 +173,62 @@ add_test(function test_signal_not_present() {
run_next_test();
});
/**
* Verify decoder for Line Control
*/
add_test(function test_line_control() {
let worker = newWorkerWithParcel([
0x01, // one inforemation record
0x06, // type: line control
0x01, // polarity included
0x00, // not toggled
0x01, // reversed
0xFF]); // Power denial timeout: 255 * 5 ms
let context = worker.ContextPool._contexts[0];
let helper = context.CdmaPDUHelper;
let records = helper.decodeInformationRecord();
do_check_eq(records[0].lineControl.polarityIncluded, 1);
do_check_eq(records[0].lineControl.toggle, 0);
do_check_eq(records[0].lineControl.reverse, 1);
do_check_eq(records[0].lineControl.powerDenial, 255);
run_next_test();
});
/**
* Verify decoder for CLIR Cause
*/
add_test(function test_clir() {
let worker = newWorkerWithParcel([
0x01, // one inforemation record
0x08, // type: clir
0x01]); // cause: Rejected by user
let context = worker.ContextPool._contexts[0];
let helper = context.CdmaPDUHelper;
let records = helper.decodeInformationRecord();
do_check_eq(records[0].clirCause, 1);
run_next_test();
});
/**
* Verify decoder for Audio Control
*/
add_test(function test_clir() {
let worker = newWorkerWithParcel([
0x01, // one inforemation record
0x0A, // type: audio control
0x01, // uplink
0xFF]); // downlink
let context = worker.ContextPool._contexts[0];
let helper = context.CdmaPDUHelper;
let records = helper.decodeInformationRecord();
do_check_eq(records[0].audioControl.upLink, 1);
do_check_eq(records[0].audioControl.downLink, 255);
run_next_test();
});