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
This commit is contained in:
Dianne Hackborn
2013-04-30 17:24:15 -07:00
parent 54824c9538
commit f7c56ef9dd
2 changed files with 3 additions and 9 deletions

View File

@@ -19,7 +19,6 @@ package com.android.server;
import android.net.LocalSocket; import android.net.LocalSocket;
import android.net.LocalSocketAddress; import android.net.LocalSocketAddress;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.LocalLog; import android.util.LocalLog;
@@ -81,9 +80,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
@Override @Override
public void run() { public void run() {
HandlerThread thread = new HandlerThread(TAG + ".CallbackHandler"); mCallbackHandler = new Handler(FgThread.get().getLooper(), this);
thread.start();
mCallbackHandler = new Handler(thread.getLooper(), this);
while (true) { while (true) {
try { try {

View File

@@ -96,7 +96,6 @@ import android.os.Binder;
import android.os.DropBoxManager; import android.os.DropBoxManager;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread;
import android.os.INetworkManagementService; import android.os.INetworkManagementService;
import android.os.Message; import android.os.Message;
import android.os.PowerManager; import android.os.PowerManager;
@@ -120,6 +119,7 @@ import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FileRotator; import com.android.internal.util.FileRotator;
import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter;
import com.android.server.EventLogTags; import com.android.server.EventLogTags;
import com.android.server.IoThread;
import com.android.server.connectivity.Tethering; import com.android.server.connectivity.Tethering;
import com.google.android.collect.Maps; import com.google.android.collect.Maps;
@@ -240,7 +240,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
/** Data layer operation counters for splicing into other structures. */ /** Data layer operation counters for splicing into other structures. */
private NetworkStats mUidOperations = new NetworkStats(0L, 10); private NetworkStats mUidOperations = new NetworkStats(0L, 10);
private final HandlerThread mHandlerThread;
private final Handler mHandler; private final Handler mHandler;
private boolean mSystemReady; private boolean mSystemReady;
@@ -271,9 +270,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
Context.POWER_SERVICE); Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mHandlerThread = new HandlerThread(TAG); mHandler = new Handler(IoThread.get().getLooper(), mHandlerCallback);
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper(), mHandlerCallback);
mSystemDir = checkNotNull(systemDir); mSystemDir = checkNotNull(systemDir);
mBaseDir = new File(systemDir, "netstats"); mBaseDir = new File(systemDir, "netstats");