• 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_HOST_IMPL_H
17 #define FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_HOST_IMPL_H
18 
19 #include "app_control_host.h"
20 #include "app_control_manager.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 class AppControlManagerHostImpl : public OHOS::AppExecFwk::AppControlHost {
25 public:
26     AppControlManagerHostImpl();
27     virtual ~AppControlManagerHostImpl();
28 
29     virtual ErrCode AddAppInstallControlRule(const std::vector<std::string> &appIds,
30         const AppInstallControlRuleType controlRuleType, int32_t userId) override;
31 
32     virtual ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType,
33         const std::vector<std::string> &appIds, int32_t userId) override;
34 
35     virtual ErrCode DeleteAppInstallControlRule(
36         const AppInstallControlRuleType controlRuleType, int32_t userId) override;
37 
38     virtual ErrCode GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId,
39         std::vector<std::string> &appIds) override;
40 
41     // for app running control rule
42     virtual ErrCode AddAppRunningControlRule(
43         const std::vector<AppRunningControlRule> &controlRules, int32_t userId) override;
44     virtual ErrCode DeleteAppRunningControlRule(
45         const std::vector<AppRunningControlRule> &controlRules, int32_t userId) override;
46     virtual ErrCode DeleteAppRunningControlRule(int32_t userId) override;
47     virtual ErrCode GetAppRunningControlRule(int32_t userId, std::vector<std::string> &appIds) override;
48     virtual ErrCode GetAppRunningControlRule(
49         const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRule) override;
50 
51     virtual ErrCode SetDisposedStatus(const std::string &appId, const Want &want) override;
52 
53     virtual ErrCode DeleteDisposedStatus(const std::string &appId) override;
54 
55     virtual ErrCode GetDisposedStatus(const std::string &appId, Want &want) override;
56 private:
57     int32_t GetCallingUserId();
58     std::string GetCallingName();
59     std::string GetControlRuleType(const AppInstallControlRuleType controlRuleType);
60     std::unordered_map<int32_t, std::string> callingNameMap_;
61     std::unordered_map<AppInstallControlRuleType, std::string> ruleTypeMap_;
62     std::shared_ptr<AppControlManager> appControlManager_ = nullptr;
63 };
64 }
65 }
66 #endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_HOST_IMPL_H
67