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

Commit 8347cc9a authored by Ying Xu's avatar Ying Xu Committed by Cassie
Browse files

Revert "Remove the usage of hidden APIs from NetworkInfo"

This reverts commit b60e9882.

Reason for revert: May be the cause of b/149459996

Bug: 148674994
Test: Telephony Unit Tests
Change-Id: Ia27d8f063090fb014d18de3a4aed3d12db17186f
parent e12e6a29
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -1715,6 +1715,7 @@ public class DataConnection extends StateMachine {
                                + " drs=" + mDataRegState
                                + " drs=" + mDataRegState
                                + " mRilRat=" + mRilRat);
                                + " mRilRat=" + mRilRat);
                    }
                    }
                    updateNetworkInfo();
                    break;
                    break;
                default:
                default:
                    if (DBG) {
                    if (DBG) {
@@ -1727,6 +1728,19 @@ 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() {
    private void updateNetworkInfoSuspendState() {
        // this is only called when we are either connected or suspended.  Decide which.
        // this is only called when we are either connected or suspended.  Decide which.
        if (mNetworkAgent == null) {
        if (mNetworkAgent == null) {
@@ -2058,6 +2072,8 @@ public class DataConnection extends StateMachine {
                    mApnSetting != null
                    mApnSetting != null
                        ? mApnSetting.canHandleType(ApnSetting.TYPE_DEFAULT) : false);
                        ? mApnSetting.canHandleType(ApnSetting.TYPE_DEFAULT) : false);


            updateNetworkInfo();

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


            mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED,
            mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED,
                    mNetworkInfo.getReason(), null);
                    mNetworkInfo.getReason(), null);
            mNetworkInfo.setExtraInfo(mApnSetting.getApnName());
            updateTcpBufferSizes(mRilRat);
            updateTcpBufferSizes(mRilRat);
            if (isBandwidthSourceKey(DctConstants.BANDWIDTH_SOURCE_CARRIER_CONFIG_KEY)) {
            if (isBandwidthSourceKey(DctConstants.BANDWIDTH_SOURCE_CARRIER_CONFIG_KEY)) {
                updateLinkBandwidthsFromCarrierConfig(mRilRat);
                updateLinkBandwidthsFromCarrierConfig(mRilRat);
@@ -2339,6 +2356,7 @@ public class DataConnection extends StateMachine {
                case EVENT_DATA_CONNECTION_ROAM_ON:
                case EVENT_DATA_CONNECTION_ROAM_ON:
                case EVENT_DATA_CONNECTION_ROAM_OFF:
                case EVENT_DATA_CONNECTION_ROAM_OFF:
                case EVENT_DATA_CONNECTION_OVERRIDE_CHANGED: {
                case EVENT_DATA_CONNECTION_OVERRIDE_CHANGED: {
                    updateNetworkInfo();
                    if (mNetworkAgent != null) {
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                                DataConnection.this);
                                DataConnection.this);
@@ -2360,6 +2378,7 @@ public class DataConnection extends StateMachine {
                }
                }
                case EVENT_DATA_CONNECTION_VOICE_CALL_STARTED:
                case EVENT_DATA_CONNECTION_VOICE_CALL_STARTED:
                case EVENT_DATA_CONNECTION_VOICE_CALL_ENDED: {
                case EVENT_DATA_CONNECTION_VOICE_CALL_ENDED: {
                    updateNetworkInfo();
                    updateNetworkInfoSuspendState();
                    updateNetworkInfoSuspendState();
                    if (mNetworkAgent != null) {
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                        mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
+3 −14
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@ import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.AnomalyReporter;
import android.telephony.AnomalyReporter;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
import android.util.LocalLog;
import android.util.SparseArray;
import android.util.SparseArray;
@@ -284,19 +282,10 @@ public class DcNetworkAgent extends NetworkAgent {
        if (!isOwned(dc, "sendNetworkInfo")) return;
        if (!isOwned(dc, "sendNetworkInfo")) return;
        final NetworkInfo.State oldState = mNetworkInfo.getState();
        final NetworkInfo.State oldState = mNetworkInfo.getState();
        final NetworkInfo.State state = networkInfo.getState();
        final NetworkInfo.State state = networkInfo.getState();
        String extraInfo = dc.getApnSetting().getApnName();
        if (mNetworkInfo.getExtraInfo() != networkInfo.getExtraInfo()) {
        if (mNetworkInfo.getExtraInfo() != extraInfo) {
            setLegacyExtraInfo(networkInfo.getExtraInfo());
            setLegacyExtraInfo(extraInfo);
        }
        }

        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) {
        if (mNetworkInfo.getSubtype() != subType) {
            setLegacySubtype(subType, TelephonyManager.getNetworkTypeName(subType));
            setLegacySubtype(subType, TelephonyManager.getNetworkTypeName(subType));
        }
        }