mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1204801: Use enum constants for Bluetooth Service module, r=btian
This commit is contained in:
parent
83d246f318
commit
7cf66612c7
@ -1419,7 +1419,8 @@ BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
|
||||
static void (BluetoothDaemonProtocol::* const HandleSvc[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
[0x00] = &BluetoothDaemonProtocol::HandleSetupSvc,
|
||||
[BluetoothDaemonSetupModule::SERVICE_ID] =
|
||||
&BluetoothDaemonProtocol::HandleSetupSvc,
|
||||
[0x01] = &BluetoothDaemonProtocol::HandleCoreSvc,
|
||||
[0x02] = &BluetoothDaemonProtocol::HandleSocketSvc,
|
||||
[0x03] = nullptr, // HID host
|
||||
|
@ -24,10 +24,14 @@ BluetoothDaemonSetupModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
const DaemonSocketPDUHeader&,
|
||||
DaemonSocketPDU&,
|
||||
BluetoothSetupResultHandler*) = {
|
||||
[0x00] = &BluetoothDaemonSetupModule::ErrorRsp,
|
||||
[0x01] = &BluetoothDaemonSetupModule::RegisterModuleRsp,
|
||||
[0x02] = &BluetoothDaemonSetupModule::UnregisterModuleRsp,
|
||||
[0x03] = &BluetoothDaemonSetupModule::ConfigurationRsp
|
||||
[OPCODE_ERROR] =
|
||||
&BluetoothDaemonSetupModule::ErrorRsp,
|
||||
[OPCODE_REGISTER_MODULE] =
|
||||
&BluetoothDaemonSetupModule::RegisterModuleRsp,
|
||||
[OPCODE_UNREGISTER_MODULE] =
|
||||
&BluetoothDaemonSetupModule::UnregisterModuleRsp,
|
||||
[OPCODE_CONFIGURATION] =
|
||||
&BluetoothDaemonSetupModule::ConfigurationRsp
|
||||
};
|
||||
|
||||
if (NS_WARN_IF(aHeader.mOpcode >= MOZ_ARRAY_LENGTH(HandleRsp)) ||
|
||||
@ -55,7 +59,9 @@ BluetoothDaemonSetupModule::RegisterModuleCmd(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(new DaemonSocketPDU(0x00, 0x01, 0));
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(
|
||||
new DaemonSocketPDU(SERVICE_ID, OPCODE_REGISTER_MODULE,
|
||||
0));
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
nsresult rv = PackPDU(aId, aMode, aMaxNumClients, *pdu);
|
||||
@ -79,7 +85,9 @@ BluetoothDaemonSetupModule::UnregisterModuleCmd(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(new DaemonSocketPDU(0x00, 0x02, 0));
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(
|
||||
new DaemonSocketPDU(SERVICE_ID, OPCODE_UNREGISTER_MODULE,
|
||||
0));
|
||||
|
||||
nsresult rv = PackPDU(aId, *pdu);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -100,7 +108,9 @@ BluetoothDaemonSetupModule::ConfigurationCmd(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(new DaemonSocketPDU(0x00, 0x03, 0));
|
||||
nsAutoPtr<DaemonSocketPDU> pdu(
|
||||
new DaemonSocketPDU(SERVICE_ID, OPCODE_CONFIGURATION,
|
||||
0));
|
||||
|
||||
nsresult rv = PackPDU(
|
||||
aLen, PackArray<BluetoothConfigurationParameter>(aParam, aLen), *pdu);
|
||||
|
@ -20,6 +20,17 @@ using mozilla::ipc::DaemonSocketResultHandler;
|
||||
class BluetoothDaemonSetupModule
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
SERVICE_ID = 0x00
|
||||
};
|
||||
|
||||
enum {
|
||||
OPCODE_ERROR = 0x00,
|
||||
OPCODE_REGISTER_MODULE = 0x01,
|
||||
OPCODE_UNREGISTER_MODULE = 0x02,
|
||||
OPCODE_CONFIGURATION = 0x03
|
||||
};
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user