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

Commit b60e9882 authored by yinxu's avatar yinxu
Browse files

Remove the usage of hidden APIs from NetworkInfo

Bug: 148674994
Test: Telephony Unit Tests
Change-Id: I635fc707b614eddef320cdc84c83a05840f95977
parent b1b247ab
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -1655,7 +1655,6 @@ public class DataConnection extends StateMachine {
                                + " drs=" + mDataRegState
                                + " mRilRat=" + mRilRat);
                    }
                    updateNetworkInfo();
                    updateNetworkInfoSuspendState();
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
@@ -1668,7 +1667,6 @@ public class DataConnection extends StateMachine {
                case EVENT_DATA_CONNECTION_ROAM_OFF:
                case EVENT_DATA_CONNECTION_METEREDNESS_CHANGED:
                case EVENT_DATA_CONNECTION_OVERRIDE_CHANGED:
                    updateNetworkInfo();
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                                DataConnection.this);
@@ -1693,19 +1691,6 @@ public class DataConnection extends StateMachine {
        }
    }

    private void updateNetworkInfo() {
        final ServiceState state = mPhone.getServiceState();

        NetworkRegistrationInfo nri = state.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, mTransportType);
        int subtype = TelephonyManager.NETWORK_TYPE_UNKNOWN;
        if (nri != null) {
            subtype = nri.getAccessNetworkTechnology();
        }

        mNetworkInfo.setSubtype(subtype, TelephonyManager.getNetworkTypeName(subtype));
    }

    private void updateNetworkInfoSuspendState() {
        // this is only called when we are either connected or suspended.  Decide which.
        if (mNetworkAgent == null) {
@@ -2037,8 +2022,6 @@ public class DataConnection extends StateMachine {
                    mApnSetting != null
                        ? mApnSetting.canHandleType(ApnSetting.TYPE_DEFAULT) : false);

            updateNetworkInfo();

            // If we were retrying there maybe more than one, otherwise they'll only be one.
            notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE,
                    Phone.REASON_CONNECTED);
@@ -2054,7 +2037,6 @@ public class DataConnection extends StateMachine {

            mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED,
                    mNetworkInfo.getReason(), null);
            mNetworkInfo.setExtraInfo(mApnSetting.getApnName());
            updateTcpBufferSizes(mRilRat);

            final NetworkAgentConfig.Builder configBuilder = new NetworkAgentConfig.Builder();
@@ -2275,7 +2257,6 @@ public class DataConnection extends StateMachine {
                case EVENT_DATA_CONNECTION_ROAM_OFF:
                case EVENT_DATA_CONNECTION_METEREDNESS_CHANGED:
                case EVENT_DATA_CONNECTION_OVERRIDE_CHANGED: {
                    updateNetworkInfo();
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                                DataConnection.this);
@@ -2303,7 +2284,6 @@ public class DataConnection extends StateMachine {
                }
                case EVENT_DATA_CONNECTION_VOICE_CALL_STARTED:
                case EVENT_DATA_CONNECTION_VOICE_CALL_ENDED: {
                    updateNetworkInfo();
                    updateNetworkInfoSuspendState();
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
+14 −3
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.net.SocketKeepalive;
import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
import android.util.SparseArray;
@@ -249,10 +251,19 @@ public class DcNetworkAgent extends NetworkAgent {
        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());
        String extraInfo = dc.getApnSetting().getApnName();
        if (mNetworkInfo.getExtraInfo() != extraInfo) {
            setLegacyExtraInfo(extraInfo);
        }
        final int subType = networkInfo.getSubtype();

        final ServiceState serviceState = mPhone.getServiceState();
        NetworkRegistrationInfo nri = serviceState.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, mTransportType);
        int subType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
        if (nri != null) {
            subType = nri.getAccessNetworkTechnology();
        }

        if (mNetworkInfo.getSubtype() != subType) {
            setLegacySubtype(subType, TelephonyManager.getNetworkTypeName(subType));
        }