Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +4 −0 Original line number Diff line number Diff line Loading @@ -905,6 +905,10 @@ public class PhoneSwitcher extends Handler { return mPreferredDataSubId; } public int getPreferredDataPhoneId() { return mPreferredDataPhoneId; } private void log(String l) { Rlog.d(LOG_TAG, l); mLocalLog.log(l); Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +37 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.internal.telephony.dataconnection; 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_INVALID; Loading Loading @@ -93,6 +96,7 @@ import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.PhoneSwitcher; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.SettingsObserver; import com.android.internal.telephony.TelephonyIntents; Loading Loading @@ -580,7 +584,7 @@ public class DcTracker extends Handler { // When false we will not auto attach and manually attaching is required. private boolean mAutoAttachOnCreationConfig = false; private AtomicBoolean mAutoAttachOnCreation = new AtomicBoolean(false); private AtomicBoolean mAutoAttachEnabled = new AtomicBoolean(false); // State of screen // (TODO: Reconsider tying directly to screen, maybe this is Loading Loading @@ -704,7 +708,7 @@ public class DcTracker extends Handler { mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone); 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.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); Loading Loading @@ -1202,7 +1206,7 @@ public class DcTracker extends Handler { mPhone.notifyDataConnection(); } if (mAutoAttachOnCreationConfig) { mAutoAttachOnCreation.set(true); mAutoAttachEnabled.set(true); } setupDataOnConnectableApns(Phone.REASON_DATA_ATTACHED, RetryFailures.ALWAYS); } Loading Loading @@ -1301,7 +1305,7 @@ public class DcTracker extends Handler { reasons.add(DataDisallowedReasonType.IN_ECBM); } if (!(attachedState || mAutoAttachOnCreation.get())) { if (!(attachedState || mAutoAttachEnabled.get())) { reasons.add(DataDisallowedReasonType.NOT_ATTACHED); } if (!recordsLoaded) { Loading Loading @@ -2176,8 +2180,8 @@ public class DcTracker extends Handler { } } public boolean getAutoAttachOnCreation() { return mAutoAttachOnCreation.get(); public boolean getAutoAttachEnabled() { return mAutoAttachEnabled.get(); } private void onRecordsLoadedOrSubIdChanged() { Loading @@ -2199,7 +2203,7 @@ public class DcTracker extends Handler { mAllApnSettings.clear(); mAutoAttachOnCreationConfig = false; // 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( SubscriptionManager.INVALID_SUBSCRIPTION_ID); // In no-sim case, we should still send the emergency APN to the modem, if there is any. Loading Loading @@ -2663,7 +2667,7 @@ public class DcTracker extends Handler { mReregisterOnReconnectFailure = false; // Clear auto attach as modem is expected to do a new attach mAutoAttachOnCreation.set(false); mAutoAttachEnabled.set(false); if (mPhone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator Loading Loading @@ -3872,11 +3876,34 @@ public class DcTracker extends Handler { log("update(): Active DDS, register for all events now!"); onUpdateIcc(); mAutoAttachOnCreation.set(false); updateAutoAttachOnCreation(); 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() { sEnableFailFastRefCounter = 0; mFailFast = false; Loading Loading @@ -3957,7 +3984,7 @@ public class DcTracker extends Handler { pw.println(" mNoRecvPollCount=" + mNoRecvPollCount); pw.println(" mResolver=" + mResolver); pw.println(" mReconnectIntent=" + mReconnectIntent); pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation.get()); pw.println(" mAutoAttachEnabled=" + mAutoAttachEnabled.get()); pw.println(" mIsScreenOn=" + mIsScreenOn); pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator); pw.println(" mDataServiceBound=" + mDataServiceBound); Loading src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java +6 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,12 @@ public class TelephonyNetworkFactory extends NetworkFactory { // apply or revoke requests if our active-ness changes 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()) { NetworkRequest networkRequest = entry.getKey(); boolean applied = entry.getValue() != TransportType.INVALID; Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -878,10 +878,10 @@ public class DcTrackerTest extends TelephonyTest { verifyDataConnected(FAKE_APN1); assertTrue(mDct.getAutoAttachOnCreation()); assertTrue(mDct.getAutoAttachEnabled()); mDct.update(); // The auto attach flag should be reset after update assertFalse(mDct.getAutoAttachOnCreation()); assertFalse(mDct.getAutoAttachEnabled()); verify(mSST, times(1)).registerForDataConnectionDetached(eq(TransportType.WWAN), eq(mDct), intArgumentCaptor.capture(), eq(null)); Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +4 −0 Original line number Diff line number Diff line Loading @@ -905,6 +905,10 @@ public class PhoneSwitcher extends Handler { return mPreferredDataSubId; } public int getPreferredDataPhoneId() { return mPreferredDataPhoneId; } private void log(String l) { Rlog.d(LOG_TAG, l); mLocalLog.log(l); Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +37 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ package com.android.internal.telephony.dataconnection; 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_INVALID; Loading Loading @@ -93,6 +96,7 @@ import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.PhoneSwitcher; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.SettingsObserver; import com.android.internal.telephony.TelephonyIntents; Loading Loading @@ -580,7 +584,7 @@ public class DcTracker extends Handler { // When false we will not auto attach and manually attaching is required. private boolean mAutoAttachOnCreationConfig = false; private AtomicBoolean mAutoAttachOnCreation = new AtomicBoolean(false); private AtomicBoolean mAutoAttachEnabled = new AtomicBoolean(false); // State of screen // (TODO: Reconsider tying directly to screen, maybe this is Loading Loading @@ -704,7 +708,7 @@ public class DcTracker extends Handler { mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone); 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.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); Loading Loading @@ -1202,7 +1206,7 @@ public class DcTracker extends Handler { mPhone.notifyDataConnection(); } if (mAutoAttachOnCreationConfig) { mAutoAttachOnCreation.set(true); mAutoAttachEnabled.set(true); } setupDataOnConnectableApns(Phone.REASON_DATA_ATTACHED, RetryFailures.ALWAYS); } Loading Loading @@ -1301,7 +1305,7 @@ public class DcTracker extends Handler { reasons.add(DataDisallowedReasonType.IN_ECBM); } if (!(attachedState || mAutoAttachOnCreation.get())) { if (!(attachedState || mAutoAttachEnabled.get())) { reasons.add(DataDisallowedReasonType.NOT_ATTACHED); } if (!recordsLoaded) { Loading Loading @@ -2176,8 +2180,8 @@ public class DcTracker extends Handler { } } public boolean getAutoAttachOnCreation() { return mAutoAttachOnCreation.get(); public boolean getAutoAttachEnabled() { return mAutoAttachEnabled.get(); } private void onRecordsLoadedOrSubIdChanged() { Loading @@ -2199,7 +2203,7 @@ public class DcTracker extends Handler { mAllApnSettings.clear(); mAutoAttachOnCreationConfig = false; // 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( SubscriptionManager.INVALID_SUBSCRIPTION_ID); // In no-sim case, we should still send the emergency APN to the modem, if there is any. Loading Loading @@ -2663,7 +2667,7 @@ public class DcTracker extends Handler { mReregisterOnReconnectFailure = false; // Clear auto attach as modem is expected to do a new attach mAutoAttachOnCreation.set(false); mAutoAttachEnabled.set(false); if (mPhone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator Loading Loading @@ -3872,11 +3876,34 @@ public class DcTracker extends Handler { log("update(): Active DDS, register for all events now!"); onUpdateIcc(); mAutoAttachOnCreation.set(false); updateAutoAttachOnCreation(); 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() { sEnableFailFastRefCounter = 0; mFailFast = false; Loading Loading @@ -3957,7 +3984,7 @@ public class DcTracker extends Handler { pw.println(" mNoRecvPollCount=" + mNoRecvPollCount); pw.println(" mResolver=" + mResolver); pw.println(" mReconnectIntent=" + mReconnectIntent); pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation.get()); pw.println(" mAutoAttachEnabled=" + mAutoAttachEnabled.get()); pw.println(" mIsScreenOn=" + mIsScreenOn); pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator); pw.println(" mDataServiceBound=" + mDataServiceBound); Loading
src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java +6 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,12 @@ public class TelephonyNetworkFactory extends NetworkFactory { // apply or revoke requests if our active-ness changes 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()) { NetworkRequest networkRequest = entry.getKey(); boolean applied = entry.getValue() != TransportType.INVALID; Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -878,10 +878,10 @@ public class DcTrackerTest extends TelephonyTest { verifyDataConnected(FAKE_APN1); assertTrue(mDct.getAutoAttachOnCreation()); assertTrue(mDct.getAutoAttachEnabled()); mDct.update(); // The auto attach flag should be reset after update assertFalse(mDct.getAutoAttachOnCreation()); assertFalse(mDct.getAutoAttachEnabled()); verify(mSST, times(1)).registerForDataConnectionDetached(eq(TransportType.WWAN), eq(mDct), intArgumentCaptor.capture(), eq(null)); Loading