1 /*
2 * Copyright (c) 2023 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 #include "allowed_install_bundles_plugin.h"
17
18 #include "array_string_serializer.h"
19 #include "edm_ipc_interface_code.h"
20 #include "iplugin_manager.h"
21
22 namespace OHOS {
23 namespace EDM {
24 const bool REGISTER_RESULT = IPluginManager::GetInstance()->AddPlugin(AllowedInstallBundlesPlugin::GetPlugin());
25
InitPlugin(std::shared_ptr<IPluginTemplate<AllowedInstallBundlesPlugin,std::vector<std::string>>> ptr)26 void AllowedInstallBundlesPlugin::InitPlugin(
27 std::shared_ptr<IPluginTemplate<AllowedInstallBundlesPlugin, std::vector<std::string>>> ptr)
28 {
29 EDMLOGD("AllowedInstallBundlesPlugin InitPlugin...");
30 ptr->InitAttribute(EdmInterfaceCode::ALLOWED_INSTALL_BUNDLES, "allowed_install_bundles",
31 "ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY", IPlugin::PermissionType::SUPER_DEVICE_ADMIN, true);
32 ptr->SetSerializer(ArrayStringSerializer::GetInstance());
33 ptr->SetOnHandlePolicyListener(&AllowedInstallBundlesPlugin::OnSetPolicy, FuncOperateType::SET);
34 ptr->SetOnHandlePolicyListener(&AllowedInstallBundlesPlugin::OnRemovePolicy, FuncOperateType::REMOVE);
35 ptr->SetOnAdminRemoveDoneListener(&AllowedInstallBundlesPlugin::OnAdminRemoveDone);
36 SetAppInstallControlRuleType(AppExecFwk::AppInstallControlRuleType::ALLOWED_INSTALL);
37 }
38
OnGetPolicy(std::string & policyData,MessageParcel & data,MessageParcel & reply,int32_t userId)39 ErrCode AllowedInstallBundlesPlugin::OnGetPolicy(std::string &policyData, MessageParcel &data, MessageParcel &reply,
40 int32_t userId)
41 {
42 EDMLOGI("AllowedInstallBundlesPlugin OnGetPolicy policyData : %{public}s, userId : %{public}d", policyData.c_str(),
43 userId);
44 return GetBundlePolicy(policyData, data, reply, userId);
45 }
46 } // namespace EDM
47 } // namespace OHOS
48