Bug 793137 - Part 2: Support PLAY_TONE, POLL_INTERVAL and REFRESH in RIL. r=philikon

This commit is contained in:
Yoshi Huang 2012-09-21 15:01:58 +08:00
parent 2f33d83f0a
commit eeb4b1d5f2
2 changed files with 191 additions and 1 deletions

View File

@ -537,9 +537,11 @@ const COMPREHENSIONTLV_TAG_ALPHA_ID = 0x05;
const COMPREHENSIONTLV_TAG_ADDRESS = 0x06;
const COMPREHENSIONTLV_TAG_SMS_TPDU = 0x0b;
const COMPREHENSIONTLV_TAG_TEXT_STRING = 0x0d;
const COMPREHENSIONTLV_TAG_TONE = 0x0e;
const COMPREHENSIONTLV_TAG_ITEM = 0x0f;
const COMPREHENSIONTLV_TAG_ITEM_ID = 0x10;
const COMPREHENSIONTLV_TAG_RESPONSE_LENGTH = 0x11;
const COMPREHENSIONTLV_TAG_FILE_LIST = 0x12;
const COMPREHENSIONTLV_TAG_LOCATION_INFO = 0x13;
const COMPREHENSIONTLV_TAG_HELP_REQUEST = 0x15;
const COMPREHENSIONTLV_TAG_DEFAULT_TEXT = 0x17;
@ -560,6 +562,8 @@ const STK_DEVICE_ID_NETWORK = 0x83;
// STK Proactive commands.
const STK_CMD_REFRESH = 0x01;
const STK_CMD_POLL_INTERVAL = 0x03;
const STK_CMD_POLL_OFF = 0x04;
const STK_CMD_SET_UP_EVENT_LIST = 0x05;
const STK_CMD_SET_UP_CALL = 0x10;
const STK_CMD_SEND_SS = 0x11;
@ -567,6 +571,7 @@ const STK_CMD_SEND_USSD = 0x12;
const STK_CMD_SEND_SMS = 0x13;
const STK_CMD_SEND_DTMF = 0x14;
const STK_CMD_LAUNCH_BROWSER = 0x15;
const STK_CMD_PLAY_TONE = 0x20;
const STK_CMD_DISPLAY_TEXT = 0x21;
const STK_CMD_GET_INKEY = 0x22;
const STK_CMD_GET_INPUT = 0x23;
@ -732,6 +737,31 @@ const STK_SERVICE_STATE_NORMAL = 0x00;
const STK_SERVICE_STATE_LIMITED = 0x01;
const STK_SERVICE_STATE_UNAVAILABLE = 0x02;
// Refresh mode.
const STK_REFRESH_NAA_INIT_AND_FULL_FILE_CHANGE = 0x00;
const STK_REFRESH_FILE_CHANGE = 0x01;
const STK_REFRESH_NAA_INIT_AND_FILE_CHANGE = 0x02;
const STK_REFRESH_NAA_INIT = 0x03;
const STK_REFRESH_UICC_RESET = 0x04;
// Tone type.
const STK_TONE_TYPE_DIAL_TONE = 0x01;
const STK_TONE_TYPE_CALLED_SUBSCRIBER_BUSY = 0x02;
const STK_TONE_TYPE_CONGESTION = 0x03;
const STK_TONE_TYPE_RADIO_PATH_ACK = 0x04;
const STK_TONE_TYPE_RADIO_PATH_NOT_AVAILABLE = 0x05;
const STK_TONE_TYPE_ERROR = 0x06;
const STK_TONE_TYPE_CALL_WAITING_TONE = 0x07;
const STK_TONE_TYPE_RINGING_TONE = 0x08;
const STK_TONE_TYPE_GENERAL_BEEP = 0x10;
const STK_TONE_TYPE_POSITIVE_ACK_TONE = 0x11;
const STK_TONE_TYPE_NEGATIVE_ACK_TONE = 0x12;
// Time unit.
const STK_TIME_UNIT_MINUTE = 0x00;
const STK_TIME_UNIT_SECOND = 0x01;
const STK_TIME_UNIT_TENTH_SECOND = 0x02;
/**
* (U)SIM Services.
*

View File

@ -6074,6 +6074,15 @@ let StkCommandParamsFactory = {
createParam: function createParam(cmdDetails, ctlvs) {
let param;
switch (cmdDetails.typeOfCommand) {
case STK_CMD_REFRESH:
param = this.processRefresh(cmdDetails, ctlvs);
break;
case STK_CMD_POLL_INTERVAL:
param = this.processPollInterval(cmdDetails, ctlvs);
break;
case STK_CMD_POLL_OFF:
param = this.processPollOff(cmdDetails, ctlvs);
break;
case STK_CMD_SET_UP_EVENT_LIST:
param = this.processSetUpEventList(cmdDetails, ctlvs);
break;
@ -6102,9 +6111,12 @@ let StkCommandParamsFactory = {
case STK_CMD_SET_UP_CALL:
param = this.processSetupCall(cmdDetails, ctlvs);
break;
case STK_LAUNCH_BROWSER:
case STK_CMD_LAUNCH_BROWSER:
param = this.processLaunchBrowser(cmdDetails, ctlvs);
break;
case STK_CMD_PLAY_TONE:
param = this.processPlayTone(cmdDetails, ctlvs);
break;
default:
debug("unknown proactive command");
break;
@ -6112,6 +6124,66 @@ let StkCommandParamsFactory = {
return param;
},
/**
* Construct a param for Refresh.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
*/
processRefresh: function processRefresh(cmdDetails, ctlvs) {
let refreshType = cmdDetails.commandQualifier;
switch (refreshType) {
case STK_REFRESH_FILE_CHANGE:
case STK_REFRESH_NAA_INIT_AND_FILE_CHANGE:
let ctlv = StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_FILE_LIST, ctlvs);
if (ctlv) {
let list = ctlv.value.fileList;
if (DEBUG) {
debug("Refresh, list = " + list);
}
RIL.fetchICCRecords();
}
break;
}
return {};
},
/**
* Construct a param for Poll Interval.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
*/
processPollInterval: function processPollInterval(cmdDetails, ctlvs) {
let ctlv = StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_TAG_DURATION, ctlvs);
if (!ctlv) {
RIL.sendStkTerminalResponse({
command: cmdDetails,
resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
throw new Error("Stk Poll Interval: Required value missing : Duration");
}
return ctlv.value;
},
/**
* Construct a param for Poll Off.
*
* @param cmdDetails
* The value object of CommandDetails TLV.
* @param ctlvs
* The all TLVs in this proactive command.
*/
processPollOff: function processPollOff(cmdDetails, ctlvs) {
return {};
},
/**
* Construct a param for Set Up Event list.
*
@ -6377,6 +6449,32 @@ let StkCommandParamsFactory = {
browser.mode = cmdDetails.commandQualifier & 0x03;
return browser;
},
processPlayTone: function processPlayTone(cmdDetails, ctlvs) {
let playTone = {};
let ctlv = StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs);
if (ctlv) {
playTone.text = ctlv.value.identifier;
}
ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_TONE, ctlvs);
if (ctlv) {
playTone.tone = ctlv.value.tone;
}
ctlv = StkProactiveCmdHelper.searchForTag(
COMPREHENSIONTLV_TAG_DURATION, ctlvs);
if (ctlv) {
playTone.duration = ctlv.value;
}
// vibrate is only defined in TS 102.223
playTone.isVibrate = (cmdDetails.commandQualifier & 0x01) != 0x00;
return playTone;
}
};
@ -6389,16 +6487,22 @@ let StkProactiveCmdHelper = {
return this.retrieveDeviceId(length);
case COMPREHENSIONTLV_TAG_ALPHA_ID:
return this.retrieveAlphaId(length);
case COMPREHENSIONTLV_TAG_DURATION:
return this.retrieveDuration(length);
case COMPREHENSIONTLV_TAG_ADDRESS:
return this.retrieveAddress(length);
case COMPREHENSIONTLV_TAG_TEXT_STRING:
return this.retrieveTextString(length);
case COMPREHENSIONTLV_TAG_TONE:
return this.retrieveTone(length);
case COMPREHENSIONTLV_TAG_ITEM:
return this.retrieveItem(length);
case COMPREHENSIONTLV_TAG_ITEM_ID:
return this.retrieveItemId(length);
case COMPREHENSIONTLV_TAG_RESPONSE_LENGTH:
return this.retrieveResponseLength(length);
case COMPREHENSIONTLV_TAG_FILE_LIST:
return this.retrieveFileList(length);
case COMPREHENSIONTLV_TAG_DEFAULT_TEXT:
return this.retrieveDefaultText(length);
case COMPREHENSIONTLV_TAG_EVENT_LIST:
@ -6466,6 +6570,23 @@ let StkProactiveCmdHelper = {
return alphaId;
},
/**
* Duration.
*
* | Byte | Description | Length |
* | 1 | Response Length Tag | 1 |
* | 2 | Lenth = 02 | 1 |
* | 3 | Time unit | 1 |
* | 4 | Time interval | 1 |
*/
retrieveDuration: function retrieveDuration(length) {
let duration = {
timeUnit: GsmPDUHelper.readHexOctet(),
timeInterval: GsmPDUHelper.readHexOctet(),
};
return duration;
},
/**
* Address.
*
@ -6518,6 +6639,21 @@ let StkProactiveCmdHelper = {
return text;
},
/**
* Tone.
*
* | Byte | Description | Length |
* | 1 | Tone Tag | 1 |
* | 2 | Lenth = 01 | 1 |
* | 3 | Tone | 1 |
*/
retrieveTone: function retrieveTone(length) {
let tone = {
tone: GsmPDUHelper.readHexOctet(),
};
return tone;
},
/**
* Item.
*
@ -6568,6 +6704,30 @@ let StkProactiveCmdHelper = {
return rspLength;
},
/**
* File List.
*
* | Byte | Description | Length |
* | 1 | File List Tag | 1 |
* | 2 ~ (Y-1)+2 | Length (X) | Y |
* | (Y-1)+3 | Number of files | 1 |
* | (Y-1)+4 ~ | Files | X |
* | (Y-1)+X+2 | | |
*/
retrieveFileList: function retrieveFileList(length) {
let num = GsmPDUHelper.readHexOctet();
let fileList = "";
length--; // -1 for the num octet.
for (let i = 0; i < 2 * length; i++) {
// Didn't use readHexOctet here,
// otherwise 0x00 will be "0", not "00"
fileList += String.fromCharCode(Buf.readUint16());
}
return {
fileList: fileList
};
},
/**
* Default Text.
*