• 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_HANDLER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_AGING_HANDLER_H
18 
19 #include <cinttypes>
20 #include <string>
21 #include <vector>
22 
23 #include "aging_request.h"
24 #include "bundle_util.h"
25 #include "status_receiver_host.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
29 class AgingHandler {
30 public:
31     AgingHandler() = default;
32     virtual ~AgingHandler() = default;
33     virtual bool Process(AgingRequest &request) const = 0;
34     virtual const std::string &GetName() const = 0;
35 };
36 
37 class RecentlyUnuseBundleAgingHandler : public AgingHandler {
38 public:
39     RecentlyUnuseBundleAgingHandler() = default;
40     virtual ~RecentlyUnuseBundleAgingHandler() = default;
41     virtual bool Process(AgingRequest &request) const override;
42     virtual bool CheckBundle(const AgingBundleInfo &bundle) const = 0;
43     virtual bool NeedContinue(const AgingRequest &request) const;
44 
45 private:
46     bool UnInstallBundle(const std::string &bundleName) const;
47 };
48 
49 class Over30DaysUnusedBundleAgingHandler : public RecentlyUnuseBundleAgingHandler {
50 public:
51     bool CheckBundle(const AgingBundleInfo &bundle) const override;
52     const std::string &GetName() const override;
53 };
54 
55 class Over20DaysUnusedBundleAgingHandler : public RecentlyUnuseBundleAgingHandler {
56 public:
57     bool CheckBundle(const AgingBundleInfo &bundle) const override;
58     const std::string &GetName() const override;
59 };
60 
61 class Over10DaysUnusedBundleAgingHandler : public RecentlyUnuseBundleAgingHandler {
62 public:
63     bool CheckBundle(const AgingBundleInfo &bundle) const override;
64     const std::string &GetName() const override;
65 };
66 
67 class BundleDataSizeAgingHandler : public RecentlyUnuseBundleAgingHandler {
68 public:
69     bool CheckBundle(const AgingBundleInfo &bundle) const override;
70     const std::string &GetName() const override;
71 };
72 
73 class AgingUninstallReceiveImpl : public StatusReceiverHost {
74 public:
75     AgingUninstallReceiveImpl() = default;
76     virtual ~AgingUninstallReceiveImpl() override = default;
OnStatusNotify(const int progress)77     virtual void OnStatusNotify(const int progress) override
78     {
79     }
OnFinished(const int32_t resultCode,const std::string & resultMsg)80     virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) override
81     {
82     }
83 };
84 }  //  namespace AppExecFwk
85 }  //  namespace OHOS
86 #endif  //  FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_AGING_HANDLER_H
87