From 49ab457a9113d0e8b1841c81a24ac111d40e22bb Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 15 Jun 2015 18:13:22 +0200 Subject: [PATCH] Don't treat metered network as wifi (fixes #409). --- .../nutomic/syncthingandroid/syncthing/DeviceStateHolder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java index 229b6baa..14803da9 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java @@ -1,5 +1,6 @@ package com.nutomic.syncthingandroid.syncthing; +import android.annotation.TargetApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -29,10 +30,13 @@ public class DeviceStateHolder extends BroadcastReceiver { private boolean mIsCharging = false; + @TargetApi(16) public DeviceStateHolder(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); mIsWifiConnected = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); + if (android.os.Build.VERSION.SDK_INT >= 16 && cm.isActiveNetworkMetered()) + mIsWifiConnected = false; } /**