Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ac46f93 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add network disconnected callback"

parents 2108a924 34a2358d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ package android.net {
    method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
    method public void onAutomaticReconnectDisabled();
    method public void onNetworkCreated();
    method public void onNetworkDisconnected();
    method public void onNetworkUnwanted();
    method public void onQosCallbackRegistered(int, @NonNull android.net.QosFilter);
    method public void onQosCallbackUnregistered(int);
+1 −0
Original line number Diff line number Diff line
@@ -47,4 +47,5 @@ oneway interface INetworkAgent {
    void onQosFilterCallbackRegistered(int qosCallbackId, in QosFilterParcelable filterParcel);
    void onQosCallbackUnregistered(int qosCallbackId);
    void onNetworkCreated();
    void onNetworkDisconnected();
}
+23 −0
Original line number Diff line number Diff line
@@ -370,6 +370,14 @@ public abstract class NetworkAgent {
     */
    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) {
        // The subtype can be changed with (TODO) setLegacySubtype, but it starts
        // with 0 (TelephonyManager.NETWORK_TYPE_UNKNOWN) and an empty description.
@@ -574,6 +582,10 @@ public abstract class NetworkAgent {
                    onNetworkCreated();
                    break;
                }
                case CMD_NETWORK_DISCONNECTED: {
                    onNetworkDisconnected();
                    break;
                }
            }
        }
    }
@@ -719,6 +731,11 @@ public abstract class NetworkAgent {
        public void onNetworkCreated() {
            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() {}


    /**
     * 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.
     *
+1 −0
Original line number Diff line number Diff line
@@ -3704,6 +3704,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
            mDnsManager.removeNetwork(nai.network);
        }
        mNetIdManager.releaseNetId(nai.network.getNetId());
        nai.onNetworkDisconnected();
    }

    private boolean createNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
+11 −0
Original line number Diff line number Diff line
@@ -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
    private class NetworkAgentMessageHandler extends INetworkAgentRegistry.Stub {
        private final Handler mHandler;