• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /* This files contains faultlog fuzzer test modules. */
17 
18 #define FUZZ_PROJECT_NAME "displaycoverage_fuzzer"
19 
20 #include "display_power_mgr_service.h"
21 #include "displaycoverage_fuzzer_test.h"
22 
23 using namespace OHOS::DisplayPowerMgr;
24 
25 namespace {
26 const uint32_t DISPLAY_ID = 0;
27 const uint32_t BRIGHTNESS_MAX = 300;
28 const uint32_t BRIGHTNESS_MIN = 0;
29 const double DISCOUNT_MAX = 1.05;
30 const double DISCOUNT_MIN = 0.01;
31 const uint32_t brightness = 1;
32 } //namespace
33 
34 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)35 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
36 {
37     OHOS::sptr<OHOS::DisplayPowerMgr::DisplayPowerMgrService> service =
38         DelayedSpSingleton<DisplayPowerMgrService>::GetInstance();
39     service->Init();
40     DisplayState state = DisplayState::DISPLAY_OFF;
41     uint32_t reason = 1;
42     service->NotifyStateChangeCallback(DISPLAY_ID, state, reason);
43     service->HandleBootBrightness();
44     bool result = false;
45     service->SetScreenOnBrightness(result);
46     service->GetSafeBrightness(BRIGHTNESS_MAX);
47     service->GetSafeBrightness(BRIGHTNESS_MIN);
48     service->GetSafeDiscount(DISCOUNT_MAX, brightness);
49     service->GetSafeDiscount(DISCOUNT_MIN, brightness);
50     return 0;
51 }
52