1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LOCATION_BLUETOOTH_SCAN_RESULT_H 17 #define LOCATION_BLUETOOTH_SCAN_RESULT_H 18 19 #include <parcel.h> 20 #include <string> 21 #include "string_ex.h" 22 23 namespace OHOS { 24 namespace Location { 25 class BluetoothScanResult : public Parcelable { 26 public: 27 BluetoothScanResult(); 28 explicit BluetoothScanResult(BluetoothScanResult &bluetoothScanResult); 29 ~BluetoothScanResult() override; 30 GetDeviceId()31 inline std::string GetDeviceId() const 32 { 33 return deviceId_; 34 } 35 SetDeviceId(std::string deviceId)36 inline void SetDeviceId(std::string deviceId) 37 { 38 deviceId_ = deviceId; 39 } 40 GetDeviceName()41 inline std::string GetDeviceName() const 42 { 43 return deviceName_; 44 } 45 SetDeviceName(std::string deviceName)46 inline void SetDeviceName(std::string deviceName) 47 { 48 deviceName_ = deviceName; 49 } 50 GetRssi()51 inline int64_t GetRssi() const 52 { 53 return rssi_; 54 } 55 SetRssi(int64_t rssi)56 inline void SetRssi(int64_t rssi) 57 { 58 rssi_ = rssi; 59 } 60 GetData()61 inline std::vector<uint8_t> GetData() const 62 { 63 return data_; 64 } 65 SetData(std::vector<uint8_t> data)66 inline void SetData(std::vector<uint8_t> data) 67 { 68 for (auto it = data.begin(); it != data.end(); ++it) { 69 data_.push_back(*it); 70 } 71 } 72 GetConnectable()73 inline bool GetConnectable() const 74 { 75 return connectable_; 76 } 77 SetConnectable(bool connectable)78 inline void SetConnectable(bool connectable) 79 { 80 connectable_ = connectable; 81 } 82 83 void ReadFromParcel(Parcel& parcel); 84 bool Marshalling(Parcel& parcel) const override; 85 static std::unique_ptr<BluetoothScanResult> Unmarshalling(Parcel& parcel); 86 static std::shared_ptr<BluetoothScanResult> UnmarshallingShared(Parcel& parcel); 87 void VectorString16ToVectorUint8(const std::vector<std::u16string>& additions); 88 std::vector<std::u16string> VectorUint8ToVectorString16() const; 89 90 private: 91 std::string deviceId_; 92 std::string deviceName_; 93 int64_t rssi_; 94 std::vector<uint8_t> data_; 95 bool connectable_; 96 }; 97 } // namespace Location 98 } // namespace OHOS 99 #endif // LOCATION_BLUETOOTH_SCAN_RESULT_H