• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     void ProcessShutDown();
38 
39 private:
40     uint32_t GetCellRequestMinInterval() const;
41     bool IsLowPowerConsumption() const;
42     bool IsSignalStrengthNotificationExpected() const;
43     void SetCellRequestMinInterval(uint32_t minInterval) const;
44     void ProcessDeviceState();
45     void SetNotificationFilter(int32_t newFilter, bool force);
46     void SetDeviceState(int32_t deviceStateType, bool deviceStateOn);
47     void SyncSettings();
48     void GetRrcConnectionState() const;
49 
50 private:
51     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
52     std::weak_ptr<ITelRilManager> telRilManager_;
53     int32_t slotId_ = 0;
54     int32_t notificationFilter_ = NOTIFICATION_FILTER_ALL;
55     uint32_t cellRequestMinInterval_ = 2;
56     bool isWifiConnected_ = false;
57     bool isLowData_ = false;
58     bool isPowerSaveModeOn_ = false;
59     bool isCharging_ = false;
60     bool isScreenOn_ = false;
61     bool isNetSharingOn_ = false;
62 };
63 } // namespace Telephony
64 } // namespace OHOS
65 #endif // NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H
66