зеркало из https://github.com/mozilla/gecko-dev.git
Merge b2g-inbound to m-c
This commit is contained in:
Коммит
b42cc30cf7
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
<!--original fetch url was https://git.mozilla.org/releases-->
|
||||
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
|
||||
<!-- B2G specific things. -->
|
||||
<project name="platform_build" path="build" remote="b2g" revision="15d69a6789c638709911507f74d25c0425963636">
|
||||
<project name="platform_build" path="build" remote="b2g" revision="f6a198295f65ac38f8511803654a3583a1c666af">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="70b698c2e8d1764a1e27527a102df6452e405b9a"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="89c5816399e71bda92a8959b5b771c04d6672ea3"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="a9e08b91e9cd1f0930f16cfc49ec72f63575d5fe">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="70b698c2e8d1764a1e27527a102df6452e405b9a"/>
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "c23b496987e1e356c1cf7cc848c69511f6db041a",
|
||||
"revision": "f2784b078a4b58c1f0af8238d5325d0f05dc9fc0",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
<!--original fetch url was https://git.mozilla.org/releases-->
|
||||
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
|
||||
<!-- B2G specific things. -->
|
||||
<project name="platform_build" path="build" remote="b2g" revision="15d69a6789c638709911507f74d25c0425963636">
|
||||
<project name="platform_build" path="build" remote="b2g" revision="f6a198295f65ac38f8511803654a3583a1c666af">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="70b698c2e8d1764a1e27527a102df6452e405b9a"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="89c5816399e71bda92a8959b5b771c04d6672ea3"/>
|
||||
|
|
|
@ -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="04d96dd43e2c5c673a0c73b5a65faeb115c2065f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f64a5aec7d8138d85de6862b8c6b999abc55acca"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -160,6 +160,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
|||
bool aRealTime) :
|
||||
mDecoder(aDecoder),
|
||||
mState(DECODER_STATE_DECODING_METADATA),
|
||||
mInRunningStateMachine(false),
|
||||
mSyncPointInMediaStream(-1),
|
||||
mSyncPointInDecodedStream(-1),
|
||||
mResetPlayStartTime(false),
|
||||
|
@ -191,10 +192,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
|||
mDispatchedEventToDecode(false),
|
||||
mStopAudioThread(true),
|
||||
mQuickBuffering(false),
|
||||
mIsRunning(false),
|
||||
mRunAgain(false),
|
||||
mMinimizePreroll(false),
|
||||
mDispatchedRunEvent(false),
|
||||
mDecodeThreadWaiting(false),
|
||||
mRealTime(aRealTime),
|
||||
mEventManager(aDecoder),
|
||||
|
@ -1047,6 +1045,12 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoderStateMachine* aCloneDonor)
|
|||
|
||||
mStateMachineThreadPool = stateMachinePool;
|
||||
|
||||
nsresult rv;
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mTimer->SetTarget(GetStateMachineThread());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return mReader->Init(cloneReader);
|
||||
}
|
||||
|
||||
|
@ -2700,42 +2704,21 @@ nsresult MediaDecoderStateMachine::GetBuffered(dom::TimeRanges* aBuffered) {
|
|||
return res;
|
||||
}
|
||||
|
||||
nsresult MediaDecoderStateMachine::Run()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
||||
|
||||
return CallRunStateMachine();
|
||||
}
|
||||
|
||||
nsresult MediaDecoderStateMachine::CallRunStateMachine()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
||||
// This will be set to true by ScheduleStateMachine() if it's called
|
||||
// while we're in RunStateMachine().
|
||||
mRunAgain = false;
|
||||
|
||||
// Set to true whenever we dispatch an event to run this state machine.
|
||||
// This flag prevents us from dispatching
|
||||
mDispatchedRunEvent = false;
|
||||
|
||||
// If audio is being captured, stop the audio thread if it's running
|
||||
if (mAudioCaptured) {
|
||||
StopAudioThread();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mInRunningStateMachine, "State machine cycles must run in sequence!");
|
||||
mTimeout = TimeStamp();
|
||||
|
||||
mIsRunning = true;
|
||||
mInRunningStateMachine = true;
|
||||
nsresult res = RunStateMachine();
|
||||
mIsRunning = false;
|
||||
|
||||
if (mRunAgain && !mDispatchedRunEvent) {
|
||||
mDispatchedRunEvent = true;
|
||||
return GetStateMachineThread()->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
mInRunningStateMachine = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -2750,16 +2733,7 @@ void MediaDecoderStateMachine::TimeoutExpired()
|
|||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
NS_ASSERTION(OnStateMachineThread(), "Must be on state machine thread");
|
||||
if (mIsRunning) {
|
||||
mRunAgain = true;
|
||||
} else if (!mDispatchedRunEvent) {
|
||||
// We don't have an event dispatched to run the state machine, so we
|
||||
// can just run it from here.
|
||||
CallRunStateMachine();
|
||||
}
|
||||
// Otherwise, an event has already been dispatched to run the state machine
|
||||
// as soon as possible. Nothing else needed to do, the state machine is
|
||||
// going to run anyway.
|
||||
CallRunStateMachine();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder() {
|
||||
|
@ -2779,60 +2753,25 @@ nsresult MediaDecoderStateMachine::ScheduleStateMachine(int64_t aUsecs) {
|
|||
aUsecs = std::max<int64_t>(aUsecs, 0);
|
||||
|
||||
TimeStamp timeout = TimeStamp::Now() + UsecsToDuration(aUsecs);
|
||||
if (!mTimeout.IsNull()) {
|
||||
if (timeout >= mTimeout) {
|
||||
// We've already scheduled a timer set to expire at or before this time,
|
||||
// or have an event dispatched to run the state machine.
|
||||
return NS_OK;
|
||||
}
|
||||
if (mTimer) {
|
||||
// We've been asked to schedule a timer to run before an existing timer.
|
||||
// Cancel the existing timer.
|
||||
mTimer->Cancel();
|
||||
}
|
||||
if (!mTimeout.IsNull() && timeout >= mTimeout) {
|
||||
// We've already scheduled a timer set to expire at or before this time,
|
||||
// or have an event dispatched to run the state machine.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t ms = static_cast<uint32_t>((aUsecs / USECS_PER_MS) & 0xFFFFFFFF);
|
||||
if (mRealTime && ms > 40)
|
||||
if (mRealTime && ms > 40) {
|
||||
ms = 40;
|
||||
if (ms == 0) {
|
||||
if (mIsRunning) {
|
||||
// We're currently running this state machine on the state machine
|
||||
// thread. Signal it to run again once it finishes its current cycle.
|
||||
mRunAgain = true;
|
||||
return NS_OK;
|
||||
} else if (!mDispatchedRunEvent) {
|
||||
// We're not currently running this state machine on the state machine
|
||||
// thread. Dispatch an event to run one cycle of the state machine.
|
||||
mDispatchedRunEvent = true;
|
||||
return GetStateMachineThread()->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
// We're not currently running this state machine on the state machine
|
||||
// thread, but something has already dispatched an event to run it again,
|
||||
// so just exit; it's going to run real soon.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Since there is already a pending task that will run immediately,
|
||||
// we don't need to schedule a timer task.
|
||||
if (mRunAgain) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mTimeout = timeout;
|
||||
|
||||
nsresult res;
|
||||
if (!mTimer) {
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &res);
|
||||
if (NS_FAILED(res)) return res;
|
||||
mTimer->SetTarget(GetStateMachineThread());
|
||||
}
|
||||
|
||||
res = mTimer->InitWithFuncCallback(mozilla::TimeoutExpired,
|
||||
this,
|
||||
ms,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
return res;
|
||||
// Cancel existing timer if any since we are going to schedule a new one.
|
||||
mTimer->Cancel();
|
||||
nsresult rv = mTimer->InitWithFuncCallback(mozilla::TimeoutExpired,
|
||||
this,
|
||||
ms,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::OnDecodeThread() const
|
||||
|
|
|
@ -113,8 +113,9 @@ class SharedThreadPool;
|
|||
|
||||
See MediaDecoder.h for more details.
|
||||
*/
|
||||
class MediaDecoderStateMachine : public nsRunnable
|
||||
class MediaDecoderStateMachine
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderStateMachine)
|
||||
public:
|
||||
typedef MediaDecoder::DecodedStreamData DecodedStreamData;
|
||||
MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
|
@ -227,9 +228,6 @@ public:
|
|||
// the main thread.
|
||||
void StartBuffering();
|
||||
|
||||
// State machine thread run function. Defers to RunStateMachine().
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE;
|
||||
|
||||
// This is called on the state machine thread and audio thread.
|
||||
// The decoder monitor must be obtained before calling this.
|
||||
bool HasAudio() const {
|
||||
|
@ -646,7 +644,7 @@ private:
|
|||
|
||||
bool IsStateMachineScheduled() const {
|
||||
AssertCurrentThreadInMonitor();
|
||||
return !mTimeout.IsNull() || mRunAgain;
|
||||
return !mTimeout.IsNull();
|
||||
}
|
||||
|
||||
// Returns true if we're not playing and the decode thread has filled its
|
||||
|
@ -682,15 +680,17 @@ private:
|
|||
|
||||
RefPtr<SharedThreadPool> mStateMachineThreadPool;
|
||||
|
||||
// Timer to call the state machine Run() method. Used by
|
||||
// Timer to run the state machine cycles. Used by
|
||||
// ScheduleStateMachine(). Access protected by decoder monitor.
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
// Timestamp at which the next state machine Run() method will be called.
|
||||
// If this is non-null, a call to Run() is scheduled, either by a timer,
|
||||
// or via an event. Access protected by decoder monitor.
|
||||
// Timestamp at which the next state machine cycle will run.
|
||||
// Access protected by decoder monitor.
|
||||
TimeStamp mTimeout;
|
||||
|
||||
// Used to check if there are state machine cycles are running in sequence.
|
||||
DebugOnly<bool> mInRunningStateMachine;
|
||||
|
||||
// The time that playback started from the system clock. This is used for
|
||||
// timing the presentation of video frames when there's no audio.
|
||||
// Accessed only via the state machine thread.
|
||||
|
@ -920,14 +920,6 @@ private:
|
|||
// Synchronised via decoder monitor.
|
||||
bool mQuickBuffering;
|
||||
|
||||
// True if the shared state machine thread is currently running this
|
||||
// state machine.
|
||||
bool mIsRunning;
|
||||
|
||||
// True if we should run the state machine again once the current
|
||||
// state machine run has finished.
|
||||
bool mRunAgain;
|
||||
|
||||
// True if we should not decode/preroll unnecessary samples, unless we're
|
||||
// played. "Prerolling" in this context refers to when we decode and
|
||||
// buffer decoded samples in advance of when they're needed for playback.
|
||||
|
@ -940,13 +932,6 @@ private:
|
|||
// memory and CPU overhead.
|
||||
bool mMinimizePreroll;
|
||||
|
||||
// True if we've dispatched an event to run the state machine. It's
|
||||
// imperative that we don't dispatch multiple events to run the state
|
||||
// machine at the same time, as our code assume all events are synchronous.
|
||||
// If we dispatch multiple events, the second event can run while the
|
||||
// first is shutting down a thread, causing inconsistent state.
|
||||
bool mDispatchedRunEvent;
|
||||
|
||||
// True if the decode thread has gone filled its buffers and is now
|
||||
// waiting to be awakened before it continues decoding. Synchronized
|
||||
// by the decoder monitor.
|
||||
|
|
|
@ -35,6 +35,9 @@ const BDADDR_ANY = "00:00:00:00:00:00";
|
|||
const BDADDR_ALL = "ff:ff:ff:ff:ff:ff";
|
||||
const BDADDR_LOCAL = "ff:ff:ff:00:00:00";
|
||||
|
||||
// A user friendly name for remote BT device.
|
||||
const REMOTE_DEVICE_NAME = "Remote BT Device";
|
||||
|
||||
let Promise =
|
||||
SpecialPowers.Cu.import("resource://gre/modules/Promise.jsm").Promise;
|
||||
|
||||
|
@ -77,6 +80,70 @@ function runEmulatorCmdSafe(aCommand) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Bluetooth remote device to scatternet and set its properties.
|
||||
*
|
||||
* Use QEMU command 'bt remote add' to add a virtual Bluetooth remote
|
||||
* and set its properties by setEmulatorDeviceProperty().
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- bluetooth address of the remote device.
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aProperies
|
||||
* A javascript object with zero or several properties for initializing
|
||||
* the remote device. By now, the properies could be 'name' or
|
||||
* 'discoverable'. It valid to put a null object or a javascript object
|
||||
* which don't have any properies.
|
||||
*
|
||||
* @return A promise object.
|
||||
*/
|
||||
function addEmulatorRemoteDevice(aProperties) {
|
||||
let address;
|
||||
let promise = runEmulatorCmdSafe("bt remote add")
|
||||
.then(function(aResults) {
|
||||
address = aResults[0].toUpperCase();
|
||||
});
|
||||
|
||||
for (let key in aProperties) {
|
||||
let value = aProperties[key];
|
||||
let propertyName = key;
|
||||
promise = promise.then(function() {
|
||||
return setEmulatorDeviceProperty(address, propertyName, value);
|
||||
});
|
||||
}
|
||||
|
||||
return promise.then(function() {
|
||||
return address;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Bluetooth remote devices in scatternet.
|
||||
*
|
||||
* Use QEMU command 'bt remote remove <addr>' to remove a specific virtual
|
||||
* Bluetooth remote device in scatternet or remove them all by QEMU command
|
||||
* 'bt remote remove BDADDR_ALL'.
|
||||
*
|
||||
* @param aAddress
|
||||
* The string of Bluetooth address with format xx:xx:xx:xx:xx:xx.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of emulator response lines.
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @return A promise object.
|
||||
*/
|
||||
function removeEmulatorRemoteDevice(aAddress) {
|
||||
let cmd = "bt remote remove " + aAddress;
|
||||
return runEmulatorCmdSafe(cmd)
|
||||
.then(function(aResults) {
|
||||
// 'bt remote remove <bd_addr>' returns a list of removed device one at a line.
|
||||
// The last item is "OK".
|
||||
return aResults.slice(0, -1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property for a Bluetooth device.
|
||||
*
|
||||
|
@ -126,6 +193,71 @@ function getEmulatorDeviceProperty(aAddress, aPropertyName) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Start dicovering Bluetooth devices.
|
||||
*
|
||||
* Allows the device's adapter to start seeking for remote devices.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
* Reject params: a DOMError
|
||||
*
|
||||
* @param aAdapter
|
||||
* A BluetoothAdapter which is used to interact with local BT dev
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function startDiscovery(aAdapter) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = aAdapter.startDiscovery();
|
||||
request.onsuccess = function () {
|
||||
log(" Start discovery - Success");
|
||||
// TODO (bug 892207): Make Bluetooth APIs available for 3rd party apps.
|
||||
// Currently, discovering state wouldn't change immediately here.
|
||||
// We would turn on this check when the redesigned API are landed.
|
||||
// is(aAdapter.discovering, true, "BluetoothAdapter.discovering");
|
||||
deferred.resolve();
|
||||
}
|
||||
request.onerror = function (aEvent) {
|
||||
ok(false, "Start discovery - Fail");
|
||||
deferred.reject(aEvent.target.error);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dicovering Bluetooth devices.
|
||||
*
|
||||
* Allows the device's adapter to stop seeking for remote devices.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
* Reject params: a DOMError
|
||||
*
|
||||
* @param aAdapter
|
||||
* A BluetoothAdapter which is used to interact with local BT device.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function stopDiscovery(aAdapter) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = aAdapter.stopDiscovery();
|
||||
request.onsuccess = function () {
|
||||
log(" Stop discovery - Success");
|
||||
// TODO (bug 892207): Make Bluetooth APIs available for 3rd party apps.
|
||||
// Currently, discovering state wouldn't change immediately here.
|
||||
// We would turn on this check when the redesigned API are landed.
|
||||
// is(aAdapter.discovering, false, "BluetoothAdapter.discovering");
|
||||
deferred.resolve();
|
||||
}
|
||||
request.onerror = function (aEvent) {
|
||||
ok(false, "Stop discovery - Fail");
|
||||
deferred.reject(aEvent.target.error);
|
||||
}
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mozSettings value specified by @aKey.
|
||||
*
|
||||
|
|
|
@ -7,3 +7,4 @@ qemu = true
|
|||
[test_dom_BluetoothManager_adapteradded.js]
|
||||
[test_dom_BluetoothAdapter_setters.js]
|
||||
[test_dom_BluetoothAdapter_getters.js]
|
||||
[test_dom_BluetoothAdapter_discovery.js]
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 sts=2 et filetype=javascript
|
||||
* 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/. */
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Test Purpose:
|
||||
// To verify that discovery process of BluetoothAdapter is correct.
|
||||
// Use B2G emulator commands to add/remote remote devices to simulate
|
||||
// discovering behavior.
|
||||
//
|
||||
// Test Coverage:
|
||||
// - BluetoothAdapter.startDiscovery()
|
||||
// - BluetoothAdapter.stopDiscovery()
|
||||
// - BluetoothAdapter.ondevicefound()
|
||||
// - BluetoothAdapter.discovering [Temporarily turned off until BT API update]
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
startBluetoothTest(true, function testCaseMain(aAdapter) {
|
||||
log("Testing the discovery process of BluetoothAdapter ...");
|
||||
|
||||
// The properties of remote device.
|
||||
let theProperties = {
|
||||
"name": REMOTE_DEVICE_NAME,
|
||||
"discoverable": true
|
||||
};
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => removeEmulatorRemoteDevice(BDADDR_ALL))
|
||||
.then(() => addEmulatorRemoteDevice(/*theProperties*/ null))
|
||||
.then(function(aRemoteAddress) {
|
||||
let promises = [];
|
||||
promises.push(waitForAdapterEvent(aAdapter, "devicefound"));
|
||||
promises.push(startDiscovery(aAdapter));
|
||||
return Promise.all(promises)
|
||||
.then(function(aResults) {
|
||||
is(aResults[0].device.address, aRemoteAddress, "BluetoothDevice.address");
|
||||
});
|
||||
})
|
||||
.then(() => stopDiscovery(aAdapter))
|
||||
.then(() => removeEmulatorRemoteDevice(BDADDR_ALL));
|
||||
});
|
|
@ -15,12 +15,6 @@ function debug(msg) {
|
|||
// mozbrowser API clients.
|
||||
docShell.isActive = true;
|
||||
|
||||
let infos = sendSyncMessage('browser-element-api:call',
|
||||
{ 'msg_name': 'hello' })[0];
|
||||
docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
|
||||
docShell.setFullscreenAllowed(infos.fullscreenAllowed);
|
||||
|
||||
|
||||
function parentDocShell(docshell) {
|
||||
if (!docshell) {
|
||||
return null;
|
||||
|
@ -57,3 +51,8 @@ if (!('BrowserElementIsPreloaded' in this)) {
|
|||
}
|
||||
|
||||
var BrowserElementIsReady = true;
|
||||
|
||||
let infos = sendSyncMessage('browser-element-api:call',
|
||||
{ 'msg_name': 'hello' })[0];
|
||||
docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
|
||||
docShell.setFullscreenAllowed(infos.fullscreenAllowed);
|
||||
|
|
|
@ -366,9 +366,11 @@ BrowserElementParent.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_recvHello: function(data) {
|
||||
_recvHello: function() {
|
||||
debug("recvHello");
|
||||
|
||||
this._ready = true;
|
||||
|
||||
// Inform our child if our owner element's document is invisible. Note
|
||||
// that we must do so here, rather than in the BrowserElementParent
|
||||
// constructor, because the BrowserElementChild may not be initialized when
|
||||
|
@ -382,7 +384,7 @@ BrowserElementParent.prototype = {
|
|||
fullscreenAllowed:
|
||||
this._frameElement.hasAttribute('allowfullscreen') ||
|
||||
this._frameElement.hasAttribute('mozallowfullscreen')
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
_fireCtxMenuEvent: function(data) {
|
||||
|
@ -724,15 +726,31 @@ BrowserElementParent.prototype = {
|
|||
} else {
|
||||
let reqOld = XPCNativeWrapper.unwrap(activeInputFrame)
|
||||
.setInputMethodActive(false);
|
||||
reqOld.onsuccess = function() {
|
||||
activeInputFrame = null;
|
||||
this._sendSetInputMethodActiveDOMRequest(req, isActive);
|
||||
|
||||
// We wan't to continue regardless whether this req succeeded
|
||||
reqOld.onsuccess = reqOld.onerror = function() {
|
||||
let setActive = function() {
|
||||
activeInputFrame = null;
|
||||
this._sendSetInputMethodActiveDOMRequest(req, isActive);
|
||||
}.bind(this);
|
||||
|
||||
if (this._ready) {
|
||||
setActive();
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for the hello event from BrowserElementChild
|
||||
let onReady = function(aMsg) {
|
||||
if (this._isAlive() && (aMsg.data.msg_name === 'hello')) {
|
||||
setActive();
|
||||
|
||||
this._mm.removeMessageListener('browser-element-api:call',
|
||||
onReady);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
this._mm.addMessageListener('browser-element-api:call', onReady);
|
||||
}.bind(this);
|
||||
reqOld.onerror = function() {
|
||||
Services.DOMRequest.fireErrorAsync(req,
|
||||
'Failed to deactivate the old input method: ' +
|
||||
reqOld.error + '.');
|
||||
};
|
||||
}
|
||||
} else {
|
||||
this._sendSetInputMethodActiveDOMRequest(req, isActive);
|
||||
|
|
|
@ -50,17 +50,32 @@ function doFailToSetPreferredNetworkType(preferredNetworkType, expectedError, ca
|
|||
};
|
||||
}
|
||||
|
||||
function getSupportedNetworkTypesFromSystemProperties(clientId, callback) {
|
||||
let key = "ro.moz.ril." + clientId + ".network_types";
|
||||
|
||||
runEmulatorShell(["getprop", key], function(results) {
|
||||
let result = results[0];
|
||||
if (!result || result === "") {
|
||||
// Copied from GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT in dom/system/gonk/ril_consts.js.
|
||||
result = "wcdma,gsm";
|
||||
}
|
||||
callback(result.split(","));
|
||||
});
|
||||
}
|
||||
|
||||
/* Test supportedNetworkTypes */
|
||||
taskHelper.push(function testSupportedNetworkTypes() {
|
||||
let supportedNetworkTypes = mobileConnection.supportedNetworkTypes;
|
||||
|
||||
ok(Array.isArray(supportedNetworkTypes), "supportedNetworkTypes should be an array");
|
||||
ok(supportedNetworkTypes.indexOf("gsm") >= 0, "Should support 'gsm'");
|
||||
ok(supportedNetworkTypes.indexOf("wcdma") >= 0, "Should support 'wcdma'");
|
||||
ok(supportedNetworkTypes.indexOf("cdma") >= 0, "Should support 'cdma'");
|
||||
ok(supportedNetworkTypes.indexOf("evdo") >= 0, "Should support 'evdo'");
|
||||
|
||||
taskHelper.runNext();
|
||||
getSupportedNetworkTypesFromSystemProperties(0, function(testData) {
|
||||
is(testData.length, supportedNetworkTypes.length);
|
||||
for (let i = 0; i < testData.length; i++) {
|
||||
ok(supportedNetworkTypes.indexOf(testData[i]) >= 0, "Should support '" + testData[i] + "'");
|
||||
}
|
||||
|
||||
taskHelper.runNext();
|
||||
});
|
||||
});
|
||||
|
||||
/* Test switching to supported preferred types */
|
||||
|
|
|
@ -430,7 +430,7 @@ this.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO = [
|
|||
GECKO_PREFERRED_NETWORK_TYPE_LTE_ONLY
|
||||
];
|
||||
|
||||
this.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT = "gsm,wcdma,cdma,evdo";
|
||||
this.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT = "gsm,wcdma";
|
||||
this.GECKO_SUPPORTED_NETWORK_TYPES = [
|
||||
"gsm",
|
||||
"wcdma",
|
||||
|
|
Загрузка…
Ссылка в новой задаче