Merge "Have registerNetworkAgent return a Network."
This commit is contained in:
commit
cbb58f167b
3 changed files with 21 additions and 16 deletions
|
|
@ -3169,10 +3169,10 @@ public class ConnectivityManager {
|
|||
/**
|
||||
* @hide
|
||||
* Register a NetworkAgent with ConnectivityService.
|
||||
* @return NetID corresponding to NetworkAgent.
|
||||
* @return Network corresponding to NetworkAgent.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
|
||||
public int registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
public Network registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
NetworkCapabilities nc, int score, NetworkAgentConfig config) {
|
||||
return registerNetworkAgent(messenger, ni, lp, nc, score, config, NetworkProvider.ID_NONE);
|
||||
}
|
||||
|
|
@ -3180,10 +3180,10 @@ public class ConnectivityManager {
|
|||
/**
|
||||
* @hide
|
||||
* Register a NetworkAgent with ConnectivityService.
|
||||
* @return NetID corresponding to NetworkAgent.
|
||||
* @return Network corresponding to NetworkAgent.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
|
||||
public int registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
public Network registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
|
||||
NetworkCapabilities nc, int score, NetworkAgentConfig config, int providerId) {
|
||||
try {
|
||||
return mService.registerNetworkAgent(messenger, ni, lp, nc, score, config, providerId);
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ interface IConnectivityManager
|
|||
|
||||
void declareNetworkRequestUnfulfillable(in NetworkRequest request);
|
||||
|
||||
int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
|
||||
Network registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
|
||||
in NetworkCapabilities nc, int score, in NetworkAgentConfig config,
|
||||
in int factorySerialNumber);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
* @hide
|
||||
*/
|
||||
public abstract class NetworkAgent {
|
||||
// Guaranteed to be valid (not NETID_UNSET), otherwise registerNetworkAgent() would have thrown
|
||||
// an exception.
|
||||
public final int netId;
|
||||
// Guaranteed to be non-null, otherwise registerNetworkAgent() would have thrown
|
||||
// an exception. Be careful in tests when mocking though.
|
||||
@NonNull
|
||||
public final Network network;
|
||||
|
||||
private final Handler mHandler;
|
||||
private volatile AsyncChannel mAsyncChannel;
|
||||
|
|
@ -246,7 +247,7 @@ public abstract class NetworkAgent {
|
|||
if (VDBG) log("Registering NetworkAgent");
|
||||
ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(
|
||||
Context.CONNECTIVITY_SERVICE);
|
||||
netId = cm.registerNetworkAgent(new Messenger(mHandler), new NetworkInfo(ni),
|
||||
network = cm.registerNetworkAgent(new Messenger(mHandler), new NetworkInfo(ni),
|
||||
new LinkProperties(lp), new NetworkCapabilities(nc), score, config,
|
||||
providerId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue