1 /* 2 * Copyright (C) 2022 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 NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H 17 #define NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H 18 19 #include <memory> 20 21 #include "i_tel_ril_manager.h" 22 23 namespace OHOS { 24 namespace Telephony { 25 class NetworkSearchManager; 26 class DeviceStateHandler { 27 public: 28 DeviceStateHandler(const std::weak_ptr<NetworkSearchManager> &networkSearchManager, 29 const std::weak_ptr<ITelRilManager> &telRilManager, int32_t slotId); 30 virtual ~DeviceStateHandler() = default; 31 void ProcessWifiState(bool isWifiConnected); 32 void ProcessScreenDisplay(bool isScreenOn); 33 void ProcessPowerSaveMode(bool isPowerSaveModeOn); 34 void ProcessChargingState(bool isCharging); 35 void ProcessNetSharingState(bool isNetSharingOn); 36 void ProcessRadioState(); 37 38 private: 39 uint32_t GetCellRequestMinInterval() const; 40 bool IsLowPowerConsumption() const; 41 bool IsSignalStrengthNotificationExpected() const; 42 void SetCellRequestMinInterval(uint32_t minInterval) const; 43 void ProcessDeviceState(); 44 void SetNotificationFilter(int32_t newFilter, bool force); 45 void SetDeviceState(int32_t deviceStateType, bool deviceStateOn); 46 void SyncSettings(); 47 void GetRrcConnectionState() const; 48 49 private: 50 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 51 std::weak_ptr<ITelRilManager> telRilManager_; 52 int32_t slotId_ = 0; 53 int32_t notificationFilter_ = NOTIFICATION_FILTER_ALL; 54 uint32_t cellRequestMinInterval_ = 2; 55 bool isWifiConnected_ = false; 56 bool isLowData_ = false; 57 bool isPowerSaveModeOn_ = false; 58 bool isCharging_ = false; 59 bool isScreenOn_ = false; 60 bool isNetSharingOn_ = false; 61 }; 62 } // namespace Telephony 63 } // namespace OHOS 64 #endif // NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H 65