• 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 #include "wifi_common_util.h"
19 
20 DEFINE_WIFILOG_LABEL("WifiDevice");
21 
22 namespace OHOS {
23 namespace Wifi {
GetInstance(int systemAbilityId,int instId)24 NO_SANITIZE("cfi") std::shared_ptr<WifiDevice> WifiDevice::GetInstance(int systemAbilityId, int instId)
25 {
26 #ifndef OHOS_ARCH_LITE
27     if (instId >= STA_INSTANCE_MAX_NUM) {
28         WIFI_LOGE("the max obj id is %{public}d, current id is %{public}d", STA_INSTANCE_MAX_NUM, instId);
29         return nullptr;
30     }
31 #endif
32 
33     std::shared_ptr<WifiDeviceImpl> device = std::make_shared<WifiDeviceImpl>();
34     if (device && device->Init(systemAbilityId, instId)) {
35         return device;
36     }
37 
38     WIFI_LOGE("new wifi device failed");
39     return nullptr;
40 }
41 
~WifiDevice()42 WifiDevice::~WifiDevice()
43 {}
44 }  // namespace Wifi
45 }  // namespace OHOS