mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Fix checks for intent actions (fixes #625)
This commit is contained in:
parent
d70302d502
commit
cfac1d3a61
3 changed files with 7 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.nutomic.syncthingandroid.test.syncthing;
|
package com.nutomic.syncthingandroid.test.syncthing;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
|
@ -40,7 +41,7 @@ public class NetworkReceiverTest extends AndroidTestCase {
|
||||||
.edit()
|
.edit()
|
||||||
.putBoolean(SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND, true)
|
.putBoolean(SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND, true)
|
||||||
.commit();
|
.commit();
|
||||||
mReceiver.onReceive(mContext, new Intent(Intent.ACTION_POWER_CONNECTED));
|
mReceiver.onReceive(mContext, new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||||
assertEquals(1, mContext.getReceivedIntents().size());
|
assertEquals(1, mContext.getReceivedIntents().size());
|
||||||
|
|
||||||
Intent receivedIntent = mContext.getReceivedIntents().get(0);
|
Intent receivedIntent = mContext.getReceivedIntents().get(0);
|
||||||
|
|
|
@ -14,6 +14,10 @@ public class BatteryReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
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))
|
if (!SyncthingService.alwaysRunInBackground(context))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ public class NetworkReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (!intent.getAction().equals(Intent.ACTION_POWER_CONNECTED) &&
|
if (!ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction()))
|
||||||
!intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!SyncthingService.alwaysRunInBackground(context))
|
if (!SyncthingService.alwaysRunInBackground(context))
|
||||||
|
|
Loading…
Reference in a new issue