167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// 267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// Copyright (C) 2015 Google, Inc. 367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// 467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// Licensed under the Apache License, Version 2.0 (the "License"); 567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// you may not use this file except in compliance with the License. 667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// You may obtain a copy of the License at: 767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// 867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// http://www.apache.org/licenses/LICENSE-2.0 967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// 1067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// Unless required by applicable law or agreed to in writing, software 1167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// distributed under the License is distributed on an "AS IS" BASIS, 1267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// See the License for the specific language governing permissions and 1467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// limitations under the License. 1567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// 1667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 1767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#pragma once 1867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 1967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include <memory> 2067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 2167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include <base/macros.h> 2267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 2367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include <android/bluetooth/IBluetoothLeAdvertiserCallback.h> 2467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include "android/bluetooth/BnBluetoothLeAdvertiser.h" 2567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 2667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include "service/common/bluetooth/low_energy_constants.h" 2767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include "service/ipc/binder/interface_with_instances_base.h" 2867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski#include "service/low_energy_advertiser.h" 2967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 3067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskiusing android::binder::Status; 3167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskiusing android::String16; 3267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 3367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskiusing android::bluetooth::BnBluetoothLeAdvertiser; 3467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskiusing android::bluetooth::IBluetoothLeAdvertiserCallback; 3567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 3667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskinamespace bluetooth { 3767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskiclass Adapter; 3867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski} // namespace bluetooth 3967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 4067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskinamespace ipc { 4167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowskinamespace binder { 4267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 4367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski// Implements the server side of the IBluetoothLowEnergy interface. 44911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonclass BluetoothLeAdvertiserBinderServer : public BnBluetoothLeAdvertiser, 45911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson public InterfaceWithInstancesBase { 4667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski public: 4767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski explicit BluetoothLeAdvertiserBinderServer(bluetooth::Adapter* adapter); 4867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski ~BluetoothLeAdvertiserBinderServer() override; 4967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 5067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // IBluetoothLowEnergy overrides: 5167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski Status RegisterAdvertiser( 5267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski const android::sp<IBluetoothLeAdvertiserCallback>& callback, 5367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski bool* _aidl_return) override; 5467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski Status UnregisterAdvertiser(int advertiser_id) override; 5567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski Status UnregisterAll() override; 5667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski Status StartMultiAdvertising( 57911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson int advertiser_id, 58911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson const android::bluetooth::AdvertiseData& advertise_data, 5967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski const android::bluetooth::AdvertiseData& scan_response, 6067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski const android::bluetooth::AdvertiseSettings& settings, 6167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski bool* _aidl_return) override; 6267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski Status StopMultiAdvertising(int advertiser_id, bool* _aidl_return) override; 6367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 6467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski private: 6567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // Returns a pointer to the IBluetoothLeAdvertiserCallback instance associated 6667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // with |advertiser_id|. Returns NULL if such a callback cannot be found. 6767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski android::sp<IBluetoothLeAdvertiserCallback> GetLECallback(int advertiser_id); 6867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 6967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // Returns a pointer to the LowEnergyAdvertiser instance associated with 7067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // |advertiser_id|. Returns NULL if such a advertiser cannot be found. 71911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson std::shared_ptr<bluetooth::LowEnergyAdvertiser> GetLEAdvertiser( 72911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson int advertiser_id); 7367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 7467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski // InterfaceWithInstancesBase override: 7567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski void OnRegisterInstanceImpl(bluetooth::BLEStatus status, 7667d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski android::sp<IInterface> callback, 7767d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski bluetooth::BluetoothInstance* instance) override; 7867d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 7967d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski bluetooth::Adapter* adapter_; // weak 8067d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 8167d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski DISALLOW_COPY_AND_ASSIGN(BluetoothLeAdvertiserBinderServer); 8267d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski}; 8367d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski 8467d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski} // namespace binder 8567d5a2523314d9757b2472c3e828dbc1015df4feJakub Pawlowski} // namespace ipc 86