Loading system/service/Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -37,8 +37,11 @@ btserviceCommonSrc := \ btserviceBinderSrc := \ ipc/binder/bluetooth_binder_server.cpp \ ipc/binder/bluetooth_low_energy_binder_server.cpp \ ipc/binder/IBluetooth.cpp \ ipc/binder/IBluetoothCallback.cpp \ ipc/binder/IBluetoothLowEnergy.cpp \ ipc/binder/IBluetoothLowEnergyCallback.cpp \ ipc/binder/ipc_handler_binder.cpp btserviceCommonIncludes := $(LOCAL_PATH)/../ Loading system/service/ipc/binder/IBluetooth.cpp +23 −4 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ using android::interface_cast; using android::IServiceManager; using android::Parcel; using android::sp; using android::status_t; using android::String16; namespace ipc { namespace binder { // static const char IBluetooth::kBluetoothServiceName[] = "bluetooth-service"; const char IBluetooth::kServiceName[] = "bluetooth-service"; // static sp<IBluetooth> IBluetooth::getClientInterface() { Loading @@ -42,7 +43,7 @@ sp<IBluetooth> IBluetooth::getClientInterface() { return nullptr; } sp<IBinder> binder = sm->getService(String16(kBluetoothServiceName)); sp<IBinder> binder = sm->getService(String16(kServiceName)); if (!binder.get()) { LOG(ERROR) << "Failed to obtain a handle to the Bluetooth service"; return nullptr; Loading @@ -60,7 +61,7 @@ sp<IBluetooth> IBluetooth::getClientInterface() { // BnBluetooth (server) implementation // ======================================================== android::status_t BnBluetooth::onTransact( status_t BnBluetooth::onTransact( uint32_t code, const Parcel& data, Parcel* reply, Loading Loading @@ -126,6 +127,11 @@ android::status_t BnBluetooth::onTransact( reply->writeInt32(result); return android::NO_ERROR; } case GET_LOW_ENERGY_INTERFACE_TRANSACTION: { sp<IBluetoothLowEnergy> ble_iface = GetLowEnergyInterface(); reply->writeStrongBinder(IInterface::asBinder(ble_iface.get())); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -247,7 +253,20 @@ bool BpBluetooth::IsMultiAdvertisementSupported() { return reply.readInt32(); } IMPLEMENT_META_INTERFACE(Bluetooth, IBluetooth::kBluetoothServiceName); sp<IBluetoothLowEnergy> BpBluetooth::GetLowEnergyInterface() { Parcel data, reply; data.writeInterfaceToken(IBluetooth::getInterfaceDescriptor()); remote()->transact(IBluetooth::GET_LOW_ENERGY_INTERFACE_TRANSACTION, data, &reply); sp<IBinder> ble_iface = reply.readStrongBinder(); return interface_cast<IBluetoothLowEnergy>(ble_iface); } IMPLEMENT_META_INTERFACE(Bluetooth, IBluetooth::kServiceName); } // namespace binder } // namespace ipc system/service/ipc/binder/IBluetooth.h +9 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <binder/IInterface.h> #include "service/ipc/binder/IBluetoothCallback.h" #include "service/ipc/binder/IBluetoothLowEnergy.h" #include "service/uuid.h" namespace ipc { Loading @@ -39,7 +40,7 @@ class IBluetooth : public android::IInterface { public: DECLARE_META_INTERFACE(Bluetooth); static const char kBluetoothServiceName[]; static const char kServiceName[]; // Transaction codes for interface methods. enum { Loading Loading @@ -118,6 +119,8 @@ class IBluetooth : public android::IInterface { DUMP_TRANSACTION, ON_LE_SERVICE_UP_TRANSACTION, ON_BR_EDR_DOWN_TRANSACTION, GET_LOW_ENERGY_INTERFACE_TRANSACTION, }; // Returns a handle to the IBluetooth Binder from the Android ServiceManager. Loading @@ -144,14 +147,14 @@ class IBluetooth : public android::IInterface { virtual bool IsMultiAdvertisementSupported() = 0; virtual android::sp<IBluetoothLowEnergy> GetLowEnergyInterface() = 0; // TODO(armansito): Complete the API definition. private: DISALLOW_COPY_AND_ASSIGN(IBluetooth); }; // TODO(armansito): Implement notification for when the process dies. // The Binder server interface to IBluetooth. A class that implements IBluetooth // must inherit from this class. class BnBluetooth : public android::BnInterface<IBluetooth> { Loading @@ -172,7 +175,7 @@ class BnBluetooth : public android::BnInterface<IBluetooth> { // The Binder client interface to IBluetooth. class BpBluetooth : public android::BpInterface<IBluetooth> { public: BpBluetooth(const android::sp<android::IBinder>& impl); explicit BpBluetooth(const android::sp<android::IBinder>& impl); virtual ~BpBluetooth() = default; // IBluetooth overrides: Loading @@ -194,6 +197,8 @@ class BpBluetooth : public android::BpInterface<IBluetooth> { bool IsMultiAdvertisementSupported() override; android::sp<IBluetoothLowEnergy> GetLowEnergyInterface() override; private: DISALLOW_COPY_AND_ASSIGN(BpBluetooth); }; Loading system/service/ipc/binder/IBluetoothCallback.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -22,18 +22,19 @@ using android::IBinder; using android::Parcel; using android::sp; using android::status_t; namespace ipc { namespace binder { // static const char IBluetoothCallback::kBluetoothCallbackServiceName[] = const char IBluetoothCallback::kServiceName[] = "bluetooth-callback-service"; // BnBluetoothCallback (server) implementation // ======================================================== android::status_t BnBluetoothCallback::onTransact( status_t BnBluetoothCallback::onTransact( uint32_t code, const Parcel& data, Parcel* reply, Loading Loading @@ -79,8 +80,7 @@ void BpBluetoothCallback::OnBluetoothStateChange( data, &reply); } IMPLEMENT_META_INTERFACE(BluetoothCallback, IBluetoothCallback::kBluetoothCallbackServiceName); IMPLEMENT_META_INTERFACE(BluetoothCallback, IBluetoothCallback::kServiceName); } // namespace binder } // namespace ipc system/service/ipc/binder/IBluetoothCallback.h +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ class IBluetoothCallback : public android::IInterface { public: DECLARE_META_INTERFACE(BluetoothCallback); static const char kBluetoothCallbackServiceName[]; static const char kServiceName[]; // Transaction codes for interface methods. enum { Loading Loading
system/service/Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -37,8 +37,11 @@ btserviceCommonSrc := \ btserviceBinderSrc := \ ipc/binder/bluetooth_binder_server.cpp \ ipc/binder/bluetooth_low_energy_binder_server.cpp \ ipc/binder/IBluetooth.cpp \ ipc/binder/IBluetoothCallback.cpp \ ipc/binder/IBluetoothLowEnergy.cpp \ ipc/binder/IBluetoothLowEnergyCallback.cpp \ ipc/binder/ipc_handler_binder.cpp btserviceCommonIncludes := $(LOCAL_PATH)/../ Loading
system/service/ipc/binder/IBluetooth.cpp +23 −4 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ using android::interface_cast; using android::IServiceManager; using android::Parcel; using android::sp; using android::status_t; using android::String16; namespace ipc { namespace binder { // static const char IBluetooth::kBluetoothServiceName[] = "bluetooth-service"; const char IBluetooth::kServiceName[] = "bluetooth-service"; // static sp<IBluetooth> IBluetooth::getClientInterface() { Loading @@ -42,7 +43,7 @@ sp<IBluetooth> IBluetooth::getClientInterface() { return nullptr; } sp<IBinder> binder = sm->getService(String16(kBluetoothServiceName)); sp<IBinder> binder = sm->getService(String16(kServiceName)); if (!binder.get()) { LOG(ERROR) << "Failed to obtain a handle to the Bluetooth service"; return nullptr; Loading @@ -60,7 +61,7 @@ sp<IBluetooth> IBluetooth::getClientInterface() { // BnBluetooth (server) implementation // ======================================================== android::status_t BnBluetooth::onTransact( status_t BnBluetooth::onTransact( uint32_t code, const Parcel& data, Parcel* reply, Loading Loading @@ -126,6 +127,11 @@ android::status_t BnBluetooth::onTransact( reply->writeInt32(result); return android::NO_ERROR; } case GET_LOW_ENERGY_INTERFACE_TRANSACTION: { sp<IBluetoothLowEnergy> ble_iface = GetLowEnergyInterface(); reply->writeStrongBinder(IInterface::asBinder(ble_iface.get())); return android::NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } Loading Loading @@ -247,7 +253,20 @@ bool BpBluetooth::IsMultiAdvertisementSupported() { return reply.readInt32(); } IMPLEMENT_META_INTERFACE(Bluetooth, IBluetooth::kBluetoothServiceName); sp<IBluetoothLowEnergy> BpBluetooth::GetLowEnergyInterface() { Parcel data, reply; data.writeInterfaceToken(IBluetooth::getInterfaceDescriptor()); remote()->transact(IBluetooth::GET_LOW_ENERGY_INTERFACE_TRANSACTION, data, &reply); sp<IBinder> ble_iface = reply.readStrongBinder(); return interface_cast<IBluetoothLowEnergy>(ble_iface); } IMPLEMENT_META_INTERFACE(Bluetooth, IBluetooth::kServiceName); } // namespace binder } // namespace ipc
system/service/ipc/binder/IBluetooth.h +9 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <binder/IInterface.h> #include "service/ipc/binder/IBluetoothCallback.h" #include "service/ipc/binder/IBluetoothLowEnergy.h" #include "service/uuid.h" namespace ipc { Loading @@ -39,7 +40,7 @@ class IBluetooth : public android::IInterface { public: DECLARE_META_INTERFACE(Bluetooth); static const char kBluetoothServiceName[]; static const char kServiceName[]; // Transaction codes for interface methods. enum { Loading Loading @@ -118,6 +119,8 @@ class IBluetooth : public android::IInterface { DUMP_TRANSACTION, ON_LE_SERVICE_UP_TRANSACTION, ON_BR_EDR_DOWN_TRANSACTION, GET_LOW_ENERGY_INTERFACE_TRANSACTION, }; // Returns a handle to the IBluetooth Binder from the Android ServiceManager. Loading @@ -144,14 +147,14 @@ class IBluetooth : public android::IInterface { virtual bool IsMultiAdvertisementSupported() = 0; virtual android::sp<IBluetoothLowEnergy> GetLowEnergyInterface() = 0; // TODO(armansito): Complete the API definition. private: DISALLOW_COPY_AND_ASSIGN(IBluetooth); }; // TODO(armansito): Implement notification for when the process dies. // The Binder server interface to IBluetooth. A class that implements IBluetooth // must inherit from this class. class BnBluetooth : public android::BnInterface<IBluetooth> { Loading @@ -172,7 +175,7 @@ class BnBluetooth : public android::BnInterface<IBluetooth> { // The Binder client interface to IBluetooth. class BpBluetooth : public android::BpInterface<IBluetooth> { public: BpBluetooth(const android::sp<android::IBinder>& impl); explicit BpBluetooth(const android::sp<android::IBinder>& impl); virtual ~BpBluetooth() = default; // IBluetooth overrides: Loading @@ -194,6 +197,8 @@ class BpBluetooth : public android::BpInterface<IBluetooth> { bool IsMultiAdvertisementSupported() override; android::sp<IBluetoothLowEnergy> GetLowEnergyInterface() override; private: DISALLOW_COPY_AND_ASSIGN(BpBluetooth); }; Loading
system/service/ipc/binder/IBluetoothCallback.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -22,18 +22,19 @@ using android::IBinder; using android::Parcel; using android::sp; using android::status_t; namespace ipc { namespace binder { // static const char IBluetoothCallback::kBluetoothCallbackServiceName[] = const char IBluetoothCallback::kServiceName[] = "bluetooth-callback-service"; // BnBluetoothCallback (server) implementation // ======================================================== android::status_t BnBluetoothCallback::onTransact( status_t BnBluetoothCallback::onTransact( uint32_t code, const Parcel& data, Parcel* reply, Loading Loading @@ -79,8 +80,7 @@ void BpBluetoothCallback::OnBluetoothStateChange( data, &reply); } IMPLEMENT_META_INTERFACE(BluetoothCallback, IBluetoothCallback::kBluetoothCallbackServiceName); IMPLEMENT_META_INTERFACE(BluetoothCallback, IBluetoothCallback::kServiceName); } // namespace binder } // namespace ipc
system/service/ipc/binder/IBluetoothCallback.h +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ class IBluetoothCallback : public android::IInterface { public: DECLARE_META_INTERFACE(BluetoothCallback); static const char kBluetoothCallbackServiceName[]; static const char kServiceName[]; // Transaction codes for interface methods. enum { Loading