From 39ec429862545b622e166bb0d0a5cf0c1e0e019e Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 22 Sep 2009 13:17:08 -0700 Subject: [PATCH] Have SyncManager.ping check that the service is properly started * If not, it will start the service * This will catch cases in which the Email process has been killed while alarms are set (this would be the vast majority of the time) * Will look into ways of catching any remaining cases... * Fixes #2131432 Change-Id: Id71e68d14b5d1b0402c866db49a07c7b1adf499d --- src/com/android/exchange/SyncManager.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 7bb4376ea..b038ece3c 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -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) {