mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-22 12:21:15 +00:00
Added verbose logging for battery/network receivers.
This commit is contained in:
parent
93f1f9ae05
commit
e76f354ddd
2 changed files with 8 additions and 0 deletions
|
@ -3,15 +3,19 @@ package com.nutomic.syncthingandroid.syncthing;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Receives battery plug/unplug intents and sends the charging state to {@link SyncthingService}.
|
||||
*/
|
||||
public class BatteryReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "BatteryReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
boolean isCharging = Intent.ACTION_POWER_CONNECTED.equals(intent.getAction());
|
||||
Log.v(TAG, "Received charger " + (isCharging ? "connected" : "disconnected") + " event");
|
||||
Intent i = new Intent(context, SyncthingService.class);
|
||||
i.putExtra(DeviceStateHolder.EXTRA_IS_CHARGING, isCharging);
|
||||
context.startService(i);
|
||||
|
|
|
@ -5,12 +5,15 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Receives network connection change intents and sends the wifi state to {@link SyncthingService}.
|
||||
*/
|
||||
public class NetworkReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "NetworkReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ConnectivityManager cm =
|
||||
|
@ -19,6 +22,7 @@ public class NetworkReceiver extends BroadcastReceiver {
|
|||
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
|
||||
boolean isWifiConnected = (wifiInfo != null && wifiInfo.isConnected()) ||
|
||||
activeNetworkInfo == null;
|
||||
Log.v(TAG, "Received wifi " + (isWifiConnected ? "connected" : "disconnected") + " event");
|
||||
Intent i = new Intent(context, SyncthingService.class);
|
||||
i.putExtra(DeviceStateHolder.EXTRA_HAS_WIFI, isWifiConnected);
|
||||
context.startService(i);
|
||||
|
|
Loading…
Reference in a new issue