本文整理汇总了C++中BluetoothHfpManager类的典型用法代码示例。如果您正苦于以下问题:C++ BluetoothHfpManager类的具体用法?C++ BluetoothHfpManager怎么用?C++ BluetoothHfpManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BluetoothHfpManager类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* @param aSend A boolean indicates whether we need to notify headset or not
*/
nsresult
TelephonyListener::HandleCallInfo(nsITelephonyCallInfo* aInfo, bool aSend)
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
uint32_t callIndex;
uint16_t callState;
nsAutoString number;
nsAutoString disconnectedReason;
bool isOutgoing;
bool isConference;
aInfo->GetCallIndex(&callIndex);
aInfo->GetCallState(&callState);
aInfo->GetNumber(number);
aInfo->GetDisconnectedReason(disconnectedReason);
aInfo->GetIsOutgoing(&isOutgoing);
aInfo->GetIsConference(&isConference);
// The disconnectedReason of a disconnected call must be nonempty no matter
// the call is disconnected for a normal reason or an error.
MOZ_ASSERT((callState != nsITelephonyService::CALL_STATE_DISCONNECTED ||
!disconnectedReason.IsEmpty()),
"disconnectedReason of an disconnected call must be nonempty.");
hfp->HandleCallStateChanged(callIndex, callState, disconnectedReason, number,
isOutgoing, isConference, aSend);
return NS_OK;
}
示例2: cmd
void
AudioManager::HandleBluetoothStatusChanged(nsISupports* aSubject,
const char* aTopic,
const nsCString aAddress)
{
#ifdef MOZ_B2G_BT
bool status;
if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
BluetoothHfpManager* hfp =
static_cast<BluetoothHfpManager*>(aSubject);
status = hfp->IsScoConnected();
} else {
BluetoothProfileManagerBase* profile =
static_cast<BluetoothProfileManagerBase*>(aSubject);
status = profile->IsConnected();
}
audio_policy_dev_state_t audioState = status ?
AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
if (audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
String8 cmd;
cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
AudioSystem::setParameters(0, cmd);
SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_BT_SCO);
} else {
int32_t force;
GetForceForUse(nsIAudioManager::USE_COMMUNICATION, &force);
if (force == nsIAudioManager::FORCE_BT_SCO)
SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_NONE);
}
} else if (!strcmp(aTopic, BLUETOOTH_A2DP_STATUS_CHANGED_ID)) {
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,
audioState, aAddress.get());
if (audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
String8 cmd("bluetooth_enabled=true");
AudioSystem::setParameters(0, cmd);
cmd.setTo("A2dpSuspended=false");
AudioSystem::setParameters(0, cmd);
} else {
String8 cmd("bluetooth_enabled=false");
AudioSystem::setParameters(0, cmd);
cmd.setTo("A2dpSuspended=true");
AudioSystem::setParameters(0, cmd);
}
} else if (!strcmp(aTopic, BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
audioState, aAddress.get());
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
audioState, aAddress.get());
}
#endif
}
示例3:
NS_IMETHODIMP
TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId,
const nsAString& aNumber)
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
hfp->UpdateSecondNumber(aNumber);
return NS_OK;
}
示例4: NS_ENSURE_TRUE
NS_IMETHODIMP
IccListener::NotifyIccInfoChanged()
{
// mOwner would be set to nullptr only in the dtor of BluetoothRilListener
NS_ENSURE_TRUE(mOwner, NS_ERROR_FAILURE);
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
hfp->HandleIccInfoChanged(mOwner->mClientId);
return NS_OK;
}
示例5: MOZ_ASSERT
void
BluetoothServiceBluedroid::DisconnectSco(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
if (!hfp || !hfp->DisconnectSco()) {
DispatchReplyError(aRunnable, NS_LITERAL_STRING("DisconnectSco failed"));
return;
}
DispatchReplySuccess(aRunnable);
}
示例6: MOZ_ASSERT
void
BluetoothServiceBluedroid::IsScoConnected(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
if (!hfp) {
NS_NAMED_LITERAL_STRING(replyError, "Fail to get BluetoothHfpManager");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
DispatchBluetoothReply(aRunnable, hfp->IsScoConnected(), EmptyString());
}
示例7: EmptyString
NS_IMETHODIMP
TelephonyListener::EnumerateCallState(uint32_t aServiceId,
uint32_t aCallIndex,
uint16_t aCallState,
const nsAString_internal& aNumber,
bool aIsOutgoing,
bool aIsEmergency,
bool aIsConference,
bool aIsSwitchable,
bool aIsMergeable)
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
hfp->HandleCallStateChanged(aCallIndex, aCallState, EmptyString(), aNumber,
aIsOutgoing, aIsConference, false);
return NS_OK;
}
示例8: MOZ_ASSERT
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 (!mBluetoothCommandThread) {
// Don't create a new thread after we've begun shutdown since bluetooth
// can't be running.
return NS_OK;
}
}
nsresult rv;
if (!mBluetoothCommandThread) {
MOZ_ASSERT(!gInShutdown);
rv = NS_NewNamedThread("BluetoothCmd",
getter_AddRefs(mBluetoothCommandThread));
NS_ENSURE_SUCCESS(rv, rv);
}
if (!aStart) {
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
hfp->Disconnect();
BluetoothOppManager* opp = BluetoothOppManager::Get();
opp->Disconnect();
}
nsCOMPtr<nsIRunnable> runnable = new ToggleBtTask(aStart, aIsStartup);
rv = mBluetoothCommandThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例9: Handle
NS_DECL_ISUPPORTS
NS_IMETHOD
Handle(const nsAString& aName, const jsval& aResult)
{
MOZ_ASSERT(NS_IsMainThread());
JSContext *cx = nsContentUtils::GetCurrentJSContext();
NS_ENSURE_TRUE(cx, NS_OK);
if (!aResult.isNumber()) {
NS_WARNING("'" AUDIO_VOLUME_BT_SCO "' is not a number!");
return NS_OK;
}
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
hfp->SetVolume(aResult.toNumber());
return NS_OK;
}
示例10: MOZ_ASSERT
// static
BluetoothHfpManager*
BluetoothHfpManager::Get()
{
MOZ_ASSERT(NS_IsMainThread());
// If sBluetoothHfpManager already exists, exit early
if (sBluetoothHfpManager) {
return sBluetoothHfpManager;
}
// If we're in shutdown, don't create a new instance
NS_ENSURE_FALSE(sInShutdown, nullptr);
// Create a new instance and return
BluetoothHfpManager* manager = new BluetoothHfpManager();
NS_ENSURE_TRUE(manager->Init(), nullptr);
sBluetoothHfpManager = manager;
return sBluetoothHfpManager;
}
示例11: EmptyString
/**
* @param aSend A boolean indicates whether we need to notify headset or not
*/
nsresult
TelephonyListener::HandleCallInfo(nsITelephonyCallInfo* aInfo, bool aSend)
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
uint32_t callIndex;
uint16_t callState;
nsAutoString number;
bool isOutgoing;
bool isConference;
aInfo->GetCallIndex(&callIndex);
aInfo->GetCallState(&callState);
aInfo->GetNumber(number);
aInfo->GetIsOutgoing(&isOutgoing);
aInfo->GetIsConference(&isConference);
hfp->HandleCallStateChanged(callIndex, callState, EmptyString(), number,
isOutgoing, isConference, aSend);
return NS_OK;
}