Commit Graph

54 Commits

Author SHA1 Message Date
Torsten Grote b9b1ef6246 Detect missing heartbeat ACKs and broken connections faster
Waiting twice the heartbeat interval since the last ACK can make us miss dead connections for more than 10min in which no push messages get received.

This change requires the ACK to come within 90 seconds of sending the heartbeat ping, otherwise the connection is considered dead which will trigger a re-connect.

We use a high timeout of 90 seconds, because in some mobile networks (like in trains) ping times of more than 60 seconds have been observed in practice.

Change-Id: I8e63843400b47e1a6d23faf180f9446bcb5e0cd8
2022-01-25 12:37:08 +01:00
Torsten Grote 2ba2c04cc0 Don't say we are connected when push is disabled for current network
This may cause a connection attempt, but in connect(), we'll notice that it is disabled and won't continue to connect.

Change-Id: Id5f00539a48fad16b5e5f55bd336fb8890aa1acc
2022-01-25 12:37:08 +01:00
Torsten Grote bb68674cae Initiate connection teardown only once
Otherwise, this gets called multiple times from different places via MSG_TEARDOWN. This causes the reconnect delay to increase with each call to scheduleReconnect(), increasing the time we stay disconnected.

This commit introduces a boolean flag preventing handleTeardown() to run twice or more until connect() was called again.

Change-Id: I3d7cb08d696be48532a61819fbb279a908919a3d
2022-01-25 12:37:08 +01:00
Torsten Grote 00a06d4b94 Don't reconnect to gcm when opening settings
This doesn't treat the underlying issues and can make debugging harder if we suddenly auto-connect due to this.

Change-Id: I9c04c78e8ebda8472b0cd8c7b0b0deb2e2300139
2021-11-03 13:02:51 +01:00
Torsten Grote 1367649a18 Lower heartbeat interval when we find the connection reset when wanting to send a message 2021-11-03 13:02:51 +01:00
Torsten Grote aa3a2d65cd Refactor settings access to use a SettingsProvider
to enable safe usage of settings no matter which process is getting/setting them.
Previously, different processes were accessing settings in an unsafe way and the warn methods were throwing Runtime exceptions which went largely unnoticed, but happened, especially on a fresh start of the OS.

