1 /*
2 * Copyright (c) 2023-2024 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 "restrictions_proxy.h"
17
18 #include "edm_log.h"
19 #include "func_code.h"
20
21 namespace OHOS {
22 namespace EDM {
23 std::shared_ptr<RestrictionsProxy> RestrictionsProxy::instance_ = nullptr;
24 std::mutex RestrictionsProxy::mutexLock_;
25 const std::u16string DESCRIPTOR = u"ohos.edm.IEnterpriseDeviceMgr";
26
GetRestrictionsProxy()27 std::shared_ptr<RestrictionsProxy> RestrictionsProxy::GetRestrictionsProxy()
28 {
29 if (instance_ == nullptr) {
30 std::lock_guard<std::mutex> lock(mutexLock_);
31 if (instance_ == nullptr) {
32 std::shared_ptr<RestrictionsProxy> temp = std::make_shared<RestrictionsProxy>();
33 instance_ = temp;
34 }
35 }
36 return instance_;
37 }
38
SetDisallowedPolicy(const AppExecFwk::ElementName & admin,bool disallow,int policyCode,std::string permissionTag)39 int32_t RestrictionsProxy::SetDisallowedPolicy(const AppExecFwk::ElementName &admin, bool disallow, int policyCode,
40 std::string permissionTag)
41 {
42 return EnterpriseDeviceMgrProxy::GetInstance()->SetPolicyDisabled(admin, disallow, policyCode, permissionTag);
43 }
44
GetDisallowedPolicy(AppExecFwk::ElementName * admin,int policyCode,bool & result,std::string permissionTag)45 int32_t RestrictionsProxy::GetDisallowedPolicy(AppExecFwk::ElementName *admin, int policyCode, bool &result,
46 std::string permissionTag)
47 {
48 return EnterpriseDeviceMgrProxy::GetInstance()->IsPolicyDisabled(admin, policyCode, result, permissionTag);
49 }
50 } // namespace EDM
51 } // namespace OHOS
52