Merge m-c to inbound. a=merge

--HG--
rename : xpcom/tests/TestExpirationTracker.cpp => xpcom/glue/tests/gtest/TestExpirationTracker.cpp
This commit is contained in:
Ryan VanderMeulen 2014-12-16 16:05:26 -05:00
commit c8728d7d48
29 changed files with 182 additions and 55 deletions

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -129,7 +129,7 @@
<!-- Stock Android things -->
<project name="platform/external/icu4c" path="external/icu4c" revision="2bb01561780583cc37bc667f0ea79f48a122d8a2"/>
<!-- dolphin specific things -->
<project name="device/sprd" path="device/sprd" revision="3a0f1b51e3b27b36b9df484f3c286b6099889f6e"/>
<project name="device/sprd" path="device/sprd" revision="ea8680ba32e41e5f7a2ff12d692f2a159cb19501"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="4e58336019b5cbcfd134caf55b142236cf986618"/>
<project name="platform/frameworks/av" path="frameworks/av" revision="4387fe988e5a1001f29ce05fcfda03ed2d32137b"/>
<project name="platform/hardware/akm" path="hardware/akm" revision="6d3be412647b0eab0adff8a2768736cf4eb68039"/>

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="631dbd1b133f09d83f526292ab8996e46b1e7654"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="631dbd1b133f09d83f526292ab8996e46b1e7654"/>

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "7d6f0979c4f3f3c5702033739561ba8d4159b409",
"revision": "99bea97a4bd9d6af1d7462e1abe15c8aaf4d7981",
"repo_path": "integration/gaia-central"
}

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>

View File

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="631dbd1b133f09d83f526292ab8996e46b1e7654"/>

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="af3d2f89f391c92667e04676fc0ac971e6021bb7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8ffb48c321bb9595ad437086c5eb450bc90aa714"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="50ad16a280fe9cfa0716f8c6ba16afdf7f266b49"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -334,7 +334,11 @@ fi
# Even after dropping 10.6 support, MOZ_PIE would not be useful since it's the
# default (and clang says the -pie option is not used).
# On other Unix systems, some file managers (Nautilus) can't start PIE programs
MOZ_PIE=
if test -n "$gonkdir" -a "$ANDROID_VERSION" -ge 16; then
MOZ_PIE=1
else
MOZ_PIE=
fi
MOZ_ARG_ENABLE_BOOL(pie,
[ --enable-pie Enable Position Independent Executables],

View File

@ -238,7 +238,7 @@ nsGonkCameraControl::Initialize()
while (i > 0) {
--i;
if (modes[i].EqualsASCII(kCenterWeighted)) {
mParams.Set(CAMERA_PARAM_METERINGMODE, kCenterWeighted);
mParams.Set(CAMERA_PARAM_METERINGMODE, modes[i]);
PushParametersImpl();
break;
}

View File

@ -2734,6 +2734,12 @@ MediaDecoderStateMachine::FlushDecoding()
DecodeTaskQueue()->FlushAndDispatch(task);
}
// These flags will be reset when the decoded data returned in OnAudioDecoded()
// and OnVideoDecoded(). Because the decode tasks are flushed, these flags need
// to be reset here.
mAudioRequestPending = false;
mVideoRequestPending = false;
// We must reset playback so that all references to frames queued
// in the state machine are dropped, else subsequent calls to Shutdown()
// or ReleaseMediaResources() can fail on B2G.

View File

@ -204,6 +204,14 @@ private:
};
#endif
void MP4Reader::RequestCodecResource() {
#ifdef MOZ_GONK_MEDIACODEC
if(mVideo.mDecoder) {
mVideo.mDecoder->AllocateMediaResources();
}
#endif
}
bool MP4Reader::IsWaitingOnCodecResource() {
#ifdef MOZ_GONK_MEDIACODEC
return mVideo.mDecoder && mVideo.mDecoder->IsWaitingMediaResources();
@ -273,6 +281,14 @@ MP4Reader::IsSupportedVideoMimeType(const char* aMimeType)
mPlatform->SupportsVideoMimeType(aMimeType);
}
void
MP4Reader::PreReadMetadata()
{
if (mPlatform) {
RequestCodecResource();
}
}
nsresult
MP4Reader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
@ -729,6 +745,7 @@ MP4Reader::Flush(TrackType aTrack)
data.RejectPromise(CANCELED, __func__);
}
data.mDiscontinuity = true;
data.mUpdateScheduled = false;
}
if (aTrack == kVideo) {
mQueuedVideoSample = nullptr;

View File

@ -45,6 +45,11 @@ public:
virtual bool HasAudio() MOZ_OVERRIDE;
virtual bool HasVideo() MOZ_OVERRIDE;
// PreReadMetadata() is called by MediaDecoderStateMachine::DecodeMetadata()
// before checking hardware resource. In Gonk, it requests hardware codec so
// MediaDecoderStateMachine could go to DORMANT state if the hardware codec is
// not available.
virtual void PreReadMetadata() MOZ_OVERRIDE;
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) MOZ_OVERRIDE;
@ -107,6 +112,7 @@ private:
bool IsSupportedAudioMimeType(const char* aMimeType);
bool IsSupportedVideoMimeType(const char* aMimeType);
void NotifyResourcesStatusChanged();
void RequestCodecResource();
bool IsWaitingOnCodecResource();
virtual bool IsWaitingOnCDMResource() MOZ_OVERRIDE;

