Skip to content

Commit 2067ef5

Browse files
committed
BootBroadcastReceiver: fix crash on Android 8+
1 parent 4174081 commit 2067ef5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/src/main/java/org/itxtech/daedalus/Daedalus.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ public static boolean prepareAndActivateService(Context context) {
210210
}
211211

212212
public static void activateService(Context context) {
213+
activateService(context, false);
214+
}
215+
216+
public static void activateService(Context context, boolean forceForeground) {
213217
DaedalusVpnService.primaryServer = (AbstractDnsServer) DnsServerHelper.getServerById(DnsServerHelper.getPrimary()).clone();
214218
DaedalusVpnService.secondaryServer = (AbstractDnsServer) DnsServerHelper.getServerById(DnsServerHelper.getSecondary()).clone();
215-
if (getInstance().prefs.getBoolean("settings_foreground", false)
219+
if ((getInstance().prefs.getBoolean("settings_foreground", false) || forceForeground)
216220
&& Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
217221
Logger.info("Starting foreground service");
218222
context.startForegroundService(Daedalus.getServiceIntent(context).setAction(DaedalusVpnService.ACTION_ACTIVATE));

app/src/main/java/org/itxtech/daedalus/receiver/BootBroadcastReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
2121
@Override
2222
public void onReceive(Context context, Intent intent) {
2323
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
24-
Daedalus.activateService(context);
24+
Daedalus.activateService(context, true);
2525
Logger.info("Triggered boot receiver");
2626
}
2727
}

0 commit comments

Comments
 (0)