Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 734c91de authored by Christopher Tate's avatar Christopher Tate
Browse files

Start the sync job service after primary boot

This avoids starting the "timeout?" clock until the system's main looper
thread is ready to actually process service startup, avoiding spurious
ANR reports.

Bug 26922408

Change-Id: I8fd3f20e4af644a933f1318e623096b73c7e8e08
parent 4fb2d18c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -600,10 +600,19 @@ public class SyncManager {
                    null, null);
        }

        Intent startServiceIntent = new Intent(mContext, SyncJobService.class);
        // Set up the communication channel between the scheduled job and the sync manager.
        // This is posted to the *main* looper intentionally, to defer calling startService()
        // until after the lengthy primary boot sequence completes on that thread, to avoid
        // spurious ANR triggering.
        final Intent startServiceIntent = new Intent(mContext, SyncJobService.class);
        startServiceIntent.putExtra(SyncJobService.EXTRA_MESSENGER, new Messenger(mSyncHandler));
        new Handler(mContext.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                mContext.startService(startServiceIntent);
            }
        });
    }

    private boolean isDeviceProvisioned() {
        final ContentResolver resolver = mContext.getContentResolver();