Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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); core/java/android/net/ConnectivityManager.java +20 −4 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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; } } } core/java/android/net/IConnectivityManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ interface IConnectivityManager NetworkState[] getAllNetworkState(); NetworkQuotaInfo getActiveNetworkQuotaInfo(); boolean isActiveNetworkMetered(); boolean setRadios(boolean onOff); Loading core/java/android/net/INetworkPolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -51,5 +51,6 @@ interface INetworkPolicyManager { boolean getRestrictBackground(); NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state); boolean isNetworkMetered(in NetworkState state); } services/java/com/android/server/ConnectivityService.java +13 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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);
core/java/android/net/ConnectivityManager.java +20 −4 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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; } } }
core/java/android/net/IConnectivityManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ interface IConnectivityManager NetworkState[] getAllNetworkState(); NetworkQuotaInfo getActiveNetworkQuotaInfo(); boolean isActiveNetworkMetered(); boolean setRadios(boolean onOff); Loading
core/java/android/net/INetworkPolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -51,5 +51,6 @@ interface INetworkPolicyManager { boolean getRestrictBackground(); NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state); boolean isNetworkMetered(in NetworkState state); }
services/java/com/android/server/ConnectivityService.java +13 −0 Original line number Diff line number Diff line Loading @@ -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