Skip to content

Commit

Permalink
Merge pull request #2 from cwarden/build-on-3.1-and-earlier
Browse files Browse the repository at this point in the history
Accept ethernet as acceptable connectivity (simplifies emulator testing)
  • Loading branch information
daggerrz committed Mar 26, 2012
2 parents 45673a2 + 24e20cc commit 436c9e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/com/squeezecontrol/ServiceUtils.java
Expand Up @@ -18,6 +18,20 @@
import android.net.wifi.WifiManager;

public class ServiceUtils {
private static int TYPE_ETHERNET;
private static boolean ethernetSupported;

static {
try {
// ethernet connections available from API version 13
TYPE_ETHERNET = ConnectivityManager.class.getField("TYPE_ETHERNET").getInt(null);
ethernetSupported = true;
} catch (IllegalAccessException e) {
ethernetSupported = false;
} catch (NoSuchFieldException e) {
ethernetSupported = false;
}
}


public static boolean bindToService(Context context,
Expand Down Expand Up @@ -61,7 +75,7 @@ public static boolean validNetworkAvailable(Context context) {
NetworkInfo activeNetwork = cmgr.getActiveNetworkInfo();
return null != activeNetwork &&
(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI ||
activeNetwork.getType() == ConnectivityManager.TYPE_ETHERNET);
(ethernetSupported && activeNetwork.getType() == TYPE_ETHERNET));
}

/**
Expand Down

0 comments on commit 436c9e8

Please sign in to comment.