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 "usb_manager_proxy.h" 17 18 #include "edm_ipc_interface_code.h" 19 #include "edm_log.h" 20 #include "func_code.h" 21 #include "message_parcel_utils.h" 22 23 namespace OHOS { 24 namespace EDM { 25 std::shared_ptr<UsbManagerProxy> UsbManagerProxy::instance_ = nullptr; 26 std::mutex UsbManagerProxy::mutexLock_; 27 const std::u16string DESCRIPTOR = u"ohos.edm.IEnterpriseDeviceMgr"; 28 GetUsbManagerProxy()29std::shared_ptr<UsbManagerProxy> UsbManagerProxy::GetUsbManagerProxy() 30 { 31 if (instance_ == nullptr) { 32 std::lock_guard<std::mutex> lock(mutexLock_); 33 if (instance_ == nullptr) { 34 std::shared_ptr<UsbManagerProxy> temp = std::make_shared<UsbManagerProxy>(); 35 instance_ = temp; 36 } 37 } 38 return instance_; 39 } 40 SetUsbReadOnly(const AppExecFwk::ElementName & admin,bool readOnly)41int32_t UsbManagerProxy::SetUsbReadOnly(const AppExecFwk::ElementName &admin, bool readOnly) 42 { 43 EDMLOGD("UsbManagerProxy::SetUsbReadOnly"); 44 return EnterpriseDeviceMgrProxy::GetInstance()->SetPolicyDisabled(admin, readOnly, EdmInterfaceCode::USB_READ_ONLY); 45 } 46 } // namespace EDM 47 } // namespace OHOS 48