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_manager.h"
17
18 #include <algorithm>
19 #include <ctime>
20 #include <fstream>
21 #include <iostream>
22
23 #include "directory_ex.h"
24 #include "edm_constants.h"
25 #include "edm_log.h"
26 #include "permission_manager.h"
27 #include "super_admin.h"
28
29 namespace OHOS {
30 namespace EDM {
31 std::shared_ptr<AdminManager> AdminManager::instance_;
32 std::mutex AdminManager::mutexLock_;
33
GetInstance()34 std::shared_ptr<AdminManager> AdminManager::GetInstance()
35 {
36 if (instance_ == nullptr) {
37 std::lock_guard<std::mutex> autoLock(mutexLock_);
38 if (instance_ == nullptr) {
39 instance_.reset(new (std::nothrow) AdminManager());
40 }
41 }
42 return instance_;
43 }
44
AdminManager()45 AdminManager::AdminManager()
46 {
47 EDMLOGI("AdminManager::AdminManager");
48 }
49
~AdminManager()50 AdminManager::~AdminManager()
51 {
52 EDMLOGI("AdminManager::~AdminManager");
53 admins_.clear();
54 }
55
GetReqPermission(const std::vector<std::string> & permissions,std::vector<EdmPermission> & reqPermissions)56 ErrCode AdminManager::GetReqPermission(const std::vector<std::string> &permissions,
57 std::vector<EdmPermission> &reqPermissions)
58 {
59 EDMLOGD("AdminManager::GetReqPermission");
60 PermissionManager::GetInstance()->GetReqPermission(permissions, reqPermissions);
61 return reqPermissions.empty() ? ERR_EDM_EMPTY_PERMISSIONS : ERR_OK;
62 }
63
GetAdminByUserId(int32_t userId,std::vector<std::shared_ptr<Admin>> & userAdmin)64 bool AdminManager::GetAdminByUserId(int32_t userId, std::vector<std::shared_ptr<Admin>> &userAdmin)
65 {
66 userAdmin.clear();
67 auto iter = admins_.find(userId);
68 if (iter == admins_.end()) {
69 EDMLOGW("GetAdminByUserId::get userId Admin failed. userId = %{public}d", userId);
70 return false;
71 }
72 userAdmin = iter->second;
73 return true;
74 }
75
GetAdminBySubscribeEvent(ManagedEvent event,std::unordered_map<int32_t,std::vector<std::shared_ptr<Admin>>> & subscribeAdmins)76 void AdminManager::GetAdminBySubscribeEvent(ManagedEvent event,
77 std::unordered_map<int32_t, std::vector<std::shared_ptr<Admin>>> &subscribeAdmins)
78 {
79 for (const auto &adminItem : admins_) {
80 std::vector<std::shared_ptr<Admin>> subAdmin;
81 for (const auto &it : adminItem.second) {
82 std::vector<ManagedEvent> events = it->adminInfo_.managedEvents_;
83 if (std::find(events.begin(), events.end(), event) != events.end()) {
84 subAdmin.push_back(it);
85 }
86 }
87 if (!subAdmin.empty()) {
88 subscribeAdmins[adminItem.first] = subAdmin;
89 }
90 }
91 }
92
SetAdminValue(AppExecFwk::ExtensionAbilityInfo & abilityInfo,EntInfo & entInfo,AdminType role,std::vector<std::string> & permissions,int32_t userId)93 ErrCode AdminManager::SetAdminValue(AppExecFwk::ExtensionAbilityInfo &abilityInfo, EntInfo &entInfo, AdminType role,
94 std::vector<std::string> &permissions, int32_t userId)
95 {
96 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
97 if (adminPoliciesStorageRdb == nullptr) {
98 EDMLOGE("AdminManager::SetAdminValue get adminPoliciesStorageRdb failed.");
99 return ERR_GET_STORAGE_RDB_FAILED;
100 }
101 std::vector<AdminPermission> reqPermission;
102 std::vector<std::string> permissionNames;
103 std::vector<std::shared_ptr<Admin>> admin;
104 PermissionManager::GetInstance()->GetReqPermission(permissions, reqPermission);
105 if (reqPermission.empty()) {
106 EDMLOGW("SetAdminValue::the application is requesting useless permissions");
107 }
108 for (const auto &it : reqPermission) {
109 if (role == AdminType::NORMAL && it.adminType == AdminType::ENT) {
110 return ERR_EDM_DENY_PERMISSION;
111 }
112 permissionNames.push_back(it.permissionName);
113 }
114
115 std::shared_ptr<Admin> adminItem = GetAdminByPkgName(abilityInfo.bundleName, userId);
116 if (!adminItem && !adminPoliciesStorageRdb->InsertAdmin(userId, abilityInfo, entInfo, role, permissions)) {
117 EDMLOGE("AdminManager::SetAdminValue failed.");
118 return ERR_EDM_ADD_ADMIN_FAILED;
119 } else if (adminItem && !adminPoliciesStorageRdb->UpdateAdmin(userId, abilityInfo, entInfo, role, permissions)) {
120 EDMLOGE("AdminManager::SetAdminValue failed.");
121 return ERR_EDM_ADD_ADMIN_FAILED;
122 }
123 bool ret = GetAdminByUserId(userId, admin);
124 if (role == AdminType::NORMAL) {
125 admin.emplace_back(std::make_shared<Admin>());
126 } else {
127 admin.emplace_back(std::make_shared<SuperAdmin>());
128 }
129 if (!ret) {
130 admins_.insert(std::pair<int32_t, std::vector<std::shared_ptr<Admin>>>(userId, admin));
131 adminItem = admin.back();
132 } else if (ret && !adminItem) {
133 admins_[userId] = admin;
134 adminItem = admin.back();
135 }
136 adminItem->adminInfo_.adminType_ = role;
137 adminItem->adminInfo_.entInfo_ = entInfo;
138 adminItem->adminInfo_.permission_ = permissionNames;
139 adminItem->adminInfo_.packageName_ = abilityInfo.bundleName;
140 adminItem->adminInfo_.className_ = abilityInfo.name;
141 return ERR_OK;
142 }
143
GetAdminByPkgName(const std::string & packageName,int32_t userId)144 std::shared_ptr<Admin> AdminManager::GetAdminByPkgName(const std::string &packageName, int32_t userId)
145 {
146 std::shared_ptr<Admin> subOrSuperAdmin;
147 if (SUCCEEDED(GetSubOrSuperAdminByPkgName(packageName, subOrSuperAdmin))) {
148 EDMLOGD("GetAdminByPkgName::get sub-super or super admin: %{public}s", packageName.c_str());
149 return subOrSuperAdmin;
150 }
151 std::vector<std::shared_ptr<Admin>> userAdmin;
152 if (!GetAdminByUserId(userId, userAdmin)) {
153 EDMLOGW("GetAdminByPkgName::get userId Admin failed. userId = %{public}d", userId);
154 return nullptr;
155 }
156 for (const auto &item : userAdmin) {
157 if (item->adminInfo_.packageName_ == packageName) {
158 return item;
159 }
160 }
161 EDMLOGD("GetAdminByPkgName::get admin failed. admin size = %{public}u, packageName = %{public}s",
162 (uint32_t)userAdmin.size(), packageName.c_str());
163 return nullptr;
164 }
165
DeleteAdmin(const std::string & packageName,int32_t userId)166 ErrCode AdminManager::DeleteAdmin(const std::string &packageName, int32_t userId)
167 {
168 auto iterMap = admins_.find(userId);
169 if (iterMap == admins_.end()) {
170 EDMLOGW("DeleteAdmin::get userId Admin failed. userId = %{public}d", userId);
171 return ERR_EDM_UNKNOWN_ADMIN;
172 }
173 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
174 if (adminPoliciesStorageRdb == nullptr) {
175 EDMLOGE("AdminManager::DeleteAdmin get adminPoliciesStorageRdb failed.");
176 return ERR_GET_STORAGE_RDB_FAILED;
177 }
178 if (!adminPoliciesStorageRdb->DeleteAdmin(userId, packageName)) {
179 EDMLOGW("delete admin (%{public}s) failed!", packageName.c_str());
180 return ERR_EDM_DEL_ADMIN_FAILED;
181 }
182 auto iter = std::remove_if(iterMap->second.begin(), iterMap->second.end(),
183 [&](std::shared_ptr<Admin> admin) { return admin->adminInfo_.packageName_ == packageName; });
184 iterMap->second.erase(iter, iterMap->second.end());
185 if (iterMap->second.empty()) {
186 admins_.erase(iterMap);
187 }
188 return ERR_OK;
189 }
190
GetGrantedPermission(std::vector<std::string> & permissions,AdminType type)191 ErrCode AdminManager::GetGrantedPermission(std::vector<std::string> &permissions, AdminType type)
192 {
193 if (permissions.empty()) {
194 EDMLOGW("GetGrantedPermission::permissions is empty");
195 return ERR_OK;
196 }
197 // filtering out non-edm permissions
198 std::vector<AdminPermission> reqPermission;
199 PermissionManager::GetInstance()->GetReqPermission(permissions, reqPermission);
200 if (reqPermission.empty()) {
201 EDMLOGW("GetGrantedPermission::edm permission is empty");
202 return ERR_OK;
203 }
204
205 // filter out super permissions if admin is NORMAL
206 std::vector<std::string> permissionNameList;
207 for (const auto &it : reqPermission) {
208 if ((type == AdminType::NORMAL) && (it.adminType == AdminType::ENT)) {
209 continue;
210 }
211 permissionNameList.push_back(it.permissionName);
212 }
213 permissions.assign(permissionNameList.begin(), permissionNameList.end());
214 return ERR_OK;
215 }
216
UpdateAdmin(AppExecFwk::ExtensionAbilityInfo & abilityInfo,const std::vector<std::string> & permissions,int32_t userId)217 ErrCode AdminManager::UpdateAdmin(AppExecFwk::ExtensionAbilityInfo &abilityInfo,
218 const std::vector<std::string> &permissions, int32_t userId)
219 {
220 auto adminItem = GetAdminByPkgName(abilityInfo.bundleName, userId);
221 if (adminItem == nullptr) {
222 EDMLOGW("UpdateAdmin::get null admin, never get here");
223 return ERR_EDM_UNKNOWN_ADMIN;
224 }
225 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
226 if (adminPoliciesStorageRdb == nullptr) {
227 EDMLOGE("AdminManager::UpdateAdmin get adminPoliciesStorageRdb failed.");
228 return ERR_GET_STORAGE_RDB_FAILED;
229 }
230
231 std::vector<std::string> combinePermission = permissions;
232 ErrCode ret = GetGrantedPermission(combinePermission, adminItem->adminInfo_.adminType_);
233 if (ret != ERR_OK) {
234 EDMLOGW("UpdateAdmin::GetGrantedPermission failed");
235 return ret;
236 }
237
238 if (!adminPoliciesStorageRdb->UpdateAdmin(userId, abilityInfo.bundleName, abilityInfo.name, combinePermission)) {
239 EDMLOGW("UpdateAdmin::update admin failed.");
240 return ERR_EDM_UNKNOWN_ADMIN;
241 }
242 adminItem->adminInfo_.permission_ = combinePermission;
243 adminItem->adminInfo_.packageName_ = abilityInfo.bundleName;
244 adminItem->adminInfo_.className_ = abilityInfo.name;
245 return ERR_OK;
246 }
247
248 // success is returned as long as there is a super administrator
IsSuperAdminExist()249 bool AdminManager::IsSuperAdminExist()
250 {
251 std::vector<std::shared_ptr<Admin>> userAdmin;
252 bool ret = GetAdminByUserId(DEFAULT_USER_ID, userAdmin);
253 if (!ret) {
254 EDMLOGD("IsSuperAdminExist::not find super Admin");
255 return false;
256 }
257 return std::any_of(userAdmin.begin(), userAdmin.end(),
258 [](const std::shared_ptr<Admin> &admin) { return admin->adminInfo_.adminType_ == AdminType::ENT; });
259 }
260
IsAdminExist()261 bool AdminManager::IsAdminExist()
262 {
263 return !admins_.empty();
264 }
265
IsSuperOrSubSuperAdmin(const std::string & bundleName)266 bool AdminManager::IsSuperOrSubSuperAdmin(const std::string &bundleName)
267 {
268 std::shared_ptr<Admin> superAdmin;
269 superAdmin = GetAdminByPkgName(bundleName, DEFAULT_USER_ID);
270 if (superAdmin == nullptr) {
271 return false;
272 }
273 return superAdmin->adminInfo_.adminType_ == AdminType::ENT ||
274 superAdmin->adminInfo_.adminType_ == AdminType::SUB_SUPER_ADMIN;
275 }
276
277 /*
278 * There are different administrator types according to the input parameters.
279 * Returns a list of package names
280 */
GetEnabledAdmin(AdminType role,std::vector<std::string> & packageNameList,int32_t userId)281 void AdminManager::GetEnabledAdmin(AdminType role, std::vector<std::string> &packageNameList, int32_t userId)
282 {
283 packageNameList.clear();
284 std::vector<std::shared_ptr<Admin>> userAdmin;
285 bool ret = GetAdminByUserId(userId, userAdmin);
286 if (!ret) {
287 EDMLOGW("GetEnabledAdmin::not find enabled Admin. userId = %{public}d", userId);
288 return;
289 }
290 EDMLOGD("AdminManager:GetEnabledAdmin adminType: %{public}d , admin size: %{public}zu", role, userAdmin.size());
291 if (static_cast<int32_t>(role) >= static_cast<int32_t>(AdminType::UNKNOWN) ||
292 static_cast<int32_t>(role) < static_cast<int32_t>(AdminType::NORMAL)) {
293 EDMLOGD("there is no admin(%{public}u) device manager package name list!", role);
294 return;
295 }
296
297 for (const auto &item : userAdmin) {
298 if (item->adminInfo_.adminType_ == role) {
299 std::string adminName = item->adminInfo_.packageName_ + "/" + item->adminInfo_.className_;
300 packageNameList.push_back(adminName);
301 }
302 }
303 }
304
GetSubOrSuperAdminByPkgName(const std::string & subAdminName,std::shared_ptr<Admin> & subOrSuperAdmin)305 ErrCode AdminManager::GetSubOrSuperAdminByPkgName(const std::string &subAdminName,
306 std::shared_ptr<Admin> &subOrSuperAdmin)
307 {
308 std::vector<std::shared_ptr<Admin>> userAdmin;
309 if (!GetAdminByUserId(DEFAULT_USER_ID, userAdmin)) {
310 EDMLOGW("GetSubOrSuperAdminByPkgName::not find Admin under default user id");
311 return ERR_EDM_SUPER_ADMIN_NOT_FOUND;
312 }
313 auto adminItem = std::find_if(userAdmin.begin(), userAdmin.end(), [&](const std::shared_ptr<Admin> &admin) {
314 return admin->adminInfo_.packageName_ == subAdminName && (admin->adminInfo_.adminType_ == AdminType::ENT ||
315 admin->adminInfo_.adminType_ == AdminType::SUB_SUPER_ADMIN);
316 });
317 if (adminItem == userAdmin.end()) {
318 EDMLOGW("GetSubOrSuperAdminByPkgName::not find sub-super admin or super Admin");
319 return ERR_EDM_SUPER_ADMIN_NOT_FOUND;
320 }
321 subOrSuperAdmin = *adminItem;
322 return ERR_OK;
323 }
324
GetSubSuperAdminsByParentName(const std::string & parentName,std::vector<std::string> & subAdmins)325 ErrCode AdminManager::GetSubSuperAdminsByParentName(const std::string &parentName, std::vector<std::string> &subAdmins)
326 {
327 subAdmins.clear();
328 std::vector<std::shared_ptr<Admin>> userAdmin;
329 if (!GetAdminByUserId(DEFAULT_USER_ID, userAdmin)) {
330 EDMLOGE("GetSubSuperAdminsByParentName::not find Admin under default user id.");
331 return ERR_EDM_SUPER_ADMIN_NOT_FOUND;
332 }
333 for (const auto &admin : userAdmin) {
334 if (admin->adminInfo_.adminType_ == AdminType::SUB_SUPER_ADMIN &&
335 admin->adminInfo_.parentAdminName_ == parentName) {
336 subAdmins.push_back(admin->adminInfo_.packageName_);
337 }
338 }
339 return ERR_OK;
340 }
341
GetEntInfo(const std::string & packageName,EntInfo & entInfo,int32_t userId)342 ErrCode AdminManager::GetEntInfo(const std::string &packageName, EntInfo &entInfo, int32_t userId)
343 {
344 std::vector<std::shared_ptr<Admin>> userAdmin;
345 bool ret = GetAdminByUserId(userId, userAdmin);
346 if (!ret) {
347 EDMLOGW("GetEntInfo::not find Admin. userId = %{public}d", userId);
348 return ERR_EDM_UNKNOWN_ADMIN;
349 }
350 for (const auto &item : userAdmin) {
351 if (item->adminInfo_.packageName_ == packageName) {
352 entInfo = item->adminInfo_.entInfo_;
353 return ERR_OK;
354 }
355 }
356 return ERR_EDM_UNKNOWN_ADMIN;
357 }
358
SetEntInfo(const std::string & packageName,EntInfo & entInfo,int32_t userId)359 ErrCode AdminManager::SetEntInfo(const std::string &packageName, EntInfo &entInfo, int32_t userId)
360 {
361 std::vector<std::shared_ptr<Admin>> userAdmin;
362 bool ret = GetAdminByUserId(userId, userAdmin);
363 if (!ret) {
364 EDMLOGW("SetEntInfo::not find Admin. userId = %{public}d", userId);
365 return ERR_EDM_UNKNOWN_ADMIN;
366 }
367 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
368 if (adminPoliciesStorageRdb == nullptr) {
369 EDMLOGE("AdminManager::SetEntInfo get adminPoliciesStorageRdb failed.");
370 return ERR_GET_STORAGE_RDB_FAILED;
371 }
372 for (auto &item : userAdmin) {
373 if (item->adminInfo_.packageName_ == packageName &&
374 adminPoliciesStorageRdb->UpdateEntInfo(userId, packageName, entInfo)) {
375 item->adminInfo_.entInfo_ = entInfo;
376 return ERR_OK;
377 }
378 }
379 return ERR_EDM_UNKNOWN_ADMIN;
380 }
381
SaveSubscribeEvents(const std::vector<uint32_t> & events,const std::string & bundleName,int32_t userId)382 ErrCode AdminManager::SaveSubscribeEvents(const std::vector<uint32_t> &events, const std::string &bundleName,
383 int32_t userId)
384 {
385 std::shared_ptr<Admin> admin = GetAdminByPkgName(bundleName, userId);
386 if (admin == nullptr) {
387 return ERR_EDM_UNKNOWN_ADMIN;
388 }
389 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
390 if (adminPoliciesStorageRdb == nullptr) {
391 EDMLOGE("AdminManager::SaveSubscribeEvents get adminPoliciesStorageRdb failed.");
392 return ERR_GET_STORAGE_RDB_FAILED;
393 }
394 std::vector<ManagedEvent> oldManagedEvents = admin->adminInfo_.managedEvents_;
395 size_t eventsNumber = admin->adminInfo_.managedEvents_.size();
396 for (const auto &event : events) {
397 std::vector<ManagedEvent> managedEvents = admin->adminInfo_.managedEvents_;
398 ManagedEvent subEvent = static_cast<ManagedEvent>(event);
399 if (std::find(managedEvents.begin(), managedEvents.end(), subEvent) == managedEvents.end()) {
400 admin->adminInfo_.managedEvents_.push_back(subEvent);
401 }
402 }
403 if (admin->adminInfo_.managedEvents_.size() > eventsNumber &&
404 !adminPoliciesStorageRdb->UpdateManagedEvents(userId, admin->adminInfo_.packageName_,
405 admin->adminInfo_.managedEvents_)) {
406 admin->adminInfo_.managedEvents_ = oldManagedEvents;
407 return ERR_EDM_UNKNOWN_ADMIN;
408 }
409 return ERR_OK;
410 }
411
RemoveSubscribeEvents(const std::vector<uint32_t> & events,const std::string & bundleName,int32_t userId)412 ErrCode AdminManager::RemoveSubscribeEvents(const std::vector<uint32_t> &events, const std::string &bundleName,
413 int32_t userId)
414 {
415 std::shared_ptr<Admin> admin = GetAdminByPkgName(bundleName, userId);
416 if (admin == nullptr) {
417 return ERR_EDM_UNKNOWN_ADMIN;
418 }
419 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
420 if (adminPoliciesStorageRdb == nullptr) {
421 EDMLOGE("AdminManager::RemoveSubscribeEvents get adminPoliciesStorageRdb failed.");
422 return ERR_GET_STORAGE_RDB_FAILED;
423 }
424
425 std::vector<ManagedEvent> oldManagedEvents = admin->adminInfo_.managedEvents_;
426 size_t eventsNumber = admin->adminInfo_.managedEvents_.size();
427 auto iter = std::remove_if(admin->adminInfo_.managedEvents_.begin(), admin->adminInfo_.managedEvents_.end(),
428 [&](ManagedEvent managedEvent) {
429 return std::find(events.begin(), events.end(), static_cast<uint32_t>(managedEvent)) != events.end();
430 });
431 admin->adminInfo_.managedEvents_.erase(iter, admin->adminInfo_.managedEvents_.end());
432
433 if (admin->adminInfo_.managedEvents_.size() < eventsNumber &&
434 !adminPoliciesStorageRdb->UpdateManagedEvents(userId, admin->adminInfo_.packageName_,
435 admin->adminInfo_.managedEvents_)) {
436 admin->adminInfo_.managedEvents_ = oldManagedEvents;
437 return ERR_EDM_UNKNOWN_ADMIN;
438 }
439 return ERR_OK;
440 }
441
SaveAuthorizedAdmin(const std::string & bundleName,const std::vector<std::string> & permissions,const std::string & parentName)442 ErrCode AdminManager::SaveAuthorizedAdmin(const std::string &bundleName, const std::vector<std::string> &permissions,
443 const std::string &parentName)
444 {
445 std::vector<std::shared_ptr<Admin>> admin;
446 if (!GetAdminByUserId(DEFAULT_USER_ID, admin)) {
447 return ERR_SAVE_AUTHORIZED_ADMIN_FAILED;
448 }
449 std::shared_ptr<Admin> adminItem = GetAdminByPkgName(bundleName, DEFAULT_USER_ID);
450 if (!adminItem &&
451 !AdminPoliciesStorageRdb::GetInstance()->InsertAuthorizedAdmin(bundleName, permissions, parentName)) {
452 EDMLOGE("AdminManager::InsertAuthorizedAdmin save authorized failed.");
453 return ERR_SAVE_AUTHORIZED_ADMIN_FAILED;
454 }
455 if (adminItem) {
456 if (adminItem->GetAdminType() != AdminType::SUB_SUPER_ADMIN) {
457 EDMLOGE("AdminManager::UpdateAuthorizedAdmin can only update sub-super admin.");
458 return ERR_SAVE_AUTHORIZED_ADMIN_FAILED;
459 }
460 if (!AdminPoliciesStorageRdb::GetInstance()->UpdateAuthorizedAdmin(bundleName, permissions, parentName)) {
461 EDMLOGE("AdminManager::UpdateAuthorizedAdmin save authorized failed.");
462 return ERR_SAVE_AUTHORIZED_ADMIN_FAILED;
463 }
464 }
465 if (!adminItem) {
466 admin.emplace_back(std::make_shared<Admin>());
467 admins_[DEFAULT_USER_ID] = admin;
468 adminItem = admin.back();
469 adminItem->adminInfo_.adminType_ = AdminType::SUB_SUPER_ADMIN;
470 }
471 adminItem->adminInfo_.packageName_ = bundleName;
472 adminItem->adminInfo_.permission_ = permissions;
473 adminItem->adminInfo_.parentAdminName_ = parentName;
474 return ERR_OK;
475 }
476
477 // init
Init()478 void AdminManager::Init()
479 {
480 auto adminPoliciesStorageRdb = AdminPoliciesStorageRdb::GetInstance();
481 if (adminPoliciesStorageRdb != nullptr) {
482 admins_ = adminPoliciesStorageRdb->QueryAllAdmin();
483 } else {
484 EDMLOGE("AdminManager::Init failed.");
485 }
486 }
487 } // namespace EDM
488 } // namespace OHOS
489