42 lines
903 B
C++
42 lines
903 B
C++
/*
|
|||
|
|
* ThermalActionCommon.cpp
|
||
|
|
*
|
||
|
|
* Copyright (C) 2016 Spreadtrum Communications Inc.
|
||
|
|
*/
|
||
|
|
#include <unistd.h>
|
||
|
|
#include <fcntl.h>
|
||
|
|
#include "ThermalActionCommon.h"
|
||
|
|
#include "alog.h"
|
||
|
|
|
||
|
|
#undef LOG_TAG
|
||
|
|
#define LOG_TAG "ThermalActionCommon"
|
||
|
|
|
||
|
|
namespace android {
|
||
|
|
|
||
|
|
ThermalActionCommon::ThermalActionCommon() {}
|
||
|
|
|
||
|
|
void ThermalActionCommon::setEnable(bool en) {
|
||
|
|
enable = en;
|
||
|
|
ALOGI("%s setEnable: %d!", this->getName(), en);
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
void ThermalActionCommon::doAction() {
|
||
|
|
if (this->enable) {
|
||
|
|
int fd;
|
||
|
|
fd = open(mFileNode.c_str(), O_WRONLY);
|
||
|
|
if (fd < 0) {
|
||
|
|
ALOGE("open %s failed!", mFileNode.c_str());
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
ALOGI("do,===>%s, mArg:%s, mFileNode:%s", mDevice.c_str(), mArg.c_str(),
|
||
|
|
mFileNode.c_str());
|
||
|
|
write(fd, mArg.c_str(), mArg.size());
|
||
|
|
close(fd);
|
||
|
|
} else {
|
||
|
|
ALOGE("%s has been turn off", this->getName());
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}; // namespace android
|