Bug 1123624 - Part 1-2: Throwing exception if the mandatory field isn't showed in proactive command and refactoring handler of SelectItem and SetupMenu. r=bevis

This commit is contained in:
Edgar Chen 2015-02-04 16:34:59 +08:00
Родитель 9c1b19b249
Коммит 3dd989f682
1 изменённых файлов: 178 добавлений и 16 удалений

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

@ -10692,6 +10692,8 @@ StkCommandParamsFactoryObject.prototype = {
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processRefresh: function(cmdDetails, ctlvs, onComplete) {
let refreshType = cmdDetails.commandQualifier;
@ -10720,8 +10722,11 @@ StkCommandParamsFactoryObject.prototype = {
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processPollInterval: function(cmdDetails, ctlvs, onComplete) {
// Duration is mandatory.
let ctlv = this.context.StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_TAG_DURATION, ctlvs);
if (!ctlv) {
@ -10741,6 +10746,8 @@ StkCommandParamsFactoryObject.prototype = {
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processPollOff: function(cmdDetails, ctlvs, onComplete) {
onComplete(null);
@ -10753,8 +10760,11 @@ StkCommandParamsFactoryObject.prototype = {
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processSetUpEventList: function(cmdDetails, ctlvs, onComplete) {
// Event list is mandatory.
let ctlv = this.context.StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_TAG_EVENT_LIST, ctlvs);
if (!ctlv) {
@ -10768,14 +10778,16 @@ StkCommandParamsFactoryObject.prototype = {
},
/**
* Construct a param for Select Item.
* Construct a param for Setup Menu.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processSelectItem: function(cmdDetails, ctlvs, onComplete) {
processSetupMenu: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let menu = {
// Help information available.
@ -10791,11 +10803,13 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID_LIST
]);
// Alpha identifier is optional.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
menu.title = ctlv.value.identifier;
}
// Item data object for item 1 is mandatory.
let menuCtlvs = selectedCtlvs[COMPREHENSIONTLV_TAG_ITEM];
if (!menuCtlvs) {
this.context.RIL.sendStkTerminalResponse({
@ -10805,27 +10819,26 @@ StkCommandParamsFactoryObject.prototype = {
}
menu.items = menuCtlvs.map(aCtlv => aCtlv.value);
// Item identifier is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ITEM_ID);
if (ctlv) {
menu.defaultItem = ctlv.value.identifier - 1;
}
if (cmdDetails.typeOfCommand == STK_CMD_SELECT_ITEM) {
// The 1st bit and 2nd bit determines the presentation type.
menu.presentationType = cmdDetails.commandQualifier & 0x03;
}
// Items next action indicator is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_NEXT_ACTION_IND);
if (ctlv) {
menu.nextActionList = ctlv.value;
}
// Icon identifier is optional.
let iconIdCtlvs = null;
let menuIconCtlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ICON_ID);
if (menuIconCtlv) {
iconIdCtlvs = [menuIconCtlv];
}
// Item icon identifier list is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ICON_ID_LIST);
if (ctlv) {
if (!iconIdCtlvs) {
@ -10858,6 +10871,34 @@ StkCommandParamsFactoryObject.prototype = {
});
},
/**
* Construct a param for Select Item.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processSelectItem: function(cmdDetails, ctlvs, onComplete) {
this.processSetupMenu(cmdDetails, ctlvs, (menu) => {
// The 1st bit and 2nd bit determines the presentation type.
menu.presentationType = cmdDetails.commandQualifier & 0x03;
onComplete(menu);
});
},
/**
* Construct a param for Display Text.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processDisplayText: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let textMsg = {
@ -10872,6 +10913,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Text string is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TEXT_STRING);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -10881,19 +10923,32 @@ StkCommandParamsFactoryObject.prototype = {
}
textMsg.text = ctlv.value.textString;
// Immediate response is optional.
textMsg.responseNeeded =
!!(selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_IMMEDIATE_RESPONSE));
// Duration is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_DURATION);
if (ctlv) {
textMsg.duration = ctlv.value;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
textMsg,
onComplete);
},
/**
* Construct a param for Setup Idle Mode Text.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processSetUpIdleModeText: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let textMsg = {};
@ -10903,6 +10958,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Text string is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TEXT_STRING);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -10912,11 +10968,22 @@ StkCommandParamsFactoryObject.prototype = {
}
textMsg.text = ctlv.value.textString;
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
textMsg,
onComplete);
},
/**
* Construct a param for Get Inkey.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processGetInkey: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let input = {
@ -10937,6 +11004,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Text string is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TEXT_STRING);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -10946,17 +11014,28 @@ StkCommandParamsFactoryObject.prototype = {
}
input.text = ctlv.value.textString;
// duration
// Duration is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_DURATION);
if (ctlv) {
input.duration = ctlv.value;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
input,
onComplete);
},
/**
* Construct a param for Get Input.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processGetInput: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let input = {
@ -10977,6 +11056,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Text string is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TEXT_STRING);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -10986,22 +11066,39 @@ StkCommandParamsFactoryObject.prototype = {
}
input.text = ctlv.value.textString;
// Response length is mandatory.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_RESPONSE_LENGTH);
if (ctlv) {
input.minLength = ctlv.value.minLength;
input.maxLength = ctlv.value.maxLength;
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
command: cmdDetails,
resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
throw new Error("Stk Get Input: Required value missing : Response Length");
}
input.minLength = ctlv.value.minLength;
input.maxLength = ctlv.value.maxLength;
// Default text is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_DEFAULT_TEXT);
if (ctlv) {
input.defaultText = ctlv.value.textString;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
input,
onComplete);
},
/**
* Construct a param for SendSS/SMS/USSD/DTMF.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processEventNotify: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let textMsg = {};
@ -11011,16 +11108,28 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Alpha identifier is optional.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
textMsg.text = ctlv.value.identifier;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
textMsg,
onComplete);
},
/**
* Construct a param for Setup Call.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processSetupCall: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let call = {};
@ -11034,6 +11143,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_DURATION
]);
// Address is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ADDRESS);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -11043,24 +11153,27 @@ StkCommandParamsFactoryObject.prototype = {
}
call.address = ctlv.value.number;
// Alpha identifier (user confirmation phase) is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
confirmMessage.text = ctlv.value.identifier;
call.confirmMessage = confirmMessage;
}
// Alpha identifier (call set up phase) is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
callMessage.text = ctlv.value.identifier;
call.callMessage = callMessage;
}
// see 3GPP TS 31.111 section 6.4.13
// Duration is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_DURATION);
if (ctlv) {
call.duration = ctlv.value;
}
// Icon identifier is optional.
let iconIdCtlvs = selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null;
this.loadIcons(iconIdCtlvs, (aIcons) => {
if (aIcons) {
@ -11081,6 +11194,16 @@ StkCommandParamsFactoryObject.prototype = {
});
},
/**
* Construct a param for Launch Browser.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processLaunchBrowser: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let browser = {
@ -11094,6 +11217,7 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// URL is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_URL);
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
@ -11103,12 +11227,14 @@ StkCommandParamsFactoryObject.prototype = {
}
browser.url = ctlv.value.url;
// Alpha identifier is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
confirmMessage.text = ctlv.value.identifier;
browser.confirmMessage = confirmMessage;
}
// Icon identifier is optional.
let iconIdCtlvs = selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null;
this.loadIcons(iconIdCtlvs, (aIcons) => {
if (aIcons) {
@ -11122,6 +11248,16 @@ StkCommandParamsFactoryObject.prototype = {
});
},
/**
* Construct a param for Play Tone.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processPlayTone: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let playTone = {
@ -11136,33 +11272,39 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Alpha identifier is optional.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
playTone.text = ctlv.value.identifier;
}
// Tone is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TONE);
if (ctlv) {
playTone.tone = ctlv.value.tone;
}
// Duration is optional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_DURATION);
if (ctlv) {
playTone.duration = ctlv.value;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
playTone,
onComplete);
},
/**
* Construct a param for Provide Local Information
* Construct a param for Provide Local Information.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processProvideLocalInfo: function(cmdDetails, ctlvs, onComplete) {
let provideLocalInfo = {
@ -11172,6 +11314,16 @@ StkCommandParamsFactoryObject.prototype = {
onComplete(provideLocalInfo);
},
/**
* Construct a param for Timer Management.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processTimerManagement: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
let timer = {
@ -11183,11 +11335,17 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_TIMER_VALUE
]);
// Timer identifier is mandatory.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TIMER_IDENTIFIER);
if (ctlv) {
timer.timerId = ctlv.value.timerId;
if (!ctlv) {
this.context.RIL.sendStkTerminalResponse({
command: cmdDetails,
resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
throw new Error("Stk Timer Management: Required value missing : Timer Identifier");
}
timer.timerId = ctlv.value.timerId;
// Timer value is conditional.
ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_TIMER_VALUE);
if (ctlv) {
timer.timerValue = ctlv.value.timerValue;
@ -11203,6 +11361,8 @@ StkCommandParamsFactoryObject.prototype = {
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
* @param onComplete
* Callback to be called when complete.
*/
processBipMessage: function(cmdDetails, ctlvs, onComplete) {
let StkProactiveCmdHelper = this.context.StkProactiveCmdHelper;
@ -11213,11 +11373,13 @@ StkCommandParamsFactoryObject.prototype = {
COMPREHENSIONTLV_TAG_ICON_ID
]);
// Alpha identifier is optional.
let ctlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
if (ctlv) {
bipMsg.text = ctlv.value.identifier;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
bipMsg,
onComplete);
@ -11239,7 +11401,7 @@ StkCommandParamsFactoryObject.prototype[STK_CMD_SET_UP_EVENT_LIST] = function ST
return this.processSetUpEventList(cmdDetails, ctlvs, onComplete);
};
StkCommandParamsFactoryObject.prototype[STK_CMD_SET_UP_MENU] = function STK_CMD_SET_UP_MENU(cmdDetails, ctlvs, onComplete) {
return this.processSelectItem(cmdDetails, ctlvs, onComplete);
return this.processSetupMenu(cmdDetails, ctlvs, onComplete);
};
StkCommandParamsFactoryObject.prototype[STK_CMD_SELECT_ITEM] = function STK_CMD_SELECT_ITEM(cmdDetails, ctlvs, onComplete) {
return this.processSelectItem(cmdDetails, ctlvs, onComplete);