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 "wifi_hid2d.h" 17 #include "wifi_p2p_impl.h" 18 #include "wifi_logger.h" 19 #include "wifi_common_util.h" 20 21 DEFINE_WIFILOG_LABEL("Hid2d"); 22 23 namespace OHOS { 24 namespace Wifi { CreateWifiHid2d(int systemAbilityId)25NO_SANITIZE("cfi") std::unique_ptr<Hid2d> Hid2d::CreateWifiHid2d(int systemAbilityId) 26 { 27 std::unique_ptr<WifiP2pImpl> impl = std::make_unique<WifiP2pImpl>(systemAbilityId); 28 if (impl != nullptr) { 29 if (impl->Init()) { 30 WIFI_LOGI("new hid2d successfully!"); 31 return impl; 32 } 33 } 34 35 WIFI_LOGE("new wifi hid2d failed"); 36 return nullptr; 37 } 38 GetInstance(int systemAbilityId)39NO_SANITIZE("cfi") std::unique_ptr<Hid2d> Hid2d::GetInstance(int systemAbilityId) 40 { 41 std::unique_ptr<WifiP2pImpl> impl = std::make_unique<WifiP2pImpl>(systemAbilityId); 42 if (impl != nullptr) { 43 if (impl->Init()) { 44 WIFI_LOGI("init hid2d successfully!"); 45 return impl; 46 } 47 } 48 49 WIFI_LOGE("new wifi hid2d failed"); 50 return nullptr; 51 } 52 ~Hid2d()53Hid2d::~Hid2d() 54 {} 55 } // namespace Wifi 56 } // namespace OHOS