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

Commit 80d279f4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Merge qt-r1-dev-plus-aosp-without-vendor (5817612) into...

Merge "Merge qt-r1-dev-plus-aosp-without-vendor (5817612) into stage-aosp-master" into stage-aosp-master
parents f3dfb26b 19fb419f
Loading
Loading
Loading
Loading
+31 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Handler;
import android.telephony.SubscriptionManager;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent;

@@ -58,8 +59,12 @@ public class CellularNetworkValidator {
    private ValidationCallback mValidationCallback;
    private Context mContext;
    private ConnectivityManager mConnectivityManager;
    private Handler mHandler = new Handler();
    private ConnectivityNetworkCallback mNetworkCallback;
    @VisibleForTesting
    public Handler mHandler = new Handler();
    @VisibleForTesting
    public ConnectivityNetworkCallback mNetworkCallback;
    @VisibleForTesting
    public Runnable mTimeoutCallback;

    /**
     * Callback to pass in when starting validation.
@@ -99,7 +104,8 @@ public class CellularNetworkValidator {
                .validationBeforeSwitchSupported;
    }

    private CellularNetworkValidator(Context context) {
    @VisibleForTesting
    public CellularNetworkValidator(Context context) {
        mContext = context;
        mConnectivityManager = (ConnectivityManager)
                mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -136,8 +142,22 @@ public class CellularNetworkValidator {

        mNetworkCallback = new ConnectivityNetworkCallback(subId);

        mConnectivityManager.requestNetwork(
                mNetworkRequest, mNetworkCallback, mHandler, mTimeoutInMs);
        mConnectivityManager.requestNetwork(mNetworkRequest, mNetworkCallback, mHandler);

        mTimeoutCallback = () -> {
            logd("timeout on subId " + subId + " validation.");
            reportValidationResult(false, subId);
        };

        mHandler.postDelayed(mTimeoutCallback, mTimeoutInMs);
    }

    private void removeTimeoutCallback() {
        // Remove timeout callback.
        if (mTimeoutCallback != null) {
            mHandler.removeCallbacks(mTimeoutCallback);
            mTimeoutCallback = null;
        }
    }

    /**
@@ -150,6 +170,8 @@ public class CellularNetworkValidator {
            mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
            mState = STATE_IDLE;
        }

        removeTimeoutCallback();
        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }

@@ -179,6 +201,8 @@ public class CellularNetworkValidator {
        // If the validation result is not for current subId, do nothing.
        if (mSubId != subId) return;

        removeTimeoutCallback();

        // Deal with the result only when state is still VALIDATING. This is to avoid
        // receiving multiple callbacks in queue.
        if (mState == STATE_VALIDATING) {
@@ -198,7 +222,8 @@ public class CellularNetworkValidator {
        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }

    class ConnectivityNetworkCallback extends ConnectivityManager.NetworkCallback {
    @VisibleForTesting
    public class ConnectivityNetworkCallback extends ConnectivityManager.NetworkCallback {
        private final int mSubId;

        ConnectivityNetworkCallback(int subId) {
+2 −1
Original line number Diff line number Diff line
@@ -245,9 +245,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    public void notifyPhysicalChannelConfiguration(Phone sender,
            List<PhysicalChannelConfig> configs) {
        int subId = sender.getSubId();
        int phoneId = sender.getPhoneId();
        try {
            if (mRegistry != null) {
                mRegistry.notifyPhysicalChannelConfigurationForSubscriber(subId, configs);
                mRegistry.notifyPhysicalChannelConfigurationForSubscriber(phoneId, subId, configs);
            }
        } catch (RemoteException ex) {
            // system process is dead
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class LocaleTracker extends Handler {
    /** Count of invalid cell info we've got so far. Will reset once we get a successful one */
    private int mFailCellInfoCount;

    /** The ISO-3166 code of device's current country */
    /** The ISO-3166 two-letter code of device's current country */
    @Nullable
    private String mCurrentCountryIso;

+1 −1
Original line number Diff line number Diff line
@@ -622,7 +622,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        return Settings.Global.getInt(
                mContext.getContentResolver(),
                Settings.Global.ENABLE_RADIO_BUG_DETECTION,
                0) != 0;
                1) != 0;
    }

    @Override
