mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-20 13:59:14 +00:00
Abstract setting the thread priority away into ProgressDialogTask
This commit is contained in:
parent
b9381d13d2
commit
488e92d429
3 changed files with 9 additions and 9 deletions
|
@ -1,10 +1,6 @@
|
|||
package me.impy.aegis.ui.tasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Process;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
|
@ -22,9 +18,9 @@ public class DerivationTask extends ProgressDialogTask<DerivationTask.Params, Se
|
|||
|
||||
@Override
|
||||
protected SecretKey doInBackground(DerivationTask.Params... args) {
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setPriority();
|
||||
|
||||
DerivationTask.Params params = args[0];
|
||||
Params params = args[0];
|
||||
try {
|
||||
byte[] salt = CryptoUtils.generateSalt();
|
||||
return params.Slot.deriveKey(params.Password, salt, CryptoUtils.CRYPTO_SCRYPT_N, CryptoUtils.CRYPTO_SCRYPT_r, CryptoUtils.CRYPTO_SCRYPT_p);
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.impy.aegis.ui.tasks;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Process;
|
||||
import android.support.annotation.CallSuper;
|
||||
|
||||
public abstract class ProgressDialogTask<Params, Result> extends AsyncTask<Params, Void, Result> {
|
||||
|
@ -28,6 +29,10 @@ public abstract class ProgressDialogTask<Params, Result> extends AsyncTask<Param
|
|||
}
|
||||
}
|
||||
|
||||
protected void setPriority() {
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
}
|
||||
|
||||
protected final ProgressDialog getDialog() {
|
||||
return _dialog;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.impy.aegis.ui.tasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Process;
|
||||
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
|
||||
|
@ -28,9 +27,9 @@ public class SlotCollectionTask<T extends Slot> extends ProgressDialogTask<SlotC
|
|||
|
||||
@Override
|
||||
protected MasterKey doInBackground(SlotCollectionTask.Params... args) {
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setPriority();
|
||||
|
||||
SlotCollectionTask.Params params = args[0];
|
||||
Params params = args[0];
|
||||
try {
|
||||
if (!params.Slots.has(_type)) {
|
||||
throw new RuntimeException();
|
||||
|
|
Loading…
Add table
Reference in a new issue