Prevent using background service on Android O+

pull/187/head
M66B 4 years ago
parent f8afd831d9
commit 9b1348a634

@ -958,6 +958,10 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
if ("alert_once".equals(key) && !Log.isXiaomi())
continue;
if ("background_service".equals(key) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
continue;
if (key != null && key.startsWith("widget."))
continue;

@ -351,6 +351,9 @@ public class ApplicationEx extends Application implements SharedPreferences.OnSh
editor.putBoolean("beige", false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
editor.remove("background_service");
if (version < BuildConfig.VERSION_CODE)
editor.putInt("previous_version", version);
editor.putInt("version", BuildConfig.VERSION_CODE);

@ -2256,7 +2256,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static void start(Context context, Intent intent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean background_service = prefs.getBoolean("background_service", false);
if (background_service && Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
if (background_service)
context.startService(intent);
else
ContextCompat.startForegroundService(context, intent);

Loading…
Cancel
Save