+47 −6
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhysicalChannelConfig;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -553,6 +554,7 @@ public class ServiceStateTracker extends Handler {
    private String mPrlVersion;
    private boolean mIsMinInfoReady = false;
    private boolean mIsEriTextLoaded = false;
    private String mEriText;
    @UnsupportedAppUsage
    private boolean mIsSubscriptionFromRuim = false;
    private CdmaSubscriptionSourceManager mCdmaSSM;
@@ -1822,7 +1824,7 @@ public class ServiceStateTracker extends Handler {
                 * data roaming status. If TSB58 roaming indicator is not in the
                 * carrier-specified list of ERIs for home system then set roaming.
                 */
                final int dataRat = mNewSS.getRilDataRadioTechnology();
                final int dataRat = getRilDataRadioTechnologyForWwan(mNewSS);
                if (ServiceState.isCdma(dataRat)) {
                    final boolean isVoiceInService =
                            (mNewSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE);
@@ -2636,9 +2638,7 @@ public class ServiceStateTracker extends Handler {
                showPlmn = true;

                // Force display no service
                final boolean forceDisplayNoService = mPhone.getContext().getResources().getBoolean(
                        com.android.internal.R.bool.config_display_no_service_when_sim_unready)
                        && !mIsSimReady;
                final boolean forceDisplayNoService = shouldForceDisplayNoService() && !mIsSimReady;
                if (!forceDisplayNoService && Phone.isEmergencyCallOnly()) {
                    // No service but emergency call allowed
                    plmn = Resources.getSystem().
@@ -2749,6 +2749,28 @@ public class ServiceStateTracker extends Handler {
        log("updateSpnDisplayLegacy-");
    }

    /**
     * Checks whether force to display "no service" to the user based on the current country.
     *
     * This method should only be used when SIM is unready.
     *
     * @return {@code True} if "no service" should be displayed.
     */
    public boolean shouldForceDisplayNoService() {
        String[] countriesWithNoService = mPhone.getContext().getResources().getStringArray(
                com.android.internal.R.array.config_display_no_service_when_sim_unready);
        if (ArrayUtils.isEmpty(countriesWithNoService)) {
            return false;
        }
        String currentCountry = mLocaleTracker.getCurrentCountry();
        for (String country : countriesWithNoService) {
            if (country.equalsIgnoreCase(currentCountry)) {
                return true;
            }
        }
        return false;
    }

    protected void setPowerStateToDesired() {
        if (DBG) {
            String tmpLog = "mDeviceShuttingDown=" + mDeviceShuttingDown +
@@ -3288,9 +3310,17 @@ public class ServiceStateTracker extends Handler {
            setNotification(CS_REJECT_CAUSE_ENABLED);
        }

        if (hasChanged) {
        String eriText = mPhone.getCdmaEriText();
        boolean hasEriChanged = !TextUtils.equals(mEriText, eriText);
        mEriText = eriText;
        // Trigger updateSpnDisplay when
        // 1. Service state is changed.
        // 2. phone type is Cdma or CdmaLte and ERI text has changed.
        if (hasChanged || (!mPhone.isPhoneTypeGsm() && hasEriChanged)) {
            updateSpnDisplay();
        }

        if (hasChanged) {
            tm.setNetworkOperatorNameForPhone(mPhone.getPhoneId(), mSS.getOperatorAlpha());
            String operatorNumeric = mSS.getOperatorNumeric();

@@ -5147,7 +5177,7 @@ public class ServiceStateTracker extends Handler {
        }
        final boolean isDataInService =
                (currentServiceState.getDataRegState() == ServiceState.STATE_IN_SERVICE);
        final int dataRegType = currentServiceState.getRilDataRadioTechnology();
        final int dataRegType = getRilDataRadioTechnologyForWwan(currentServiceState);
        if (isDataInService) {
            if (!currentServiceState.getDataRoaming()) {
                currentServiceState.setDataRoamingType(ServiceState.ROAMING_TYPE_NOT_ROAMING);
@@ -5464,4 +5494,15 @@ public class ServiceStateTracker extends Handler {
        }
        return operatorName;
    }

    @RilRadioTechnology
    private static int getRilDataRadioTechnologyForWwan(ServiceState ss) {
        NetworkRegistrationInfo regInfo = ss.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
        if (regInfo != null) {
            networkType = regInfo.getAccessNetworkTechnology();
        }
        return ServiceState.networkTypeToRilRadioTechnology(networkType);
    }
}
Loading