Bug 1114935 - Part 5.1: Bind new nsIccService into MozIcc. r=echen, r=hsinyi

--HG--
extra : histedit_source : c4f30cabe18e4a2ef4f6a34745e95d46c5baaff7
This commit is contained in:
Bevis Tseng 2015-01-13 18:03:44 +08:00
parent 1cba772979
commit e511c87731
13 changed files with 385 additions and 61 deletions

View File

@ -4,6 +4,7 @@
#include "mozilla/dom/Icc.h"
#include "IccCallback.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/IccInfo.h"
#include "mozilla/dom/MozStkCommandEvent.h"
@ -11,10 +12,13 @@
#include "mozilla/dom/ScriptSettings.h"
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsJSON.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
using mozilla::dom::icc::IccCallback;
namespace mozilla {
namespace dom {
@ -50,9 +54,10 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(Icc, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(Icc, DOMEventTargetHelper)
Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo)
Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIcc* aHandler, nsIIccInfo* aIccInfo)
: mLive(true)
, mClientId(aClientId)
, mHandler(aHandler)
{
BindToOwner(aWindow);
@ -79,6 +84,7 @@ Icc::Shutdown()
{
mIccInfo.SetNull();
mProvider = nullptr;
mHandler = nullptr;
mLive = false;
}
@ -170,10 +176,10 @@ Icc::GetCardState() const
{
Nullable<IccCardState> result;
uint32_t cardState = nsIIccProvider::CARD_STATE_UNDETECTED;
if (mProvider &&
NS_SUCCEEDED(mProvider->GetCardState(mClientId, &cardState)) &&
cardState != nsIIccProvider::CARD_STATE_UNDETECTED) {
uint32_t cardState = nsIIcc::CARD_STATE_UNDETECTED;
if (mHandler &&
NS_SUCCEEDED(mHandler->GetCardState(&cardState)) &&
cardState != nsIIcc::CARD_STATE_UNDETECTED) {
MOZ_ASSERT(cardState < static_cast<uint32_t>(IccCardState::EndGuard_));
result.SetValue(static_cast<IccCardState>(cardState));
}
@ -249,72 +255,78 @@ Icc::SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
already_AddRefed<DOMRequest>
Icc::GetCardLock(IccLockType aLockType, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->GetCardLockEnabled(mClientId, GetOwner(),
static_cast<uint32_t>(aLockType),
getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request, true);
nsresult rv = mHandler->GetCardLockEnabled(static_cast<uint32_t>(aLockType),
requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::UnlockCardLock(const IccUnlockCardLockOptions& aOptions, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
const nsString& password = IsPukCardLockType(aOptions.mLockType)
? aOptions.mPuk : aOptions.mPin;
nsresult rv = mProvider->UnlockCardLock(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mNewPin,
getter_AddRefs(request));
nsresult rv =
mHandler->UnlockCardLock(static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mNewPin, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsresult rv;
nsRefPtr<nsIDOMDOMRequest> request;
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
if (aOptions.mEnabled.WasPassed()) {
// Enable card lock.
const nsString& password = (aOptions.mLockType == IccLockType::Fdn) ?
aOptions.mPin2 : aOptions.mPin;
rv = mProvider->SetCardLockEnabled(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mEnabled.Value(),
getter_AddRefs(request));
rv =
mHandler->SetCardLockEnabled(static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mEnabled.Value(),
requestCallback);
} else {
// Change card lock password.
rv = mProvider->ChangeCardLockPassword(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
aOptions.mPin, aOptions.mNewPin,
getter_AddRefs(request));
rv =
mHandler->ChangeCardLockPassword(static_cast<uint32_t>(aOptions.mLockType),
aOptions.mPin, aOptions.mNewPin,
requestCallback);
}
if (NS_FAILED(rv)) {
@ -322,27 +334,28 @@ Icc::SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv)
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::GetCardLockRetryCount(IccLockType aLockType, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->GetCardLockRetryCount(mClientId, GetOwner(),
static_cast<uint32_t>(aLockType),
getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
nsresult rv = mHandler->GetCardLockRetryCount(static_cast<uint32_t>(aLockType),
requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
@ -392,41 +405,54 @@ already_AddRefed<DOMRequest>
Icc::MatchMvno(IccMvnoType aMvnoType, const nsAString& aMvnoData,
ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->MatchMvno(mClientId, GetOwner(),
static_cast<uint32_t>(aMvnoType),
aMvnoData, getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
nsresult rv = mHandler->MatchMvno(static_cast<uint32_t>(aMvnoType),
aMvnoData, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<Promise>
Icc::GetServiceState(IccService aService, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsISupports> supports;
nsresult rv = mProvider->GetServiceState(mClientId, GetOwner(),
static_cast<uint32_t>(aService),
getter_AddRefs(supports));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
if (!global) {
return nullptr;
}
nsCOMPtr<Promise> promise = do_QueryInterface(supports);
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
if (aRv.Failed()) {
return nullptr;
}
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), promise);
nsresult rv =
mHandler->GetServiceStateEnabled(static_cast<uint32_t>(aService),
requestCallback);
if (NS_FAILED(rv)) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
// fall-through to return promise.
}
return promise.forget();
}

View File

@ -8,6 +8,7 @@
#include "mozilla/dom/MozIccBinding.h"
#include "mozilla/DOMEventTargetHelper.h"
class nsIIcc;
class nsIIccInfo;
class nsIIccProvider;
@ -25,7 +26,8 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Icc, DOMEventTargetHelper)
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo);
Icc(nsPIDOMWindow* aWindow, long aClientId,
nsIIcc* aHandler, nsIIccInfo* aIccInfo);
void
Shutdown();
@ -111,14 +113,20 @@ public:
IMPL_EVENT_HANDLER(stksessionend)
private:
// Put definition of the destructor in Icc.cpp to ensure forward declaration
// of nsIIccProvider, nsIIcc for the auto-generated .cpp file (i.e.,
// MozIccManagerBinding.cpp) that includes this header.
~Icc();
bool mLive;
uint32_t mClientId;
nsString mIccId;
// mProvider is a xpcom service and will be released at shutdown, so it
// 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(), so there is no need to join cycle
// collection.
nsCOMPtr<nsIIcc> mHandler;
Nullable<OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo> mIccInfo;
};

135
dom/icc/IccCallback.cpp Normal file
View File

@ -0,0 +1,135 @@
/* 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 "IccCallback.h"
#include "mozilla/dom/IccCardLockError.h"
#include "mozilla/dom/MozIccBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
namespace dom {
namespace icc {
NS_IMPL_ISUPPORTS(IccCallback, nsIIccCallback)
IccCallback::IccCallback(nsPIDOMWindow* aWindow, DOMRequest* aRequest,
bool aIsCardLockEnabled)
: mWindow(aWindow)
, mRequest(aRequest)
, mIsCardLockEnabled(aIsCardLockEnabled)
{
}
IccCallback::IccCallback(nsPIDOMWindow* aWindow, Promise* aPromise)
: mWindow(aWindow)
, mPromise(aPromise)
{
}
nsresult
IccCallback::NotifySuccess(JS::Handle<JS::Value> aResult)
{
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
return rs->FireSuccessAsync(mRequest, aResult);
}
nsresult
IccCallback::NotifyGetCardLockEnabled(bool aResult)
{
IccCardLockStatus result;
result.mEnabled.Construct(aResult);
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mWindow))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
return NS_ERROR_TYPE_ERR;
}
return NotifySuccess(jsResult);
}
NS_IMETHODIMP
IccCallback::NotifySuccess()
{
return NotifySuccess(JS::UndefinedHandleValue);
}
NS_IMETHODIMP
IccCallback::NotifySuccessWithBoolean(bool aResult)
{
if (mPromise) {
mPromise->MaybeResolve(aResult ? JS::TrueHandleValue : JS::FalseHandleValue);
return NS_OK;
}
return mIsCardLockEnabled
? NotifyGetCardLockEnabled(aResult)
: NotifySuccess(aResult ? JS::TrueHandleValue : JS::FalseHandleValue);
}
NS_IMETHODIMP
IccCallback::NotifyGetCardLockRetryCount(int32_t aCount)
{
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
IccCardLockRetryCount result;
result.mRetryCount.Construct(aCount);
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mWindow))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
return NS_ERROR_TYPE_ERR;
}
return NotifySuccess(jsResult);
}
NS_IMETHODIMP
IccCallback::NotifyError(const nsAString & aErrorMsg)
{
if (mPromise) {
mPromise->MaybeRejectBrokenly(aErrorMsg);
return NS_OK;
}
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
return rs->FireErrorAsync(mRequest, aErrorMsg);
}
NS_IMETHODIMP
IccCallback::NotifyCardLockError(const nsAString & aErrorMsg,
int32_t aRetryCount)
{
nsRefPtr<IccCardLockError> error =
new IccCardLockError(mWindow, aErrorMsg, aRetryCount);
mRequest->FireDetailedError(error);
return NS_OK;
}
} // namespace icc
} // namespace dom
} // namespace mozilla

64
dom/icc/IccCallback.h Normal file
View File

@ -0,0 +1,64 @@
/* 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/. */
#ifndef mozilla_dom_icc_IccCallback_h
#define mozilla_dom_icc_IccCallback_h
#include "nsCOMPtr.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
class DOMRequest;
class Promise;
namespace icc {
/**
* A callback object for handling asynchronous request/response. This object is
* created when an asynchronous request is made and should be destroyed after
* Notify*Success/Error is called.
* The modules hold the reference of IccCallback in OOP mode and non-OOP mode
* are different.
* - OOP mode: IccRequestChild
* - non-OOP mode: IccService
* The reference should be released after Notify*Success/Error is called.
*/
class IccCallback final : public nsIIccCallback
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCCALLBACK
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
IccCallback(nsPIDOMWindow* aWindow, DOMRequest* aRequest,
bool aIsCardLockEnabled = false);
IccCallback(nsPIDOMWindow* aWindow, Promise* aPromise);
private:
~IccCallback() {}
nsresult
NotifySuccess(JS::Handle<JS::Value> aResult);
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
nsresult
NotifyGetCardLockEnabled(bool aResult);
nsCOMPtr<nsPIDOMWindow> mWindow;
nsRefPtr<DOMRequest> mRequest;
nsRefPtr<Promise> mPromise;
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
bool mIsCardLockEnabled;
};
} // namespace icc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_icc_IccCallback_h

View File

@ -20,6 +20,8 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
{
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) {
@ -27,17 +29,34 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
return;
}
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
if (!iccService) {
NS_WARNING("Could not acquire nsIIccService!");
return;
}
iccService->GetIccByServiceId(mClientId, getter_AddRefs(mHandler));
if (!mHandler) {
NS_WARNING("Could not acquire nsIIcc!");
return;
}
nsCOMPtr<nsIIccInfo> iccInfo;
mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
mHandler->GetIccInfo(getter_AddRefs(iccInfo));
if (iccInfo) {
nsString iccId;
iccInfo->GetIccid(iccId);
if (!iccId.IsEmpty()) {
mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
mIcc = new Icc(mIccManager->GetOwner(), mClientId, mHandler, iccInfo);
}
}
DebugOnly<nsresult> rv = mProvider->RegisterIccMsg(mClientId, this);
DebugOnly<nsresult> rv = mHandler->RegisterListener(this);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"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");
}
@ -50,11 +69,18 @@ IccListener::~IccListener()
void
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) {
mHandler->UnregisterListener(this);
mHandler = nullptr;
}
if (mIcc) {
mIcc->Shutdown();
mIcc = nullptr;
@ -98,8 +124,12 @@ IccListener::NotifyCardStateChanged()
NS_IMETHODIMP
IccListener::NotifyIccInfoChanged()
{
if (!mHandler) {
return NS_OK;
}
nsCOMPtr<nsIIccInfo> iccInfo;
mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
mHandler->GetIccInfo(getter_AddRefs(iccInfo));
// Create/delete icc object based on current iccInfo.
// 1. If the mIcc is nullptr and iccInfo has valid data, create icc object and
@ -111,7 +141,7 @@ IccListener::NotifyIccInfoChanged()
nsString iccId;
iccInfo->GetIccid(iccId);
if (!iccId.IsEmpty()) {
mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
mIcc = new Icc(mIccManager->GetOwner(), mClientId, mHandler, iccInfo);
mIccManager->NotifyIccAdd(iccId);
mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange"));
}

View File

@ -7,6 +7,7 @@
#include "nsAutoPtr.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
@ -42,9 +43,12 @@ private:
// IccListener, this will release the reference and break the cycle.
nsRefPtr<Icc> mIcc;
nsRefPtr<IccManager> mIccManager;
// mProvider is a xpcom service and will be released at shutdown, so it
// 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
// collection.
nsCOMPtr<nsIIcc> mHandler;
};
} // namespace dom

View File

@ -10,6 +10,12 @@
#include "mozilla/dom/IccChangeEvent.h"
#include "mozilla/Preferences.h"
#include "nsIIccInfo.h"
// Service instantiation
#include "ipc/IccIPCService.h"
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
#include "nsIGonkIccService.h"
#endif
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
using namespace mozilla::dom;
@ -129,3 +135,19 @@ IccManager::GetIccById(const nsAString& aIccId) const
}
return nullptr;
}
already_AddRefed<nsIIccService>
NS_CreateIccService()
{
nsCOMPtr<nsIIccService> service;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
service = new mozilla::dom::icc::IccIPCService();
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
} else {
service = do_GetService(GONK_ICC_SERVICE_CONTRACTID);
#endif
}
return service.forget();
}

View File

@ -7,7 +7,6 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIIccProvider.h"
#include "nsTArrayHelpers.h"
namespace mozilla {
@ -25,7 +24,7 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IccManager, DOMEventTargetHelper)
IccManager(nsPIDOMWindow* aWindow);
explicit IccManager(nsPIDOMWindow* aWindow);
void
Shutdown();

View File

@ -4,6 +4,11 @@
#include "nsIIccService.idl"
%{C++
#define GONK_ICC_SERVICE_CONTRACTID \
"@mozilla.org/icc/gonkiccservice;1"
%}
[scriptable, uuid(a037b8a2-b027-11e4-9496-c3b7af59a512)]
interface nsIGonkIccService : nsIIccService
{

View File

@ -63,6 +63,15 @@ interface nsIIccCallback : nsISupports
void notifyCardLockError(in DOMString aErrorMsg, in long aRetryCount);
};
%{C++
#define ICC_SERVICE_CID \
{ 0xbab0277a, 0x900e, 0x11e4, { 0x80, 0xc7, 0xdb, 0xd7, 0xad, 0x05, 0x24, 0x01 } }
#define ICC_SERVICE_CONTRACTID \
"@mozilla.org/icc/iccservice;1"
template<typename T> struct already_AddRefed;
%}
/**
* XPCOM Service for the selection of the ICC to be accessed.
*/
@ -80,6 +89,11 @@ interface nsIIccService : nsISupports
nsIIcc getIccByServiceId(in unsigned long aServiceId);
};
%{C++
already_AddRefed<nsIIccService>
NS_CreateIccService();
%}
/**
* XPCOM component that provides the access to the selected ICC.
*/

