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

Commit 53811b99 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge changes I53c01060,Iff8c36f5

* changes:
  Fixed incorrect 5G icon
  Exclude IWLAN from data dormant
parents 00d61d52 1e9544e0
Loading
Loading
Loading
Loading
+47 −54
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation;
import android.telephony.CarrierConfigManager;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneStateListener;
import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
@@ -36,6 +35,8 @@ import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.android.internal.telephony.dataconnection.DcController;
import com.android.internal.telephony.dataconnection.DcController.PhysicalLinkState;
import com.android.internal.util.IState;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.State;
@@ -81,19 +82,19 @@ public class NetworkTypeController extends StateMachine {
    private static final int EVENT_DATA_RAT_CHANGED = 2;
    private static final int EVENT_NR_STATE_CHANGED = 3;
    private static final int EVENT_NR_FREQUENCY_CHANGED = 4;
    private static final int EVENT_DATA_ACTIVITY_CHANGED = 5;
    private static final int EVENT_PHYSICAL_LINK_STATE_CHANGED = 5;
    private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED = 6;
    private static final int EVENT_CARRIER_CONFIG_CHANGED = 7;
    private static final int EVENT_PRIMARY_TIMER_EXPIRED = 8;
    private static final int EVENT_SECONDARY_TIMER_EXPIRED = 9;
    private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 10;
    private static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 11;
    private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 12;
    private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 11;
    private static final int EVENT_INIITIALIZE = 12;
    // events that don't reset the timer
    private static final int[] ALL_EVENTS = { EVENT_DATA_RAT_CHANGED, EVENT_NR_STATE_CHANGED,
            EVENT_NR_FREQUENCY_CHANGED, EVENT_DATA_ACTIVITY_CHANGED,
            EVENT_NR_FREQUENCY_CHANGED, EVENT_PHYSICAL_LINK_STATE_CHANGED,
            EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED, EVENT_PRIMARY_TIMER_EXPIRED,
            EVENT_SECONDARY_TIMER_EXPIRED, EVENT_DATA_CONNECTION_STATE_CHANGED };
            EVENT_SECONDARY_TIMER_EXPIRED};

    private static final String[] sEvents = new String[EVENT_PREFERRED_NETWORK_MODE_CHANGED + 1];
    static {
@@ -102,20 +103,18 @@ public class NetworkTypeController extends StateMachine {
        sEvents[EVENT_DATA_RAT_CHANGED] = "EVENT_DATA_RAT_CHANGED";
        sEvents[EVENT_NR_STATE_CHANGED] = "EVENT_NR_STATE_CHANGED";
        sEvents[EVENT_NR_FREQUENCY_CHANGED] = "EVENT_NR_FREQUENCY_CHANGED";
        sEvents[EVENT_DATA_ACTIVITY_CHANGED] = "EVENT_DATA_ACTIVITY_CHANGED";
        sEvents[EVENT_PHYSICAL_LINK_STATE_CHANGED] = "EVENT_PHYSICAL_LINK_STATE_CHANGED";
        sEvents[EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED] =
                "EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED";
        sEvents[EVENT_CARRIER_CONFIG_CHANGED] = "EVENT_CARRIER_CONFIG_CHANGED";
        sEvents[EVENT_PRIMARY_TIMER_EXPIRED] = "EVENT_PRIMARY_TIMER_EXPIRED";
        sEvents[EVENT_SECONDARY_TIMER_EXPIRED] = "EVENT_SECONDARY_TIMER_EXPIRED";
        sEvents[EVENT_RADIO_OFF_OR_UNAVAILABLE] = "EVENT_RADIO_OFF_OR_UNAVAILABLE";
        sEvents[EVENT_DATA_CONNECTION_STATE_CHANGED] = "EVENT_DATA_CONNECTION_STATE_CHANGED";
        sEvents[EVENT_PREFERRED_NETWORK_MODE_CHANGED] = "EVENT_PREFERRED_NETWORK_MODE_CHANGED";
    }

    private final Phone mPhone;
    private final DisplayInfoController mDisplayInfoController;
    private final TelephonyManager mTelephonyManager;
    private final SettingsObserver mSettingsObserver;
    private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        @Override
@@ -129,16 +128,6 @@ public class NetworkTypeController extends StateMachine {
            }
        }
    };
    private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
        @Override
        public void onDataActivity(int direction) {
            sendMessage(EVENT_DATA_ACTIVITY_CHANGED);
        }
        @Override
        public void onDataConnectionStateChanged(int state, int networkType) {
            sendMessage(EVENT_DATA_CONNECTION_STATE_CHANGED);
        }
    };

    private Map<String, OverrideTimerRule> mOverrideTimerRules = new HashMap<>();
    private String mLteEnhancedPattern = "";
