From 109acc1b1566729d39be41324830572c05ebcdd8 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 18 Sep 2013 16:28:50 -0700 Subject: [PATCH] Use a separate thread for services that do NTP lookup Some services do periodic network time lookups and can wedge the other operations on BackgroundThread and IO Thread, causing Watchdog to kill the runtime. So best to put those handlers on separate threads. Going forward, should convert NTP lookups to be async with callbacks. Bug: 10646480 Change-Id: I8c7ba6052cb3539575712c2099a706b14ff60196 --- .../java/com/android/server/net/NetworkStatsService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 1e8a7b0176..5d6adc2268 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -96,6 +96,7 @@ import android.os.Binder; import android.os.DropBoxManager; import android.os.Environment; import android.os.Handler; +import android.os.HandlerThread; import android.os.INetworkManagementService; import android.os.Message; import android.os.PowerManager; @@ -119,7 +120,6 @@ import com.android.internal.util.ArrayUtils; import com.android.internal.util.FileRotator; import com.android.internal.util.IndentingPrintWriter; import com.android.server.EventLogTags; -import com.android.server.IoThread; import com.android.server.connectivity.Tethering; import com.google.android.collect.Maps; @@ -270,7 +270,9 @@ public class NetworkStatsService extends INetworkStatsService.Stub { Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); - mHandler = new Handler(IoThread.get().getLooper(), mHandlerCallback); + HandlerThread thread = new HandlerThread(TAG); + thread.start(); + mHandler = new Handler(thread.getLooper(), mHandlerCallback); mSystemDir = checkNotNull(systemDir); mBaseDir = new File(systemDir, "netstats");