@@ -219,20 +219,13 @@ public void onReceive(Context context, Intent intent) {
219219 // Use this as a random offset to seed all periodic syncs
220220 private int mSyncRandomOffsetMillis ;
221221
222- private UserManager mUserManager ;
222+ private final UserManager mUserManager ;
223223
224224 private static final long SYNC_ALARM_TIMEOUT_MIN = 30 * 1000 ; // 30 seconds
225225 private static final long SYNC_ALARM_TIMEOUT_MAX = 2 * 60 * 60 * 1000 ; // two hours
226226
227- private UserManager getUserManager () {
228- if (mUserManager == null ) {
229- mUserManager = (UserManager ) mContext .getSystemService (Context .USER_SERVICE );
230- }
231- return mUserManager ;
232- }
233-
234227 private List <UserInfo > getAllUsers () {
235- return getUserManager () .getUsers ();
228+ return mUserManager .getUsers ();
236229 }
237230
238231 private boolean containsAccountAndUser (AccountAndUser [] accounts , Account account , int userId ) {
@@ -337,6 +330,7 @@ public SyncManager(Context context, boolean factoryTest) {
337330 // Initialize the SyncStorageEngine first, before registering observers
338331 // and creating threads and so on; it may fail if the disk is full.
339332 mContext = context ;
333+
340334 SyncStorageEngine .init (context );
341335 mSyncStorageEngine = SyncStorageEngine .getSingleton ();
342336 mSyncStorageEngine .setOnSyncRequestListener (new OnSyncRequestListener () {
@@ -402,6 +396,7 @@ public void onServiceChanged(SyncAdapterType type, int userId, boolean removed)
402396 mNotificationMgr = null ;
403397 }
404398 mPowerManager = (PowerManager ) context .getSystemService (Context .POWER_SERVICE );
399+ mUserManager = (UserManager ) mContext .getSystemService (Context .USER_SERVICE );
405400
406401 // This WakeLock is used to ensure that we stay awake between the time that we receive
407402 // a sync alarm notification and when we finish processing it. We need to do this
0 commit comments