Loading core/java/android/net/ConnectivityManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -2451,6 +2451,23 @@ public class ConnectivityManager { sendRequestForNetwork(request.networkCapabilities, networkCallback, 0, LISTEN, TYPE_NONE); } /** * Request connectivityservice to refresh network capabilities for the given * {@link network}. This method returns true if the network is still active, false * otherwise. Notice the method call assumes the caller has registered for * listening NetworkCapabilities updates. * * @param network{@link Network} specifying which network you're interested. * @hide */ public boolean requestBwUpdate(Network network) { try { return mService.requestBwUpdate(network); } catch (RemoteException e) { return false; } } /** * Unregisters callbacks about and possibly releases networks originating from * {@link #requestNetwork} and {@link #registerNetworkCallback} calls. If the Loading core/java/android/net/IConnectivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ interface IConnectivityManager void registerNetworkFactory(in Messenger messenger, in String name); boolean requestBwUpdate(in Network network); void unregisterNetworkFactory(in Messenger messenger); int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp, Loading core/java/android/net/NetworkAgent.java +24 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ public abstract class NetworkAgent extends Handler { private static final boolean VDBG = false; private final Context mContext; private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>(); private volatile long mLastBwRefreshTime = 0; private static final long BW_REFRESH_MIN_WIN_MS = 500; private static final int BASE = Protocol.BASE_NETWORK_AGENT; Loading Loading @@ -138,6 +140,11 @@ public abstract class NetworkAgent extends Handler { */ public static final int CMD_SAVE_ACCEPT_UNVALIDATED = BASE + 9; /** Sent by ConnectivityService to the NetworkAgent to inform the agent to pull * the underlying network connection for updated bandwidth information. */ public static final int CMD_REQUEST_BANDWIDTH_UPDATE = BASE + 10; public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score) { this(looper, context, logTag, ni, nc, lp, score, null); Loading Loading @@ -199,6 +206,15 @@ public abstract class NetworkAgent extends Handler { log("Unhandled Message " + msg); break; } case CMD_REQUEST_BANDWIDTH_UPDATE: { if (VDBG) { log("CMD_REQUEST_BANDWIDTH_UPDATE request received."); } if (System.currentTimeMillis() > (mLastBwRefreshTime + BW_REFRESH_MIN_WIN_MS)) { pollLceData(); } break; } case CMD_REPORT_NETWORK_STATUS: { if (VDBG) { log("CMD_REPORT_NETWORK_STATUS(" + Loading Loading @@ -244,6 +260,7 @@ public abstract class NetworkAgent extends Handler { * Called by the bearer code when it has new NetworkCapabilities data. */ public void sendNetworkCapabilities(NetworkCapabilities networkCapabilities) { mLastBwRefreshTime = System.currentTimeMillis(); queueOrSendMessage(EVENT_NETWORK_CAPABILITIES_CHANGED, new NetworkCapabilities(networkCapabilities)); } Loading Loading @@ -297,6 +314,13 @@ public abstract class NetworkAgent extends Handler { */ abstract protected void unwanted(); /** * Called when ConnectivityService request a bandwidth update. The parent factory * shall try to overwrite this method and produce a bandwidth update if capable. */ protected void pollLceData() { } /** * Called when the system determines the usefulness of this network. * Loading services/core/java/com/android/server/ConnectivityService.java +18 −0 Original line number Diff line number Diff line Loading @@ -3455,6 +3455,24 @@ public class ConnectivityService extends IConnectivityManager.Stub } } @Override public boolean requestBwUpdate(Network network) { enforceAccessPermission(); NetworkAgentInfo nai = null; if (network == null) { return false; } synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(network.netId); } if (nai != null) { nai.asyncChannel.sendMessage(android.net.NetworkAgent.CMD_REQUEST_BANDWIDTH_UPDATE); return true; } return false; } private void enforceMeteredApnPolicy(NetworkCapabilities networkCapabilities) { // if UID is restricted, don't allow them to bring up metered APNs if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) Loading telephony/java/com/android/internal/telephony/RILConstants.java +10 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,6 @@ public interface RILConstants { int SS_MODIFIED_TO_USSD = 25; /* SS request modified to USSD */ int SUBSCRIPTION_NOT_SUPPORTED = 26; /* Subscription not supported */ int SS_MODIFIED_TO_SS = 27; /* SS request modified to different SS request */ int SIM_NOT_READY = 28; int SIM_ALREADY_POWERED_OFF = 29; /* SAP: 0x03, Error card aleready powered off */ int SIM_ALREADY_POWERED_ON = 30; /* SAP: 0x05, Error card already powered on */ int SIM_DATA_NOT_AVAILABLE = 31; /* SAP: 0x06, Error data not available */ Loading @@ -79,6 +76,7 @@ public interface RILConstants { int SIM_SAP_MSG_SIZE_TOO_LARGE = 33; int SIM_SAP_MSG_SIZE_TOO_SMALL = 34; int SIM_SAP_CONNECT_OK_CALL_ONGOING = 35; int LCE_NOT_SUPPORTED = 36; /* Link Capacity Estimation (LCE) not supported */ /* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */ Loading Loading @@ -145,6 +143,11 @@ public interface RILConstants { int NV_CONFIG_ERASE_RESET = 2; int NV_CONFIG_FACTORY_RESET = 3; /* LCE service related constants. */ int LCE_NOT_AVAILABLE = -1; int LCE_STOPPED = 0; int LCE_ACTIVE = 1; /* cat include/telephony/ril.h | \ egrep '^#define' | \ Loading Loading @@ -317,6 +320,9 @@ cat include/telephony/ril.h | \ int RIL_REQUEST_SHUTDOWN = 129; int RIL_REQUEST_GET_RADIO_CAPABILITY = 130; int RIL_REQUEST_SET_RADIO_CAPABILITY = 131; int RIL_REQUEST_START_LCE = 132; int RIL_REQUEST_STOP_LCE = 133; int RIL_REQUEST_PULL_LCEDATA = 134; int RIL_UNSOL_RESPONSE_BASE = 1000; int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000; Loading Loading @@ -364,4 +370,5 @@ cat include/telephony/ril.h | \ int RIL_UNSOL_RADIO_CAPABILITY = 1042; int RIL_UNSOL_ON_SS = 1043; int RIL_UNSOL_STK_CC_ALPHA_NOTIFY = 1044; int RIL_UNSOL_LCEDATA_RECV = 1045; } Loading
core/java/android/net/ConnectivityManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -2451,6 +2451,23 @@ public class ConnectivityManager { sendRequestForNetwork(request.networkCapabilities, networkCallback, 0, LISTEN, TYPE_NONE); } /** * Request connectivityservice to refresh network capabilities for the given * {@link network}. This method returns true if the network is still active, false * otherwise. Notice the method call assumes the caller has registered for * listening NetworkCapabilities updates. * * @param network{@link Network} specifying which network you're interested. * @hide */ public boolean requestBwUpdate(Network network) { try { return mService.requestBwUpdate(network); } catch (RemoteException e) { return false; } } /** * Unregisters callbacks about and possibly releases networks originating from * {@link #requestNetwork} and {@link #registerNetworkCallback} calls. If the Loading
core/java/android/net/IConnectivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ interface IConnectivityManager void registerNetworkFactory(in Messenger messenger, in String name); boolean requestBwUpdate(in Network network); void unregisterNetworkFactory(in Messenger messenger); int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp, Loading
core/java/android/net/NetworkAgent.java +24 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ public abstract class NetworkAgent extends Handler { private static final boolean VDBG = false; private final Context mContext; private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>(); private volatile long mLastBwRefreshTime = 0; private static final long BW_REFRESH_MIN_WIN_MS = 500; private static final int BASE = Protocol.BASE_NETWORK_AGENT; Loading Loading @@ -138,6 +140,11 @@ public abstract class NetworkAgent extends Handler { */ public static final int CMD_SAVE_ACCEPT_UNVALIDATED = BASE + 9; /** Sent by ConnectivityService to the NetworkAgent to inform the agent to pull * the underlying network connection for updated bandwidth information. */ public static final int CMD_REQUEST_BANDWIDTH_UPDATE = BASE + 10; public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score) { this(looper, context, logTag, ni, nc, lp, score, null); Loading Loading @@ -199,6 +206,15 @@ public abstract class NetworkAgent extends Handler { log("Unhandled Message " + msg); break; } case CMD_REQUEST_BANDWIDTH_UPDATE: { if (VDBG) { log("CMD_REQUEST_BANDWIDTH_UPDATE request received."); } if (System.currentTimeMillis() > (mLastBwRefreshTime + BW_REFRESH_MIN_WIN_MS)) { pollLceData(); } break; } case CMD_REPORT_NETWORK_STATUS: { if (VDBG) { log("CMD_REPORT_NETWORK_STATUS(" + Loading Loading @@ -244,6 +260,7 @@ public abstract class NetworkAgent extends Handler { * Called by the bearer code when it has new NetworkCapabilities data. */ public void sendNetworkCapabilities(NetworkCapabilities networkCapabilities) { mLastBwRefreshTime = System.currentTimeMillis(); queueOrSendMessage(EVENT_NETWORK_CAPABILITIES_CHANGED, new NetworkCapabilities(networkCapabilities)); } Loading Loading @@ -297,6 +314,13 @@ public abstract class NetworkAgent extends Handler { */ abstract protected void unwanted(); /** * Called when ConnectivityService request a bandwidth update. The parent factory * shall try to overwrite this method and produce a bandwidth update if capable. */ protected void pollLceData() { } /** * Called when the system determines the usefulness of this network. * Loading
services/core/java/com/android/server/ConnectivityService.java +18 −0 Original line number Diff line number Diff line Loading @@ -3455,6 +3455,24 @@ public class ConnectivityService extends IConnectivityManager.Stub } } @Override public boolean requestBwUpdate(Network network) { enforceAccessPermission(); NetworkAgentInfo nai = null; if (network == null) { return false; } synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(network.netId); } if (nai != null) { nai.asyncChannel.sendMessage(android.net.NetworkAgent.CMD_REQUEST_BANDWIDTH_UPDATE); return true; } return false; } private void enforceMeteredApnPolicy(NetworkCapabilities networkCapabilities) { // if UID is restricted, don't allow them to bring up metered APNs if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) Loading
telephony/java/com/android/internal/telephony/RILConstants.java +10 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,6 @@ public interface RILConstants { int SS_MODIFIED_TO_USSD = 25; /* SS request modified to USSD */ int SUBSCRIPTION_NOT_SUPPORTED = 26; /* Subscription not supported */ int SS_MODIFIED_TO_SS = 27; /* SS request modified to different SS request */ int SIM_NOT_READY = 28; int SIM_ALREADY_POWERED_OFF = 29; /* SAP: 0x03, Error card aleready powered off */ int SIM_ALREADY_POWERED_ON = 30; /* SAP: 0x05, Error card already powered on */ int SIM_DATA_NOT_AVAILABLE = 31; /* SAP: 0x06, Error data not available */ Loading @@ -79,6 +76,7 @@ public interface RILConstants { int SIM_SAP_MSG_SIZE_TOO_LARGE = 33; int SIM_SAP_MSG_SIZE_TOO_SMALL = 34; int SIM_SAP_CONNECT_OK_CALL_ONGOING = 35; int LCE_NOT_SUPPORTED = 36; /* Link Capacity Estimation (LCE) not supported */ /* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */ Loading Loading @@ -145,6 +143,11 @@ public interface RILConstants { int NV_CONFIG_ERASE_RESET = 2; int NV_CONFIG_FACTORY_RESET = 3; /* LCE service related constants. */ int LCE_NOT_AVAILABLE = -1; int LCE_STOPPED = 0; int LCE_ACTIVE = 1; /* cat include/telephony/ril.h | \ egrep '^#define' | \ Loading Loading @@ -317,6 +320,9 @@ cat include/telephony/ril.h | \ int RIL_REQUEST_SHUTDOWN = 129; int RIL_REQUEST_GET_RADIO_CAPABILITY = 130; int RIL_REQUEST_SET_RADIO_CAPABILITY = 131; int RIL_REQUEST_START_LCE = 132; int RIL_REQUEST_STOP_LCE = 133; int RIL_REQUEST_PULL_LCEDATA = 134; int RIL_UNSOL_RESPONSE_BASE = 1000; int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000; Loading Loading @@ -364,4 +370,5 @@ cat include/telephony/ril.h | \ int RIL_UNSOL_RADIO_CAPABILITY = 1042; int RIL_UNSOL_ON_SS = 1043; int RIL_UNSOL_STK_CC_ALPHA_NOTIFY = 1044; int RIL_UNSOL_LCEDATA_RECV = 1045; }