Skip to content

Commit

Permalink
Compensate the lack of GCM with increased wakeup frequency.
Browse files Browse the repository at this point in the history
  • Loading branch information
slp authored and Sergio Lopez committed Mar 31, 2014
1 parent 881602b commit 8da1b2d
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
private Runnable stageRunnable;
private Runnable pingRunnable;
private long lastPingTime = System.currentTimeMillis();
private int nextWakeUpTimeout = 60000;
private int nextWakeUpTimeout = 15000;
private int nextSleepTimeout = 60000;

public static volatile ConnectionsManager Instance = null;
Expand Down Expand Up @@ -137,11 +137,8 @@ public void run() {
paused = true;
if (ApplicationLoader.lastPauseTime < currentTime - nextSleepTimeout - nextWakeUpTimeout) {
ApplicationLoader.lastPauseTime = currentTime;
nextSleepTimeout = 30000;
nextSleepTimeout = 15000;
FileLog.e("tmessages", "wakeup network in background by wakeup time = " + nextWakeUpTimeout);
if (nextWakeUpTimeout < 30 * 60 * 1000) {
nextWakeUpTimeout *= 2;
}
} else {
Thread.sleep(500);
return;
Expand Down Expand Up @@ -175,7 +172,7 @@ public void run() {
}
});
}
}, 1000, 1000);
}, 1000, 5000);
}

public void resumeNetworkMaybe() {
Expand All @@ -184,7 +181,6 @@ public void resumeNetworkMaybe() {
public void run() {
if (paused) {
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
nextWakeUpTimeout = 60000;
nextSleepTimeout = 30000;
FileLog.e("tmessages", "wakeup network in background by recieved push");
} else if (ApplicationLoader.lastPauseTime != 0) {
Expand All @@ -201,7 +197,6 @@ public void applicationMovedToForeground() {
public void run() {
if (paused) {
nextSleepTimeout = 60000;
nextWakeUpTimeout = 60000;
FileLog.e("tmessages", "reset timers by application moved to foreground");
}
}
Expand Down

3 comments on commit 8da1b2d

@CharString
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this mean in terms of battery life?

@slp
Copy link
Member Author

@slp slp commented on 8da1b2d Apr 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't have formal metrics, but I can say I'm running version 1.4.9b and I haven't noticed any significant change on my battery life. But sure, it should eat a little more, but in exchange notifications arrive in a reasonable time, even when the phone is inactive.

@geileszeuch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work you have done here. F-Droid needs people like you.
Do you have any interest in freeing TextSecure from GCM, too?
If so there is an open issue about that right here signalapp/Signal-Android#1000 (comment)
The community would be really thankful for your help and your coding skills. There is already ongoing work, right here https://github.com/JavaJens/TextSecure/tree/feature-1000
Feel free to jump in :). And thank you for supporting FOSS :) 👍

Please sign in to comment.