Change-Id: Ie4134e7be2a7ca4a373790f45fbcbd09bf02ad86
2021-06-27 22:39:15 +02:00
Marvin W ecfe3da3f7
Wakeful receivers only handle non-null intents 2021-03-09 22:21:25 +01:00
Marvin W 68a16af53b
Change background service notification
Fixes #1324
2020-12-21 21:46:03 +01:00
Marvin W c648883128
UI: Move advanced GCM configuration get/set off ui process 2020-12-20 19:29:51 +01:00
Marvin W 3db548187d
Workaround for Android 8.0 NotificationChannel bug
Fixes #1312
2020-12-14 10:04:39 +01:00
Marvin W a95f6449f5
GCM: Fix apps not always whitelisted from powersave
Fixes #1188
2020-10-18 10:20:41 +02:00
Marvin W 6ec8332b1e
GCM: Ensure we have a context for preferences 2020-09-09 00:49:05 +02:00
Marvin W d641ca7e7e
Fix UI mismatching actual configuration due to multiprocess 2020-09-03 00:50:39 +02:00
Marvin W 60cc63ed60
GCM: Add support for message acking, deliver to all receivers of package when working permissionless 2020-08-22 23:43:14 +02:00
Marvin W 3c2119ce79
Migrate to latest Wire library, build directly from proto 2020-08-01 22:34:53 +02:00
Marvin W 74213474b5
GCM: Do not require receiver permission for target app 2020-07-09 11:39:43 +02:00
Marvin W 895c74d095
Huge merge/refactor/update 2020-07-08 22:49:27 +02:00
Marvin W db4bb568e1
Run GCM services as foreground service if needed
That's when we run with battery optimizations disabled but not in foreground
2019-12-04 23:14:58 +01:00
voidstarstar 5875ab752b Move some expensive reflection calls to onCreate 2019-04-22 19:56:51 +02:00
voidstarstar 60023887d1 Temporary whitelist support for Doze (#732)
Fixes #338 

Co-Authored-By: @ccaapton <6211551+ccaapton@users.noreply.github.com>
Co-Authored-By: @ale5000-git <15793015+ale5000-git@users.noreply.github.com>
2019-04-21 16:39:18 +02:00
Moritz Horstmann 652d7a9104 Include GCM message ID in app message intent 2019-04-20 15:09:58 +02:00
Marvin W f94d140dea
Only require C2D_MESSAGE permission when defined 2018-08-28 14:13:49 +02:00
Marvin W d9e86d960d
Increase version code, update sublib and copyright header 2017-06-13 00:34:09 +02:00
Marvin W 01f154dcdb
Configure GCM by network type and automatically learn ping interval
Related to: #187 #192
2017-05-01 13:15:18 +02:00
Marvin W d99fa7e86f
Directly start/stop GCM service if setting is changed in UI 2017-02-08 14:17:17 +01:00
Marvin W 05a8b44f2d
Various fixes
related to #86, #164, #242
2016-12-23 19:02:05 +01:00
Marvin W 97f4c82172
GCM improvements
- Add upstream message support (#228)
- Improve support for 7.0+ (#226)
- don't start closed apps if disabled (#230)
- ask after denying registered app (#230)
- automatically unregister apps on uninstall
2016-11-20 20:37:31 +01:00
Marvin W 5316e0220a
Squashed commit
- Update all submodules, used sdk version, etc
- Settings UI rebuild
- Some GCM features and fixes
- Fix newest Cast Framework for some apps (tested with "ZDF Mediathek")

Fixes #224, #223, #145
2016-11-16 01:03:17 +01:00
fiaxh 33a6137aec
Screen showing GCM registered apps + infos + unregistration option 2016-09-17 01:43:50 +02:00
Marvin W 70119087fe
Ensure all threads to be closed
Fixes possible OOM error
2016-05-18 14:10:17 +02:00
Marvin W 016d2ca3f4 Refactor GCM Service, fix #129 2016-05-12 01:07:22 +02:00
Marvin W 60b2eaec25 Add support for collapse_key
related to #104
2016-04-18 10:29:52 +02:00
Marvin W 2a394f98aa Various changes
- Extend Wear support
- Rework Gms Services
- Fix ProGuard
- Add Waze to Google Whitelist (as in original Play Services, fixes #116)
2016-04-14 21:55:07 +02:00
Marvin W 67b1ac74e8 Various small fixes
- Add two Google signatures to acceptable apps. Likely to increae this further
- Fix small change in GCM unregistering
- Modify intent delivery for GCM, related to #75 and #84
- Lint fixes
- Update Travis CI config
2016-02-08 03:38:07 +01:00
Marvin W fbfb6c088a Merge branch 'master' of github.com:microg/android_packages_apps_GmsCore 2016-01-27 01:39:31 +01:00
Marvin W 8fa0515bf6 Squashed commit:
- Update build tools
- Update sublibs
- Add proper PlacePicker, fixes #65
- Add selfcheck
- Improvements to MCS connection, related #31 #54
- Do not crash when permission to GPS is not granted
- Various smaller fixes
2016-01-27 01:36:48 +01:00
Michael Hamann 48809464a7 McsService: only send to the output stream if it is alive
The output stream handler thread might not be alive, this occurs
reproducibly when connecting fails and a tear down is initiated.
Messages shouldn't be sent when the output handler thread is not alive
(triggers an expection which is catched but logged), this check avoids
this unless some special race condition occurs. Dropping the messages
shouldn't hurt (they were dropped anyway).
2016-01-17 15:56:03 +01:00
Marvin W affce9dc23 Set FLAG_INCLUDE_STOPPED_PACKAGES on GCM intents
Related to #75 #31
2016-01-12 20:59:39 +01:00
Michael Hamann 5fd376de7a GCM: Consider connection to be dead without ack messages
This stores the timestamp of the last ack message that has been
received. The connection is considered to be dead if the last ack
message has been received more than twice the configured interval ago.
2016-01-11 20:54:25 +01:00
Michael Hamann e264144aea GCM: Wake with exact guarantees for heartbeat
This changes how the alarms for heartbeat pings are scheduled. Instead
of a repeating, inexact alarm that may be delayed (at least up to 15
minutes), either an exact alarm (below Android 4.4) or an interval is used
which ensures that the alarm fires between half the configured interval
and the configured interval. This interval allows the OS to optimize
alarms a bit. For Android 6.0 further adjustments are probably
necessary.
2016-01-11 20:49:17 +01:00
mar-v-in 93645ca68f Make heartbeat interval adjustable #47 2015-12-04 11:26:59 -08:00
mar-v-in b6506209a9 Limit GCM Wakelock to 5s
fixes #53
2015-12-03 18:49:53 -08:00
lambdaupb 788eddc31e Reconnect Loop because of skipping backOff logic
currentDelay would stay 0 if error occurs in connect() method,
resulting in busy-loop on network failures.

Fix by always calling scheduleReconnect() which contains backoff logic.
2015-10-23 18:27:50 +02:00
mar-v-in 770a70821e Add from field to legacy C2DM support. 2015-10-20 19:04:01 +02:00
mar-v-in 766a6a1b47 Update portions of GCM implementation
- Fix bug causing unregister to be send multiple times
- More work related to #23, #29 and #31
2015-10-11 00:46:58 +02:00
mar-v-in 1f67d1aad0 Automatically checkin after 12 hours 2015-10-04 00:15:24 +02:00
mar-v-in 40ca65bbf4 Huge Update
- Update Location APIs, fixes #37
- Update version number, fixes #38
- Enable long press input on WebView during login, fixes #34
- Extended log output and auto-repair for GCM connection, related to #29 and #31
- New icons
- Small quirks in Auth handling (required for Login to some applications)
2015-10-03 22:47:05 +02:00
mar-v-in 1a83f8281f Improve mcs connection
wake up device when reconnecting, fix teardown incomplete on null message (#24)
2015-08-17 23:28:01 +02:00
mar-v-in c826702bb9 Update build tools and upstream, fix issue described in #24 2015-08-17 01:03:06 +02:00
mar-v-in 331813ce3c Update maps, rework MCS
MCS rework related to #23 and #24
2015-08-04 13:05:47 +02:00