зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1016186 - Do not fire AdapterAdded event when BT is turned on, r=echou
This commit is contained in:
Родитель
7874a4cb49
Коммит
70e03af5fd
|
@ -25,7 +25,6 @@
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
#include "mozilla/dom/ContentParent.h"
|
#include "mozilla/dom/ContentParent.h"
|
||||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||||
#include "mozilla/ipc/UnixSocket.h"
|
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsCxPusher.h"
|
#include "nsCxPusher.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
|
@ -163,7 +162,6 @@ BluetoothService::ToggleBtAck::Run()
|
||||||
sBluetoothService->SetEnabled(mEnabled);
|
sBluetoothService->SetEnabled(mEnabled);
|
||||||
sToggleInProgress = false;
|
sToggleInProgress = false;
|
||||||
|
|
||||||
sBluetoothService->TryFiringAdapterAdded();
|
|
||||||
sBluetoothService->FireAdapterStateChanged(mEnabled);
|
sBluetoothService->FireAdapterStateChanged(mEnabled);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -376,8 +374,6 @@ BluetoothService::StartBluetooth(bool aIsStartup,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapterAddedReceived = false;
|
|
||||||
|
|
||||||
/* When IsEnabled() is true, we don't switch on Bluetooth but we still
|
/* When IsEnabled() is true, we don't switch on Bluetooth but we still
|
||||||
* send ToggleBtAck task. One special case happens at startup stage. At
|
* send ToggleBtAck task. One special case happens at startup stage. At
|
||||||
* startup, the initialization of BluetoothService still has to be done
|
* startup, the initialization of BluetoothService still has to be done
|
||||||
|
@ -438,8 +434,6 @@ BluetoothService::StopBluetooth(bool aIsStartup,
|
||||||
profile->Reset();
|
profile->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapterAddedReceived = false;
|
|
||||||
|
|
||||||
/* When IsEnabled() is false, we don't switch off Bluetooth but we still
|
/* When IsEnabled() is false, we don't switch off Bluetooth but we still
|
||||||
* send ToggleBtAck task. One special case happens at startup stage. At
|
* send ToggleBtAck task. One special case happens at startup stage. At
|
||||||
* startup, the initialization of BluetoothService still has to be done
|
* startup, the initialization of BluetoothService still has to be done
|
||||||
|
@ -494,8 +488,8 @@ BluetoothService::SetEnabled(bool aEnabled)
|
||||||
* aEnabled: expected status of bluetooth
|
* aEnabled: expected status of bluetooth
|
||||||
*/
|
*/
|
||||||
if (mEnabled == aEnabled) {
|
if (mEnabled == aEnabled) {
|
||||||
BT_WARNING("Bluetooth has already been enabled/disabled before "
|
BT_WARNING("Bluetooth is already %s, or the toggling failed.",
|
||||||
"or the toggling is failed.");
|
mEnabled ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
mEnabled = aEnabled;
|
mEnabled = aEnabled;
|
||||||
|
@ -564,7 +558,7 @@ BluetoothService::HandleSettingsChanged(const nsAString& aData)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, check if the string equals to BLUETOOTH_DEBUGGING_SETTING
|
// Check whether the string is BLUETOOTH_DEBUGGING_SETTING
|
||||||
bool match;
|
bool match;
|
||||||
if (!JS_StringEqualsAscii(cx, key.toString(), BLUETOOTH_DEBUGGING_SETTING, &match)) {
|
if (!JS_StringEqualsAscii(cx, key.toString(), BLUETOOTH_DEBUGGING_SETTING, &match)) {
|
||||||
MOZ_ASSERT(!JS_IsExceptionPending(cx));
|
MOZ_ASSERT(!JS_IsExceptionPending(cx));
|
||||||
|
@ -706,28 +700,6 @@ BluetoothService::Observe(nsISupports* aSubject, const char* aTopic,
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BluetoothService::TryFiringAdapterAdded()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
|
|
||||||
if (IsToggling() || !mAdapterAddedReceived) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothSignal signal(NS_LITERAL_STRING("AdapterAdded"),
|
|
||||||
NS_LITERAL_STRING(KEY_MANAGER), true);
|
|
||||||
DistributeSignal(signal);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BluetoothService::AdapterAddedReceived()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
|
|
||||||
mAdapterAddedReceived = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable the local adapter.
|
* Enable/Disable the local adapter.
|
||||||
*
|
*
|
||||||
|
@ -795,10 +767,8 @@ BluetoothService::Notify(const BluetoothSignal& aData)
|
||||||
"pairedstatuschanged: Wrong length of parameters");
|
"pairedstatuschanged: Wrong length of parameters");
|
||||||
type.AssignLiteral("bluetooth-pairedstatuschanged");
|
type.AssignLiteral("bluetooth-pairedstatuschanged");
|
||||||
} else {
|
} else {
|
||||||
nsCString warningMsg;
|
BT_WARNING("Not handling service signal: %s",
|
||||||
warningMsg.AssignLiteral("Not handling service signal: ");
|
NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||||
warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
|
|
||||||
BT_WARNING(warningMsg.get());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,13 +308,6 @@ public:
|
||||||
bool
|
bool
|
||||||
IsToggling() const;
|
IsToggling() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Below 2 function/variable are used for ensuring event 'AdapterAdded' will
|
|
||||||
* be fired after event 'Enabled'.
|
|
||||||
*/
|
|
||||||
void TryFiringAdapterAdded();
|
|
||||||
void AdapterAddedReceived();
|
|
||||||
|
|
||||||
void FireAdapterStateChanged(bool aEnable);
|
void FireAdapterStateChanged(bool aEnable);
|
||||||
nsresult EnableDisable(bool aEnable,
|
nsresult EnableDisable(bool aEnable,
|
||||||
BluetoothReplyRunnable* aRunnable);
|
BluetoothReplyRunnable* aRunnable);
|
||||||
|
@ -339,9 +332,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BluetoothService() : mEnabled(false)
|
BluetoothService() : mEnabled(false)
|
||||||
, mAdapterAddedReceived(false)
|
{ }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~BluetoothService();
|
virtual ~BluetoothService();
|
||||||
|
|
||||||
|
@ -400,9 +391,6 @@ protected:
|
||||||
BluetoothSignalObserverTable mBluetoothSignalObserverTable;
|
BluetoothSignalObserverTable mBluetoothSignalObserverTable;
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
private:
|
|
||||||
bool mAdapterAddedReceived;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_BLUETOOTH_NAMESPACE
|
END_BLUETOOTH_NAMESPACE
|
||||||
|
|
|
@ -127,14 +127,6 @@ public:
|
||||||
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
|
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to fire event 'AdapterAdded' to fit the original behaviour when
|
|
||||||
// we used BlueZ as backend.
|
|
||||||
BluetoothService* bs = BluetoothService::Get();
|
|
||||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
bs->AdapterAddedReceived();
|
|
||||||
bs->TryFiringAdapterAdded();
|
|
||||||
|
|
||||||
// Trigger BluetoothOppManager to listen
|
// Trigger BluetoothOppManager to listen
|
||||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||||
if (!opp || !opp->Listen()) {
|
if (!opp || !opp->Listen()) {
|
||||||
|
|
|
@ -538,8 +538,10 @@ public:
|
||||||
BluetoothService* bs = BluetoothService::Get();
|
BluetoothService* bs = BluetoothService::Get();
|
||||||
NS_ENSURE_TRUE_VOID(bs);
|
NS_ENSURE_TRUE_VOID(bs);
|
||||||
|
|
||||||
|
#if 0 // for API_V2
|
||||||
bs->AdapterAddedReceived();
|
bs->AdapterAddedReceived();
|
||||||
bs->TryFiringAdapterAdded();
|
bs->TryFiringAdapterAdded();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче