• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <memory>
17 #include <optional>
18 #include <utility>
19 
20 #include "pointer_event.h"
21 #include "stopdrag_fuzzer.h"
22 
23 #include "devicestatus_define.h"
24 #include "drag_data.h"
25 #include "fi_log.h"
26 #include "interaction_manager.h"
27 
28 namespace OHOS {
29 namespace Msdp {
30 namespace DeviceStatus {
31 namespace {
32 constexpr bool HAS_CUSTOM_ANIMATION { true };
33 constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "StopDragFuzzTest" };
34 } // namespace
35 
StopDragFuzzTest(const uint8_t * data,size_t size)36 void StopDragFuzzTest(const uint8_t* data, size_t  size)
37 {
38     CALL_DEBUG_ENTER;
39     if (data == nullptr) {
40         return;
41     }
42     int32_t result = *(reinterpret_cast<const int32_t*>(data));
43     InteractionManager::GetInstance()->StopDrag(static_cast<DragResult>(result), HAS_CUSTOM_ANIMATION);
44 }
45 } // namespace DeviceStatus
46 } // namespace Msdp
47 } // namespace OHOS
48 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)49 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
50 {
51     if (size < sizeof(int32_t)) {
52         return 0;
53     }
54     OHOS::Msdp::DeviceStatus::StopDragFuzzTest(data, size);
55     return 0;
56 }
57 
58