本文整理汇总了C++中BluetoothProfileManagerBase::Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ BluetoothProfileManagerBase::Disconnect方法的具体用法?C++ BluetoothProfileManagerBase::Disconnect怎么用?C++ BluetoothProfileManagerBase::Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BluetoothProfileManagerBase
的用法示例。
在下文中一共展示了BluetoothProfileManagerBase::Disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
nsresult
BluetoothService::StopBluetooth(bool aIsStartup)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothProfileManagerBase* profile;
profile = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
profile = BluetoothOppManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
profile = BluetoothA2dpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
profile = BluetoothHidManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
mAdapterAddedReceived = false;
/* When IsEnabled() is false, we don't switch off Bluetooth but we still
* send ToggleBtAck task. One special case happens at startup stage. At
* startup, the initialization of BluetoothService still has to be done
* even if Bluetooth is disabled.
*
* Please see bug 892392 for more information.
*/
if (aIsStartup || sBluetoothService->IsEnabled()) {
// Switch Bluetooth off
if (NS_FAILED(sBluetoothService->StopInternal())) {
BT_WARNING("Bluetooth service failed to stop!");
}
} else {
BT_WARNING("Bluetooth has already been enabled/disabled before.");
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(false);
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
BT_WARNING("Failed to dispatch to main thread!");
}
}
return NS_OK;
}
示例2: LazyIdleThread
nsresult
BluetoothService::StartStopBluetooth(bool aStart, bool aIsStartup)
{
MOZ_ASSERT(NS_IsMainThread());
if (gInShutdown) {
if (aStart) {
// Don't try to start if we're already shutting down.
MOZ_ASSERT(false, "Start called while in shutdown!");
return NS_ERROR_FAILURE;
}
if (!mBluetoothThread) {
// Don't create a new thread after we've begun shutdown since bluetooth
// can't be running.
return NS_OK;
}
}
if (!aStart) {
BluetoothProfileManagerBase* profile;
profile = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
profile = BluetoothOppManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
profile = BluetoothA2dpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
profile = BluetoothHidManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
}
if (!mBluetoothThread) {
mBluetoothThread = new LazyIdleThread(DEFAULT_THREAD_TIMEOUT_MS,
NS_LITERAL_CSTRING("Bluetooth"),
LazyIdleThread::ManualShutdown);
}
mAdapterAddedReceived = false;
nsCOMPtr<nsIRunnable> runnable = new ToggleBtTask(aStart, aIsStartup);
nsresult rv = mBluetoothThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例3: StopGonkBluetooth
nsresult
BluetoothServiceBluedroid::StopInternal(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothProfileManagerBase* profile;
profile = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
profile = BluetoothOppManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
}
profile = BluetoothA2dpManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
profile = BluetoothHidManager::Get();
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
if (profile->IsConnected()) {
profile->Disconnect(nullptr);
} else {
profile->Reset();
}
// aRunnable will be a nullptr during starup and shutdown
if(aRunnable) {
sChangeAdapterStateRunnableArray.AppendElement(aRunnable);
}
nsresult ret = StopGonkBluetooth();
if (NS_FAILED(ret)) {
BluetoothService::AcknowledgeToggleBt(true);
// Reject Promise
if(aRunnable) {
DispatchReplyError(aRunnable, NS_LITERAL_STRING("StopBluetoothError"));
sChangeAdapterStateRunnableArray.RemoveElement(aRunnable);
}
BT_LOGR("Error");
}
return ret;
}