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_scan.h"
16 #ifndef OHOS_ARCH_LITE
17 #include "iremote_broker.h"
18 #endif
19 #include "wifi_logger.h"
20 #include "wifi_scan_impl.h"
21 #include "wifi_common_util.h"
22
23 DEFINE_WIFILOG_SCAN_LABEL("WifiScan");
24
25 namespace OHOS {
26 namespace Wifi {
GetInstance(int systemAbilityId,int instId)27 NO_SANITIZE("cfi") std::shared_ptr<WifiScan> WifiScan::GetInstance(int systemAbilityId, int instId)
28 {
29 #ifndef OHOS_ARCH_LITE
30 if (instId >= STA_INSTANCE_MAX_NUM) {
31 WIFI_LOGE("the max obj id is %{public}d, current id is %{public}d", STA_INSTANCE_MAX_NUM, instId);
32 return nullptr;
33 }
34 #endif
35
36 std::shared_ptr<WifiScanImpl> pImpl = std::make_shared<WifiScanImpl>();
37 if (pImpl && pImpl->Init(systemAbilityId, instId)) {
38 WIFI_LOGD("init scan %{public}d successfully!", instId);
39 return pImpl;
40 }
41
42 WIFI_LOGE("new wifi WifiScan failed");
43 return nullptr;
44 }
45
~WifiScan()46 WifiScan::~WifiScan()
47 {}
48 } // namespace Wifi
49 } // namespace OHOS