From 9531e5ea5f80736af41d6d1e81b61dc322433499 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sat, 18 Aug 2012 17:19:37 -0700 Subject: Revert "Make sure that all access to service map is lock-protected" This reverts commit 9d593aab1b5b4af6df4d9bbc3f4126da4ec2e2a0 Change-Id: I2b8f044e2119c60b9a42c7cb84577147c89ea0cb --- .../src/com/android/emailsync/SyncManager.java | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'emailsync') diff --git a/emailsync/src/com/android/emailsync/SyncManager.java b/emailsync/src/com/android/emailsync/SyncManager.java index 965391167..b331501bb 100644 --- a/emailsync/src/com/android/emailsync/SyncManager.java +++ b/emailsync/src/com/android/emailsync/SyncManager.java @@ -1093,7 +1093,7 @@ public abstract class SyncManager extends Service implements Runnable { } else if (ssm == null) { context.startService(new Intent(context, SyncManager.class)); } else { - final AbstractSyncService service = ssm.getRunningService(id); + final AbstractSyncService service = ssm.mServiceMap.get(id); if (service != null) { // Handle alerts in a background thread, as we are typically called from a // broadcast receiver, and are therefore running in the UI thread @@ -1679,18 +1679,6 @@ public abstract class SyncManager extends Service implements Runnable { releaseWakeLock(mailboxId); } - /** - * Retrieve a running sync service for the passed-in mailbox id in a threadsafe manner - * - * @param mailboxId the id of the mailbox whose service is to be found - * @return the running service (a subclass of AbstractSyncService) or null if none - */ - public AbstractSyncService getRunningService(long mailboxId) { - synchronized(sSyncLock) { - return mServiceMap.get(mailboxId); - } - } - /** * Check whether an Outbox (referenced by a Cursor) has any messages that can be sent * @param c the cursor to an Outbox @@ -1877,7 +1865,10 @@ public abstract class SyncManager extends Service implements Runnable { try { while (c.moveToNext()) { long mailboxId = c.getLong(Mailbox.CONTENT_ID_COLUMN); - AbstractSyncService service = getRunningService(mailboxId); + AbstractSyncService service = null; + synchronized (sSyncLock) { + service = mServiceMap.get(mailboxId); + } if (service == null) { // Get the cached account Account account = getAccountById(c.getInt(Mailbox.CONTENT_ACCOUNT_KEY_COLUMN)); @@ -1999,7 +1990,7 @@ public abstract class SyncManager extends Service implements Runnable { Mailbox m = Mailbox.restoreMailboxWithId(ssm, mailboxId); if (m == null || !isSyncable(m)) return; try { - AbstractSyncService service = ssm.getRunningService(mailboxId); + AbstractSyncService service = ssm.mServiceMap.get(mailboxId); if (service != null) { service.mRequestTime = System.currentTimeMillis() + ms; kick("service request"); @@ -2014,7 +2005,7 @@ public abstract class SyncManager extends Service implements Runnable { static public void serviceRequestImmediate(long mailboxId) { SyncManager ssm = INSTANCE; if (ssm == null) return; - AbstractSyncService service = ssm.getRunningService(mailboxId); + AbstractSyncService service = ssm.mServiceMap.get(mailboxId); if (service != null) { service.mRequestTime = System.currentTimeMillis(); Mailbox m = Mailbox.restoreMailboxWithId(ssm, mailboxId); @@ -2056,7 +2047,7 @@ public abstract class SyncManager extends Service implements Runnable { static public void sendRequest(long mailboxId, Request req) { SyncManager ssm = INSTANCE; if (ssm == null) return; - AbstractSyncService service = ssm.getRunningService(mailboxId); + AbstractSyncService service = ssm.mServiceMap.get(mailboxId); if (service == null) { startManualSync(mailboxId, SYNC_SERVICE_PART_REQUEST, req); kick("part request"); @@ -2076,7 +2067,7 @@ public abstract class SyncManager extends Service implements Runnable { SyncManager ssm = INSTANCE; if (ssm == null) return PING_STATUS_OK; // Already syncing... - if (ssm.getRunningService(mailboxId) != null) { + if (ssm.mServiceMap.get(mailboxId) != null) { return PING_STATUS_RUNNING; } // No errors or a transient error, don't ping... @@ -2158,7 +2149,7 @@ public abstract class SyncManager extends Service implements Runnable { } private boolean isRunningInServiceThread(long mailboxId) { - AbstractSyncService syncService = getRunningService(mailboxId); + AbstractSyncService syncService = mServiceMap.get(mailboxId); Thread thisThread = Thread.currentThread(); return syncService != null && syncService.mThread != null && thisThread == syncService.mThread; -- cgit v1.2.3