1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-30 08:11:17 +00:00

Don't treat metered network as wifi (fixes #409).

This commit is contained in:
Felix Ableitner 2015-06-15 18:13:22 +02:00
parent c52ee5a4dc
commit 49ab457a91

View file

@ -1,5 +1,6 @@
package com.nutomic.syncthingandroid.syncthing; package com.nutomic.syncthingandroid.syncthing;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -29,10 +30,13 @@ public class DeviceStateHolder extends BroadcastReceiver {
private boolean mIsCharging = false; private boolean mIsCharging = false;
@TargetApi(16)
public DeviceStateHolder(Context context) { public DeviceStateHolder(Context context) {
ConnectivityManager cm = (ConnectivityManager) ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE); context.getSystemService(Context.CONNECTIVITY_SERVICE);
mIsWifiConnected = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); mIsWifiConnected = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
if (android.os.Build.VERSION.SDK_INT >= 16 && cm.isActiveNetworkMetered())
mIsWifiConnected = false;
} }
/** /**