• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include "low_latency_timer.h"
17 
18 #include "res_sched_client.h"
19 #include "res_type.h"
20 
21 #include "constants.h"
22 #include "distributed_hardware_log.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 #undef DH_LOG_TAG
27 #define DH_LOG_TAG "LowLatencyTimer"
28 
29 constexpr int32_t MODE_ENABLE = 0;
30 constexpr int32_t MODE_DISABLE = 1;
31 const std::string LOW_LATENCY_KEY = "identity";
32 
LowLatencyTimer(std::string timerId,int32_t delayTimeMs)33 LowLatencyTimer::LowLatencyTimer(std::string timerId, int32_t delayTimeMs) : DHTimer(timerId, delayTimeMs)
34 {
35     DHLOGI("LowLatencyTimer ctor!");
36 }
37 
~LowLatencyTimer()38 LowLatencyTimer::~LowLatencyTimer()
39 {
40     DHLOGI("LowLatencyTimer dtor!");
41 }
42 
ExecuteInner()43 void LowLatencyTimer::ExecuteInner()
44 {
45     DHLOGD("ExecuteInner");
46     // to enable low latency mode: value = 0
47     OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
48         OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE,
49         {{LOW_LATENCY_KEY, DH_FWK_PKG_NAME}});
50 }
51 
HandleStopTimer()52 void LowLatencyTimer::HandleStopTimer()
53 {
54     DHLOGI("HandleStopTimer!");
55     // to restore normal latency mode: value = 1
56     OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
57         OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE,
58         {{LOW_LATENCY_KEY, DH_FWK_PKG_NAME}});
59 }
60 }
61 }
62