1 /* 2 * Copyright (C) 2025 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 #ifndef OHOS_WIFI_SENSOR_SCENE_H 17 #define OHOS_WIFI_SENSOR_SCENE_H 18 19 #include <mutex> 20 #include "sta_service_callback.h" 21 22 namespace OHOS { 23 namespace Wifi { 24 25 enum ConnScene { 26 UNKNOW_SCENE = 0, 27 OUTDOOR_SCENE = 1, 28 INDOOR_SCENE = 2, 29 }; 30 31 class WifiSensorScene { 32 public: 33 WifiSensorScene(); 34 ~WifiSensorScene() = default; 35 36 static WifiSensorScene &GetInstance(); 37 38 void OnConnectivityChanged(int32_t bearType, int32_t code); 39 int GetMinRssiThres(int frequency); 40 bool IsOutdoorScene(); 41 StaServiceCallback GetStaCallback() const; 42 43 private: 44 void RegisterSensorEnhCallback(); 45 void SensorEnhCallback(int scenario); 46 void InitCallback(); 47 void DealStaConnChanged(OperateResState state, const WifiLinkedInfo &info, int instId); 48 void HandleSignalInfoChange(const WifiSignalPollInfo &wifiSignalPollInfo); 49 void ReportLinkedQuality(int32_t rssi, int32_t instId = 0); 50 51 private: 52 std::mutex mutex_; 53 std::mutex staCbMutex_; 54 int scenario_; 55 56 int minRssi24G_; 57 int minRssi5G_; 58 59 int rssiCnt_ = 0; 60 int connScene_ = UNKNOW_SCENE; 61 int reportRssi_ = 0; 62 StaServiceCallback staCallback_; 63 bool isCallbackReg_; 64 }; 65 66 } // namespace Wifi 67 } // namespace OHOS 68 #endif