зеркало из https://github.com/mozilla/gecko-dev.git
Bug 792345 - patch 1: Listened to RIL status, r=qdot
This commit is contained in:
Родитель
411020abf7
Коммит
8f7dd845f8
|
@ -167,3 +167,9 @@ BluetoothHfpManager::SendLine(const char* aMessage)
|
|||
return SendSocketData(msg);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::CallStateChanged(int aCallIndex, int aCallState,
|
||||
const char* aNumber, bool aIsActive)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable);
|
||||
void Disconnect();
|
||||
bool SendLine(const char* aMessage);
|
||||
void CallStateChanged(int aCallIndex, int aCallState,
|
||||
const char* aNumber, bool aIsActive);
|
||||
|
||||
private:
|
||||
BluetoothHfpManager();
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "BluetoothRilListener.h"
|
||||
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothRILTelephonyCallback : public nsIRILTelephonyCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIRILTELEPHONYCALLBACK
|
||||
|
||||
BluetoothRILTelephonyCallback() { }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(BluetoothRILTelephonyCallback, nsIRILTelephonyCallback)
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothRILTelephonyCallback::CallStateChanged(PRUint32 aCallIndex,
|
||||
PRUint16 aCallState,
|
||||
const nsAString& aNumber,
|
||||
bool aIsActive)
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
hfp->CallStateChanged(aCallIndex, aCallState,
|
||||
NS_ConvertUTF16toUTF8(aNumber).get(), aIsActive);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothRILTelephonyCallback::EnumerateCallState(PRUint32 aCallIndex,
|
||||
PRUint16 aCallState,
|
||||
const nsAString_internal& aNumber,
|
||||
bool aIsActive,
|
||||
bool* aResult)
|
||||
{
|
||||
*aResult = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothRILTelephonyCallback::NotifyError(PRInt32 aCallIndex,
|
||||
const nsAString& aError)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothRilListener::BluetoothRilListener()
|
||||
{
|
||||
mRILTelephonyCallback = new BluetoothRILTelephonyCallback();
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StartListening()
|
||||
{
|
||||
nsCOMPtr<nsIRILContentHelper> ril = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
if (!ril) {
|
||||
NS_ERROR("No RIL Service!");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult rv = ril->RegisterTelephonyCallback(mRILTelephonyCallback);
|
||||
|
||||
return NS_FAILED(rv) ? false : true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StopListening()
|
||||
{
|
||||
nsCOMPtr<nsIRILContentHelper> ril = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
if (!ril) {
|
||||
NS_ERROR("No RIL Service!");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult rv = ril->UnregisterTelephonyCallback(mRILTelephonyCallback);
|
||||
|
||||
return NS_FAILED(rv) ? false : true;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__
|
||||
#define mozilla_dom_bluetooth_bluetoothrillistener_h__
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRadioInterfaceLayer.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothRilListener
|
||||
{
|
||||
public:
|
||||
BluetoothRilListener();
|
||||
|
||||
bool StartListening();
|
||||
bool StopListening();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIRILTelephonyCallback> mRILTelephonyCallback;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -55,6 +55,10 @@ CPPSRCS += \
|
|||
BluetoothHfpManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
CPPSRCS += BluetoothRilListener.cpp
|
||||
endif
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDOMNavigatorBluetooth.idl \
|
||||
nsIDOMBluetoothManager.idl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче