Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a655a2f4 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Only show ethernet when traffic has occurred." into jb-dev

parents 6e9e5195 b67c4a8e
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -2155,13 +2155,25 @@ public class DataUsageSummary extends Fragment {
    /**
     * Test if device has an ethernet network connection.
     */
    public static boolean hasEthernet(Context context) {
    public boolean hasEthernet(Context context) {
        if (TEST_RADIOS) {
            return SystemProperties.get(TEST_RADIOS_PROP).contains("ethernet");
        }

        final ConnectivityManager conn = ConnectivityManager.from(context);
        return conn.isNetworkSupported(TYPE_ETHERNET);
        final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET);

        final long ethernetBytes;
        try {
            ethernetBytes = mStatsSession.getSummaryForNetwork(
                    NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
                    .getTotalBytes();
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }

        // suppress ethernet unless traffic has occurred
        return hasEthernet && ethernetBytes > 0;
    }

    /**