universal7885: parts: Use isMutexLocked() to disable switch if needed

This commit is contained in:
roynatech2544 2022-10-11 12:33:05 +09:00
commit c12209095a
4 changed files with 9 additions and 2 deletions

View file

@ -33,7 +33,7 @@ void SmartChargeImpl::start(void) {
shouldRun = true;
monitor = new std::thread(battery_monitor, limit_percent, restart_percent,
&charge_limit_cnt, &restart_cnt);
monitor->join();
monitor->detach();
}
void SmartChargeImpl::stop(void) {

View file

@ -75,12 +75,12 @@ static void swapon_func(void) {
}
static void swapoff_func(void) {
if (!swapfile_exist()) return;
const std::lock_guard<std::mutex> lock(thread_lock);
swapoff(SWAP_PATH);
}
::ndk::ScopedAStatus SwapOnData::setSwapOff() {
if (!swapfile_exist()) return ::ndk::ScopedAStatus::ok();
std::thread swapoff_thread(swapoff_func);
swapoff_thread.detach();
return ::ndk::ScopedAStatus::ok();