View File

@ -231,6 +231,7 @@ public:
virtual bool IsDormantNeeded() {
return false;
};
virtual void AllocateMediaResources() {}
virtual void ReleaseMediaResources() {}
virtual void ReleaseDecoder() {}
};

View File

@ -164,6 +164,12 @@ GonkMediaDataDecoder::IsDormantNeeded() {
return mDecoder.get() ? true : false;
}
void
GonkMediaDataDecoder::AllocateMediaResources()
{
mManager->AllocateMediaResources();
}
void
GonkMediaDataDecoder::ReleaseMediaResources() {
mManager->ReleaseMediaResources();

View File

@ -35,6 +35,8 @@ public:
nsRefPtr<MediaData>& aOutput) = 0;
virtual nsresult Flush() = 0;
virtual void AllocateMediaResources() {};
virtual void ReleaseMediaResources() {};
};
@ -65,6 +67,8 @@ public:
virtual bool IsDormantNeeded() MOZ_OVERRIDE;
virtual void AllocateMediaResources() MOZ_OVERRIDE;
virtual void ReleaseMediaResources() MOZ_OVERRIDE;
private:

View File

@ -474,6 +474,12 @@ GonkVideoDecoderManager::Flush()
return NS_OK;
}
void
GonkVideoDecoderManager::AllocateMediaResources()
{
mDecoder->RequestMediaResources();
}
void
GonkVideoDecoderManager::codecReserved()
{

View File

@ -52,6 +52,8 @@ public:
virtual nsresult Flush() MOZ_OVERRIDE;
virtual void AllocateMediaResources();
virtual void ReleaseMediaResources();
static void RecycleCallback(TextureClient* aClient, void* aClosure);

View File

@ -135,6 +135,12 @@ MediaCodecProxy::requestResource()
return true;
}
void
MediaCodecProxy::RequestMediaResources()
{
requestResource();
}
void
MediaCodecProxy::cancelResource()
{
@ -572,7 +578,6 @@ status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs)
status_t err = dequeueOutputBuffer(&index, &offset, &size,
&timeUs, &flags, aTimeoutUs);
if (err != OK) {
ALOG("Output returned %d", err);
return err;
}
@ -598,9 +603,10 @@ status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs)
bool MediaCodecProxy::IsWaitingResources()
{
// Write Lock for mCodec
RWLock::AutoWLock awl(mCodecLock);
return mCodec == nullptr;
if (mResourceHandler.get()) {
return mResourceHandler->IsWaitingResource();
}
return false;
}
bool MediaCodecProxy::IsDormantNeeded()

