From ed09b1af2dcb014f3b7c6a436c5cff552e749d10 Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Wed, 6 Apr 2016 15:42:36 +0200
Subject: [PATCH] run UpdateService at lowest priority possible

Currently, UpdateService is running at default priority, which is the same
as the UI tasks, since it is a regular IntentService.  That means it would
put a noticable load on the device when running, especially on older
devices.  This should help with that.

#563 https://gitlab.com/fdroid/fdroidclient/issues/563
---
 app/src/main/java/org/fdroid/fdroid/UpdateService.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java
index f95dae114..8f045744b 100644
--- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java
+++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java
@@ -31,6 +31,7 @@ import android.database.Cursor;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.Build;
+import android.os.Process;
 import android.os.SystemClock;
 import android.preference.PreferenceManager;
 import android.support.v4.app.NotificationCompat;
@@ -338,6 +339,7 @@ public class UpdateService extends IntentService implements ProgressListener {
 
     @Override
     protected void onHandleIntent(Intent intent) {
+        Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
 
         final long startTime = System.currentTimeMillis();
         String address = intent.getStringExtra(EXTRA_ADDRESS);