mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1114938 - Part 2.1: (Gonk) Refactor Stk Proactive Commands from IccProvider to IccService. r=echen
This commit is contained in:
parent
e89472499d
commit
4dc1a2216d
@ -38,7 +38,7 @@ IccListener::NotifyIccInfoChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
IccListener::NotifyStkCommand(const nsAString & aMessage)
|
IccListener::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ IccListener::NotifyIccInfoChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
IccListener::NotifyStkCommand(const nsAString & aMessage)
|
IccListener::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
#include "nsIIccInfo.h"
|
#include "nsIIccInfo.h"
|
||||||
#include "nsIIccProvider.h"
|
#include "nsIIccProvider.h"
|
||||||
#include "nsIIccService.h"
|
#include "nsIIccService.h"
|
||||||
#include "nsJSON.h"
|
#include "nsIStkCmdFactory.h"
|
||||||
|
#include "nsIStkProactiveCmd.h"
|
||||||
#include "nsRadioInterfaceLayer.h"
|
#include "nsRadioInterfaceLayer.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ Icc::NotifyEvent(const nsAString& aName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage)
|
Icc::NotifyStkEvent(const nsAString& aName, nsIStkProactiveCmd* aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
AutoJSAPI jsapi;
|
AutoJSAPI jsapi;
|
||||||
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetOwner()))) {
|
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetOwner()))) {
|
||||||
@ -108,13 +109,12 @@ Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage)
|
|||||||
JSContext* cx = jsapi.cx();
|
JSContext* cx = jsapi.cx();
|
||||||
JS::Rooted<JS::Value> value(cx);
|
JS::Rooted<JS::Value> value(cx);
|
||||||
|
|
||||||
if (!aMessage.IsEmpty()) {
|
nsCOMPtr<nsIStkCmdFactory> cmdFactory =
|
||||||
nsCOMPtr<nsIJSON> json(new nsJSON());
|
do_GetService(ICC_STK_CMD_FACTORY_CONTRACTID);
|
||||||
nsresult rv = json->DecodeToJSVal(aMessage, cx, &value);
|
NS_ENSURE_TRUE(cmdFactory, NS_ERROR_UNEXPECTED);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
} else {
|
cmdFactory->CreateCommandMessage(aStkProactiveCmd, &value);
|
||||||
value = JS::NullValue();
|
NS_ENSURE_TRUE(value.isObject(), NS_ERROR_UNEXPECTED);
|
||||||
}
|
|
||||||
|
|
||||||
MozStkCommandEventInit init;
|
MozStkCommandEventInit init;
|
||||||
init.mBubbles = false;
|
init.mBubbles = false;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
class nsIIcc;
|
class nsIIcc;
|
||||||
class nsIIccInfo;
|
class nsIIccInfo;
|
||||||
class nsIIccProvider;
|
class nsIIccProvider;
|
||||||
|
class nsIStkProactiveCmd;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
@ -38,7 +39,7 @@ public:
|
|||||||
NotifyEvent(const nsAString& aName);
|
NotifyEvent(const nsAString& aName);
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NotifyStkEvent(const nsAString& aName, const nsAString& aMessage);
|
NotifyStkEvent(const nsAString& aName, nsIStkProactiveCmd* aStkProactiveCmd);
|
||||||
|
|
||||||
nsString
|
nsString
|
||||||
GetIccId()
|
GetIccId()
|
||||||
|
@ -22,15 +22,6 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(mIccManager);
|
MOZ_ASSERT(mIccManager);
|
||||||
|
|
||||||
// TODO: Bug 1114938, Refactor STK in MozIcc.webidl with IPDL.
|
|
||||||
// Remove the registration to IccProvider.
|
|
||||||
mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
|
||||||
|
|
||||||
if (!mProvider) {
|
|
||||||
NS_WARNING("Could not acquire nsIIccProvider!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
|
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
|
||||||
|
|
||||||
if (!iccService) {
|
if (!iccService) {
|
||||||
@ -57,10 +48,6 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
|
|||||||
DebugOnly<nsresult> rv = mHandler->RegisterListener(this);
|
DebugOnly<nsresult> rv = mHandler->RegisterListener(this);
|
||||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
||||||
"Failed registering icc listener with Icc Handler");
|
"Failed registering icc listener with Icc Handler");
|
||||||
|
|
||||||
rv = mProvider->RegisterIccMsg(mClientId, this);
|
|
||||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
|
||||||
"Failed registering icc messages with provider");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IccListener::~IccListener()
|
IccListener::~IccListener()
|
||||||
@ -71,13 +58,6 @@ IccListener::~IccListener()
|
|||||||
void
|
void
|
||||||
IccListener::Shutdown()
|
IccListener::Shutdown()
|
||||||
{
|
{
|
||||||
// TODO: Bug 1114938, Refactor STK in MozIcc.webidl with IPDL.
|
|
||||||
// Remove the unregistration to IccProvider.
|
|
||||||
if (mProvider) {
|
|
||||||
mProvider->UnregisterIccMsg(mClientId, this);
|
|
||||||
mProvider = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mHandler) {
|
if (mHandler) {
|
||||||
mHandler->UnregisterListener(this);
|
mHandler->UnregisterListener(this);
|
||||||
mHandler = nullptr;
|
mHandler = nullptr;
|
||||||
@ -94,13 +74,13 @@ IccListener::Shutdown()
|
|||||||
// nsIIccListener
|
// nsIIccListener
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
IccListener::NotifyStkCommand(const nsAString& aMessage)
|
IccListener::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
if (!mIcc) {
|
if (!mIcc) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mIcc->NotifyStkEvent(NS_LITERAL_STRING("stkcommand"), aMessage);
|
return mIcc->NotifyStkEvent(NS_LITERAL_STRING("stkcommand"), aStkProactiveCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -45,9 +45,6 @@ private:
|
|||||||
// IccListener, this will release the reference and break the cycle.
|
// IccListener, this will release the reference and break the cycle.
|
||||||
nsRefPtr<Icc> mIcc;
|
nsRefPtr<Icc> mIcc;
|
||||||
nsRefPtr<IccManager> mIccManager;
|
nsRefPtr<IccManager> mIccManager;
|
||||||
// mProvider is a xpcom service and will be released at Shutdown(), so it
|
|
||||||
// doesn't need to be cycle collected.
|
|
||||||
nsCOMPtr<nsIIccProvider> mProvider;
|
|
||||||
// mHandler will be released at Shutdown(), there is no need to join cycle
|
// mHandler will be released at Shutdown(), there is no need to join cycle
|
||||||
// collection.
|
// collection.
|
||||||
nsCOMPtr<nsIIcc> mHandler;
|
nsCOMPtr<nsIIcc> mHandler;
|
||||||
|
@ -29,6 +29,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
|
|||||||
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
|
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
|
||||||
"nsIGonkMobileConnectionService");
|
"nsIGonkMobileConnectionService");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, "gIccMessenger",
|
||||||
|
"@mozilla.org/ril/system-messenger-helper;1",
|
||||||
|
"nsIIccMessenger");
|
||||||
|
|
||||||
let DEBUG = RIL.DEBUG_RIL;
|
let DEBUG = RIL.DEBUG_RIL;
|
||||||
function debug(s) {
|
function debug(s) {
|
||||||
dump("IccService: " + s);
|
dump("IccService: " + s);
|
||||||
@ -124,6 +128,27 @@ IccService.prototype = {
|
|||||||
/**
|
/**
|
||||||
* nsIGonkIccService interface.
|
* nsIGonkIccService interface.
|
||||||
*/
|
*/
|
||||||
|
notifyStkCommand: function(aServiceId, aStkcommand) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("notifyStkCommand for service Id: " + aServiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
let icc = this.getIccByServiceId(aServiceId);
|
||||||
|
|
||||||
|
gIccMessenger.notifyStkProactiveCommand(icc.iccInfo.iccid, aStkcommand);
|
||||||
|
|
||||||
|
icc._deliverListenerEvent("notifyStkCommand", [aStkcommand]);
|
||||||
|
},
|
||||||
|
|
||||||
|
notifyStkSessionEnd: function(aServiceId) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("notifyStkSessionEnd for service Id: " + aServiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getIccByServiceId(aServiceId)
|
||||||
|
._deliverListenerEvent("notifyStkSessionEnd");
|
||||||
|
},
|
||||||
|
|
||||||
notifyCardStateChanged: function(aServiceId, aCardState) {
|
notifyCardStateChanged: function(aServiceId, aCardState) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
debug("notifyCardStateChanged for service Id: " + aServiceId +
|
debug("notifyCardStateChanged for service Id: " + aServiceId +
|
||||||
|
@ -9,12 +9,11 @@
|
|||||||
"@mozilla.org/icc/gonkiccservice;1"
|
"@mozilla.org/icc/gonkiccservice;1"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
[scriptable, uuid(a037b8a2-b027-11e4-9496-c3b7af59a512)]
|
[scriptable, uuid(cdcdd800-ef24-11e4-99e7-1f0f5f2576c5)]
|
||||||
interface nsIGonkIccService : nsIIccService
|
interface nsIGonkIccService : nsIIccService
|
||||||
{
|
{
|
||||||
// TODO: Bug 1114938 - Refactor STK in MozIcc.webidl with IPDL:
|
void notifyStkCommand(in unsigned long aServiceId, in nsIStkProactiveCmd aStkcommand);
|
||||||
// void notifyStkCommand(in unsigned long aServiceId, in jsval aStkcommand);
|
void notifyStkSessionEnd(in unsigned long aServiceId);
|
||||||
// void notifyStkSessionEnd(in unsigned long aServiceId);
|
|
||||||
void notifyCardStateChanged(in unsigned long aServiceId, in unsigned long aCardState);
|
void notifyCardStateChanged(in unsigned long aServiceId, in unsigned long aCardState);
|
||||||
void notifyIccInfoChanged(in unsigned long aServiceId, in jsval aIccInfo);
|
void notifyIccInfoChanged(in unsigned long aServiceId, in jsval aIccInfo);
|
||||||
void notifyImsiChanged(in unsigned long aServiceId, in DOMString aImsi);
|
void notifyImsiChanged(in unsigned long aServiceId, in DOMString aImsi);
|
||||||
|
@ -6,22 +6,13 @@
|
|||||||
|
|
||||||
interface nsIDOMDOMRequest;
|
interface nsIDOMDOMRequest;
|
||||||
interface nsIDOMWindow;
|
interface nsIDOMWindow;
|
||||||
interface nsIIccListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XPCOM component (in the content process) that provides the ICC information.
|
* XPCOM component (in the content process) that provides the ICC information.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(2fbacfc4-f52d-11e4-9667-33b72f279d14)]
|
[scriptable, uuid(b331eb34-006e-11e5-aabc-1341ac30c5f9)]
|
||||||
interface nsIIccProvider : nsISupports
|
interface nsIIccProvider : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Called when a content process registers receiving unsolicited messages from
|
|
||||||
* RadioInterfaceLayer in the chrome process. Only a content process that has
|
|
||||||
* the 'mobileconnection' permission is allowed to register.
|
|
||||||
*/
|
|
||||||
void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
|
|
||||||
void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STK interfaces.
|
* STK interfaces.
|
||||||
*/
|
*/
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
|
|
||||||
interface nsIIcc;
|
interface nsIIcc;
|
||||||
interface nsIIccInfo;
|
interface nsIIccInfo;
|
||||||
|
interface nsIStkProactiveCmd;
|
||||||
|
|
||||||
[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
|
[scriptable, uuid(71b33012-eca2-11e4-a40d-9ff040a6fe2a)]
|
||||||
interface nsIIccListener : nsISupports
|
interface nsIIccListener : nsISupports
|
||||||
{
|
{
|
||||||
void notifyStkCommand(in DOMString aMessage);
|
void notifyStkCommand(in nsIStkProactiveCmd aStkProactiveCmd);
|
||||||
void notifyStkSessionEnd();
|
void notifyStkSessionEnd();
|
||||||
void notifyCardStateChanged();
|
void notifyCardStateChanged();
|
||||||
void notifyIccInfoChanged();
|
void notifyIccInfoChanged();
|
||||||
|
@ -154,7 +154,7 @@ IccParent::RecvPIccRequestConstructor(PIccRequestParent* aActor,
|
|||||||
NS_IMPL_ISUPPORTS(IccParent, nsIIccListener)
|
NS_IMPL_ISUPPORTS(IccParent, nsIIccListener)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
IccParent::NotifyStkCommand(const nsAString & aMessage)
|
IccParent::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
// Bug 1114938 - [B2G][ICC] Refactor STK in MozIcc.webidl with IPDL.
|
// Bug 1114938 - [B2G][ICC] Refactor STK in MozIcc.webidl with IPDL.
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
@ -1129,7 +1129,7 @@ MobileConnection::NotifyNetworkSelectionModeChanged()
|
|||||||
// nsIIccListener
|
// nsIIccListener
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
MobileConnection::NotifyStkCommand(const nsAString& aMessage)
|
MobileConnection::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gCellBroadcastService",
|
|||||||
"@mozilla.org/cellbroadcast/cellbroadcastservice;1",
|
"@mozilla.org/cellbroadcast/cellbroadcastservice;1",
|
||||||
"nsIGonkCellBroadcastService");
|
"nsIGonkCellBroadcastService");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "gIccMessenger",
|
|
||||||
"@mozilla.org/ril/system-messenger-helper;1",
|
|
||||||
"nsIIccMessenger");
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "gDataCallManager",
|
XPCOMUtils.defineLazyServiceGetter(this, "gDataCallManager",
|
||||||
"@mozilla.org/datacall/manager;1",
|
"@mozilla.org/datacall/manager;1",
|
||||||
"nsIDataCallManager");
|
"nsIDataCallManager");
|
||||||
@ -966,11 +962,6 @@ RadioInterface.prototype = {
|
|||||||
Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
|
Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
|
||||||
},
|
},
|
||||||
|
|
||||||
getIccInfo: function() {
|
|
||||||
let icc = gIccService.getIccByServiceId(this.clientId);
|
|
||||||
return icc ? icc.iccInfo : null;
|
|
||||||
},
|
|
||||||
|
|
||||||
isCardPresent: function() {
|
isCardPresent: function() {
|
||||||
let icc = gIccService.getIccByServiceId(this.clientId);
|
let icc = gIccService.getIccByServiceId(this.clientId);
|
||||||
let cardState = icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKNOWN;
|
let cardState = icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKNOWN;
|
||||||
@ -1097,11 +1088,11 @@ RadioInterface.prototype = {
|
|||||||
this.handleIccMwis(message.mwi);
|
this.handleIccMwis(message.mwi);
|
||||||
break;
|
break;
|
||||||
case "stkcommand":
|
case "stkcommand":
|
||||||
this.handleStkProactiveCommand(message);
|
gIccService.notifyStkCommand(this.clientId,
|
||||||
|
gStkCmdFactory.createCommand(message));
|
||||||
break;
|
break;
|
||||||
case "stksessionend":
|
case "stksessionend":
|
||||||
// TODO: Bug 815526, deprecate RILContentHelper.
|
gIccService.notifyStkSessionEnd(this.clientId);
|
||||||
gMessageManager.sendIccMessage("RIL:StkSessionEnd", this.clientId, null);
|
|
||||||
break;
|
break;
|
||||||
case "cdma-info-rec-received":
|
case "cdma-info-rec-received":
|
||||||
this.handleCdmaInformationRecords(message.records);
|
this.handleCdmaInformationRecords(message.records);
|
||||||
@ -1290,18 +1281,6 @@ RadioInterface.prototype = {
|
|||||||
null, null);
|
null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleStkProactiveCommand: function(message) {
|
|
||||||
if (DEBUG) this.debug("handleStkProactiveCommand " + JSON.stringify(message));
|
|
||||||
let iccInfo = this.getIccInfo();
|
|
||||||
if (iccInfo && iccInfo.iccid) {
|
|
||||||
gIccMessenger
|
|
||||||
.notifyStkProactiveCommand(iccInfo.iccid,
|
|
||||||
gStkCmdFactory.createCommand(message));
|
|
||||||
}
|
|
||||||
// TODO: Bug 815526, deprecate RILContentHelper.
|
|
||||||
gMessageManager.sendIccMessage("RIL:StkCommand", this.clientId, message);
|
|
||||||
},
|
|
||||||
|
|
||||||
_convertCbGsmGeographicalScope: function(aGeographicalScope) {
|
_convertCbGsmGeographicalScope: function(aGeographicalScope) {
|
||||||
return (aGeographicalScope != null)
|
return (aGeographicalScope != null)
|
||||||
? aGeographicalScope
|
? aGeographicalScope
|
||||||
|
Loading…
Reference in New Issue
Block a user