Bug 1114935 - Part 1: Define new nsIIccService/nsIGonkIccService to replace nsIIccProvider. r=echen

This commit is contained in:
Bevis Tseng 2014-12-31 10:52:25 +08:00
parent 28800c7d33
commit 091f532fce
5 changed files with 339 additions and 137 deletions

View File

@ -3,15 +3,15 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/MozIccBinding.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
namespace icc {
#define ASSERT_EQUALITY(webidlType, webidlState, xpidlState) \
static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsIIccProvider::xpidlState, \
#webidlType "::" #webidlState " should equal to nsIIccProvider::" #xpidlState)
static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsIIcc::xpidlState, \
#webidlType "::" #webidlState " should equal to nsIIccService::" #xpidlState)
/**
* Enum IccCardState

View File

@ -7,10 +7,12 @@
XPIDL_SOURCES += [
'nsIIccInfo.idl',
'nsIIccProvider.idl',
'nsIIccService.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIGonkIccService.idl',
'nsIIccMessenger.idl',
]

View File

@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIIccService.idl"
[scriptable, uuid(a037b8a2-b027-11e4-9496-c3b7af59a512)]
interface nsIGonkIccService : nsIIccService
{
// TODO: Bug 1114938 - Refactor STK in MozIcc.webidl with IPDL:
// void notifyStkCommand(in unsigned long aServiceId, in jsval aStkcommand);
// void notifyStkSessionEnd(in unsigned long aServiceId);
void notifyCardStateChanged(in unsigned long aServiceId, in unsigned long aCardState);
void notifyIccInfoChanged(in unsigned long aServiceId, in jsval aIccInfo);
void notifyImsiChanged(in unsigned long aServiceId, in DOMString aImsi);
};

View File

@ -7,15 +7,7 @@
interface nsIDOMDOMRequest;
interface nsIDOMWindow;
interface nsIIccInfo;
[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
interface nsIIccListener : nsISupports
{
void notifyStkCommand(in DOMString aMessage);
void notifyStkSessionEnd();
void notifyCardStateChanged();
void notifyIccInfoChanged();
};
interface nsIIccListener;
[scriptable, uuid(6136acab-b50e-494a-a86d-df392a032897)]
interface nsIIccChannelCallback : nsISupports
@ -58,83 +50,9 @@ interface nsIIccChannelCallback : nsISupports
/**
* XPCOM component (in the content process) that provides the ICC information.
*/
[scriptable, uuid(a203cd2e-2280-4d8e-a687-42b745d322c1)]
[scriptable, uuid(7dd6e186-b007-11e4-9b7e-7717d7863cb8)]
interface nsIIccProvider : nsISupports
{
// MUST match enum IccCardState in MozIcc.webidl!
const unsigned long CARD_STATE_UNKNOWN = 0;
const unsigned long CARD_STATE_READY = 1;
const unsigned long CARD_STATE_PIN_REQUIRED = 2;
const unsigned long CARD_STATE_PUK_REQUIRED = 3;
const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5;
const unsigned long CARD_STATE_PERSONALIZATION_READY = 6;
const unsigned long CARD_STATE_NETWORK_LOCKED = 7;
const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8;
const unsigned long CARD_STATE_CORPORATE_LOCKED = 9;
const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10;
const unsigned long CARD_STATE_SIM_LOCKED = 11;
const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12;
const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13;
const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14;
const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15;
const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16;
const unsigned long CARD_STATE_NETWORK1_LOCKED = 17;
const unsigned long CARD_STATE_NETWORK2_LOCKED = 18;
const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19;
const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21;
const unsigned long CARD_STATE_RUIM_LOCKED = 22;
const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23;
const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24;
const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
const unsigned long CARD_STATE_ILLEGAL = 29;
const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
// MUST match with enum IccLockType in MozIcc.webidl
const unsigned long CARD_LOCK_TYPE_PIN = 0;
const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
const unsigned long CARD_LOCK_TYPE_PUK = 2;
const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
const unsigned long CARD_LOCK_TYPE_NCK = 4;
const unsigned long CARD_LOCK_TYPE_NSCK = 5;
const unsigned long CARD_LOCK_TYPE_NCK1 = 6;
const unsigned long CARD_LOCK_TYPE_NCK2 = 7;
const unsigned long CARD_LOCK_TYPE_HNCK = 8;
const unsigned long CARD_LOCK_TYPE_CCK = 9;
const unsigned long CARD_LOCK_TYPE_SPCK = 10;
const unsigned long CARD_LOCK_TYPE_PCK = 11;
const unsigned long CARD_LOCK_TYPE_RCCK = 12;
const unsigned long CARD_LOCK_TYPE_RSPCK = 13;
const unsigned long CARD_LOCK_TYPE_NCK_PUK = 14;
const unsigned long CARD_LOCK_TYPE_NSCK_PUK = 15;
const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 16;
const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 17;
const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 18;
const unsigned long CARD_LOCK_TYPE_CCK_PUK = 19;
const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 20;
const unsigned long CARD_LOCK_TYPE_PCK_PUK = 21;
const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 22;
const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 23;
const unsigned long CARD_LOCK_TYPE_FDN = 24;
// MUST match with enum IccContactType in MozIcc.webidl
const unsigned long CARD_CONTACT_TYPE_ADN = 0;
const unsigned long CARD_CONTACT_TYPE_FDN = 1;
const unsigned long CARD_CONTACT_TYPE_SDN = 2;
// MUST match with enum IccMvnoType in MozIcc.webidl
const unsigned long CARD_MVNO_TYPE_IMSI = 0;
const unsigned long CARD_MVNO_TYPE_SPN = 1;
const unsigned long CARD_MVNO_TYPE_GID = 2;
// MUST match with enum IccService in MozIcc.webidl
const unsigned long CARD_SERVICE_FDN = 0;
/**
* Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has
@ -143,18 +61,6 @@ interface nsIIccProvider : nsISupports
void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
/**
* UICC Information
*/
nsIIccInfo getIccInfo(in unsigned long clientId);
/**
* Card State
*
* One of the nsIIccProvider.CARD_STATE_* values.
*/
unsigned long getCardState(in unsigned long clientId);
/**
* STK interfaces.
*/
@ -173,31 +79,6 @@ interface nsIIccProvider : nsISupports
in nsIDOMWindow window,
in jsval event);
/**
* Card lock interfaces.
*/
nsIDOMDOMRequest getCardLockEnabled(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType);
nsIDOMDOMRequest unlockCardLock(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
[optional] in DOMString newPin);
nsIDOMDOMRequest setCardLockEnabled(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
in boolean enabled);
nsIDOMDOMRequest changeCardLockPassword(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
in DOMString newPassword);
nsIDOMDOMRequest getCardLockRetryCount(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType);
/**
* Phonebook interfaces.
*/
@ -211,7 +92,7 @@ interface nsIIccProvider : nsISupports
in jsval contact,
in DOMString pin2);
/**
/**
* Secure Card Icc communication channel
*/
void iccOpenChannel(in unsigned long clientId,
@ -238,16 +119,4 @@ interface nsIIccProvider : nsISupports
void iccCloseChannel(in unsigned long clientId,
in long channel,
in nsIIccChannelCallback callback);
/**
* Helpers
*/
nsIDOMDOMRequest matchMvno(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long mvnoType,
in DOMString mvnoData);
nsISupports getServiceState(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long service);
};

