홈 복귀 시 사용 통계 동기화 메인 스레드 블로킹 제거
- LauncherActivity.onResume(): WorkersDb.syncSystemUsageStats()를 lifecycleScope.launch(Dispatchers.IO)로 비동기 실행 - WorkersDb.syncSystemUsageStats(): 3분 쿨다운 적용 및 AppInfo 일괄 조회(associateBy)로 N+1 Realm 쿼리 제거
This commit is contained in:
@@ -22,6 +22,7 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import android.provider.OpenableColumns
|
||||
import android.provider.Settings
|
||||
import android.view.GestureDetector
|
||||
@@ -1076,7 +1077,10 @@ open class LauncherActivity : CommonActivity() {
|
||||
super.onResume()
|
||||
Blog.LOGE("LauncherActivity onResume")
|
||||
if (checkUsageStatsPermission()) {
|
||||
WorkersDb.syncSystemUsageStats(applicationContext)
|
||||
val appCtx = applicationContext
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
WorkersDb.syncSystemUsageStats(appCtx)
|
||||
}
|
||||
} else {
|
||||
requestPermission()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user