1 /*
2 * Copyright (c) 2023 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
SetPrinterDisabled(const AppExecFwk::ElementName & admin,bool isDisabled)39 int32_t RestrictionsProxy::SetPrinterDisabled(const AppExecFwk::ElementName &admin, bool isDisabled)
40 {
41 return EnterpriseDeviceMgrProxy::GetInstance()->SetPolicyDisabled(admin, isDisabled,
42 EdmInterfaceCode::DISABLED_PRINTER);
43 }
44
SetHdcDisabled(const AppExecFwk::ElementName & admin,bool isDisabled)45 int32_t RestrictionsProxy::SetHdcDisabled(const AppExecFwk::ElementName &admin, bool isDisabled)
46 {
47 return EnterpriseDeviceMgrProxy::GetInstance()->SetPolicyDisabled(admin, isDisabled,
48 EdmInterfaceCode::DISABLED_HDC);
49 }
50
IsPrinterDisabled(AppExecFwk::ElementName * admin,bool & result)51 int32_t RestrictionsProxy::IsPrinterDisabled(AppExecFwk::ElementName *admin, bool &result)
52 {
53 return EnterpriseDeviceMgrProxy::GetInstance()->IsPolicyDisabled(admin, EdmInterfaceCode::DISABLED_PRINTER, result);
54 }
55
IsHdcDisabled(AppExecFwk::ElementName * admin,bool & result)56 int32_t RestrictionsProxy::IsHdcDisabled(AppExecFwk::ElementName *admin, bool &result)
57 {
58 return EnterpriseDeviceMgrProxy::GetInstance()->IsPolicyDisabled(admin, EdmInterfaceCode::DISABLED_HDC, result);
59 }
60 } // namespace EDM
61 } // namespace OHOS
62