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

Commit 3955c226 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5321987 from b76a2518 to qt-release

Change-Id: I02809edfd1fde1e5ec662ff9612cfd9ba9ea5595
parents ac2dd020 b76a2518
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -598,6 +598,7 @@ public class PhoneSwitcher extends Handler {
                    activate(phoneId);
                    activate(phoneId);
                }
                }
            }
            }

            // Notify all registrants.
            // Notify all registrants.
            mActivePhoneRegistrants.notifyRegistrants();
            mActivePhoneRegistrants.notifyRegistrants();
        }
        }
@@ -911,6 +912,10 @@ public class PhoneSwitcher extends Handler {
        return mPreferredDataSubId;
        return mPreferredDataSubId;
    }
    }


    public int getPreferredDataPhoneId() {
        return mPreferredDataPhoneId;
    }

    private void log(String l) {
    private void log(String l) {
        Rlog.d(LOG_TAG, l);
        Rlog.d(LOG_TAG, l);
        mLocalLog.log(l);
        mLocalLog.log(l);
+37 −10
Original line number Original line Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.internal.telephony.dataconnection;
package com.android.internal.telephony.dataconnection;


import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE;
import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE;
import static android.telephony.TelephonyManager.NETWORK_TYPE_LTE;
import static android.telephony.TelephonyManager.NETWORK_TYPE_LTE_CA;
import static android.telephony.TelephonyManager.NETWORK_TYPE_NR;


import static com.android.internal.telephony.RILConstants.DATA_PROFILE_DEFAULT;
import static com.android.internal.telephony.RILConstants.DATA_PROFILE_DEFAULT;
import static com.android.internal.telephony.RILConstants.DATA_PROFILE_INVALID;
import static com.android.internal.telephony.RILConstants.DATA_PROFILE_INVALID;
@@ -91,6 +94,7 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneSwitcher;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.SettingsObserver;
import com.android.internal.telephony.SettingsObserver;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyIntents;
@@ -559,7 +563,7 @@ public class DcTracker extends Handler {


    // When false we will not auto attach and manually attaching is required.
    // When false we will not auto attach and manually attaching is required.
    private boolean mAutoAttachOnCreationConfig = false;
    private boolean mAutoAttachOnCreationConfig = false;
    private AtomicBoolean mAutoAttachOnCreation = new AtomicBoolean(false);
    private AtomicBoolean mAutoAttachEnabled = new AtomicBoolean(false);


    // State of screen
    // State of screen
    // (TODO: Reconsider tying directly to screen, maybe this is
    // (TODO: Reconsider tying directly to screen, maybe this is
@@ -683,7 +687,7 @@ public class DcTracker extends Handler {
        mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);
        mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);


        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
        mAutoAttachOnCreation.set(sp.getBoolean(Phone.DATA_DISABLED_ON_BOOT_KEY, false));
        mAutoAttachEnabled.set(sp.getBoolean(Phone.DATA_DISABLED_ON_BOOT_KEY, false));


        mSubscriptionManager = SubscriptionManager.from(mPhone.getContext());
        mSubscriptionManager = SubscriptionManager.from(mPhone.getContext());
        mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
        mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
@@ -1180,7 +1184,7 @@ public class DcTracker extends Handler {
            notifyOffApnsOfAvailability();
            notifyOffApnsOfAvailability();
        }
        }
        if (mAutoAttachOnCreationConfig) {
        if (mAutoAttachOnCreationConfig) {
            mAutoAttachOnCreation.set(true);
            mAutoAttachEnabled.set(true);
        }
        }
        setupDataOnConnectableApns(Phone.REASON_DATA_ATTACHED, RetryFailures.ALWAYS);
        setupDataOnConnectableApns(Phone.REASON_DATA_ATTACHED, RetryFailures.ALWAYS);
    }
    }
