mirror of
https://gitee.com/openharmony/distributeddatamgr_pasteboard
synced 2024-11-27 01:52:01 +00:00
code fix
Signed-off-by: z30053452 <zhiyihang1@huawei.com>
This commit is contained in:
parent
281ee4b4a0
commit
fa726b498e
@ -25,7 +25,7 @@ bool PasteboardStaticCapability::IsSupportCapability()
|
||||
return true;
|
||||
}
|
||||
|
||||
DistributedDeviceProfile::IStaticCapabilityCollector* GetStaticCapabilityCollector()
|
||||
DistributedDeviceProfile::IStaticCapabilityCollector *GetStaticCapabilityCollector()
|
||||
{
|
||||
return &PasteboardStaticCapability::GetInstance();
|
||||
}
|
||||
|
@ -15,12 +15,8 @@
|
||||
|
||||
#include "eventcenter/event.h"
|
||||
namespace OHOS::MiscServices {
|
||||
Event::Event(int32_t evtId) : evtId_(evtId)
|
||||
{
|
||||
}
|
||||
Event::~Event()
|
||||
{
|
||||
}
|
||||
Event::Event(int32_t evtId) : evtId_(evtId) {}
|
||||
Event::~Event() {}
|
||||
int32_t Event::GetEventId() const
|
||||
{
|
||||
return evtId_;
|
||||
|
@ -16,8 +16,7 @@
|
||||
#include "eventcenter/pasteboard_event.h"
|
||||
namespace OHOS::MiscServices {
|
||||
|
||||
PasteboardEvent::PasteboardEvent(int32_t evtId, std::string networkId)
|
||||
: Event(evtId), networkId_(std::move(networkId))
|
||||
PasteboardEvent::PasteboardEvent(int32_t evtId, std::string networkId) : Event(evtId), networkId_(std::move(networkId))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
std::string account;
|
||||
std::vector<std::string> dataType;
|
||||
int32_t syncTime = 0;
|
||||
bool operator == (const GlobalEvent globalEvent)
|
||||
bool operator==(const GlobalEvent globalEvent)
|
||||
{
|
||||
return globalEvent.seqId == this->seqId && globalEvent.deviceId == this->deviceId;
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ namespace OHOS {
|
||||
template<typename T>
|
||||
class BlockObject {
|
||||
public:
|
||||
explicit BlockObject(uint32_t interval, const T &invalid = T()) : interval_(interval), data_(invalid)
|
||||
{
|
||||
}
|
||||
explicit BlockObject(uint32_t interval, const T &invalid = T()) : interval_(interval), data_(invalid) {}
|
||||
~BlockObject() = default;
|
||||
|
||||
void SetValue(T data)
|
||||
@ -36,7 +34,9 @@ public:
|
||||
T GetValue()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
cv_.wait_for(lock, std::chrono::milliseconds(interval_), [this]() { return isSet_; });
|
||||
cv_.wait_for(lock, std::chrono::milliseconds(interval_), [this]() {
|
||||
return isSet_;
|
||||
});
|
||||
isSet_ = false;
|
||||
T data = std::move(data_);
|
||||
cv_.notify_one();
|
||||
|
@ -16,8 +16,9 @@
|
||||
#ifndef PASTE_BOARD_DEV_PROFILE_H
|
||||
#define PASTE_BOARD_DEV_PROFILE_H
|
||||
|
||||
#include "api/visibility.h"
|
||||
#include <functional>
|
||||
|
||||
#include "api/visibility.h"
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
#include "distributed_device_profile_client.h"
|
||||
#include "profile_change_listener_stub.h"
|
||||
@ -39,7 +40,7 @@ public:
|
||||
void Watch(Observer observer);
|
||||
static constexpr const uint32_t FIRST_VERSION = 4;
|
||||
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
class SubscribeDPChangeListener : public DistributedDeviceProfile::ProfileChangeListenerStub {
|
||||
public:
|
||||
SubscribeDPChangeListener();
|
||||
@ -61,7 +62,7 @@ public:
|
||||
int32_t OnCharacteristicProfileUpdate(const DistributedDeviceProfile::CharacteristicProfile &oldProfile,
|
||||
const DistributedDeviceProfile::CharacteristicProfile &newProfile) override;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
DevProfile();
|
||||
@ -69,10 +70,9 @@ private:
|
||||
void Notify(bool isEnable);
|
||||
std::mutex callbackMutex_;
|
||||
Observer observer_ = nullptr;
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
std::map<std::string, DistributedDeviceProfile::SubscribeInfo> subscribeInfoCache_;
|
||||
#endif // PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
|
||||
#endif // PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -16,9 +16,10 @@
|
||||
#ifndef PASTE_BOARD_DISTRIBUTE_MODULE_CONFIG_H
|
||||
#define PASTE_BOARD_DISTRIBUTE_MODULE_CONFIG_H
|
||||
|
||||
#include "api/visibility.h"
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
|
||||
#include "api/visibility.h"
|
||||
#include "device/dm_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -30,10 +31,12 @@ public:
|
||||
void Watch(Observer observer);
|
||||
void Init();
|
||||
void DeInit();
|
||||
|
||||
protected:
|
||||
void Online(const std::string &device) override;
|
||||
void Offline(const std::string &device) override;
|
||||
void OnReady(const std::string &device) override;
|
||||
|
||||
private:
|
||||
int32_t GetEnabledStatus();
|
||||
void Notify();
|
||||
@ -44,9 +47,9 @@ private:
|
||||
std::atomic<bool> retrying_ = false;
|
||||
static constexpr uint32_t RETRY_TIMES = 30;
|
||||
static constexpr uint32_t RETRY_INTERVAL = 1000; //milliseconds
|
||||
static constexpr uint32_t RANDOM_MAX = 500; //milliseconds
|
||||
static constexpr uint32_t RANDOM_MIN = 5; //milliseconds
|
||||
static constexpr const char* SUPPORT_STATUS = "1";
|
||||
static constexpr uint32_t RANDOM_MAX = 500; //milliseconds
|
||||
static constexpr uint32_t RANDOM_MIN = 5; //milliseconds
|
||||
static constexpr const char *SUPPORT_STATUS = "1";
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -49,10 +49,10 @@ public:
|
||||
bool IsSameAccount(const std::string &networkId);
|
||||
void SetDevices();
|
||||
|
||||
#ifdef PB_DEVICE_MANAGER_ENABLE
|
||||
#ifdef PB_DEVICE_MANAGER_ENABLE
|
||||
int32_t GetRemoteDeviceInfo(const std::string &networkId, DmDeviceInfo &remoteDevice);
|
||||
std::vector<DmDeviceInfo> GetDevices();
|
||||
#endif
|
||||
#endif
|
||||
std::string GetDeviceName(const std::string &networkId);
|
||||
void Register(DMObserver *observer);
|
||||
void Unregister(DMObserver *observer);
|
||||
@ -70,10 +70,10 @@ private:
|
||||
mutable std::mutex mutex_{};
|
||||
std::string localDeviceUdid_{};
|
||||
ConcurrentMap<DMObserver *, DMObserver *> observers_;
|
||||
#ifdef PB_DEVICE_MANAGER_ENABLE
|
||||
#ifdef PB_DEVICE_MANAGER_ENABLE
|
||||
std::shared_mutex dmMutex_;
|
||||
std::vector<DmDeviceInfo> devices_;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
} // namespace OHOS::MiscServices
|
||||
#endif // OHOS_PASTEBOARD_SERVICES_DEVICE_DM_ADAPTER_H
|
||||
|
@ -29,7 +29,8 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
#ifdef PB_DEVICE_INFO_MANAGER_ENABLE
|
||||
class PasteboardStaticCapability : public DistributedDeviceProfile::IStaticCapabilityCollector {
|
||||
DECLARE_SINGLE_INSTANCE_BASE(PasteboardStaticCapability);
|
||||
DECLARE_SINGLE_INSTANCE_BASE(PasteboardStaticCapability);
|
||||
|
||||
public:
|
||||
PasteboardStaticCapability() = default;
|
||||
~PasteboardStaticCapability() = default;
|
||||
@ -39,7 +40,7 @@ public:
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
API_EXPORT DistributedDeviceProfile::IStaticCapabilityCollector* GetStaticCapabilityCollector();
|
||||
API_EXPORT DistributedDeviceProfile::IStaticCapabilityCollector *GetStaticCapabilityCollector();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -16,8 +16,9 @@
|
||||
#ifndef OHOS_DISTRIBUTED_DATA_PASTEBOARD_SERVICES_FRAMEWORK_EVENTCENTER_EVENT_H
|
||||
#define OHOS_DISTRIBUTED_DATA_PASTEBOARD_SERVICES_FRAMEWORK_EVENTCENTER_EVENT_H
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "api/visibility.h"
|
||||
namespace OHOS::MiscServices {
|
||||
class Event {
|
||||
|
@ -16,11 +16,12 @@
|
||||
#ifndef OHOS_DISTRIBUTED_DATA_PASTEBOARD_SERVICES_FRAMEWORK_EVENTCENTER_EVENT_CENTER_H
|
||||
#define OHOS_DISTRIBUTED_DATA_PASTEBOARD_SERVICES_FRAMEWORK_EVENTCENTER_EVENT_CENTER_H
|
||||
#include <list>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
|
||||
#include "api/visibility.h"
|
||||
#include "common/concurrent_map.h"
|
||||
#include "eventcenter/event.h"
|
||||
#include "api/visibility.h"
|
||||
namespace OHOS::MiscServices {
|
||||
class EventCenter {
|
||||
public:
|
||||
@ -34,15 +35,16 @@ public:
|
||||
public:
|
||||
API_EXPORT Defer(std::function<void(const Event &)> handler = nullptr, int32_t evtId = Event::EVT_INVALID);
|
||||
API_EXPORT ~Defer();
|
||||
void *operator new (size_t size) = delete;
|
||||
void *operator new[] (size_t size) = delete;
|
||||
void operator delete (void *) = delete;
|
||||
void operator delete[] (void *) = delete;
|
||||
void *operator new(size_t size) = delete;
|
||||
void *operator new[](size_t size) = delete;
|
||||
void operator delete(void *) = delete;
|
||||
void operator delete[](void *) = delete;
|
||||
};
|
||||
API_EXPORT static EventCenter &GetInstance();
|
||||
API_EXPORT bool Subscribe(int32_t evtId, const std::function<void(const Event &)> &observer);
|
||||
API_EXPORT bool Unsubscribe(int32_t evtId);
|
||||
API_EXPORT int32_t PostEvent(std::unique_ptr<Event> evt) const;
|
||||
|
||||
private:
|
||||
void Dispatch(const Event &evt) const;
|
||||
class AsyncQueue final {
|
||||
@ -53,6 +55,7 @@ private:
|
||||
bool operator<=(int32_t depth) const;
|
||||
void Post(std::unique_ptr<Event> event);
|
||||
void AddHandler(int32_t evtId, std::function<void(const Event &)> handler);
|
||||
|
||||
private:
|
||||
std::map<int32_t, std::function<void(const Event &)>> handlers_;
|
||||
std::deque<std::unique_ptr<Event>> events_;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_DISTRIBUTED_DATA_PASTEBOARD_SERVICES_FRAMEWORK_EVENTCENTER_DISTRIBUTED_PASTEBOARD_EVENT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "eventcenter/event.h"
|
||||
namespace OHOS::MiscServices {
|
||||
class API_EXPORT PasteboardEvent : public Event {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "api/visibility.h"
|
||||
#include "ffrt_inner.h"
|
||||
|
||||
@ -45,75 +46,75 @@ using FFRTMutex = ffrt::mutex;
|
||||
class API_EXPORT FFRTUtils final {
|
||||
public:
|
||||
/**
|
||||
* Submit an FFRT atomization task without blocking the current thread.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
*/
|
||||
static void SubmitTask(const FFRTTask& task);
|
||||
* Submit an FFRT atomization task without blocking the current thread.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
*/
|
||||
static void SubmitTask(const FFRTTask &task);
|
||||
|
||||
/**
|
||||
* Submit an FFRT serial task without blocking the current thread.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
*/
|
||||
static void SubmitQueueTasks(const std::vector<FFRTTask>& tasks, FFRTQueue& queue);
|
||||
* Submit an FFRT serial task without blocking the current thread.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
*/
|
||||
static void SubmitQueueTasks(const std::vector<FFRTTask> &tasks, FFRTQueue &queue);
|
||||
|
||||
/**
|
||||
* Submit the FFRT delayed task without blocking the current thread.
|
||||
* <p>
|
||||
* When the delay time is reached, the task starts to be executed.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param delayMs Delay time, in milliseconds.
|
||||
* @param queue FFRT task execution queue.
|
||||
*
|
||||
* @return FFRT task handle.
|
||||
*/
|
||||
static FFRTHandle SubmitDelayTask(FFRTTask& task, uint32_t delayMs, FFRTQueue& queue);
|
||||
* Submit the FFRT delayed task without blocking the current thread.
|
||||
* <p>
|
||||
* When the delay time is reached, the task starts to be executed.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param delayMs Delay time, in milliseconds.
|
||||
* @param queue FFRT task execution queue.
|
||||
*
|
||||
* @return FFRT task handle.
|
||||
*/
|
||||
static FFRTHandle SubmitDelayTask(FFRTTask &task, uint32_t delayMs, FFRTQueue &queue);
|
||||
|
||||
/**
|
||||
* Submit the FFRT delayed task without blocking the current thread.
|
||||
* <p>
|
||||
* When the delay time is reached, the task starts to be executed.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param delayMs Delay time, in milliseconds.
|
||||
* @param queue Shared_ptr of FFRT task execution queue.
|
||||
*
|
||||
* @return FFRT task handle.
|
||||
*/
|
||||
static FFRTHandle SubmitDelayTask(FFRTTask& task, uint32_t delayMs, std::shared_ptr<FFRTQueue> queue);
|
||||
* Submit the FFRT delayed task without blocking the current thread.
|
||||
* <p>
|
||||
* When the delay time is reached, the task starts to be executed.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param delayMs Delay time, in milliseconds.
|
||||
* @param queue Shared_ptr of FFRT task execution queue.
|
||||
*
|
||||
* @return FFRT task handle.
|
||||
*/
|
||||
static FFRTHandle SubmitDelayTask(FFRTTask &task, uint32_t delayMs, std::shared_ptr<FFRTQueue> queue);
|
||||
|
||||
/**
|
||||
* Submit an FFRT timeout task without blocking the current thread.
|
||||
* <p>
|
||||
* When the timeout period is reached, the task will be canceled.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param timeoutMs Timeout interval, in milliseconds.
|
||||
*
|
||||
* @return true: The task is executed successfully. false: The task execution times out.
|
||||
*/
|
||||
static bool SubmitTimeoutTask(const FFRTTask& task, uint32_t timeoutMs);
|
||||
* Submit an FFRT timeout task without blocking the current thread.
|
||||
* <p>
|
||||
* When the timeout period is reached, the task will be canceled.
|
||||
*
|
||||
* @param task FFRT task.
|
||||
* @param timeoutMs Timeout interval, in milliseconds.
|
||||
*
|
||||
* @return true: The task is executed successfully. false: The task execution times out.
|
||||
*/
|
||||
static bool SubmitTimeoutTask(const FFRTTask &task, uint32_t timeoutMs);
|
||||
|
||||
/**
|
||||
* Cancel the FFRT task.
|
||||
* <p>
|
||||
* You cannot cancel a completed task.
|
||||
*
|
||||
* @param handle FFRT task.
|
||||
*/
|
||||
static int CancelTask(FFRTHandle& handle, FFRTQueue& queue);
|
||||
* Cancel the FFRT task.
|
||||
* <p>
|
||||
* You cannot cancel a completed task.
|
||||
*
|
||||
* @param handle FFRT task.
|
||||
*/
|
||||
static int CancelTask(FFRTHandle &handle, FFRTQueue &queue);
|
||||
|
||||
/**
|
||||
* Cancel the FFRT task.
|
||||
* <p>
|
||||
* You cannot cancel a completed task.
|
||||
*
|
||||
* @param handle FFRT task.
|
||||
* @param queue Shared_ptr of FFRT task cancel queue.
|
||||
*/
|
||||
static int CancelTask(FFRTHandle& handle, std::shared_ptr<FFRTQueue> queue);
|
||||
* Cancel the FFRT task.
|
||||
* <p>
|
||||
* You cannot cancel a completed task.
|
||||
*
|
||||
* @param handle FFRT task.
|
||||
* @param queue Shared_ptr of FFRT task cancel queue.
|
||||
*/
|
||||
static int CancelTask(FFRTHandle &handle, std::shared_ptr<FFRTQueue> queue);
|
||||
};
|
||||
|
||||
class API_EXPORT FFRTTimer {
|
||||
@ -124,9 +125,10 @@ public:
|
||||
void Clear();
|
||||
void CancelAllTimer();
|
||||
void CancelTimer(const std::string &timerId);
|
||||
void SetTimer(const std::string &timerId, FFRTTask& task);
|
||||
void SetTimer(const std::string &timerId, FFRTTask& task, uint32_t delayMs);
|
||||
void SetTimer(const std::string &timerId, FFRTTask &task);
|
||||
void SetTimer(const std::string &timerId, FFRTTask &task, uint32_t delayMs);
|
||||
uint32_t GetTaskId(const std::string &timerId);
|
||||
|
||||
private:
|
||||
/* inner functions must be called when mutex_ is locked */
|
||||
void CancelAllTimerInner();
|
||||
|
@ -12,9 +12,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "device/dm_adapter.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "device/dm_adapter.h"
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
|
||||
@ -26,21 +26,13 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void DMAdapterTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::SetUpTestCase(void) {}
|
||||
|
||||
void DMAdapterTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::TearDownTestCase(void) {}
|
||||
|
||||
void DMAdapterTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::SetUp(void) {}
|
||||
|
||||
void DMAdapterTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::TearDown(void) {}
|
||||
|
||||
/**
|
||||
* @tc.name: GetLocalDeviceUdid
|
||||
@ -52,4 +44,4 @@ HWTEST_F(DMAdapterTest, GetLocalDeviceUdid, TestSize.Level0)
|
||||
auto &udid = DMAdapter::GetInstance().GetLocalDeviceUdid();
|
||||
ASSERT_FALSE(udid.empty());
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::MiscServices
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "parcel.h"
|
||||
#include "paste_data_record.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
#include "tlv_object.h"
|
||||
#include "uri.h"
|
||||
#include "want.h"
|
||||
#include "want_params.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
@ -38,7 +38,7 @@ struct API_EXPORT PasteDataProperty : public TLVObject {
|
||||
PasteDataProperty() = default;
|
||||
~PasteDataProperty();
|
||||
explicit PasteDataProperty(const PasteDataProperty &property);
|
||||
PasteDataProperty& operator=(const PasteDataProperty &property);
|
||||
PasteDataProperty &operator=(const PasteDataProperty &property);
|
||||
AAFwk::WantParams additions;
|
||||
std::vector<std::string> mimeTypes;
|
||||
std::string tag;
|
||||
@ -63,7 +63,7 @@ public:
|
||||
PasteData();
|
||||
~PasteData();
|
||||
PasteData(const PasteData &data);
|
||||
PasteData& operator=(const PasteData &data);
|
||||
PasteData &operator=(const PasteData &data);
|
||||
explicit PasteData(std::vector<std::shared_ptr<PasteDataRecord>> records);
|
||||
|
||||
void AddHtmlRecord(const std::string &html);
|
||||
@ -132,7 +132,7 @@ public:
|
||||
void SetDataId(uint32_t dataId);
|
||||
uint32_t GetDataId() const;
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static PasteData* Unmarshalling(Parcel &parcel);
|
||||
static PasteData *Unmarshalling(Parcel &parcel);
|
||||
void SetPasteId(const std::string &pasteId);
|
||||
std::string GetPasteId() const;
|
||||
std::string GetDeviceId() const;
|
||||
@ -168,7 +168,6 @@ private:
|
||||
using Func = std::function<void(bool &ret, const std::vector<std::uint8_t> &buffer, TLVHead &head)>;
|
||||
std::map<uint16_t, Func> decodeMap_;
|
||||
void InitDecodeMap();
|
||||
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -25,9 +25,9 @@ class API_EXPORT MineCustomData : public TLVObject {
|
||||
public:
|
||||
MineCustomData() = default;
|
||||
std::map<std::string, std::vector<uint8_t>> GetItemData();
|
||||
void AddItemData(const std::string& mimeType, const std::vector<uint8_t>& arrayBuffer);
|
||||
bool Encode(std::vector<std::uint8_t>& buffer) override;
|
||||
bool Decode(const std::vector<std::uint8_t>& buffer) override;
|
||||
void AddItemData(const std::string &mimeType, const std::vector<uint8_t> &arrayBuffer);
|
||||
bool Encode(std::vector<std::uint8_t> &buffer) override;
|
||||
bool Decode(const std::vector<std::uint8_t> &buffer) override;
|
||||
size_t Count() override;
|
||||
|
||||
private:
|
||||
@ -38,10 +38,10 @@ class API_EXPORT PasteDataEntry : public TLVObject {
|
||||
public:
|
||||
using UDType = UDMF::UDType;
|
||||
PasteDataEntry() = default;
|
||||
PasteDataEntry(const PasteDataEntry& entry);
|
||||
PasteDataEntry& operator=(const PasteDataEntry& entry);
|
||||
PasteDataEntry(const std::string& utdId, const EntryValue& value);
|
||||
PasteDataEntry(const std::string& utdId, const std::string& mimeType, const EntryValue& value);
|
||||
PasteDataEntry(const PasteDataEntry &entry);
|
||||
PasteDataEntry &operator=(const PasteDataEntry &entry);
|
||||
PasteDataEntry(const std::string &utdId, const EntryValue &value);
|
||||
PasteDataEntry(const std::string &utdId, const std::string &mimeType, const EntryValue &value);
|
||||
|
||||
std::shared_ptr<std::string> ConvertToPlianText() const;
|
||||
std::shared_ptr<std::string> ConvertToHtml() const;
|
||||
@ -50,18 +50,19 @@ public:
|
||||
std::shared_ptr<Media::PixelMap> ConvertToPixelMap() const;
|
||||
std::shared_ptr<MineCustomData> ConvertToCustomData() const;
|
||||
|
||||
void SetValue(const EntryValue& value);
|
||||
void SetValue(const EntryValue &value);
|
||||
EntryValue GetValue() const;
|
||||
void SetUtdId(const std::string& utdId);
|
||||
void SetUtdId(const std::string &utdId);
|
||||
std::string GetUtdId() const;
|
||||
void SetMimeType(const std::string& mimeType);
|
||||
void SetMimeType(const std::string &mimeType);
|
||||
std::string GetMimeType() const;
|
||||
bool Encode(std::vector<std::uint8_t>& buffer) override;
|
||||
bool Decode(const std::vector<std::uint8_t>& buffer) override;
|
||||
bool Encode(std::vector<std::uint8_t> &buffer) override;
|
||||
bool Decode(const std::vector<std::uint8_t> &buffer) override;
|
||||
size_t Count() override;
|
||||
|
||||
bool Marshalling(std::vector<std::uint8_t>& buffer);
|
||||
bool Unmarshalling(const std::vector<std::uint8_t>& buffer);
|
||||
bool Marshalling(std::vector<std::uint8_t> &buffer);
|
||||
bool Unmarshalling(const std::vector<std::uint8_t> &buffer);
|
||||
|
||||
private:
|
||||
std::string utdId_;
|
||||
std::string mimeType_; // pasteboard mimeType
|
||||
@ -72,9 +73,9 @@ class API_EXPORT CommonUtils {
|
||||
public:
|
||||
using UDType = UDMF::UDType;
|
||||
static std::string Convert(UDType uDType);
|
||||
static std::string Convert2MimeType(const std::string& utdId);
|
||||
static UDType Convert(int32_t uDType, const std::string& mimeType);
|
||||
static std::string Convert2UtdId(int32_t uDType, const std::string& mimeType);
|
||||
static std::string Convert2MimeType(const std::string &utdId);
|
||||
static UDType Convert(int32_t uDType, const std::string &mimeType);
|
||||
static std::string Convert2UtdId(int32_t uDType, const std::string &mimeType);
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -86,22 +86,22 @@ public:
|
||||
void SetGrantUriPermission(bool hasPermission);
|
||||
bool HasGrantUriPermission();
|
||||
|
||||
void SetTextContent(const std::string& content);
|
||||
void SetTextContent(const std::string &content);
|
||||
std::string GetTextContent() const;
|
||||
void SetDetails(const Details& details);
|
||||
void SetDetails(const Details &details);
|
||||
std::shared_ptr<Details> GetDetails() const;
|
||||
void SetSystemDefinedContent(const Details& contents);
|
||||
void SetSystemDefinedContent(const Details &contents);
|
||||
std::shared_ptr<Details> GetSystemDefinedContent() const;
|
||||
int32_t GetUDType() const;
|
||||
void SetUDType(int32_t type);
|
||||
|
||||
bool IsEmpty() const;
|
||||
void SetUDMFValue(const std::shared_ptr<EntryValue>& udmfValue);
|
||||
void SetUDMFValue(const std::shared_ptr<EntryValue> &udmfValue);
|
||||
std::shared_ptr<EntryValue> GetUDMFValue();
|
||||
void AddEntry(const std::string& utdType, std::shared_ptr<PasteDataEntry> value);
|
||||
std::shared_ptr<PasteDataEntry> GetEntry(const std::string& utdType) const;
|
||||
void AddEntry(const std::string &utdType, std::shared_ptr<PasteDataEntry> value);
|
||||
std::shared_ptr<PasteDataEntry> GetEntry(const std::string &utdType) const;
|
||||
std::vector<std::shared_ptr<PasteDataEntry>> GetEntries() const;
|
||||
std::vector<std::string> GetValidTypes(const std::vector<std::string>& types) const;
|
||||
std::vector<std::string> GetValidTypes(const std::vector<std::string> &types) const;
|
||||
|
||||
void SetDelayRecordFlag(bool isDelay);
|
||||
bool IsDelayRecord() const;
|
||||
|
@ -16,9 +16,10 @@
|
||||
#ifndef PASTE_BOARD_CLIENT_H
|
||||
#define PASTE_BOARD_CLIENT_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <singleton.h>
|
||||
#include <condition_variable>
|
||||
|
||||
#include "i_pasteboard_service.h"
|
||||
#include "paste_data.h"
|
||||
#include "paste_data_record.h"
|
||||
@ -45,337 +46,337 @@ public:
|
||||
DISALLOW_COPY_AND_MOVE(PasteboardClient);
|
||||
|
||||
/**
|
||||
* CreateHtmlTextRecord
|
||||
* @descrition Create Html Text Record.
|
||||
* @param std::string text.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreateHtmlTextRecord
|
||||
* @descrition Create Html Text Record.
|
||||
* @param std::string text.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreateHtmlTextRecord(const std::string &text);
|
||||
|
||||
/**
|
||||
* CreatePlainTextRecord
|
||||
* @descrition Create Plaint Text Record.
|
||||
* @param std::string text.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreatePlainTextRecord
|
||||
* @descrition Create Plaint Text Record.
|
||||
* @param std::string text.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreatePlainTextRecord(const std::string &text);
|
||||
|
||||
/**
|
||||
* CreatePixelMapRecord
|
||||
* @descrition Create PixelMap Record.
|
||||
* @param OHOS::Media::PixelMap pixelMap.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreatePixelMapRecord
|
||||
* @descrition Create PixelMap Record.
|
||||
* @param OHOS::Media::PixelMap pixelMap.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreatePixelMapRecord(std::shared_ptr<OHOS::Media::PixelMap> pixelMap);
|
||||
|
||||
/**
|
||||
* CreateUriRecord
|
||||
* @descrition Create Uri Text Record.
|
||||
* @param OHOS::Uri uri.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreateUriRecord
|
||||
* @descrition Create Uri Text Record.
|
||||
* @param OHOS::Uri uri.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreateUriRecord(const OHOS::Uri &uri);
|
||||
|
||||
/**
|
||||
* CreateWantRecord
|
||||
* @descrition Create Plaint Want Record.
|
||||
* @param OHOS::AAFwk::Want want.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreateWantRecord
|
||||
* @descrition Create Plaint Want Record.
|
||||
* @param OHOS::AAFwk::Want want.
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreateWantRecord(std::shared_ptr<OHOS::AAFwk::Want> want);
|
||||
|
||||
/**
|
||||
* CreateKvRecord
|
||||
* @descrition Create Kv Record.
|
||||
* @param std::string mimeType
|
||||
* @param std::vector<uint8_t> arrayBuffer
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
* CreateKvRecord
|
||||
* @descrition Create Kv Record.
|
||||
* @param std::string mimeType
|
||||
* @param std::vector<uint8_t> arrayBuffer
|
||||
* @return PasteDataRecord.
|
||||
*/
|
||||
std::shared_ptr<PasteDataRecord> CreateKvRecord(
|
||||
const std::string &mimeType, const std::vector<uint8_t> &arrayBuffer);
|
||||
|
||||
/**
|
||||
* CreateHtmlData
|
||||
* @descrition Create Html Paste Data.
|
||||
* @param std::string text .
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreateHtmlData
|
||||
* @descrition Create Html Paste Data.
|
||||
* @param std::string text .
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreateHtmlData(const std::string &htmlText);
|
||||
|
||||
/**
|
||||
* CreatePlainTextData
|
||||
* @descritionCreate Plain Text Paste Data.
|
||||
* @param std::string text .
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreatePlainTextData
|
||||
* @descritionCreate Plain Text Paste Data.
|
||||
* @param std::string text .
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreatePlainTextData(const std::string &text);
|
||||
|
||||
/**
|
||||
* CreatePixelMapData
|
||||
* @descrition Create PixelMap Paste Data.
|
||||
* @param OHOS::Media::PixelMap pixelMap .
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreatePixelMapData
|
||||
* @descrition Create PixelMap Paste Data.
|
||||
* @param OHOS::Media::PixelMap pixelMap .
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreatePixelMapData(std::shared_ptr<OHOS::Media::PixelMap> pixelMap);
|
||||
|
||||
/**
|
||||
* CreateUriData
|
||||
* @descrition Create Uri Paste Data.
|
||||
* @param OHOS::Uri uri .
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreateUriData
|
||||
* @descrition Create Uri Paste Data.
|
||||
* @param OHOS::Uri uri .
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreateUriData(const OHOS::Uri &uri);
|
||||
|
||||
/**
|
||||
* CreateWantData
|
||||
* @descrition Create Want Paste Data.
|
||||
* @param OHOS::AAFwk::Want want .
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreateWantData
|
||||
* @descrition Create Want Paste Data.
|
||||
* @param OHOS::AAFwk::Want want .
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreateWantData(std::shared_ptr<OHOS::AAFwk::Want> want);
|
||||
|
||||
/**
|
||||
* CreateKvData
|
||||
* @descrition Create Kv Paste Data.
|
||||
* @param std::string mimeType
|
||||
* @param std::vector<uint8_t> arrayBuffer
|
||||
* @return PasteData.
|
||||
*/
|
||||
* CreateKvData
|
||||
* @descrition Create Kv Paste Data.
|
||||
* @param std::string mimeType
|
||||
* @param std::vector<uint8_t> arrayBuffer
|
||||
* @return PasteData.
|
||||
*/
|
||||
std::shared_ptr<PasteData> CreateKvData(const std::string &mimeType, const std::vector<uint8_t> &arrayBuffer);
|
||||
|
||||
/**
|
||||
* GetRecordValueByType
|
||||
* @descrition get entry value from the pasteboard.
|
||||
* @param dataId the dataId of the PasteData.
|
||||
* @param recordId the recordId of the PasteRecord.
|
||||
* @param value the value of the PasteDataEntry.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetRecordValueByType(uint32_t dataId, uint32_t recordId, PasteDataEntry& value);
|
||||
* GetRecordValueByType
|
||||
* @descrition get entry value from the pasteboard.
|
||||
* @param dataId the dataId of the PasteData.
|
||||
* @param recordId the recordId of the PasteRecord.
|
||||
* @param value the value of the PasteDataEntry.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetRecordValueByType(uint32_t dataId, uint32_t recordId, PasteDataEntry &value);
|
||||
|
||||
/**
|
||||
* GetPasteData
|
||||
* @descrition get paste data from the pasteboard.
|
||||
* @param pasteData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
* GetPasteData
|
||||
* @descrition get paste data from the pasteboard.
|
||||
* @param pasteData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetPasteData(PasteData &pasteData);
|
||||
|
||||
/**
|
||||
* HasPasteData
|
||||
* @descrition check paste data exist in the pasteboard.
|
||||
* @return bool. True exists, false does not exist
|
||||
*/
|
||||
* HasPasteData
|
||||
* @descrition check paste data exist in the pasteboard.
|
||||
* @return bool. True exists, false does not exist
|
||||
*/
|
||||
bool HasPasteData();
|
||||
|
||||
/**
|
||||
* Clear
|
||||
* @descrition Clear Current pasteboard data.
|
||||
* @return void.
|
||||
*/
|
||||
* Clear
|
||||
* @descrition Clear Current pasteboard data.
|
||||
* @return void.
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param pasteData the object of the PasteData.
|
||||
* @param pasteData the object of the PasteboardDelayGetter.
|
||||
* @param pasteData the map of the EntryGetter.
|
||||
* @return int32_t.
|
||||
*/
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param pasteData the object of the PasteData.
|
||||
* @param pasteData the object of the PasteboardDelayGetter.
|
||||
* @param pasteData the map of the EntryGetter.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t SetPasteData(PasteData &pasteData, std::shared_ptr<PasteboardDelayGetter> delayGetter = nullptr,
|
||||
std::map<uint32_t, std::shared_ptr<UDMF::EntryGetter>> entryGetters = {});
|
||||
|
||||
/**
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t SetUnifiedData(const UDMF::UnifiedData &unifiedData,
|
||||
std::shared_ptr<PasteboardDelayGetter> delayGetter = nullptr);
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t SetUnifiedData(
|
||||
const UDMF::UnifiedData &unifiedData, std::shared_ptr<PasteboardDelayGetter> delayGetter = nullptr);
|
||||
|
||||
/**
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
* SetPasteData
|
||||
* @descrition set paste data to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetUnifiedData(UDMF::UnifiedData &unifiedData);
|
||||
|
||||
/**
|
||||
* SetUdsdData
|
||||
* @descrition set unified data with uds entries to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t SetUdsdData(const UDMF::UnifiedData& unifiedData);
|
||||
* SetUdsdData
|
||||
* @descrition set unified data with uds entries to the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t SetUdsdData(const UDMF::UnifiedData &unifiedData);
|
||||
|
||||
/**
|
||||
* GetUnifiedDataWithEntry
|
||||
* @descrition get unified data with uds entries from the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetUdsdData(UDMF::UnifiedData& unifiedData);
|
||||
* GetUnifiedDataWithEntry
|
||||
* @descrition get unified data with uds entries from the pasteboard.
|
||||
* @param unifiedData the object of the PasteDate.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetUdsdData(UDMF::UnifiedData &unifiedData);
|
||||
|
||||
/**
|
||||
* IsRemoteData
|
||||
* @descrition check if remote data.
|
||||
* @return bool. True is remote data, else false.
|
||||
*/
|
||||
* IsRemoteData
|
||||
* @descrition check if remote data.
|
||||
* @return bool. True is remote data, else false.
|
||||
*/
|
||||
bool IsRemoteData();
|
||||
|
||||
/**
|
||||
* GetDataSource
|
||||
* @descrition Obtain the package name of the data source application.
|
||||
* @param std::string bundleName The package name of the application.
|
||||
* @return int32_t.
|
||||
*/
|
||||
* GetDataSource
|
||||
* @descrition Obtain the package name of the data source application.
|
||||
* @param std::string bundleName The package name of the application.
|
||||
* @return int32_t.
|
||||
*/
|
||||
int32_t GetDataSource(std::string &bundleName);
|
||||
|
||||
/**
|
||||
* HasDataType
|
||||
* @descrition Check if there is data of the specified type in the pasteboard.
|
||||
* @param std::string mimeType Specified mimetype.
|
||||
* @return bool. True exists, false does not exist
|
||||
*/
|
||||
* HasDataType
|
||||
* @descrition Check if there is data of the specified type in the pasteboard.
|
||||
* @param std::string mimeType Specified mimetype.
|
||||
* @return bool. True exists, false does not exist
|
||||
*/
|
||||
bool HasDataType(const std::string &mimeType);
|
||||
|
||||
/**
|
||||
* DetectPatterns
|
||||
* @description Checks the specified patterns contained in clipboard, and removes if not found.
|
||||
* @param patternsToCheck A reference to an set of Pattern to check against the clipboard.
|
||||
* @return Returns DetectPatterns.
|
||||
*/
|
||||
* DetectPatterns
|
||||
* @description Checks the specified patterns contained in clipboard, and removes if not found.
|
||||
* @param patternsToCheck A reference to an set of Pattern to check against the clipboard.
|
||||
* @return Returns DetectPatterns.
|
||||
*/
|
||||
std::set<Pattern> DetectPatterns(const std::set<Pattern> &patternsToCheck);
|
||||
|
||||
/**
|
||||
* Subscribe
|
||||
* @descrition
|
||||
* @param type observer type
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
* Subscribe
|
||||
* @descrition
|
||||
* @param type observer type
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
void Subscribe(PasteboardObserverType type, sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* AddPasteboardChangedObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
* AddPasteboardChangedObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
void AddPasteboardChangedObserver(sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* AddPasteboardEventObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard event(read or change) callback.
|
||||
* @return void.
|
||||
*/
|
||||
* AddPasteboardEventObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard event(read or change) callback.
|
||||
* @return void.
|
||||
*/
|
||||
void AddPasteboardEventObserver(sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* Unsubscribe
|
||||
* @descrition
|
||||
* @param type observer type
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
/**
|
||||
* Unsubscribe
|
||||
* @descrition
|
||||
* @param type observer type
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
void Unsubscribe(PasteboardObserverType type, sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* RemovePasteboardChangedObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
* RemovePasteboardChangedObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard change callback.
|
||||
* @return void.
|
||||
*/
|
||||
void RemovePasteboardChangedObserver(sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* RemovePasteboardEventObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard event callback.
|
||||
* @return void.
|
||||
*/
|
||||
* RemovePasteboardEventObserver
|
||||
* @descrition
|
||||
* @param observer pasteboard event callback.
|
||||
* @return void.
|
||||
*/
|
||||
void RemovePasteboardEventObserver(sptr<PasteboardObserver> callback);
|
||||
|
||||
/**
|
||||
* SetGlobalShareOption
|
||||
* @descrition Set globalShareOptions.
|
||||
* @param globalShareOption globalShareOptions
|
||||
* @return int32_t
|
||||
*/
|
||||
* SetGlobalShareOption
|
||||
* @descrition Set globalShareOptions.
|
||||
* @param globalShareOption globalShareOptions
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t SetGlobalShareOption(const std::map<uint32_t, ShareOption> &globalShareOptions);
|
||||
|
||||
/**
|
||||
* RemoveGlobalShareOption
|
||||
* @descrition Remove globalShareOptions.
|
||||
* @param tokenId tokenIds
|
||||
* @return int32_t
|
||||
*/
|
||||
* RemoveGlobalShareOption
|
||||
* @descrition Remove globalShareOptions.
|
||||
* @param tokenId tokenIds
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t RemoveGlobalShareOption(const std::vector<uint32_t> &tokenIds);
|
||||
|
||||
/**
|
||||
* GetGlobalShareOption
|
||||
* @descrition Get globalShareOptions.
|
||||
* @param tokenId tokenIds
|
||||
* @return globalShareOptions
|
||||
*/
|
||||
* GetGlobalShareOption
|
||||
* @descrition Get globalShareOptions.
|
||||
* @param tokenId tokenIds
|
||||
* @return globalShareOptions
|
||||
*/
|
||||
std::map<uint32_t, ShareOption> GetGlobalShareOption(const std::vector<uint32_t> &tokenIds);
|
||||
|
||||
/**
|
||||
* SetAppShareOptions
|
||||
* @description Sets a unified ShareOptions for the application.
|
||||
* @param shareOptions shareOptions
|
||||
* @return result
|
||||
*/
|
||||
* SetAppShareOptions
|
||||
* @description Sets a unified ShareOptions for the application.
|
||||
* @param shareOptions shareOptions
|
||||
* @return result
|
||||
*/
|
||||
int32_t SetAppShareOptions(const ShareOption &shareOptions);
|
||||
|
||||
/**
|
||||
* RemoveAppShareOptions
|
||||
* @description Removes the ShareOptions for the application.
|
||||
* @return result
|
||||
*/
|
||||
* RemoveAppShareOptions
|
||||
* @description Removes the ShareOptions for the application.
|
||||
* @return result
|
||||
*/
|
||||
int32_t RemoveAppShareOptions();
|
||||
|
||||
/**
|
||||
* OnRemoteSaDied
|
||||
* @descrition
|
||||
* @param object systemAbility proxy object
|
||||
* @return void.
|
||||
*/
|
||||
* OnRemoteSaDied
|
||||
* @descrition
|
||||
* @param object systemAbility proxy object
|
||||
* @return void.
|
||||
*/
|
||||
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
|
||||
|
||||
/**
|
||||
* LoadSystemAbilitySuccess
|
||||
* @descrition inherit SystemAbilityLoadCallbackStub override LoadSystemAbilitySuccess
|
||||
* @param remoteObject systemAbility proxy object.
|
||||
* @return void.
|
||||
*/
|
||||
* LoadSystemAbilitySuccess
|
||||
* @descrition inherit SystemAbilityLoadCallbackStub override LoadSystemAbilitySuccess
|
||||
* @param remoteObject systemAbility proxy object.
|
||||
* @return void.
|
||||
*/
|
||||
void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
|
||||
|
||||
/**
|
||||
* LoadSystemAbilityFail
|
||||
* @descrition inherit SystemAbilityLoadCallbackStub override LoadSystemAbilityFail
|
||||
* @return void.
|
||||
*/
|
||||
* LoadSystemAbilityFail
|
||||
* @descrition inherit SystemAbilityLoadCallbackStub override LoadSystemAbilityFail
|
||||
* @return void.
|
||||
*/
|
||||
void LoadSystemAbilityFail();
|
||||
|
||||
/**
|
||||
* PasteStart
|
||||
* @descrition Utilized to notify pasteboard service while reading PasteData, in this case, the service will help to
|
||||
* preserve the context and resources
|
||||
* @return void.
|
||||
*/
|
||||
* PasteStart
|
||||
* @descrition Utilized to notify pasteboard service while reading PasteData, in this case, the service will help to
|
||||
* preserve the context and resources
|
||||
* @return void.
|
||||
*/
|
||||
void PasteStart(const std::string &pasteId);
|
||||
|
||||
/**
|
||||
* PasteComplete
|
||||
* @descrition Invoked to notify pasteboard service the utilization of PasteData has completed and occupied
|
||||
* resources can be released for further usage
|
||||
* @return void.
|
||||
*/
|
||||
* PasteComplete
|
||||
* @descrition Invoked to notify pasteboard service the utilization of PasteData has completed and occupied
|
||||
* resources can be released for further usage
|
||||
* @return void.
|
||||
*/
|
||||
void PasteComplete(const std::string &deviceId, const std::string &pasteId);
|
||||
|
||||
private:
|
||||
@ -389,20 +390,20 @@ private:
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_{ nullptr };
|
||||
std::atomic<uint32_t> getSequenceId_ = 0;
|
||||
class StaticDestoryMonitor {
|
||||
public:
|
||||
StaticDestoryMonitor() : destoryed_(false) {}
|
||||
~StaticDestoryMonitor()
|
||||
{
|
||||
destoryed_ = true;
|
||||
}
|
||||
public:
|
||||
StaticDestoryMonitor() : destoryed_(false) {}
|
||||
~StaticDestoryMonitor()
|
||||
{
|
||||
destoryed_ = true;
|
||||
}
|
||||
|
||||
bool IsDestoryed() const
|
||||
{
|
||||
return destoryed_;
|
||||
}
|
||||
bool IsDestoryed() const
|
||||
{
|
||||
return destoryed_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool destoryed_;
|
||||
private:
|
||||
bool destoryed_;
|
||||
};
|
||||
static StaticDestoryMonitor staticDestoryMonitor_;
|
||||
void RebuildWebviewPasteData(PasteData &pasteData);
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
PasteboardDelayGetter() = default;
|
||||
|
||||
virtual ~PasteboardDelayGetter() {};
|
||||
virtual ~PasteboardDelayGetter(){};
|
||||
|
||||
virtual void GetPasteData(const std::string &type, PasteData &data) = 0;
|
||||
|
||||
|
@ -25,11 +25,13 @@ public:
|
||||
PasteboardEntryGetter() = default;
|
||||
~PasteboardEntryGetter() = default;
|
||||
UDMF::ValueType GetValueByType(uint32_t dataId, uint32_t recordId, const std::string &utdId) override;
|
||||
|
||||
private:
|
||||
class Factory {
|
||||
public:
|
||||
Factory();
|
||||
~Factory();
|
||||
|
||||
private:
|
||||
std::shared_ptr<PasteboardEntryGetter> getter_;
|
||||
};
|
||||
|
@ -31,10 +31,10 @@ namespace MiscServices {
|
||||
|
||||
class API_EXPORT PasteboardWebController : public RefBase {
|
||||
public:
|
||||
PasteboardWebController() {};
|
||||
~PasteboardWebController() {};
|
||||
PasteboardWebController(){};
|
||||
~PasteboardWebController(){};
|
||||
|
||||
static PasteboardWebController& GetInstance();
|
||||
static PasteboardWebController &GetInstance();
|
||||
|
||||
std::shared_ptr<PasteData> SplitHtml(std::shared_ptr<std::string> html) noexcept;
|
||||
std::shared_ptr<std::string> RebuildHtml(std::shared_ptr<PasteData> pasteData) noexcept;
|
||||
@ -43,11 +43,11 @@ private:
|
||||
std::vector<std::pair<std::string, uint32_t>> SplitHtmlWithImgLabel(
|
||||
const std::shared_ptr<std::string> html) noexcept;
|
||||
std::map<std::string, std::vector<uint8_t>> SplitHtmlWithImgSrcLabel(
|
||||
const std::vector<std::pair<std::string, uint32_t>>& matchVec) noexcept;
|
||||
const std::vector<std::pair<std::string, uint32_t>> &matchVec) noexcept;
|
||||
std::shared_ptr<PasteData> BuildPasteData(
|
||||
std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>>& imgSrcMap) noexcept;
|
||||
std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>> &imgSrcMap) noexcept;
|
||||
void RemoveAllRecord(std::shared_ptr<PasteData> pasteData) noexcept;
|
||||
bool IsLocalURI(std::string& uri) noexcept;
|
||||
bool IsLocalURI(std::string &uri) noexcept;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -13,14 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <if_system_ability_manager.h>
|
||||
#include <ipc_skeleton.h>
|
||||
#include <iservice_registry.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "convert_utils.h"
|
||||
#include "file_uri.h"
|
||||
#include "hiview_adapter.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "hiview_adapter.h"
|
||||
#include "ipasteboard_client_death_observer.h"
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_delay_getter_client.h"
|
||||
#include "pasteboard_entry_getter_client.h"
|
||||
@ -28,11 +30,10 @@
|
||||
#include "pasteboard_event_dfx.h"
|
||||
#include "pasteboard_load_callback.h"
|
||||
#include "pasteboard_observer.h"
|
||||
#include "pasteboard_utils.h"
|
||||
#include "pasteboard_web_controller.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "pasteboard_web_controller.h"
|
||||
#include "pasteboard_utils.h"
|
||||
#include "ipasteboard_client_death_observer.h"
|
||||
using namespace OHOS::Media;
|
||||
|
||||
namespace OHOS {
|
||||
@ -230,7 +231,7 @@ int32_t PasteboardClient::GetPasteData(PasteData &pasteData)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t PasteboardClient::GetUnifiedData(UDMF::UnifiedData& unifiedData)
|
||||
int32_t PasteboardClient::GetUnifiedData(UDMF::UnifiedData &unifiedData)
|
||||
{
|
||||
StartAsyncTrace(HITRACE_TAG_MISC, "PasteboardClient::GetUnifiedData", HITRACE_GETPASTEDATA);
|
||||
PasteData pasteData;
|
||||
@ -258,7 +259,7 @@ void PasteboardClient::RebuildWebviewPasteData(PasteData &pasteData)
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "Rebuild webview PasteData start.");
|
||||
auto details = std::make_shared<Details>();
|
||||
std::string textContent;
|
||||
for (auto& item : pasteData.AllRecords()) {
|
||||
for (auto &item : pasteData.AllRecords()) {
|
||||
if (!item->GetTextContent().empty() && textContent.empty()) {
|
||||
details = item->GetDetails();
|
||||
textContent = item->GetTextContent();
|
||||
@ -285,8 +286,10 @@ void PasteboardClient::RebuildWebviewPasteData(PasteData &pasteData)
|
||||
auto webData = std::make_shared<PasteData>(pasteData);
|
||||
PasteboardWebController.RebuildHtml(webData);
|
||||
PasteDataRecord::Builder builder(MIMETYPE_TEXT_HTML);
|
||||
std::shared_ptr<PasteDataRecord> pasteDataRecord = builder.SetMimeType(MIMETYPE_TEXT_HTML).
|
||||
SetPlainText(pasteData.GetPrimaryText()).SetHtmlText(webData->GetPrimaryHtml()).Build();
|
||||
std::shared_ptr<PasteDataRecord> pasteDataRecord = builder.SetMimeType(MIMETYPE_TEXT_HTML)
|
||||
.SetPlainText(pasteData.GetPrimaryText())
|
||||
.SetHtmlText(webData->GetPrimaryHtml())
|
||||
.Build();
|
||||
if (details) {
|
||||
pasteDataRecord->SetDetails(*details);
|
||||
}
|
||||
@ -327,8 +330,8 @@ bool PasteboardClient::HasPasteData()
|
||||
return proxyService->HasPasteData();
|
||||
}
|
||||
|
||||
int32_t PasteboardClient::SetPasteData(PasteData &pasteData, std::shared_ptr <PasteboardDelayGetter> delayGetter,
|
||||
std::map <uint32_t, std::shared_ptr<UDMF::EntryGetter>> entryGetters)
|
||||
int32_t PasteboardClient::SetPasteData(PasteData &pasteData, std::shared_ptr<PasteboardDelayGetter> delayGetter,
|
||||
std::map<uint32_t, std::shared_ptr<UDMF::EntryGetter>> entryGetters)
|
||||
{
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "SetPasteData start.");
|
||||
RADAR_REPORT(RadarReporter::DFX_SET_PASTEBOARD, RadarReporter::DFX_SET_BIZ_SCENE, RadarReporter::DFX_SUCCESS,
|
||||
@ -345,10 +348,10 @@ int32_t PasteboardClient::SetPasteData(PasteData &pasteData, std::shared_ptr <Pa
|
||||
pasteData.SetDelayData(true);
|
||||
delayGetterAgent = new (std::nothrow) PasteboardDelayGetterClient(delayGetter);
|
||||
}
|
||||
sptr <PasteboardEntryGetterClient> entryGetterAgent;
|
||||
sptr<PasteboardEntryGetterClient> entryGetterAgent;
|
||||
if (!(entryGetters.empty())) {
|
||||
pasteData.SetDelayRecord(true);
|
||||
entryGetterAgent = new(std::nothrow) PasteboardEntryGetterClient(entryGetters);
|
||||
entryGetterAgent = new (std::nothrow) PasteboardEntryGetterClient(entryGetters);
|
||||
}
|
||||
std::shared_ptr<std::string> html = pasteData.GetPrimaryHtml();
|
||||
if (html == nullptr) {
|
||||
@ -370,8 +373,8 @@ int32_t PasteboardClient::SetPasteData(PasteData &pasteData, std::shared_ptr <Pa
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t PasteboardClient::SetUnifiedData(const UDMF::UnifiedData &unifiedData,
|
||||
std::shared_ptr<PasteboardDelayGetter> delayGetter)
|
||||
int32_t PasteboardClient::SetUnifiedData(
|
||||
const UDMF::UnifiedData &unifiedData, std::shared_ptr<PasteboardDelayGetter> delayGetter)
|
||||
{
|
||||
auto pasteData = PasteboardUtils::GetInstance().Convert(unifiedData);
|
||||
return SetPasteData(*pasteData, delayGetter);
|
||||
@ -380,7 +383,7 @@ int32_t PasteboardClient::SetUnifiedData(const UDMF::UnifiedData &unifiedData,
|
||||
int32_t PasteboardClient::SetUdsdData(const UDMF::UnifiedData &unifiedData)
|
||||
{
|
||||
auto pasteData = ConvertUtils::Convert(unifiedData);
|
||||
std::map <uint32_t, std::shared_ptr<UDMF::EntryGetter>> entryGetters;
|
||||
std::map<uint32_t, std::shared_ptr<UDMF::EntryGetter>> entryGetters;
|
||||
for (auto record : unifiedData.GetRecords()) {
|
||||
if (record != nullptr && record->GetEntryGetter() != nullptr) {
|
||||
entryGetters.emplace(record->GetRecordId(), record->GetEntryGetter());
|
||||
@ -609,8 +612,9 @@ sptr<IPasteboardService> PasteboardClient::GetPasteboardService()
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "Failed to load systemAbility.");
|
||||
return nullptr;
|
||||
}
|
||||
auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(LOADSA_TIMEOUT_MS),
|
||||
[this]() { return pasteboardServiceProxy_ != nullptr; });
|
||||
auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(LOADSA_TIMEOUT_MS), [this]() {
|
||||
return pasteboardServiceProxy_ != nullptr;
|
||||
});
|
||||
if (!waitStatus) {
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "Load systemAbility timeout.");
|
||||
return nullptr;
|
||||
@ -672,9 +676,7 @@ void PasteboardClient::PasteComplete(const std::string &deviceId, const std::str
|
||||
proxyService->PasteComplete(deviceId, pasteId);
|
||||
}
|
||||
|
||||
PasteboardSaDeathRecipient::PasteboardSaDeathRecipient()
|
||||
{
|
||||
}
|
||||
PasteboardSaDeathRecipient::PasteboardSaDeathRecipient() {}
|
||||
|
||||
void PasteboardSaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
|
||||
{
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "pasteboard_entry_getter.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -39,8 +39,8 @@ PasteboardEntryGetter::Factory::~Factory()
|
||||
|
||||
UDMF::ValueType PasteboardEntryGetter::GetValueByType(uint32_t dataId, uint32_t recordId, const std::string &utdId)
|
||||
{
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "dataId:%{public}d. recordId:%{public}d, utdId:%{public}s",
|
||||
dataId, recordId, utdId.c_str());
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "dataId:%{public}d. recordId:%{public}d, utdId:%{public}s", dataId,
|
||||
recordId, utdId.c_str());
|
||||
auto pasteType = CommonUtils::Convert2MimeType(utdId);
|
||||
PasteDataEntry entryValue;
|
||||
entryValue.SetUtdId(utdId);
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "pasteboard_load_callback.h"
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_load_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
@ -31,5 +31,5 @@ void PasteboardLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
PasteboardClient::GetInstance()->LoadSystemAbilityFail();
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "Load system ability failed!");
|
||||
}
|
||||
}
|
||||
} // namespace MiscServices
|
||||
}
|
@ -12,8 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "pasteboard_utils.h"
|
||||
|
||||
#include "application_defined_record.h"
|
||||
#include "audio.h"
|
||||
#include "folder.h"
|
||||
@ -21,13 +19,14 @@
|
||||
#include "image.h"
|
||||
#include "link.h"
|
||||
#include "paste_data_record.h"
|
||||
#include "pasteboard_utils.h"
|
||||
#include "pixel_map.h"
|
||||
#include "plain_text.h"
|
||||
#include "system_defined_appitem.h"
|
||||
#include "system_defined_form.h"
|
||||
#include "system_defined_pixelmap.h"
|
||||
#include "unified_record.h"
|
||||
#include "video.h"
|
||||
#include "system_defined_pixelmap.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
@ -74,7 +73,7 @@ void PasteboardUtils::InitDecodeMap()
|
||||
};
|
||||
}
|
||||
|
||||
std::shared_ptr<PasteData> PasteboardUtils::Convert(const UnifiedData& unifiedData)
|
||||
std::shared_ptr<PasteData> PasteboardUtils::Convert(const UnifiedData &unifiedData)
|
||||
{
|
||||
auto unifiedRecords = unifiedData.GetRecords();
|
||||
auto pasteData = std::make_shared<PasteData>(Convert(unifiedRecords));
|
||||
@ -86,7 +85,7 @@ std::shared_ptr<PasteData> PasteboardUtils::Convert(const UnifiedData& unifiedDa
|
||||
return pasteData;
|
||||
}
|
||||
|
||||
std::shared_ptr<UnifiedData> PasteboardUtils::Convert(const PasteData& pasteData)
|
||||
std::shared_ptr<UnifiedData> PasteboardUtils::Convert(const PasteData &pasteData)
|
||||
{
|
||||
auto unifiedData = std::make_shared<UnifiedData>();
|
||||
for (std::size_t i = 0; i < pasteData.GetRecordCount(); ++i) {
|
||||
@ -110,10 +109,10 @@ std::shared_ptr<UnifiedData> PasteboardUtils::Convert(const PasteData& pasteData
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> PasteboardUtils::Convert(
|
||||
const std::vector<std::shared_ptr<UnifiedRecord>>& records)
|
||||
const std::vector<std::shared_ptr<UnifiedRecord>> &records)
|
||||
{
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteboardRecords;
|
||||
for (auto const& record : records) {
|
||||
for (auto const &record : records) {
|
||||
if (record == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -130,7 +129,7 @@ std::vector<std::shared_ptr<PasteDataRecord>> PasteboardUtils::Convert(
|
||||
return pasteboardRecords;
|
||||
}
|
||||
|
||||
PasteDataProperty PasteboardUtils::Convert(const UnifiedDataProperties& properties)
|
||||
PasteDataProperty PasteboardUtils::Convert(const UnifiedDataProperties &properties)
|
||||
{
|
||||
PasteDataProperty pasteDataProperty;
|
||||
pasteDataProperty.shareOption = static_cast<ShareOption>(properties.shareOptions);
|
||||
@ -141,11 +140,11 @@ PasteDataProperty PasteboardUtils::Convert(const UnifiedDataProperties& properti
|
||||
return PasteDataProperty(pasteDataProperty);
|
||||
}
|
||||
|
||||
std::shared_ptr<UnifiedDataProperties> PasteboardUtils::Convert(const PasteDataProperty& properties)
|
||||
std::shared_ptr<UnifiedDataProperties> PasteboardUtils::Convert(const PasteDataProperty &properties)
|
||||
{
|
||||
auto unifiedDataProperties = std::make_shared<UnifiedDataProperties>();
|
||||
unifiedDataProperties->shareOptions = properties.shareOption == ShareOption::InApp ? UDMF::ShareOptions::IN_APP
|
||||
: UDMF::ShareOptions::CROSS_APP;
|
||||
: UDMF::ShareOptions::CROSS_APP;
|
||||
unifiedDataProperties->extras = properties.additions;
|
||||
unifiedDataProperties->timestamp = properties.timestamp;
|
||||
unifiedDataProperties->tag = properties.tag;
|
||||
@ -153,10 +152,10 @@ std::shared_ptr<UnifiedDataProperties> PasteboardUtils::Convert(const PasteDataP
|
||||
return unifiedDataProperties;
|
||||
}
|
||||
|
||||
std::vector<std::string> PasteboardUtils::Convert(const std::vector<std::string>& utdIds)
|
||||
std::vector<std::string> PasteboardUtils::Convert(const std::vector<std::string> &utdIds)
|
||||
{
|
||||
std::vector<std::string> types;
|
||||
for (const auto& utdId : utdIds) {
|
||||
for (const auto &utdId : utdIds) {
|
||||
types.push_back(CommonUtils::Convert2MimeType(utdId));
|
||||
}
|
||||
return types;
|
||||
@ -185,7 +184,7 @@ std::string PasteboardUtils::Convert(UDType uDType)
|
||||
}
|
||||
}
|
||||
|
||||
UDType PasteboardUtils::Convert(int32_t uDType, const std::string& mimeType)
|
||||
UDType PasteboardUtils::Convert(int32_t uDType, const std::string &mimeType)
|
||||
{
|
||||
if (uDType != UDMF::UD_BUTT) {
|
||||
return static_cast<UDType>(uDType);
|
||||
@ -214,7 +213,7 @@ UDType PasteboardUtils::Convert(int32_t uDType, const std::string& mimeType)
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::PlainText2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto plainText = static_cast<UDMF::PlainText*>(record.get());
|
||||
auto plainText = static_cast<UDMF::PlainText *>(record.get());
|
||||
if (plainText == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get PLAIN_TEXT record failed.");
|
||||
return nullptr;
|
||||
@ -255,7 +254,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2PlaintText(const std
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Want2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto want = static_cast<UDMF::UnifiedRecord*>(record.get());
|
||||
auto want = static_cast<UDMF::UnifiedRecord *>(record.get());
|
||||
if (want == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get want record failed.");
|
||||
return nullptr;
|
||||
@ -287,7 +286,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Want(const std::shar
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Html2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto html = static_cast<UDMF::Html*>(record.get());
|
||||
auto html = static_cast<UDMF::Html *>(record.get());
|
||||
if (html == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get HTML record failed.");
|
||||
return nullptr;
|
||||
@ -328,7 +327,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Html(const std::shar
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Link2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto link = static_cast<UDMF::Link*>(record.get());
|
||||
auto link = static_cast<UDMF::Link *>(record.get());
|
||||
if (link == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get Link record failed.");
|
||||
return nullptr;
|
||||
@ -369,7 +368,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Link(const std::shar
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::File2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto file = static_cast<UDMF::File*>(record.get());
|
||||
auto file = static_cast<UDMF::File *>(record.get());
|
||||
if (file == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get file record failed.");
|
||||
return nullptr;
|
||||
@ -401,7 +400,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2File(const std::shar
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Image2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto image = static_cast<UDMF::Image*>(record.get());
|
||||
auto image = static_cast<UDMF::Image *>(record.get());
|
||||
if (image == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get image record failed.");
|
||||
return nullptr;
|
||||
@ -433,7 +432,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Image(const std::sha
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Video2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto video = static_cast<UDMF::Video*>(record.get());
|
||||
auto video = static_cast<UDMF::Video *>(record.get());
|
||||
if (video == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get video record failed.");
|
||||
return nullptr;
|
||||
@ -465,7 +464,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Video(const std::sha
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Audio2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto audio = static_cast<UDMF::Audio*>(record.get());
|
||||
auto audio = static_cast<UDMF::Audio *>(record.get());
|
||||
if (audio == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get audio record failed.");
|
||||
return nullptr;
|
||||
@ -497,7 +496,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Audio(const std::sha
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Folder2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto folder = static_cast<UDMF::Folder*>(record.get());
|
||||
auto folder = static_cast<UDMF::Folder *>(record.get());
|
||||
if (folder == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get folder record failed.");
|
||||
return nullptr;
|
||||
@ -529,7 +528,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Folder(const std::sh
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::PixelMap2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto pixelMap = static_cast<UDMF::SystemDefinedPixelMap*>(record.get());
|
||||
auto pixelMap = static_cast<UDMF::SystemDefinedPixelMap *>(record.get());
|
||||
if (pixelMap == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get pixelMap record failed.");
|
||||
return nullptr;
|
||||
@ -561,7 +560,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2PixelMap(const std::
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::AppItem2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto appItem = static_cast<UDMF::SystemDefinedAppItem*>(record.get());
|
||||
auto appItem = static_cast<UDMF::SystemDefinedAppItem *>(record.get());
|
||||
if (appItem == nullptr) {
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "get SystemDefinedAppItem record failed.");
|
||||
return nullptr;
|
||||
@ -605,7 +604,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2AppItem(const std::s
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Form2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto form = static_cast<UDMF::SystemDefinedForm*>(record.get());
|
||||
auto form = static_cast<UDMF::SystemDefinedForm *>(record.get());
|
||||
if (form == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get SystemDefinedForm record failed.");
|
||||
return nullptr;
|
||||
@ -635,7 +634,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2Form(const std::shar
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::SystemDefined2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto systemDefined = static_cast<UDMF::SystemDefinedRecord*>(record.get());
|
||||
auto systemDefined = static_cast<UDMF::SystemDefinedRecord *>(record.get());
|
||||
if (systemDefined == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get systemRecord record failed.");
|
||||
return nullptr;
|
||||
@ -661,7 +660,7 @@ std::shared_ptr<UnifiedRecord> PasteboardUtils::PasteRecord2SystemDefined(const
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::Text2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto text = static_cast<UDMF::Text*>(record.get());
|
||||
auto text = static_cast<UDMF::Text *>(record.get());
|
||||
if (text == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get TEXT record failed.");
|
||||
return nullptr;
|
||||
@ -698,7 +697,7 @@ std::vector<std::shared_ptr<UnifiedRecord>> PasteboardUtils::Custom2AppDefined(
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "customData is null");
|
||||
return unifiedRecords;
|
||||
}
|
||||
for (auto& [type, rawData] : customData->GetItemData()) {
|
||||
for (auto &[type, rawData] : customData->GetItemData()) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "app defied type:%{public}s.", type.c_str());
|
||||
unifiedRecords.push_back(std::make_shared<UDMF::ApplicationDefinedRecord>(type, rawData));
|
||||
}
|
||||
@ -707,7 +706,7 @@ std::vector<std::shared_ptr<UnifiedRecord>> PasteboardUtils::Custom2AppDefined(
|
||||
|
||||
std::shared_ptr<PasteDataRecord> PasteboardUtils::AppDefined2PasteRecord(const std::shared_ptr<UnifiedRecord> record)
|
||||
{
|
||||
auto appRecord = static_cast<UDMF::ApplicationDefinedRecord*>(record.get());
|
||||
auto appRecord = static_cast<UDMF::ApplicationDefinedRecord *>(record.get());
|
||||
if (appRecord == nullptr) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "get ApplicationDefinedRecord record failed.");
|
||||
return nullptr;
|
||||
@ -732,7 +731,7 @@ PasteboardUtils::PasteboardUtils()
|
||||
InitDecodeMap();
|
||||
}
|
||||
|
||||
PasteboardUtils& PasteboardUtils::GetInstance()
|
||||
PasteboardUtils &PasteboardUtils::GetInstance()
|
||||
{
|
||||
static PasteboardUtils instance;
|
||||
return instance;
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include "file_uri.h"
|
||||
#include "pasteboard_web_controller.h"
|
||||
|
||||
@ -27,7 +28,7 @@ constexpr uint32_t FOUR_BYTES = 4;
|
||||
constexpr uint32_t EIGHT_BIT = 8;
|
||||
|
||||
struct Cmp {
|
||||
bool operator()(const uint32_t& lhs, const uint32_t& rhs) const
|
||||
bool operator()(const uint32_t &lhs, const uint32_t &rhs) const
|
||||
{
|
||||
return lhs > rhs;
|
||||
}
|
||||
@ -38,7 +39,7 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
// static
|
||||
PasteboardWebController& PasteboardWebController::GetInstance()
|
||||
PasteboardWebController &PasteboardWebController::GetInstance()
|
||||
{
|
||||
static PasteboardWebController instance;
|
||||
return instance;
|
||||
@ -55,14 +56,13 @@ std::shared_ptr<PasteData> PasteboardWebController::SplitHtml(std::shared_ptr<st
|
||||
return pasteData;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> PasteboardWebController::RebuildHtml(
|
||||
std::shared_ptr<PasteData> pasteData) noexcept
|
||||
std::shared_ptr<std::string> PasteboardWebController::RebuildHtml(std::shared_ptr<PasteData> pasteData) noexcept
|
||||
{
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteDataRecords = pasteData->AllRecords();
|
||||
std::shared_ptr<std::string> htmlData;
|
||||
std::map<uint32_t, std::pair<std::string, std::string>, Cmp> replaceUris;
|
||||
|
||||
for (auto& item : pasteDataRecords) {
|
||||
for (auto &item : pasteDataRecords) {
|
||||
std::shared_ptr<std::string> html = item->GetHtmlText();
|
||||
if (html) {
|
||||
htmlData = html;
|
||||
@ -73,7 +73,7 @@ std::shared_ptr<std::string> PasteboardWebController::RebuildHtml(
|
||||
continue;
|
||||
}
|
||||
std::map<std::string, std::vector<uint8_t>> customItemData = customData->GetItemData();
|
||||
for (auto& itemData : customItemData) {
|
||||
for (auto &itemData : customItemData) {
|
||||
for (uint32_t i = 0; i < itemData.second.size(); i += FOUR_BYTES) {
|
||||
uint32_t offset = static_cast<uint32_t>(itemData.second[i]) |
|
||||
static_cast<uint32_t>(itemData.second[i + 1] << 8) |
|
||||
@ -85,7 +85,7 @@ std::shared_ptr<std::string> PasteboardWebController::RebuildHtml(
|
||||
}
|
||||
|
||||
RemoveAllRecord(pasteData);
|
||||
for (auto& replaceUri : replaceUris) {
|
||||
for (auto &replaceUri : replaceUris) {
|
||||
htmlData->replace(replaceUri.first, replaceUri.second.second.size(), replaceUri.second.first);
|
||||
}
|
||||
pasteData->AddHtmlRecord(*htmlData);
|
||||
@ -114,12 +114,12 @@ std::vector<std::pair<std::string, uint32_t>> PasteboardWebController::SplitHtml
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<uint8_t>> PasteboardWebController::SplitHtmlWithImgSrcLabel(
|
||||
const std::vector<std::pair<std::string, uint32_t>>& matchVec) noexcept
|
||||
const std::vector<std::pair<std::string, uint32_t>> &matchVec) noexcept
|
||||
{
|
||||
std::map<std::string, std::vector<uint8_t>> res;
|
||||
std::smatch match;
|
||||
std::regex re(IMG_TAG_SRC_PATTERN);
|
||||
for (auto& node : matchVec) {
|
||||
for (auto &node : matchVec) {
|
||||
std::string::const_iterator iterStart = node.first.begin();
|
||||
std::string::const_iterator iterEnd = node.first.end();
|
||||
|
||||
@ -142,11 +142,11 @@ std::map<std::string, std::vector<uint8_t>> PasteboardWebController::SplitHtmlWi
|
||||
}
|
||||
|
||||
std::shared_ptr<PasteData> PasteboardWebController::BuildPasteData(
|
||||
std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>>& imgSrcMap) noexcept
|
||||
std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>> &imgSrcMap) noexcept
|
||||
{
|
||||
std::shared_ptr<PasteData> pasteData = std::make_shared<PasteData>();
|
||||
pasteData->AddHtmlRecord(*html);
|
||||
for (auto& item : imgSrcMap) {
|
||||
for (auto &item : imgSrcMap) {
|
||||
PasteDataRecord::Builder builder(MiscServices::MIMETYPE_TEXT_URI);
|
||||
auto uri = std::make_shared<OHOS::Uri>(item.first);
|
||||
builder.SetUri(uri);
|
||||
@ -170,7 +170,7 @@ void PasteboardWebController::RemoveAllRecord(std::shared_ptr<PasteData> pasteDa
|
||||
}
|
||||
}
|
||||
|
||||
bool PasteboardWebController::IsLocalURI(std::string& uri) noexcept
|
||||
bool PasteboardWebController::IsLocalURI(std::string &uri) noexcept
|
||||
{
|
||||
return uri.substr(0, IMG_LOCAL_URI.size()) == IMG_LOCAL_URI || uri.find(IMG_LOCAL_PATH) == std::string::npos;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define DISTRIBUTED_PASTEBOARD_FRAMEWORK_DISTRIBUTED_CLIP_H
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
||||
#include "device/dm_adapter.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
@ -27,16 +28,10 @@ public:
|
||||
void OnReady(const std::string &device) override;
|
||||
};
|
||||
|
||||
void DistributedClip::Online(const std::string &device)
|
||||
{
|
||||
}
|
||||
void DistributedClip::Online(const std::string &device) {}
|
||||
|
||||
void DistributedClip::Offline(const std::string &device)
|
||||
{
|
||||
}
|
||||
void DistributedClip::Offline(const std::string &device) {}
|
||||
|
||||
void DistributedClip::OnReady(const std::string &device)
|
||||
{
|
||||
}
|
||||
void DistributedClip::OnReady(const std::string &device) {}
|
||||
} // namespace OHOS::MiscServices
|
||||
#endif // DISTRIBUTED_PASTEBOARD_FRAMEWORK_DISTRIBUTED_CLIP_H
|
||||
|
@ -13,12 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "convert_utils.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <paste_data.h>
|
||||
#include <unified_data.h>
|
||||
|
||||
#include "convert_utils.h"
|
||||
#include "paste_data_entry.h"
|
||||
#include "tlv_object.h"
|
||||
#include "unified_meta.h"
|
||||
@ -45,7 +44,7 @@ protected:
|
||||
std::vector<uint8_t> rawData1_ = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
std::vector<uint8_t> rawData2_ = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
void CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>>& entries);
|
||||
void CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>> &entries);
|
||||
void CheckPlainUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckFileUriUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckPixelMapUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
@ -53,23 +52,23 @@ protected:
|
||||
void CheckLinkUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckCustomEntry(const std::shared_ptr<PasteDataEntry> entry);
|
||||
|
||||
void InitDataWithEntries(UDMF::UnifiedData& data);
|
||||
void InitDataWithPlainEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWithHtmlEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWithFileUriEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWithPixelMapEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWitCustomEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWitSameCustomEntry(UDMF::UnifiedData& data);
|
||||
void InitDataWithEntries(UDMF::UnifiedData &data);
|
||||
void InitDataWithPlainEntry(UDMF::UnifiedData &data);
|
||||
void InitDataWithHtmlEntry(UDMF::UnifiedData &data);
|
||||
void InitDataWithFileUriEntry(UDMF::UnifiedData &data);
|
||||
void InitDataWithPixelMapEntry(UDMF::UnifiedData &data);
|
||||
void InitDataWitCustomEntry(UDMF::UnifiedData &data);
|
||||
void InitDataWitSameCustomEntry(UDMF::UnifiedData &data);
|
||||
|
||||
void AddPlainUdsEntry(UDMF::UnifiedRecord& record);
|
||||
void AddFileUriUdsEntry(UDMF::UnifiedRecord& record);
|
||||
void AddHtmlUdsEntry(UDMF::UnifiedRecord& record);
|
||||
void AddPixelMapUdsEntry(UDMF::UnifiedRecord& record);
|
||||
void AddLinkUdsEntry(UDMF::UnifiedRecord& record);
|
||||
void AddCustomEntry(UDMF::UnifiedRecord& record);
|
||||
void AddCustomEntries(UDMF::UnifiedRecord& record);
|
||||
void AddPlainUdsEntry(UDMF::UnifiedRecord &record);
|
||||
void AddFileUriUdsEntry(UDMF::UnifiedRecord &record);
|
||||
void AddHtmlUdsEntry(UDMF::UnifiedRecord &record);
|
||||
void AddPixelMapUdsEntry(UDMF::UnifiedRecord &record);
|
||||
void AddLinkUdsEntry(UDMF::UnifiedRecord &record);
|
||||
void AddCustomEntry(UDMF::UnifiedRecord &record);
|
||||
void AddCustomEntries(UDMF::UnifiedRecord &record);
|
||||
|
||||
static PasteData TlvData(const std::shared_ptr<PasteData>& data);
|
||||
static PasteData TlvData(const std::shared_ptr<PasteData> &data);
|
||||
};
|
||||
|
||||
void ConvertUtilsTest::SetUpTestCase(void) {}
|
||||
@ -80,7 +79,7 @@ void ConvertUtilsTest::SetUp(void) {}
|
||||
|
||||
void ConvertUtilsTest::TearDown(void) {}
|
||||
|
||||
PasteData ConvertUtilsTest::TlvData(const std::shared_ptr<PasteData>& data)
|
||||
PasteData ConvertUtilsTest::TlvData(const std::shared_ptr<PasteData> &data)
|
||||
{
|
||||
std::vector<std::uint8_t> buffer;
|
||||
data->Init(buffer);
|
||||
@ -90,7 +89,7 @@ PasteData ConvertUtilsTest::TlvData(const std::shared_ptr<PasteData>& data)
|
||||
return decodePasteData;
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddPlainUdsEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddPlainUdsEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
Object plainUds;
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT);
|
||||
@ -99,7 +98,7 @@ void ConvertUtilsTest::AddPlainUdsEntry(UDMF::UnifiedRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<Object>(plainUds));
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddFileUriUdsEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddFileUriUdsEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
Object fileUriobject;
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::FILE_URI);
|
||||
@ -109,7 +108,7 @@ void ConvertUtilsTest::AddFileUriUdsEntry(UDMF::UnifiedRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<Object>(fileUriobject));
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddHtmlUdsEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddHtmlUdsEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HTML);
|
||||
Object htmlobject;
|
||||
@ -118,7 +117,7 @@ void ConvertUtilsTest::AddHtmlUdsEntry(UDMF::UnifiedRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<Object>(htmlobject));
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddLinkUdsEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddLinkUdsEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HYPERLINK);
|
||||
Object linkObject;
|
||||
@ -127,18 +126,18 @@ void ConvertUtilsTest::AddLinkUdsEntry(UDMF::UnifiedRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<Object>(linkObject));
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddCustomEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddCustomEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
record.AddEntry(appUtdId1_, rawData1_);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddCustomEntries(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddCustomEntries(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
record.AddEntry(appUtdId1_, rawData1_);
|
||||
record.AddEntry(appUtdId2_, rawData2_);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::AddPixelMapUdsEntry(UDMF::UnifiedRecord& record)
|
||||
void ConvertUtilsTest::AddPixelMapUdsEntry(UDMF::UnifiedRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::SYSTEM_DEFINED_PIXEL_MAP);
|
||||
Object object;
|
||||
@ -151,7 +150,7 @@ void ConvertUtilsTest::AddPixelMapUdsEntry(UDMF::UnifiedRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<Object>(object));
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWithPlainEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWithPlainEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddPlainUdsEntry(*record);
|
||||
@ -162,7 +161,7 @@ void ConvertUtilsTest::InitDataWithPlainEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWithHtmlEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWithHtmlEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddHtmlUdsEntry(*record);
|
||||
@ -173,7 +172,7 @@ void ConvertUtilsTest::InitDataWithHtmlEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWithFileUriEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWithFileUriEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddFileUriUdsEntry(*record);
|
||||
@ -184,7 +183,7 @@ void ConvertUtilsTest::InitDataWithFileUriEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWithPixelMapEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWithPixelMapEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddPixelMapUdsEntry(*record);
|
||||
@ -195,7 +194,7 @@ void ConvertUtilsTest::InitDataWithPixelMapEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWitCustomEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWitCustomEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddCustomEntry(*record);
|
||||
@ -206,7 +205,7 @@ void ConvertUtilsTest::InitDataWitCustomEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWitSameCustomEntry(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWitSameCustomEntry(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddCustomEntry(*record);
|
||||
@ -218,7 +217,7 @@ void ConvertUtilsTest::InitDataWitSameCustomEntry(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, entriesSize);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::InitDataWithEntries(UDMF::UnifiedData& data)
|
||||
void ConvertUtilsTest::InitDataWithEntries(UDMF::UnifiedData &data)
|
||||
{
|
||||
std::shared_ptr<UDMF::UnifiedRecord> record = std::make_shared<UDMF::UnifiedRecord>();
|
||||
AddPlainUdsEntry(*record);
|
||||
@ -233,9 +232,9 @@ void ConvertUtilsTest::InitDataWithEntries(UDMF::UnifiedData& data)
|
||||
ASSERT_EQ(1, size);
|
||||
}
|
||||
|
||||
void ConvertUtilsTest::CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>>& entries)
|
||||
void ConvertUtilsTest::CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>> &entries)
|
||||
{
|
||||
for (auto const& entry : entries) {
|
||||
for (auto const &entry : entries) {
|
||||
if (entry->GetUtdId() == UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT)) {
|
||||
CheckPlainUds(entry);
|
||||
} else if (entry->GetUtdId() == UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::FILE_URI)) {
|
||||
|
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "device/dm_adapter.h"
|
||||
#include "distributed_clip.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "pasteboard_error.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
@ -28,21 +29,13 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void DMAdapterTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::SetUpTestCase(void) {}
|
||||
|
||||
void DMAdapterTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::TearDownTestCase(void) {}
|
||||
|
||||
void DMAdapterTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::SetUp(void) {}
|
||||
|
||||
void DMAdapterTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void DMAdapterTest::TearDown(void) {}
|
||||
|
||||
/**
|
||||
* @tc.name: GetLocalDeviceUdid
|
||||
@ -138,4 +131,4 @@ HWTEST_F(DMAdapterTest, IsSameAccount, TestSize.Level0)
|
||||
bool ret = DMAdapter::GetInstance().IsSameAccount(networkId);
|
||||
ASSERT_FALSE(ret);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::MiscServices
|
||||
|
@ -13,10 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "eventcenter/event_center.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "eventcenter/event_center.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
using namespace testing;
|
||||
@ -30,15 +31,15 @@ public:
|
||||
};
|
||||
class TestBegin : public Event {
|
||||
public:
|
||||
TestBegin(): Event(TEST_EVT_BEGIN) {};
|
||||
TestBegin() : Event(TEST_EVT_BEGIN){};
|
||||
};
|
||||
class TestMiddle : public Event {
|
||||
public:
|
||||
TestMiddle(): Event(TEST_EVT_MIDDLE) {};
|
||||
TestMiddle() : Event(TEST_EVT_MIDDLE){};
|
||||
};
|
||||
class TestEnd : public Event {
|
||||
public:
|
||||
TestEnd(): Event(TEST_EVT_END) {};
|
||||
TestEnd() : Event(TEST_EVT_END){};
|
||||
};
|
||||
static void SetUpTestCase(void) {}
|
||||
static void TearDownTestCase(void) {}
|
||||
@ -135,7 +136,6 @@ HWTEST_F(EventCenterTest, ASyncEventWithoutDefer, TestSize.Level2)
|
||||
ASSERT_EQ(waitEvent_, TEST_EVT_BEGIN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: ImmediatelyASyncEvent
|
||||
* @tc.desc: post the async event, there is top layer and no defer; we will dispatch the async event Immediately.
|
||||
|
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ffrt_utils.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "ffrt_utils.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
using namespace testing;
|
||||
@ -28,21 +29,13 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void FFRTTimerTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void FFRTTimerTest::SetUpTestCase(void) {}
|
||||
|
||||
void FFRTTimerTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void FFRTTimerTest::TearDownTestCase(void) {}
|
||||
|
||||
void FFRTTimerTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void FFRTTimerTest::SetUp(void) {}
|
||||
|
||||
void FFRTTimerTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void FFRTTimerTest::TearDown(void) {}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTimerTest001
|
||||
|
@ -13,8 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "convert_utils.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "convert_utils.h"
|
||||
#include "unified_meta.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
@ -57,7 +58,7 @@ PasteDataEntry PasteDataEntryTest::InitPlaintTextEntry()
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT);
|
||||
udsObject->value_[UDMF::UNIFORM_DATA_TYPE] = utdId;
|
||||
udsObject->value_[UDMF::CONTENT] = text_;
|
||||
return {utdId, udsObject};
|
||||
return { utdId, udsObject };
|
||||
}
|
||||
|
||||
PasteDataEntry PasteDataEntryTest::InitUriEntry()
|
||||
@ -67,7 +68,7 @@ PasteDataEntry PasteDataEntryTest::InitUriEntry()
|
||||
udsObject->value_[UDMF::UNIFORM_DATA_TYPE] = utdId;
|
||||
udsObject->value_[UDMF::FILE_URI_PARAM] = uri_;
|
||||
udsObject->value_[UDMF::FILE_TYPE] = "";
|
||||
return {utdId, udsObject};
|
||||
return { utdId, udsObject };
|
||||
}
|
||||
|
||||
PasteDataEntry PasteDataEntryTest::InitWantEntry()
|
||||
@ -79,7 +80,7 @@ PasteDataEntry PasteDataEntryTest::InitWantEntry()
|
||||
int32_t idValue = 123;
|
||||
std::string deviceKey = "deviceId_key";
|
||||
want->SetParam(idKey, idValue);
|
||||
return {utdId, want};
|
||||
return { utdId, want };
|
||||
}
|
||||
|
||||
PasteDataEntry PasteDataEntryTest::InitHtmlEntry()
|
||||
@ -88,7 +89,7 @@ PasteDataEntry PasteDataEntryTest::InitHtmlEntry()
|
||||
auto udsObject = std::make_shared<Object>();
|
||||
udsObject->value_[UDMF::UNIFORM_DATA_TYPE] = utdId;
|
||||
udsObject->value_[UDMF::HTML_CONTENT] = html_;
|
||||
return {utdId, udsObject};
|
||||
return { utdId, udsObject };
|
||||
}
|
||||
|
||||
PasteDataEntry PasteDataEntryTest::InitPixelMapEntry()
|
||||
@ -101,10 +102,9 @@ PasteDataEntry PasteDataEntryTest::InitPixelMapEntry()
|
||||
std::unique_ptr<PixelMap> pixelMap = PixelMap::Create(color, sizeof(color) / sizeof(color[0]), opts);
|
||||
std::shared_ptr<PixelMap> pixelMapIn = move(pixelMap);
|
||||
udsObject->value_[UDMF::PIXEL_MAP] = pixelMapIn;
|
||||
return {utdId, udsObject};
|
||||
return { utdId, udsObject };
|
||||
}
|
||||
|
||||
|
||||
void PasteDataEntryTest::CheckPlainUds(const std::shared_ptr<PasteDataEntry> entry)
|
||||
{
|
||||
ASSERT_NE(entry, nullptr);
|
||||
|
@ -13,10 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "paste_data_record.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "paste_data_record.h"
|
||||
#include "tlv_object.h"
|
||||
#include "unified_meta.h"
|
||||
|
||||
@ -42,18 +41,18 @@ protected:
|
||||
int32_t width_ = 5;
|
||||
int32_t height_ = 7;
|
||||
|
||||
void CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>>& entries);
|
||||
void CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>> &entries);
|
||||
void CheckPlainUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckFileUriUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckPixelMapUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckHtmlUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
void CheckLinkUds(const std::shared_ptr<PasteDataEntry> entry);
|
||||
|
||||
void AddPlainUdsEntry(PasteDataRecord& record);
|
||||
void AddFileUriUdsEntry(PasteDataRecord& record);
|
||||
void AddHtmlUdsEntry(PasteDataRecord& record);
|
||||
void AddPixelMapUdsEntry(PasteDataRecord& record);
|
||||
void AddLinkUdsEntry(PasteDataRecord& record);
|
||||
void AddPlainUdsEntry(PasteDataRecord &record);
|
||||
void AddFileUriUdsEntry(PasteDataRecord &record);
|
||||
void AddHtmlUdsEntry(PasteDataRecord &record);
|
||||
void AddPixelMapUdsEntry(PasteDataRecord &record);
|
||||
void AddLinkUdsEntry(PasteDataRecord &record);
|
||||
};
|
||||
|
||||
void PasteDataRecordTest::SetUpTestCase(void) {}
|
||||
@ -72,7 +71,7 @@ void PasteDataRecordTest::SetUp(void)
|
||||
|
||||
void PasteDataRecordTest::TearDown(void) {}
|
||||
|
||||
void PasteDataRecordTest::AddPlainUdsEntry(PasteDataRecord& record)
|
||||
void PasteDataRecordTest::AddPlainUdsEntry(PasteDataRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT);
|
||||
auto object = std::make_shared<Object>();
|
||||
@ -81,7 +80,7 @@ void PasteDataRecordTest::AddPlainUdsEntry(PasteDataRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<PasteDataEntry>(utdId, object));
|
||||
}
|
||||
|
||||
void PasteDataRecordTest::AddFileUriUdsEntry(PasteDataRecord& record)
|
||||
void PasteDataRecordTest::AddFileUriUdsEntry(PasteDataRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::FILE_URI);
|
||||
auto object = std::make_shared<Object>();
|
||||
@ -91,7 +90,7 @@ void PasteDataRecordTest::AddFileUriUdsEntry(PasteDataRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<PasteDataEntry>(utdId, object));
|
||||
}
|
||||
|
||||
void PasteDataRecordTest::AddHtmlUdsEntry(PasteDataRecord& record)
|
||||
void PasteDataRecordTest::AddHtmlUdsEntry(PasteDataRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HTML);
|
||||
auto object = std::make_shared<Object>();
|
||||
@ -100,7 +99,7 @@ void PasteDataRecordTest::AddHtmlUdsEntry(PasteDataRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<PasteDataEntry>(utdId, object));
|
||||
}
|
||||
|
||||
void PasteDataRecordTest::AddLinkUdsEntry(PasteDataRecord& record)
|
||||
void PasteDataRecordTest::AddLinkUdsEntry(PasteDataRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HYPERLINK);
|
||||
auto object = std::make_shared<Object>();
|
||||
@ -109,7 +108,7 @@ void PasteDataRecordTest::AddLinkUdsEntry(PasteDataRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<PasteDataEntry>(utdId, object));
|
||||
}
|
||||
|
||||
void PasteDataRecordTest::AddPixelMapUdsEntry(PasteDataRecord& record)
|
||||
void PasteDataRecordTest::AddPixelMapUdsEntry(PasteDataRecord &record)
|
||||
{
|
||||
auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::SYSTEM_DEFINED_PIXEL_MAP);
|
||||
auto object = std::make_shared<Object>();
|
||||
@ -122,9 +121,9 @@ void PasteDataRecordTest::AddPixelMapUdsEntry(PasteDataRecord& record)
|
||||
record.AddEntry(utdId, std::make_shared<PasteDataEntry>(utdId, object));
|
||||
}
|
||||
|
||||
void PasteDataRecordTest::CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>>& entries)
|
||||
void PasteDataRecordTest::CheckEntries(const std::vector<std::shared_ptr<PasteDataEntry>> &entries)
|
||||
{
|
||||
for (auto const& entry : entries) {
|
||||
for (auto const &entry : entries) {
|
||||
if (entry->GetUtdId() == UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT)) {
|
||||
CheckPlainUds(entry);
|
||||
}
|
||||
|
@ -13,17 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <cstdio>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "copy_uri_handler.h"
|
||||
#include "common/block_object.h"
|
||||
#include "clip/clip_plugin.h"
|
||||
#include "clip_factory.h"
|
||||
#include "common/block_object.h"
|
||||
#include "copy_uri_handler.h"
|
||||
#include "int_wrapper.h"
|
||||
#include "paste_uri_handler.h"
|
||||
#include "pasteboard_client.h"
|
||||
#include "remote_file_share.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
@ -40,21 +40,13 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void PasteDataTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void PasteDataTest::SetUpTestCase(void) {}
|
||||
|
||||
void PasteDataTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void PasteDataTest::TearDownTestCase(void) {}
|
||||
|
||||
void PasteDataTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void PasteDataTest::SetUp(void) {}
|
||||
|
||||
void PasteDataTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void PasteDataTest::TearDown(void) {}
|
||||
|
||||
ClipFactory::ClipFactory()
|
||||
{
|
||||
@ -345,8 +337,7 @@ HWTEST_F(PasteDataTest, MaxLength001, TestSize.Level0)
|
||||
int maxLength = 20 * 1024 * 1024;
|
||||
std::string res = "hello";
|
||||
std::string temp = "world";
|
||||
for (int i = 0; i < maxLength; i++)
|
||||
{
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
res += temp;
|
||||
}
|
||||
std::string htmlText = "<div class='disabled'>" + res + "</div>";
|
||||
@ -366,8 +357,7 @@ HWTEST_F(PasteDataTest, MaxLength002, TestSize.Level0)
|
||||
int maxLength = 20 * 1024 * 1024;
|
||||
std::string plainText = "hello";
|
||||
std::string temp = "world";
|
||||
for (int i = 0; i < maxLength; i++)
|
||||
{
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
plainText += temp;
|
||||
}
|
||||
auto record = PasteboardClient::GetInstance()->CreatePlainTextRecord(plainText);
|
||||
@ -491,7 +481,7 @@ HWTEST_F(PasteDataTest, GetPasteDataMsg002, TestSize.Level0)
|
||||
ASSERT_TRUE(primaryUri == nullptr);
|
||||
auto record = newPasteData->GetRecordAt(1);
|
||||
ASSERT_TRUE(record == nullptr);
|
||||
auto res1 = newPasteData->RemoveRecordAt(1);
|
||||
auto res1 = newPasteData->RemoveRecordAt(1);
|
||||
ASSERT_FALSE(res1);
|
||||
std::string mimeType = "text/plain";
|
||||
ASSERT_FALSE(newPasteData->HasMimeType(mimeType));
|
||||
|
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "pasteboard_client.h"
|
||||
#include "unistd.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
@ -41,13 +42,9 @@ void PasteboardClientTest::TearDownTestCase(void)
|
||||
setuid(0);
|
||||
}
|
||||
|
||||
void PasteboardClientTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void PasteboardClientTest::SetUp(void) {}
|
||||
|
||||
void PasteboardClientTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void PasteboardClientTest::TearDown(void) {}
|
||||
|
||||
/**
|
||||
* @tc.name: IsRemoteData001
|
||||
@ -183,24 +180,21 @@ HWTEST_F(PasteboardClientTest, GetDataSource001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PasteboardClientTest, SetGlobalShareOption, TestSize.Level0)
|
||||
{
|
||||
std::map<uint32_t, ShareOption> settings = {
|
||||
{100, ShareOption::InApp},
|
||||
{200, ShareOption::LocalDevice},
|
||||
{300, ShareOption::CrossDevice}};
|
||||
std::map<uint32_t, ShareOption> settings = { { 100, ShareOption::InApp }, { 200, ShareOption::LocalDevice },
|
||||
{ 300, ShareOption::CrossDevice } };
|
||||
PasteboardClient::GetInstance()->SetGlobalShareOption(settings);
|
||||
auto result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 3);
|
||||
EXPECT_EQ(result[100], ShareOption::InApp);
|
||||
EXPECT_EQ(result[200], ShareOption::LocalDevice);
|
||||
EXPECT_EQ(result[300], ShareOption::CrossDevice);
|
||||
std::map<uint32_t, ShareOption> modify = {{100, ShareOption::CrossDevice},
|
||||
{400, ShareOption::InApp}};
|
||||
std::map<uint32_t, ShareOption> modify = { { 100, ShareOption::CrossDevice }, { 400, ShareOption::InApp } };
|
||||
PasteboardClient::GetInstance()->SetGlobalShareOption(modify);
|
||||
result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 4);
|
||||
EXPECT_EQ(result[100], ShareOption::CrossDevice);
|
||||
EXPECT_EQ(result[400], ShareOption::InApp);
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({100, 200, 300, 400});
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({ 100, 200, 300, 400 });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,21 +206,19 @@ HWTEST_F(PasteboardClientTest, SetGlobalShareOption, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PasteboardClientTest, GetGlobalShareOption, TestSize.Level0)
|
||||
{
|
||||
std::map<uint32_t, ShareOption> settings = {
|
||||
{100, ShareOption::InApp},
|
||||
{200, ShareOption::LocalDevice},
|
||||
{300, ShareOption::CrossDevice}};
|
||||
std::map<uint32_t, ShareOption> settings = { { 100, ShareOption::InApp }, { 200, ShareOption::LocalDevice },
|
||||
{ 300, ShareOption::CrossDevice } };
|
||||
PasteboardClient::GetInstance()->SetGlobalShareOption(settings);
|
||||
auto result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 3);
|
||||
EXPECT_EQ(result[100], ShareOption::InApp);
|
||||
EXPECT_EQ(result[200], ShareOption::LocalDevice);
|
||||
EXPECT_EQ(result[300], ShareOption::CrossDevice);
|
||||
result = PasteboardClient::GetInstance()->GetGlobalShareOption({100, 400});
|
||||
result = PasteboardClient::GetInstance()->GetGlobalShareOption({ 100, 400 });
|
||||
EXPECT_TRUE(result.size() == 1);
|
||||
EXPECT_EQ(result[100], ShareOption::InApp);
|
||||
EXPECT_TRUE(result.find(400) == result.end());
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({100, 200, 300});
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({ 100, 200, 300 });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,10 +230,8 @@ HWTEST_F(PasteboardClientTest, GetGlobalShareOption, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PasteboardClientTest, RemoveGlobalShareOption, TestSize.Level0)
|
||||
{
|
||||
std::map<uint32_t, ShareOption> settings = {
|
||||
{100, ShareOption::InApp},
|
||||
{200, ShareOption::LocalDevice},
|
||||
{300, ShareOption::CrossDevice}};
|
||||
std::map<uint32_t, ShareOption> settings = { { 100, ShareOption::InApp }, { 200, ShareOption::LocalDevice },
|
||||
{ 300, ShareOption::CrossDevice } };
|
||||
PasteboardClient::GetInstance()->SetGlobalShareOption(settings);
|
||||
auto result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 3);
|
||||
@ -251,11 +241,11 @@ HWTEST_F(PasteboardClientTest, RemoveGlobalShareOption, TestSize.Level0)
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({});
|
||||
result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 3);
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({100, 400});
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({ 100, 400 });
|
||||
result = PasteboardClient::GetInstance()->GetGlobalShareOption({});
|
||||
EXPECT_TRUE(result.size() == 2);
|
||||
EXPECT_TRUE(result.find(100) == result.end());
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({200, 300});
|
||||
PasteboardClient::GetInstance()->RemoveGlobalShareOption({ 200, 300 });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,39 +258,26 @@ HWTEST_F(PasteboardClientTest, RemoveGlobalShareOption, TestSize.Level0)
|
||||
HWTEST_F(PasteboardClientTest, DetectPatterns001, TestSize.Level0)
|
||||
{
|
||||
std::string plainText("r法塔赫已经,速tdghf!】qd rqdswww.comsski,.sjopwe"
|
||||
"ihhtpsdhttp我也带过去给他№のjioijhhu");
|
||||
"ihhtpsdhttp我也带过去给他№のjioijhhu");
|
||||
std::string plainText0("https://giedqwrtheeeeeefub.cerm/meeeelkove/obaklo_tjokl"
|
||||
"psetkjdttk/bkkjob/mwjweww.md)");
|
||||
"psetkjdttk/bkkjob/mwjweww.md)");
|
||||
std::string plainText1("2我就破888芙蓉王82h7");
|
||||
std::string plainText2("uhiyqydueuw@kahqw.oisko.sji");
|
||||
|
||||
std::vector<std::string> plainTextVec{
|
||||
plainText, plainText+plainText0, plainText+plainText1, plainText+plainText2,
|
||||
plainText+plainText0+plainText1, plainText0+plainText2+plainText, plainText1+plainText+plainText2,
|
||||
plainText0+plainText1+plainText+plainText2
|
||||
};
|
||||
std::vector<Patterns> patternsVec{
|
||||
{}, {Pattern::URL}, {Pattern::Number}, {Pattern::EmailAddress},
|
||||
{Pattern::URL, Pattern::Number}, {Pattern::URL, Pattern::EmailAddress},
|
||||
{Pattern::Number, Pattern::EmailAddress}, {Pattern::URL, Pattern::Number, Pattern::EmailAddress}
|
||||
};
|
||||
std::vector<std::vector<int>> patternsRightIndexVec{
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 1, 0, 0, 1, 1, 0, 1},
|
||||
{0, 0, 2, 0, 2, 0, 2, 2},
|
||||
{0, 0, 0, 3, 0, 3, 3, 3},
|
||||
{0, 1, 2, 0, 4, 1, 2, 4},
|
||||
{0, 1, 0, 3, 1, 5, 3, 5},
|
||||
{0, 0, 2, 3, 2, 3, 6, 6},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
};
|
||||
std::vector<std::string> plainTextVec{ plainText, plainText + plainText0, plainText + plainText1,
|
||||
plainText + plainText2, plainText + plainText0 + plainText1, plainText0 + plainText2 + plainText,
|
||||
plainText1 + plainText + plainText2, plainText0 + plainText1 + plainText + plainText2 };
|
||||
std::vector<Patterns> patternsVec{ {}, { Pattern::URL }, { Pattern::Number }, { Pattern::EmailAddress },
|
||||
{ Pattern::URL, Pattern::Number }, { Pattern::URL, Pattern::EmailAddress },
|
||||
{ Pattern::Number, Pattern::EmailAddress }, { Pattern::URL, Pattern::Number, Pattern::EmailAddress } };
|
||||
std::vector<std::vector<int>> patternsRightIndexVec{ { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 1, 1, 0, 1 },
|
||||
{ 0, 0, 2, 0, 2, 0, 2, 2 }, { 0, 0, 0, 3, 0, 3, 3, 3 }, { 0, 1, 2, 0, 4, 1, 2, 4 }, { 0, 1, 0, 3, 1, 5, 3, 5 },
|
||||
{ 0, 0, 2, 3, 2, 3, 6, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 } };
|
||||
for (int i = 0; i != 8; ++i) {
|
||||
for (int j = 0; j != 8; ++j) {
|
||||
auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(
|
||||
plainTextVec[i]);
|
||||
auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainTextVec[i]);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData);
|
||||
auto ret = PasteboardClient::GetInstance()->DetectPatterns(
|
||||
patternsVec[j]);
|
||||
auto ret = PasteboardClient::GetInstance()->DetectPatterns(patternsVec[j]);
|
||||
int rightIndex = patternsRightIndexVec[i][j];
|
||||
ASSERT_EQ(ret, patternsVec[rightIndex]);
|
||||
}
|
||||
@ -317,25 +294,26 @@ HWTEST_F(PasteboardClientTest, DetectPatterns001, TestSize.Level0)
|
||||
HWTEST_F(PasteboardClientTest, DetectPatterns002, TestSize.Level0)
|
||||
{
|
||||
std::string htmlText1 = "<!DOCTYPE html><html><head><title>"
|
||||
"超链案头研究。,封为啊啊</title></head><body><h2>发高热</h2>"
|
||||
"<p>隔热隔热的氛围<a href=\"https://exq23amwerwqple.com\">"
|
||||
"个人网站https://ex24t33tamp65hhle.com</a>。</p></body></html>";
|
||||
"超链案头研究。,封为啊啊</title></head><body><h2>发高热</h2>"
|
||||
"<p>隔热隔热的氛围<a href=\"https://exq23amwerwqple.com\">"
|
||||
"个人网站https://ex24t33tamp65hhle.com</a>。</p></body></html>";
|
||||
auto newData1 = PasteboardClient::GetInstance()->CreateHtmlData(htmlText1);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData1);
|
||||
Patterns patternsToCheck1{Pattern::URL, Pattern::EmailAddress};
|
||||
Patterns patternsToCheck1{ Pattern::URL, Pattern::EmailAddress };
|
||||
auto ret1 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck1);
|
||||
Patterns expected1{Pattern::URL};
|
||||
Patterns expected1{ Pattern::URL };
|
||||
ASSERT_EQ(ret1, expected1);
|
||||
|
||||
std::string htmlText2 = "<!DOCTYPE html><html><head><title>"
|
||||
"各个环节</title></head><body><h2>妈妈那边的</h2>"
|
||||
"<p>啊啊分,凤凰方法,环境https://examjjuyewple.com问我的<a href=\"https://ehhgxametgeple.com\">"
|
||||
"阿婆吗weqkqo@exaetmple.com</a>。????打法</p></body></html>";
|
||||
"各个环节</title></head><body><h2>妈妈那边的</h2>"
|
||||
"<p>啊啊分,凤凰方法,环境https://examjjuyewple.com问我的<a "
|
||||
"href=\"https://ehhgxametgeple.com\">"
|
||||
"阿婆吗weqkqo@exaetmple.com</a>。????打法</p></body></html>";
|
||||
auto newData2 = PasteboardClient::GetInstance()->CreateHtmlData(htmlText2);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData2);
|
||||
Patterns patternsToCheck2{Pattern::URL, Pattern::EmailAddress, Pattern::Number};
|
||||
Patterns patternsToCheck2{ Pattern::URL, Pattern::EmailAddress, Pattern::Number };
|
||||
auto ret2 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck2);
|
||||
Patterns expected2{Pattern::URL, Pattern::EmailAddress};
|
||||
Patterns expected2{ Pattern::URL, Pattern::EmailAddress };
|
||||
ASSERT_EQ(ret2, expected2);
|
||||
}
|
||||
|
||||
@ -349,28 +327,28 @@ HWTEST_F(PasteboardClientTest, DetectPatterns002, TestSize.Level0)
|
||||
HWTEST_F(PasteboardClientTest, DetectPatterns003, TestSize.Level0)
|
||||
{
|
||||
std::string plainText1 = "部分人的十点半:\n"
|
||||
"「而飞过海」\n"
|
||||
"方法:\n"
|
||||
"https://pr5yyye-drseyive.u54yk.cwerfe/s/42e1ewed77f3dab4"
|
||||
"网gest加尔文iqru发的我ui哦计划任务i文化人:\n"
|
||||
"~b0043fg3423tddj~";
|
||||
"「而飞过海」\n"
|
||||
"方法:\n"
|
||||
"https://pr5yyye-drseyive.u54yk.cwerfe/s/42e1ewed77f3dab4"
|
||||
"网gest加尔文iqru发的我ui哦计划任务i文化人:\n"
|
||||
"~b0043fg3423tddj~";
|
||||
auto newData1 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText1);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData1);
|
||||
Patterns patternsToCheck{
|
||||
Pattern::Number, Pattern::URL, Pattern::EmailAddress, static_cast<Pattern>(1023)};
|
||||
Patterns patternsToCheck{ Pattern::Number, Pattern::URL, Pattern::EmailAddress, static_cast<Pattern>(1023) };
|
||||
auto ret1 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
Patterns expected1{};
|
||||
ASSERT_EQ(ret1, expected1);
|
||||
std::string plainText2 = "【撒迪化,等我i却很难,无穷花的!】"
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg"
|
||||
"(¥¥软骨素用人员为bdfdgse https://tgrthwerrwt.com/marrkerrerlorrve/ usrdq12_22swe@16rtgre3.com)";
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg"
|
||||
"(¥¥软骨素用人员为bdfdgse https://tgrthwerrwt.com/marrkerrerlorrve/ "
|
||||
"usrdq12_22swe@16rtgre3.com)";
|
||||
auto newData2 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText2);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData2);
|
||||
auto ret2 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
Patterns expected2{};
|
||||
ASSERT_EQ(ret2, expected2);
|
||||
std::string plainText3 = "【撒迪化,等我i却很难,无穷花的!】"
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg";
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg";
|
||||
auto newData3 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText3);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData3);
|
||||
auto ret3 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
@ -387,29 +365,29 @@ HWTEST_F(PasteboardClientTest, DetectPatterns003, TestSize.Level0)
|
||||
HWTEST_F(PasteboardClientTest, DetectPatterns004, TestSize.Level0)
|
||||
{
|
||||
std::string plainText1 = "部分人的十点半:\n"
|
||||
"「而飞过海」\n"
|
||||
"方法:\n"
|
||||
"https://pr5yyye-drseyive.u54yk.cwerfe/s/42e1ewed77f3dab4"
|
||||
"网gest加尔文iqru发的我ui哦计划任务i文化人:\n"
|
||||
"~b0043fg3423tddj~";
|
||||
"「而飞过海」\n"
|
||||
"方法:\n"
|
||||
"https://pr5yyye-drseyive.u54yk.cwerfe/s/42e1ewed77f3dab4"
|
||||
"网gest加尔文iqru发的我ui哦计划任务i文化人:\n"
|
||||
"~b0043fg3423tddj~";
|
||||
auto newData1 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText1);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData1);
|
||||
std::set<Pattern> patternsToCheck{
|
||||
Pattern::Number, Pattern::URL, Pattern::EmailAddress,
|
||||
static_cast<Pattern>(0xffffffff), static_cast<Pattern>(0xffffff1a)};
|
||||
std::set<Pattern> patternsToCheck{ Pattern::Number, Pattern::URL, Pattern::EmailAddress,
|
||||
static_cast<Pattern>(0xffffffff), static_cast<Pattern>(0xffffff1a) };
|
||||
auto ret1 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
std::set<Pattern> expected1{};
|
||||
ASSERT_EQ(ret1, expected1);
|
||||
std::string plainText2 = "【撒迪化,等我i却很难,无穷花的!】"
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg"
|
||||
"(¥¥软骨素用人员为bdfdgse https://tgrthwerrwt.com/marrkerrerlorrve/ usrdq12_22swe@16rtgre3.com)";
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg"
|
||||
"(¥¥软骨素用人员为bdfdgse https://tgrthwerrwt.com/marrkerrerlorrve/ "
|
||||
"usrdq12_22swe@16rtgre3.com)";
|
||||
auto newData2 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText2);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData2);
|
||||
auto ret2 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
std::set<Pattern> expected2{};
|
||||
ASSERT_EQ(ret2, expected2);
|
||||
std::string plainText3 = "【撒迪化,等我i却很难,无穷花的!】"
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg";
|
||||
"额外i卡号!念佛为?,为单位打开陪我。而奋斗,我去二队去,威威:trfwrtg";
|
||||
auto newData3 = PasteboardClient::GetInstance()->CreatePlainTextData(plainText3);
|
||||
PasteboardClient::GetInstance()->SetPasteData(*newData3);
|
||||
auto ret3 = PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
|
@ -15,25 +15,24 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_error.h"
|
||||
|
||||
#include "application_defined_record.h"
|
||||
#include "audio.h"
|
||||
#include "folder.h"
|
||||
#include "html.h"
|
||||
#include "image.h"
|
||||
#include "link.h"
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "pixel_map.h"
|
||||
#include "plain_text.h"
|
||||
#include "system_defined_appitem.h"
|
||||
#include "system_defined_form.h"
|
||||
#include "system_defined_record.h"
|
||||
#include "system_defined_pixelmap.h"
|
||||
#include "system_defined_record.h"
|
||||
#include "text.h"
|
||||
#include "unified_data.h"
|
||||
#include "unified_record.h"
|
||||
#include "video.h"
|
||||
#include "pixel_map.h"
|
||||
#include "want.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
@ -90,22 +89,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void PasteboardClientUdmfDelayTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
void PasteboardClientUdmfDelayTest::SetUpTestCase() {}
|
||||
|
||||
void PasteboardClientUdmfDelayTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
void PasteboardClientUdmfDelayTest::TearDownTestCase() {}
|
||||
|
||||
void PasteboardClientUdmfDelayTest::SetUp()
|
||||
{
|
||||
PasteboardClient::GetInstance()->Clear();
|
||||
}
|
||||
|
||||
void PasteboardClientUdmfDelayTest::TearDown()
|
||||
{
|
||||
}
|
||||
void PasteboardClientUdmfDelayTest::TearDown() {}
|
||||
|
||||
void PasteboardClientUdmfDelayTest::SetUnifiedData()
|
||||
{
|
||||
@ -830,7 +823,6 @@ HWTEST_F(PasteboardClientUdmfDelayTest, SetWantDataTest001, TestSize.Level1)
|
||||
auto deviceValue1 = (*(want))->GetStringParam("deviceId_key");
|
||||
ASSERT_EQ(deviceValue1, "deviceId_value");
|
||||
|
||||
|
||||
PasteData pasteData;
|
||||
status = PasteboardClient::GetInstance()->GetPasteData(pasteData);
|
||||
ASSERT_EQ(status, static_cast<int32_t>(PasteboardError::E_OK));
|
||||
@ -878,4 +870,4 @@ HWTEST_F(PasteboardClientUdmfDelayTest, SetPixelMapDataTest001, TestSize.Level1)
|
||||
ASSERT_EQ(imageInfo2.size.width, 5);
|
||||
ASSERT_EQ(imageInfo2.pixelFormat, PixelFormat::ARGB_8888);
|
||||
}
|
||||
} // OHOS::Test
|
||||
} // namespace OHOS::Test
|
@ -14,12 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include "pasteboard_hilog.h"
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing;
|
||||
@ -62,17 +61,11 @@ void PasteboardMultiTypeUnifiedDataDelayTest::SetUpTestCase(void)
|
||||
PasteboardClient::GetInstance()->Clear();
|
||||
}
|
||||
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::TearDownTestCase(void) {}
|
||||
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::SetUp()
|
||||
{
|
||||
}
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::SetUp() {}
|
||||
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::TearDown()
|
||||
{
|
||||
}
|
||||
void PasteboardMultiTypeUnifiedDataDelayTest::TearDown() {}
|
||||
|
||||
UDMF::ValueType PasteboardMultiTypeUnifiedDataDelayTest::InitPlainUds()
|
||||
{
|
||||
@ -121,10 +114,10 @@ UDMF::ValueType PasteboardMultiTypeUnifiedDataDelayTest::InitLinkUds()
|
||||
|
||||
class EntryGetterImpl : public UDMF::EntryGetter {
|
||||
public:
|
||||
UDMF::ValueType GetValueByType(const std::string& utdId) override;
|
||||
UDMF::ValueType GetValueByType(const std::string &utdId) override;
|
||||
};
|
||||
|
||||
UDMF::ValueType EntryGetterImpl::GetValueByType(const std::string& utdId)
|
||||
UDMF::ValueType EntryGetterImpl::GetValueByType(const std::string &utdId)
|
||||
{
|
||||
if (utdId == plainTextUtdId_) {
|
||||
return PasteboardMultiTypeUnifiedDataDelayTest::InitPlainUds();
|
||||
@ -361,4 +354,4 @@ HWTEST_F(PasteboardMultiTypeUnifiedDataDelayTest, SetMultiTypeUnifiedDataDelayTe
|
||||
ASSERT_TRUE(outputTypes3.find(linkUtdId_) != outputTypes3.end());
|
||||
CheckLinkUds(outputRecord3->GetEntry(linkUtdId_));
|
||||
}
|
||||
} // OHOS::MiscServices
|
||||
} // namespace OHOS::MiscServices
|
@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "pasteboard_utils.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "application_defined_record.h"
|
||||
@ -23,6 +21,7 @@
|
||||
#include "html.h"
|
||||
#include "image.h"
|
||||
#include "link.h"
|
||||
#include "pasteboard_utils.h"
|
||||
#include "plain_text.h"
|
||||
#include "system_defined_appitem.h"
|
||||
#include "system_defined_form.h"
|
||||
@ -286,7 +285,7 @@ HWTEST_F(PasteboardUtilsTest, Text2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::TEXT);
|
||||
auto newPlainRecord = static_cast<UDMF::Text*>(newRecord.get());
|
||||
auto newPlainRecord = static_cast<UDMF::Text *>(newRecord.get());
|
||||
auto newDetails = newPlainRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
}
|
||||
@ -319,7 +318,7 @@ HWTEST_F(PasteboardUtilsTest, PlainText2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::PLAIN_TEXT);
|
||||
auto newPlainRecord = static_cast<UDMF::PlainText*>(newRecord.get());
|
||||
auto newPlainRecord = static_cast<UDMF::PlainText *>(newRecord.get());
|
||||
auto newPlainText = newPlainRecord->GetContent();
|
||||
auto newAbstract = newPlainRecord->GetAbstract();
|
||||
auto newDetails = newPlainRecord->GetDetails();
|
||||
@ -358,7 +357,7 @@ HWTEST_F(PasteboardUtilsTest, Html2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::HTML);
|
||||
auto newPlainRecord = static_cast<UDMF::Html*>(newRecord.get());
|
||||
auto newPlainRecord = static_cast<UDMF::Html *>(newRecord.get());
|
||||
auto newPlainText = newPlainRecord->GetHtmlContent();
|
||||
auto newAbstract = newPlainRecord->GetPlainContent();
|
||||
auto newDetails = newPlainRecord->GetDetails();
|
||||
@ -395,7 +394,7 @@ HWTEST_F(PasteboardUtilsTest, Link2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::HYPERLINK);
|
||||
auto newPlainRecord = static_cast<UDMF::Link*>(newRecord.get());
|
||||
auto newPlainRecord = static_cast<UDMF::Link *>(newRecord.get());
|
||||
auto newUrl = newPlainRecord->GetUrl();
|
||||
auto newDescription = newPlainRecord->GetDescription();
|
||||
auto newDetails = newPlainRecord->GetDetails();
|
||||
@ -464,7 +463,7 @@ HWTEST_F(PasteboardUtilsTest, File2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::FILE);
|
||||
auto newFileRecord = static_cast<UDMF::File*>(newRecord.get());
|
||||
auto newFileRecord = static_cast<UDMF::File *>(newRecord.get());
|
||||
auto newDetails = newFileRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
auto uri2 = newFileRecord->GetUri();
|
||||
@ -498,7 +497,7 @@ HWTEST_F(PasteboardUtilsTest, Image2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::IMAGE);
|
||||
auto newImageRecord = static_cast<UDMF::Image*>(newRecord.get());
|
||||
auto newImageRecord = static_cast<UDMF::Image *>(newRecord.get());
|
||||
auto newDetails = newImageRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
auto uri2 = newImageRecord->GetUri();
|
||||
@ -532,7 +531,7 @@ HWTEST_F(PasteboardUtilsTest, Audio2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::AUDIO);
|
||||
auto newAudioRecord = static_cast<UDMF::Audio*>(newRecord.get());
|
||||
auto newAudioRecord = static_cast<UDMF::Audio *>(newRecord.get());
|
||||
auto newDetails = newAudioRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
auto uri2 = newAudioRecord->GetUri();
|
||||
@ -566,7 +565,7 @@ HWTEST_F(PasteboardUtilsTest, Video2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::VIDEO);
|
||||
auto newVideoRecord = static_cast<UDMF::Video*>(newRecord.get());
|
||||
auto newVideoRecord = static_cast<UDMF::Video *>(newRecord.get());
|
||||
auto newDetails = newVideoRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
auto uri2 = newVideoRecord->GetUri();
|
||||
@ -600,7 +599,7 @@ HWTEST_F(PasteboardUtilsTest, Folder2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::FOLDER);
|
||||
auto newFolderRecord = static_cast<UDMF::Folder*>(newRecord.get());
|
||||
auto newFolderRecord = static_cast<UDMF::Folder *>(newRecord.get());
|
||||
auto newDetails = newFolderRecord->GetDetails();
|
||||
ASSERT_EQ(newDetails, details_);
|
||||
auto uri2 = newFolderRecord->GetUri();
|
||||
@ -632,7 +631,7 @@ HWTEST_F(PasteboardUtilsTest, SystemDefined2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::SYSTEM_DEFINED_RECORD);
|
||||
auto newSystemRecord = static_cast<UDMF::SystemDefinedRecord*>(newRecord.get());
|
||||
auto newSystemRecord = static_cast<UDMF::SystemDefinedRecord *>(newRecord.get());
|
||||
ASSERT_EQ(newSystemRecord->GetDetails(), details_);
|
||||
}
|
||||
|
||||
@ -671,7 +670,7 @@ HWTEST_F(PasteboardUtilsTest, AppItem2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::SYSTEM_DEFINED_APP_ITEM);
|
||||
auto newAppItem = static_cast<UDMF::SystemDefinedAppItem*>(newRecord.get());
|
||||
auto newAppItem = static_cast<UDMF::SystemDefinedAppItem *>(newRecord.get());
|
||||
ASSERT_EQ(newAppItem->GetAppId(), "appId");
|
||||
ASSERT_EQ(newAppItem->GetAppIconId(), "appIconId");
|
||||
ASSERT_EQ(newAppItem->GetAppName(), "appName");
|
||||
@ -717,7 +716,7 @@ HWTEST_F(PasteboardUtilsTest, Form2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::SYSTEM_DEFINED_FORM);
|
||||
auto newForm = static_cast<UDMF::SystemDefinedForm*>(newRecord.get());
|
||||
auto newForm = static_cast<UDMF::SystemDefinedForm *>(newRecord.get());
|
||||
ASSERT_EQ(newForm->GetFormId(), formId1);
|
||||
ASSERT_EQ(newForm->GetFormName(), formName1);
|
||||
ASSERT_EQ(newForm->GetModule(), module1);
|
||||
@ -792,7 +791,7 @@ HWTEST_F(PasteboardUtilsTest, AppDefined2PasteRecord001, TestSize.Level0)
|
||||
auto newRecord = newData->GetRecordAt(0);
|
||||
auto newType = newRecord->GetType();
|
||||
ASSERT_EQ(newType, UDMF::APPLICATION_DEFINED_RECORD);
|
||||
auto newSystemRecord = static_cast<UDMF::ApplicationDefinedRecord*>(newRecord.get());
|
||||
auto newSystemRecord = static_cast<UDMF::ApplicationDefinedRecord *>(newRecord.get());
|
||||
ASSERT_EQ(newSystemRecord->GetRawData(), rawData_);
|
||||
}
|
||||
} // namespace OHOS::MiscServices
|
@ -13,10 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "tlv_object.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "pasteboard_client.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "tlv_object.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
using namespace testing::ext;
|
||||
@ -31,21 +32,13 @@ public:
|
||||
static std::shared_ptr<PasteDataRecord> GenRecord(std::uint32_t index);
|
||||
};
|
||||
|
||||
void TLVObjectTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void TLVObjectTest::SetUpTestCase(void) {}
|
||||
|
||||
void TLVObjectTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void TLVObjectTest::TearDownTestCase(void) {}
|
||||
|
||||
void TLVObjectTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void TLVObjectTest::SetUp(void) {}
|
||||
|
||||
void TLVObjectTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void TLVObjectTest::TearDown(void) {}
|
||||
|
||||
std::shared_ptr<PasteDataRecord> TLVObjectTest::GenRecord(std::uint32_t index)
|
||||
{
|
||||
|
@ -13,37 +13,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "pasteboard_web_controller.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "pasteboard_web_controller.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::MiscServices;
|
||||
class WebControllerTest : public testing::Test {
|
||||
public:
|
||||
WebControllerTest() {};
|
||||
~WebControllerTest() {};
|
||||
WebControllerTest(){};
|
||||
~WebControllerTest(){};
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void WebControllerTest::SetUpTestCase(void)
|
||||
{
|
||||
}
|
||||
void WebControllerTest::SetUpTestCase(void) {}
|
||||
|
||||
void WebControllerTest::TearDownTestCase(void)
|
||||
{
|
||||
}
|
||||
void WebControllerTest::TearDownTestCase(void) {}
|
||||
|
||||
void WebControllerTest::SetUp(void)
|
||||
{
|
||||
}
|
||||
void WebControllerTest::SetUp(void) {}
|
||||
|
||||
void WebControllerTest::TearDown(void)
|
||||
{
|
||||
}
|
||||
void WebControllerTest::TearDown(void) {}
|
||||
|
||||
/**
|
||||
* @tc.name: SplitHtmlTest_001.
|
||||
@ -55,9 +48,10 @@ void WebControllerTest::TearDown(void)
|
||||
HWTEST_F(WebControllerTest, SplitHtmlTest_001, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='http://file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='http://file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), 1);
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteDataRecords = pasteData->AllRecords();
|
||||
@ -74,9 +68,10 @@ HWTEST_F(WebControllerTest, SplitHtmlTest_001, TestSize.Level1)
|
||||
HWTEST_F(WebControllerTest, SplitHtmlTest_002, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_NE(pasteData, nullptr);
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteDataRecords = pasteData->AllRecords();
|
||||
@ -93,10 +88,11 @@ HWTEST_F(WebControllerTest, SplitHtmlTest_002, TestSize.Level1)
|
||||
HWTEST_F(WebControllerTest, SplitHtmlTest_003, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='file2.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='file2.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_NE(pasteData, nullptr);
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteDataRecords = pasteData->AllRecords();
|
||||
@ -113,9 +109,10 @@ HWTEST_F(WebControllerTest, SplitHtmlTest_003, TestSize.Level1)
|
||||
HWTEST_F(WebControllerTest, RebuildHtmlTest_004, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='http://file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='http://file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), 1);
|
||||
std::shared_ptr<std::string> newHtml = webClipboardController.RebuildHtml(pasteData);
|
||||
@ -134,13 +131,14 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_005, TestSize.Level1)
|
||||
const int32_t splitRecordCount = 2;
|
||||
const std::string uri = "file:///data/storage/el2/distributedfiles/temp.png";
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
const char* execptHtml =
|
||||
"<img data-ohos='clipboard' src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
const char *execptHtml = "<img data-ohos='clipboard' "
|
||||
"src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_NE(pasteData, nullptr);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), splitRecordCount);
|
||||
@ -160,7 +158,7 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_005, TestSize.Level1)
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), splitRecordCount);
|
||||
std::shared_ptr<std::string> newHtml = webClipboardController.RebuildHtml(newPasteData);
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), 1);
|
||||
const char* newHtmlStr = newHtml.get()->c_str();
|
||||
const char *newHtmlStr = newHtml.get()->c_str();
|
||||
EXPECT_STREQ(newHtmlStr, execptHtml);
|
||||
}
|
||||
|
||||
@ -176,15 +174,16 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_006, TestSize.Level1)
|
||||
const int32_t splitRecordCount = 3;
|
||||
const std::string uri = "file:///data/storage/el2/distributedfiles/temp.png";
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img data-ohos='clipboard' "
|
||||
"src=\"file2.jpg\"><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
const char* execptHtml =
|
||||
"<img data-ohos='clipboard' src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src=\"file:///data/storage/el2/distributedfiles/temp.png\"><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='file:///file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src=\"file2.jpg\"><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
const char *execptHtml = "<img data-ohos='clipboard' "
|
||||
"src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src=\"file:///data/storage/el2/distributedfiles/temp.png\"><img data-ohos='clipboard' "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_NE(pasteData, nullptr);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), splitRecordCount);
|
||||
@ -204,7 +203,7 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_006, TestSize.Level1)
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), splitRecordCount);
|
||||
std::shared_ptr<std::string> newHtml = webClipboardController.RebuildHtml(newPasteData);
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), 1);
|
||||
const char* newHtmlStr = newHtml.get()->c_str();
|
||||
const char *newHtmlStr = newHtml.get()->c_str();
|
||||
EXPECT_STREQ(newHtmlStr, execptHtml);
|
||||
}
|
||||
|
||||
@ -218,9 +217,9 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_006, TestSize.Level1)
|
||||
HWTEST_F(WebControllerTest, SplitHtmlTest_007, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='xxx://file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='yyy://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='xxx://file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='yyy://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), 1);
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> pasteDataRecords = pasteData->AllRecords();
|
||||
@ -237,9 +236,9 @@ HWTEST_F(WebControllerTest, SplitHtmlTest_007, TestSize.Level1)
|
||||
HWTEST_F(WebControllerTest, RebuildHtmlTest_008, TestSize.Level1)
|
||||
{
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img data-ohos='clipboard' src='xxx://file1.jpg'><img data-ohos='clipboard' "
|
||||
"src='ttt://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
std::shared_ptr<std::string> html(new std::string("<img data-ohos='clipboard' src='xxx://file1.jpg'><img "
|
||||
"data-ohos='clipboard' "
|
||||
"src='ttt://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), 1);
|
||||
std::shared_ptr<std::string> newHtml = webClipboardController.RebuildHtml(pasteData);
|
||||
@ -258,14 +257,13 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_009, TestSize.Level1)
|
||||
const int32_t splitRecordCount = 3;
|
||||
const std::string uri = "file:///data/storage/el2/distributedfiles/temp.png";
|
||||
auto webClipboardController = PasteboardWebController::GetInstance();
|
||||
std::shared_ptr<std::string> html(
|
||||
new std::string("<img src='file:///file1.jpg'><img src=\"file2.jpg\"><img "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>"));
|
||||
const char* execptHtml =
|
||||
"<img src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
""
|
||||
"src=\"file:///data/storage/el2/distributedfiles/temp.png\"><img "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
std::shared_ptr<std::string> html(new std::string("<img src='file:///file1.jpg'><img src=\"file2.jpg\"><img "
|
||||
"src='https://data/storage/el2/distributedfiles/"
|
||||
"202305301.png'>"));
|
||||
const char *execptHtml = "<img src='file:///data/storage/el2/distributedfiles/temp.png'><img "
|
||||
""
|
||||
"src=\"file:///data/storage/el2/distributedfiles/temp.png\"><img "
|
||||
"src='https://data/storage/el2/distributedfiles/202305301.png'>";
|
||||
auto pasteData = webClipboardController.SplitHtml(html);
|
||||
EXPECT_NE(pasteData, nullptr);
|
||||
EXPECT_EQ(pasteData->GetRecordCount(), splitRecordCount);
|
||||
@ -285,6 +283,6 @@ HWTEST_F(WebControllerTest, RebuildHtmlTest_009, TestSize.Level1)
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), splitRecordCount);
|
||||
std::shared_ptr<std::string> newHtml = webClipboardController.RebuildHtml(newPasteData);
|
||||
EXPECT_EQ(newPasteData->GetRecordCount(), 1);
|
||||
const char* newHtmlStr = newHtml.get()->c_str();
|
||||
const char *newHtmlStr = newHtml.get()->c_str();
|
||||
EXPECT_STREQ(newHtmlStr, execptHtml);
|
||||
}
|
@ -103,8 +103,8 @@ inline double HostToNet(double value)
|
||||
{
|
||||
double to;
|
||||
size_t typeLen = sizeof(double);
|
||||
const uint8_t* fromByte = reinterpret_cast<const uint8_t*>(&value);
|
||||
uint8_t* toByte = reinterpret_cast<uint8_t*>(&to);
|
||||
const uint8_t *fromByte = reinterpret_cast<const uint8_t *>(&value);
|
||||
uint8_t *toByte = reinterpret_cast<uint8_t *>(&to);
|
||||
for (size_t i = 0; i < typeLen; i++) {
|
||||
toByte[i] = fromByte[typeLen - i - 1]; // 1 is for index boundary
|
||||
}
|
||||
|
@ -12,9 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "tlv_object.h"
|
||||
|
||||
#include "securec.h"
|
||||
#include "tlv_object.h"
|
||||
#include "unified_meta.h"
|
||||
#include "want.h"
|
||||
namespace OHOS::MiscServices {
|
||||
@ -27,7 +26,7 @@ bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, std::mon
|
||||
cursor_ += sizeof(TLVHead);
|
||||
return true;
|
||||
}
|
||||
bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, void* value)
|
||||
bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, void *value)
|
||||
{
|
||||
if (!HasExpectBuffer(buffer, sizeof(TLVHead))) {
|
||||
return false;
|
||||
@ -125,7 +124,7 @@ bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, const Ob
|
||||
auto tagCursor = cursor_;
|
||||
cursor_ += sizeof(TLVHead);
|
||||
auto valueCursor = cursor_;
|
||||
for (const auto& [key, val] : value.value_) {
|
||||
for (const auto &[key, val] : value.value_) {
|
||||
if (!Write(buffer, TAG_MAP_KEY, key)) {
|
||||
return false;
|
||||
}
|
||||
@ -157,13 +156,13 @@ bool TLVObject::Write(
|
||||
}
|
||||
|
||||
template<typename _InTp>
|
||||
bool TLVObject::WriteVariant(std::vector<std::uint8_t>& buffer, uint16_t type, uint32_t step, const _InTp &input)
|
||||
bool TLVObject::WriteVariant(std::vector<std::uint8_t> &buffer, uint16_t type, uint32_t step, const _InTp &input)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename _InTp, typename _First, typename... _Rest>
|
||||
bool TLVObject::WriteVariant(std::vector<std::uint8_t>& buffer, uint16_t type, uint32_t step, const _InTp &input)
|
||||
bool TLVObject::WriteVariant(std::vector<std::uint8_t> &buffer, uint16_t type, uint32_t step, const _InTp &input)
|
||||
{
|
||||
if (step == input.index()) {
|
||||
auto val = std::get<_First>(input);
|
||||
@ -173,7 +172,7 @@ bool TLVObject::WriteVariant(std::vector<std::uint8_t>& buffer, uint16_t type, u
|
||||
}
|
||||
|
||||
template<typename... _Types>
|
||||
bool TLVObject::Write(std::vector<std::uint8_t>& buffer, uint16_t type, const std::variant<_Types...> &input)
|
||||
bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, const std::variant<_Types...> &input)
|
||||
{
|
||||
if (!HasExpectBuffer(buffer, sizeof(TLVHead))) {
|
||||
return false;
|
||||
@ -192,7 +191,7 @@ bool TLVObject::Write(std::vector<std::uint8_t>& buffer, uint16_t type, const st
|
||||
}
|
||||
|
||||
template<>
|
||||
bool TLVObject::Write(std::vector<std::uint8_t>& buffer, uint16_t type, const EntryValue& input)
|
||||
bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, const EntryValue &input)
|
||||
{
|
||||
if (!HasExpectBuffer(buffer, sizeof(TLVHead))) {
|
||||
return false;
|
||||
@ -206,13 +205,13 @@ bool TLVObject::Write(std::vector<std::uint8_t>& buffer, uint16_t type, const En
|
||||
return false;
|
||||
}
|
||||
WriteVariant<decltype(input), std::monostate, int32_t, int64_t, double, bool, std::string, std::vector<uint8_t>,
|
||||
std::shared_ptr<OHOS::AAFwk::Want>, std::shared_ptr<OHOS::Media::PixelMap>, std::shared_ptr<Object>,
|
||||
nullptr_t>(buffer, TAG_VARIANT_VALUE, 0, input);
|
||||
std::shared_ptr<OHOS::AAFwk::Want>, std::shared_ptr<OHOS::Media::PixelMap>, std::shared_ptr<Object>, nullptr_t>(
|
||||
buffer, TAG_VARIANT_VALUE, 0, input);
|
||||
WriteHead(buffer, type, tagCursor, cursor_ - valueCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TLVObject::Write(std::vector<std::uint8_t>& buffer, uint16_t type, const Details& value)
|
||||
bool TLVObject::Write(std::vector<std::uint8_t> &buffer, uint16_t type, const Details &value)
|
||||
{
|
||||
if (!HasExpectBuffer(buffer, sizeof(TLVHead))) {
|
||||
return false;
|
||||
@ -373,15 +372,15 @@ bool TLVObject::ReadValue(
|
||||
}
|
||||
|
||||
template<typename _OutTp>
|
||||
bool TLVObject::ReadVariant(const std::vector<std::uint8_t>& buffer, uint32_t step, uint32_t index, _OutTp& output,
|
||||
const TLVHead& head)
|
||||
bool TLVObject::ReadVariant(
|
||||
const std::vector<std::uint8_t> &buffer, uint32_t step, uint32_t index, _OutTp &output, const TLVHead &head)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename _OutTp, typename _First, typename... _Rest>
|
||||
bool TLVObject::ReadVariant(const std::vector<std::uint8_t>& buffer, uint32_t step, uint32_t index, _OutTp& value,
|
||||
const TLVHead& head)
|
||||
bool TLVObject::ReadVariant(
|
||||
const std::vector<std::uint8_t> &buffer, uint32_t step, uint32_t index, _OutTp &value, const TLVHead &head)
|
||||
{
|
||||
if (step == index) {
|
||||
TLVHead valueHead{};
|
||||
@ -395,7 +394,7 @@ bool TLVObject::ReadVariant(const std::vector<std::uint8_t>& buffer, uint32_t st
|
||||
}
|
||||
|
||||
template<typename... _Types>
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t>& buffer, std::variant<_Types...>& value, const TLVHead& head)
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t> &buffer, std::variant<_Types...> &value, const TLVHead &head)
|
||||
{
|
||||
TLVHead valueHead{};
|
||||
ReadHead(buffer, valueHead);
|
||||
@ -407,7 +406,7 @@ bool TLVObject::ReadValue(const std::vector<std::uint8_t>& buffer, std::variant<
|
||||
}
|
||||
|
||||
template<>
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t>& buffer, EntryValue& value, const TLVHead& head)
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t> &buffer, EntryValue &value, const TLVHead &head)
|
||||
{
|
||||
TLVHead valueHead{};
|
||||
ReadHead(buffer, valueHead);
|
||||
@ -415,12 +414,12 @@ bool TLVObject::ReadValue(const std::vector<std::uint8_t>& buffer, EntryValue& v
|
||||
if (!ReadValue(buffer, index, valueHead)) {
|
||||
return false;
|
||||
}
|
||||
return ReadVariant<decltype(value), std::monostate, int32_t, int64_t, double, bool, std::string,
|
||||
std::vector<uint8_t>, std::shared_ptr<OHOS::AAFwk::Want>, std::shared_ptr<OHOS::Media::PixelMap>,
|
||||
std::shared_ptr<Object>, nullptr_t>(buffer, 0, index, value, valueHead);
|
||||
return ReadVariant<decltype(value), std::monostate, int32_t, int64_t, double, bool, std::string, std::vector<uint8_t>,
|
||||
std::shared_ptr<OHOS::AAFwk::Want>, std::shared_ptr<OHOS::Media::PixelMap>, std::shared_ptr<Object>, nullptr_t>(
|
||||
buffer, 0, index, value, valueHead);
|
||||
}
|
||||
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t>& buffer, Details& value, const TLVHead& head)
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t> &buffer, Details &value, const TLVHead &head)
|
||||
{
|
||||
auto mapEnd = cursor_ + head.len;
|
||||
while (cursor_ < mapEnd) {
|
||||
@ -480,8 +479,8 @@ bool TLVObject::ReadValue(const std::vector<std::uint8_t> &buffer, AAFwk::Want &
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TLVObject::ReadValue(const std::vector<std::uint8_t> &buffer, std::shared_ptr<Media::PixelMap> &value,
|
||||
const TLVHead &head)
|
||||
bool TLVObject::ReadValue(
|
||||
const std::vector<std::uint8_t> &buffer, std::shared_ptr<Media::PixelMap> &value, const TLVHead &head)
|
||||
{
|
||||
std::vector<std::uint8_t> u8Value;
|
||||
if (!ReadValue(buffer, u8Value, head)) {
|
||||
@ -513,7 +512,7 @@ std::shared_ptr<Media::PixelMap> TLVObject::Vector2PixelMap(std::vector<std::uin
|
||||
if (value.size() == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::shared_ptr<Media::PixelMap> (Media::PixelMap::DecodeTlv(value));
|
||||
return std::shared_ptr<Media::PixelMap>(Media::PixelMap::DecodeTlv(value));
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> TLVObject::PixelMap2Vector(std::shared_ptr<Media::PixelMap> pixelMap)
|
||||
|
@ -25,9 +25,9 @@
|
||||
#include "api/visibility.h"
|
||||
#include "endian_converter.h"
|
||||
#include "parcel.h"
|
||||
#include "parcel_util.h"
|
||||
#include "securec.h"
|
||||
#include "unified_meta.h"
|
||||
#include "parcel_util.h"
|
||||
namespace OHOS::MiscServices {
|
||||
#pragma pack(1)
|
||||
struct TLVHead {
|
||||
@ -59,9 +59,7 @@ using Object = UDMF::Object;
|
||||
|
||||
struct API_EXPORT TLVObject {
|
||||
public:
|
||||
TLVObject() : total_(0), cursor_(0)
|
||||
{
|
||||
}
|
||||
TLVObject() : total_(0), cursor_(0) {}
|
||||
virtual bool Encode(std::vector<std::uint8_t> &buffer) = 0;
|
||||
virtual bool Decode(const std::vector<std::uint8_t> &buffer) = 0;
|
||||
virtual size_t Count() = 0;
|
||||
@ -145,17 +143,17 @@ public:
|
||||
return expectSize;
|
||||
}
|
||||
|
||||
static inline size_t Count(const Details& value)
|
||||
static inline size_t Count(const Details &value)
|
||||
{
|
||||
size_t expectSize = sizeof(TLVHead);
|
||||
for (auto& item : value) {
|
||||
for (auto &item : value) {
|
||||
expectSize += Count(item.first);
|
||||
expectSize += Count(item.second);
|
||||
}
|
||||
return expectSize;
|
||||
}
|
||||
|
||||
static inline size_t Count(const std::shared_ptr<AAFwk::Want>& value)
|
||||
static inline size_t Count(const std::shared_ptr<AAFwk::Want> &value)
|
||||
{
|
||||
size_t expectSize = sizeof(TLVHead);
|
||||
if (value == nullptr) {
|
||||
@ -173,13 +171,13 @@ public:
|
||||
return expectSize + Count(PixelMap2Vector(value));
|
||||
}
|
||||
|
||||
static inline size_t Count(const std::shared_ptr<Object>& value)
|
||||
static inline size_t Count(const std::shared_ptr<Object> &value)
|
||||
{
|
||||
size_t expectSize = sizeof(TLVHead);
|
||||
if (value == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
for (auto& item : value->value_) {
|
||||
for (auto &item : value->value_) {
|
||||
expectSize += Count(item.first);
|
||||
expectSize += Count(item.second);
|
||||
}
|
||||
@ -200,13 +198,13 @@ public:
|
||||
static std::vector<std::uint8_t> PixelMap2Vector(std::shared_ptr<Media::PixelMap> pixelMap);
|
||||
|
||||
template<typename _InTp>
|
||||
static inline size_t CountVariant(uint32_t step, const _InTp& input)
|
||||
static inline size_t CountVariant(uint32_t step, const _InTp &input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename _InTp, typename _First, typename... _Rest>
|
||||
static inline size_t CountVariant(uint32_t step, const _InTp& input)
|
||||
static inline size_t CountVariant(uint32_t step, const _InTp &input)
|
||||
{
|
||||
if (step == input.index()) {
|
||||
return Count(step) + Count(std::get<_First>(input));
|
||||
@ -215,14 +213,14 @@ public:
|
||||
}
|
||||
|
||||
template<typename... _Types>
|
||||
static inline size_t Count(const std::variant<_Types...>& input)
|
||||
static inline size_t Count(const std::variant<_Types...> &input)
|
||||
{
|
||||
size_t expectSize = sizeof(TLVHead);
|
||||
return expectSize + CountVariant<decltype(input), _Types...>(0, input);
|
||||
}
|
||||
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, std::monostate value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, void* value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, void *value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, bool value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, double value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, int8_t value);
|
||||
@ -261,18 +259,18 @@ public:
|
||||
}
|
||||
|
||||
template<typename _InTp>
|
||||
bool WriteVariant(std::vector<std::uint8_t>& buffer, uint16_t type, uint32_t step, const _InTp& input);
|
||||
bool WriteVariant(std::vector<std::uint8_t> &buffer, uint16_t type, uint32_t step, const _InTp &input);
|
||||
|
||||
template<typename _InTp, typename _First, typename... _Rest>
|
||||
bool WriteVariant(std::vector<std::uint8_t>& buffer, uint16_t type, uint32_t step, const _InTp& input);
|
||||
bool WriteVariant(std::vector<std::uint8_t> &buffer, uint16_t type, uint32_t step, const _InTp &input);
|
||||
|
||||
template<typename... _Types>
|
||||
bool Write(std::vector<std::uint8_t>& buffer, uint16_t type, const std::variant<_Types...>& input);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, const std::variant<_Types...> &input);
|
||||
|
||||
template<>
|
||||
bool Write(std::vector<std::uint8_t>& buffer, uint16_t type, const EntryValue& input);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, const EntryValue &input);
|
||||
|
||||
bool Write(std::vector<std::uint8_t>& buffer, uint16_t type, const Details& value);
|
||||
bool Write(std::vector<std::uint8_t> &buffer, uint16_t type, const Details &value);
|
||||
|
||||
bool ReadHead(const std::vector<std::uint8_t> &buffer, TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, bool &value, const TLVHead &head);
|
||||
@ -288,8 +286,8 @@ public:
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, RawMem &rawMem, const TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, Object &value, const TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, AAFwk::Want &value, const TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, std::shared_ptr<Media::PixelMap> &value,
|
||||
const TLVHead &head);
|
||||
bool ReadValue(
|
||||
const std::vector<std::uint8_t> &buffer, std::shared_ptr<Media::PixelMap> &value, const TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, TLVObject &value, const TLVHead &head);
|
||||
template<typename T>
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, std::vector<T> &value, const TLVHead &head)
|
||||
@ -309,23 +307,23 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadValue(const std::vector<std::uint8_t>& buffer, std::vector<uint8_t>& value, const TLVHead& head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, std::vector<uint8_t> &value, const TLVHead &head);
|
||||
|
||||
template<typename _InTp>
|
||||
bool ReadVariant(const std::vector<std::uint8_t>& buffer, uint32_t step, uint32_t index, _InTp& input,
|
||||
const TLVHead& head);
|
||||
bool ReadVariant(
|
||||
const std::vector<std::uint8_t> &buffer, uint32_t step, uint32_t index, _InTp &input, const TLVHead &head);
|
||||
|
||||
template<typename _InTp, typename _First, typename... _Rest>
|
||||
bool ReadVariant(const std::vector<std::uint8_t>& buffer, uint32_t step, uint32_t index, _InTp& input,
|
||||
const TLVHead& head);
|
||||
bool ReadVariant(
|
||||
const std::vector<std::uint8_t> &buffer, uint32_t step, uint32_t index, _InTp &input, const TLVHead &head);
|
||||
|
||||
template<typename... _Types>
|
||||
bool ReadValue(const std::vector<std::uint8_t>& buffer, std::variant<_Types...>& value, const TLVHead& head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, std::variant<_Types...> &value, const TLVHead &head);
|
||||
|
||||
template<>
|
||||
bool ReadValue(const std::vector<std::uint8_t>& buffer, EntryValue& value, const TLVHead& head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, EntryValue &value, const TLVHead &head);
|
||||
|
||||
bool ReadValue(const std::vector<std::uint8_t>& buffer, Details& value, const TLVHead& head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, Details &value, const TLVHead &head);
|
||||
bool ReadValue(const std::vector<std::uint8_t> &buffer, std::map<std::string, std::vector<uint8_t>> &value,
|
||||
const TLVHead &head);
|
||||
|
||||
|
@ -12,11 +12,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "copy_uri_handler.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "copy_uri_handler.h"
|
||||
#include "errors.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
|
@ -20,6 +20,7 @@ class CopyUriHandler : public UriHandler {
|
||||
public:
|
||||
CopyUriHandler();
|
||||
std::string ToUri(int32_t fd) override;
|
||||
|
||||
private:
|
||||
static constexpr int32_t FILE_EXIST = 17;
|
||||
};
|
||||
|
@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "paste_uri_handler.h"
|
||||
|
||||
#include "pasteboard_hilog.h"
|
||||
#include "remote_uri.h"
|
||||
namespace OHOS::MiscServices {
|
||||
|
@ -12,28 +12,28 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PASTEBOARD_LOG_H
|
||||
|
||||
#define PASTEBOARD_LOG_H
|
||||
|
||||
|
||||
#include "hilog/log.h"
|
||||
|
||||
|
||||
#undef LOG_DOMAIN
|
||||
#undef LOG_TAG
|
||||
#define LOG_DOMAIN 0xD001650
|
||||
#define LOG_TAG "PasteboardFFI"
|
||||
|
||||
|
||||
#undef LOGI
|
||||
#undef LOGE
|
||||
#define LOGI(...) \
|
||||
if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_INFO)) { \
|
||||
HILOG_INFO(LOG_CORE, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define LOGE(...) \
|
||||
if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_ERROR)) { \
|
||||
HILOG_ERROR(LOG_CORE, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define LOGI(...) \
|
||||
if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_INFO)) { \
|
||||
HILOG_INFO(LOG_CORE, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define LOGE(...) \
|
||||
if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_ERROR)) { \
|
||||
HILOG_ERROR(LOG_CORE, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#endif
|
@ -1,131 +1,131 @@
|
||||
// namespace OHOS/*
|
||||
*Copyright(c) 2024 Huawei Device Co., Ltd.*Licensed under the Apache License, Version 2.0(the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "paste_data_impl.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServicesCj {
|
||||
namespace OHOS {
|
||||
namespace MiscServicesCj {
|
||||
|
||||
static std::map<std::shared_ptr<PasteDataRecord>, sptr<PasteDataRecordImpl>> g_cjPasteDataRecordMap;
|
||||
std::recursive_mutex g_PasteDataMutex;
|
||||
static std::map<std::shared_ptr<PasteDataRecord>, sptr<PasteDataRecordImpl>> g_cjPasteDataRecordMap;
|
||||
std::recursive_mutex g_PasteDataMutex;
|
||||
|
||||
OHOS::FFI::RuntimeType *PasteDataRecordImpl::GetClassType()
|
||||
{
|
||||
static OHOS::FFI::RuntimeType runtimeType = OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("PasteDataRecordIm"
|
||||
"pl");
|
||||
return &runtimeType;
|
||||
}
|
||||
OHOS::FFI::RuntimeType *PasteDataRecordImpl::GetClassType()
|
||||
{
|
||||
static OHOS::FFI::RuntimeType runtimeType = OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("PasteDataRecordIm"
|
||||
"pl");
|
||||
return &runtimeType;
|
||||
}
|
||||
|
||||
int64_t CreateCjPasteDataRecordObject(std::string mimeType, CJValueType value)
|
||||
{
|
||||
auto pasteDataRecordImpl = FFI::FFIData::Create<PasteDataRecordImpl>(mimeType, value);
|
||||
if (!pasteDataRecordImpl) {
|
||||
return 0;
|
||||
}
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> realValue = pasteDataRecordImpl->GetRealPasteDataRecord();
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.try_emplace(realValue, pasteDataRecordImpl);
|
||||
int64_t CreateCjPasteDataRecordObject(std::string mimeType, CJValueType value)
|
||||
{
|
||||
auto pasteDataRecordImpl = FFI::FFIData::Create<PasteDataRecordImpl>(mimeType, value);
|
||||
if (!pasteDataRecordImpl) {
|
||||
return 0;
|
||||
}
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> realValue = pasteDataRecordImpl->GetRealPasteDataRecord();
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.try_emplace(realValue, pasteDataRecordImpl);
|
||||
|
||||
return pasteDataRecordImpl->GetID();
|
||||
}
|
||||
return pasteDataRecordImpl->GetID();
|
||||
}
|
||||
|
||||
sptr<PasteDataRecordImpl> getCjPasteDataRecordImpl(std::shared_ptr<PasteDataRecord> record)
|
||||
{
|
||||
if (record == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
if (g_cjPasteDataRecordMap.find(record) == g_cjPasteDataRecordMap.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return g_cjPasteDataRecordMap[record];
|
||||
}
|
||||
sptr<PasteDataRecordImpl> getCjPasteDataRecordImpl(std::shared_ptr<PasteDataRecord> record)
|
||||
{
|
||||
if (record == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
if (g_cjPasteDataRecordMap.find(record) == g_cjPasteDataRecordMap.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return g_cjPasteDataRecordMap[record];
|
||||
}
|
||||
|
||||
void removeCjPasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> record)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.erase(record);
|
||||
}
|
||||
void removeCjPasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> record)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.erase(record);
|
||||
}
|
||||
|
||||
void addCjPasteDataRecordImpl(
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> record, sptr<PasteDataRecordImpl> pasteDataRecordImpl)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.try_emplace(record, pasteDataRecordImpl);
|
||||
}
|
||||
void addCjPasteDataRecordImpl(
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> record, sptr<PasteDataRecordImpl> pasteDataRecordImpl)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(g_PasteDataMutex);
|
||||
g_cjPasteDataRecordMap.try_emplace(record, pasteDataRecordImpl);
|
||||
}
|
||||
|
||||
PasteDataRecordImpl::PasteDataRecordImpl()
|
||||
{
|
||||
value_ = std::make_shared<PasteDataRecord>();
|
||||
}
|
||||
PasteDataRecordImpl::PasteDataRecordImpl()
|
||||
{
|
||||
value_ = std::make_shared<PasteDataRecord>();
|
||||
}
|
||||
|
||||
PasteDataRecordImpl::PasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> pasteDataRecord)
|
||||
{
|
||||
value_ = pasteDataRecord;
|
||||
}
|
||||
PasteDataRecordImpl::PasteDataRecordImpl(std::shared_ptr<MiscServices::PasteDataRecord> pasteDataRecord)
|
||||
{
|
||||
value_ = pasteDataRecord;
|
||||
}
|
||||
|
||||
PasteDataRecordImpl::PasteDataRecordImpl(std::string mimeType, CJValueType value)
|
||||
{
|
||||
if (mimeType == "text/html") {
|
||||
CreateHtmlDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/plain") {
|
||||
CreatePlainTextDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/uri") {
|
||||
CreateUriDataRecord(mimeType, value);
|
||||
} else if (mimeType == "pixelMap") {
|
||||
CreatePixelMapDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/want") {
|
||||
CreateWantDataRecord(mimeType, value);
|
||||
} else {
|
||||
std::vector<uint8_t> arrayBuf(reinterpret_cast<uint8_t *>(value.arrayBufferData),
|
||||
reinterpret_cast<uint8_t *>(value.arrayBufferData) + value.arrayBufferSize);
|
||||
value_ = PasteboardClient::GetInstance()->CreateKvRecord(mimeType, arrayBuf);
|
||||
}
|
||||
}
|
||||
PasteDataRecordImpl::PasteDataRecordImpl(std::string mimeType, CJValueType value)
|
||||
{
|
||||
if (mimeType == "text/html") {
|
||||
CreateHtmlDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/plain") {
|
||||
CreatePlainTextDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/uri") {
|
||||
CreateUriDataRecord(mimeType, value);
|
||||
} else if (mimeType == "pixelMap") {
|
||||
CreatePixelMapDataRecord(mimeType, value);
|
||||
} else if (mimeType == "text/want") {
|
||||
CreateWantDataRecord(mimeType, value);
|
||||
} else {
|
||||
std::vector<uint8_t> arrayBuf(reinterpret_cast<uint8_t *>(value.arrayBufferData),
|
||||
reinterpret_cast<uint8_t *>(value.arrayBufferData) + value.arrayBufferSize);
|
||||
value_ = PasteboardClient::GetInstance()->CreateKvRecord(mimeType, arrayBuf);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> PasteDataRecordImpl::GetRealPasteDataRecord()
|
||||
{
|
||||
if (value_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> res = value_;
|
||||
return res;
|
||||
}
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> PasteDataRecordImpl::GetRealPasteDataRecord()
|
||||
{
|
||||
if (value_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<MiscServices::PasteDataRecord> res = value_;
|
||||
return res;
|
||||
}
|
||||
|
||||
void PasteDataRecordImpl::CreateHtmlDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreateHtmlTextRecord(value.stringValue);
|
||||
}
|
||||
void PasteDataRecordImpl::CreateHtmlDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreateHtmlTextRecord(value.stringValue);
|
||||
}
|
||||
|
||||
void PasteDataRecordImpl::CreatePlainTextDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreatePlainTextRecord(value.stringValue);
|
||||
}
|
||||
void PasteDataRecordImpl::CreatePlainTextDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreatePlainTextRecord(value.stringValue);
|
||||
}
|
||||
|
||||
void PasteDataRecordImpl::CreateUriDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreateUriRecord(OHOS::Uri(value.stringValue));
|
||||
}
|
||||
void PasteDataRecordImpl::CreateUriDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreateUriRecord(OHOS::Uri(value.stringValue));
|
||||
}
|
||||
|
||||
void PasteDataRecordImpl::CreatePixelMapDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreatePixelMapRecord(value.pixelMap);
|
||||
}
|
||||
void PasteDataRecordImpl::CreatePixelMapDataRecord(std::string mimeType, CJValueType value)
|
||||
{
|
||||
value_ = PasteboardClient::GetInstance()->CreatePixelMapRecord(value.pixelMap);
|
||||
}
|
||||
|
||||
void PasteDataRecordImpl::CreateWantDataRecord(std::string mimeType, CJValueType value) {}
|
||||
void PasteDataRecordImpl::CreateWantDataRecord(std::string mimeType, CJValueType value) {}
|
||||
|
||||
} // namespace MiscServicesCj
|
||||
}
|
||||
} // namespace MiscServicesCj
|
||||
} // namespace OHOS
|
@ -116,3 +116,4 @@ private:
|
||||
} // namespace OHOS::MiscServicesNapi
|
||||
|
||||
#endif // PASTEBOARD_ASYNC_CALL_H
|
||||
// namespace OHOS
|
@ -27,8 +27,8 @@ EXTERN_C_START
|
||||
static napi_value NapiInit(napi_env env, napi_value exports)
|
||||
{
|
||||
/*
|
||||
* Propertise define
|
||||
*/
|
||||
* Propertise define
|
||||
*/
|
||||
PasteDataRecordNapi::PasteDataRecordInit(env, exports);
|
||||
PasteDataNapi::PasteDataInit(env, exports);
|
||||
SystemPasteboardNapi::SystemPasteboardInit(env, exports);
|
||||
|
@ -76,14 +76,14 @@ typedef enum Pasteboard_NotifyType {
|
||||
* @param type The types of data changes. For details, see {@link Pasteboard_NotifyType}.
|
||||
* @since 13
|
||||
*/
|
||||
typedef void (*Pasteboard_Notify)(void* context, Pasteboard_NotifyType type);
|
||||
typedef void (*Pasteboard_Notify)(void *context, Pasteboard_NotifyType type);
|
||||
|
||||
/**
|
||||
* @brief Defines the callback function used free the context.
|
||||
* @param context Pointer to the context which is to be free.
|
||||
* @since 13
|
||||
*/
|
||||
typedef void (*Pasteboard_Finalize)(void* context);
|
||||
typedef void (*Pasteboard_Finalize)(void *context);
|
||||
|
||||
/**
|
||||
* @brief Defines the Pasteboard subscriber information
|
||||
@ -100,7 +100,7 @@ typedef struct OH_PasteboardObserver OH_PasteboardObserver;
|
||||
* @see OH_PasteboardObserver.
|
||||
* @since 13
|
||||
*/
|
||||
OH_PasteboardObserver* OH_PasteboardObserver_Create();
|
||||
OH_PasteboardObserver *OH_PasteboardObserver_Create();
|
||||
|
||||
/**
|
||||
* @brief Destroy a {@link OH_PasteboardObserver} instance.
|
||||
@ -112,7 +112,7 @@ OH_PasteboardObserver* OH_PasteboardObserver_Create();
|
||||
* @see OH_PasteboardObserver PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_PasteboardObserver_Destroy(OH_PasteboardObserver* observer);
|
||||
int OH_PasteboardObserver_Destroy(OH_PasteboardObserver *observer);
|
||||
|
||||
/**
|
||||
* @brief Sets a callback function to return the Pasteboard data changed.
|
||||
@ -128,8 +128,8 @@ int OH_PasteboardObserver_Destroy(OH_PasteboardObserver* observer);
|
||||
* @see OH_PasteboardObserver Pasteboard_Notify PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_PasteboardObserver_SetData(OH_PasteboardObserver* observer, void* context,
|
||||
const Pasteboard_Notify callback, const Pasteboard_Finalize finalize);
|
||||
int OH_PasteboardObserver_SetData(OH_PasteboardObserver *observer, void *context, const Pasteboard_Notify callback,
|
||||
const Pasteboard_Finalize finalize);
|
||||
|
||||
/**
|
||||
* @brief Represents the Pasteboard information.
|
||||
@ -146,7 +146,7 @@ typedef struct OH_Pasteboard OH_Pasteboard;
|
||||
* @see OH_Pasteboard.
|
||||
* @since 13
|
||||
*/
|
||||
OH_Pasteboard* OH_Pasteboard_Create();
|
||||
OH_Pasteboard *OH_Pasteboard_Create();
|
||||
|
||||
/**
|
||||
* @brief Destroy a {@link OH_Pasteboard} instance.
|
||||
@ -155,7 +155,7 @@ OH_Pasteboard* OH_Pasteboard_Create();
|
||||
* @see OH_Pasteboard.
|
||||
* @since 13
|
||||
*/
|
||||
void OH_Pasteboard_Destroy(OH_Pasteboard* pasteboard);
|
||||
void OH_Pasteboard_Destroy(OH_Pasteboard *pasteboard);
|
||||
|
||||
/**
|
||||
* @brief Subscribes to the Pasteboard data change.
|
||||
@ -170,7 +170,7 @@ void OH_Pasteboard_Destroy(OH_Pasteboard* pasteboard);
|
||||
* @see OH_Pasteboard OH_PasteboardObserver PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_Pasteboard_Subscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer);
|
||||
int OH_Pasteboard_Subscribe(OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribes from the Pasteboard data change.
|
||||
@ -185,7 +185,7 @@ int OH_Pasteboard_Subscribe(OH_Pasteboard* pasteboard, int type, const OH_Pasteb
|
||||
* @see OH_Pasteboard OH_PasteboardObserver PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_Pasteboard_Unsubscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer);
|
||||
int OH_Pasteboard_Unsubscribe(OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer);
|
||||
|
||||
/**
|
||||
* @brief Checks whether the Pasteboard data is from a remote device.
|
||||
@ -197,7 +197,7 @@ int OH_Pasteboard_Unsubscribe(OH_Pasteboard* pasteboard, int type, const OH_Past
|
||||
* @see OH_Pasteboard.
|
||||
* @since 13
|
||||
*/
|
||||
bool OH_Pasteboard_IsRemoteData(OH_Pasteboard* pasteboard);
|
||||
bool OH_Pasteboard_IsRemoteData(OH_Pasteboard *pasteboard);
|
||||
|
||||
/**
|
||||
* @brief Obtains the source of Pasteboard data.
|
||||
@ -211,7 +211,7 @@ bool OH_Pasteboard_IsRemoteData(OH_Pasteboard* pasteboard);
|
||||
* @see OH_Pasteboard PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_Pasteboard_GetDataSource(OH_Pasteboard* pasteboard, char* source, unsigned int len);
|
||||
int OH_Pasteboard_GetDataSource(OH_Pasteboard *pasteboard, char *source, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Checks whether the Pasteboard has the specified type of data.
|
||||
@ -224,7 +224,7 @@ int OH_Pasteboard_GetDataSource(OH_Pasteboard* pasteboard, char* source, unsigne
|
||||
* @see OH_Pasteboard.
|
||||
* @since 13
|
||||
*/
|
||||
bool OH_Pasteboard_HasType(OH_Pasteboard* pasteboard, const char* type);
|
||||
bool OH_Pasteboard_HasType(OH_Pasteboard *pasteboard, const char *type);
|
||||
|
||||
/**
|
||||
* @brief Checks whether there is data in the Pasteboard.
|
||||
@ -236,7 +236,7 @@ bool OH_Pasteboard_HasType(OH_Pasteboard* pasteboard, const char* type);
|
||||
* @see OH_Pasteboard.
|
||||
* @since 13
|
||||
*/
|
||||
bool OH_Pasteboard_HasData(OH_Pasteboard* pasteboard);
|
||||
bool OH_Pasteboard_HasData(OH_Pasteboard *pasteboard);
|
||||
|
||||
/**
|
||||
* @brief Obtains data from the Pasteboard.
|
||||
@ -247,7 +247,7 @@ bool OH_Pasteboard_HasData(OH_Pasteboard* pasteboard);
|
||||
* @see OH_Pasteboard OH_UdmfData PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
OH_UdmfData* OH_Pasteboard_GetData(OH_Pasteboard* pasteboard, int* status);
|
||||
OH_UdmfData *OH_Pasteboard_GetData(OH_Pasteboard *pasteboard, int *status);
|
||||
|
||||
/**
|
||||
* @brief Writes data to the Pasteboard.
|
||||
@ -260,7 +260,7 @@ OH_UdmfData* OH_Pasteboard_GetData(OH_Pasteboard* pasteboard, int* status);
|
||||
* @see OH_Pasteboard OH_UdmfData PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_Pasteboard_SetData(OH_Pasteboard* pasteboard, OH_UdmfData* data);
|
||||
int OH_Pasteboard_SetData(OH_Pasteboard *pasteboard, OH_UdmfData *data);
|
||||
|
||||
/**
|
||||
* @brief Clears the data in the Pastedboard.
|
||||
@ -272,7 +272,7 @@ int OH_Pasteboard_SetData(OH_Pasteboard* pasteboard, OH_UdmfData* data);
|
||||
* @see OH_Pasteboard PASTEBOARD_ErrCode.
|
||||
* @since 13
|
||||
*/
|
||||
int OH_Pasteboard_ClearData(OH_Pasteboard* pasteboard);
|
||||
int OH_Pasteboard_ClearData(OH_Pasteboard *pasteboard);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -16,22 +16,23 @@
|
||||
#define OH_PASTEBOARD_COMMON_H
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include "pasteboard_observer.h"
|
||||
|
||||
#include "oh_pasteboard.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "oh_pasteboard_err_code.h"
|
||||
#include "pasteboard_error.h"
|
||||
#include "pasteboard_observer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
const std::map<PasteboardError, PASTEBOARD_ErrCode> errCodeMap = {
|
||||
{PasteboardError::PERMISSION_VERIFICATION_ERROR, ERR_PERMISSION_ERROR},
|
||||
{PasteboardError::INVALID_PARAM_ERROR, ERR_INVALID_PARAMETER},
|
||||
{PasteboardError::TASK_PROCESSING, ERR_BUSY},
|
||||
{ PasteboardError::PERMISSION_VERIFICATION_ERROR, ERR_PERMISSION_ERROR },
|
||||
{ PasteboardError::INVALID_PARAM_ERROR, ERR_INVALID_PARAMETER },
|
||||
{ PasteboardError::TASK_PROCESSING, ERR_BUSY },
|
||||
};
|
||||
|
||||
class PasteboardObserverCapiImpl;
|
||||
}
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
enum PasteboardNdkStructId : std::int64_t {
|
||||
SUBSCRIBER_STRUCT_ID = 1002950,
|
||||
@ -41,7 +42,7 @@ enum PasteboardNdkStructId : std::int64_t {
|
||||
struct OH_Pasteboard {
|
||||
const int64_t cid = PASTEBOARD_STRUCT_ID;
|
||||
std::mutex mutex;
|
||||
std::map<const OH_PasteboardObserver*, OHOS::sptr<OHOS::MiscServices::PasteboardObserverCapiImpl>> observers_;
|
||||
std::map<const OH_PasteboardObserver *, OHOS::sptr<OHOS::MiscServices::PasteboardObserverCapiImpl>> observers_;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
@ -36,7 +36,6 @@
|
||||
* @since 13
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OH_PASTEBOARD_ERR_CODE_H
|
||||
#define OH_PASTEBOARD_ERR_CODE_H
|
||||
|
||||
|
@ -16,14 +16,15 @@
|
||||
#define OH_PASTEBOARD_OBSERVER_IMPL_H
|
||||
|
||||
#include <memory>
|
||||
#include "pasteboard_observer.h"
|
||||
|
||||
#include "oh_pasteboard_common.h"
|
||||
#include "pasteboard_observer.h"
|
||||
|
||||
struct OH_PasteboardObserver {
|
||||
const int64_t cid = SUBSCRIBER_STRUCT_ID;
|
||||
Pasteboard_Notify callback { nullptr };
|
||||
void* context { nullptr };
|
||||
Pasteboard_Finalize finalize { nullptr };
|
||||
Pasteboard_Notify callback{ nullptr };
|
||||
void *context{ nullptr };
|
||||
Pasteboard_Finalize finalize{ nullptr };
|
||||
};
|
||||
|
||||
namespace OHOS {
|
||||
@ -33,13 +34,14 @@ public:
|
||||
void OnPasteboardChanged() override;
|
||||
void SetType(Pasteboard_NotifyType type);
|
||||
Pasteboard_NotifyType GetType();
|
||||
void SetInnerObserver(const OH_PasteboardObserver* observer);
|
||||
void SetInnerObserver(const OH_PasteboardObserver *observer);
|
||||
|
||||
private:
|
||||
const OH_PasteboardObserver* innerObserver_;
|
||||
const OH_PasteboardObserver *innerObserver_;
|
||||
Pasteboard_NotifyType type_;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
/** @} */
|
||||
#endif
|
@ -237,4 +237,4 @@ int OH_Pasteboard_ClearData(OH_Pasteboard *pasteboard)
|
||||
}
|
||||
PasteboardClient::GetInstance()->Clear();
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace OHOS
|
@ -15,9 +15,9 @@
|
||||
|
||||
#define LOG_TAG "Pasteboard_Observer_Impl"
|
||||
|
||||
#include "oh_pasteboard_common.h"
|
||||
#include "oh_pasteboard_observer_impl.h"
|
||||
#include "pasteboard_hilog.h"
|
||||
#include "oh_pasteboard_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
@ -40,9 +40,9 @@ Pasteboard_NotifyType PasteboardObserverCapiImpl::GetType()
|
||||
return type_;
|
||||
}
|
||||
|
||||
void PasteboardObserverCapiImpl::SetInnerObserver(const OH_PasteboardObserver* innerObserver)
|
||||
void PasteboardObserverCapiImpl::SetInnerObserver(const OH_PasteboardObserver *innerObserver)
|
||||
{
|
||||
innerObserver_ = innerObserver;
|
||||
}
|
||||
}
|
||||
} // namespace MiscServices
|
||||
}
|
@ -20,17 +20,8 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum class PasteboardEventStatus {
|
||||
PASTEBOARD_CLEAR = 1,
|
||||
PASTEBOARD_READ = 2,
|
||||
PASTEBOARD_WRITE = 3
|
||||
};
|
||||
enum class PasteboardObserverType {
|
||||
OBSERVER_LOCAL = 1,
|
||||
OBSERVER_REMOTE = 2,
|
||||
OBSERVER_ALL = 3,
|
||||
OBSERVER_EVENT = 4
|
||||
};
|
||||
enum class PasteboardEventStatus { PASTEBOARD_CLEAR = 1, PASTEBOARD_READ = 2, PASTEBOARD_WRITE = 3 };
|
||||
enum class PasteboardObserverType { OBSERVER_LOCAL = 1, OBSERVER_REMOTE = 2, OBSERVER_ALL = 3, OBSERVER_EVENT = 4 };
|
||||
class IPasteboardChangedObserver : public IRemoteBroker {
|
||||
public:
|
||||
virtual void OnPasteboardChanged() = 0;
|
||||
|
@ -35,21 +35,21 @@
|
||||
#include "common/block_object.h"
|
||||
#include "common/concurrent_map.h"
|
||||
#include "distributed_module_config.h"
|
||||
#include "eventcenter/event_center.h"
|
||||
#include "pasteboard_switch.h"
|
||||
#include "event_handler.h"
|
||||
#include "iremote_object.h"
|
||||
#include "eventcenter/event_center.h"
|
||||
#include "ffrt_utils.h"
|
||||
#include "i_pasteboard_delay_getter.h"
|
||||
#include "i_pasteboard_observer.h"
|
||||
#include "pasteboard_common_event_subscriber.h"
|
||||
#include "input_manager.h"
|
||||
#include "iremote_object.h"
|
||||
#include "paste_data.h"
|
||||
#include "pasteboard_common_event_subscriber.h"
|
||||
#include "pasteboard_dump_helper.h"
|
||||
#include "pasteboard_service_stub.h"
|
||||
#include "system_ability.h"
|
||||
#include "pasteboard_switch.h"
|
||||
#include "privacy_kit.h"
|
||||
#include "input_manager.h"
|
||||
#include "ffrt_utils.h"
|
||||
#include "security_level.h"
|
||||
#include "system_ability.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
@ -87,6 +87,7 @@ public:
|
||||
void OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const override;
|
||||
bool IsCtrlVProcess(uint32_t callingPid, bool isFocused);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
static constexpr uint32_t EVENT_TIME_OUT = 2000;
|
||||
mutable int32_t windowPid_;
|
||||
@ -110,10 +111,10 @@ public:
|
||||
virtual bool HasDataType(const std::string &mimeType) override;
|
||||
virtual std::set<Pattern> DetectPatterns(const std::set<Pattern> &patternsToCheck) override;
|
||||
virtual int32_t GetDataSource(std::string &bundleNme) override;
|
||||
virtual void SubscribeObserver(PasteboardObserverType type,
|
||||
const sptr<IPasteboardChangedObserver> &observer) override;
|
||||
virtual void UnsubscribeObserver(PasteboardObserverType type,
|
||||
const sptr<IPasteboardChangedObserver> &observer) override;
|
||||
virtual void SubscribeObserver(
|
||||
PasteboardObserverType type, const sptr<IPasteboardChangedObserver> &observer) override;
|
||||
virtual void UnsubscribeObserver(
|
||||
PasteboardObserverType type, const sptr<IPasteboardChangedObserver> &observer) override;
|
||||
virtual void UnsubscribeAllObserver(PasteboardObserverType type) override;
|
||||
virtual int32_t SetGlobalShareOption(const std::map<uint32_t, ShareOption> &globalShareOptions) override;
|
||||
virtual int32_t RemoveGlobalShareOption(const std::vector<uint32_t> &tokenIds) override;
|
||||
@ -156,7 +157,8 @@ private:
|
||||
public:
|
||||
explicit DelayGetterDeathRecipient(int32_t userId, PasteboardService &service);
|
||||
virtual ~DelayGetterDeathRecipient() = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
|
||||
|
||||
private:
|
||||
int32_t userId_ = ERROR_USERID;
|
||||
PasteboardService &service_;
|
||||
@ -166,7 +168,8 @@ private:
|
||||
public:
|
||||
explicit EntryGetterDeathRecipient(int32_t userId, PasteboardService &service);
|
||||
virtual ~EntryGetterDeathRecipient() = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
|
||||
|
||||
private:
|
||||
int32_t userId_ = ERROR_USERID;
|
||||
PasteboardService &service_;
|
||||
@ -176,14 +179,15 @@ private:
|
||||
public:
|
||||
struct TaskContext {
|
||||
std::atomic<bool> pasting_ = false;
|
||||
ConcurrentMap<uint32_t, std::shared_ptr<BlockObject<bool>>> getDataBlocks_;
|
||||
std::shared_ptr<PasteDateTime> data_;
|
||||
ConcurrentMap<uint32_t, std::shared_ptr<BlockObject<bool>>> getDataBlocks_;
|
||||
std::shared_ptr<PasteDateTime> data_;
|
||||
};
|
||||
using DataTask = std::pair<std::shared_ptr<PasteboardService::RemoteDataTaskManager::TaskContext>, bool>;
|
||||
DataTask GetRemoteDataTask(const Event &event);
|
||||
void Notify(const Event &event, std::shared_ptr<PasteDateTime> data);
|
||||
void ClearRemoteDataTask(const Event &event);
|
||||
std::shared_ptr<PasteDateTime> WaitRemoteData(const Event &event);
|
||||
|
||||
private:
|
||||
std::atomic<uint32_t> mapKey_ = 0;
|
||||
std::mutex mutex_;
|
||||
@ -208,20 +212,18 @@ private:
|
||||
void InitServiceHandler();
|
||||
bool IsCopyable(uint32_t tokenId) const;
|
||||
|
||||
int32_t SavePasteData(std::shared_ptr<PasteData> &pasteData,
|
||||
sptr<IPasteboardDelayGetter> delayGetter = nullptr,
|
||||
int32_t SavePasteData(std::shared_ptr<PasteData> &pasteData, sptr<IPasteboardDelayGetter> delayGetter = nullptr,
|
||||
sptr<IPasteboardEntryGetter> entryGetter = nullptr) override;
|
||||
int32_t SaveData(std::shared_ptr<PasteData>& pasteData,
|
||||
sptr<IPasteboardDelayGetter> delayGetter = nullptr,
|
||||
int32_t SaveData(std::shared_ptr<PasteData> &pasteData, sptr<IPasteboardDelayGetter> delayGetter = nullptr,
|
||||
sptr<IPasteboardEntryGetter> entryGetter = nullptr);
|
||||
void HandleDelayDataAndRecord(std::shared_ptr<PasteData> &pasteData,
|
||||
sptr<IPasteboardDelayGetter> delayGetter, sptr<IPasteboardEntryGetter> entryGetter, const AppInfo& appInfo);
|
||||
void HandleDelayDataAndRecord(std::shared_ptr<PasteData> &pasteData, sptr<IPasteboardDelayGetter> delayGetter,
|
||||
sptr<IPasteboardEntryGetter> entryGetter, const AppInfo &appInfo);
|
||||
int32_t PreParePasteData(std::shared_ptr<PasteData> &pasteData, const AppInfo &appInfo);
|
||||
void RemovePasteData(const AppInfo &appInfo);
|
||||
void SetPasteDataDot(PasteData &pasteData);
|
||||
std::pair<bool, ClipPlugin::GlobalEvent> GetValidDistributeEvent(int32_t user);
|
||||
int32_t GetSdkVersion(uint32_t tokenId);
|
||||
bool IsPermissionGranted(const std::string& perm, uint32_t tokenId);
|
||||
bool IsPermissionGranted(const std::string &perm, uint32_t tokenId);
|
||||
int32_t GetData(uint32_t tokenId, PasteData &data, int32_t &syncTime);
|
||||
|
||||
void GetPasteDataDot(PasteData &pasteData, const std::string &bundleName);
|
||||
@ -239,8 +241,8 @@ private:
|
||||
void CheckAppUriPermission(PasteData &data);
|
||||
std::string GetAppLabel(uint32_t tokenId);
|
||||
sptr<OHOS::AppExecFwk::IBundleMgr> GetAppBundleManager();
|
||||
void EstablishP2PLink(const std::string& networkId, const std::string &pasteId);
|
||||
void CloseP2PLink(const std::string& networkId);
|
||||
void EstablishP2PLink(const std::string &networkId, const std::string &pasteId);
|
||||
void CloseP2PLink(const std::string &networkId);
|
||||
uint8_t GenerateDataType(PasteData &data);
|
||||
bool HasDistributedDataType(const std::string &mimeType);
|
||||
|
||||
@ -293,13 +295,8 @@ private:
|
||||
static std::shared_ptr<Command> copyData;
|
||||
std::atomic<bool> setting_ = false;
|
||||
std::map<int32_t, ServiceListenerFunc> ServiceListenerFunc_;
|
||||
std::map<std::string, int> typeMap_ = {
|
||||
{ MIMETYPE_TEXT_PLAIN, PLAIN_INDEX },
|
||||
{ MIMETYPE_TEXT_HTML, HTML_INDEX },
|
||||
{ MIMETYPE_TEXT_URI, URI_INDEX },
|
||||
{ MIMETYPE_TEXT_WANT, WANT_INDEX },
|
||||
{ MIMETYPE_PIXELMAP, PIXELMAP_INDEX }
|
||||
};
|
||||
std::map<std::string, int> typeMap_ = { { MIMETYPE_TEXT_PLAIN, PLAIN_INDEX }, { MIMETYPE_TEXT_HTML, HTML_INDEX },
|
||||
{ MIMETYPE_TEXT_URI, URI_INDEX }, { MIMETYPE_TEXT_WANT, WANT_INDEX }, { MIMETYPE_PIXELMAP, PIXELMAP_INDEX } };
|
||||
|
||||
std::shared_ptr<FFRTTimer> ffrtTimer_;
|
||||
ConcurrentMap<std::string, ConcurrentMap<std::string, int32_t>> p2pMap_;
|
||||
@ -307,8 +304,8 @@ private:
|
||||
PastedSwitch switch_;
|
||||
|
||||
void AddObserver(int32_t userId, const sptr<IPasteboardChangedObserver> &observer, ObserverMap &observerMap);
|
||||
void RemoveSingleObserver(int32_t userId, const sptr<IPasteboardChangedObserver> &observer,
|
||||
ObserverMap &observerMap);
|
||||
void RemoveSingleObserver(
|
||||
int32_t userId, const sptr<IPasteboardChangedObserver> &observer, ObserverMap &observerMap);
|
||||
void RemoveAllObserver(int32_t userId, ObserverMap &observerMap);
|
||||
inline bool IsCallerUidValid();
|
||||
bool HasLocalDataType(const std::string &mimeType);
|
||||
@ -324,7 +321,7 @@ private:
|
||||
DistributedModuleConfig moduleConfig_;
|
||||
std::vector<std::string> bundles_;
|
||||
int32_t uid_ = -1;
|
||||
RemoteDataTaskManager taskMgr_;
|
||||
RemoteDataTaskManager taskMgr_;
|
||||
pid_t setPasteDataUId_ = 0;
|
||||
static constexpr const pid_t TESE_SERVER_UID = 3500;
|
||||
std::mutex eventMutex_;
|
||||
|
@ -13,28 +13,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "pasteboard_pattern.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "pasteboard_pattern.h"
|
||||
|
||||
namespace OHOS::MiscServices {
|
||||
std::map<uint32_t, std::string> PatternDetection::patterns_{
|
||||
{ static_cast<uint32_t>(Pattern::URL), std::string("[a-zA-Z0-9+.-]+://[-a-zA-Z0-9+&@#/%?"
|
||||
"=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_]")},
|
||||
{ static_cast<uint32_t>(Pattern::Number), std::string("[-+]?[0-9]*\\.?[0-9]+")},
|
||||
"=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_]") },
|
||||
{ static_cast<uint32_t>(Pattern::Number), std::string("[-+]?[0-9]*\\.?[0-9]+") },
|
||||
{ static_cast<uint32_t>(Pattern::EmailAddress), std::string("(([a-zA-Z0-9_\\-\\.]+)@"
|
||||
"((?:\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\])|"
|
||||
"([a-zA-Z0-9\\-]+(?:\\.[a-zA-Z0-9\\-]+)*))"
|
||||
"([a-zA-Z]{2,}|[0-9]{1,3}))")},
|
||||
"((?:\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\])|"
|
||||
"([a-zA-Z0-9\\-]+(?:\\.[a-zA-Z0-9\\-]+)*))"
|
||||
"([a-zA-Z]{2,}|[0-9]{1,3}))") },
|
||||
};
|
||||
|
||||
const std::set<Pattern> PatternDetection::Detect(const std::set<Pattern> &patternsToCheck,
|
||||
const PasteData &pasteData, bool hasHTML, bool hasPlain)
|
||||
const std::set<Pattern> PatternDetection::Detect(
|
||||
const std::set<Pattern> &patternsToCheck, const PasteData &pasteData, bool hasHTML, bool hasPlain)
|
||||
{
|
||||
std::set<Pattern> existedPatterns;
|
||||
for (auto& record : pasteData.AllRecords()) {
|
||||
for (auto &record : pasteData.AllRecords()) {
|
||||
if (patternsToCheck == existedPatterns) {
|
||||
break;
|
||||
}
|
||||
@ -60,8 +60,8 @@ bool PatternDetection::IsValid(const std::set<Pattern> &patterns)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PatternDetection::DetectPlainText(std::set<Pattern> &patternsOut,
|
||||
const std::set<Pattern> &patternsIn, const std::string &plainText)
|
||||
void PatternDetection::DetectPlainText(
|
||||
std::set<Pattern> &patternsOut, const std::set<Pattern> &patternsIn, const std::string &plainText)
|
||||
{
|
||||
for (Pattern pattern : patternsIn) {
|
||||
if (patternsOut.find(pattern) != patternsOut.end()) {
|
||||
@ -99,7 +99,7 @@ std::string PatternDetection::ExtractHtmlContent(const std::string &html_str)
|
||||
xmlFreeDoc(doc);
|
||||
return "";
|
||||
}
|
||||
std::string result(reinterpret_cast<const char*>(xmlStr));
|
||||
std::string result(reinterpret_cast<const char *>(xmlStr));
|
||||
xmlFree(xmlStr);
|
||||
xmlFreeDoc(doc);
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user