Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
GmsCore
Commits
dac4d861
Commit
dac4d861
authored
Dec 01, 2021
by
Aayush Gupta
Browse files
Merge branch 'microg-upstream' into 'master'
Fix Device registration See merge request e/apps/GmsCore!36
parents
0be19728
346d0617
Pipeline
#152335
passed with stage
in 9 minutes
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
play-services-core/src/main/java/org/microg/gms/checkin/TriggerReceiver.java
View file @
dac4d861
...
...
@@ -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"
);
...
...
play-services-core/src/main/java/org/microg/gms/gcm/TriggerReceiver.java
View file @
dac4d861
...
...
@@ -25,6 +25,7 @@ import android.util.Log;
import
androidx.legacy.content.WakefulBroadcastReceiver
;
import
org.microg.gms.checkin.CheckinPrefs
;
import
org.microg.gms.checkin.LastCheckinInfo
;
import
org.microg.gms.common.ForegroundServiceContext
;
...
...
@@ -67,6 +68,14 @@ public class TriggerReceiver extends WakefulBroadcastReceiver {
if
(
LastCheckinInfo
.
read
(
context
).
getAndroidId
()
==
0
)
{
Log
.
d
(
TAG
,
"Ignoring "
+
intent
+
": need to checkin first."
);
if
(
CheckinPrefs
.
isEnabled
(
context
))
{
// Do a check-in if we are not actually checked in,
// but should be, e.g. cleared app data
Log
.
d
(
TAG
,
"Requesting check-in..."
);
String
action
=
"android.server.checkin.CHECKIN"
;
Class
<?>
clazz
=
org
.
microg
.
gms
.
checkin
.
TriggerReceiver
.
class
;
context
.
sendBroadcast
(
new
Intent
(
action
,
null
,
context
,
clazz
));
}
return
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment