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 {
if (INSTANCE == null) return;
// 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));
}
checkSyncManagerServiceRunning();
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId);
if (m.mType == Mailbox.TYPE_OUTBOX) {
// 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() {
public int getMaxForRoute(HttpRoute route) {
return 8;
@ -1084,6 +1089,7 @@ public class SyncManager extends Service implements Runnable {
}
static public void ping(Context context, long id) {
checkSyncManagerServiceRunning();
if (id < 0) {
kick("ping SyncManager");
} else if (INSTANCE == null) {