|
|
|
@ -19,19 +19,18 @@ package eu.faircode.email;
|
|
|
|
|
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
|
|
public class ReceiverAutoStart extends BroadcastReceiver {
|
|
|
|
|
// https://developer.android.com/reference/android/app/AlarmManager#ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED
|
|
|
|
|
private final String ACTION_EXACT =
|
|
|
|
|
"android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(final Context context, Intent intent) {
|
|
|
|
|
String action = intent.getAction();
|
|
|
|
|
if (ACTION_EXACT.equals(action) ||
|
|
|
|
|
if (AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED.equals(action) ||
|
|
|
|
|
Intent.ACTION_BOOT_COMPLETED.equals(action) ||
|
|
|
|
|
Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) {
|
|
|
|
|
EntityLog.log(context, "Received " + intent);
|
|
|
|
@ -39,12 +38,13 @@ public class ReceiverAutoStart extends BroadcastReceiver {
|
|
|
|
|
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(action))
|
|
|
|
|
ApplicationEx.upgrade(context);
|
|
|
|
|
|
|
|
|
|
if (ACTION_EXACT.equals(action))
|
|
|
|
|
ServiceSynchronize.reload(context, null, false, action);
|
|
|
|
|
else {
|
|
|
|
|
ServiceSynchronize.boot(context);
|
|
|
|
|
ServiceSend.boot(context);
|
|
|
|
|
if (AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED.equals(action)) {
|
|
|
|
|
ServiceSynchronize.stop(context);
|
|
|
|
|
ServiceSend.stop(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ServiceSynchronize.boot(context);
|
|
|
|
|
ServiceSend.boot(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|