@@ -1279,7 +1283,7 @@ public class DcTracker extends Handler {
            reasons.add(DataDisallowedReasonType.IN_ECBM);
            reasons.add(DataDisallowedReasonType.IN_ECBM);
        }
        }


        if (!(attachedState || mAutoAttachOnCreation.get())) {
        if (!(attachedState || mAutoAttachEnabled.get())) {
            reasons.add(DataDisallowedReasonType.NOT_ATTACHED);
            reasons.add(DataDisallowedReasonType.NOT_ATTACHED);
        }
        }
        if (!recordsLoaded) {
        if (!recordsLoaded) {
@@ -2174,8 +2178,8 @@ public class DcTracker extends Handler {
        }
        }
    }
    }


    public boolean getAutoAttachOnCreation() {
    public boolean getAutoAttachEnabled() {
        return mAutoAttachOnCreation.get();
        return mAutoAttachEnabled.get();
    }
    }


    private void onRecordsLoadedOrSubIdChanged() {
    private void onRecordsLoadedOrSubIdChanged() {
@@ -2200,7 +2204,7 @@ public class DcTracker extends Handler {
        mAllApnSettings.clear();
        mAllApnSettings.clear();
        mAutoAttachOnCreationConfig = false;
        mAutoAttachOnCreationConfig = false;
        // Clear auto attach as modem is expected to do a new attach once SIM is ready
        // Clear auto attach as modem is expected to do a new attach once SIM is ready
        mAutoAttachOnCreation.set(false);
        mAutoAttachEnabled.set(false);
        mOnSubscriptionsChangedListener.mPreviousSubId.set(
        mOnSubscriptionsChangedListener.mPreviousSubId.set(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        // In no-sim case, we should still send the emergency APN to the modem, if there is any.
        // In no-sim case, we should still send the emergency APN to the modem, if there is any.
@@ -2672,7 +2676,7 @@ public class DcTracker extends Handler {
        mReregisterOnReconnectFailure = false;
        mReregisterOnReconnectFailure = false;


        // Clear auto attach as modem is expected to do a new attach
        // Clear auto attach as modem is expected to do a new attach
        mAutoAttachOnCreation.set(false);
        mAutoAttachEnabled.set(false);


        if (mPhone.getSimulatedRadioControl() != null) {
        if (mPhone.getSimulatedRadioControl() != null) {
            // Assume data is connected on the simulator
            // Assume data is connected on the simulator
@@ -3890,11 +3894,34 @@ public class DcTracker extends Handler {
        log("update(): Active DDS, register for all events now!");
        log("update(): Active DDS, register for all events now!");
        onUpdateIcc();
        onUpdateIcc();


        mAutoAttachOnCreation.set(false);
        updateAutoAttachOnCreation();


        mPhone.updateCurrentCarrierInProvider();
        mPhone.updateCurrentCarrierInProvider();
    }
    }


    /**
     * For non DDS phone, mAutoAttachEnabled should be true because it may be detached
     * automatically from network only because it's idle for too long. In this case, we should
     * try setting up data call even if it's not attached for 2G or 3G networks. And doing so will
     * trigger PS attach if possible.
     */
    public void updateAutoAttachOnCreation() {
        PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance();
        ServiceState serviceState = mPhone.getServiceState();
        if (PhoneSwitcher.getInstance() == null || serviceState == null) {
            mAutoAttachEnabled.set(false);
            return;
        }

        // If it's non DDS phone, and voice is registered on 2G or 3G network, we set
        // mAutoAttachEnabled to true.
        mAutoAttachEnabled.set(mPhone.getPhoneId() != phoneSwitcher.getPreferredDataPhoneId()
                && serviceState.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_LTE
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_LTE_CA
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_NR);
    }

    private void notifyAllDataDisconnected() {
    private void notifyAllDataDisconnected() {
        sEnableFailFastRefCounter = 0;
        sEnableFailFastRefCounter = 0;
        mFailFast = false;
        mFailFast = false;
@@ -3975,7 +4002,7 @@ public class DcTracker extends Handler {
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mResolver=" + mResolver);
        pw.println(" mResolver=" + mResolver);
        pw.println(" mReconnectIntent=" + mReconnectIntent);
        pw.println(" mReconnectIntent=" + mReconnectIntent);
        pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation.get());
        pw.println(" mAutoAttachEnabled=" + mAutoAttachEnabled.get());
        pw.println(" mIsScreenOn=" + mIsScreenOn);
        pw.println(" mIsScreenOn=" + mIsScreenOn);
        pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator);
        pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator);
        pw.println(" mDataServiceBound=" + mDataServiceBound);
        pw.println(" mDataServiceBound=" + mDataServiceBound);
+6 −0
Original line number Original line Diff line number Diff line
@@ -219,6 +219,12 @@ public class TelephonyNetworkFactory extends NetworkFactory {


    // apply or revoke requests if our active-ness changes
    // apply or revoke requests if our active-ness changes
    private void onActivePhoneSwitch() {
    private void onActivePhoneSwitch() {
        // For non DDS phone, mAutoAttachOnCreation should be true because it may be detached
        // automatically from network only because it's idle for too long. In this case, we should
        // try setting up data call even if it's not attached. And doing so will trigger PS attach
        // if possible.
        mPhone.getDcTracker(TransportType.WWAN).updateAutoAttachOnCreation();

        for (HashMap.Entry<NetworkRequest, Integer> entry : mNetworkRequests.entrySet()) {
        for (HashMap.Entry<NetworkRequest, Integer> entry : mNetworkRequests.entrySet()) {
            NetworkRequest networkRequest = entry.getKey();
            NetworkRequest networkRequest = entry.getKey();
            boolean applied = entry.getValue() != TransportType.INVALID;
            boolean applied = entry.getValue() != TransportType.INVALID;
+4 −2
Original line number Original line Diff line number Diff line
@@ -868,10 +868,10 @@ public class DcTrackerTest extends TelephonyTest {


        verifyDataConnected(FAKE_APN1);
        verifyDataConnected(FAKE_APN1);


        assertTrue(mDct.getAutoAttachOnCreation());
        assertTrue(mDct.getAutoAttachEnabled());
        mDct.update();
        mDct.update();
        // The auto attach flag should be reset after update
        // The auto attach flag should be reset after update
        assertFalse(mDct.getAutoAttachOnCreation());
        assertFalse(mDct.getAutoAttachEnabled());


        verify(mSST, times(1)).registerForDataConnectionDetached(eq(mDct),
        verify(mSST, times(1)).registerForDataConnectionDetached(eq(mDct),
                intArgumentCaptor.capture(), eq(null));
                intArgumentCaptor.capture(), eq(null));
@@ -1467,6 +1467,7 @@ public class DcTrackerTest extends TelephonyTest {
        verify(mSimulatedCommandsVerifier, times(0)).getDataCallList(any(Message.class));
        verify(mSimulatedCommandsVerifier, times(0)).getDataCallList(any(Message.class));
    }
    }


    @FlakyTest
    @Test
    @Test
    @SmallTest
    @SmallTest
    public void testNetworkStatusChangedRecoveryON() throws Exception {
    public void testNetworkStatusChangedRecoveryON() throws Exception {
@@ -1511,6 +1512,7 @@ public class DcTrackerTest extends TelephonyTest {
        waitForMs(200);
        waitForMs(200);
    }
    }


    @FlakyTest
    @Test
    @Test
    @SmallTest
    @SmallTest
    public void testRecoveryStepPDPReset() throws Exception {
    public void testRecoveryStepPDPReset() throws Exception {