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 namespace ipc { 24 namespace binder { 25 26 // This class defines the Binder IPC interface for receiving callbacks related 27 // to Bluetooth GATT client-role operations. 28 // TODO(armansito): This class was written based on a new design doc proposal. 29 // We need to add an AIDL for this to the framework code. 30 // 31 // NOTE: KEEP THIS FILE UP-TO-DATE with the corresponding AIDL, otherwise this 32 // won't be compatible with the Android framework. 33 /* oneway */ class IBluetoothGattClientCallback : public android::IInterface { 34 public: 35 DECLARE_META_INTERFACE(BluetoothGattClientCallback); 36 37 static const char kServiceName[]; 38 39 // Transaction codes for interface methods. 40 enum { 41 ON_CLIENT_REGISTERED_TRANSACTION = android::IBinder::FIRST_CALL_TRANSACTION, 42 ON_GET_SERVICE_TRANSACTION, 43 ON_GET_INCLUDED_SERVICE_TRANSACTION, 44 ON_GET_CHARACTERISTIC_TRANSACTION, 45 ON_GET_DESCRIPTOR_TRANSACTION, 46 ON_SEARCH_COMPLETE_TRANSACTION, 47 ON_CHARACTERISTIC_READ_TRANSACTION, 48 ON_CHARACTERISTIC_WRITE_TRANSACTION, 49 ON_EXECUTE_WRITE_TRANSACTION, 50 ON_DESCRIPTOR_READ_TRANSACTION, 51 ON_DESCRIPTOR_WRITE_TRANSACTION, 52 ON_NOTIFY_TRANSACTION, 53 }; 54 55 virtual void OnClientRegistered(int status, int client_id) = 0; 56 57 // TODO(armansito): Complete interface definition. 58 59 private: 60 DISALLOW_COPY_AND_ASSIGN(IBluetoothGattClientCallback); 61 }; 62 63 // The Binder server interface to IBluetoothGattClientCallback. A class that 64 // implements IBluetoothGattClientCallback must inherit from this class. 65 class BnBluetoothGattClientCallback 66 : public android::BnInterface<IBluetoothGattClientCallback> { 67 public: 68 BnBluetoothGattClientCallback() = default; 69 virtual ~BnBluetoothGattClientCallback() = default; 70 71 private: 72 virtual android::status_t onTransact( 73 uint32_t code, 74 const android::Parcel& data, 75 android::Parcel* reply, 76 uint32_t flags = 0); 77 78 DISALLOW_COPY_AND_ASSIGN(BnBluetoothGattClientCallback); 79 }; 80 81 // The Binder client interface to IBluetoothGattClientCallback. 82 class BpBluetoothGattClientCallback 83 : public android::BpInterface<IBluetoothGattClientCallback> { 84 public: 85 explicit BpBluetoothGattClientCallback( 86 const android::sp<android::IBinder>& impl); 87 virtual ~BpBluetoothGattClientCallback() = default; 88 89 // IBluetoothGattClientCallback overrides: 90 void OnClientRegistered(int status, int server_if) override; 91 92 private: 93 DISALLOW_COPY_AND_ASSIGN(BpBluetoothGattClientCallback); 94 }; 95 96 } // namespace binder 97 } // namespace ipc 98