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::string &appId, int32_t appIndex, int32_t userId) override; 61 virtual ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t appIndex, int32_t userId) override; 62 virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t appIndex, int32_t userId, 63 std::vector<DisposedRule>& disposedRules) override; 64 65 private: 66 ErrCode DeleteOldControlRule(const std::string &callingName, const std::string &controlRuleType, 67 const std::string &appId, int32_t userId); 68 ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId, 69 int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates); 70 void PrintDisposedRuleInfo(const std::shared_ptr<NativeRdb::ResultSet> absSharedResultSet, 71 const DisposedRule &rule); 72 std::shared_ptr<RdbDataManager> rdbDataManager_; 73 }; 74 } // namespace AppExecFwk 75 } // namespace OHOS 76 #endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_RDB_H