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 "admin.h"
17 
18 #include "edm_log.h"
19 #include "ent_info.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace EDM {
Admin(const AppExecFwk::ExtensionAbilityInfo &abilityInfo, AdminType type, const EntInfo &entInfo, const std::vector<std::string> &permissions, bool isDebug)24 Admin::Admin(const AppExecFwk::ExtensionAbilityInfo &abilityInfo, AdminType type, const EntInfo &entInfo,
25     const std::vector<std::string> &permissions, bool isDebug)
26 {
27     adminInfo_.adminType_ = type;
28     adminInfo_.entInfo_ = entInfo;
29     adminInfo_.permission_ = permissions;
30     adminInfo_.packageName_ = abilityInfo.bundleName;
31     adminInfo_.className_ = abilityInfo.name;
32     adminInfo_.isDebug_ = isDebug;
33 }
CheckPermission(const std::string &permission)34 bool Admin::CheckPermission(const std::string &permission)
35 {
36     EDMLOGD("Admin::CheckPermission");
37     return std::any_of(adminInfo_.permission_.begin(), adminInfo_.permission_.end(),
38         [&permission](const std::string &item) { return item == permission; });
39 }
40 
GetAdminType()41 AdminType Admin::GetAdminType()
42 {
43     return adminInfo_.adminType_;
44 }
GetParentAdminName() const45 std::string Admin::GetParentAdminName() const
46 {
47     return adminInfo_.parentAdminName_;
48 }
49 } // namespace EDM
50 } // namespace OHOS