Loading system/service/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceBinderSrc) \ adapter_state.cpp \ advertise_data.cpp \ advertise_settings.cpp \ client/main.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 Loading system/service/client/main.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,13 @@ class CLIBluetoothLowEnergyCallback ble_registering = false; } void OnMultiAdvertiseCallback( int status, bool is_start, const bluetooth::AdvertiseSettings& settings) { // TODO(armansito): Implement once there are commands to start and stop // advertising. } private: DISALLOW_COPY_AND_ASSIGN(CLIBluetoothLowEnergyCallback); }; Loading system/service/ipc/binder/IBluetoothLowEnergy.cpp +52 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,17 @@ #include <base/logging.h> #include <binder/Parcel.h> #include "service/ipc/binder/parcel_helpers.h" using android::IBinder; using android::interface_cast; using android::Parcel; using android::sp; using android::status_t; using bluetooth::AdvertiseData; using bluetooth::AdvertiseSettings; namespace ipc { namespace binder { Loading Loading @@ -59,6 +64,26 @@ status_t BnBluetoothLowEnergy::onTransact( UnregisterAll(); return android::NO_ERROR; } case START_MULTI_ADVERTISING_TRANSACTION: { int client_if = data.readInt32(); std::unique_ptr<AdvertiseData> adv_data = CreateAdvertiseDataFromParcel(data); std::unique_ptr<AdvertiseData> scan_rsp = CreateAdvertiseDataFromParcel(data); std::unique_ptr<AdvertiseSettings> adv_settings = CreateAdvertiseSettingsFromParcel(data); StartMultiAdvertising(client_if, *adv_data, *scan_rsp, *adv_settings); return android::NO_ERROR; } case STOP_MULTI_ADVERTISING_TRANSACTION: { int client_if = data.readInt32(); StopMultiAdvertising(client_if); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -101,6 +126,33 @@ void BpBluetoothLowEnergy::UnregisterAll() { data, &reply); } void BpBluetoothLowEnergy::StartMultiAdvertising( int client_if, const AdvertiseData& advertise_data, const AdvertiseData& scan_response, const AdvertiseSettings& settings) { Parcel data, reply; data.writeInterfaceToken(IBluetoothLowEnergy::getInterfaceDescriptor()); data.writeInt32(client_if); WriteAdvertiseDataToParcel(advertise_data, &data); WriteAdvertiseDataToParcel(scan_response, &data); WriteAdvertiseSettingsToParcel(settings, &data); remote()->transact(IBluetoothLowEnergy::START_MULTI_ADVERTISING_TRANSACTION, data, &reply); } void BpBluetoothLowEnergy::StopMultiAdvertising(int client_if) { Parcel data, reply; data.writeInterfaceToken(IBluetoothLowEnergy::getInterfaceDescriptor()); data.writeInt32(client_if); remote()->transact(IBluetoothLowEnergy::STOP_MULTI_ADVERTISING_TRANSACTION, data, &reply); } IMPLEMENT_META_INTERFACE(BluetoothLowEnergy, IBluetoothLowEnergy::kServiceName); } // namespace binder Loading system/service/ipc/binder/IBluetoothLowEnergy.h +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <binder/IBinder.h> #include <binder/IInterface.h> #include "service/advertise_data.h" #include "service/advertise_settings.h" #include "service/ipc/binder/IBluetoothLowEnergyCallback.h" namespace ipc { Loading Loading @@ -68,6 +70,13 @@ class IBluetoothLowEnergy : public android::IInterface { virtual void UnregisterClient(int client_if) = 0; virtual void UnregisterAll() = 0; virtual void StartMultiAdvertising( int client_if, const bluetooth::AdvertiseData& advertise_data, const bluetooth::AdvertiseData& scan_response, const bluetooth::AdvertiseSettings& settings) = 0; virtual void StopMultiAdvertising(int client_if) = 0; // TODO(armansito): Complete the API definition. private: Loading Loading @@ -102,6 +111,12 @@ class BpBluetoothLowEnergy : public android::BpInterface<IBluetoothLowEnergy> { const android::sp<IBluetoothLowEnergyCallback>& callback) override; void UnregisterClient(int client_if) override; void UnregisterAll() override; void StartMultiAdvertising( int client_if, const bluetooth::AdvertiseData& advertise_data, const bluetooth::AdvertiseData& scan_response, const bluetooth::AdvertiseSettings& settings) override; void StopMultiAdvertising(int client_if) override; private: DISALLOW_COPY_AND_ASSIGN(BpBluetoothLowEnergy); Loading system/service/ipc/binder/IBluetoothLowEnergyCallback.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -19,11 +19,16 @@ #include <base/logging.h> #include <binder/Parcel.h> #include "service/ipc/binder/parcel_helpers.h" using android::IBinder; using android::Parcel; using android::sp; using android::status_t; using bluetooth::AdvertiseData; using bluetooth::AdvertiseSettings; namespace ipc { namespace binder { Loading @@ -50,6 +55,14 @@ status_t BnBluetoothLowEnergyCallback::onTransact( OnClientRegistered(status, client_if); return android::NO_ERROR; } case ON_MULTI_ADVERTISE_CALLBACK_TRANSACTION: { int status = data.readInt32(); bool is_start = data.readInt32(); std::unique_ptr<AdvertiseSettings> settings = CreateAdvertiseSettingsFromParcel(data); OnMultiAdvertiseCallback(status, is_start, *settings); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -78,6 +91,23 @@ void BpBluetoothLowEnergyCallback::OnClientRegistered( IBinder::FLAG_ONEWAY); } void BpBluetoothLowEnergyCallback::OnMultiAdvertiseCallback( int status, bool is_start, const AdvertiseSettings& settings) { Parcel data, reply; data.writeInterfaceToken( IBluetoothLowEnergyCallback::getInterfaceDescriptor()); data.writeInt32(status); data.writeInt32(is_start); WriteAdvertiseSettingsToParcel(settings, &data); remote()->transact( IBluetoothLowEnergyCallback::ON_MULTI_ADVERTISE_CALLBACK_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY); } IMPLEMENT_META_INTERFACE(BluetoothLowEnergyCallback, IBluetoothLowEnergyCallback::kServiceName); Loading Loading
system/service/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceBinderSrc) \ adapter_state.cpp \ advertise_data.cpp \ advertise_settings.cpp \ client/main.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 Loading
system/service/client/main.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,13 @@ class CLIBluetoothLowEnergyCallback ble_registering = false; } void OnMultiAdvertiseCallback( int status, bool is_start, const bluetooth::AdvertiseSettings& settings) { // TODO(armansito): Implement once there are commands to start and stop // advertising. } private: DISALLOW_COPY_AND_ASSIGN(CLIBluetoothLowEnergyCallback); }; Loading
system/service/ipc/binder/IBluetoothLowEnergy.cpp +52 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,17 @@ #include <base/logging.h> #include <binder/Parcel.h> #include "service/ipc/binder/parcel_helpers.h" using android::IBinder; using android::interface_cast; using android::Parcel; using android::sp; using android::status_t; using bluetooth::AdvertiseData; using bluetooth::AdvertiseSettings; namespace ipc { namespace binder { Loading Loading @@ -59,6 +64,26 @@ status_t BnBluetoothLowEnergy::onTransact( UnregisterAll(); return android::NO_ERROR; } case START_MULTI_ADVERTISING_TRANSACTION: { int client_if = data.readInt32(); std::unique_ptr<AdvertiseData> adv_data = CreateAdvertiseDataFromParcel(data); std::unique_ptr<AdvertiseData> scan_rsp = CreateAdvertiseDataFromParcel(data); std::unique_ptr<AdvertiseSettings> adv_settings = CreateAdvertiseSettingsFromParcel(data); StartMultiAdvertising(client_if, *adv_data, *scan_rsp, *adv_settings); return android::NO_ERROR; } case STOP_MULTI_ADVERTISING_TRANSACTION: { int client_if = data.readInt32(); StopMultiAdvertising(client_if); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -101,6 +126,33 @@ void BpBluetoothLowEnergy::UnregisterAll() { data, &reply); } void BpBluetoothLowEnergy::StartMultiAdvertising( int client_if, const AdvertiseData& advertise_data, const AdvertiseData& scan_response, const AdvertiseSettings& settings) { Parcel data, reply; data.writeInterfaceToken(IBluetoothLowEnergy::getInterfaceDescriptor()); data.writeInt32(client_if); WriteAdvertiseDataToParcel(advertise_data, &data); WriteAdvertiseDataToParcel(scan_response, &data); WriteAdvertiseSettingsToParcel(settings, &data); remote()->transact(IBluetoothLowEnergy::START_MULTI_ADVERTISING_TRANSACTION, data, &reply); } void BpBluetoothLowEnergy::StopMultiAdvertising(int client_if) { Parcel data, reply; data.writeInterfaceToken(IBluetoothLowEnergy::getInterfaceDescriptor()); data.writeInt32(client_if); remote()->transact(IBluetoothLowEnergy::STOP_MULTI_ADVERTISING_TRANSACTION, data, &reply); } IMPLEMENT_META_INTERFACE(BluetoothLowEnergy, IBluetoothLowEnergy::kServiceName); } // namespace binder Loading
system/service/ipc/binder/IBluetoothLowEnergy.h +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <binder/IBinder.h> #include <binder/IInterface.h> #include "service/advertise_data.h" #include "service/advertise_settings.h" #include "service/ipc/binder/IBluetoothLowEnergyCallback.h" namespace ipc { Loading Loading @@ -68,6 +70,13 @@ class IBluetoothLowEnergy : public android::IInterface { virtual void UnregisterClient(int client_if) = 0; virtual void UnregisterAll() = 0; virtual void StartMultiAdvertising( int client_if, const bluetooth::AdvertiseData& advertise_data, const bluetooth::AdvertiseData& scan_response, const bluetooth::AdvertiseSettings& settings) = 0; virtual void StopMultiAdvertising(int client_if) = 0; // TODO(armansito): Complete the API definition. private: Loading Loading @@ -102,6 +111,12 @@ class BpBluetoothLowEnergy : public android::BpInterface<IBluetoothLowEnergy> { const android::sp<IBluetoothLowEnergyCallback>& callback) override; void UnregisterClient(int client_if) override; void UnregisterAll() override; void StartMultiAdvertising( int client_if, const bluetooth::AdvertiseData& advertise_data, const bluetooth::AdvertiseData& scan_response, const bluetooth::AdvertiseSettings& settings) override; void StopMultiAdvertising(int client_if) override; private: DISALLOW_COPY_AND_ASSIGN(BpBluetoothLowEnergy); Loading
system/service/ipc/binder/IBluetoothLowEnergyCallback.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -19,11 +19,16 @@ #include <base/logging.h> #include <binder/Parcel.h> #include "service/ipc/binder/parcel_helpers.h" using android::IBinder; using android::Parcel; using android::sp; using android::status_t; using bluetooth::AdvertiseData; using bluetooth::AdvertiseSettings; namespace ipc { namespace binder { Loading @@ -50,6 +55,14 @@ status_t BnBluetoothLowEnergyCallback::onTransact( OnClientRegistered(status, client_if); return android::NO_ERROR; } case ON_MULTI_ADVERTISE_CALLBACK_TRANSACTION: { int status = data.readInt32(); bool is_start = data.readInt32(); std::unique_ptr<AdvertiseSettings> settings = CreateAdvertiseSettingsFromParcel(data); OnMultiAdvertiseCallback(status, is_start, *settings); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -78,6 +91,23 @@ void BpBluetoothLowEnergyCallback::OnClientRegistered( IBinder::FLAG_ONEWAY); } void BpBluetoothLowEnergyCallback::OnMultiAdvertiseCallback( int status, bool is_start, const AdvertiseSettings& settings) { Parcel data, reply; data.writeInterfaceToken( IBluetoothLowEnergyCallback::getInterfaceDescriptor()); data.writeInt32(status); data.writeInt32(is_start); WriteAdvertiseSettingsToParcel(settings, &data); remote()->transact( IBluetoothLowEnergyCallback::ON_MULTI_ADVERTISE_CALLBACK_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY); } IMPLEMENT_META_INTERFACE(BluetoothLowEnergyCallback, IBluetoothLowEnergyCallback::kServiceName); Loading