зеркало из https://github.com/mozilla/pjs.git
Bug 755190 - Enabling b2g bluetooth will lead to system crash, r=qDot
This commit is contained in:
Родитель
74d5e460c9
Коммит
8f1bfaeee9
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче