1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Fix checks for intent actions (fixes #625)

This commit is contained in:
Martin Carpella 2016-04-26 20:01:50 +02:00
parent d70302d502
commit cfac1d3a61
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))