View File

@ -131,6 +131,7 @@ public:
bool Prepare();
bool IsWaitingResources();
bool IsDormantNeeded();
void RequestMediaResources();
void ReleaseMediaResources();
// This updates mOutputBuffer when receiving INFO_OUTPUT_BUFFERS_CHANGED event.
bool UpdateOutputBuffers();

View File

@ -5,15 +5,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaResourceHandler.h"
#include "mozilla/NullPtr.h"
namespace android {
MediaResourceHandler::MediaResourceHandler(const wp<ResourceListener> &aListener)
: mListener(aListener)
, mState(MediaResourceManagerClient::CLIENT_STATE_WAIT_FOR_RESOURCE)
, mType(IMediaResourceManagerService::INVALID_RESOURCE_TYPE)
, mWaitingResource(false)
{
}
@ -22,6 +21,13 @@ MediaResourceHandler::~MediaResourceHandler()
cancelResource();
}
bool
MediaResourceHandler::IsWaitingResource()
{
Mutex::Autolock al(mLock);
return mWaitingResource;
}
bool
MediaResourceHandler::requestResource(IMediaResourceManagerService::ResourceType aType)
{
@ -45,6 +51,7 @@ MediaResourceHandler::requestResource(IMediaResourceManagerService::ResourceType
mClient = client;
mService = service;
mType = aType;
mWaitingResource = true;
return true;
}
@ -58,6 +65,7 @@ MediaResourceHandler::cancelResource()
mService->cancelClient(mClient, (int)mType);
}
mWaitingResource = false;
mClient = nullptr;
mService = nullptr;
}
@ -70,19 +78,15 @@ MediaResourceHandler::statusChanged(int aEvent)
Mutex::Autolock autoLock(mLock);
MediaResourceManagerClient::State state = (MediaResourceManagerClient::State)aEvent;
if (state == mState) {
return;
}
mState = state;
listener = mListener.promote();
if (listener == nullptr) {
return;
}
if (mState == MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
mWaitingResource = false;
MediaResourceManagerClient::State state = (MediaResourceManagerClient::State)aEvent;
if (state == MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
listener->resourceReserved();
} else {
listener->resourceCanceled();

View File

@ -42,6 +42,8 @@ public:
// Cancel Resource
void cancelResource();
bool IsWaitingResource();
protected:
// MediaResourceManagerClient::EventListener::statusChanged()
virtual void statusChanged(int event);
@ -57,10 +59,11 @@ private:
// Resource Management
Mutex mLock;
MediaResourceManagerClient::State mState;
sp<IMediaResourceManagerClient> mClient;
sp<IMediaResourceManagerService> mService;
IMediaResourceManagerService::ResourceType mType;
bool mWaitingResource;
};
} // namespace android

View File

