!6134 Fix window manager fuzz test

Merge pull request !6134 from wangjian10/master
This commit is contained in:
openharmony_ci 2024-05-06 11:52:42 +00:00 committed by Gitee
commit d259a7ca27
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -117,21 +117,31 @@ bool DoSomethingForWindowManagerImpl(WindowManager& windowManager, const uint8_t
void CheckAccessibilityWindowInfo(WindowManager& windowManager, const uint8_t* data, size_t size)
{
Parcel accessibilityWindowInfosParcel;
if (accessibilityWindowInfosParcel.WriteBuffer(data, size)) {
std::vector<sptr<AccessibilityWindowInfo>> windowInfos;
MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(accessibilityWindowInfosParcel,
windowInfos);
windowManager.GetAccessibilityWindowInfo(windowInfos);
WindowUpdateType type;
GetObject<WindowUpdateType>(type, data, size);
windowManager.NotifyAccessibilityWindowInfo(windowInfos, type);
if (!accessibilityWindowInfosParcel.WriteBuffer(data, size)) {
return;
}
std::vector<sptr<AccessibilityWindowInfo>> windowInfos;
if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(
accessibilityWindowInfosParcel, windowInfos)) {
return;
}
windowManager.GetAccessibilityWindowInfo(windowInfos);
WindowUpdateType type;
GetObject<WindowUpdateType>(type, data, size);
windowManager.NotifyAccessibilityWindowInfo(windowInfos, type);
}
void CheckVisibilityInfo(WindowManager& windowManager, const uint8_t* data, size_t size)
{
Parcel windowVisibilityInfosParcel;
windowVisibilityInfosParcel.WriteBuffer(data, size);
if (!windowVisibilityInfosParcel.WriteBuffer(data, size)) {
return;
}
std::vector<sptr<WindowVisibilityInfo>> visibilitynfos;
MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(windowVisibilityInfosParcel,
visibilitynfos);
if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(windowVisibilityInfosParcel,
visibilitynfos)) {
return;
}
windowManager.GetVisibilityWindowInfo(visibilitynfos);
windowManager.UpdateWindowVisibilityInfo(visibilitynfos);
bool enable = false;
@ -140,11 +150,9 @@ void CheckAccessibilityWindowInfo(WindowManager& windowManager, const uint8_t* d
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
if (data == nullptr || size < DATA_MIN_SIZE) {
return false;
}
WindowManager& windowManager = WindowManager::GetInstance();
CheckAccessibilityWindowInfo(windowManager, data, size);
CheckVisibilityInfo(windowManager, data, size);
Parcel focusChangeInfoParcel;
if (focusChangeInfoParcel.WriteBuffer(data, size)) {
FocusChangeInfo::Unmarshalling(focusChangeInfoParcel);
@ -195,6 +203,9 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr || size < OHOS::DATA_MIN_SIZE) {
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(data, size);
return 0;
}