Merge pull request #630 from capi/fix-625

Track WiFi changes again in NetworkReceiver (fixes #625)
This commit is contained in:
Felix Ableitner 2016-04-26 20:14:17 +02:00
commit db17cf9267
3 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.nutomic.syncthingandroid.test.syncthing;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
@ -40,7 +41,7 @@ public class NetworkReceiverTest extends AndroidTestCase {
.edit()
.putBoolean(SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND, true)
.commit();
mReceiver.onReceive(mContext, new Intent(Intent.ACTION_POWER_CONNECTED));
mReceiver.onReceive(mContext, new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
assertEquals(1, mContext.getReceivedIntents().size());
Intent receivedIntent = mContext.getReceivedIntents().get(0);

View File

@ -14,6 +14,10 @@ public class BatteryReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())
&& !Intent.ACTION_POWER_DISCONNECTED.equals(intent.getAction()))
return;
if (!SyncthingService.alwaysRunInBackground(context))
return;

View File

@ -16,8 +16,7 @@ public class NetworkReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!intent.getAction().equals(Intent.ACTION_POWER_CONNECTED) &&
!intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED))
if (!ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction()))
return;
if (!SyncthingService.alwaysRunInBackground(context))