Use a Thread instead of an AsyncTask to delete downloads

This commit is contained in:
Gabriele M
2017-07-04 19:05:04 +02:00
parent 4dcf4199f1
commit c13d79b39c

View File

@@ -17,7 +17,6 @@ package org.lineageos.updater.controller;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
@@ -305,17 +304,17 @@ public class UpdaterController implements UpdaterControllerInt {
} }
private void deleteUpdateAsync(final String downloadId) { private void deleteUpdateAsync(final String downloadId) {
new AsyncTask<Void, Void, Void>() { new Thread(new Runnable() {
protected Void doInBackground(Void... voids) { @Override
public void run() {
UpdateDownload update = mDownloads.get(downloadId).mUpdate; UpdateDownload update = mDownloads.get(downloadId).mUpdate;
File file = update.getFile(); File file = update.getFile();
if (file.exists() && !file.delete()) { if (file.exists() && !file.delete()) {
Log.e(TAG, "Could not delete " + file.getAbsolutePath()); Log.e(TAG, "Could not delete " + file.getAbsolutePath());
} }
mUpdatesDbHelper.removeUpdate(downloadId); mUpdatesDbHelper.removeUpdate(downloadId);
return null;
} }
}.execute(); }).start();
} }
@Override @Override