Loading src/java/com/android/internal/telephony/RatRatcheter.java +23 −42 Original line number Original line Diff line number Diff line Loading @@ -54,8 +54,6 @@ public class RatRatcheter { private final SparseArray<SparseIntArray> mRatFamilyMap = new SparseArray<>(); private final SparseArray<SparseIntArray> mRatFamilyMap = new SparseArray<>(); private final Phone mPhone; private final Phone mPhone; private boolean mVoiceRatchetEnabled = true; private boolean mDataRatchetEnabled = true; /** /** * Updates the ServiceState with a new set of cell bandwidths IFF the new bandwidth list has a * Updates the ServiceState with a new set of cell bandwidths IFF the new bandwidth list has a Loading Loading @@ -119,52 +117,35 @@ public class RatRatcheter { } } } } /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */ /** public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS, * Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. boolean locationChange) { * // temporarily disable rat ratchet on location change. * Ensure that a device on the same cell reports the best-seen capability to the user. if (locationChange) { */ mVoiceRatchetEnabled = false; public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS) { mDataRatchetEnabled = false; return; } // Different rat family, don't need rat ratchet and update cell bandwidths. // Different rat family, don't need rat ratchet and update cell bandwidths. if (!isSameRatFamily(oldSS, newSS)) { if (!isSameRatFamily(oldSS, newSS)) { Rlog.e(LOG_TAG, "Same cell cannot have different RAT Families. Likely bug."); return; return; } } updateBandwidths(oldSS.getCellBandwidths(), newSS); final int[] domains = { NetworkRegistrationInfo.DOMAIN_CS, NetworkRegistrationInfo.DOMAIN_PS}; for (int domain : domains) { NetworkRegistrationInfo oldNri = oldSS.getNetworkRegistrationInfo( domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo newNri = newSS.getNetworkRegistrationInfo( domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo( int newNetworkType = ratchetRat(oldNri.getAccessNetworkTechnology(), NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); newNri.getAccessNetworkTechnology()); NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo( newNri.setAccessNetworkTechnology(newNetworkType); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (oldNri.isUsingCarrierAggregation()) newNri.setIsUsingCarrierAggregation(true); if (mVoiceRatchetEnabled) { newSS.addNetworkRegistrationInfo(newNri); int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(), newCsNri.getAccessNetworkTechnology()); newCsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newCsNri); if (oldCsNri.isUsingCarrierAggregation()) newCsNri.setIsUsingCarrierAggregation(true); } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mVoiceRatchetEnabled = true; } NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo newPsNri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (mDataRatchetEnabled) { int newPsNetworkType = ratchetRat(oldPsNri.getAccessNetworkTechnology(), newPsNri.getAccessNetworkTechnology()); newPsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newPsNri); if (oldPsNri.isUsingCarrierAggregation()) newPsNri.setIsUsingCarrierAggregation(true); } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mDataRatchetEnabled = true; } } // Ratchet Cell Bandwidths updateBandwidths(oldSS.getCellBandwidths(), newSS); } } private boolean isSameRatFamily(ServiceState ss1, ServiceState ss2) { private boolean isSameRatFamily(ServiceState ss1, ServiceState ss2) { Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +9 −6 Original line number Original line Diff line number Diff line Loading @@ -3292,12 +3292,15 @@ public class ServiceStateTracker extends Handler { boolean hasLocationChanged = mCellIdentity == null boolean hasLocationChanged = mCellIdentity == null ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity); ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity); // ratchet the new tech up through its rat family but don't drop back down boolean isRegisteredOnWwan = false; // until cell change or device is OOS for (NetworkRegistrationInfo nri : mNewSS.getNetworkRegistrationInfoListForTransportType( boolean isDataInService = mNewSS.getDataRegistrationState() AccessNetworkConstants.TRANSPORT_TYPE_WWAN)) { == ServiceState.STATE_IN_SERVICE; isRegisteredOnWwan |= nri.isRegistered(); if (isDataInService) { } mRatRatcheter.ratchet(mSS, mNewSS, hasLocationChanged); // Ratchet if the device is in service on the same cell if (isRegisteredOnWwan && !hasLocationChanged) { mRatRatcheter.ratchet(mSS, mNewSS); } } boolean hasRilVoiceRadioTechnologyChanged = boolean hasRilVoiceRadioTechnologyChanged = Loading tests/telephonytests/src/com/android/internal/telephony/RatRatcheterTest.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -140,7 +140,7 @@ public class RatRatcheterTest extends TelephonyTest { setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); ratRatcheter.ratchet(oldSS, newSS, false); ratRatcheter.ratchet(oldSS, newSS); assertTrue(newSS.isUsingCarrierAggregation()); assertTrue(newSS.isUsingCarrierAggregation()); } } Loading @@ -157,7 +157,7 @@ public class RatRatcheterTest extends TelephonyTest { setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); ratRatcheter.ratchet(oldSS, newSS, false); ratRatcheter.ratchet(oldSS, newSS); assertFalse(newSS.isUsingCarrierAggregation()); assertFalse(newSS.isUsingCarrierAggregation()); } } Loading tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +0 −24 Original line number Original line Diff line number Diff line Loading @@ -2024,30 +2024,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { } } // TODO(nharold): This actually seems like broken behavior; rather than preserve it, we should // probably remove it. // GSM, Edge, GPRS are grouped under the same family where Edge > GPRS > GSM. // Expect no rat update from E to G immediately following cell id change. // Expect ratratchet (from G to E) for the following rat update within the cell location. @Test public void testRatRatchetWithCellChangeBeforeRatChange() throws Exception { // cell ID update CellIdentityGsm cellIdentity = new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList()); changeRegState(1, cellIdentity, 16, 2); assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState()); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology()); // RAT: EDGE -> GPRS, cell ID unchanged. Expect no rat ratchet following cell Id change. changeRegState(1, cellIdentity, 16, 1); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, sst.mSS.getRilDataRadioTechnology()); // RAT: GPRS -> EDGE should ratchet. changeRegState(1, cellIdentity, 16, 2); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology()); } private void sendPhyChanConfigChange(int[] bandwidths) { private void sendPhyChanConfigChange(int[] bandwidths) { ArrayList<PhysicalChannelConfig> pc = new ArrayList<>(); ArrayList<PhysicalChannelConfig> pc = new ArrayList<>(); int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING; int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING; Loading Loading
src/java/com/android/internal/telephony/RatRatcheter.java +23 −42 Original line number Original line Diff line number Diff line Loading @@ -54,8 +54,6 @@ public class RatRatcheter { private final SparseArray<SparseIntArray> mRatFamilyMap = new SparseArray<>(); private final SparseArray<SparseIntArray> mRatFamilyMap = new SparseArray<>(); private final Phone mPhone; private final Phone mPhone; private boolean mVoiceRatchetEnabled = true; private boolean mDataRatchetEnabled = true; /** /** * Updates the ServiceState with a new set of cell bandwidths IFF the new bandwidth list has a * Updates the ServiceState with a new set of cell bandwidths IFF the new bandwidth list has a Loading Loading @@ -119,52 +117,35 @@ public class RatRatcheter { } } } } /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */ /** public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS, * Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. boolean locationChange) { * // temporarily disable rat ratchet on location change. * Ensure that a device on the same cell reports the best-seen capability to the user. if (locationChange) { */ mVoiceRatchetEnabled = false; public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS) { mDataRatchetEnabled = false; return; } // Different rat family, don't need rat ratchet and update cell bandwidths. // Different rat family, don't need rat ratchet and update cell bandwidths. if (!isSameRatFamily(oldSS, newSS)) { if (!isSameRatFamily(oldSS, newSS)) { Rlog.e(LOG_TAG, "Same cell cannot have different RAT Families. Likely bug."); return; return; } } updateBandwidths(oldSS.getCellBandwidths(), newSS); final int[] domains = { NetworkRegistrationInfo.DOMAIN_CS, NetworkRegistrationInfo.DOMAIN_PS}; for (int domain : domains) { NetworkRegistrationInfo oldNri = oldSS.getNetworkRegistrationInfo( domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo newNri = newSS.getNetworkRegistrationInfo( domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo( int newNetworkType = ratchetRat(oldNri.getAccessNetworkTechnology(), NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); newNri.getAccessNetworkTechnology()); NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo( newNri.setAccessNetworkTechnology(newNetworkType); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (oldNri.isUsingCarrierAggregation()) newNri.setIsUsingCarrierAggregation(true); if (mVoiceRatchetEnabled) { newSS.addNetworkRegistrationInfo(newNri); int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(), newCsNri.getAccessNetworkTechnology()); newCsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newCsNri); if (oldCsNri.isUsingCarrierAggregation()) newCsNri.setIsUsingCarrierAggregation(true); } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mVoiceRatchetEnabled = true; } NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo newPsNri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (mDataRatchetEnabled) { int newPsNetworkType = ratchetRat(oldPsNri.getAccessNetworkTechnology(), newPsNri.getAccessNetworkTechnology()); newPsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newPsNri); if (oldPsNri.isUsingCarrierAggregation()) newPsNri.setIsUsingCarrierAggregation(true); } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mDataRatchetEnabled = true; } } // Ratchet Cell Bandwidths updateBandwidths(oldSS.getCellBandwidths(), newSS); } } private boolean isSameRatFamily(ServiceState ss1, ServiceState ss2) { private boolean isSameRatFamily(ServiceState ss1, ServiceState ss2) { Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +9 −6 Original line number Original line Diff line number Diff line Loading @@ -3292,12 +3292,15 @@ public class ServiceStateTracker extends Handler { boolean hasLocationChanged = mCellIdentity == null boolean hasLocationChanged = mCellIdentity == null ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity); ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity); // ratchet the new tech up through its rat family but don't drop back down boolean isRegisteredOnWwan = false; // until cell change or device is OOS for (NetworkRegistrationInfo nri : mNewSS.getNetworkRegistrationInfoListForTransportType( boolean isDataInService = mNewSS.getDataRegistrationState() AccessNetworkConstants.TRANSPORT_TYPE_WWAN)) { == ServiceState.STATE_IN_SERVICE; isRegisteredOnWwan |= nri.isRegistered(); if (isDataInService) { } mRatRatcheter.ratchet(mSS, mNewSS, hasLocationChanged); // Ratchet if the device is in service on the same cell if (isRegisteredOnWwan && !hasLocationChanged) { mRatRatcheter.ratchet(mSS, mNewSS); } } boolean hasRilVoiceRadioTechnologyChanged = boolean hasRilVoiceRadioTechnologyChanged = Loading
tests/telephonytests/src/com/android/internal/telephony/RatRatcheterTest.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -140,7 +140,7 @@ public class RatRatcheterTest extends TelephonyTest { setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); ratRatcheter.ratchet(oldSS, newSS, false); ratRatcheter.ratchet(oldSS, newSS); assertTrue(newSS.isUsingCarrierAggregation()); assertTrue(newSS.isUsingCarrierAggregation()); } } Loading @@ -157,7 +157,7 @@ public class RatRatcheterTest extends TelephonyTest { setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); RatRatcheter ratRatcheter = new RatRatcheter(mPhone); ratRatcheter.ratchet(oldSS, newSS, false); ratRatcheter.ratchet(oldSS, newSS); assertFalse(newSS.isUsingCarrierAggregation()); assertFalse(newSS.isUsingCarrierAggregation()); } } Loading
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +0 −24 Original line number Original line Diff line number Diff line Loading @@ -2024,30 +2024,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { } } // TODO(nharold): This actually seems like broken behavior; rather than preserve it, we should // probably remove it. // GSM, Edge, GPRS are grouped under the same family where Edge > GPRS > GSM. // Expect no rat update from E to G immediately following cell id change. // Expect ratratchet (from G to E) for the following rat update within the cell location. @Test public void testRatRatchetWithCellChangeBeforeRatChange() throws Exception { // cell ID update CellIdentityGsm cellIdentity = new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList()); changeRegState(1, cellIdentity, 16, 2); assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState()); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology()); // RAT: EDGE -> GPRS, cell ID unchanged. Expect no rat ratchet following cell Id change. changeRegState(1, cellIdentity, 16, 1); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, sst.mSS.getRilDataRadioTechnology()); // RAT: GPRS -> EDGE should ratchet. changeRegState(1, cellIdentity, 16, 2); assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology()); } private void sendPhyChanConfigChange(int[] bandwidths) { private void sendPhyChanConfigChange(int[] bandwidths) { ArrayList<PhysicalChannelConfig> pc = new ArrayList<>(); ArrayList<PhysicalChannelConfig> pc = new ArrayList<>(); int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING; int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING; Loading