Skip to content

Data usage widget: support Ethernet and Cellular, not just WiFi #14

@el-bakkali

Description

@el-bakkali

Feature Request: Data usage widget should support Ethernet and Cellular, not just WiFi

Current Behavior

The data usage widget only tracks WiFi usage. Users on Ethernet or Cellular connections see no data usage info.

Root Cause

The usage tracking in MainActivity.java hardcodes NetworkCapabilities.TRANSPORT_WIFI:

// MainActivity.java — getWifiUsage methods
// These only query TRANSPORT_WIFI, ignoring Ethernet/Cellular
NetworkStats networkStats = networkStatsManager.querySummary(
    NetworkCapabilities.TRANSPORT_WIFI, null, startTime, endTime);

Similarly, the Dart side only exposes WiFi-specific methods:

// lib/providers/network_service.dart
int _dailyWifiUsage; // Only WiFi

Future<int> getWifiUsageForPeriod(String period) async {
    switch (period) {
      case 'daily':
        return await _channel.getDailyWifiUsage();
      case 'weekly':
        return await _channel.getWeeklyWifiUsage();
      case 'monthly':
        return await _channel.getMonthlyWifiUsage();
    }
}

What Already Works

The network detection code in NetworkUtils.java already handles all transport types correctly:

// NetworkUtils.java — already detects Ethernet
public static final short NETWORK_TYPE_WIRED = 3;

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
    networkType = NETWORK_TYPE_WIRED;
}

And the Dart enum already includes Wired:

enum NetworkType { Cellular, Wifi, Vpn, Wired, Unknown }

Suggested Improvement

  1. Generalize the usage methods in MainActivity.java to accept a network type parameter instead of hardcoding TRANSPORT_WIFI
  2. Add a setting in the Settings menu to select which network type to track (WiFi / Ethernet / Cellular / All)
  3. Store the preference via SharedPreferences
  4. Update FLauncherChannel and NetworkService to pass the selected type when fetching usage

This would be a natural extension since the detection infrastructure already supports all network types — only the usage tracking is limited.

Environment

  • Device: Google Streamer 4K (supports both WiFi and Ethernet)
  • LTvLauncher: v3.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions