OSDN Git Service

Fixed a leaked partial wakelock in AbstractThreadedSyncAdapter.
authorDaniel Karlberg <daniel.karlberg@sonymobile.com>
Wed, 15 Aug 2012 08:00:41 +0000 (10:00 +0200)
committerJohan Redestig <johan.redestig@sonymobile.com>
Fri, 26 Jul 2013 18:19:48 +0000 (18:19 +0000)
This fix ensures that onFinished() is always called in a syncClient
even if the application lacks the READ_SYNC_SETTINGS permission.

Change-Id: I944717e71ceae06a665f8a3b1199b41d73e12da4

core/java/android/content/AbstractThreadedSyncAdapter.java

index bafe67d..898cc4e 100644 (file)
@@ -160,10 +160,13 @@ public abstract class AbstractThreadedSyncAdapter {
                     if (mAutoInitialize
                             && extras != null
                             && extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
-                        if (ContentResolver.getIsSyncable(account, authority) < 0) {
-                            ContentResolver.setIsSyncable(account, authority, 1);
+                        try {
+                            if (ContentResolver.getIsSyncable(account, authority) < 0) {
+                                ContentResolver.setIsSyncable(account, authority, 1);
+                            }
+                        } finally {
+                            syncContextClient.onFinished(new SyncResult());
                         }
-                        syncContextClient.onFinished(new SyncResult());
                         return;
                     }
                     SyncThread syncThread = new SyncThread(