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 TEL_RIL_HANDLER_H 17 #define TEL_RIL_HANDLER_H 18 19 #include "event_handler.h" 20 #include "event_runner.h" 21 #include "tel_event_handler.h" 22 #ifdef ABILITY_POWER_SUPPORT 23 #include "power_mgr_client.h" 24 #include "power_mgr_errors.h" 25 #endif 26 27 namespace OHOS { 28 namespace Telephony { 29 class TelRilHandler : public TelEventHandler { 30 public: TelRilHandler()31 TelRilHandler() : TelEventHandler("TelRilHandler") {} 32 ~TelRilHandler() = default; 33 34 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 35 void OnInit(void); 36 void ApplyRunningLock(int32_t lockType); 37 void ReduceRunningLock(int32_t lockType); 38 void ReleaseRunningLock(int32_t lockType); 39 40 public: 41 static const int32_t NORMAL_RUNNING_LOCK = 100; 42 static const int32_t ACK_RUNNING_LOCK = 101; 43 44 private: 45 static const uint32_t RUNNING_LOCK_TIMEOUT_EVENT_ID = 0; 46 static const uint32_t ACK_RUNNING_LOCK_TIMEOUT_EVENT_ID = 1; 47 48 static const int64_t RUNNING_LOCK_DEFAULT_TIMEOUT_MS = 60 * 1000; // 60s 49 static const int64_t ACK_RUNNING_LOCK_DEFAULT_TIMEOUT_MS = 200; // 200ms 50 static const int64_t DELAR_RELEASE_RUNNING_LOCK_TIMEOUT_MS = 5 * 1000; // 5s 51 52 private: 53 #ifdef ABILITY_POWER_SUPPORT 54 std::shared_ptr<PowerMgr::RunningLock> reqRunningLock_; 55 std::shared_ptr<PowerMgr::RunningLock> ackRunningLock_; 56 #endif 57 std::atomic_uint reqRunningLockCount_; 58 std::atomic_int reqLockSerialNum_; 59 std::atomic_int ackLockSerialNum_; 60 std::mutex mutexRunningLock_; 61 62 private: 63 void ReleaseRunningLockDelay(int32_t lockType); 64 }; 65 } // namespace Telephony 66 } // namespace OHOS 67 #endif // TEL_RIL_HANDLER_H 68