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
16 #include "wifi_hotspot.h"
17 #include "wifi_hotspot_impl.h"
18 #include "wifi_logger.h"
19 #include "wifi_common_util.h"
20
21 DEFINE_WIFILOG_HOTSPOT_LABEL("WifiHotspot");
22
23 namespace OHOS {
24 namespace Wifi {
GetInstance(int systemAbilityId,int id)25 NO_SANITIZE("cfi") std::shared_ptr<WifiHotspot> WifiHotspot::GetInstance(int systemAbilityId, int id)
26 {
27 if (id >= AP_INSTANCE_MAX_NUM) {
28 WIFI_LOGE("the max obj id is %{public}d, current id is %{public}d", AP_INSTANCE_MAX_NUM, id);
29 return nullptr;
30 }
31
32 std::shared_ptr<WifiHotspotImpl> hotspot = std::make_shared<WifiHotspotImpl>();
33 if (hotspot && hotspot->Init(systemAbilityId, id)) {
34 WIFI_LOGD("ap obj id:%{public}d succeeded, sa id:%{public}d", id, systemAbilityId);
35 return hotspot;
36 }
37
38 WIFI_LOGE("new wifi hotspot id:%{public}d failed, sa id:%{public}d", id, systemAbilityId);
39 return nullptr;
40 }
41
~WifiHotspot()42 WifiHotspot::~WifiHotspot()
43 {}
44 } // namespace Wifi
45 } // namespace OHOS