This commit is contained in:
Oizaro 2020-09-20 01:21:47 +02:00
parent a9ee2e5065
commit 1ccd603860
2 changed files with 6 additions and 3 deletions

View File

@ -36,11 +36,10 @@ public class ForegroundServiceContext extends ContextWrapper {
if (!isIgnoringBatteryOptimizations() && !isAppOnForeground()) { if (!isIgnoringBatteryOptimizations() && !isAppOnForeground()) {
Log.d(TAG, "Starting in foreground mode."); Log.d(TAG, "Starting in foreground mode.");
service.putExtra(EXTRA_FOREGROUND, true); 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) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return super.startForegroundService(service); return super.startForegroundService(service);
} else {
return super.startService(service);
} }
} }
return super.startService(service); return super.startService(service);

View File

@ -20,6 +20,7 @@ import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -27,6 +28,8 @@ import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import androidx.annotation.RequiresApi;
import org.microg.gms.checkin.LastCheckinInfo; import org.microg.gms.checkin.LastCheckinInfo;
import org.microg.gms.common.ForegroundServiceContext; import org.microg.gms.common.ForegroundServiceContext;
import org.microg.gms.common.PackageUtils; import org.microg.gms.common.PackageUtils;
@ -108,6 +111,7 @@ class PushRegisterHandler extends Handler {
return PendingIntent.getBroadcast(context, 0, intent, 0); return PendingIntent.getBroadcast(context, 0, intent, 0);
} }
@RequiresApi(api = Build.VERSION_CODES.M)
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (msg.what == 0) { if (msg.what == 0) {