mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: parts-aidl: Swap changes
* Remove join() call for std::thread which blocks the current context, halting the HAL thread also * access returns 0 on successful, so we should make file if return value isnt 0 * Set parts AIDL thread to 3, for SwapThread, other interactions, Binder transaction
This commit is contained in:
parent
76ac588516
commit
497fa53db9
2 changed files with 4 additions and 6 deletions
|
|
@ -45,19 +45,17 @@ static bool swapOnRes = false;
|
|||
|
||||
static void mkfile_swapon_thread(void) {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
if (access(SWAP_PATH, F_OK) == 0) {
|
||||
if (access(SWAP_PATH, F_OK) != 0) {
|
||||
mkfile(mSwapSize * 10, SWAP_PATH);
|
||||
mkswap(SWAP_PATH);
|
||||
}
|
||||
int res =
|
||||
swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK);
|
||||
int res = swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK);
|
||||
swapOnRes = res == 0;
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus SwapOnData::setSwapOn() {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
std::thread mkswapfile(mkfile_swapon_thread);
|
||||
mkswapfile.join();
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
|
@ -67,8 +65,8 @@ static void swapoff_thread(void) {
|
|||
}
|
||||
|
||||
::ndk::ScopedAStatus SwapOnData::setSwapOff() {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
std::thread swapoff(swapoff_thread);
|
||||
swapoff.join();
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ template <class C> static void registerAsService(std::shared_ptr<C> service) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(3);
|
||||
|
||||
registerAsService(ndk::SharedRefBase::make<BatteryStats>());
|
||||
registerAsService(ndk::SharedRefBase::make<DisplayConfigs>());
|
||||
|
|
|
|||
Loading…
Reference in a new issue