Bug 744714 - Part 3: RIL implementation. r=philikon

This commit is contained in:
Yoshi Huang 2012-04-10 20:04:27 +08:00
parent 633b06fe42
commit eda0230151
7 changed files with 1266 additions and 6 deletions

View File

@ -6,6 +6,8 @@
#include "IccManager.h"
#include "SimToolKit.h"
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
DOMCI_DATA(MozIccManager, mozilla::dom::icc::IccManager)
namespace mozilla {
@ -24,6 +26,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IccManager,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(stkcommand)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(stksessionend)
tmp->mProvider = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IccManager)
@ -37,6 +40,13 @@ NS_IMPL_RELEASE_INHERITED(IccManager, nsDOMEventTargetHelper)
IccManager::IccManager()
{
mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
// Not being able to acquire the provider isn't fatal since we check
// for it explicitly below.
if (!mProvider) {
NS_WARNING("Could not acquire nsIMobileConnectionProvider!");
}
}
void
@ -65,13 +75,23 @@ IccManager::Observe(nsISupports* aSubject,
NS_IMETHODIMP
IccManager::SendStkResponse(const JS::Value& aResponse)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (!mProvider) {
return NS_ERROR_FAILURE;
}
mProvider->SendStkResponse(GetOwner(), aResponse);
return NS_OK;
}
NS_IMETHODIMP
IccManager::SendStkMenuSelection(PRUint16 aItemIdentifier, bool aHelpRequested)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (!mProvider) {
return NS_ERROR_FAILURE;
}
mProvider->SendStkMenuSelection(GetOwner(), aItemIdentifier, aHelpRequested);
return NS_OK;
}
NS_IMPL_EVENT_HANDLER(IccManager, stkcommand)

View File

@ -8,6 +8,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMIccManager.h"
#include "nsIMobileConnectionProvider.h"
#include "nsIObserver.h"
namespace mozilla {
@ -34,6 +35,8 @@ public:
nsDOMEventTargetHelper)
private:
nsCOMPtr<nsIMobileConnectionProvider> mProvider;
NS_DECL_EVENT_HANDLER(stkcommand)
NS_DECL_EVENT_HANDLER(stksessionend)
};

View File

@ -28,6 +28,13 @@ interface nsIMobileConnectionProvider : nsISupports
nsIDOMDOMRequest getCardLock(in nsIDOMWindow window, in DOMString lockType);
nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info);
nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info);
nsIDOMDOMRequest sendUSSD(in nsIDOMWindow window, in DOMString ussd);
nsIDOMDOMRequest cancelUSSD(in nsIDOMWindow window);
void sendStkResponse(in nsIDOMWindow window,
in jsval response);
void sendStkMenuSelection(in nsIDOMWindow window,
in unsigned short itemIdentifier,
in boolean helpRequested);
};

View File

@ -56,13 +56,17 @@ const RIL_IPC_MSG_NAMES = [
"RIL:SendUssd:Return:OK",
"RIL:SendUssd:Return:KO",
"RIL:CancelUssd:Return:OK",
"RIL:CancelUssd:Return:KO"
"RIL:CancelUssd:Return:KO",
"RIL:StkCommand",
"RIL:StkSessionEnd"
];
const kVoiceChangedTopic = "mobile-connection-voice-changed";
const kDataChangedTopic = "mobile-connection-data-changed";
const kCardStateChangedTopic = "mobile-connection-cardstate-changed";
const kUssdReceivedTopic = "mobile-connection-ussd-received";
const kStkCommandTopic = "icc-manager-stk-command";
const kStkSessionEndTopic = "icc-manager-stk-session-end";
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
@ -377,6 +381,25 @@ RILContentHelper.prototype = {
return request;
},
sendStkResponse: function sendStkResponse(window, response) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
cpmm.sendAsyncMessage("RIL:SendStkResponse", response);
},
sendStkMenuSelection: function sendStkMenuSelection(window,
itemIdentifier,
helpRequested) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
cpmm.sendAsyncMessage("RIL:SendStkMenuSelection", {itemIdentifier: itemIdentifier,
helpRequested: helpRequested});
},
_telephonyCallbacks: null,
_voicemailCallbacks: null,
_enumerateTelephonyCallbacks: null,
@ -629,6 +652,13 @@ RILContentHelper.prototype = {
Services.DOMRequest.fireError(request, msg.json.errorMsg);
}
break;
case "RIL:StkCommand":
let jsonString = JSON.stringify(msg.json);
Services.obs.notifyObservers(null, kStkCommandTopic, jsonString);
break;
case "RIL:StkSessionEnd":
Services.obs.notifyObservers(null, kStkSessionEndTopic, null);
break;
}
},

View File

