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

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

Merge "API to report if active network is metered."

parents a5d552fc 9f7cbf0e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11833,6 +11833,7 @@ package android.net {
    method public deprecated boolean getBackgroundDataSetting();
    method public android.net.NetworkInfo getNetworkInfo(int);
    method public int getNetworkPreference();
    method public boolean isActiveNetworkMetered();
    method public static boolean isNetworkTypeValid(int);
    method public boolean requestRouteToHost(int, int);
    method public void setNetworkPreference(int);
+20 −4
Original line number Diff line number Diff line
@@ -373,9 +373,10 @@ public class ConnectivityManager {
    }

    /**
     * Gets you info about the current data network.
     * Call {@link NetworkInfo#isConnected()} on the returned {@link NetworkInfo}
     * to check if the device has a data connection.
     * Returns details about the currently active data network. When connected,
     * this network is the default route for outgoing connections. You should
     * always check {@link NetworkInfo#isConnected()} before initiating network
     * traffic. This may return {@code null} when no networks are available.
     */
    public NetworkInfo getActiveNetworkInfo() {
        try {
@@ -856,4 +857,19 @@ public class ConnectivityManager {
        } catch (RemoteException e) {}
        return false;
    }

    /**
     * Returns if the currently active data network is metered. A network is
     * classified as metered when the user is sensitive to heavy data usage on
     * that connection. You should check this before doing large data transfers,
     * and warn the user or delay the operation until another network is
     * available.
     */
    public boolean isActiveNetworkMetered() {
        try {
            return mService.isActiveNetworkMetered();
        } catch (RemoteException e) {
            return false;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ interface IConnectivityManager
    NetworkState[] getAllNetworkState();

    NetworkQuotaInfo getActiveNetworkQuotaInfo();
    boolean isActiveNetworkMetered();

    boolean setRadios(boolean onOff);

+1 −0
Original line number Diff line number Diff line
@@ -51,5 +51,6 @@ interface INetworkPolicyManager {
    boolean getRestrictBackground();

    NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);
    boolean isNetworkMetered(in NetworkState state);

}
+13 −0
Original line number Diff line number Diff line
@@ -875,6 +875,19 @@ private NetworkStateTracker makeWimaxStateTracker() {
        return null;
    }

    @Override
    public boolean isActiveNetworkMetered() {
        enforceAccessPermission();
        final NetworkState state = getNetworkStateUnchecked(mActiveDefaultNetwork);
        if (state != null) {
            try {
                return mPolicyManager.isNetworkMetered(state);
            } catch (RemoteException e) {
            }
        }
        return false;
    }

    public boolean setRadios(boolean turnOn) {
        boolean result = true;
        enforceChangePermission();
Loading