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

Commit 3875fdf6 authored by Aaron Huang's avatar Aaron Huang Committed by Gerrit Code Review
Browse files

Merge changes from topic "networkagent-register"

* changes:
  Use NetworkAgent#register.
  Remove usages of non-system API NetworkAgent methods
  Use the new NetworkAgent API
  Use NetworkFactory from frameworks/libs/net.
parents 5e153e49 848c730e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ java_library {
    srcs: [
        ":opt-telephony-common-srcs",
        ":framework-telephony-stack-shared-srcs",
        ":net-utils-telephony-common-srcs",
        "src/java/**/I*.aidl",
        "src/java/**/*.logtags",
    ],
+1 −0
Original line number Diff line number Diff line
rule android.net.NetworkFactory* com.android.internal.telephony.NetworkFactory@1
rule android.os.RegistrantList* com.android.internal.telephony.RegistrantList@1
rule android.os.Registrant* com.android.internal.telephony.Registrant@1
rule android.hidl.** android.internal.hidl.@1
+8 −3
Original line number Diff line number Diff line
@@ -2058,6 +2058,8 @@ public class DataConnection extends StateMachine {
            updateTcpBufferSizes(mRilRat);

            final NetworkAgentConfig.Builder configBuilder = new NetworkAgentConfig.Builder();
            configBuilder.setLegacyType(ConnectivityManager.TYPE_MOBILE);
            configBuilder.setLegacyTypeName(NETWORK_TYPE);
            final CarrierSignalAgent carrierSignalAgent = mPhone.getCarrierSignalAgent();
            if (carrierSignalAgent.hasRegisteredReceivers(TelephonyManager
                    .ACTION_CARRIER_SIGNAL_REDIRECTED)) {
@@ -2125,14 +2127,17 @@ public class DataConnection extends StateMachine {
                mScore = calculateScore();
                final NetworkFactory factory = PhoneFactory.getNetworkFactory(
                        mPhone.getPhoneId());
                final int providerId = (null == factory)
                        ? NetworkProvider.ID_NONE : factory.getProviderId();
                final NetworkProvider provider = (null == factory) ? null : factory.getProvider();

                mDisabledApnTypeBitMask |= getDisallowedApnTypes();

                mNetworkAgent = new DcNetworkAgent(DataConnection.this,
                        mPhone, mNetworkInfo, mScore, configBuilder.build(), providerId,
                        mPhone, mNetworkInfo, mScore, configBuilder.build(), provider,
                        mTransportType);
                // All network agents start out in CONNECTING mode, but DcNetworkAgents are
                // created when the network is already connected. Hence, send the connected
                // notification immediately.
                mNetworkAgent.setConnected();
            }

            if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
+53 −52
Original line number Diff line number Diff line
@@ -17,16 +17,19 @@
package com.android.internal.telephony.dataconnection;

import android.annotation.NonNull;
import android.net.KeepalivePacketData;
import android.net.LinkProperties;
import android.net.NattKeepalivePacketData;
import android.net.NetworkAgent;
import android.net.NetworkAgentConfig;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkProvider;
import android.net.SocketKeepalive;
import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
import android.util.SparseArray;

@@ -68,11 +71,12 @@ public class DcNetworkAgent extends NetworkAgent {
    private NetworkInfo mNetworkInfo;

    DcNetworkAgent(DataConnection dc, Phone phone, NetworkInfo ni, int score,
            NetworkAgentConfig config, int factorySerialNumber, int transportType) {
        super(dc.getHandler().getLooper(), phone.getContext(), "DcNetworkAgent", ni,
            NetworkAgentConfig config, NetworkProvider networkProvider, int transportType) {
        super(phone.getContext(), dc.getHandler().getLooper(), "DcNetworkAgent",
                dc.getNetworkCapabilities(), dc.getLinkProperties(), score, config,
                factorySerialNumber);
        mTag = "DcNetworkAgent" + "-" + network.netId;
                networkProvider);
        register();
        mTag = "DcNetworkAgent" + "-" + getNetwork().netId;
        mPhone = phone;
        mNetworkCapabilities = dc.getNetworkCapabilities();
        mTransportType = transportType;
@@ -125,22 +129,22 @@ public class DcNetworkAgent extends NetworkAgent {
    }

    @Override
    protected synchronized void unwanted() {
    public synchronized void onNetworkUnwanted() {
        if (mDataConnection == null) {
            loge("Unwanted found called on no-owner DcNetworkAgent!");
            loge("onNetworkUnwanted found called on no-owner DcNetworkAgent!");
            return;
        }

        logd("unwanted called. Now tear down the data connection "
        logd("onNetworkUnwanted called. Now tear down the data connection "
                + mDataConnection.getName());
        mDataConnection.tearDownAll(Phone.REASON_RELEASED_BY_CONNECTIVITY_SERVICE,
                DcTracker.RELEASE_TYPE_DETACH, null);
    }

    @Override
    protected synchronized void pollLceData() {
    public synchronized void onBandwidthUpdateRequested() {
        if (mDataConnection == null) {
            loge("pollLceData called on no-owner DcNetworkAgent!");
            loge("onBandwidthUpdateRequested called on no-owner DcNetworkAgent!");
            return;
        }

@@ -152,9 +156,9 @@ public class DcNetworkAgent extends NetworkAgent {
    }

    @Override
    protected synchronized void networkStatus(int status, String redirectUrl) {
    public synchronized void onValidationStatus(int status, String redirectUrl) {
        if (mDataConnection == null) {
            loge("networkStatus called on no-owner DcNetworkAgent!");
            loge("onValidationStatus called on no-owner DcNetworkAgent!");
            return;
        }

@@ -167,6 +171,18 @@ public class DcNetworkAgent extends NetworkAgent {
        }
    }

    private synchronized boolean isOwned(DataConnection dc, String reason) {
        if (mDataConnection == null) {
            loge(reason + " called on no-owner DcNetworkAgent!");
            return false;
        } else if (mDataConnection != dc) {
            loge(reason + ": This agent belongs to "
                    + mDataConnection.getName() + ", ignored the request from " + dc.getName());
            return false;
        }
        return true;
    }

    /**
     * Set the network capabilities.
     *
@@ -175,14 +191,7 @@ public class DcNetworkAgent extends NetworkAgent {
     */
    public synchronized void sendNetworkCapabilities(NetworkCapabilities networkCapabilities,
                                                     DataConnection dc) {
        if (mDataConnection == null) {
            loge("sendNetworkCapabilities called on no-owner DcNetworkAgent!");
            return;
        } else if (mDataConnection != dc) {
            loge("sendNetworkCapabilities: This agent belongs to "
                    + mDataConnection.getName() + ", ignored the request from " + dc.getName());
            return;
        }
        if (!isOwned(dc, "sendNetworkCapabilities")) return;

        if (!networkCapabilities.equals(mNetworkCapabilities)) {
            String logStr = "Changed from " + mNetworkCapabilities + " to "
@@ -215,14 +224,7 @@ public class DcNetworkAgent extends NetworkAgent {
     */
    public synchronized void sendLinkProperties(LinkProperties linkProperties,
                                                DataConnection dc) {
        if (mDataConnection == null) {
            loge("sendLinkProperties called on no-owner DcNetworkAgent!");
            return;
        } else if (mDataConnection != dc) {
            loge("sendLinkProperties: This agent belongs to "
                    + mDataConnection.getName() + ", ignored the request from " + dc.getName());
            return;
        }
        if (!isOwned(dc, "sendLinkProperties")) return;
        sendLinkProperties(linkProperties);
    }

@@ -233,14 +235,7 @@ public class DcNetworkAgent extends NetworkAgent {
     * @param dc The data connection that invokes this method.
     */
    public synchronized void sendNetworkScore(int score, DataConnection dc) {
        if (mDataConnection == null) {
            loge("sendNetworkScore called on no-owner DcNetworkAgent!");
            return;
        } else if (mDataConnection != dc) {
            loge("sendNetworkScore: This agent belongs to "
                    + mDataConnection.getName() + ", ignored the request from " + dc.getName());
            return;
        }
        if (!isOwned(dc, "sendNetworkScore")) return;
        sendNetworkScore(score);
    }

@@ -251,16 +246,21 @@ public class DcNetworkAgent extends NetworkAgent {
     * @param dc The data connection that invokes this method.
     */
    public synchronized void sendNetworkInfo(NetworkInfo networkInfo, DataConnection dc) {
        if (mDataConnection == null) {
            loge("sendNetworkInfo called on no-owner DcNetworkAgent!");
            return;
        } else if (mDataConnection != dc) {
            loge("sendNetworkInfo: This agent belongs to "
                    + mDataConnection.getName() + ", ignored the request from " + dc.getName());
            return;
        if (!isOwned(dc, "sendNetworkInfo")) return;
        final NetworkInfo.State oldState = mNetworkInfo.getState();
        final NetworkInfo.State state = networkInfo.getState();
        if (mNetworkInfo.getExtraInfo() != networkInfo.getExtraInfo()) {
            setLegacyExtraInfo(networkInfo.getExtraInfo());
        }
        final int subType = networkInfo.getSubtype();
        if (mNetworkInfo.getSubtype() != subType) {
            setLegacySubtype(subType, TelephonyManager.getNetworkTypeName(subType));
        }
        if ((oldState == NetworkInfo.State.SUSPENDED || oldState == NetworkInfo.State.CONNECTED)
                && state == NetworkInfo.State.DISCONNECTED) {
            unregister();
        }
        mNetworkInfo = networkInfo;
        sendNetworkInfo(networkInfo);
    }

    /**
@@ -273,29 +273,30 @@ public class DcNetworkAgent extends NetworkAgent {
    }

    @Override
    protected synchronized void startSocketKeepalive(Message msg) {
    public synchronized void onStartSocketKeepalive(int slot, int intervalSeconds,
            @NonNull KeepalivePacketData packet) {
        if (mDataConnection == null) {
            loge("startSocketKeepalive called on no-owner DcNetworkAgent!");
            loge("onStartSocketKeepalive called on no-owner DcNetworkAgent!");
            return;
        }

        if (msg.obj instanceof NattKeepalivePacketData) {
        if (packet instanceof NattKeepalivePacketData) {
            mDataConnection.obtainMessage(DataConnection.EVENT_KEEPALIVE_START_REQUEST,
                    msg.arg1, msg.arg2, msg.obj).sendToTarget();
                    slot, intervalSeconds, packet).sendToTarget();
        } else {
            onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED);
            sendSocketKeepaliveEvent(slot, SocketKeepalive.ERROR_UNSUPPORTED);
        }
    }

    @Override
    protected synchronized void stopSocketKeepalive(Message msg) {
    public synchronized void onStopSocketKeepalive(int slot) {
        if (mDataConnection == null) {
            loge("stopSocketKeepalive called on no-owner DcNetworkAgent!");
            loge("onStopSocketKeepalive called on no-owner DcNetworkAgent!");
            return;
        }

        mDataConnection.obtainMessage(DataConnection.EVENT_KEEPALIVE_STOP_REQUEST,
                msg.arg1, msg.arg2, msg.obj).sendToTarget();
        mDataConnection.obtainMessage(DataConnection.EVENT_KEEPALIVE_STOP_REQUEST, slot)
                .sendToTarget();
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -2968,7 +2968,7 @@ public class DcTracker extends Handler {
            mPhone.getCarrierSignalAgent().notifyCarrierSignalReceivers(intent);
            log("Notify carrier signal receivers with redirectUrl: " + redirectUrl);
        } else {
            final boolean isValid = status == NetworkAgent.VALID_NETWORK;
            final boolean isValid = status == NetworkAgent.VALIDATION_STATUS_VALID;
            final DataConnection dc = getDataConnectionByContextId(cid);
            if (!mDsRecoveryHandler.isRecoveryOnBadNetworkEnabled()) {
                if (DBG) log("Skip data stall recovery on network status change with in threshold");
Loading