From 8d044e8bc287c1a567d82aedbe30085b011544c3 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 30 Apr 2013 17:24:15 -0700 Subject: Start combining threads in system process. This introduces four generic thread that services can use in the system process: - Background: part of the framework for all processes, for work that is purely background (no timing constraint). - UI: for time-critical display of UI. - Foreground: normal foreground work. - IO: performing IO operations. I went through and moved services into these threads in the places I felt relatively comfortable about understanding what they are doing. There are still a bunch more we need to look at -- lots of networking stuff left, 3 or so different native daemon connectors which I didn't know how much would block, audio stuff, etc. Also updated Watchdog to be aware of and check these new threads, with a new API for other threads to also participate in this checking. Change-Id: Ie2f11061cebde5f018d7383b3a910fbbd11d5e11 --- services/java/com/android/server/NetworkTimeUpdateService.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'services/java/com/android/server/NetworkTimeUpdateService.java') diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java index 3bfd1909cf22..02b42b81de67 100644 --- a/services/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/java/com/android/server/NetworkTimeUpdateService.java @@ -27,7 +27,6 @@ import android.database.ContentObserver; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Handler; -import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.SystemClock; @@ -36,6 +35,7 @@ import android.util.Log; import android.util.NtpTrustedTime; import android.util.TrustedTime; +import com.android.internal.os.BackgroundThread; import com.android.internal.telephony.TelephonyIntents; /** @@ -71,7 +71,6 @@ public class NetworkTimeUpdateService { // NTP lookup is done on this thread and handler private Handler mHandler; - private HandlerThread mThread; private AlarmManager mAlarmManager; private PendingIntent mPendingPollIntent; private SettingsObserver mSettingsObserver; @@ -114,9 +113,7 @@ public class NetworkTimeUpdateService { registerForAlarms(); registerForConnectivityIntents(); - mThread = new HandlerThread(TAG); - mThread.start(); - mHandler = new MyHandler(mThread.getLooper()); + mHandler = new MyHandler(BackgroundThread.get().getLooper()); // Check the network time on the new thread mHandler.obtainMessage(EVENT_POLL_NETWORK_TIME).sendToTarget(); -- cgit v1.2.3