• 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_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_RDB_H
17 #define FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_RDB_H
18 
19 #include "app_control_manager_db_interface.h"
20 
21 #include "rdb_data_manager.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class AppControlManagerRdb : public IAppControlManagerDb {
26 public:
27     AppControlManagerRdb();
28     ~AppControlManagerRdb();
29 
30     virtual ErrCode AddAppInstallControlRule(const std::string &callingName, const std::vector<std::string> &appIds,
31         const std::string &controlRuleType, int32_t userId) override;
32     virtual ErrCode DeleteAppInstallControlRule(const std::string &callingName, const std::string &controlRuleType,
33         const std::vector<std::string> &appIds, int32_t userId) override;
34     virtual ErrCode DeleteAppInstallControlRule(const std::string &callingName, const std::string &controlRuleType,
35         int32_t userId) override;
36     virtual ErrCode GetAppInstallControlRule(const std::string &callingName,
37         const std::string &controlRuleType, int32_t userId, std::vector<std::string> &appIds) override;
38 
39     virtual ErrCode AddAppRunningControlRule(const std::string &callingName,
40         const std::vector<AppRunningControlRule> &controlRules, int32_t userId) override;
41     virtual ErrCode DeleteAppRunningControlRule(const std::string &callingName,
42         const std::vector<AppRunningControlRule> &controlRules, int32_t userId) override;
43     virtual ErrCode DeleteAppRunningControlRule(const std::string &callingName, int32_t userId) override;
44     virtual ErrCode GetAppRunningControlRule(const std::string &callingName,
45         int32_t userId, std::vector<std::string> &appIds) override;
46     virtual ErrCode GetAppRunningControlRule(const std::string &appId,
47         int32_t userId, AppRunningControlRuleResult &controlRuleResult) override;
48 
49     virtual ErrCode SetDisposedStatus(const std::string &callingName,
50         const std::string &appId, const Want& want, int32_t userId) override;
51     virtual ErrCode DeleteDisposedStatus(const std::string &callingName,
52         const std::string &appId, int32_t userId) override;
53     virtual ErrCode GetDisposedStatus(const std::string &callingName,
54         const std::string &appId, Want& want, int32_t userId) override;
55     virtual ErrCode SetDisposedRule(const std::string &callingName,
56         const std::string &appId, const DisposedRule& rule, int32_t appIndex, int32_t userId) override;
57     virtual ErrCode GetDisposedRule(const std::string &callingName,
58         const std::string &appId, DisposedRule& rule, int32_t appIndex, int32_t userId) override;
59     virtual ErrCode DeleteDisposedRule(const std::string &callingName,
60         const std::vector<std::string> &appIdList, int32_t appIndex, int32_t userId) override;
61     virtual ErrCode DeleteAllDisposedRuleByBundle(const std::vector<std::string> &appIdList,
62         int32_t appIndex, int32_t userId) override;
63     virtual ErrCode GetAbilityRunningControlRule(const std::vector<std::string> &appIdList, int32_t appIndex,
64         int32_t userId, std::vector<DisposedRule>& disposedRules) override;
65 
66     virtual ErrCode SetUninstallDisposedRule(const std::string &callingName, const std::string &appIdentifier,
67         const UninstallDisposedRule &rule, int32_t appIndex, int32_t userId) override;
68     virtual ErrCode DeleteUninstallDisposedRule(const std::string &callingName, const std::string &appIdentifier,
69         int32_t appIndex, int32_t userId) override;
70     virtual ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex,
71         int32_t userId, UninstallDisposedRule &rule) override;
72 
73 private:
74     ErrCode DeleteOldControlRule(const std::string &callingName, const std::string &controlRuleType,
75         const std::string &appId, int32_t userId);
76     ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId,
77         int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates);
78     ErrCode GetDisposedRuleFromResultSet(
79         std::shared_ptr<NativeRdb::ResultSet> absSharedResultSet, std::vector<DisposedRule> &disposedRules);
80     std::shared_ptr<RdbDataManager> rdbDataManager_;
81 };
82 } // namespace AppExecFwk
83 } // namespace OHOS
84 #endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_RDB_H