mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-12-04 16:57:27 +00:00
When check-in fails due to missing internet access, try again as soon as access is restored
This commit is contained in:
parent
1367649a18
commit
f806e1bcdb
1 changed files with 13 additions and 0 deletions
|
@ -16,16 +16,21 @@
|
|||
|
||||
package org.microg.gms.checkin;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkRequest;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.legacy.content.WakefulBroadcastReceiver;
|
||||
|
||||
import org.microg.gms.common.ForegroundServiceContext;
|
||||
|
||||
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static org.microg.gms.checkin.CheckinService.EXTRA_FORCE_CHECKIN;
|
||||
import static org.microg.gms.checkin.CheckinService.REGULAR_CHECKIN_INTERVAL;
|
||||
|
||||
|
@ -50,6 +55,14 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
|
|||
Intent subIntent = new Intent(context, CheckinService.class);
|
||||
subIntent.putExtra(EXTRA_FORCE_CHECKIN, force);
|
||||
startWakefulService(new ForegroundServiceContext(context), subIntent);
|
||||
} else if (SDK_INT >= 23) {
|
||||
// no network, register a network callback to retry when we have internet
|
||||
NetworkRequest networkRequest = new NetworkRequest.Builder()
|
||||
.addCapability(NET_CAPABILITY_INTERNET)
|
||||
.build();
|
||||
Intent i = new Intent(context, TriggerReceiver.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, i, FLAG_UPDATE_CURRENT);
|
||||
cm.registerNetworkCallback(networkRequest, pendingIntent);
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "Ignoring " + intent + ": checkin is disabled");
|
||||
|
|
Loading…
Reference in a new issue