// // Copyright (C) 2016 Google, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at: // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #pragma once #include #include #include #include // BtBinderFacade provides simple wrappers to call Binder apis. // Each public function returns a tuple of the return type and an integer // representing the pass/fail value of the function. The functions check to see // if the API call is actually possible. If it is the function's tuple will // contain the actual result and an integer that indicates the value passed. If // the function is not possible then there will be a dummy return value in the // first position of the tuple and the second value in the tuple indicates the // value failed. Therefore it is up to the function to decide whether the // expected api call is actually possible before calling it. // // TODO(tturney): Instead of using an integer in the tuple to represent // pass/fail, create a class that properly represents the result of the // function. class BtBinderFacade { public: BtBinderFacade(); std::tuple BtBinderEnable(); std::tuple BtBinderGetAddress(); std::tuple BtBinderGetName(); std::tuple BtBinderInitInterface(); std::tuple BtBinderRegisterBLE(); std::tuple BtBinderSetAdvSettings( int mode, int timeout_seconds, int tx_power_level, bool is_connectable); std::tuple BtBinderSetName(std::string name); private: bool SharedValidator(); // Returns a handle to the IBluetooth Binder from the Android ServiceManager. // Binder client code can use this to make calls to the service. android::sp bt_iface; // Returns a handle to the IBluetoothLowEnergy Binder from the Android // ServiceManager. Binder client code can use this to make calls to the // service. android::sp ble_iface; std::map adv_settings_map; int adv_settings_count; int manu_data_count; };