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
This commit is contained in:
Hans-Christoph Steiner 2016-04-06 15:42:36 +02:00
parent 22e40bfee1
commit ed09b1af2d

View File

@ -31,6 +31,7 @@ import android.database.Cursor;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Build; import android.os.Build;
import android.os.Process;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
@ -338,6 +339,7 @@ public class UpdateService extends IntentService implements ProgressListener {
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
String address = intent.getStringExtra(EXTRA_ADDRESS); String address = intent.getStringExtra(EXTRA_ADDRESS);