diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 517dce6325fc..4e0811646b6f 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 610ec7e757e0..632de92f308a 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 18b4702d28ea..c671e0e03fa4 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index e07e766f3b4c..d4d72a67d484 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 610ec7e757e0..632de92f308a 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 5da95adf2e9d..dc9f43451828 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index b65c34b43c81..57a190ca1947 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index fac79002bae5..0c7e9df1cdb6 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "842fd7448790cfaeaf0bf22164e599c74e9be0e9", + "revision": "1e5360b21cca807b2ea63ea8fb878b451131c9bd", "repo_path": "/integration/gaia-central" } diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 4502056aebd2..9829ae1ee1b9 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 21accb4f61d3..fd004381a46f 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index d26d8364099e..a28b38433feb 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index e33fcd97654d..0c7223fe2874 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index d42658104445..23b8e93684cd 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -698,6 +698,11 @@ DOMInterfaces = { 'notflattened': True }, +'MozCdmaIccInfo': { + 'headerFile': 'mozilla/dom/IccInfo.h', + 'nativeType': 'mozilla::dom::CdmaIccInfo', +}, + 'MozCellBroadcast': { 'nativeType': 'mozilla::dom::CellBroadcast', }, @@ -711,10 +716,19 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::CellBroadcastMessage', }, +'MozGsmIccInfo': { + 'headerFile': 'mozilla/dom/IccInfo.h', + 'nativeType': 'mozilla::dom::GsmIccInfo', +}, + 'MozIcc': { 'nativeType': 'mozilla::dom::Icc', }, +'MozIccInfo': { + 'nativeType': 'mozilla::dom::IccInfo', +}, + 'MozIccManager': { 'nativeType': 'mozilla::dom::IccManager', }, @@ -1794,7 +1808,6 @@ addExternalIface('MozControllers', nativeType='nsIControllers') addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True) addExternalIface('MozFrameRequestCallback', nativeType='nsIFrameRequestCallback', notflattened=True) -addExternalIface('MozIccInfo', headerFile='nsIDOMIccInfo.h') addExternalIface('MozMmsMessage') addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True) addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource', diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index 30bca7e8740d..605fbccae913 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -16,7 +16,7 @@ #include "mozilla/StaticPtr.h" #include "nsContentUtils.h" #include "nsIAudioManager.h" -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsIIccProvider.h" #include "nsIMobileConnectionInfo.h" #include "nsIMobileConnectionService.h" @@ -673,11 +673,11 @@ BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId) do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE_VOID(icc); - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo)); NS_ENSURE_TRUE_VOID(iccInfo); - nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); + nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); NS_ENSURE_TRUE_VOID(gsmIccInfo); gsmIccInfo->GetMsisdn(mMsisdn); } diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.cpp b/dom/bluetooth/bluez/BluetoothHfpManager.cpp index 49a1faa1d961..da082358cdec 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp @@ -27,7 +27,7 @@ #include "mozilla/dom/SettingChangeNotificationBinding.h" #ifdef MOZ_B2G_RIL -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsIIccProvider.h" #include "nsIMobileConnectionInfo.h" #include "nsIMobileConnectionService.h" @@ -674,11 +674,11 @@ BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId) do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE_VOID(icc); - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo)); NS_ENSURE_TRUE_VOID(iccInfo); - nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); + nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); NS_ENSURE_TRUE_VOID(gsmIccInfo); gsmIccInfo->GetMsisdn(mMsisdn); } diff --git a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp index 1803844ca545..a4b83d4cba78 100644 --- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp @@ -16,7 +16,7 @@ #include "mozilla/StaticPtr.h" #include "nsContentUtils.h" #include "nsIAudioManager.h" -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsIIccProvider.h" #include "nsIMobileConnectionInfo.h" #include "nsIMobileConnectionService.h" @@ -678,11 +678,11 @@ BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId) do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE_VOID(icc); - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo)); NS_ENSURE_TRUE_VOID(iccInfo); - nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); + nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); NS_ENSURE_TRUE_VOID(gsmIccInfo); gsmIccInfo->GetMsisdn(mMsisdn); } diff --git a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp index b6ebb13a964b..dcede69cbda5 100644 --- a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp @@ -27,7 +27,7 @@ #include "mozilla/dom/SettingChangeNotificationBinding.h" #ifdef MOZ_B2G_RIL -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsIIccProvider.h" #include "nsIMobileConnectionInfo.h" #include "nsIMobileConnectionService.h" @@ -674,11 +674,11 @@ BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId) do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE_VOID(icc); - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo)); NS_ENSURE_TRUE_VOID(iccInfo); - nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); + nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); NS_ENSURE_TRUE_VOID(gsmIccInfo); gsmIccInfo->GetMsisdn(mMsisdn); } diff --git a/dom/icc/Icc.cpp b/dom/icc/Icc.cpp index d99bc7948fd9..75856a5fa523 100644 --- a/dom/icc/Icc.cpp +++ b/dom/icc/Icc.cpp @@ -2,29 +2,43 @@ * 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 "Icc.h" +#include "mozilla/dom/Icc.h" +#include "mozilla/dom/DOMRequest.h" +#include "mozilla/dom/IccInfo.h" #include "mozilla/dom/MozIccBinding.h" #include "mozilla/dom/MozStkCommandEvent.h" -#include "mozilla/dom/DOMRequest.h" #include "mozilla/dom/ScriptSettings.h" -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" +#include "nsIIccProvider.h" #include "nsJSON.h" #include "nsRadioInterfaceLayer.h" #include "nsServiceManagerUtils.h" using namespace mozilla::dom; -Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, const nsAString& aIccId) +NS_IMPL_CYCLE_COLLECTION_INHERITED(Icc, DOMEventTargetHelper, mIccInfo) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Icc) +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) : mLive(true) , mClientId(aClientId) - , mIccId(aIccId) { SetIsDOMBinding(); BindToOwner(aWindow); mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID); + if (aIccInfo) { + aIccInfo->GetIccid(mIccId); + UpdateIccInfo(aIccInfo); + } + // Not being able to acquire the provider isn't fatal since we check // for it explicitly below. if (!mProvider) { @@ -35,6 +49,7 @@ Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, const nsAString& aIccId) void Icc::Shutdown() { + mIccInfo.SetNull(); mProvider = nullptr; mLive = false; } @@ -74,6 +89,38 @@ Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage) return DispatchTrustedEvent(event); } +void +Icc::UpdateIccInfo(nsIIccInfo* aIccInfo) +{ + if (!aIccInfo) { + mIccInfo.SetNull(); + return; + } + + nsCOMPtr gsmIccInfo(do_QueryInterface(aIccInfo)); + if (gsmIccInfo) { + if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozGsmIccInfo()) { + mIccInfo.SetValue().SetAsMozGsmIccInfo() = new GsmIccInfo(GetOwner()); + } + mIccInfo.Value().GetAsMozGsmIccInfo().get()->Update(gsmIccInfo); + return; + } + + nsCOMPtr cdmaIccInfo(do_QueryInterface(aIccInfo)); + if (cdmaIccInfo) { + if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozCdmaIccInfo()) { + mIccInfo.SetValue().SetAsMozCdmaIccInfo() = new CdmaIccInfo(GetOwner()); + } + mIccInfo.Value().GetAsMozCdmaIccInfo().get()->Update(cdmaIccInfo); + return; + } + + if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozIccInfo()) { + mIccInfo.SetValue().SetAsMozIccInfo() = new IccInfo(GetOwner()); + } + mIccInfo.Value().GetAsMozIccInfo().get()->Update(aIccInfo); +} + // WrapperCache JSObject* @@ -84,20 +131,10 @@ Icc::WrapObject(JSContext* aCx) // MozIcc WebIDL -already_AddRefed -Icc::GetIccInfo() const +void +Icc::GetIccInfo(Nullable& aIccInfo) const { - if (!mProvider) { - return nullptr; - } - - nsCOMPtr iccInfo; - nsresult rv = mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo)); - if (NS_FAILED(rv)) { - return nullptr; - } - - return iccInfo.forget(); + aIccInfo = mIccInfo; } void diff --git a/dom/icc/Icc.h b/dom/icc/Icc.h index 04eec79f1d3a..bc82d3f5eefb 100644 --- a/dom/icc/Icc.h +++ b/dom/icc/Icc.h @@ -5,8 +5,11 @@ #ifndef mozilla_dom_Icc_h #define mozilla_dom_Icc_h +#include "mozilla/dom/UnionTypes.h" #include "mozilla/DOMEventTargetHelper.h" -#include "nsIIccProvider.h" + +class nsIIccInfo; +class nsIIccProvider; namespace mozilla { namespace dom { @@ -16,9 +19,11 @@ class DOMRequest; class Icc MOZ_FINAL : public DOMEventTargetHelper { public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Icc, DOMEventTargetHelper) NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) - Icc(nsPIDOMWindow* aWindow, long aClientId, const nsAString& aIccId); + Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo); void Shutdown(); @@ -35,6 +40,9 @@ public: return mIccId; } + void + UpdateIccInfo(nsIIccInfo* aIccInfo); + nsPIDOMWindow* GetParentObject() const { @@ -46,8 +54,8 @@ public: WrapObject(JSContext* aCx) MOZ_OVERRIDE; // MozIcc WebIDL - already_AddRefed - GetIccInfo() const; + void + GetIccInfo(Nullable& aIccInfo) const; void GetCardState(nsString& aCardState) const; @@ -116,6 +124,7 @@ private: // mProvider is a xpcom service and will be released at shutdown, so it // doesn't need to be cycle collected. nsCOMPtr mProvider; + Nullable mIccInfo; }; } // namespace dom diff --git a/dom/icc/IccInfo.cpp b/dom/icc/IccInfo.cpp new file mode 100644 index 000000000000..5080262ec5e0 --- /dev/null +++ b/dom/icc/IccInfo.cpp @@ -0,0 +1,230 @@ +/* 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 "mozilla/dom/IccInfo.h" + +#include "nsPIDOMWindow.h" + +#define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum) \ +{ \ + uint32_t i = 0; \ + for (const EnumEntry* entry = _enumType##Values::strings; \ + entry->value; \ + ++entry, ++i) { \ + if (_string.EqualsASCII(entry->value)) { \ + _enum.SetValue(static_cast<_enumType>(i)); \ + } \ + } \ +} + +using namespace mozilla::dom; + +// IccInfo + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IccInfo, mWindow, mIccInfo) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(IccInfo) +NS_IMPL_CYCLE_COLLECTING_RELEASE(IccInfo) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IccInfo) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +IccInfo::IccInfo(nsPIDOMWindow* aWindow) + : mWindow(aWindow) +{ + SetIsDOMBinding(); +} + +void +IccInfo::Update(nsIIccInfo* aInfo) +{ + mIccInfo = aInfo; +} + +JSObject* +IccInfo::WrapObject(JSContext* aCx) +{ + return MozIccInfoBinding::Wrap(aCx, this); +} + +Nullable +IccInfo::GetIccType() const +{ + if (!mIccInfo) { + return Nullable(); + } + + nsAutoString type; + Nullable iccType; + + mIccInfo->GetIccType(type); + CONVERT_STRING_TO_NULLABLE_ENUM(type, IccType, iccType); + + return iccType; +} + +void +IccInfo::GetIccid(nsAString& aIccId) const +{ + if (!mIccInfo) { + aIccId.SetIsVoid(true); + return; + } + + mIccInfo->GetIccid(aIccId); +} + +void +IccInfo::GetMcc(nsAString& aMcc) const +{ + if (!mIccInfo) { + aMcc.SetIsVoid(true); + return; + } + + mIccInfo->GetMcc(aMcc); +} + +void +IccInfo::GetMnc(nsAString& aMnc) const +{ + if (!mIccInfo) { + aMnc.SetIsVoid(true); + return; + } + + mIccInfo->GetMnc(aMnc); +} + +void +IccInfo::GetSpn(nsAString& aSpn) const +{ + if (!mIccInfo) { + aSpn.SetIsVoid(true); + return; + } + + mIccInfo->GetSpn(aSpn); +} + +bool +IccInfo::IsDisplayNetworkNameRequired() const +{ + if (!mIccInfo) { + return false; + } + + bool isDisplayNetworkNameRequired; + mIccInfo->GetIsDisplayNetworkNameRequired(&isDisplayNetworkNameRequired); + + return isDisplayNetworkNameRequired; +} + +bool +IccInfo::IsDisplaySpnRequired() const +{ + if (!mIccInfo) { + return false; + } + + bool isDisplaySpnRequired; + mIccInfo->GetIsDisplaySpnRequired(&isDisplaySpnRequired); + + return isDisplaySpnRequired; +} + +// GsmIccInfo + +NS_IMPL_CYCLE_COLLECTION_INHERITED(GsmIccInfo, IccInfo, mGsmIccInfo) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GsmIccInfo) +NS_INTERFACE_MAP_END_INHERITING(IccInfo) + +NS_IMPL_ADDREF_INHERITED(GsmIccInfo, IccInfo) +NS_IMPL_RELEASE_INHERITED(GsmIccInfo, IccInfo) + +GsmIccInfo::GsmIccInfo(nsPIDOMWindow* aWindow) + : IccInfo(aWindow) +{ + SetIsDOMBinding(); +} + +void +GsmIccInfo::Update(nsIGsmIccInfo* aInfo) +{ + IccInfo::Update(aInfo); + mGsmIccInfo = aInfo; +} + +JSObject* +GsmIccInfo::WrapObject(JSContext* aCx) +{ + return MozGsmIccInfoBinding::Wrap(aCx, this); +} + +void +GsmIccInfo::GetMsisdn(nsAString& aMsisdn) const +{ + if (!mGsmIccInfo) { + aMsisdn.SetIsVoid(true); + return; + } + + mGsmIccInfo->GetMsisdn(aMsisdn); +} + +// CdmaIccInfo + +NS_IMPL_CYCLE_COLLECTION_INHERITED(CdmaIccInfo, IccInfo, mCdmaIccInfo) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CdmaIccInfo) +NS_INTERFACE_MAP_END_INHERITING(IccInfo) + +NS_IMPL_ADDREF_INHERITED(CdmaIccInfo, IccInfo) +NS_IMPL_RELEASE_INHERITED(CdmaIccInfo, IccInfo) + +CdmaIccInfo::CdmaIccInfo(nsPIDOMWindow* aWindow) + : IccInfo(aWindow) +{ + SetIsDOMBinding(); +} + +void +CdmaIccInfo::Update(nsICdmaIccInfo* aInfo) +{ + IccInfo::Update(aInfo); + mCdmaIccInfo = aInfo; +} + +JSObject* +CdmaIccInfo::WrapObject(JSContext* aCx) +{ + return MozCdmaIccInfoBinding::Wrap(aCx, this); +} + +void +CdmaIccInfo::GetMdn(nsAString& aMdn) const +{ + if (!mCdmaIccInfo) { + aMdn.SetIsVoid(true); + return; + } + + mCdmaIccInfo->GetMdn(aMdn); +} + +int32_t +CdmaIccInfo::PrlVersion() const +{ + if (!mCdmaIccInfo) { + return 0; + } + + int32_t prlVersion; + mCdmaIccInfo->GetPrlVersion(&prlVersion); + + return prlVersion; +} diff --git a/dom/icc/IccInfo.h b/dom/icc/IccInfo.h new file mode 100644 index 000000000000..1e51af805a6b --- /dev/null +++ b/dom/icc/IccInfo.h @@ -0,0 +1,128 @@ +/* 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_IccInfo_h +#define mozilla_dom_IccInfo_h + +#include "MozIccInfoBinding.h" +#include "nsIIccInfo.h" +#include "nsWrapperCache.h" + +class nsPIDOMWindow; + +namespace mozilla { +namespace dom { + +class IccInfo : public nsISupports + , public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IccInfo) + + explicit IccInfo(nsPIDOMWindow* aWindow); + + void + Update(nsIIccInfo* aInfo); + + nsPIDOMWindow* + GetParentObject() const + { + return mWindow; + } + + // WrapperCache + virtual JSObject* + WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + // WebIDL interface + Nullable + GetIccType() const; + + void + GetIccid(nsAString& aIccId) const; + + void + GetMcc(nsAString& aMcc) const; + + void + GetMnc(nsAString& aMnc) const; + + void + GetSpn(nsAString& aSpn) const; + + bool + IsDisplayNetworkNameRequired() const; + + bool + IsDisplaySpnRequired() const; + +protected: + ~IccInfo() {} + +protected: + nsCOMPtr mWindow; + nsCOMPtr mIccInfo; +}; + +class GsmIccInfo MOZ_FINAL : public IccInfo +{ +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GsmIccInfo, IccInfo) + + explicit GsmIccInfo(nsPIDOMWindow* aWindow); + + void + Update(nsIGsmIccInfo* aInfo); + + // WrapperCache + virtual JSObject* + WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + // MozCdmaIccInfo WebIDL + void + GetMsisdn(nsAString& aMsisdn) const; + +private: + ~GsmIccInfo() {} + +private: + nsCOMPtr mGsmIccInfo; +}; + +class CdmaIccInfo MOZ_FINAL : public IccInfo +{ +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CdmaIccInfo, IccInfo) + + explicit CdmaIccInfo(nsPIDOMWindow* aWindow); + + void + Update(nsICdmaIccInfo* aInfo); + + // WrapperCache + virtual JSObject* + WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + // MozCdmaIccInfo WebIDL + void + GetMdn(nsAString& aMdn) const; + + int32_t + PrlVersion() const; + +private: + ~CdmaIccInfo() {} + +private: + nsCOMPtr mCdmaIccInfo; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_IccInfo_h + diff --git a/dom/icc/IccListener.cpp b/dom/icc/IccListener.cpp index 7a2fa3fcc26d..911974c9bcce 100644 --- a/dom/icc/IccListener.cpp +++ b/dom/icc/IccListener.cpp @@ -7,7 +7,7 @@ #include "Icc.h" #include "IccManager.h" #include "nsIDOMClassInfo.h" -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsRadioInterfaceLayer.h" using namespace mozilla::dom; @@ -27,13 +27,13 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId) return; } - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo)); if (iccInfo) { nsString iccId; iccInfo->GetIccid(iccId); if (!iccId.IsEmpty()) { - mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccId); + mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo); } } @@ -98,7 +98,7 @@ IccListener::NotifyCardStateChanged() NS_IMETHODIMP IccListener::NotifyIccInfoChanged() { - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo)); // Create/delete icc object based on current iccInfo. @@ -111,12 +111,13 @@ IccListener::NotifyIccInfoChanged() nsString iccId; iccInfo->GetIccid(iccId); if (!iccId.IsEmpty()) { - mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccId); + mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo); mIccManager->NotifyIccAdd(iccId); mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange")); } } } else { + mIcc->UpdateIccInfo(iccInfo); mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange")); if (!iccInfo) { nsString iccId = mIcc->GetIccId(); diff --git a/dom/icc/IccManager.cpp b/dom/icc/IccManager.cpp index dcc35c563395..59270ad8f430 100644 --- a/dom/icc/IccManager.cpp +++ b/dom/icc/IccManager.cpp @@ -8,7 +8,7 @@ #include "IccListener.h" #include "mozilla/dom/IccChangeEvent.h" #include "mozilla/Preferences.h" -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" using namespace mozilla::dom; diff --git a/dom/icc/interfaces/moz.build b/dom/icc/interfaces/moz.build index 98be41672795..aece507e3124 100644 --- a/dom/icc/interfaces/moz.build +++ b/dom/icc/interfaces/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. XPIDL_SOURCES += [ - 'nsIDOMIccInfo.idl', + 'nsIIccInfo.idl', 'nsIIccProvider.idl', ] diff --git a/dom/icc/interfaces/nsIDOMIccInfo.idl b/dom/icc/interfaces/nsIIccInfo.idl similarity index 82% rename from dom/icc/interfaces/nsIDOMIccInfo.idl rename to dom/icc/interfaces/nsIIccInfo.idl index d3ad761ff7f4..8dc26d8559ab 100644 --- a/dom/icc/interfaces/nsIDOMIccInfo.idl +++ b/dom/icc/interfaces/nsIIccInfo.idl @@ -4,8 +4,8 @@ #include "nsISupports.idl" -[scriptable, uuid(dd9f229c-e5a6-453a-8388-950af0ff9918)] -interface nsIDOMMozIccInfo : nsISupports +[scriptable, uuid(3ba11a90-34e0-11e4-8c21-0800200c9a66)] +interface nsIIccInfo : nsISupports { /** * Integrated Circuit Card Type. @@ -45,8 +45,8 @@ interface nsIDOMMozIccInfo : nsISupports readonly attribute boolean isDisplaySpnRequired; }; -[scriptable, uuid(3c237e39-7af3-4748-baf4-4a3b6c3e0e66)] -interface nsIDOMMozGsmIccInfo : nsIDOMMozIccInfo +[scriptable, uuid(6c9c78b0-34e0-11e4-8c21-0800200c9a66)] +interface nsIGsmIccInfo : nsIIccInfo { /** * Mobile Station ISDN Number (MSISDN) of the subscriber, aka @@ -55,8 +55,8 @@ interface nsIDOMMozGsmIccInfo : nsIDOMMozIccInfo readonly attribute DOMString msisdn; }; -[scriptable, uuid(7e937d09-4d1d-43c5-96d8-c91396022809)] -interface nsIDOMMozCdmaIccInfo : nsIDOMMozIccInfo +[scriptable, uuid(7452f570-34e0-11e4-8c21-0800200c9a66)] +interface nsICdmaIccInfo : nsIIccInfo { /** * Mobile Directory Number (MDN) of the subscriber, aka his phone number. diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl index 066b42c9fd81..b7cea656d1ed 100644 --- a/dom/icc/interfaces/nsIIccProvider.idl +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -5,8 +5,8 @@ #include "nsISupports.idl" interface nsIDOMDOMRequest; -interface nsIDOMMozIccInfo; interface nsIDOMWindow; +interface nsIIccInfo; [scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)] interface nsIIccListener : nsISupports @@ -20,7 +20,7 @@ interface nsIIccListener : nsISupports /** * XPCOM component (in the content process) that provides the ICC information. */ -[scriptable, uuid(7c67ab92-52a3-4e11-995c-c0ad2f66c4cb)] +[scriptable, uuid(1afa72d0-3d70-11e4-916c-0800200c9a66)] interface nsIIccProvider : nsISupports { /** @@ -34,7 +34,7 @@ interface nsIIccProvider : nsISupports /** * UICC Information */ - nsIDOMMozIccInfo getIccInfo(in unsigned long clientId); + nsIIccInfo getIccInfo(in unsigned long clientId); /** * Card State diff --git a/dom/icc/moz.build b/dom/icc/moz.build index 65d15e16e3a8..e87a6e726def 100644 --- a/dom/icc/moz.build +++ b/dom/icc/moz.build @@ -8,11 +8,13 @@ DIRS += ['interfaces'] EXPORTS.mozilla.dom += [ 'Icc.h', + 'IccInfo.h', 'IccManager.h', ] UNIFIED_SOURCES += [ 'Icc.cpp', + "IccInfo.cpp", 'IccListener.cpp', 'IccManager.cpp', ] diff --git a/dom/icc/tests/IccInfo.cpp b/dom/icc/tests/IccInfo.cpp new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/dom/icc/tests/marionette/test_icc_info.js b/dom/icc/tests/marionette/test_icc_info.js index f441a9c8a23b..a74b79884282 100644 --- a/dom/icc/tests/marionette/test_icc_info.js +++ b/dom/icc/tests/marionette/test_icc_info.js @@ -35,7 +35,7 @@ taskHelper.push(function basicTest() { // See it here {B2G_HOME}/external/qemu/telephony/sim_card.c#L299. is(iccInfo.iccid, 89014103211118510720); - if (iccInfo instanceof Ci.nsIDOMMozGsmIccInfo) { + if (iccInfo instanceof MozGsmIccInfo) { log("Test Gsm IccInfo"); is(iccInfo.iccType, "sim"); is(iccInfo.spn, "Android"); diff --git a/dom/mobilemessage/gonk/MmsService.js b/dom/mobilemessage/gonk/MmsService.js index a474e9cd324e..ab0d8c8c2c87 100644 --- a/dom/mobilemessage/gonk/MmsService.js +++ b/dom/mobilemessage/gonk/MmsService.js @@ -339,10 +339,10 @@ MmsConnection.prototype = { * Get phone number from iccInfo. * * If the icc card is gsm card, the phone number is in msisdn. - * @see nsIDOMMozGsmIccInfo + * @see nsIGsmIccInfo * * Otherwise, the phone number is in mdn. - * @see nsIDOMMozCdmaIccInfo + * @see nsICdmaIccInfo */ getPhoneNumber: function() { let number; @@ -351,10 +351,10 @@ MmsConnection.prototype = { let iccInfo = null; let baseIccInfo = this.radioInterface.rilContext.iccInfo; if (baseIccInfo.iccType === 'ruim' || baseIccInfo.iccType === 'csim') { - iccInfo = baseIccInfo.QueryInterface(Ci.nsIDOMMozCdmaIccInfo); + iccInfo = baseIccInfo.QueryInterface(Ci.nsICdmaIccInfo); number = iccInfo.mdn; } else { - iccInfo = baseIccInfo.QueryInterface(Ci.nsIDOMMozGsmIccInfo); + iccInfo = baseIccInfo.QueryInterface(Ci.nsIGsmIccInfo); number = iccInfo.msisdn; } } catch (e) { diff --git a/dom/system/gonk/GonkGPSGeolocationProvider.cpp b/dom/system/gonk/GonkGPSGeolocationProvider.cpp index 59f19d90ae68..c19cfeb23cbe 100644 --- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp +++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp @@ -34,7 +34,7 @@ #include "prtime.h" #ifdef MOZ_B2G_RIL -#include "nsIDOMIccInfo.h" +#include "nsIIccInfo.h" #include "nsIMobileConnectionInfo.h" #include "nsIMobileConnectionService.h" #include "nsIMobileCellInfo.h" @@ -459,10 +459,10 @@ GonkGPSGeolocationProvider::RequestSetID(uint32_t flags) } if (flags & AGPS_RIL_REQUEST_SETID_MSISDN) { - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; rilCtx->GetIccInfo(getter_AddRefs(iccInfo)); if (iccInfo) { - nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); + nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); if (gsmIccInfo) { type = AGPS_SETID_TYPE_MSISDN; gsmIccInfo->GetMsisdn(id); @@ -494,7 +494,7 @@ GonkGPSGeolocationProvider::SetReferenceLocation() location.type = AGPS_REF_LOCATION_TYPE_UMTS_CELLID; if (rilCtx) { - nsCOMPtr iccInfo; + nsCOMPtr iccInfo; rilCtx->GetIccInfo(getter_AddRefs(iccInfo)); if (iccInfo) { nsresult result; diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index e8524ba77657..a128915d19c4 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -41,12 +41,6 @@ function debug(s) { const RILCONTENTHELPER_CID = Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}"); -const ICCINFO_CID = - Components.ID("{39d64d90-26a6-11e4-8c21-0800200c9a66}"); -const GSMICCINFO_CID = - Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}"); -const CDMAICCINFO_CID = - Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}"); const ICCCARDLOCKERROR_CID = Components.ID("{08a71987-408c-44ff-93fd-177c0a85c3dd}"); @@ -108,16 +102,9 @@ MobileIccCardLockRetryCount.prototype = { function IccInfo() {} IccInfo.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozIccInfo]), - classID: ICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: ICCINFO_CID, - classDescription: "MozIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccInfo]), - // nsIDOMMozIccInfo + // nsIIccInfo iccType: null, iccid: null, @@ -130,34 +117,20 @@ IccInfo.prototype = { function GsmIccInfo() {} GsmIccInfo.prototype = { - __proto__: IccInfo.prototype, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozGsmIccInfo]), - classID: GSMICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: GSMICCINFO_CID, - classDescription: "MozGsmIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozGsmIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIGsmIccInfo, + Ci.nsIIccInfo]), - // nsIDOMMozGsmIccInfo + // nsIGsmIccInfo msisdn: null }; function CdmaIccInfo() {} CdmaIccInfo.prototype = { - __proto__: IccInfo.prototype, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCdmaIccInfo]), - classID: CDMAICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: CDMAICCINFO_CID, - classDescription: "MozCdmaIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozCdmaIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsICdmaIccInfo, + Ci.nsIIccInfo]), - // nsIDOMMozCdmaIccInfo + // nsICdmaIccInfo mdn: null, prlVersion: 0 diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index cf78179d5492..0bc662acd4d2 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -53,12 +53,6 @@ const RADIOINTERFACE_CID = Components.ID("{6a7c91f0-a2b3-4193-8562-8969296c0b54}"); const RILNETWORKINTERFACE_CID = Components.ID("{3bdd52a9-3965-4130-b569-0ac5afed045e}"); -const ICCINFO_CID = - Components.ID("{52eec7f0-26a4-11e4-8c21-0800200c9a66}"); -const GSMICCINFO_CID = - Components.ID("{d90c4261-a99d-47bc-8b05-b057bb7e8f8a}"); -const CDMAICCINFO_CID = - Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}"); const NEIGHBORINGCELLINFO_CID = Components.ID("{f9dfe26a-851e-4a8b-a769-cbb1baae7ded}"); const GSMCELLINFO_CID = @@ -941,16 +935,9 @@ try { function IccInfo() {} IccInfo.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozIccInfo]), - classID: ICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: ICCINFO_CID, - classDescription: "MozIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccInfo]), - // nsIDOMMozIccInfo + // nsIIccInfo iccType: null, iccid: null, @@ -964,16 +951,10 @@ IccInfo.prototype = { function GsmIccInfo() {} GsmIccInfo.prototype = { __proto__: IccInfo.prototype, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozGsmIccInfo]), - classID: GSMICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: GSMICCINFO_CID, - classDescription: "MozGsmIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozGsmIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIGsmIccInfo, + Ci.nsIIccInfo]), - // nsIDOMMozGsmIccInfo + // nsIGsmIccInfo msisdn: null }; @@ -981,16 +962,10 @@ GsmIccInfo.prototype = { function CdmaIccInfo() {} CdmaIccInfo.prototype = { __proto__: IccInfo.prototype, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCdmaIccInfo]), - classID: CDMAICCINFO_CID, - classInfo: XPCOMUtils.generateCI({ - classID: CDMAICCINFO_CID, - classDescription: "MozCdmaIccInfo", - flags: Ci.nsIClassInfo.DOM_OBJECT, - interfaces: [Ci.nsIDOMMozCdmaIccInfo] - }), + QueryInterface: XPCOMUtils.generateQI([Ci.nsICdmaIccInfo, + Ci.nsIIccInfo]), - // nsIDOMMozCdmaIccInfo + // nsICdmaIccInfo mdn: null, prlVersion: 0 @@ -2141,10 +2116,10 @@ RadioInterface.prototype = { * Get phone number from iccInfo. * * If the icc card is gsm card, the phone number is in msisdn. - * @see nsIDOMMozGsmIccInfo + * @see nsIGsmIccInfo * * Otherwise, the phone number is in mdn. - * @see nsIDOMMozCdmaIccInfo + * @see nsICdmaIccInfo */ getPhoneNumber: function() { let iccInfo = this.rilContext.iccInfo; @@ -2154,7 +2129,7 @@ RadioInterface.prototype = { } // After moving SMS code out of RadioInterfaceLayer, we could use - // |iccInfo instanceof Ci.nsIDOMMozGsmIccInfo| here. + // |iccInfo instanceof Ci.nsIGsmIccInfo| here. // TODO: Bug 873351 - B2G SMS: move SMS code out of RadioInterfaceLayer to // SmsService let number = (iccInfo instanceof GsmIccInfo) ? iccInfo.msisdn : iccInfo.mdn; diff --git a/dom/system/gonk/nsIRadioInterfaceLayer.idl b/dom/system/gonk/nsIRadioInterfaceLayer.idl index aa4e14a35fd9..1fdd74219c62 100644 --- a/dom/system/gonk/nsIRadioInterfaceLayer.idl +++ b/dom/system/gonk/nsIRadioInterfaceLayer.idl @@ -5,11 +5,11 @@ #include "nsISupports.idl" #include "nsINetworkManager.idl" -interface nsIDOMMozIccInfo; +interface nsICellInfoListCallback; +interface nsIIccInfo; interface nsIMobileConnectionInfo; interface nsIMobileMessageCallback; interface nsINeighboringCellIdsCallback; -interface nsICellInfoListCallback; [scriptable, uuid(6e0f45b8-410e-11e3-8c8e-b715b2cd0128)] interface nsIRilNetworkInterface : nsINetworkInterface @@ -23,14 +23,14 @@ interface nsIRilNetworkInterface : nsINetworkInterface readonly attribute long mmsPort; // -1 if not set. }; -[scriptable, uuid(0226a2c1-a3b9-416a-92cb-c89e4dad4be0)] +[scriptable, uuid(08a69c70-34b1-11e4-8c21-0800200c9a66)] interface nsIRilContext : nsISupports { readonly attribute DOMString cardState; readonly attribute DOMString imsi; - readonly attribute nsIDOMMozIccInfo iccInfo; + readonly attribute nsIIccInfo iccInfo; }; [scriptable, function, uuid(3bc96351-53b0-47a1-a888-c74c64b60f25)] diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 32249a1f2c5a..e0bd6bb922ce 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -2725,6 +2725,13 @@ RilObject.prototype = { queryCallBarringStatus: function(options) { options.facility = CALL_BARRING_PROGRAM_TO_FACILITY[options.program]; options.password = ""; // For query no need to provide it. + + // For some operators, querying specific serviceClass doesn't work. We use + // serviceClass 0 instead, and then process the response to extract the + // answer for queryServiceClass. + options.queryServiceClass = options.serviceClass; + options.serviceClass = 0; + this.queryICCFacilityLock(options); }, @@ -5930,20 +5937,23 @@ RilObject.prototype[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILI return; } - let services; - if (length) { - // Buf.readInt32List()[0] for Call Barring is a bit vector of services. - services = this.context.Buf.readInt32List()[0]; - } else { + if (!length) { options.success = false; options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; this.sendChromeMessage(options); return; } - options.enabled = services === 0 ? false : true; + // Buf.readInt32List()[0] for Call Barring is a bit vector of services. + let services = this.context.Buf.readInt32List()[0]; - if (options.success && (options.rilMessageType === "sendMMI")) { + if (options.queryServiceClass) { + options.enabled = (services & options.queryServiceClass) ? true : false; + } else { + options.enabled = services ? true : false; + } + + if (options.rilMessageType === "sendMMI") { if (!options.enabled) { options.statusMessage = MMI_SM_KS_SERVICE_DISABLED; } else { diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 8bc1acff77f9..ff179a4cf9cb 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -700,16 +700,22 @@ var interfaceNamesInGlobalScope = "MozCSSKeyframeRule", // IMPORTANT: Do not change this list without review from a DOM peer! "MozCSSKeyframesRule", +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "MozCdmaIccInfo", b2g: true, pref: "dom.icc.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozEmergencyCbModeEvent", b2g: true, pref: "dom.mobileconnection.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozIcc", b2g: true, pref: "dom.icc.enabled"}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "MozIccInfo", b2g: true, pref: "dom.icc.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozIccManager", b2g: true, pref: "dom.icc.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozInputContext", b2g: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozInputMethodManager", b2g: true}, +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "MozGsmIccInfo", b2g: true, pref: "dom.icc.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "MozMessageDeletedEvent", b2g: true, pref: "dom.sms.enabled"}, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/MozIcc.webidl b/dom/webidl/MozIcc.webidl index 40621df0b1e4..9d3f09b402e1 100644 --- a/dom/webidl/MozIcc.webidl +++ b/dom/webidl/MozIcc.webidl @@ -2,8 +2,6 @@ * 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/. */ -interface MozIccInfo; - [Pref="dom.icc.enabled"] interface MozIcc : EventTarget { @@ -16,7 +14,7 @@ interface MozIcc : EventTarget * Also, the attribute is set to null and this MozIcc object becomes invalid. * Calling asynchronous functions raises exception then. */ - readonly attribute MozIccInfo? iccInfo; + readonly attribute (MozIccInfo or MozGsmIccInfo or MozCdmaIccInfo)? iccInfo; /** * The 'iccinfochange' event is notified whenever the icc info object diff --git a/dom/webidl/MozIccInfo.webidl b/dom/webidl/MozIccInfo.webidl new file mode 100644 index 000000000000..53b6049d33bd --- /dev/null +++ b/dom/webidl/MozIccInfo.webidl @@ -0,0 +1,65 @@ +/* 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/. */ + +enum IccType {"sim", "usim", "csim", "ruim"}; + +[Pref="dom.icc.enabled"] +interface MozIccInfo { + /** + * Integrated Circuit Card Type. + */ + readonly attribute IccType? iccType; + + /** + * Integrated Circuit Card Identifier. + */ + readonly attribute DOMString? iccid; + + /** + * Mobile Country Code (MCC) of the subscriber's home network. + */ + readonly attribute DOMString? mcc; + + /** + * Mobile Network Code (MNC) of the subscriber's home network. + */ + readonly attribute DOMString? mnc; + + /** + * Service Provider Name (SPN) of the subscriber's home network. + */ + readonly attribute DOMString? spn; + + /** + * Network name must be a part of displayed carrier name. + */ + readonly attribute boolean isDisplayNetworkNameRequired; + + /** + * Service provider name must be a part of displayed carrier name. + */ + readonly attribute boolean isDisplaySpnRequired; +}; + +[Pref="dom.icc.enabled"] +interface MozGsmIccInfo : MozIccInfo { + /** + * Mobile Station ISDN Number (MSISDN) of the subscriber, aka + * his phone number. + */ + readonly attribute DOMString? msisdn; +}; + +[Pref="dom.icc.enabled"] +interface MozCdmaIccInfo : MozIccInfo { + /** + * Mobile Directory Number (MDN) of the subscriber, aka his phone number. + */ + readonly attribute DOMString? mdn; + + /** + * Preferred Roaming List (PRL) version of the subscriber. + */ + readonly attribute long prlVersion; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 5a049a2b406b..2fe400636b0d 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -616,6 +616,7 @@ if CONFIG['MOZ_B2G_RIL']: WEBIDL_FILES += [ 'IccCardLockError.webidl', 'MozIcc.webidl', + 'MozIccInfo.webidl', 'MozIccManager.webidl', ] diff --git a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp index ff85e95dce81..7a7b93eabd8f 100644 --- a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp +++ b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp @@ -49,6 +49,7 @@ RTSPSource::RTSPSource( mFinalResult(OK), mDisconnectReplyID(0), mLatestPausedUnit(0), + mPlayPending(false), mSeekGeneration(0) { @@ -213,11 +214,19 @@ void RTSPSource::performPlay(int64_t playTimeUs) { start(); return; } - if (mState != CONNECTED && mState != PAUSING) { + // If state is PAUSING, which means a previous PAUSE request is still being + // processed, put off the PLAY request until PausedDone. + if (mState == PAUSING) { + mPlayPending = true; return; } - if (mState == PAUSING) { - playTimeUs = mLatestPausedUnit; + // Reject invalid state transition. + if (mState != CONNECTED && mState != PAUSED) { + return; + } + // Use the latest received frame time if we were paused. + if (mState == PAUSED) { + playTimeUs = mLatestPausedUnit; } int64_t duration = 0; @@ -225,7 +234,7 @@ void RTSPSource::performPlay(int64_t playTimeUs) { MOZ_ASSERT(playTimeUs < duration, "Should never receive an out of bounds play time!"); if (playTimeUs >= duration) { - return; + return; } LOGI("performPlay : duration=%lld playTimeUs=%lld", duration, playTimeUs); @@ -234,13 +243,14 @@ void RTSPSource::performPlay(int64_t playTimeUs) { } void RTSPSource::performPause() { + // Reject invalid state transition. if (mState != PLAYING) { return; } LOGI("performPause :"); for (size_t i = 0; i < mTracks.size(); ++i) { - TrackInfo *info = &mTracks.editItemAt(i); - info->mLatestPausedUnit = 0; + TrackInfo *info = &mTracks.editItemAt(i); + info->mLatestPausedUnit = 0; } mLatestPausedUnit = 0; @@ -257,16 +267,17 @@ void RTSPSource::performSuspend() { } void RTSPSource::performPlaybackEnded() { - // Transition from PLAYING to CONNECTED state so that we are ready to - // perform an another play operation. + // Reject invalid state transition. if (mState != PLAYING) { return; } + // Transition from PLAYING to CONNECTED state so that we are ready to + // perform an another play operation. mState = CONNECTED; } void RTSPSource::performSeek(int64_t seekTimeUs) { - if (mState != CONNECTED && mState != PLAYING && mState != PAUSING) { + if (mState != CONNECTED && mState != PLAYING && mState != PAUSED) { return; } @@ -275,12 +286,12 @@ void RTSPSource::performSeek(int64_t seekTimeUs) { MOZ_ASSERT(seekTimeUs < duration, "Should never receive an out of bounds seek time!"); if (seekTimeUs >= duration) { - return; + return; } for (size_t i = 0; i < mTracks.size(); ++i) { - TrackInfo *info = &mTracks.editItemAt(i); - info->mLatestPausedUnit = 0; + TrackInfo *info = &mTracks.editItemAt(i); + info->mLatestPausedUnit = 0; } mLatestPausedUnit = 0; @@ -366,6 +377,12 @@ void RTSPSource::onMessageReceived(const sp &msg) { case RtspConnectionHandler::kWhatPausedDone: { + // Reject invalid state transition. + if (mState != PAUSING) { + return; + } + mState = PAUSED; + for (size_t i = 0; i < mTracks.size(); ++i) { TrackInfo *info = &mTracks.editItemAt(i); info->mLatestPausedUnit = info->mLatestReceivedUnit; @@ -381,6 +398,11 @@ void RTSPSource::onMessageReceived(const sp &msg) { mLatestPausedUnit = info->mLatestReceivedUnit; } } + + if (mPlayPending) { + mPlayPending = false; + performPlay(mLatestPausedUnit); + } break; } @@ -431,7 +453,7 @@ void RTSPSource::onMessageReceived(const sp &msg) { info->mLatestReceivedUnit = nptUs; // Drop the frames that are older than the frames in the queue. if (info->mLatestPausedUnit && (int64_t)info->mLatestPausedUnit > nptUs) { - break; + break; } source->queueAccessUnit(accessUnit); } @@ -576,17 +598,17 @@ void RTSPSource::onConnected(bool isSeekable) meta->SetDuration(int64Value); if (isAudio) { - CHECK(format->findInt32(kKeyChannelCount, &int32Value)); - meta->SetChannelCount(int32Value); + CHECK(format->findInt32(kKeyChannelCount, &int32Value)); + meta->SetChannelCount(int32Value); - CHECK(format->findInt32(kKeySampleRate, &int32Value)); - meta->SetSampleRate(int32Value); + CHECK(format->findInt32(kKeySampleRate, &int32Value)); + meta->SetSampleRate(int32Value); } else { - CHECK(format->findInt32(kKeyWidth, &int32Value)); - meta->SetWidth(int32Value); + CHECK(format->findInt32(kKeyWidth, &int32Value)); + meta->SetWidth(int32Value); - CHECK(format->findInt32(kKeyHeight, &int32Value)); - meta->SetHeight(int32Value); + CHECK(format->findInt32(kKeyHeight, &int32Value)); + meta->SetHeight(int32Value); } // Optional meta data. @@ -595,15 +617,15 @@ void RTSPSource::onConnected(bool isSeekable) size_t length = 0; if (format->findData(kKeyESDS, &type, &data, &length)) { - nsCString esds; - esds.Assign((const char *)data, length); - meta->SetEsdsData(esds); + nsCString esds; + esds.Assign((const char *)data, length); + meta->SetEsdsData(esds); } if (format->findData(kKeyAVCC, &type, &data, &length)) { - nsCString avcc; - avcc.Assign((const char *)data, length); - meta->SetAvccData(avcc); + nsCString avcc; + avcc.Assign((const char *)data, length); + meta->SetAvccData(avcc); } mListener->OnConnected(i, meta.get()); diff --git a/netwerk/protocol/rtsp/rtsp/RTSPSource.h b/netwerk/protocol/rtsp/rtsp/RTSPSource.h index e9a36e7dd728..327464017cc8 100644 --- a/netwerk/protocol/rtsp/rtsp/RTSPSource.h +++ b/netwerk/protocol/rtsp/rtsp/RTSPSource.h @@ -89,6 +89,7 @@ private: CONNECTED, SEEKING, PAUSING, + PAUSED, PLAYING, }; @@ -117,6 +118,7 @@ private: status_t mFinalResult; uint32_t mDisconnectReplyID; uint64_t mLatestPausedUnit; + bool mPlayPending; sp mLooper; sp > mReflector; diff --git a/services/mobileid/MobileIdentityManager.jsm b/services/mobileid/MobileIdentityManager.jsm index 3c3556fcc2b5..dcf5dc3f1cf2 100644 --- a/services/mobileid/MobileIdentityManager.jsm +++ b/services/mobileid/MobileIdentityManager.jsm @@ -280,8 +280,7 @@ this.MobileIdentityManager = { .then( (creds) => { if (creds) { - this.iccInfo[aServiceId].credentials = creds; - return; + return creds; } return this.credStore.getByMsisdn(this.iccInfo[aServiceId].msisdn); } @@ -306,10 +305,12 @@ this.MobileIdentityManager = { ) .then( (result) => { - log.debug("Discover result ${}", result); + // If we already have credentials for this ICC and no discover request + // is done, we just bail out. if (!result || !result.verificationMethods) { return; } + log.debug("Discover result ${}", result); this.iccInfo[aServiceId].verificationMethods = result.verificationMethods; this.iccInfo[aServiceId].verificationDetails = result.verificationDetails; this.iccInfo[aServiceId].canDoSilentVerification = @@ -675,14 +676,16 @@ this.MobileIdentityManager = { let mcc; // If the user selected one of the existing SIM cards we have to check - // that we either have the MSISDN for that SIM or we can do a silent - // verification that does not require us to have the MSISDN in advance. + // that we either have the MSISDN for that SIM, we have already existing + // credentials or we can do a silent verification that does not require + // us to have the MSISDN in advance. // result.serviceId can be "0". if (result.serviceId !== undefined && result.serviceId !== null) { let icc = this.iccInfo[result.serviceId]; log.debug("icc ${}", icc); - if (!icc || !icc.msisdn && !icc.canDoSilentVerification) { + if (!icc || !icc.msisdn && !icc.canDoSilentVerification && + !icc.credentials) { return Promise.reject(ERROR_INTERNAL_CANNOT_VERIFY_SELECTION); } msisdn = icc.msisdn; @@ -972,7 +975,12 @@ this.MobileIdentityManager = { // before generating and sharing the assertion. // If we've just prompted the user in the previous step, the permission // is already granted and stored so we just progress the credentials. + // But we have to refresh the cached permission before checking. if (creds) { + permission = permissionManager.testPermissionFromPrincipal( + principal, + MOBILEID_PERM + ); if (permission == Ci.nsIPermissionManager.ALLOW_ACTION) { return creds; } diff --git a/services/mobileid/tests/xpcshell/test_mobileid_manager.js b/services/mobileid/tests/xpcshell/test_mobileid_manager.js index aa2fdba7e37e..920ec8bc58b0 100644 --- a/services/mobileid/tests/xpcshell/test_mobileid_manager.js +++ b/services/mobileid/tests/xpcshell/test_mobileid_manager.js @@ -457,7 +457,7 @@ add_test(function() { credStore._("add").call(1).arg(2, PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, SESSION_TOKEN); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); // MockUI. @@ -960,10 +960,10 @@ add_test(function() { credStore._("add").call(1).arg(2, PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, SESSION_TOKEN); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); credStore._("setDeviceIccIds").callsLength(1); credStore._("setDeviceIccIds").call(1).arg(1, PHONE_NUMBER); - credStore._("setDeviceIccIds").call(1).arg(2, null); + credStore._("setDeviceIccIds").call(1).arg(2, []); // MockUI. ui._("startFlow").callsLength(1); @@ -1054,7 +1054,7 @@ add_test(function() { credStore._("add").call(1).arg(2, ANOTHER_PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, _sessionToken); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); credStore._("setDeviceIccIds").callsLength(0); credStore._("removeOrigin").callsLength(1); credStore._("removeOrigin").call(1).arg(1, PHONE_NUMBER); @@ -1139,7 +1139,7 @@ add_test(function() { credStore._("add").call(1).arg(2, PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, _sessionToken); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); credStore._("setDeviceIccIds").callsLength(1); credStore._("removeOrigin").callsLength(0); @@ -1229,7 +1229,7 @@ add_test(function() { credStore._("add").call(1).arg(2, ANOTHER_PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, _sessionToken); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); credStore._("setDeviceIccIds").callsLength(0); credStore._("removeOrigin").callsLength(1); credStore._("removeOrigin").call(1).arg(1, PHONE_NUMBER); @@ -1278,7 +1278,7 @@ add_test(function() { sessionToken: _sessionToken, msisdn: PHONE_NUMBER, origin: ORIGIN, - deviceIccIds: null + deviceIccIds: [] }; let ui = new MockUi({ @@ -1323,7 +1323,7 @@ add_test(function() { credStore._("add").call(1).arg(2, PHONE_NUMBER); credStore._("add").call(1).arg(3, ORIGIN); credStore._("add").call(1).arg(4, SESSION_TOKEN); - credStore._("add").call(1).arg(5, null); + credStore._("add").call(1).arg(5, []); credStore._("setDeviceIccIds").callsLength(0); credStore._("delete").callsLength(1); credStore._("delete").call(1).arg(1, PHONE_NUMBER); @@ -1383,12 +1383,8 @@ add_test(function() { MobileIdentityManager._mobileConnectionService = { _interfaces: [RADIO_INTERFACE, ANOTHER_RADIO_INTERFACE], - getVoiceConnectionInfo: function(aIndex) { - return this._interfaces[aIndex].voice; - }, - - getDataConnectionInfo: function(aIndex) { - return this._interfaces[aIndex].data; + getItemByServiceId: function(aIndex) { + return this._interfaces[aIndex]; } }; diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index 8129487ea1ce..9d9db2f9a38c 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -162,7 +162,7 @@ endif ifeq ($(MOZ_PKG_FORMAT),ZIP) ifdef MOZ_EXTERNAL_SIGNING_FORMAT # We can't use signcode on zip files -MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) +MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out osslsigncode signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) endif PKG_SUFFIX = .zip INNER_MAKE_PACKAGE = $(ZIP) -r9D $(PACKAGE) $(MOZ_PKG_DIR) \ diff --git a/tools/update-packaging/Makefile.in b/tools/update-packaging/Makefile.in index bf45b030a3ce..69dda3737508 100644 --- a/tools/update-packaging/Makefile.in +++ b/tools/update-packaging/Makefile.in @@ -47,7 +47,7 @@ include $(topsrcdir)/toolkit/mozapps/installer/packager.mk ifdef MOZ_EXTERNAL_SIGNING_FORMAT # We can't use signcode on mar files -MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) +MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out osslsigncode signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) MOZ_EXTERNAL_SIGNING_FORMAT := mar $(MOZ_EXTERNAL_SIGNING_FORMAT) endif