@@ -149,6 +138,7 @@ public class NetworkTypeController extends StateMachine {
    private String mPrimaryTimerState;
    private String mSecondaryTimerState;
    private String mPreviousState;
    private @PhysicalLinkState int mPhysicalLinkState;

    /**
     * NetworkTypeController constructor.
@@ -160,8 +150,6 @@ public class NetworkTypeController extends StateMachine {
        super(TAG, displayInfoController);
        mPhone = phone;
        mDisplayInfoController = displayInfoController;
        mTelephonyManager = TelephonyManager.from(phone.getContext())
                .createForSubscriptionId(phone.getSubId());
        mSettingsObserver = new SettingsObserver(mPhone.getContext(), getHandler());
        mOverrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE;
        mIsPhysicalChannelConfigOn = true;
@@ -171,9 +159,8 @@ public class NetworkTypeController extends StateMachine {
        addState(mLteConnectedState, mDefaultState);
        addState(mNrConnectedState, mDefaultState);
        setInitialState(mDefaultState);
        registerForAllEvents();
        parseCarrierConfigs();
        start();
        sendMessage(EVENT_INIITIALIZE);
    }

    /**
@@ -190,6 +177,9 @@ public class NetworkTypeController extends StateMachine {
        mPhone.getServiceStateTracker().registerForDataRegStateOrRatChanged(
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getHandler(),
                EVENT_DATA_RAT_CHANGED, null);
        mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .registerForPhysicalLinkStateChanged(getHandler(),
                        EVENT_PHYSICAL_LINK_STATE_CHANGED);
        mPhone.getServiceStateTracker().registerForNrStateChanged(getHandler(),
                EVENT_NR_STATE_CHANGED, null);
        mPhone.getServiceStateTracker().registerForNrFrequencyChanged(getHandler(),
@@ -199,10 +189,6 @@ public class NetworkTypeController extends StateMachine {
        IntentFilter filter = new IntentFilter();
        filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);
        if (mTelephonyManager != null) {
            mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_ACTIVITY
                    | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
        }
        mSettingsObserver.observe(Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE),
                EVENT_PREFERRED_NETWORK_MODE_CHANGED);
    }
@@ -215,9 +201,6 @@ public class NetworkTypeController extends StateMachine {
        mPhone.getServiceStateTracker().unregisterForNrFrequencyChanged(getHandler());
        mPhone.getDeviceStateMonitor().unregisterForPhysicalChannelConfigNotifChanged(getHandler());
        mPhone.getContext().unregisterReceiver(mIntentReceiver);
        if (mTelephonyManager != null) {
            mTelephonyManager.listen(mPhoneStateListener, 0);
        }
        mSettingsObserver.unobserve();
    }

@@ -393,7 +376,7 @@ public class NetworkTypeController extends StateMachine {
                keys.add(STATE_CONNECTED);
                break;
            case NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED:
                keys.add(isDataActive() ? STATE_NOT_RESTRICTED_RRC_CON
                keys.add(isPhysicalLinkActive() ? STATE_NOT_RESTRICTED_RRC_CON
                        : STATE_NOT_RESTRICTED_RRC_IDLE);
                break;
            case NetworkRegistrationInfo.NR_STATE_RESTRICTED:
@@ -457,12 +440,22 @@ public class NetworkTypeController extends StateMachine {
                    unRegisterForAllEvents();
                    quit();
                    break;
                case EVENT_INIITIALIZE:
                    // The reason that we do it here is because some of the works below requires
                    // other modules (e.g. DcTracker, ServiceStateTracker), which is not created
                    // yet when NetworkTypeController is created.
                    registerForAllEvents();
                    parseCarrierConfigs();
                    break;
                case EVENT_DATA_RAT_CHANGED:
                case EVENT_NR_STATE_CHANGED:
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_DATA_ACTIVITY_CHANGED:
                    // ignored
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED:
                    AsyncResult result = (AsyncResult) msg.obj;
                    mIsPhysicalChannelConfigOn = (boolean) result.result;
@@ -498,13 +491,6 @@ public class NetworkTypeController extends StateMachine {
                    resetAllTimers();
                    transitionTo(mLegacyState);
                    break;
                case EVENT_DATA_CONNECTION_STATE_CHANGED:
                    if (mPhone.getServiceState().getDataNetworkType()
                            != mDisplayInfoController.getTelephonyDisplayInfo().getNetworkType()) {
                        resetAllTimers();
                        transitionToCurrentState();
                    }
                    break;
                case EVENT_PREFERRED_NETWORK_MODE_CHANGED:
                    resetAllTimers();
                    transitionToCurrentState();
@@ -551,7 +537,8 @@ public class NetworkTypeController extends StateMachine {
                    if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) {
                        transitionTo(mNrConnectedState);
                    } else if (isLte(rat) && isNrNotRestricted()) {
                        transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState);
                        transitionWithTimerTo(isPhysicalLinkActive()
                                ? mLteConnectedState : mIdleState);
                    } else {
                        updateOverrideNetworkType();
                    }
@@ -561,14 +548,14 @@ public class NetworkTypeController extends StateMachine {
                    if (isNrConnected()) {
                        transitionTo(mNrConnectedState);
                    } else if (isLte(rat) && isNrNotRestricted()) {
                        transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState);
                        transitionWithTimerTo(isPhysicalLinkActive()
                                ? mLteConnectedState : mIdleState);
                    } else if (isLte(rat) && isNrRestricted()) {
                        updateOverrideNetworkType();
                    }
                    mIsNrRestricted = isNrRestricted();
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_DATA_ACTIVITY_CHANGED:
                    // ignored
                    break;
                default:
@@ -625,10 +612,12 @@ public class NetworkTypeController extends StateMachine {
                case EVENT_NR_FREQUENCY_CHANGED:
                    // ignore
                    break;
                case EVENT_DATA_ACTIVITY_CHANGED:
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
                    if (isNrNotRestricted()) {
                        // NOT_RESTRICTED_RRC_IDLE -> NOT_RESTRICTED_RRC_CON
                        if (isDataActive()) {
                        if (isPhysicalLinkActive()) {
                            transitionWithTimerTo(mLteConnectedState);
                        }
                    } else {
@@ -690,10 +679,12 @@ public class NetworkTypeController extends StateMachine {
                case EVENT_NR_FREQUENCY_CHANGED:
                    // ignore
                    break;
                case EVENT_DATA_ACTIVITY_CHANGED:
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
                    if (isNrNotRestricted()) {
                        // NOT_RESTRICTED_RRC_CON -> NOT_RESTRICTED_RRC_IDLE
                        if (!isDataActive()) {
                        if (!isPhysicalLinkActive()) {
                            transitionWithTimerTo(mIdleState);
                        }
                    } else {
@@ -745,14 +736,16 @@ public class NetworkTypeController extends StateMachine {
                    if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) {
                        updateOverrideNetworkType();
                    } else if (isLte(rat) && isNrNotRestricted()) {
                        transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState);
                        transitionWithTimerTo(isPhysicalLinkActive()
                                ? mLteConnectedState : mIdleState);
                    } else {
                        transitionWithTimerTo(mLegacyState);
                    }
                    break;
                case EVENT_NR_STATE_CHANGED:
                    if (isLte(rat) && isNrNotRestricted()) {
                        transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState);
                        transitionWithTimerTo(isPhysicalLinkActive()
                                ? mLteConnectedState : mIdleState);
                    } else if (rat != TelephonyManager.NETWORK_TYPE_NR && !isNrConnected()) {
                        transitionWithTimerTo(mLegacyState);
                    }
@@ -772,7 +765,9 @@ public class NetworkTypeController extends StateMachine {
                    }
                    mIsNrMmwave = isNrMmwave();
                    break;
                case EVENT_DATA_ACTIVITY_CHANGED:
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
                    if (!isNrConnected()) {
                        log("NR state changed. Sending EVENT_NR_STATE_CHANGED");
                        sendMessage(EVENT_NR_STATE_CHANGED);
@@ -831,7 +826,7 @@ public class NetworkTypeController extends StateMachine {
            transitionState = mNrConnectedState;
            mPreviousState = isNrMmwave() ? STATE_CONNECTED_MMWAVE : STATE_CONNECTED;
        } else if (isLte(dataRat) && isNrNotRestricted()) {
            if (isDataActive()) {
            if (isPhysicalLinkActive()) {
                transitionState = mLteConnectedState;
                mPreviousState = STATE_NOT_RESTRICTED_RRC_CON;
            } else {
@@ -994,10 +989,8 @@ public class NetworkTypeController extends StateMachine {
                || rat == TelephonyManager.NETWORK_TYPE_LTE_CA;
    }

    private boolean isDataActive() {
        PhoneInternalInterface.DataActivityState activity = mPhone.getDataActivityState();
        return activity != PhoneInternalInterface.DataActivityState.DORMANT
                && activity != PhoneInternalInterface.DataActivityState.NONE;
    private boolean isPhysicalLinkActive() {
        return mPhysicalLinkState == DcController.PHYSICAL_LINK_ACTIVE;
    }

    private String getEventName(int event) {
+77 −17
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.dataconnection;

import android.annotation.IntDef;
import android.content.Context;
import android.hardware.radio.V1_4.DataConnActiveStatus;
import android.net.LinkAddress;
@@ -25,6 +26,7 @@ import android.net.util.NetUtils;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
import android.os.RegistrantList;
import android.telephony.AccessNetworkConstants;
import android.telephony.DataFailCause;
import android.telephony.PhoneStateListener;
@@ -42,6 +44,8 @@ import com.android.telephony.Rlog;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -55,6 +59,24 @@ public class DcController extends StateMachine {
    private static final boolean DBG = true;
    private static final boolean VDBG = false;

    /** Physical link state unknown */
    public static final int PHYSICAL_LINK_UNKNOWN = 0;

    /** Physical link state inactive (i.e. RRC idle) */
    public static final int PHYSICAL_LINK_NOT_ACTIVE = 1;

    /** Physical link state active (i.e. RRC connected) */
    public static final int PHYSICAL_LINK_ACTIVE = 2;

    /** @hide */
    @IntDef(prefix = { "PHYSICAL_LINK_" }, value = {
            PHYSICAL_LINK_UNKNOWN,
            PHYSICAL_LINK_NOT_ACTIVE,
            PHYSICAL_LINK_ACTIVE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface PhysicalLinkState{}

    private final Phone mPhone;
    private final DcTracker mDct;
    private final DataServiceManager mDataServiceManager;
@@ -76,6 +98,16 @@ public class DcController extends StateMachine {
    //carrier network change
    private volatile boolean mExecutingCarrierChange;

    /**
     * Aggregated physical link state from all data connections. This reflects the device's RRC
     * connection state.
     * // TODO: Instead of tracking the RRC state here, we should make PhysicalChannelConfig work in
     *          S.
     */
    private @PhysicalLinkState int mPhysicalLinkState = PHYSICAL_LINK_UNKNOWN;

    private RegistrantList mPhysicalLinkStateChangedRegistrants = new RegistrantList();

    /**
     * Constructor.
     *
@@ -392,6 +424,14 @@ public class DcController extends StateMachine {
                }
            }

            if (mDataServiceManager.getTransportType()
                    == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
                int physicalLinkState = isAnyDataCallActive
                        ? PHYSICAL_LINK_ACTIVE : PHYSICAL_LINK_NOT_ACTIVE;
                if (mPhysicalLinkState != physicalLinkState) {
                    mPhysicalLinkState = physicalLinkState;
                    mPhysicalLinkStateChangedRegistrants.notifyResult(mPhysicalLinkState);
                }
                if (isAnyDataCallDormant && !isAnyDataCallActive) {
                    // There is no way to indicate link activity per APN right now. So
                    // Link Activity will be considered dormant only when all data calls
@@ -399,19 +439,20 @@ public class DcController extends StateMachine {
                    // If a single data call is in dormant state and none of the data
                    // calls are active broadcast overall link state as dormant.
                    if (DBG) {
                    log("onDataStateChanged: Data Activity updated to DORMANT. stopNetStatePoll");
                        log("onDataStateChanged: Data activity DORMANT. stopNetStatePoll");
                    }
                    mDct.sendStopNetStatPoll(DctConstants.Activity.DORMANT);
                } else {
                    if (DBG) {
                    log("onDataStateChanged: Data Activity updated to NONE. " +
                            "isAnyDataCallActive = " + isAnyDataCallActive +
                            " isAnyDataCallDormant = " + isAnyDataCallDormant);
                        log("onDataStateChanged: Data Activity updated to NONE. "
                                + "isAnyDataCallActive = " + isAnyDataCallActive
                                + " isAnyDataCallDormant = " + isAnyDataCallDormant);
                    }
                    if (isAnyDataCallActive) {
                        mDct.sendStartNetStatPoll(DctConstants.Activity.NONE);
                    }
                }
            }

            if (DBG) {
                lr("onDataStateChanged: dcsToRetry=" + dcsToRetry
@@ -433,6 +474,25 @@ public class DcController extends StateMachine {
        }
    }

    /**
     * Register for physical link state (i.e. RRC state) changed event.
     *
     * @param h The handler
     * @param what The event
     */
    public void registerForPhysicalLinkStateChanged(Handler h, int what) {
        mPhysicalLinkStateChangedRegistrants.addUnique(h, what, null);
    }

    /**
     * Unregister from physical link state (i.e. RRC state) changed event.
     *
     * @param h The previously registered handler
     */
    public void unregisterForPhysicalLinkStateChanged(Handler h) {
        mPhysicalLinkStateChangedRegistrants.remove(h);
    }

    /**
     * lr is short name for logAndAddLogRec
     * @param s
+19 −0
Original line number Diff line number Diff line
@@ -5131,4 +5131,23 @@ public class DcTracker extends Handler {
        }
        updateLinkBandwidths(bandwidths, useLte);
    }

    /**
     * Register for physical link state (i.e. RRC state) changed event.
     *
     * @param h The handler
     * @param what The event
     */
    public void registerForPhysicalLinkStateChanged(Handler h, int what) {
        mDcc.registerForPhysicalLinkStateChanged(h, what);
    }

    /**
     * Unregister from physical link state (i.e. RRC state) changed event.
     *
     * @param h The previously registered handler
     */
    public void unregisterForPhysicalLinkStateChanged(Handler h) {
        mDcc.unregisterForPhysicalLinkStateChanged(h);
    }
}
+13 −38

File changed.

Preview size limit exceeded, changes collapsed.

+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.net.LinkProperties;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Looper;
import android.telephony.AccessNetworkConstants;
import android.telephony.data.ApnSetting;
import android.telephony.data.DataCallResponse;
import android.test.suitebuilder.annotation.SmallTest;
@@ -99,6 +100,8 @@ public class DcControllerTest extends TelephonyTest {
        LinkProperties lp = new LinkProperties();
        mResult = new UpdateLinkPropertyResult(lp);
        doReturn(mResult).when(mDc).updateLinkProperty(any(DataCallResponse.class));
        doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .when(mDataServiceManager).getTransportType();

        mDcc = DcController.makeDcc(mPhone, mDcTracker, mDataServiceManager,
                new Handler(Looper.myLooper()), "");