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 EDM_ENTERPRISE_DEVICE_MANAGER_H 17 #define EDM_ENTERPRISE_DEVICE_MANAGER_H 18 #include <message_parcel.h> 19 #include <map> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <vector> 24 #include "ienterprise_device_mgr.h" 25 26 namespace OHOS { 27 namespace EDM { 28 class EnterpriseDeviceMgrProxy { 29 public: 30 EnterpriseDeviceMgrProxy(); 31 ~EnterpriseDeviceMgrProxy(); 32 static std::shared_ptr<EnterpriseDeviceMgrProxy> GetInstance(); 33 static void DestroyInstance(); 34 35 ErrCode ActivateAdmin(AppExecFwk::ElementName &admin, EntInfo &entInfo, AdminType type, int32_t userId); 36 ErrCode DeactivateAdmin(AppExecFwk::ElementName &admin, int32_t userId); 37 ErrCode DeactivateSuperAdmin(std::string bundleName); 38 ErrCode GetActiveAdmin(AdminType type, std::vector<std::u16string> &activeAdminList); 39 ErrCode GetEnterpriseInfo(AppExecFwk::ElementName &admin, EntInfo &entInfo); 40 ErrCode SetEnterpriseInfo(AppExecFwk::ElementName &admin, EntInfo &entInfo); 41 bool IsSuperAdmin(std::string bundleName); 42 bool IsAdminActive(AppExecFwk::ElementName &admin); 43 bool HandleDevicePolicy(int32_t policyCode, MessageParcel &data); 44 45 void GetActiveSuperAdmin(std::string &activeAdmin); 46 bool IsSuperAdminExist(); 47 void GetActiveAdmins(std::vector<std::string> &activeAdminList); 48 bool IsPolicyDisable(int policyCode, bool &isDisabled); 49 bool GetPolicyValue(int policyCode, std::string &policyData); 50 bool GetPolicyArray(int policyCode, std::vector<std::string> &policyData); 51 bool GetPolicyConfig(int policyCode, std::map<std::string, std::string> &policyData); 52 53 private: 54 static std::shared_ptr<EnterpriseDeviceMgrProxy> instance_; 55 static std::mutex mutexLock_; 56 57 void GetActiveAdmins(std::uint32_t type, std::vector<std::string> &activeAdminList); 58 sptr<IRemoteObject> GetRemoteObject(); 59 bool GetPolicy(int policyCode, MessageParcel &reply); 60 }; 61 } // namespace EDM 62 } // namespace OHOS 63 64 #endif // EDM_ENTERPRISE_DEVICE_MANAGER_H 65