From 2e76a9ba541ed07cb544fe4b3d8be59de7598266 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Mon, 14 May 2018 11:14:19 -0400 Subject: [PATCH] Protect against multiple starts of device index job Its rare, but can happen. Test: existing tests pass Change-Id: Ie7aaa47902741d5f7fdd954f35e8f13e9466e07c Fixes: 78898947 --- .../settings/search/DeviceIndexUpdateJobService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/search/DeviceIndexUpdateJobService.java b/src/com/android/settings/search/DeviceIndexUpdateJobService.java index 12a9cf00fcb..510da3a6226 100644 --- a/src/com/android/settings/search/DeviceIndexUpdateJobService.java +++ b/src/com/android/settings/search/DeviceIndexUpdateJobService.java @@ -53,10 +53,12 @@ public class DeviceIndexUpdateJobService extends JobService { @Override public boolean onStartJob(JobParameters params) { if (DEBUG) Log.d(TAG, "onStartJob"); - mRunningJob = true; - Thread thread = new Thread(() -> updateIndex(params)); - thread.setPriority(Thread.MIN_PRIORITY); - thread.start(); + if (!mRunningJob) { + mRunningJob = true; + Thread thread = new Thread(() -> updateIndex(params)); + thread.setPriority(Thread.MIN_PRIORITY); + thread.start(); + } return true; }