diff --git a/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java b/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java index 25ba55d6..67649a9b 100644 --- a/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java +++ b/play-services-core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java @@ -36,11 +36,10 @@ public class ForegroundServiceContext extends ContextWrapper { if (!isIgnoringBatteryOptimizations() && !isAppOnForeground()) { Log.d(TAG, "Starting in foreground mode."); service.putExtra(EXTRA_FOREGROUND, true); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - return super.startService(service); - } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { return super.startForegroundService(service); + } else { + return super.startService(service); } } return super.startService(service); diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java b/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java index 15aaecc1..5486e38c 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/PushRegisterHandler.java @@ -20,6 +20,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Binder; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -27,6 +28,8 @@ import android.os.Messenger; import android.os.RemoteException; import android.util.Log; +import androidx.annotation.RequiresApi; + import org.microg.gms.checkin.LastCheckinInfo; import org.microg.gms.common.ForegroundServiceContext; import org.microg.gms.common.PackageUtils; @@ -108,6 +111,7 @@ class PushRegisterHandler extends Handler { return PendingIntent.getBroadcast(context, 0, intent, 0); } + @RequiresApi(api = Build.VERSION_CODES.M) @Override public void handleMessage(Message msg) { if (msg.what == 0) {