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

Commit c301eb05 authored by Sarah Chin's avatar Sarah Chin
Browse files

TelephonyDisplayInfo get network type from NetworkTypeController

Prevent network type and override network type mismatch in the race
condition where the override network type is updated and the data rat
changes as we're updating the TelephonyDisplayInfo.
Get the network type from the cached ServiceState value in
NetworkTypeController instead.

Test: atest NetworkTypeControllerTest
Bug: 239184651
Change-Id: I62244d8dc99d742dff284f6a9e14b06527da4cf0
parent 6231102f
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -20,9 +20,7 @@ import android.annotation.NonNull;
import android.os.Handler;
import android.os.Registrant;
import android.os.RegistrantList;
import android.telephony.AccessNetworkConstants;
import android.telephony.AnomalyReporter;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.util.IndentingPrintWriter;
@@ -45,8 +43,6 @@ import javax.sip.InvalidArgumentException;
 * TelephonyDisplayInfo via {@link #getTelephonyDisplayInfo}.
 */
public class DisplayInfoController extends Handler {
    private static final String TAG = "DisplayInfoController";

    private final String mLogTag;
    private final LocalLog mLocalLog = new LocalLog(128);

@@ -90,11 +86,8 @@ public class DisplayInfoController extends Handler {
     * NetworkTypeController.
     */
    public void updateTelephonyDisplayInfo() {
        NetworkRegistrationInfo nri =  mPhone.getServiceState().getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        int dataNetworkType = nri == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN
                : nri.getAccessNetworkTechnology();
        TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo(dataNetworkType,
        TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo(
                mNetworkTypeController.getDataNetworkType(),
                mNetworkTypeController.getOverrideNetworkType());
        if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) {
            logl("TelephonyDisplayInfo changed from " + mTelephonyDisplayInfo + " to "
+11 −7
Original line number Diff line number Diff line
@@ -214,6 +214,17 @@ public class NetworkTypeController extends StateMachine {
        return mOverrideNetworkType;
    }

    /**
     * @return The current data network type, used to create TelephonyDisplayInfo in
     * DisplayInfoController.
     */
    public @Annotation.NetworkType int getDataNetworkType() {
        NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        return nri == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN
                : nri.getAccessNetworkTechnology();
    }

    /**
     * @return {@code true} if either the primary or secondary 5G icon timers are active,
     * and {@code false} if neither are.
@@ -1325,13 +1336,6 @@ public class NetworkTypeController extends StateMachine {
                ? DataCallResponse.LINK_STATUS_DORMANT : DataCallResponse.LINK_STATUS_ACTIVE;
    }

    private int getDataNetworkType() {
        NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        return nri == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN
                : nri.getAccessNetworkTechnology();
    }

    private String getEventName(int event) {
        try {
            return sEvents[event];