Merge "Add network disconnected callback" am: 1ac46f932e am: 00d44574b9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652259 Change-Id: Iec2661c2f77a17784f7be963d1a4d8ec8ef483ec
This commit is contained in:
@@ -218,6 +218,7 @@ package android.net {
|
|||||||
method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
|
method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
|
||||||
method public void onAutomaticReconnectDisabled();
|
method public void onAutomaticReconnectDisabled();
|
||||||
method public void onNetworkCreated();
|
method public void onNetworkCreated();
|
||||||
|
method public void onNetworkDisconnected();
|
||||||
method public void onNetworkUnwanted();
|
method public void onNetworkUnwanted();
|
||||||
method public void onQosCallbackRegistered(int, @NonNull android.net.QosFilter);
|
method public void onQosCallbackRegistered(int, @NonNull android.net.QosFilter);
|
||||||
method public void onQosCallbackUnregistered(int);
|
method public void onQosCallbackUnregistered(int);
|
||||||
|
|||||||
@@ -47,4 +47,5 @@ oneway interface INetworkAgent {
|
|||||||
void onQosFilterCallbackRegistered(int qosCallbackId, in QosFilterParcelable filterParcel);
|
void onQosFilterCallbackRegistered(int qosCallbackId, in QosFilterParcelable filterParcel);
|
||||||
void onQosCallbackUnregistered(int qosCallbackId);
|
void onQosCallbackUnregistered(int qosCallbackId);
|
||||||
void onNetworkCreated();
|
void onNetworkCreated();
|
||||||
|
void onNetworkDisconnected();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,14 @@ public abstract class NetworkAgent {
|
|||||||
*/
|
*/
|
||||||
public static final int CMD_NETWORK_CREATED = BASE + 22;
|
public static final int CMD_NETWORK_CREATED = BASE + 22;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent by ConnectivityService to {@link NetworkAgent} to inform the agent that its native
|
||||||
|
* network was destroyed.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int CMD_NETWORK_DISCONNECTED = BASE + 23;
|
||||||
|
|
||||||
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
|
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
|
||||||
// The subtype can be changed with (TODO) setLegacySubtype, but it starts
|
// The subtype can be changed with (TODO) setLegacySubtype, but it starts
|
||||||
// with 0 (TelephonyManager.NETWORK_TYPE_UNKNOWN) and an empty description.
|
// with 0 (TelephonyManager.NETWORK_TYPE_UNKNOWN) and an empty description.
|
||||||
@@ -574,6 +582,10 @@ public abstract class NetworkAgent {
|
|||||||
onNetworkCreated();
|
onNetworkCreated();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CMD_NETWORK_DISCONNECTED: {
|
||||||
|
onNetworkDisconnected();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,6 +731,11 @@ public abstract class NetworkAgent {
|
|||||||
public void onNetworkCreated() {
|
public void onNetworkCreated() {
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(CMD_NETWORK_CREATED));
|
mHandler.sendMessage(mHandler.obtainMessage(CMD_NETWORK_CREATED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNetworkDisconnected() {
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(CMD_NETWORK_DISCONNECTED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1031,6 +1048,12 @@ public abstract class NetworkAgent {
|
|||||||
*/
|
*/
|
||||||
public void onNetworkCreated() {}
|
public void onNetworkCreated() {}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when ConnectivityService has successfully destroy this NetworkAgent's native network.
|
||||||
|
*/
|
||||||
|
public void onNetworkDisconnected() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the network hardware send the specified packet at the specified interval.
|
* Requests that the network hardware send the specified packet at the specified interval.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3704,6 +3704,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mDnsManager.removeNetwork(nai.network);
|
mDnsManager.removeNetwork(nai.network);
|
||||||
}
|
}
|
||||||
mNetIdManager.releaseNetId(nai.network.getNetId());
|
mNetIdManager.releaseNetId(nai.network.getNetId());
|
||||||
|
nai.onNetworkDisconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
private boolean createNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
||||||
|
|||||||
@@ -588,6 +588,17 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the NetworkAgent that the network is disconnected and destroyed.
|
||||||
|
*/
|
||||||
|
public void onNetworkDisconnected() {
|
||||||
|
try {
|
||||||
|
networkAgent.onNetworkDisconnected();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Error sending network disconnected event", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: consider moving out of NetworkAgentInfo into its own class
|
// TODO: consider moving out of NetworkAgentInfo into its own class
|
||||||
private class NetworkAgentMessageHandler extends INetworkAgentRegistry.Stub {
|
private class NetworkAgentMessageHandler extends INetworkAgentRegistry.Stub {
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
|||||||
Reference in New Issue
Block a user