@ -7058,21 +7058,21 @@ GsmPDUHelperObject.prototype = {
},
/**
* Convert a semi-octet (number) to a GSM BCD char, or return empty string
* if invalid semiOctet and supressException is set to true.
* Convert a semi-octet (number) to a GSM BCD char, or return empty
* string if invalid semiOctet and suppressException is set to true.
*
* @param semiOctet
* Nibble to be converted to.
* @param [optional] supressException
* Supress exception if invalid semiOctet and supressException is set
* @param suppressException [optional]
* Suppress exception if invalid semiOctet and suppressException is set
* to true.
*
* @return GSM BCD char, or empty string.
*/
bcdChars: "0123456789*#,;",
semiOctetToBcdChar: function(semiOctet, supressException) {
if (semiOctet >= 14) {
if (supressException) {
bcdChars: "0123456789",
semiOctetToBcdChar: function(semiOctet, suppressException) {
if (semiOctet >= this.bcdChars.length) {
if (suppressException) {
return "";
} else {
throw new RangeError();
@ -7082,6 +7082,31 @@ GsmPDUHelperObject.prototype = {
return this.bcdChars.charAt(semiOctet);
},
/**
* Convert a semi-octet (number) to a GSM extended BCD char, or return empty
* string if invalid semiOctet and suppressException is set to true.
*
* @param semiOctet
* Nibble to be converted to.
* @param suppressException [optional]
* Suppress exception if invalid semiOctet and suppressException is set
* to true.
*
* @return GSM extended BCD char, or empty string.
*/
extendedBcdChars: "0123456789*#,;",
semiOctetToExtendedBcdChar: function(semiOctet, suppressException) {
if (semiOctet >= this.extendedBcdChars.length) {
if (suppressException) {
return "";
} else {
throw new RangeError();
}
}
return this.extendedBcdChars.charAt(semiOctet);
},
/**
* Read a *swapped nibble* binary coded decimal (BCD)
*
@ -7112,17 +7137,17 @@ GsmPDUHelperObject.prototype = {
},
/**
* Read a *swapped nibble* binary coded string (BCD)
* Read a *swapped nibble* binary coded decimal (BCD) string
*
* @param pairs
* Number of nibble *pairs* to read.
* @param [optional] supressException
* Supress exception if invalid semiOctet and supressException is set
* @param suppressException [optional]
* Suppress exception if invalid semiOctet and suppressException is set
* to true.
*
* @return The BCD string.
*/
readSwappedNibbleBcdString: function(pairs, supressException) {
readSwappedNibbleBcdString: function(pairs, suppressException) {
let str = "";
for (let i = 0; i < pairs; i++) {
let nibbleH = this.readHexNibble();
@ -7131,9 +7156,38 @@ GsmPDUHelperObject.prototype = {
break;
}
str += this.semiOctetToBcdChar(nibbleL, supressException);
str += this.semiOctetToBcdChar(nibbleL, suppressException);
if (nibbleH != 0x0F) {
str += this.semiOctetToBcdChar(nibbleH, supressException);
str += this.semiOctetToBcdChar(nibbleH, suppressException);
}
}
return str;
},
/**
* Read a *swapped nibble* extended binary coded decimal (BCD) string
*
* @param pairs
* Number of nibble *pairs* to read.
* @param suppressException [optional]
* Suppress exception if invalid semiOctet and suppressException is set
* to true.
*
* @return The BCD string.
*/
readSwappedNibbleExtendedBcdString: function(pairs, suppressException) {
let str = "";
for (let i = 0; i < pairs; i++) {
let nibbleH = this.readHexNibble();
let nibbleL = this.readHexNibble();
if (nibbleL == 0x0F) {
break;
}
str += this.semiOctetToExtendedBcdChar(nibbleL, suppressException);
if (nibbleH != 0x0F) {
str += this.semiOctetToExtendedBcdChar(nibbleH, suppressException);
}
}
@ -7605,7 +7659,7 @@ GsmPDUHelperObject.prototype = {
PDU_NL_IDENTIFIER_DEFAULT , PDU_NL_IDENTIFIER_DEFAULT );
return addr;
}
addr = this.readSwappedNibbleBcdString(len / 2);
addr = this.readSwappedNibbleExtendedBcdString(len / 2);
if (addr.length <= 0) {
if (DEBUG) this.context.debug("PDU error: no number provided");
return null;
@ -7955,7 +8009,7 @@ GsmPDUHelperObject.prototype = {
if (smscLength > 0) {
let smscTypeOfAddress = this.readHexOctet();
// Subtract the type-of-address octet we just read from the length.
msg.SMSC = this.readSwappedNibbleBcdString(smscLength - 1);
msg.SMSC = this.readSwappedNibbleExtendedBcdString(smscLength - 1);
if ((smscTypeOfAddress >> 4) == (PDU_TOA_INTERNATIONAL >> 4)) {
msg.SMSC = '+' + msg.SMSC;
}
@ -10424,7 +10478,7 @@ ICCPDUHelperObject.prototype = {
// TOA = TON + NPI
let toa = GsmPDUHelper.readHexOctet();
let number = GsmPDUHelper.readSwappedNibbleBcdString(len - 1);
let number = GsmPDUHelper.readSwappedNibbleExtendedBcdString(len - 1);
if (number.length <= 0) {
if (DEBUG) this.context.debug("No number provided");
return "";
@ -12668,11 +12722,12 @@ ICCRecordHelperObject.prototype = {
function callback() {
let Buf = this.context.Buf;
let RIL = this.context.RIL;
let GsmPDUHelper = this.context.GsmPDUHelper;
let strLen = Buf.readInt32();
let octetLen = strLen / 2;
RIL.iccInfo.iccid =
this.context.GsmPDUHelper.readSwappedNibbleBcdString(octetLen, true);
GsmPDUHelper.readSwappedNibbleBcdString(octetLen, true);
// Consumes the remaining buffer if any.
let unReadBuffer = this.context.Buf.getReadAvailable() -
this.context.Buf.PDU_HEX_OCTET_SIZE;
@ -13961,7 +14016,7 @@ SimRecordHelperObject.prototype = {
let buf = "";
for (let i = 0; i < reformat.length; i++) {
if (reformat[i] != 0xF) {
buf += GsmPDUHelper.semiOctetToBcdChar(reformat[i]);
buf += GsmPDUHelper.semiOctetToExtendedBcdChar(reformat[i]);
}
if (i === 2) {
// 0-2: MCC
@ -14118,7 +14173,7 @@ SimRecordHelperObject.prototype = {
let plmnEntry = {};
for (let i = 0; i < reformat.length; i++) {
if (reformat[i] != 0xF) {
buf += GsmPDUHelper.semiOctetToBcdChar(reformat[i]);
buf += GsmPDUHelper.semiOctetToExtendedBcdChar(reformat[i]);
}
if (i === 2) {
// 0-2: MCC
@ -14611,7 +14666,7 @@ ICCUtilsHelperObject.prototype = {
}
} else {
let GsmPDUHelper = this.context.GsmPDUHelper;
let wildChar = GsmPDUHelper.bcdChars.charAt(0x0d);
let wildChar = GsmPDUHelper.extendedBcdChars.charAt(0x0d);
// According to 3GPP TS 31.102 Sec. 4.2.59 and 3GPP TS 51.011 Sec. 10.3.42,
// the ME shall use this EF_OPL in association with the EF_PNN in place
// of any network name stored within the ME's internal list and any network

View File

@ -61,7 +61,7 @@ add_test(function test_read_dialling_number() {
return 0x81;
};
helper.readSwappedNibbleBcdString = function(len) {
helper.readSwappedNibbleExtendedBcdString = function(len) {
return str.substring(0, len);
};

View File

@ -714,10 +714,16 @@ add_test(function test_handling_iccid() {
do_check_eq(ril.iccInfo.iccid, expectedICCID);
}
// Invalid char at high nibbile + low nibbile contains 0xF.
// Invalid value 0xE at high nibbile + low nibbile contains 0xF.
do_test("9868002E90909F001519", "89860020909");
// Invalid char at low nibbile.
do_test("986800E2909090001519", "8986002090909005191");
// Invalid value 0xD at low nibbile.
do_test("986800D2909090001519", "8986002090909005191");
// Invalid value 0xC at low nibbile.
do_test("986800C2909090001519", "8986002090909005191");
// Invalid value 0xB at low nibbile.
do_test("986800B2909090001519", "8986002090909005191");
// Invalid value 0xA at low nibbile.
do_test("986800A2909090001519", "8986002090909005191");
// Valid ICCID.
do_test("98101430121181157002", "89014103211118510720");