@ -62,7 +62,9 @@ const RIL_IPC_MSG_NAMES = [
"RIL:UnlockCardLock",
"RIL:SetCardLock",
"RIL:SendUSSD",
"RIL:CancelUSSD"
"RIL:CancelUSSD",
"RIL:SendStkResponse",
"RIL:SendStkMenuSelection"
];
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
@ -303,6 +305,12 @@ RadioInterfaceLayer.prototype = {
this.saveRequestTarget(msg);
this.cancelUSSD(msg.json);
break;
case "RIL:SendStkResponse":
this.sendStkResponse(msg.json);
break;
case "RIL:SendStkMenuSelection":
this.sendStkMenuSelection(msg.json);
break;
}
},
@ -440,6 +448,12 @@ RadioInterfaceLayer.prototype = {
case "cancelussd":
this.handleCancelUSSD(message);
break;
case "stkcommand":
this.handleStkProactiveCommand(message);
break;
case "stksessionend":
ppmm.broadcastAsyncMessage("RIL:StkSessionEnd", null);
break;
default:
throw new Error("Don't know about this message type: " +
message.rilMessageType);
@ -1012,6 +1026,11 @@ RadioInterfaceLayer.prototype = {
this._sendRequestResults(messageType, message);
},
handleStkProactiveCommand: function handleStkProactiveCommand(message) {
debug("handleStkProactiveCommand " + JSON.stringify(message));
ppmm.broadcastAsyncMessage("RIL:StkCommand", message);
},
// nsIObserver
observe: function observe(subject, topic, data) {
@ -1182,6 +1201,15 @@ RadioInterfaceLayer.prototype = {
this.worker.postMessage(message);
},
sendStkResponse: function sendStkResponse(message) {
message.rilMessageType = "sendStkTerminalResponse";
this.worker.postMessage(message);
},
sendStkMenuSelection: function sendStkMenuSelection(message) {
message.rilMessageType = "sendStkMenuSelection";
this.worker.postMessage(message);
},
get microphoneMuted() {
return gAudioManager.microphoneMuted;

View File

@ -510,6 +510,194 @@ const ICC_USIM_EFUID_TAG = 0xc9;
const ICC_USIM_EFEMAIL_TAG = 0xca;
const ICC_USIM_EFCCP1_TAG = 0xcb;
/**
* STK constants.
*/
// Tags for Ber Tlv.
const BER_UNKNOWN_TAG = 0x00;
const BER_PROACTIVE_COMMAND_TAG = 0xd0;
const BER_MENU_SELECTION_TAG = 0xd3;
const BER_EVENT_DOWNLOAD_TAG = 0xd6;
// Flags in Comprehension TLV.
const COMPREHENSIONTLV_FLAG_CR = 0x80; // Comprehension required.
// Tags for Comprehension TLV.
const COMPREHENSIONTLV_TAG_COMMAND_DETAILS = 0x01;
const COMPREHENSIONTLV_TAG_DEVICE_ID = 0x02;
const COMPREHENSIONTLV_TAG_RESULT = 0x03;
const COMPREHENSIONTLV_TAG_DURATION = 0x04;
const COMPREHENSIONTLV_TAG_ALPHA_ID = 0x05;
const COMPREHENSIONTLV_TAG_ADDRESS = 0x06;
const COMPREHENSIONTLV_TAG_TEXT_STRING = 0x0d;
const COMPREHENSIONTLV_TAG_ITEM = 0x0f;
const COMPREHENSIONTLV_TAG_ITEM_ID = 0x10;
const COMPREHENSIONTLV_TAG_RESPONSE_LENGTH = 0x11;
const COMPREHENSIONTLV_TAG_HELP_REQUEST = 0x15;
const COMPREHENSIONTLV_TAG_DEFAULT_TEXT = 0x17;
const COMPREHENSIONTLV_TAG_ICON_ID = 0x1e;
const COMPREHENSIONTLV_TAG_ICON_ID_LIST = 0x1f;
const COMPREHENSIONTLV_TAG_IMMEDIATE_RESPONSE = 0x2b;
const COMPREHENSIONTLV_TAG_URL = 0x31;
// Device identifiers, see TS 11.14, clause 12.7
const STK_DEVICE_ID_KEYPAD = 0x01;
const STK_DEVICE_ID_DISPLAY = 0x02;
const STK_DEVICE_ID_EARPIECE = 0x03;
const STK_DEVICE_ID_SIM = 0x81;
const STK_DEVICE_ID_ME = 0x82;
const STK_DEVICE_ID_NETWORK = 0x83;
// STK Proactive commands.
const STK_CMD_REFRESH = 0x01;
const STK_CMD_SET_UP_CALL = 0x10;
const STK_CMD_SEND_SS = 0x11;
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_DISPLAY_TEXT = 0x21;
const STK_CMD_GET_INKEY = 0x22;
const STK_CMD_GET_INPUT = 0x23;
const STK_CMD_SELECT_ITEM = 0x24;
const STK_CMD_SET_UP_MENU = 0x25;
const STK_CMD_SET_UP_IDLE_MODE_TEXT = 0x28;
// STK Result code.
// TS 11.14, clause 12.12
// Results '0X' and '1X' indicate that the command has been performed.
// Command performed successfully.
const STK_RESULT_OK = 0x00;
// Command performed with partial comprehension.
const STK_RESULT_PRFRMD_WITH_PARTIAL_COMPREHENSION = 0x01;
// Command performed, with missing information.
const STK_RESULT_PRFRMD_WITH_MISSING_INFO = 0x02;
// REFRESH performed with additional EFs read.
const STK_RESULT_PRFRMD_WITH_ADDITIONAL_EFS_READ = 0x03;
// Command performed successfully, but requested icon could not be
// displayed.
const STK_RESULT_PRFRMD_ICON_NOT_DISPLAYED = 0x04;
// Command performed, but modified by call control by NAA.
const STK_RESULT_PRFRMD_MODIFIED_BY_NAA = 0x05;
// Command performed successfully, limited service.
const STK_RESULT_PRFRMD_LIMITED_SERVICE = 0x06;
// Command performed with modification.
const STK_RESULT_PRFRMD_WITH_MODIFICATION = 0x07;
// REFRESH performed but indicated NAA was not active.
const STK_RESULT_PRFRMD_NAA_NOT_ACTIVE = 0x08;
// Command performed successfully; tone not played.
const STK_RESULT_PRFRMD_TONE_NOT_PLAYED = 0x09;
// Proactive UICC session terminated by the user.
const STK_RESULT_UICC_SESSION_TERM_BY_USER = 0x10;
// Backward move in the proactive UICC session requested by the user.
const STK_RESULT_BACKWARD_MOVE_BY_USER = 0x11;
// No response from user.
const STK_RESULT_NO_RESPONSE_FROM_USER = 0x12;
// Help information required by the user.
const STK_RESULT_HELP_INFO_REQUIRED = 0x13;
// USSD or SS transaction terminated by the user.
const STK_RESULT_USSD_SS_SESSION_TERM_BY_USER = 0x14;
// Results '2X' indicate to the UICC that it may be worth re-trying the
// command at a later opportunity.
// Terminal currently unable to process command.
const STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS = 0x20;
// Network currently unable to process command.
const STK_RESULT_NETWORK_CRNTLY_UNABLE_TO_PROCESS = 0x21;
// User did not accept the proactive command.
const STK_RESULT_USER_NOT_ACCEPT = 0x22;
// User cleared down call before connection or network release.
const STK_RESULT_USER_CLEAR_DOWN_CALL = 0x23;
// Action in contradiction with the current timer state.
const STK_RESULT_CONTRADICTION_WITH_TIMER = 0x24;
// Interaction with call control by NAA; temporary problem.
const STK_RESULT_NAA_CALL_CONTROL_TEMPORARY = 0x25;
// Launch browser generic error code.
const STK_RESULT_LAUNCH_BROWSER_ERROR = 0x26;
// MMS temporary problem.
const STK_RESULT_MMS_TEMPORARY = 0x27;
// Results '3X' indicate that it is not worth the UICC re-trying with an
// identical command; as it will only get the same response. However, the
// decision to retry lies with the application.
// Command beyond terminal's capabilities.
const STK_RESULT_BEYOND_TERMINAL_CAPABILITY = 0x30;
// Command type not understood by terminal.
const STK_RESULT_CMD_TYPE_NOT_UNDERSTOOD = 0x31;
// Command data not understood by terminal.
const STK_RESULT_CMD_DATA_NOT_UNDERSTOOD = 0x32;
// Command number not known by terminal.
const STK_RESULT_CMD_NUM_NOT_KNOWN = 0x33;
// SS Return Error.
const STK_RESULT_SS_RETURN_ERROR = 0x34;
// SMS RP-ERROR.
const STK_RESULT_SMS_RP_ERROR = 0x35;
// Error, required values are missing.
const STK_RESULT_REQUIRED_VALUES_MISSING = 0x36;
// USSD Return Error.
const STK_RESULT_USSD_RETURN_ERROR = 0x37;
// MultipleCard commands error.
const STK_RESULT_MULTI_CARDS_CMD_ERROR = 0x38;
// Interaction with call control by USIM or MO short message control by
// USIM; permanent problem.
const STK_RESULT_USIM_CALL_CONTROL_PERMANENT = 0x39;
// Bearer Independent Protocol error.
const STK_RESULT_BIP_ERROR = 0x3a;
// Access Technology unable to process command.
const STK_RESULT_ACCESS_TECH_UNABLE_TO_PROCESS = 0x3b;
// Frames error.
const STK_RESULT_FRAMES_ERROR = 0x3c;
// MMS Error.
const STK_RESULT_MMS_ERROR = 0x3d;
// STK presentation types, TS 11.14, clause 12.6, Command Qualifier: Select Item
const STK_PRESENTATION_TYPE_NOT_SPECIFIED = 0x00; // Bit 1 is 0.
const STK_PRESENTATION_TYPE_DATA_VALUES = 0x01; // Bit 1 is 1, bit 2 is 0.
const STK_PRESENTATION_TYPE_NAVIGATION_OPTIONS = 0x03; // Bit 1 is 1, bit 2 is 1.
// STK Coding Scheme.
const STK_TEXT_CODING_GSM_7BIT_PACKED = 0x00;
const STK_TEXT_CODING_GSM_8BIT = 0x04;
const STK_TEXT_CODING_UCS2 = 0x08;
/**
* GSM PDU constants
*/

File diff suppressed because it is too large Load Diff