• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_AGING_REQUEST_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_AGING_REQUEST_H
18 
19 #include <vector>
20 
21 #include "aging_bundle_info.h"
22 #include "aging_util.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 class AgingRequest {
27 public:
28     AgingRequest();
29     bool IsReachStartAgingThreshold() const;
30     bool IsReachEndAgingThreshold() const;
GetAgingBundles()31     const std::vector<AgingBundleInfo> &GetAgingBundles() const
32     {
33         return agingBundles;
34     };
35     void AddAgingBundle(AgingBundleInfo &bundleInfo);
SortAgingBundles()36     size_t SortAgingBundles()
37     {
38         AgingUtil::SortAgingBundles(agingBundles);
39         return agingBundles.size();
40     };
UpdateTotalDataBytesAfterUninstalled(const int64_t dataBytes)41     void UpdateTotalDataBytesAfterUninstalled(const int64_t dataBytes)
42     {
43         tatalDataBytes -= dataBytes;
44     };
GetTotalDataBytes()45     int64_t GetTotalDataBytes() const
46     {
47         return tatalDataBytes;
48     };
SetTotalDataBytes(const int64_t allBundleDataBytes)49     void SetTotalDataBytes(const int64_t allBundleDataBytes)
50     {
51         tatalDataBytes = allBundleDataBytes;
52     };
53     void RequestReset();
54 
55 public:
GetTotalDataBytesThreshold()56     static int64_t GetTotalDataBytesThreshold()
57     {
58         return totalDataBytesThreshold;
59     };
GetOneDayTimeMs()60     static int64_t GetOneDayTimeMs()
61     {
62         return oneDayTimeMs;
63     };
64 
65 private:
66     void InitAgingPolicySystemParameters();
67     void InitAgingDatasizeThreshold();
68     void InitAgingOneDayTimeMs();
69     std::vector<AgingBundleInfo> agingBundles;
70     int64_t tatalDataBytes = 0;
71 
72 private:
73     static int64_t totalDataBytesThreshold;
74     static int64_t oneDayTimeMs;
75 };
76 }  //  namespace AppExecFwk
77 }  //  namespace OHOS
78 
79 #endif  //  FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_AGING_REQUEST_H
80