OSDN Git Service

908e78b2e987826c9388a2cfc8ed29425eeb9447
[android-x86/system-bt.git] / service / common / bluetooth / binder / IBluetoothLowEnergyCallback.h
1 //
2 //  Copyright (C) 2015 Google, Inc.
3 //
4 //  Licensed under the Apache License, Version 2.0 (the "License");
5 //  you may not use this file except in compliance with the License.
6 //  You may obtain a copy of the License at:
7 //
8 //  http://www.apache.org/licenses/LICENSE-2.0
9 //
10 //  Unless required by applicable law or agreed to in writing, software
11 //  distributed under the License is distributed on an "AS IS" BASIS,
12 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 //  See the License for the specific language governing permissions and
14 //  limitations under the License.
15 //
16
17 #pragma once
18
19 #include <base/macros.h>
20 #include <binder/IBinder.h>
21 #include <binder/IInterface.h>
22
23 #include <bluetooth/advertise_data.h>
24 #include <bluetooth/advertise_settings.h>
25 #include <bluetooth/scan_result.h>
26
27 namespace ipc {
28 namespace binder {
29
30 // This class defines the Binder IPC interface for receiving callbacks related
31 // to Bluetooth Low Energy operations.
32 // TODO(armansito): This class was written based on a new design doc proposal.
33 // We need to add an AIDL for this to the framework code.
34 //
35 // NOTE: KEEP THIS FILE UP-TO-DATE with the corresponding AIDL, otherwise this
36 // won't be compatible with the Android framework.
37 /* oneway */ class IBluetoothLowEnergyCallback : public android::IInterface {
38  public:
39   DECLARE_META_INTERFACE(BluetoothLowEnergyCallback);
40
41   static const char kServiceName[];
42
43   // Transaction codes for interface methods.
44   enum {
45     ON_CLIENT_REGISTERED_TRANSACTION = android::IBinder::FIRST_CALL_TRANSACTION,
46     ON_CONNECTION_STATE_TRANSACTION,
47     ON_SCAN_RESULT_TRANSACTION,
48     ON_BATCH_SCAN_RESULTS_TRANSACTION,
49     ON_READ_REMOTE_RSSI_TRANSACTION,
50     ON_MULTI_ADVERTISE_CALLBACK_TRANSACTION,
51     ON_SCAN_MANAGER_ERROR_CALLBACK_TRANSACTION,
52     ON_CONFIGURE_ATT_MTU_TRANSACTION,
53     ON_ATT_MTU_CHANGED_TRANSACTION,
54     ON_FOUND_OR_LOST_TRANSACTION,
55   };
56
57   virtual void OnClientRegistered(int status, int client_if) = 0;
58   virtual void OnConnectionState(int status, int client_id, const char* address,
59                                  bool connected) = 0;
60   virtual void OnScanResult(const bluetooth::ScanResult& scan_result) = 0;
61   virtual void OnMultiAdvertiseCallback(
62       int status, bool is_start,
63       const bluetooth::AdvertiseSettings& settings) = 0;
64
65   // TODO(armansito): Complete the API definition.
66
67  private:
68   DISALLOW_COPY_AND_ASSIGN(IBluetoothLowEnergyCallback);
69 };
70
71 // The Binder server interface to allback. A class that
72 // implements IBluetoothLowEnergyCallback must inherit from this class.
73 class BnBluetoothLowEnergyCallback
74     : public android::BnInterface<IBluetoothLowEnergyCallback> {
75  public:
76   BnBluetoothLowEnergyCallback() = default;
77   virtual ~BnBluetoothLowEnergyCallback() = default;
78
79  private:
80   virtual android::status_t onTransact(
81       uint32_t code,
82       const android::Parcel& data,
83       android::Parcel* reply,
84       uint32_t flags = 0);
85
86   DISALLOW_COPY_AND_ASSIGN(BnBluetoothLowEnergyCallback);
87 };
88
89 // The Binder client interface to IBluetoothLowEnergyCallback.
90 class BpBluetoothLowEnergyCallback
91     : public android::BpInterface<IBluetoothLowEnergyCallback> {
92  public:
93   BpBluetoothLowEnergyCallback(const android::sp<android::IBinder>& impl);
94   virtual ~BpBluetoothLowEnergyCallback() = default;
95
96   // IBluetoothLowEnergyCallback overrides:
97   void OnClientRegistered(int status, int client_if) override;
98   void OnConnectionState(int status, int client_id, const char* address,
99                          bool connected) override;
100   void OnScanResult(const bluetooth::ScanResult& scan_result) override;
101   void OnMultiAdvertiseCallback(
102       int status, bool is_start,
103       const bluetooth::AdvertiseSettings& settings) override;
104
105  private:
106   DISALLOW_COPY_AND_ASSIGN(BpBluetoothLowEnergyCallback);
107 };
108
109 }  // namespace binder
110 }  // namespace ipc