Bug 755190 - Enabling b2g bluetooth will lead to system crash, r=qDot

This commit is contained in:
Eric Chou 2012-05-15 12:47:27 -07:00
parent 88f9d706a6
commit 801de3662e
3 changed files with 38 additions and 18 deletions

View File

@ -104,16 +104,16 @@ class ToggleBtTask : public nsRunnable
}
// return 1 if it's enabled, 0 if it's disabled, and -1 on error
int isEnabled = sBluedroidFunctions.bt_is_enabled();
int isEnabled = IsBluetoothEnabled();
if ((isEnabled == 1 && mEnabled) || (isEnabled == 0 && !mEnabled)) {
result = true;
} else if (isEnabled < 0) {
result = false;
} else if (mEnabled) {
result = (sBluedroidFunctions.bt_enable() == 0) ? true : false;
result = (EnableBluetooth() == 0) ? true : false;
} else {
result = (sBluedroidFunctions.bt_disable() == 0) ? true : false;
result = (DisableBluetooth() == 0) ? true : false;
}
#else
result = true;

View File

@ -14,6 +14,21 @@ namespace mozilla {
namespace dom {
namespace bluetooth {
static struct BluedroidFunctions {
bool initialized;
bool tried_initialization;
BluedroidFunctions() :
initialized(false),
tried_initialization(false)
{
}
int (* bt_enable)();
int (* bt_disable)();
int (* bt_is_enabled)();
} sBluedroidFunctions;
bool EnsureBluetoothInit() {
if (sBluedroidFunctions.tried_initialization)
{
@ -49,6 +64,22 @@ bool EnsureBluetoothInit() {
return true;
}
int IsBluetoothEnabled()
{
return sBluedroidFunctions.bt_is_enabled();
}
int EnableBluetooth()
{
return sBluedroidFunctions.bt_enable();
}
int DisableBluetooth()
{
return sBluedroidFunctions.bt_disable();
}
}
}
}

View File

@ -11,22 +11,11 @@ namespace mozilla {
namespace dom {
namespace bluetooth {
static struct BluedroidFunctions {
bool initialized;
bool tried_initialization;
BluedroidFunctions() :
initialized(false),
tried_initialization(false)
{
}
int (* bt_enable)();
int (* bt_disable)();
int (* bt_is_enabled)();
} sBluedroidFunctions;
bool EnsureBluetoothInit();
int IsBluetoothEnabled();
int EnableBluetooth();
int DisableBluetooth();
}
}
}