• 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 #ifndef OHOS_FORM_FWK_REFRESH_CONTROL_MGR_H
17 #define OHOS_FORM_FWK_REFRESH_CONTROL_MGR_H
18 
19 #include <singleton.h>
20 
21 #include "data_center/form_record/form_record.h"
22 #include "form_constants.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 /**
27 * @class RefreshControlMgr
28 * RefreshControlMgr is used to check form refresh be controlled.
29 */
30 class RefreshControlMgr : public DelayedRefSingleton<RefreshControlMgr> {
31     DECLARE_DELAYED_REF_SINGLETON(RefreshControlMgr);
32 public:
33     DISALLOW_COPY_AND_MOVE(RefreshControlMgr);
34 
35 #ifdef RES_SCHEDULE_ENABLE
36     /**
37      * @brief Set the system load exceeding the refresh limit flag.
38      * @param flag The value of whether Refresh Timer task should be controlled.
39      */
40     void SetSystemOverloadFlag(bool flag);
41 #endif
42 
43     /**
44      * @brief Whether the system load exceeding the refresh limit.
45      */
46     bool IsSystemOverload();
47 
48     /**
49      * @brief Whether the refresh form is invisible.
50      */
51     bool IsFormInvisible(const FormRecord &record);
52 
53     /**
54      * @brief Whether the device screen off.
55      */
56     bool IsScreenOff(const FormRecord &record);
57 
58     /**
59      * @brief Whether The application corresponding to the form is under health control.
60      */
61     bool IsHealthyControl(const FormRecord &record);
62 
63     /**
64      * @brief Whether the form need fresh.
65      */
66     bool IsNeedToFresh(FormRecord &record, bool isVisibleToFresh);
67 
68 private:
69 #ifdef RES_SCHEDULE_ENABLE
70     bool isSystemOverload_ = false;
71 #endif
72 };
73 } // namespace AppExecFwk
74 } // namespace OHOS
75 
76 #endif // OHOS_FORM_FWK_REFRESH_CONTROL_MGR_H