View File

@ -0,0 +1,315 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIIcc;
interface nsIIccInfo;
[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
interface nsIIccListener : nsISupports
{
void notifyStkCommand(in DOMString aMessage);
void notifyStkSessionEnd();
void notifyCardStateChanged();
void notifyIccInfoChanged();
};
/**
* A callback interface for handling asynchronous response.
*/
[scriptable, uuid(b0e2899a-adc3-11e4-89cf-1b60eaa35b06)]
interface nsIIccCallback : nsISupports
{
/**
* The success callback with no result required:
* |unlockCardLock|, |setCardLockEnabled| and |changeCardLockPassword|.
*/
void notifySuccess();
/**
* The success callback with boolean response:
* |getCardLockEnabled|, |matchMvno|, and |getServiceStateEnabled|.
*/
void notifySuccessWithBoolean(in boolean aResult);
/**
* The success callback of |getCardLockRetryCount|.
*
* @param aCount
* The number of remaining retries. -1 if unknown.
*/
void notifyGetCardLockRetryCount(in long aCount);
/**
* The error callback of |getCardLockEnabled|, |getCardLockRetryCount|,
* |matchMvno|, and |getServiceStateEnabled|.
*
* @param aErrorMsg
* The error message.
*/
void notifyError(in DOMString aErrorMsg);
/**
* The error callback of |unlockCardLock|, |setCardLockEnabled| and
* |changeCardLockPassword|.
*
* @param aErrorMsg
* The error message.
* @param aRetryCount
* The number of remaining retries. -1 if unknown.
*/
void notifyCardLockError(in DOMString aErrorMsg, in long aRetryCount);
};
/**
* XPCOM Service for the selection of the ICC to be accessed.
*/
[scriptable, uuid(6590a04c-9ca4-11e4-ae95-570876ecc428)]
interface nsIIccService : nsISupports
{
/**
* Get Icc instance with specified Service Id.
*
* @param aServiceId
* Started from 0 to nsIMobileConnectionService.numItems - 1;
*
* @return a nsIcc instance.
*/
nsIIcc getIccByServiceId(in unsigned long aServiceId);
};
/**
* XPCOM component that provides the access to the selected ICC.
*/
[scriptable, uuid(38a5bbe2-add6-11e4-ba9e-e390d1d19195)]
interface nsIIcc : nsISupports
{
/**
* Card State Constants
*
* Note: MUST be matched with enum IccCardState in MozIcc.webidl!
*/
const unsigned long CARD_STATE_UNKNOWN = 0;
const unsigned long CARD_STATE_READY = 1;
const unsigned long CARD_STATE_PIN_REQUIRED = 2;
const unsigned long CARD_STATE_PUK_REQUIRED = 3;
const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5;
const unsigned long CARD_STATE_PERSONALIZATION_READY = 6;
const unsigned long CARD_STATE_NETWORK_LOCKED = 7;
const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8;
const unsigned long CARD_STATE_CORPORATE_LOCKED = 9;
const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10;
const unsigned long CARD_STATE_SIM_LOCKED = 11;
const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12;
const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13;
const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14;
const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15;
const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16;
const unsigned long CARD_STATE_NETWORK1_LOCKED = 17;
const unsigned long CARD_STATE_NETWORK2_LOCKED = 18;
const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19;
const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21;
const unsigned long CARD_STATE_RUIM_LOCKED = 22;
const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23;
const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24;
const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
const unsigned long CARD_STATE_ILLEGAL = 29;
const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
/**
* Card Lock Constants
*
* Note: MUST be matched with enum IccLockType in MozIcc.webidl!
*/
const unsigned long CARD_LOCK_TYPE_PIN = 0;
const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
const unsigned long CARD_LOCK_TYPE_PUK = 2;
const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
const unsigned long CARD_LOCK_TYPE_NCK = 4;
const unsigned long CARD_LOCK_TYPE_NSCK = 5;
const unsigned long CARD_LOCK_TYPE_NCK1 = 6;
const unsigned long CARD_LOCK_TYPE_NCK2 = 7;
const unsigned long CARD_LOCK_TYPE_HNCK = 8;
const unsigned long CARD_LOCK_TYPE_CCK = 9;
const unsigned long CARD_LOCK_TYPE_SPCK = 10;
const unsigned long CARD_LOCK_TYPE_PCK = 11;
const unsigned long CARD_LOCK_TYPE_RCCK = 12;
const unsigned long CARD_LOCK_TYPE_RSPCK = 13;
const unsigned long CARD_LOCK_TYPE_NCK_PUK = 14;
const unsigned long CARD_LOCK_TYPE_NSCK_PUK = 15;
const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 16;
const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 17;
const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 18;
const unsigned long CARD_LOCK_TYPE_CCK_PUK = 19;
const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 20;
const unsigned long CARD_LOCK_TYPE_PCK_PUK = 21;
const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 22;
const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 23;
const unsigned long CARD_LOCK_TYPE_FDN = 24;
/**
* Contact Type Constants
*
* Note: MUST be matched with enum IccContactType in MozIcc.webidl!
*/
const unsigned long CARD_CONTACT_TYPE_ADN = 0;
const unsigned long CARD_CONTACT_TYPE_FDN = 1;
const unsigned long CARD_CONTACT_TYPE_SDN = 2;
/**
* MVNO Type Constants
*
* Note: MUST be matched with enum IccMvnoType in MozIcc.webidl!
*/
const unsigned long CARD_MVNO_TYPE_IMSI = 0;
const unsigned long CARD_MVNO_TYPE_SPN = 1;
const unsigned long CARD_MVNO_TYPE_GID = 2;
/**
* Card Service Constants
*
* Note: MUST be matched with enum IccService in MozIcc.webidl!
*/
const unsigned long CARD_SERVICE_FDN = 0;
/**
* Called to register icc-related changes.
*
* 'mobileconnection' permission is required to register.
*/
void registerListener(in nsIIccListener aListener);
void unregisterListener(in nsIIccListener aListener);
/**
* Information stored in this ICC.
*/
readonly attribute nsIIccInfo iccInfo;
/**
* Indicates the state of this ICC.
*
* One of the CARD_STATE_* values.
*/
readonly attribute unsigned long cardState;
/**
* Get the status of an ICC lock (e.g. the PIN lock).
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getCardLockEnabled(in unsigned long aLockType,
in nsIIccCallback aCallback);
/**
* Unlock a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aNewPin (Optional)
* The new PIN to be set after PUK/PUK2 is unlock.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void unlockCardLock(in unsigned long aLockType,
in DOMString aPassword,
in DOMString aNewPin,
in nsIIccCallback aCallback);
/**
* Enable/Disable a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aEnabled.
* True to enable the lock. False to disable, otherwise.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void setCardLockEnabled(in unsigned long aLockType,
in DOMString aPassword,
in boolean aEnabled,
in nsIIccCallback aCallback);
/**
* Change the password of a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aNewPassword.
* The new password of this lock.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void changeCardLockPassword(in unsigned long aLockType,
in DOMString aPassword,
in DOMString aNewPassword,
in nsIIccCallback aCallback);
/**
* Get the number of remaining tries of a lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifyGetCardLockRetryCount() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getCardLockRetryCount(in unsigned long aLockType,
in nsIIccCallback aCallback);
/**
* Verify whether the passed data (matchData) matches with some ICC's field
* according to the mvno type (mvnoType).
*
* @param aMvnoType
* One of CARD_MVNO_TYPE_* values.
* @param aMvnoData
* Data to be compared with ICC's field.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void matchMvno(in unsigned long aMvnoType,
in DOMString aMvnoData,
in nsIIccCallback aCallback);
/**
* Retrieve the the availability of an icc service.
*
* @param aService
* One of CARD_SERVICE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getServiceStateEnabled(in unsigned long aService,
in nsIIccCallback aCallback);
};