View File

@ -21,6 +21,7 @@ EXPORTS.mozilla.dom.icc += [
UNIFIED_SOURCES += [
'Assertions.cpp',
'Icc.cpp',
'IccCallback.cpp',
'IccCardLockError.cpp',
"IccInfo.cpp",
'IccListener.cpp',

View File

@ -129,6 +129,16 @@ dictionary IccSetCardLockOptions
// Necessary for lock types: "pin", "fdn"
};
dictionary IccCardLockStatus
{
boolean enabled; // True when CardLock is enabled.
};
dictionary IccCardLockRetryCount
{
long retryCount; // The number of remaining retries. -1 if unkown.
};
[Pref="dom.icc.enabled",
CheckPermissions="mobileconnection",
AvailableIn="CertifiedApps"]
@ -247,6 +257,7 @@ interface MozIcc : EventTarget
* The request's result will be an object containing
* information about the specified lock's status.
* e.g. {enabled: true}.
* @see IccCardLockStatus.
*/
[Throws]
DOMRequest getCardLock(IccLockType lockType);
@ -289,8 +300,8 @@ interface MozIcc : EventTarget
*
* @return a DOMRequest.
* The request's result will be an object containing the number of
* remaining retries.
* e.g. {retryCount: 3}.
* remaining retries. e.g. {retryCount: 3}.
* @see IccCardLockRetryCount.
*/
[Throws]
DOMRequest getCardLockRetryCount(IccLockType lockType);

View File

@ -213,6 +213,7 @@ static void Shutdown();
#include "mozilla/dom/nsCSPService.h"
#include "mozilla/dom/nsCSPContext.h"
#include "nsICellBroadcastService.h"
#include "nsIIccService.h"
#include "nsISmsService.h"
#include "nsIMmsService.h"
#include "nsIMobileConnectionService.h"
@ -338,6 +339,7 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsICellBroadcastService,
NS_CreateCellBroadcastService)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService, NS_CreateSmsService)
#endif
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIIccService, NS_CreateIccService)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMmsService, NS_CreateMmsService)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageService,
NS_CreateMobileMessageService)
@ -798,6 +800,7 @@ NS_DEFINE_NAMED_CID(NS_VOICEMAIL_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_MOBILE_CONNECTION_SERVICE_CID);
NS_DEFINE_NAMED_CID(SMS_SERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(ICC_SERVICE_CID);
NS_DEFINE_NAMED_CID(MMS_SERVICE_CID);
NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_SERVICE_CID);
NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_DATABASE_SERVICE_CID);
@ -1092,6 +1095,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kCELLBROADCAST_SERVICE_CID, false, nullptr, nsICellBroadcastServiceConstructor },
{ &kSMS_SERVICE_CID, false, nullptr, nsISmsServiceConstructor },
#endif
{ &kICC_SERVICE_CID, false, nullptr, nsIIccServiceConstructor },
{ &kMMS_SERVICE_CID, false, nullptr, nsIMmsServiceConstructor },
{ &kMOBILE_MESSAGE_SERVICE_CID, false, nullptr, nsIMobileMessageServiceConstructor },
{ &kMOBILE_MESSAGE_DATABASE_SERVICE_CID, false, nullptr, nsIMobileMessageDatabaseServiceConstructor },
@ -1255,6 +1259,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ CELLBROADCAST_SERVICE_CONTRACTID, &kCELLBROADCAST_SERVICE_CID },
{ SMS_SERVICE_CONTRACTID, &kSMS_SERVICE_CID },
#endif
{ ICC_SERVICE_CONTRACTID, &kICC_SERVICE_CID },
{ MMS_SERVICE_CONTRACTID, &kMMS_SERVICE_CID },
{ MOBILE_MESSAGE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_SERVICE_CID },
{ MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_DATABASE_SERVICE_CID },