|
21 | 21 | import android.accounts.AccountManager; |
22 | 22 | import android.accounts.AccountManagerService; |
23 | 23 | import android.app.ActivityManager; |
24 | | -import android.app.ActivityManagerNative; |
25 | 24 | import android.app.AlarmManager; |
26 | 25 | import android.app.Notification; |
27 | 26 | import android.app.NotificationManager; |
@@ -154,7 +153,9 @@ public class SyncManager { |
154 | 153 | private AlarmManager mAlarmService = null; |
155 | 154 |
|
156 | 155 | private SyncStorageEngine mSyncStorageEngine; |
157 | | - final public SyncQueue mSyncQueue; |
| 156 | + |
| 157 | + // @GuardedBy("mSyncQueue") |
| 158 | + private final SyncQueue mSyncQueue; |
158 | 159 |
|
159 | 160 | protected final ArrayList<ActiveSyncContext> mActiveSyncContexts = Lists.newArrayList(); |
160 | 161 |
|
@@ -902,7 +903,9 @@ private void onUserStarting(int userId) { |
902 | 903 |
|
903 | 904 | updateRunningAccounts(); |
904 | 905 |
|
905 | | - mSyncQueue.addPendingOperations(userId); |
| 906 | + synchronized (mSyncQueue) { |
| 907 | + mSyncQueue.addPendingOperations(userId); |
| 908 | + } |
906 | 909 |
|
907 | 910 | // Schedule sync for any accounts under started user |
908 | 911 | final Account[] accounts = AccountManagerService.getSingleton().getAccounts(userId); |
@@ -1957,10 +1960,10 @@ private long maybeStartNextSyncLocked() { |
1957 | 1960 | synchronized (mSyncQueue) { |
1958 | 1961 | if (isLoggable) { |
1959 | 1962 | Log.v(TAG, "build the operation array, syncQueue size is " |
1960 | | - + mSyncQueue.mOperationsMap.size()); |
| 1963 | + + mSyncQueue.getOperations().size()); |
1961 | 1964 | } |
1962 | | - Iterator<SyncOperation> operationIterator = |
1963 | | - mSyncQueue.mOperationsMap.values().iterator(); |
| 1965 | + final Iterator<SyncOperation> operationIterator = mSyncQueue.getOperations() |
| 1966 | + .iterator(); |
1964 | 1967 |
|
1965 | 1968 | final ActivityManager activityManager |
1966 | 1969 | = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); |
@@ -2153,7 +2156,7 @@ private long maybeStartNextSyncLocked() { |
2153 | 2156 | runSyncFinishedOrCanceledLocked(null, toReschedule); |
2154 | 2157 | scheduleSyncOperation(toReschedule.mSyncOperation); |
2155 | 2158 | } |
2156 | | - synchronized (mSyncQueue){ |
| 2159 | + synchronized (mSyncQueue) { |
2157 | 2160 | mSyncQueue.remove(candidate); |
2158 | 2161 | } |
2159 | 2162 | dispatchSyncOperation(candidate); |
|
0 commit comments