1 /*
2 * Copyright (c) 2021-2023 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 "thermal_service.h"
17
18 #include "file_ex.h"
19 #include "if_system_ability_manager.h"
20 #include "iservice_registry.h"
21 #include "securec.h"
22 #include "system_ability_definition.h"
23 #include <algorithm>
24 #include <fcntl.h>
25 #include <ipc_skeleton.h>
26 #include <thread>
27 #include <unistd.h>
28
29 #include "config_policy_utils.h"
30 #include "constants.h"
31 #include "ffrt_utils.h"
32 #include "permission.h"
33 #include "sysparam.h"
34 #include "thermal_common.h"
35 #include "thermal_mgr_dumper.h"
36 #include "xcollie/watchdog.h"
37
38 namespace OHOS {
39 namespace PowerMgr {
40 namespace {
41 const std::string THERMAL_SERVICE_CONFIG_PATH = "etc/thermal_config/thermal_service_config.xml";
42 const std::string VENDOR_THERMAL_SERVICE_CONFIG_PATH = "/vendor/etc/thermal_config/thermal_service_config.xml";
43 const std::string SYSTEM_THERMAL_SERVICE_CONFIG_PATH = "/system/etc/thermal_config/thermal_service_config.xml";
44 constexpr const char* THMERMAL_SERVICE_NAME = "ThermalService";
45 constexpr const char* HDI_SERVICE_NAME = "thermal_interface_service";
46 FFRTQueue g_queue("thermal_service");
47 constexpr uint32_t RETRY_TIME = 1000;
48 auto g_service = DelayedSpSingleton<ThermalService>::GetInstance();
49 const bool G_REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(g_service.GetRefPtr());
50 SysParam::BootCompletedCallback g_bootCompletedCallback;
51 } // namespace
52 std::atomic_bool ThermalService::isBootCompleted_ = false;
ThermalService()53 ThermalService::ThermalService() : SystemAbility(POWER_MANAGER_THERMAL_SERVICE_ID, true) {}
54
~ThermalService()55 ThermalService::~ThermalService() {}
56
OnStart()57 void ThermalService::OnStart()
58 {
59 THERMAL_HILOGD(COMP_SVC, "Enter");
60 if (ready_) {
61 THERMAL_HILOGE(COMP_SVC, "OnStart is ready, nothing to do");
62 return;
63 }
64
65 if (!(Init())) {
66 THERMAL_HILOGE(COMP_SVC, "OnStart call init fail");
67 return;
68 }
69
70 AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID);
71 if (!Publish(DelayedSpSingleton<ThermalService>::GetInstance())) {
72 THERMAL_HILOGE(COMP_SVC, "OnStart register to system ability manager failed.");
73 return;
74 }
75 RegisterBootCompletedCallback();
76 ready_ = true;
77 THERMAL_HILOGD(COMP_SVC, "OnStart and add system ability success");
78 }
79
RegisterBootCompletedCallback()80 void ThermalService::RegisterBootCompletedCallback()
81 {
82 g_bootCompletedCallback = []() {
83 isBootCompleted_ = true;
84 };
85 SysParam::RegisterBootCompletedCallback(g_bootCompletedCallback);
86 }
87
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)88 void ThermalService::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
89 {
90 THERMAL_HILOGI(COMP_SVC, "systemAbilityId=%{public}d, deviceId=%{private}s", systemAbilityId, deviceId.c_str());
91 if (systemAbilityId == COMMON_EVENT_SERVICE_ID) {
92 InitStateMachine();
93 }
94 }
95
Init()96 bool ThermalService::Init()
97 {
98 THERMAL_HILOGD(COMP_SVC, "Enter");
99 if (!CreateConfigModule()) {
100 return false;
101 }
102 if (!InitModules()) {
103 return false;
104 }
105 RegisterHdiStatusListener();
106 THERMAL_HILOGD(COMP_SVC, "Init success");
107 return true;
108 }
109
CreateConfigModule()110 bool ThermalService::CreateConfigModule()
111 {
112 if (!baseInfo_) {
113 baseInfo_ = std::make_shared<ThermalConfigBaseInfo>();
114 if (baseInfo_ == nullptr) {
115 THERMAL_HILOGE(COMP_SVC, "failed to create base info");
116 return false;
117 }
118 }
119
120 if (!state_) {
121 state_ = std::make_shared<StateMachine>();
122 if (state_ == nullptr) {
123 THERMAL_HILOGE(COMP_SVC, "failed to create state machine");
124 return false;
125 }
126 }
127
128 if (!actionMgr_) {
129 actionMgr_ = std::make_shared<ThermalActionManager>();
130 if (actionMgr_ == nullptr) {
131 THERMAL_HILOGE(COMP_SVC, "failed to create action manager");
132 return false;
133 }
134 }
135
136 if (!policy_) {
137 policy_ = std::make_shared<ThermalPolicy>();
138 if (policy_ == nullptr) {
139 THERMAL_HILOGE(COMP_SVC, "failed to create thermal policy");
140 return false;
141 }
142 }
143
144 if (!fanFaultDetect_) {
145 fanFaultDetect_ = std::make_shared<FanFaultDetect>();
146 if (fanFaultDetect_ == nullptr) {
147 THERMAL_HILOGE(COMP_SVC, "failed to create fan fault detect");
148 return false;
149 }
150 }
151
152 return true;
153 }
154
InitConfigFile()155 bool ThermalService::InitConfigFile()
156 {
157 if (serviceConfigParsed) {
158 THERMAL_HILOGI(COMP_SVC, "system config file has parsed.");
159 return true;
160 }
161 char buf[MAX_PATH_LEN];
162 char* path = GetOneCfgFile(THERMAL_SERVICE_CONFIG_PATH.c_str(), buf, MAX_PATH_LEN);
163 if (path != nullptr && *path != '\0') {
164 if (configParser_.ThermalSrvConfigInit(path)) {
165 THERMAL_HILOGD(COMP_SVC, "match pliocy config file");
166 return true;
167 }
168 THERMAL_HILOGE(COMP_SVC, "pliocy config file config init err");
169 return false;
170 }
171
172 if (configParser_.ThermalSrvConfigInit(VENDOR_THERMAL_SERVICE_CONFIG_PATH)) {
173 THERMAL_HILOGD(COMP_SVC, "thermal service config init suc:VENDOR_CONFIG");
174 return true;
175 }
176
177 if (configParser_.ThermalSrvConfigInit(SYSTEM_THERMAL_SERVICE_CONFIG_PATH)) {
178 THERMAL_HILOGD(COMP_SVC, "thermal service config init suc:SYSTEM_CONFIG");
179 return true;
180 }
181
182 return false;
183 }
184
185
InitConfigModule()186 bool ThermalService::InitConfigModule()
187 {
188 THERMAL_HILOGD(COMP_SVC, "InitVendor Enter");
189 if (!CreateConfigModule()) {
190 THERMAL_HILOGD(COMP_SVC, "CreateConfigModule fail");
191 }
192
193 if (!configParser_.ThermalSrvConfigInit(SYSTEM_THERMAL_SERVICE_CONFIG_PATH)) {
194 THERMAL_HILOGE(COMP_SVC, "system thermal service config init failed.");
195 return false;
196 }
197 serviceConfigParsed = true;
198
199 THERMAL_HILOGE(COMP_SVC, "system thermal service config init suc.");
200 return true;
201 }
202
InitModules()203 bool ThermalService::InitModules()
204 {
205 if (!InitConfigFile()) {
206 return false;
207 }
208
209 if (popup_ == nullptr) {
210 popup_ = std::make_shared<ActionPopup>(POPUP_ACTION_NAME);
211 }
212
213 if (!InitThermalObserver()) {
214 THERMAL_HILOGE(COMP_SVC, "thermal observer start fail");
215 return false;
216 }
217
218 if (!InitActionManager()) {
219 THERMAL_HILOGE(COMP_SVC, "action manager init fail");
220 return false;
221 }
222
223 if (!InitThermalPolicy()) {
224 THERMAL_HILOGE(COMP_SVC, "thermal policy start fail");
225 return false;
226 }
227 return true;
228 }
229
InitThermalObserver()230 bool ThermalService::InitThermalObserver()
231 {
232 if (!InitBaseInfo()) {
233 return false;
234 }
235
236 THERMAL_HILOGD(COMP_SVC, "Enter");
237 if (observer_ == nullptr) {
238 observer_ = std::make_shared<ThermalObserver>(g_service);
239 if (!(observer_->Init())) {
240 THERMAL_HILOGE(COMP_SVC, "InitThermalObserver: thermal observer start fail");
241 return false;
242 }
243 }
244 if (info_ == nullptr) {
245 info_ = std::make_shared<ThermalSensorInfo>();
246 }
247 THERMAL_HILOGI(COMP_SVC, "InitThermalObserver: Init Success");
248 return true;
249 }
250
InitBaseInfo()251 bool ThermalService::InitBaseInfo()
252 {
253 THERMAL_HILOGD(COMP_SVC, "Enter");
254 if (!baseInfo_->Init()) {
255 THERMAL_HILOGE(COMP_SVC, "InitBaseInfo: base info init failed");
256 return false;
257 }
258 return true;
259 }
260
InitStateMachine()261 bool ThermalService::InitStateMachine()
262 {
263 THERMAL_HILOGD(COMP_SVC, "Enter");
264 if (!state_->Init()) {
265 THERMAL_HILOGE(COMP_SVC, "InitStateMachine: state machine init failed");
266 return false;
267 }
268 return true;
269 }
270
InitActionManager()271 bool ThermalService::InitActionManager()
272 {
273 THERMAL_HILOGD(COMP_SVC, "Enter");
274 if (!actionMgr_->Init()) {
275 THERMAL_HILOGE(COMP_SVC, "InitActionManager: action manager init failed");
276 return false;
277 }
278 return true;
279 }
280
InitThermalPolicy()281 bool ThermalService::InitThermalPolicy()
282 {
283 THERMAL_HILOGD(COMP_SVC, "Enter");
284 if (!policy_->Init()) {
285 THERMAL_HILOGE(COMP_SVC, "InitThermalPolicy: policy init failed");
286 return false;
287 }
288 return true;
289 }
290
OnStop()291 void ThermalService::OnStop()
292 {
293 THERMAL_HILOGD(COMP_SVC, "Enter");
294 if (!ready_) {
295 return;
296 }
297 ready_ = false;
298 isBootCompleted_ = false;
299 RemoveSystemAbilityListener(COMMON_EVENT_SERVICE_ID);
300 if (thermalInterface_) {
301 thermalInterface_->Unregister();
302 thermalInterface_->UnregisterFanCallback();
303 thermalInterface_ = nullptr;
304 }
305 if (hdiServiceMgr_) {
306 hdiServiceMgr_->UnregisterServiceStatusListener(hdiServStatListener_);
307 hdiServiceMgr_ = nullptr;
308 }
309 }
310
SubscribeThermalTempCallback(const std::vector<std::string> & typeList,const sptr<IThermalTempCallback> & callback)311 bool ThermalService::SubscribeThermalTempCallback(
312 const std::vector<std::string>& typeList, const sptr<IThermalTempCallback>& callback)
313 {
314 if (!Permission::IsSystem()) {
315 return false;
316 }
317 THERMAL_HILOGD(COMP_SVC, "Enter");
318 auto uid = IPCSkeleton::GetCallingUid();
319 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
320 observer_->SubscribeThermalTempCallback(typeList, callback);
321 return true;
322 }
323
UnSubscribeThermalTempCallback(const sptr<IThermalTempCallback> & callback)324 bool ThermalService::UnSubscribeThermalTempCallback(const sptr<IThermalTempCallback>& callback)
325 {
326 if (!Permission::IsSystem()) {
327 return false;
328 }
329 THERMAL_HILOGD(COMP_SVC, "Enter");
330 auto uid = IPCSkeleton::GetCallingUid();
331 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
332 observer_->UnSubscribeThermalTempCallback(callback);
333 return true;
334 }
335
GetThermalSrvSensorInfo(const SensorType & type,ThermalSrvSensorInfo & sensorInfo)336 bool ThermalService::GetThermalSrvSensorInfo(const SensorType& type, ThermalSrvSensorInfo& sensorInfo)
337 {
338 THERMAL_HILOGD(COMP_SVC, "Enter");
339 if (!(observer_->GetThermalSrvSensorInfo(type, sensorInfo))) {
340 THERMAL_HILOGW(COMP_SVC, "failed to get sensor temp, type enum: %{public}u", static_cast<uint32_t>(type));
341 return false;
342 }
343 return true;
344 }
345
SubscribeThermalLevelCallback(const sptr<IThermalLevelCallback> & callback)346 bool ThermalService::SubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback)
347 {
348 THERMAL_HILOGD(COMP_SVC, "Enter");
349 auto uid = IPCSkeleton::GetCallingUid();
350 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
351 actionMgr_->SubscribeThermalLevelCallback(callback);
352 return true;
353 }
354
UnSubscribeThermalLevelCallback(const sptr<IThermalLevelCallback> & callback)355 bool ThermalService::UnSubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback)
356 {
357 THERMAL_HILOGD(COMP_SVC, "Enter");
358 auto uid = IPCSkeleton::GetCallingUid();
359 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
360 actionMgr_->UnSubscribeThermalLevelCallback(callback);
361 return true;
362 }
363
SubscribeThermalActionCallback(const std::vector<std::string> & actionList,const std::string & desc,const sptr<IThermalActionCallback> & callback)364 bool ThermalService::SubscribeThermalActionCallback(
365 const std::vector<std::string>& actionList, const std::string& desc, const sptr<IThermalActionCallback>& callback)
366 {
367 if (!Permission::IsSystem()) {
368 return false;
369 }
370 THERMAL_HILOGD(COMP_SVC, "Enter");
371 auto pid = IPCSkeleton::GetCallingPid();
372 auto uid = IPCSkeleton::GetCallingUid();
373 THERMAL_HILOGI(COMP_SVC, "pid %{public}d", pid);
374 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
375 observer_->SubscribeThermalActionCallback(actionList, desc, callback);
376 return true;
377 }
378
UnSubscribeThermalActionCallback(const sptr<IThermalActionCallback> & callback)379 bool ThermalService::UnSubscribeThermalActionCallback(const sptr<IThermalActionCallback>& callback)
380 {
381 if (!Permission::IsSystem()) {
382 return false;
383 }
384 THERMAL_HILOGD(COMP_SVC, "Enter");
385 auto pid = IPCSkeleton::GetCallingPid();
386 auto uid = IPCSkeleton::GetCallingUid();
387 THERMAL_HILOGI(COMP_SVC, "pid %{public}d", pid);
388 THERMAL_HILOGI(COMP_SVC, "uid %{public}d", uid);
389 observer_->UnSubscribeThermalActionCallback(callback);
390 return true;
391 }
392
GetThermalLevel(ThermalLevel & level)393 bool ThermalService::GetThermalLevel(ThermalLevel& level)
394 {
395 uint32_t levelValue = actionMgr_->GetThermalLevel();
396 level = static_cast<ThermalLevel>(levelValue);
397 return true;
398 }
399
GetThermalInfo()400 bool ThermalService::GetThermalInfo()
401 {
402 THERMAL_HILOGD(COMP_SVC, "Enter");
403 HdfThermalCallbackInfo thermalInfo;
404 bool ret = false;
405 if (thermalInterface_ == nullptr) {
406 thermalInterface_ = IThermalInterface::Get();
407 if (thermalInterface_ == nullptr) {
408 THERMAL_HILOGD(COMP_SVC, "thermalInterface_ is nullptr");
409 return ret;
410 }
411 }
412
413 if (thermalInterface_ != nullptr) {
414 int32_t res = thermalInterface_->GetThermalZoneInfo(thermalInfo);
415 HandleThermalCallbackEvent(thermalInfo);
416 if (!res) {
417 ret = true;
418 }
419 }
420 return ret;
421 }
422
SetScene(const std::string & scene)423 bool ThermalService::SetScene(const std::string& scene)
424 {
425 if (!Permission::IsSystem()) {
426 return false;
427 }
428 scene_ = scene;
429 return true;
430 }
431
UpdateThermalState(const std::string & tag,const std::string & val,bool isImmed)432 bool ThermalService::UpdateThermalState(const std::string& tag, const std::string& val, bool isImmed)
433 {
434 if (!Permission::IsSystem()) {
435 return false;
436 }
437 THERMAL_HILOGI(COMP_SVC, "tag %{public}s, val %{public}s", tag.c_str(), val.c_str());
438 std::lock_guard<std::mutex> lock(mutex_);
439 state_->UpdateState(tag, val);
440 if (isImmed) {
441 policy_->ExecutePolicy();
442 }
443 return true;
444 }
445
RegisterHdiStatusListener()446 void ThermalService::RegisterHdiStatusListener()
447 {
448 THERMAL_HILOGD(COMP_SVC, "Enter");
449 hdiServiceMgr_ = IServiceManager::Get();
450 if (hdiServiceMgr_ == nullptr) {
451 FFRTTask retryTask = [this] {
452 return RegisterHdiStatusListener();
453 };
454 FFRTUtils::SubmitDelayTask(retryTask, RETRY_TIME, g_queue);
455 THERMAL_HILOGW(COMP_SVC, "hdi service manager is nullptr, try again after %{public}u ms", RETRY_TIME);
456 return;
457 }
458
459 hdiServStatListener_ = new HdiServiceStatusListener(
460 HdiServiceStatusListener::StatusCallback([&](const OHOS::HDI::ServiceManager::V1_0::ServiceStatus& status) {
461 THERMAL_RETURN_IF(status.serviceName != HDI_SERVICE_NAME || status.deviceClass != DEVICE_CLASS_DEFAULT)
462
463 if (status.status == SERVIE_STATUS_START) {
464 FFRTTask task = [this] {
465 RegisterThermalHdiCallback();
466 RegisterFanHdiCallback();
467 };
468 FFRTUtils::SubmitTask(task);
469 THERMAL_HILOGD(COMP_SVC, "thermal interface service start");
470 } else if (status.status == SERVIE_STATUS_STOP && thermalInterface_) {
471 thermalInterface_->Unregister();
472 thermalInterface_->UnregisterFanCallback();
473 thermalInterface_ = nullptr;
474 THERMAL_HILOGW(COMP_SVC, "thermal interface service, unregister interface");
475 }
476 }));
477
478 int32_t status = hdiServiceMgr_->RegisterServiceStatusListener(hdiServStatListener_, DEVICE_CLASS_DEFAULT);
479 if (status != ERR_OK) {
480 THERMAL_HILOGW(COMP_SVC, "Register hdi failed, try again after %{public}u ms", RETRY_TIME);
481 FFRTTask retryTask = [this] {
482 return RegisterHdiStatusListener();
483 };
484 FFRTUtils::SubmitDelayTask(retryTask, RETRY_TIME, g_queue);
485 }
486 }
487
RegisterThermalHdiCallback()488 void ThermalService::RegisterThermalHdiCallback()
489 {
490 THERMAL_HILOGD(COMP_SVC, "Enter");
491 if (serviceSubscriber_ == nullptr) {
492 serviceSubscriber_ = std::make_shared<ThermalServiceSubscriber>();
493 THERMAL_RETURN_IF_WITH_LOG(!(serviceSubscriber_->Init()), "thermal service suvscriber start fail");
494 }
495
496 THERMAL_HILOGD(COMP_SVC, "register thermal hdi callback");
497 if (thermalInterface_ == nullptr) {
498 thermalInterface_ = IThermalInterface::Get();
499 THERMAL_RETURN_IF_WITH_LOG(thermalInterface_ == nullptr, "failed to get thermal hdi interface");
500 }
501
502 sptr<IThermalCallback> callback = new ThermalCallback();
503 ThermalCallback::ThermalEventCallback eventCb =
504 std::bind(&ThermalService::HandleThermalCallbackEvent, this, std::placeholders::_1);
505 ThermalCallback::RegisterThermalEvent(eventCb);
506 int32_t ret = thermalInterface_->Register(callback);
507 THERMAL_HILOGI(COMP_SVC, "register thermal hdi callback end, ret: %{public}d", ret);
508 }
509
HandleThermalCallbackEvent(const HdfThermalCallbackInfo & event)510 int32_t ThermalService::HandleThermalCallbackEvent(const HdfThermalCallbackInfo& event)
511 {
512 TypeTempMap typeTempMap;
513 if (!event.info.empty()) {
514 for (auto iter = event.info.begin(); iter != event.info.end(); iter++) {
515 typeTempMap.insert(std::make_pair(iter->type, iter->temp));
516 }
517 }
518 std::lock_guard<std::mutex> lock(mutex_);
519 serviceSubscriber_->OnTemperatureChanged(typeTempMap);
520 return ERR_OK;
521 }
522
RegisterFanHdiCallback()523 void ThermalService::RegisterFanHdiCallback()
524 {
525 if (!fanFaultDetect_->HasFanConfig()) {
526 return;
527 }
528
529 if (thermalInterface_ == nullptr) {
530 thermalInterface_ = IThermalInterface::Get();
531 THERMAL_RETURN_IF_WITH_LOG(thermalInterface_ == nullptr, "failed to get thermal hdi interface");
532 }
533
534 sptr<IFanCallback> callback = new FanCallback();
535 FanCallback::FanEventCallback eventCb =
536 std::bind(&ThermalService::HandleFanCallbackEvent, this, std::placeholders::_1);
537 FanCallback::RegisterFanEvent(eventCb);
538 int32_t ret = thermalInterface_->RegisterFanCallback(callback);
539 THERMAL_HILOGI(COMP_SVC, "register fan hdi callback end, ret: %{public}d", ret);
540
541 return;
542 }
543
HandleFanCallbackEvent(const HdfThermalCallbackInfo & event)544 int32_t ThermalService::HandleFanCallbackEvent(const HdfThermalCallbackInfo& event)
545 {
546 FanSensorInfo report;
547 if (!event.info.empty()) {
548 for (auto iter = event.info.begin(); iter != event.info.end(); iter++) {
549 report.insert(std::make_pair(iter->type, iter->temp));
550 }
551 }
552
553 fanFaultDetect_->OnFanSensorInfoChanged(report);
554 return ERR_OK;
555 }
556
ShellDump(const std::vector<std::string> & args,uint32_t argc)557 std::string ThermalService::ShellDump(const std::vector<std::string>& args, uint32_t argc)
558 {
559 if (!Permission::IsSystem() || !isBootCompleted_) {
560 return "";
561 }
562 std::lock_guard<std::mutex> lock(mutex_);
563 pid_t pid = IPCSkeleton::GetCallingPid();
564 THERMAL_HILOGI(COMP_SVC, "PID: %{public}d", pid);
565 std::string result;
566 bool ret = ThermalMgrDumper::Dump(args, result);
567 THERMAL_HILOGI(COMP_SVC, "ThermalMgrDumper :%{public}d", ret);
568 return result;
569 }
570
Dump(int fd,const std::vector<std::u16string> & args)571 int32_t ThermalService::Dump(int fd, const std::vector<std::u16string>& args)
572 {
573 if (!isBootCompleted_) {
574 return ERR_NO_INIT;
575 }
576 if (!Permission::IsSystem()) {
577 return ERR_PERMISSION_DENIED;
578 }
579 std::vector<std::string> argsInStr;
580 std::transform(args.begin(), args.end(), std::back_inserter(argsInStr), [](const std::u16string& arg) {
581 std::string ret = Str16ToStr8(arg);
582 THERMAL_HILOGI(COMP_SVC, "arg: %{public}s", ret.c_str());
583 return ret;
584 });
585 std::string result;
586 ThermalMgrDumper::Dump(argsInStr, result);
587 if (!SaveStringToFd(fd, result)) {
588 THERMAL_HILOGE(COMP_SVC, "ThermalService::Dump failed, save to fd failed.");
589 THERMAL_HILOGE(COMP_SVC, "Dump Info:\n");
590 THERMAL_HILOGE(COMP_SVC, "%{public}s", result.c_str());
591 return ERR_OK;
592 }
593 return ERR_OK;
594 }
595 } // namespace PowerMgr
596 } // namespace OHOS
597