2 // Copyright (C) 2015 Google, Inc.
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:
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <base/macros.h>
20 #include <binder/IBinder.h>
21 #include <binder/IInterface.h>
23 #include <bluetooth/advertise_data.h>
24 #include <bluetooth/advertise_settings.h>
25 #include <bluetooth/scan_result.h>
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.
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 {
39 DECLARE_META_INTERFACE(BluetoothLowEnergyCallback);
41 static const char kServiceName[];
43 // Transaction codes for interface methods.
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,
57 virtual void OnClientRegistered(int status, int client_if) = 0;
58 virtual void OnConnectionState(int status, int client_id, const char* address,
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;
65 // TODO(armansito): Complete the API definition.
68 DISALLOW_COPY_AND_ASSIGN(IBluetoothLowEnergyCallback);
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> {
76 BnBluetoothLowEnergyCallback() = default;
77 virtual ~BnBluetoothLowEnergyCallback() = default;
80 virtual android::status_t onTransact(
82 const android::Parcel& data,
83 android::Parcel* reply,
86 DISALLOW_COPY_AND_ASSIGN(BnBluetoothLowEnergyCallback);
89 // The Binder client interface to IBluetoothLowEnergyCallback.
90 class BpBluetoothLowEnergyCallback
91 : public android::BpInterface<IBluetoothLowEnergyCallback> {
93 BpBluetoothLowEnergyCallback(const android::sp<android::IBinder>& impl);
94 virtual ~BpBluetoothLowEnergyCallback() = default;
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;
106 DISALLOW_COPY_AND_ASSIGN(BpBluetoothLowEnergyCallback);
109 } // namespace binder