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

Commit 0e414a78 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add network created callback support" into sc-dev

parents acc5fbcb c5167795
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 onBandwidthUpdateRequested();
    method public void onNetworkCreated();
    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
@@ -46,4 +46,5 @@ oneway interface INetworkAgent {
    void onRemoveKeepalivePacketFilter(int slot);
    void onQosFilterCallbackRegistered(int qosCallbackId, in QosFilterParcelable filterParcel);
    void onQosCallbackUnregistered(int qosCallbackId);
    void onNetworkCreated();
}
+22 −0
Original line number Diff line number Diff line
@@ -362,6 +362,14 @@ public abstract class NetworkAgent {
     */
    public static final int CMD_UNREGISTER_QOS_CALLBACK = BASE + 21;

    /**
     * Sent by ConnectivityService to {@link NetworkAgent} to inform the agent that its native
     * network was created and the Network object is now valid.
     *
     * @hide
     */
    public static final int CMD_NETWORK_CREATED = BASE + 22;

    private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
        final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacySubType,
                config.legacyTypeName, config.legacySubTypeName);
@@ -561,6 +569,10 @@ public abstract class NetworkAgent {
                            msg.arg1 /* QoS callback id */);
                    break;
                }
                case CMD_NETWORK_CREATED: {
                    onNetworkCreated();
                    break;
                }
            }
        }
    }
@@ -701,6 +713,11 @@ public abstract class NetworkAgent {
            mHandler.sendMessage(mHandler.obtainMessage(
                    CMD_UNREGISTER_QOS_CALLBACK, qosCallbackId, 0, null));
        }

        @Override
        public void onNetworkCreated() {
            mHandler.sendMessage(mHandler.obtainMessage(CMD_NETWORK_CREATED));
        }
    }

    /**
@@ -1010,6 +1027,11 @@ public abstract class NetworkAgent {
    protected void saveAcceptUnvalidated(boolean accept) {
    }

    /**
     * Called when ConnectivityService has successfully created this NetworkAgent's native network.
     */
    public void onNetworkCreated() {}

    /**
     * Requests that the network hardware send the specified packet at the specified interval.
     *
+1 −0
Original line number Diff line number Diff line
@@ -8126,6 +8126,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
                updateCapabilitiesForNetwork(networkAgent);
            }
            networkAgent.created = true;
            networkAgent.onNetworkCreated();
        }

        if (!networkAgent.everConnected && state == NetworkInfo.State.CONNECTED) {
+11 −0
Original line number Diff line number Diff line
@@ -577,6 +577,17 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
        }
    }

    /**
     * Notify the NetworkAgent that the network is successfully connected.
     */
    public void onNetworkCreated() {
        try {
            networkAgent.onNetworkCreated();
        } catch (RemoteException e) {
            Log.e(TAG, "Error sending network created event", e);
        }
    }

    // TODO: consider moving out of NetworkAgentInfo into its own class
    private class NetworkAgentMessageHandler extends INetworkAgentRegistry.Stub {
        private final Handler mHandler;