mirror of https://github.com/M66B/FairEmail.git
Cleanup on boot/update
This commit is contained in:
parent
2067d89666
commit
4bfef11c2e
|
@ -22,9 +22,8 @@ package eu.faircode.email;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||||
|
|
||||||
public class ReceiverAutoStart extends BroadcastReceiver {
|
public class ReceiverAutoStart extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,15 +31,22 @@ public class ReceiverAutoStart extends BroadcastReceiver {
|
||||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) ||
|
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) ||
|
||||||
Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
|
Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
|
||||||
Log.i("Received " + intent);
|
Log.i("Received " + intent);
|
||||||
|
|
||||||
ServiceSynchronize.boot(context);
|
ServiceSynchronize.boot(context);
|
||||||
ServiceSend.boot(context);
|
ServiceSend.boot(context);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
Thread cleanup = new Thread(new Runnable() {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
@Override
|
||||||
if (!prefs.getBoolean("unified", true))
|
public void run() {
|
||||||
editor.putString("startup", "folders");
|
try {
|
||||||
editor.remove("unified");
|
WorkerCleanup.cleanup(context, true);
|
||||||
editor.apply();
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cleanup.setPriority(THREAD_PRIORITY_BACKGROUND);
|
||||||
|
cleanup.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue