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

Commit 3a26cef1 authored by SongFerngWang's avatar SongFerngWang Committed by SongFerng Wang
Browse files

Reduce the set_allowed_network_type to one time

Android S has three times set_allowed_network_type after bootup.
If those network types are different values, it causes attach
issue in modem.
Reduce set_allowed_network_type to one time, and framework set
allowed network type after carrier config changed.

Bug: 190874388
Bug: 187773531
Test: atest CarrierServiceStateTrackerTest
atest android.telephony.cts.TelephonyCallbackTest
atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason
atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason_moreReason
atest -c com.android.internal.telephony

Change-Id: I17dc6a2953ef8f12c211565813f2953f7e83a472
Merged-In: I17dc6a2953ef8f12c211565813f2953f7e83a472
parent 3601a516
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2900,8 +2900,6 @@ public class GsmCdmaPhone extends Phone {
                break;

            case EVENT_CARRIER_CONFIG_CHANGED:
                // Obtain new radio capabilities from the modem, since some are SIM-dependent
                mCi.getRadioCapability(obtainMessage(EVENT_GET_RADIO_CAPABILITY));
                // Only check for the voice radio tech if it not going to be updated by the voice
                // registration changes.
                if (!mContext.getResources().getBoolean(
@@ -2920,7 +2918,8 @@ public class GsmCdmaPhone extends Phone {

                updateNrSettingsAfterCarrierConfigChanged(b);
                loadAllowedNetworksFromSubscriptionDatabase();
                updateAllowedNetworkTypes(null);
                // Obtain new radio capabilities from the modem, since some are SIM-dependent
                mCi.getRadioCapability(obtainMessage(EVENT_GET_RADIO_CAPABILITY));
                break;

            case EVENT_SET_ROAMING_PREFERENCE_DONE:
+10 −4
Original line number Diff line number Diff line
@@ -451,7 +451,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static final String ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G = "enable_2g";
    private static final int INVALID_ALLOWED_NETWORK_TYPES = -1;
    protected boolean mIsCarrierNrSupported = false;

    protected boolean mIsAllowedNetworkTypesLoadedFromDb = false;
    private boolean mUnitTestMode;

    protected VoiceCallSessionStats mVoiceCallSessionStats;
@@ -2304,6 +2304,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * Loads the allowed network type from subscription database.
     */
    public void loadAllowedNetworksFromSubscriptionDatabase() {
        mIsAllowedNetworkTypesLoadedFromDb = false;
        // Try to load ALLOWED_NETWORK_TYPES from SIMINFO.
        if (SubscriptionController.getInstance() == null) {
            return;
@@ -2343,6 +2344,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                    }
                }
            }
            mIsAllowedNetworkTypesLoadedFromDb = true;
        } catch (NumberFormatException e) {
            Rlog.e(LOG_TAG, "allowedNetworkTypes NumberFormat exception" + e);
        }
@@ -2415,8 +2417,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            loge("setAllowedNetworkTypes: Invalid allowed network type reason: " + reason);
            return;
        }
        if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
            loge("setAllowedNetworkTypes: Invalid subscriptionId: " + subId);
        if (!SubscriptionManager.isUsableSubscriptionId(subId)
                || !mIsAllowedNetworkTypesLoadedFromDb) {
            loge("setAllowedNetworkTypes: no sim or network type is not loaded. SubscriptionId: "
                    + subId + ", isNetworkTypeLoaded" + mIsAllowedNetworkTypesLoadedFromDb);
            return;
        }
        String mapAsString = "";
@@ -4354,7 +4358,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    public void sendSubscriptionSettings(boolean restoreNetworkSelection) {
        // Send settings down
        if (mIsAllowedNetworkTypesLoadedFromDb) {
            updateAllowedNetworkTypes(null);
        }

        if (restoreNetworkSelection) {
            restoreSavedNetworkSelection(null);