mirror of
https://github.com/M66B/NetGuard.git
synced 2025-03-07 04:09:05 +00:00
Prevent loop
This commit is contained in:
parent
db7aaa69b7
commit
5b8939720e
1 changed files with 36 additions and 30 deletions
|
@ -21,6 +21,7 @@ package eu.faircode.netguard;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
|
import android.app.ForegroundServiceStartNotAllowedException;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -3296,12 +3297,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
try {
|
try {
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// ForegroundServiceStartNotAllowedException
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
try {
|
ex instanceof ForegroundServiceStartNotAllowedException)
|
||||||
context.startService(intent);
|
try {
|
||||||
} catch (Throwable exex) {
|
context.startService(intent);
|
||||||
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
} catch (Throwable exex) {
|
||||||
}
|
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3312,12 +3314,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
try {
|
try {
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// ForegroundServiceStartNotAllowedException
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
try {
|
ex instanceof ForegroundServiceStartNotAllowedException)
|
||||||
context.startService(intent);
|
try {
|
||||||
} catch (Throwable exex) {
|
context.startService(intent);
|
||||||
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
} catch (Throwable exex) {
|
||||||
}
|
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3331,12 +3334,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
try {
|
try {
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// ForegroundServiceStartNotAllowedException
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
try {
|
ex instanceof ForegroundServiceStartNotAllowedException)
|
||||||
context.startService(intent);
|
try {
|
||||||
} catch (Throwable exex) {
|
context.startService(intent);
|
||||||
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
} catch (Throwable exex) {
|
||||||
}
|
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3349,12 +3353,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
try {
|
try {
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// ForegroundServiceStartNotAllowedException
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
try {
|
ex instanceof ForegroundServiceStartNotAllowedException)
|
||||||
context.startService(intent);
|
try {
|
||||||
} catch (Throwable exex) {
|
context.startService(intent);
|
||||||
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
} catch (Throwable exex) {
|
||||||
}
|
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3365,12 +3370,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
try {
|
try {
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// ForegroundServiceStartNotAllowedException
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
try {
|
ex instanceof ForegroundServiceStartNotAllowedException)
|
||||||
context.startService(intent);
|
try {
|
||||||
} catch (Throwable exex) {
|
context.startService(intent);
|
||||||
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
} catch (Throwable exex) {
|
||||||
}
|
Log.e(TAG, exex + "\n" + Log.getStackTraceString(exex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue