зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1003472 - If OPP manager can't get valid service channel, refresh SDP records until timeout is hit. r=shuang
If user tries to send a file to a device which just completes the pairing process, the OPP manager may update SDP records when it's not ready. It's especially likely to occur in BT file transfer with inline pairing since OPP manager would request for a service channel to send the file when device is just paired.
This commit is contained in:
Родитель
d44101b207
Коммит
a2d35c1933
|
@ -35,6 +35,8 @@
|
|||
USING_BLUETOOTH_NAMESPACE
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::ipc;
|
||||
using mozilla::TimeDuration;
|
||||
using mozilla::TimeStamp;
|
||||
|
||||
namespace {
|
||||
// Sending system message "bluetooth-opp-update-progress" every 50kb
|
||||
|
@ -53,6 +55,10 @@ static const uint32_t kPutRequestHeaderSize = 6;
|
|||
*/
|
||||
static const uint32_t kPutRequestAppendHeaderSize = 5;
|
||||
|
||||
// The default timeout we permit to wait for SDP updating if we can't get
|
||||
// service channel.
|
||||
static const double kSdpUpdatingTimeoutMs = 3000.0;
|
||||
|
||||
StaticRefPtr<BluetoothOppManager> sBluetoothOppManager;
|
||||
static bool sInShutdown = false;
|
||||
}
|
||||
|
@ -1546,9 +1552,17 @@ BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
|||
if (aChannel < 0) {
|
||||
if (mNeedsUpdatingSdpRecords) {
|
||||
mNeedsUpdatingSdpRecords = false;
|
||||
mLastServiceChannelCheck = TimeStamp::Now();
|
||||
bs->UpdateSdpRecords(aDeviceAddress, this);
|
||||
} else {
|
||||
OnSocketConnectError(mSocket);
|
||||
TimeDuration duration = TimeStamp::Now() - mLastServiceChannelCheck;
|
||||
// Refresh SDP records until it gets valid service channel
|
||||
// unless timeout is hit.
|
||||
if (duration.ToMilliseconds() < kSdpUpdatingTimeoutMs) {
|
||||
bs->UpdateSdpRecords(aDeviceAddress, this);
|
||||
} else {
|
||||
OnSocketConnectError(mSocket);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -215,6 +215,10 @@ private:
|
|||
// is called.
|
||||
nsRefPtr<BluetoothSocket> mRfcommSocket;
|
||||
nsRefPtr<BluetoothSocket> mL2capSocket;
|
||||
|
||||
// This holds the time when OPP manager fail to get service channel and
|
||||
// prepare to refresh SDP records.
|
||||
mozilla::TimeStamp mLastServiceChannelCheck;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
|
Загрузка…
Ссылка в новой задаче