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 #include "iplugin.h"
17 #include <string_ex.h>
18 #include "policy_manager.h"
19
20 namespace OHOS {
21 namespace EDM {
GetPolicyName()22 std::string IPlugin::GetPolicyName()
23 {
24 return policyName_;
25 }
26
NeedSavePolicy()27 bool IPlugin::NeedSavePolicy()
28 {
29 return needSave_;
30 }
31
IsGlobalPolicy()32 bool IPlugin::IsGlobalPolicy()
33 {
34 return isGlobal_;
35 }
36
GetPermission()37 std::string IPlugin::GetPermission()
38 {
39 return permission_;
40 }
41
GetCode()42 std::uint32_t IPlugin::GetCode()
43 {
44 return policyCode_;
45 }
46
MergePolicyData(const std::string & adminName,std::string & mergeJsonData)47 ErrCode IPlugin::MergePolicyData(const std::string &adminName, std::string &mergeJsonData)
48 {
49 std::shared_ptr<PolicyManager> ptr = PolicyManager::GetInstance();
50 AdminValueItemsMap map;
51 if (ptr != nullptr) {
52 ptr->GetAdminByPolicyName(policyName_, map);
53 }
54 return ERR_OK;
55 }
56
WritePolicyToParcel(const std::string & policyJsonData,MessageParcel & reply)57 ErrCode IPlugin::WritePolicyToParcel(const std::string &policyJsonData, MessageParcel &reply)
58 {
59 return reply.WriteString16(Str8ToStr16(policyJsonData)) ? ERR_OK : ERR_EDM_OPERATE_PARCEL;
60 }
61
~IPlugin()62 IPlugin::~IPlugin() {}
63 } // namespace EDM
64 } // namespace OHOS
65