Fix potential crash in sync.

Change-Id: I523d8faa24b7ba57dcc09cbe91b5cb91d9f6f262
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 3e44fcf..26b6ad7 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1696,16 +1696,17 @@
                 Log.v(TAG, "runStateIdle: setting mActiveSyncContext to " + mActiveSyncContext);
             }
             mSyncStorageEngine.setActiveSync(mActiveSyncContext);
-            mSyncWakeLock.setWorkSource(new WorkSource(syncAdapterInfo.uid));
             if (!activeSyncContext.bindToSyncAdapter(syncAdapterInfo)) {
                 Log.e(TAG, "Bind attempt failed to " + syncAdapterInfo);
                 mActiveSyncContext.close();
                 mActiveSyncContext = null;
                 mSyncStorageEngine.setActiveSync(mActiveSyncContext);
+                mSyncWakeLock.setWorkSource(null);
                 runStateIdle();
                 return;
             }
 
+            mSyncWakeLock.setWorkSource(new WorkSource(syncAdapterInfo.uid));
             mSyncWakeLock.acquire();
             // no need to schedule an alarm, as that will be done by our caller.