• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #include "wifi_device.h"
16 #include "wifi_device_impl.h"
17 #include "wifi_logger.h"
18 
19 DEFINE_WIFILOG_LABEL("WifiDevice");
20 
21 namespace OHOS {
22 namespace Wifi {
CreateWifiDevice(int systemAbilityId)23 std::unique_ptr<WifiDevice> WifiDevice::CreateWifiDevice(int systemAbilityId)
24 {
25     std::unique_ptr<WifiDeviceImpl> device = std::make_unique<WifiDeviceImpl>(systemAbilityId);
26     if (device != nullptr) {
27         if (device->Init()) {
28             WIFI_LOGI("new device successfully!");
29             return device;
30         }
31     }
32 
33     WIFI_LOGE("new wifi device failed");
34     return nullptr;
35 }
36 
GetInstance(int systemAbilityId)37 std::unique_ptr<WifiDevice> WifiDevice::GetInstance(int systemAbilityId)
38 {
39     std::unique_ptr<WifiDeviceImpl> device = std::make_unique<WifiDeviceImpl>(systemAbilityId);
40     if (device != nullptr) {
41         if (device->Init()) {
42             WIFI_LOGI("init successfully!");
43             return device;
44         }
45     }
46 
47     WIFI_LOGE("new wifi device failed");
48     return nullptr;
49 }
50 
~WifiDevice()51 WifiDevice::~WifiDevice()
52 {}
53 }  // namespace Wifi
54 }  // namespace OHOS