diff options
author | Alon Albert <aalbert@google.com> | 2010-12-09 14:08:27 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-12-09 14:08:27 -0800 |
commit | 6a843d03c7eaf4fa3c11798585626d68d81a9304 (patch) | |
tree | 0397bf5dc4e2c348b31fd4e7fc3f44e562f1e4bd /core | |
parent | 41cb9d10de37fd05277288d2f01ad74ac11d2edf (diff) | |
parent | eca7511f61a6bfbb43a6646f87b5771bcc5d3fdc (diff) | |
download | frameworks_base-6a843d03c7eaf4fa3c11798585626d68d81a9304.zip frameworks_base-6a843d03c7eaf4fa3c11798585626d68d81a9304.tar.gz frameworks_base-6a843d03c7eaf4fa3c11798585626d68d81a9304.tar.bz2 |
Merge "Listen for SyncAdapter death to cancel a sync"
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/content/SyncManager.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 221fe23..a6ffed6 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -873,7 +873,8 @@ public class SyncManager implements OnAccountsUpdateListener { /** * @hide */ - class ActiveSyncContext extends ISyncContext.Stub implements ServiceConnection { + class ActiveSyncContext extends ISyncContext.Stub + implements ServiceConnection, IBinder.DeathRecipient { final SyncOperation mSyncOperation; final long mHistoryRowId; ISyncAdapter mSyncAdapter; @@ -883,6 +884,7 @@ public class SyncManager implements OnAccountsUpdateListener { final PowerManager.WakeLock mSyncWakeLock; final int mSyncAdapterUid; SyncInfo mSyncInfo; + boolean mIsLinkedToDeath = false; /** * Create an ActiveSyncContext for an impending sync and grab the wakelock for that @@ -984,6 +986,11 @@ public class SyncManager implements OnAccountsUpdateListener { toString(sb); return sb.toString(); } + + @Override + public void binderDied() { + sendSyncFinishedOrCanceledMessage(this, null); + } } protected void dump(FileDescriptor fd, PrintWriter pw) { @@ -1798,11 +1805,14 @@ public class SyncManager implements OnAccountsUpdateListener { return true; } - private void runBoundToSyncAdapter(ActiveSyncContext activeSyncContext, + private void runBoundToSyncAdapter(final ActiveSyncContext activeSyncContext, ISyncAdapter syncAdapter) { activeSyncContext.mSyncAdapter = syncAdapter; final SyncOperation syncOperation = activeSyncContext.mSyncOperation; try { + activeSyncContext.mIsLinkedToDeath = true; + syncAdapter.asBinder().linkToDeath(activeSyncContext, 0); + syncAdapter.startSync(activeSyncContext, syncOperation.authority, syncOperation.account, syncOperation.extras); } catch (RemoteException remoteExc) { @@ -1842,6 +1852,11 @@ public class SyncManager implements OnAccountsUpdateListener { private void runSyncFinishedOrCanceledLocked(SyncResult syncResult, ActiveSyncContext activeSyncContext) { boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); + + if (activeSyncContext.mIsLinkedToDeath) { + activeSyncContext.mSyncAdapter.asBinder().unlinkToDeath(activeSyncContext, 0); + activeSyncContext.mIsLinkedToDeath = false; + } closeActiveSyncContext(activeSyncContext); final SyncOperation syncOperation = activeSyncContext.mSyncOperation; |