Skip to content

Commit 38474d1

Browse files
committed
Update timeout back to 120 secs.
1 parent e822eb3 commit 38474d1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/android/BackgroundModeExt.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class BackgroundModeExt extends CordovaPlugin {
8787
private AlarmManager alarmMgr;
8888
private PendingIntent alarmIntent;
8989
final String RECEIVER = ".AlarmReceiver";
90-
final int TIMEOUT = 60 * 1000; // 1 min
90+
final int TIMEOUT = 120 * 1000; // 2 mins
9191
final int QUICK_TIMEOUT = 2 * 1000; // 2 secs
9292
final int WAKELIMIT = 2;
9393
private boolean isOnBg = false;
@@ -123,19 +123,20 @@ public void onReceive(Context context, Intent intent) {
123123
if(cm != null) {
124124
NetworkInfo netInfo = cm.getActiveNetworkInfo();
125125

126-
wfl = wm.createWifiLock(WIFI_MODE_FULL_HIGH_PERF, "backgroundmode:sync_all_wifi");
127-
wfl.acquire();
128-
129126
//should check null because in airplane mode it will be null
130127
if(netInfo != null && netInfo.isConnected()) {
128+
129+
wfl = wm.createWifiLock(WIFI_MODE_FULL_HIGH_PERF, "backgroundmode:sync_all_wifi");
130+
wfl.acquire();
131+
131132
webView.loadUrl("javascript:syncReconnect()");
133+
134+
wfl.release();
135+
wfl = null;
132136
}
133137
else {
134138
Log.d("MlesTalk", "No network!");
135139
}
136-
137-
wfl.release();
138-
wfl = null;
139140
}
140141
else {
141142
Log.d("MlesTalk", "No CM!");
@@ -170,14 +171,14 @@ else if(1 == wakeCounter) {
170171
flags = flags | PendingIntent.FLAG_IMMUTABLE;
171172
}
172173

173-
Log.d("MlesTalk", "Got exception, no intent loaded, loading 60 s!");
174+
Log.d("MlesTalk", "Got exception, no intent loaded, loading 120 s!");
174175
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
175176

176177
Intent newIntent = new Intent(RECEIVER);
177178

178179
alarmIntent = PendingIntent.getBroadcast(context, 0, newIntent, flags);
179180
alarmMgr.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
180-
SystemClock.elapsedRealtime() + 60*1000, alarmIntent);
181+
SystemClock.elapsedRealtime() + 120*1000, alarmIntent);
181182
}
182183
finally {
183184
wakeLock.release();

0 commit comments

Comments
 (0)