am 39ec4298: Have SyncManager.ping check that the service is properly started

Merge commit '39ec429862545b622e166bb0d0a5cf0c1e0e019e' into eclair-plus-aosp

* commit '39ec429862545b622e166bb0d0a5cf0c1e0e019e':
  Have SyncManager.ping check that the service is properly started
This commit is contained in:
Marc Blank 2009-09-22 13:32:06 -07:00 committed by Android Git Automerger
commit 27c713b344

View File

@ -280,14 +280,7 @@ public class SyncManager extends Service implements Runnable {
} }
public void startSync(long mailboxId) throws RemoteException { public void startSync(long mailboxId) throws RemoteException {
if (INSTANCE == null) return; checkSyncManagerServiceRunning();
// Get the service thread running if it isn't
// This is a stopgap for cases in which SyncManager died (due to a crash somewhere in
// com.android.email) and hasn't been restarted
// See the comment for onCreate for details
if (sServiceThread == null) {
startService(new Intent(INSTANCE, SyncManager.class));
}
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId); Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId);
if (m.mType == Mailbox.TYPE_OUTBOX) { if (m.mType == Mailbox.TYPE_OUTBOX) {
// We're using SERVER_ID to indicate an error condition (it has no other use for // We're using SERVER_ID to indicate an error condition (it has no other use for
@ -858,6 +851,18 @@ public class SyncManager extends Service implements Runnable {
} }
} }
static void checkSyncManagerServiceRunning() {
// Get the service thread running if it isn't
// This is a stopgap for cases in which SyncManager died (due to a crash somewhere in
// com.android.email) and hasn't been restarted
// See the comment for onCreate for details
if (INSTANCE == null) return;
if (sServiceThread == null) {
INSTANCE.alwaysLog("!!! checkSyncManagerServiceRunning; starting service...");
INSTANCE.startService(new Intent(INSTANCE, SyncManager.class));
}
}
static public ConnPerRoute sConnPerRoute = new ConnPerRoute() { static public ConnPerRoute sConnPerRoute = new ConnPerRoute() {
public int getMaxForRoute(HttpRoute route) { public int getMaxForRoute(HttpRoute route) {
return 8; return 8;
@ -1084,6 +1089,7 @@ public class SyncManager extends Service implements Runnable {
} }
static public void ping(Context context, long id) { static public void ping(Context context, long id) {
checkSyncManagerServiceRunning();
if (id < 0) { if (id < 0) {
kick("ping SyncManager"); kick("ping SyncManager");
} else if (INSTANCE == null) { } else if (INSTANCE == null) {