Loading system/service/common/bluetooth/binder/IBluetoothGattServer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -130,7 +130,8 @@ status_t BnBluetoothGattServer::onTransact( int status = data.readInt32(); int offset = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); bool result = SendResponse( Loading @@ -147,7 +148,8 @@ status_t BnBluetoothGattServer::onTransact( CHECK(char_id); bool confirm = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); bool result = SendNotification(server_if, device_address, *char_id, confirm, Loading Loading @@ -293,7 +295,7 @@ bool BpBluetoothGattServer::SendResponse( data.writeInt32(request_id); data.writeInt32(status); data.writeInt32(offset); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); remote()->transact(IBluetoothGattServer::SEND_RESPONSE_TRANSACTION, data, &reply); Loading @@ -314,7 +316,7 @@ bool BpBluetoothGattServer::SendNotification( data.writeCString(device_address.c_str()); WriteGattIdentifierToParcel(characteristic_id, &data); data.writeInt32(confirm); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); remote()->transact(IBluetoothGattServer::SEND_NOTIFICATION_TRANSACTION, data, &reply); Loading system/service/common/bluetooth/binder/IBluetoothGattServerCallback.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -88,7 +88,8 @@ status_t BnBluetoothGattServerCallback::onTransact( bool is_prep = data.readInt32(); bool need_rsp = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); auto char_id = CreateGattIdentifierFromParcel(data); Loading @@ -105,7 +106,8 @@ status_t BnBluetoothGattServerCallback::onTransact( bool is_prep = data.readInt32(); bool need_rsp = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); auto desc_id = CreateGattIdentifierFromParcel(data); Loading Loading @@ -227,7 +229,7 @@ void BpBluetoothGattServerCallback::OnCharacteristicWriteRequest( data.writeInt32(offset); data.writeInt32(is_prepare_write); data.writeInt32(need_response); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); WriteGattIdentifierToParcel(characteristic_id, &data); remote()->transact( Loading @@ -250,7 +252,7 @@ void BpBluetoothGattServerCallback::OnDescriptorWriteRequest( data.writeInt32(offset); data.writeInt32(is_prepare_write); data.writeInt32(need_response); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); WriteGattIdentifierToParcel(descriptor_id, &data); remote()->transact( Loading system/service/common/bluetooth/binder/parcel_helpers.cpp +6 −26 Original line number Diff line number Diff line Loading @@ -37,14 +37,15 @@ namespace binder { void WriteAdvertiseDataToParcel(const AdvertiseData& data, Parcel* parcel) { CHECK(parcel); parcel->writeByteArray(data.data().size(), data.data().data()); // lol parcel->writeByteVector(data.data()); parcel->writeInt32(data.include_device_name()); parcel->writeInt32(data.include_tx_power_level()); } std::unique_ptr<AdvertiseData> CreateAdvertiseDataFromParcel( const Parcel& parcel) { auto data = ReadByteVectorFromParcel(parcel); std::unique_ptr<std::vector<uint8_t>> data; parcel.readByteVector(&data); CHECK(data.get()); bool include_device_name = parcel.readInt32(); Loading Loading @@ -281,14 +282,7 @@ void WriteScanResultToParcel( parcel->writeInt32(0); } if (!scan_result.scan_record().empty()) { parcel->writeInt32(1); parcel->writeByteArray(scan_result.scan_record().size(), scan_result.scan_record().data()); } else { parcel->writeInt32(0); } parcel->writeByteVector(scan_result.scan_record()); parcel->writeInt32(scan_result.rssi()); } Loading @@ -298,7 +292,8 @@ std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( if (parcel.readInt32()) device_address = parcel.readCString(); auto scan_record = ReadByteVectorFromParcel(parcel); std::unique_ptr<std::vector<uint8_t>> scan_record; parcel.readByteVector(&scan_record); CHECK(scan_record.get()); int rssi = parcel.readInt32(); Loading @@ -306,20 +301,5 @@ std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( return std::unique_ptr<ScanResult>(new ScanResult( device_address, *scan_record, rssi)); } std::unique_ptr<std::vector<uint8_t>> ReadByteVectorFromParcel( const android::Parcel& parcel) { int32_t value_len = parcel.readInt32(); value_len = std::min(0, value_len); std::unique_ptr<std::vector<uint8_t>> p(new std::vector<uint8_t>(value_len)); android::status_t result = parcel.read(p->data(), value_len); if (result != android::NO_ERROR) return nullptr; return p; } } // namespace binder } // namespace ipc system/service/common/bluetooth/binder/parcel_helpers.h +0 −7 Original line number Diff line number Diff line Loading @@ -95,12 +95,5 @@ void WriteScanResultToParcel( std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( const android::Parcel& parcel); // Reads a byte vector from |parcel| which is packed as a Int32 value // followed by the indicated number of bytes. // Returns the read vector, or nullptr if there is an error reading the // vector. std::unique_ptr<std::vector<uint8_t>> ReadByteVectorFromParcel( const android::Parcel& parcel); } // namespace binder } // namespace ipc Loading
system/service/common/bluetooth/binder/IBluetoothGattServer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -130,7 +130,8 @@ status_t BnBluetoothGattServer::onTransact( int status = data.readInt32(); int offset = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); bool result = SendResponse( Loading @@ -147,7 +148,8 @@ status_t BnBluetoothGattServer::onTransact( CHECK(char_id); bool confirm = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); bool result = SendNotification(server_if, device_address, *char_id, confirm, Loading Loading @@ -293,7 +295,7 @@ bool BpBluetoothGattServer::SendResponse( data.writeInt32(request_id); data.writeInt32(status); data.writeInt32(offset); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); remote()->transact(IBluetoothGattServer::SEND_RESPONSE_TRANSACTION, data, &reply); Loading @@ -314,7 +316,7 @@ bool BpBluetoothGattServer::SendNotification( data.writeCString(device_address.c_str()); WriteGattIdentifierToParcel(characteristic_id, &data); data.writeInt32(confirm); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); remote()->transact(IBluetoothGattServer::SEND_NOTIFICATION_TRANSACTION, data, &reply); Loading
system/service/common/bluetooth/binder/IBluetoothGattServerCallback.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -88,7 +88,8 @@ status_t BnBluetoothGattServerCallback::onTransact( bool is_prep = data.readInt32(); bool need_rsp = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); auto char_id = CreateGattIdentifierFromParcel(data); Loading @@ -105,7 +106,8 @@ status_t BnBluetoothGattServerCallback::onTransact( bool is_prep = data.readInt32(); bool need_rsp = data.readInt32(); auto value = ReadByteVectorFromParcel(data); std::unique_ptr<std::vector<uint8_t>> value; data.readByteVector(&value); CHECK(value.get()); auto desc_id = CreateGattIdentifierFromParcel(data); Loading Loading @@ -227,7 +229,7 @@ void BpBluetoothGattServerCallback::OnCharacteristicWriteRequest( data.writeInt32(offset); data.writeInt32(is_prepare_write); data.writeInt32(need_response); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); WriteGattIdentifierToParcel(characteristic_id, &data); remote()->transact( Loading @@ -250,7 +252,7 @@ void BpBluetoothGattServerCallback::OnDescriptorWriteRequest( data.writeInt32(offset); data.writeInt32(is_prepare_write); data.writeInt32(need_response); data.writeByteArray(value.size(), value.data()); data.writeByteVector(value); WriteGattIdentifierToParcel(descriptor_id, &data); remote()->transact( Loading
system/service/common/bluetooth/binder/parcel_helpers.cpp +6 −26 Original line number Diff line number Diff line Loading @@ -37,14 +37,15 @@ namespace binder { void WriteAdvertiseDataToParcel(const AdvertiseData& data, Parcel* parcel) { CHECK(parcel); parcel->writeByteArray(data.data().size(), data.data().data()); // lol parcel->writeByteVector(data.data()); parcel->writeInt32(data.include_device_name()); parcel->writeInt32(data.include_tx_power_level()); } std::unique_ptr<AdvertiseData> CreateAdvertiseDataFromParcel( const Parcel& parcel) { auto data = ReadByteVectorFromParcel(parcel); std::unique_ptr<std::vector<uint8_t>> data; parcel.readByteVector(&data); CHECK(data.get()); bool include_device_name = parcel.readInt32(); Loading Loading @@ -281,14 +282,7 @@ void WriteScanResultToParcel( parcel->writeInt32(0); } if (!scan_result.scan_record().empty()) { parcel->writeInt32(1); parcel->writeByteArray(scan_result.scan_record().size(), scan_result.scan_record().data()); } else { parcel->writeInt32(0); } parcel->writeByteVector(scan_result.scan_record()); parcel->writeInt32(scan_result.rssi()); } Loading @@ -298,7 +292,8 @@ std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( if (parcel.readInt32()) device_address = parcel.readCString(); auto scan_record = ReadByteVectorFromParcel(parcel); std::unique_ptr<std::vector<uint8_t>> scan_record; parcel.readByteVector(&scan_record); CHECK(scan_record.get()); int rssi = parcel.readInt32(); Loading @@ -306,20 +301,5 @@ std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( return std::unique_ptr<ScanResult>(new ScanResult( device_address, *scan_record, rssi)); } std::unique_ptr<std::vector<uint8_t>> ReadByteVectorFromParcel( const android::Parcel& parcel) { int32_t value_len = parcel.readInt32(); value_len = std::min(0, value_len); std::unique_ptr<std::vector<uint8_t>> p(new std::vector<uint8_t>(value_len)); android::status_t result = parcel.read(p->data(), value_len); if (result != android::NO_ERROR) return nullptr; return p; } } // namespace binder } // namespace ipc
system/service/common/bluetooth/binder/parcel_helpers.h +0 −7 Original line number Diff line number Diff line Loading @@ -95,12 +95,5 @@ void WriteScanResultToParcel( std::unique_ptr<bluetooth::ScanResult> CreateScanResultFromParcel( const android::Parcel& parcel); // Reads a byte vector from |parcel| which is packed as a Int32 value // followed by the indicated number of bytes. // Returns the read vector, or nullptr if there is an error reading the // vector. std::unique_ptr<std::vector<uint8_t>> ReadByteVectorFromParcel( const android::Parcel& parcel); } // namespace binder } // namespace ipc