Skip to content

Detecting (un)metered connection state #892

Description

@Terrance

Feature description

I'm looking for a way to tell if the current connection is set as metered or not (including use of mobile data as well as Wi-Fi networks set as metered e.g. hotspots), so that I can guard scripts or steps of them from using large amounts of data where this is chargeable.

termux-job-schedule allows deferring jobs from running on metered connections with --network unmetered, though I'd like more fine-grained control that can also be used outside of work jobs.

It doesn't look like there's currently any transport-agnostic network tools here, and the existing Wi-Fi commands don't expose this information.

Reference implementation

NetworkCapabilities::getCapabilities() and NetworkCapabilities::NET_CAPABILITY_NOT_METERED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions