Add bindService API to not bring ot foreground.

Add a new flag for bindService that tells the system to not bring the
target service's process in to the foreground scheduling class.  This is
used by the sync system to not cause the current sync adapter to come to
the foreground as it is running.

Also some small improvements to the debug output of the process list
of oom adj and scheduling info.
This commit is contained in:
Dianne Hackborn
2009-12-08 14:50:51 -08:00
parent ea4823c1c7
commit 09c916bccb
4 changed files with 127 additions and 20 deletions

View File

@ -104,6 +104,18 @@ public abstract class Context {
*/
public static final int BIND_DEBUG_UNBIND = 0x0002;
/**
* Flag for {@link #bindService}: don't allow this binding to raise
* the target service's process to the foreground scheduling priority.
* It will still be raised to the at least the same memory priority
* as the client (so that its process will not be killable in any
* situation where the client is not killable), but for CPU scheduling
* purposes it may be left in the background. This only has an impact
* in the situation where the binding client is a foreground process
* and the target service is in a background process.
*/
public static final int BIND_NOT_FOREGROUND = 0x0004;
/** Return an AssetManager instance for your application's package. */
public abstract AssetManager getAssets();

View File

@ -557,7 +557,7 @@ class SyncManager implements OnAccountsUpdateListener {
intent.setAction("android.content.SyncAdapter");
intent.setComponent(syncAdapterInfo.componentName);
mContext.bindService(intent, new InitializerServiceConnection(account, authority),
Context.BIND_AUTO_CREATE);
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND);
}
private class InitializerServiceConnection implements ServiceConnection {
@ -1145,7 +1145,8 @@ class SyncManager implements OnAccountsUpdateListener {
com.android.internal.R.string.sync_binding_label);
intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
mContext, 0, new Intent(Settings.ACTION_SYNC_SETTINGS), 0));
return mContext.bindService(intent, this, Context.BIND_AUTO_CREATE);
return mContext.bindService(intent, this,
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND);
}
void unBindFromSyncAdapter() {