Merge "am b5e0cfb..557d2f5 from mirror-m-wireless-internal-release"
This commit is contained in:
commit
e80d3096ad
3 changed files with 141 additions and 101 deletions
|
|
@ -610,6 +610,27 @@ public class ConnectivityManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Network} object corresponding to the currently active
|
||||
* default data network. In the event that the current active default data
|
||||
* network disconnects, the returned {@code Network} object will no longer
|
||||
* be usable. This will return {@code null} when there is no default
|
||||
* network.
|
||||
*
|
||||
* @return a {@link Network} object for the current default network or
|
||||
* {@code null} if no default network is currently active
|
||||
*
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
|
||||
*/
|
||||
public Network getActiveNetwork() {
|
||||
try {
|
||||
return mService.getActiveNetwork();
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns details about the currently active default data network
|
||||
* for a given uid. This is for internal use only to avoid spying
|
||||
|
|
@ -830,48 +851,6 @@ public class ConnectivityManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells each network type to set its radio power state as directed.
|
||||
*
|
||||
* @param turnOn a boolean, {@code true} to turn the radios on,
|
||||
* {@code false} to turn them off.
|
||||
* @return a boolean, {@code true} indicating success. All network types
|
||||
* will be tried, even if some fail.
|
||||
*
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
* {@hide}
|
||||
*/
|
||||
// TODO - check for any callers and remove
|
||||
// public boolean setRadios(boolean turnOn) {
|
||||
// try {
|
||||
// return mService.setRadios(turnOn);
|
||||
// } catch (RemoteException e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Tells a given networkType to set its radio power state as directed.
|
||||
*
|
||||
* @param networkType the int networkType of interest.
|
||||
* @param turnOn a boolean, {@code true} to turn the radio on,
|
||||
* {@code} false to turn it off.
|
||||
* @return a boolean, {@code true} indicating success.
|
||||
*
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
* {@hide}
|
||||
*/
|
||||
// TODO - check for any callers and remove
|
||||
// public boolean setRadio(int networkType, boolean turnOn) {
|
||||
// try {
|
||||
// return mService.setRadio(networkType, turnOn);
|
||||
// } catch (RemoteException e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Tells the underlying networking system that the caller wants to
|
||||
* begin using the named feature. The interpretation of {@code feature}
|
||||
|
|
@ -1738,10 +1717,33 @@ public class ConnectivityManager {
|
|||
*
|
||||
* @param network The {@link Network} the application was attempting to use
|
||||
* or {@code null} to indicate the current default network.
|
||||
* @deprecated Use {@link #reportNetworkConnectivity} which allows reporting both
|
||||
* working and non-working connectivity.
|
||||
*/
|
||||
public void reportBadNetwork(Network network) {
|
||||
try {
|
||||
mService.reportBadNetwork(network);
|
||||
// One of these will be ignored because it matches system's current state.
|
||||
// The other will trigger the necessary reevaluation.
|
||||
mService.reportNetworkConnectivity(network, true);
|
||||
mService.reportNetworkConnectivity(network, false);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report to the framework whether a network has working connectivity.
|
||||
* This provides a hint to the system that a particular network is providing
|
||||
* working connectivity or not. In response the framework may re-evaluate
|
||||
* the network's connectivity and might take further action thereafter.
|
||||
*
|
||||
* @param network The {@link Network} the application was attempting to use
|
||||
* or {@code null} to indicate the current default network.
|
||||
* @param hasConnectivity {@code true} if the application was able to successfully access the
|
||||
* Internet using {@code network} or {@code false} if not.
|
||||
*/
|
||||
public void reportNetworkConnectivity(Network network, boolean hasConnectivity) {
|
||||
try {
|
||||
mService.reportNetworkConnectivity(network, hasConnectivity);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1978,12 +1980,18 @@ public class ConnectivityManager {
|
|||
} catch (RemoteException e) { }
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public void registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
/**
|
||||
* @hide
|
||||
* Register a NetworkAgent with ConnectivityService.
|
||||
* @return NetID corresponding to NetworkAgent.
|
||||
*/
|
||||
public int registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
NetworkCapabilities nc, int score, NetworkMisc misc) {
|
||||
try {
|
||||
mService.registerNetworkAgent(messenger, ni, lp, nc, score, misc);
|
||||
} catch (RemoteException e) { }
|
||||
return mService.registerNetworkAgent(messenger, ni, lp, nc, score, misc);
|
||||
} catch (RemoteException e) {
|
||||
return NETID_UNSET;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.android.internal.net.VpnProfile;
|
|||
/** {@hide} */
|
||||
interface IConnectivityManager
|
||||
{
|
||||
Network getActiveNetwork();
|
||||
NetworkInfo getActiveNetworkInfo();
|
||||
NetworkInfo getActiveNetworkInfoForUid(int uid);
|
||||
NetworkInfo getNetworkInfo(int networkType);
|
||||
|
|
@ -95,7 +96,7 @@ interface IConnectivityManager
|
|||
|
||||
void reportInetCondition(int networkType, int percentage);
|
||||
|
||||
void reportBadNetwork(in Network network);
|
||||
void reportNetworkConnectivity(in Network network, boolean hasConnectivity);
|
||||
|
||||
ProxyInfo getGlobalProxy();
|
||||
|
||||
|
|
@ -121,8 +122,6 @@ interface IConnectivityManager
|
|||
|
||||
void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal);
|
||||
|
||||
int findConnectionTypeForIface(in String iface);
|
||||
|
||||
int checkMobileProvisioning(int suggestedTimeOutMs);
|
||||
|
||||
String getMobileProvisioningUrl();
|
||||
|
|
@ -137,7 +136,7 @@ interface IConnectivityManager
|
|||
|
||||
void unregisterNetworkFactory(in Messenger messenger);
|
||||
|
||||
void registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
|
||||
int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
|
||||
in NetworkCapabilities nc, int score, in NetworkMisc misc);
|
||||
|
||||
NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ import java.util.ArrayList;
|
|||
* @hide
|
||||
*/
|
||||
public abstract class NetworkAgent extends Handler {
|
||||
// Guaranteed to be valid (not NETID_UNSET), otherwise registerNetworkAgent() would have thrown
|
||||
// an exception.
|
||||
public final int netId;
|
||||
|
||||
private volatile AsyncChannel mAsyncChannel;
|
||||
private final String LOG_TAG;
|
||||
private static final boolean DBG = true;
|
||||
|
|
@ -151,7 +155,7 @@ public abstract class NetworkAgent extends Handler {
|
|||
if (VDBG) log("Registering NetworkAgent");
|
||||
ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(
|
||||
Context.CONNECTIVITY_SERVICE);
|
||||
cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni),
|
||||
netId = cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni),
|
||||
new LinkProperties(lp), new NetworkCapabilities(nc), score, misc);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue