1 /*
2  * Copyright (c) 2022-2024 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 
LowLatencyTimer(std::string timerId,int32_t delayTimeMs)29 LowLatencyTimer::LowLatencyTimer(std::string timerId, int32_t delayTimeMs) : DHTimer(timerId, delayTimeMs)
30 {
31     DHLOGI("LowLatencyTimer ctor!");
32 }
33 
~LowLatencyTimer()34 LowLatencyTimer::~LowLatencyTimer()
35 {
36     DHLOGI("LowLatencyTimer dtor!");
37 }
38 
ExecuteInner()39 void LowLatencyTimer::ExecuteInner()
40 {
41     DHLOGD("ExecuteInner");
42     // to enable low latency mode: value = 0
43     OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
44         OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE,
45         {{LOW_LATENCY_KEY, DH_FWK_PKG_NAME}});
46 }
47 
HandleStopTimer()48 void LowLatencyTimer::HandleStopTimer()
49 {
50     DHLOGI("HandleStopTimer!");
51     // to restore normal latency mode: value = 1
52     OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
53         OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE,
54         {{LOW_LATENCY_KEY, DH_FWK_PKG_NAME}});
55 }
56 }
57 }
58