Backed out changeset b064b9271e0e (bug 942712) Build bustage on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2013-11-28 12:09:46 +01:00
parent 0e2b0a7095
commit bcf7e426ab
4 changed files with 37 additions and 98 deletions

View File

@ -164,9 +164,6 @@ public:
BluetoothSignal signal(signalName, NS_LITERAL_STRING(KEY_MANAGER), true);
gBluetoothService->DistributeSignal(signal);
// Event 'AdapterAdded' has to be fired after firing 'Enabled'
gBluetoothService->TryFiringAdapterAdded();
return NS_OK;
}
@ -511,8 +508,6 @@ BluetoothService::StartStopBluetooth(bool aStart, bool aIsStartup)
LazyIdleThread::ManualShutdown);
}
mAdapterAddedReceived = false;
nsCOMPtr<nsIRunnable> runnable = new ToggleBtTask(aStart, aIsStartup);
nsresult rv = mBluetoothThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
@ -791,20 +786,6 @@ BluetoothService::Observe(nsISupports* aSubject, const char* aTopic,
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::Notify(const BluetoothSignal& aData)
{

View File

@ -317,23 +317,9 @@ public:
void
RemoveObserverFromTable(const nsAString& key);
/**
* Below 2 function/variable are used for ensuring event 'AdapterAdded' will
* be fired after event 'Enabled'.
*/
void TryFiringAdapterAdded();
void
AdapterAddedReceived()
{
MOZ_ASSERT(NS_IsMainThread());
mAdapterAddedReceived = true;
}
protected:
BluetoothService() : mEnabled(false)
, mAdapterAddedReceived(false)
BluetoothService()
: mEnabled(false)
{
}
@ -422,8 +408,6 @@ private:
* Bluetooth operations though.
*/
nsCOMPtr<nsIThread> mBluetoothThread;
bool mAdapterAddedReceived;
};
END_BLUETOOTH_NAMESPACE

View File

@ -35,43 +35,6 @@ using namespace mozilla;
using namespace mozilla::ipc;
USING_BLUETOOTH_NAMESPACE
class SetupAfterEnabledTask : public nsRunnable
{
public:
SetupAfterEnabledTask()
{ }
NS_IMETHOD
Run()
{
MOZ_ASSERT(NS_IsMainThread());
// Bluetooth scan mode is NONE by default
bt_scan_mode_t mode = BT_SCAN_MODE_CONNECTABLE;
bt_property_t prop;
prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
prop.val = (void*)&mode;
prop.len = sizeof(mode);
NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
int ret = sBtInterface->set_adapter_property(&prop);
if (ret != BT_STATUS_SUCCESS) {
BT_LOGR("%s: Fail to set: BT_SCAN_MODE_CONNECTABLE", __FUNCTION__);
}
// 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();
return NS_OK;
}
};
/**
* Classes only used in this file
*/
@ -88,8 +51,6 @@ public:
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
bs->DistributeSignal(mSignal);
return NS_OK;
@ -261,6 +222,34 @@ BdAddressTypeToString(bt_bdaddr_t* aBdAddressType, nsAString& aRetBdAddress)
aRetBdAddress = NS_ConvertUTF8toUTF16((char*)bdstr);
}
static void
Setup()
{
// Bluetooth scan mode is NONE by default
bt_scan_mode_t mode = BT_SCAN_MODE_CONNECTABLE;
bt_property_t prop;
prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
prop.val = (void*)&mode;
prop.len = sizeof(mode);
NS_ENSURE_TRUE_VOID(sBtInterface);
int ret = sBtInterface->set_adapter_property(&prop);
if (ret != BT_STATUS_SUCCESS) {
BT_LOGR("%s: Fail to set: BT_SCAN_MODE_CONNECTABLE", __FUNCTION__);
}
// Event 'AdapterAdded' has to be fired after enabled to notify Gaia
// that BluetoothAdapter is ready.
BluetoothSignal signal(NS_LITERAL_STRING("AdapterAdded"),
NS_LITERAL_STRING(KEY_MANAGER), true);
nsRefPtr<DistributeBluetoothSignalTask>
t = new DistributeBluetoothSignalTask(signal);
if (NS_FAILED(NS_DispatchToMainThread(t))) {
BT_WARNING("Failed to dispatch to main thread!");
}
}
static void
AdapterStateChangeCallback(bt_state_t aStatus)
{
@ -275,9 +264,8 @@ AdapterStateChangeCallback(bt_state_t aStatus)
lock.Notify();
}
if (sIsBtEnabled &&
NS_FAILED(NS_DispatchToMainThread(new SetupAfterEnabledTask()))) {
BT_WARNING("Failed to dispatch to main thread!");
if (sIsBtEnabled) {
Setup();
}
}

View File

@ -335,24 +335,6 @@ private:
BluetoothSignal mSignal;
};
class TryFiringAdapterAddedTask : public nsRunnable
{
public:
NS_IMETHOD
Run()
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
bs->AdapterAddedReceived();
bs->TryFiringAdapterAdded();
return NS_OK;
}
};
static bool
IsDBusMessageError(DBusMessage* aMsg, DBusError* aErr, nsAString& aErrorStr)
{
@ -727,7 +709,11 @@ GetProperty(DBusMessageIter aIter, Properties* aPropertyTypes,
// Notify BluetoothManager whenever adapter name is ready.
if (!propertyValue.get_nsString().IsEmpty()) {
sAdapterNameIsReady = true;
NS_DispatchToMainThread(new TryFiringAdapterAddedTask());
BluetoothSignal signal(NS_LITERAL_STRING("AdapterAdded"),
NS_LITERAL_STRING(KEY_MANAGER), sAdapterPath);
nsRefPtr<DistributeBluetoothSignalTask> task =
new DistributeBluetoothSignalTask(signal);
NS_DispatchToMainThread(task);
}
}