2012-09-26 06:34:55 -07:00
|
|
|
/* -*- 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_bluetoothhfpmanager_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
|
|
|
|
|
|
|
|
#include "BluetoothCommon.h"
|
2012-09-27 05:24:06 -07:00
|
|
|
#include "BluetoothRilListener.h"
|
2012-09-26 06:34:55 -07:00
|
|
|
#include "mozilla/ipc/UnixSocket.h"
|
2012-09-25 03:18:38 -07:00
|
|
|
#include "nsIObserver.h"
|
2012-09-26 06:34:55 -07:00
|
|
|
|
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
class BluetoothReplyRunnable;
|
2012-10-05 17:11:24 -07:00
|
|
|
class BluetoothHfpManagerObserver;
|
2013-01-15 22:13:58 -08:00
|
|
|
class Call;
|
2012-09-26 06:34:55 -07:00
|
|
|
|
2013-01-10 22:00:04 -08:00
|
|
|
/**
|
|
|
|
* These costants are defined in 4.33.2 "AT Capabilities Re-Used from GSM 07.07
|
|
|
|
* and 3GPP 27.007" in Bluetooth hands-free profile 1.6
|
|
|
|
*/
|
|
|
|
enum BluetoothCmeError {
|
|
|
|
AG_FAILURE = 0,
|
|
|
|
NO_CONNECTION_TO_PHONE = 1,
|
|
|
|
OPERATION_NOT_ALLOWED = 3,
|
|
|
|
OPERATION_NOT_SUPPORTED = 4,
|
|
|
|
PIN_REQUIRED = 5,
|
|
|
|
SIM_NOT_INSERTED = 10,
|
|
|
|
SIM_PIN_REQUIRED = 11,
|
|
|
|
SIM_PUK_REQUIRED = 12,
|
|
|
|
SIM_FAILURE = 13,
|
|
|
|
SIM_BUSY = 14,
|
|
|
|
INCORRECT_PASSWORD = 16,
|
|
|
|
SIM_PIN2_REQUIRED = 17,
|
|
|
|
SIM_PUK2_REQUIRED = 18,
|
|
|
|
MEMORY_FULL = 20,
|
|
|
|
INVALID_INDEX = 21,
|
|
|
|
MEMORY_FAILURE = 23,
|
|
|
|
TEXT_STRING_TOO_LONG = 24,
|
|
|
|
INVALID_CHARACTERS_IN_TEXT_STRING = 25,
|
|
|
|
DIAL_STRING_TOO_LONG = 26,
|
|
|
|
INVALID_CHARACTERS_IN_DIAL_STRING = 27,
|
|
|
|
NO_NETWORK_SERVICE = 30,
|
|
|
|
NETWORK_TIMEOUT = 31,
|
|
|
|
NETWORK_NOT_ALLOWED = 32
|
|
|
|
};
|
|
|
|
|
2012-09-26 06:34:55 -07:00
|
|
|
class BluetoothHfpManager : public mozilla::ipc::UnixSocketConsumer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BluetoothHfpManager* Get();
|
2012-10-10 22:49:11 -07:00
|
|
|
virtual void ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage)
|
|
|
|
MOZ_OVERRIDE;
|
2013-01-15 22:13:41 -08:00
|
|
|
|
2012-09-26 06:34:55 -07:00
|
|
|
bool Connect(const nsAString& aDeviceObjectPath,
|
2012-10-05 03:48:05 -07:00
|
|
|
const bool aIsHandsfree,
|
2012-09-26 06:34:55 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable);
|
|
|
|
void Disconnect();
|
2013-01-15 22:13:41 -08:00
|
|
|
bool Listen();
|
|
|
|
|
2013-01-15 22:13:58 -08:00
|
|
|
void CallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
|
|
|
|
const nsAString& aNumber, bool aIsActive);
|
|
|
|
void EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState,
|
|
|
|
const nsAString& aNumber, bool aIsActive);
|
2012-10-02 22:53:39 -07:00
|
|
|
|
2012-09-26 06:34:55 -07:00
|
|
|
private:
|
2013-01-15 22:13:41 -08:00
|
|
|
class GetVolumeTask;
|
|
|
|
friend class GetVolumeTask;
|
2012-10-05 17:11:24 -07:00
|
|
|
friend class BluetoothHfpManagerObserver;
|
2013-01-15 22:13:41 -08:00
|
|
|
|
2012-09-26 06:34:55 -07:00
|
|
|
BluetoothHfpManager();
|
2013-01-15 22:13:41 -08:00
|
|
|
~BluetoothHfpManager();
|
2012-12-17 01:44:32 -08:00
|
|
|
nsresult HandleIccInfoChanged();
|
2012-12-19 23:28:51 -08:00
|
|
|
nsresult HandleShutdown();
|
|
|
|
nsresult HandleVolumeChanged(const nsAString& aData);
|
|
|
|
nsresult HandleVoiceConnectionChanged();
|
2012-12-17 01:44:32 -08:00
|
|
|
|
2012-10-05 17:11:24 -07:00
|
|
|
bool Init();
|
|
|
|
void Cleanup();
|
2012-10-01 00:44:48 -07:00
|
|
|
void NotifyDialer(const nsAString& aCommand);
|
2012-10-22 03:34:15 -07:00
|
|
|
void NotifySettings();
|
2013-01-15 22:13:58 -08:00
|
|
|
void Reset();
|
|
|
|
void ResetCallArray();
|
|
|
|
bool SendCommand(const char* aCommand, const uint16_t aValue = 0);
|
2013-01-15 22:13:41 -08:00
|
|
|
bool SendLine(const char* aMessage);
|
2013-01-15 22:13:58 -08:00
|
|
|
void SetupCIND(uint32_t aCallIndex, uint16_t aCallState,
|
|
|
|
const nsAString& aNumber, bool aInitial);
|
2012-10-10 22:49:11 -07:00
|
|
|
virtual void OnConnectSuccess() MOZ_OVERRIDE;
|
|
|
|
virtual void OnConnectError() MOZ_OVERRIDE;
|
2012-10-12 11:38:14 -07:00
|
|
|
virtual void OnDisconnect() MOZ_OVERRIDE;
|
2012-09-25 03:18:38 -07:00
|
|
|
|
2012-09-26 19:24:39 -07:00
|
|
|
int mCurrentVgs;
|
2013-01-07 00:58:59 -08:00
|
|
|
int mCurrentVgm;
|
2013-01-15 22:13:58 -08:00
|
|
|
uint32_t mCurrentCallIndex;
|
2013-01-15 22:17:41 -08:00
|
|
|
bool mCCWA;
|
2012-12-17 07:24:35 -08:00
|
|
|
bool mCLIP;
|
2013-01-10 22:00:04 -08:00
|
|
|
bool mCMEE;
|
2013-01-08 22:05:34 -08:00
|
|
|
bool mCMER;
|
2012-10-25 03:50:41 -07:00
|
|
|
bool mReceiveVgsFlag;
|
2012-10-26 02:21:32 -07:00
|
|
|
nsString mDevicePath;
|
2012-12-17 01:44:32 -08:00
|
|
|
nsString mMsisdn;
|
2012-10-26 02:28:39 -07:00
|
|
|
enum mozilla::ipc::SocketConnectionStatus mSocketStatus;
|
2013-01-15 22:13:58 -08:00
|
|
|
|
|
|
|
nsTArray<Call> mCurrentCallArray;
|
2012-09-27 05:24:06 -07:00
|
|
|
nsAutoPtr<BluetoothRilListener> mListener;
|
2012-11-07 15:48:39 -08:00
|
|
|
nsRefPtr<BluetoothReplyRunnable> mRunnable;
|
2012-09-26 06:34:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|