mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 861085 - Enable/Disable Bluetooth based on mozSettings value at startup, r=gyeh, r=qdot
This commit is contained in:
parent
fd6cbbfcfa
commit
e909254f82
@ -184,7 +184,7 @@ public:
|
||||
* When two values are the same, we don't switch on/off bluetooth,
|
||||
* but we still do ToggleBtAck task.
|
||||
*/
|
||||
if (mEnabled == gBluetoothService->IsEnabled()) {
|
||||
if (mEnabled == gBluetoothService->IsEnabledInternal()) {
|
||||
NS_WARNING("Bluetooth has already been enabled/disabled before.");
|
||||
} else {
|
||||
// Switch on/off bluetooth
|
||||
@ -529,18 +529,7 @@ nsresult
|
||||
BluetoothService::HandleStartupSettingsCheck(bool aEnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aEnable) {
|
||||
return StartStopBluetooth(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since BLUETOOTH_ENABLED_SETTING is false, we don't have to turn on
|
||||
* bluetooth here, and set gToggleInProgress back to false.
|
||||
*/
|
||||
gToggleInProgress = false;
|
||||
|
||||
return NS_OK;
|
||||
return StartStopBluetooth(aEnable);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -292,7 +292,7 @@ protected:
|
||||
virtual nsresult
|
||||
StartInternal() = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Platform specific startup functions go here. Usually deals with member
|
||||
* variables, so not static. Guaranteed to be called outside of main thread.
|
||||
*
|
||||
@ -301,6 +301,15 @@ protected:
|
||||
virtual nsresult
|
||||
StopInternal() = 0;
|
||||
|
||||
/**
|
||||
* Platform specific startup functions go here. Usually deals with member
|
||||
* variables, so not static. Guaranteed to be called outside of main thread.
|
||||
*
|
||||
* @return true if Bluetooth is enabled, false otherwise
|
||||
*/
|
||||
virtual bool
|
||||
IsEnabledInternal() = 0;
|
||||
|
||||
/**
|
||||
* Called when XPCOM first creates this service.
|
||||
*/
|
||||
|
@ -120,7 +120,7 @@ StartStopGonkBluetooth(bool aShouldEnable)
|
||||
nsresult
|
||||
BluetoothGonkService::StartInternal()
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "This should not run on the main thread!");
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsresult ret;
|
||||
|
||||
@ -136,7 +136,7 @@ BluetoothGonkService::StartInternal()
|
||||
nsresult
|
||||
BluetoothGonkService::StopInternal()
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "This should not run on the main thread!");
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsresult ret;
|
||||
|
||||
@ -149,3 +149,16 @@ BluetoothGonkService::StopInternal()
|
||||
return StartStopGonkBluetooth(false);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothGonkService::IsEnabledInternal()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
if (!EnsureBluetoothInit()) {
|
||||
NS_ERROR("Failed to load bluedroid library.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return (sBluedroidFunctions.bt_is_enabled() == 1);
|
||||
}
|
||||
|
||||
|
@ -35,23 +35,27 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
class BluetoothGonkService : public BluetoothDBusService
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Set up variables and start the platform specific connection. Must
|
||||
* be called from main thread.
|
||||
* be called from non-main thread.
|
||||
*
|
||||
* @return NS_OK if connection starts successfully, NS_ERROR_FAILURE
|
||||
* otherwise
|
||||
* @return NS_OK if connection starts successfully, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult StartInternal();
|
||||
|
||||
/**
|
||||
* Stop the platform specific connection. Must be called from main
|
||||
* thread.
|
||||
/**
|
||||
* Stop the platform specific connection. Must be called from non-main thread.
|
||||
*
|
||||
* @return NS_OK if connection starts successfully, NS_ERROR_FAILURE
|
||||
* otherwise
|
||||
* @return NS_OK if connection starts successfully, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult StopInternal();
|
||||
|
||||
/**
|
||||
* Get status of Bluetooth. Must be called from non-main thread.
|
||||
*
|
||||
* @return true if Bluetooth is enabled, false otherwise
|
||||
*/
|
||||
virtual bool IsEnabledInternal();
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -361,6 +361,13 @@ BluetoothServiceChildProcess::StopInternal()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothServiceChildProcess::IsEnabledInternal()
|
||||
{
|
||||
MOZ_NOT_REACHED("This should never be called!");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothServiceChildProcess::IsConnected(uint16_t aProfileId)
|
||||
{
|
||||
|
@ -163,6 +163,10 @@ private:
|
||||
virtual nsresult
|
||||
StopInternal() MOZ_OVERRIDE;
|
||||
|
||||
// This method should never be called.
|
||||
virtual bool
|
||||
IsEnabledInternal() MOZ_OVERRIDE;
|
||||
|
||||
// Should never be called from the child
|
||||
virtual nsresult
|
||||
GetDevicePropertiesInternal(const BluetoothSignal& aSignal) MOZ_OVERRIDE;
|
||||
|
@ -1708,7 +1708,9 @@ BluetoothDBusService::StopInternal()
|
||||
// If Bluetooth is turned off while connections exist, in order not to only
|
||||
// disconnect with profile connections with low level ACL connections alive,
|
||||
// we disconnect ACLs directly instead of closing each socket.
|
||||
DisconnectAllAcls(sAdapterPath);
|
||||
if (!sAdapterPath.IsEmpty()) {
|
||||
DisconnectAllAcls(sAdapterPath);
|
||||
}
|
||||
|
||||
if (!mConnection) {
|
||||
StopDBus();
|
||||
@ -1756,6 +1758,12 @@ BluetoothDBusService::StopInternal()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothDBusService::IsEnabledInternal()
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
class DefaultAdapterPropertiesRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
|
||||
virtual nsresult StopInternal();
|
||||
|
||||
virtual bool IsEnabledInternal();
|
||||
|
||||
virtual nsresult GetDefaultAdapterPathInternal(BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
|
Loading…
Reference in New Issue
Block a user