Loading src/java/com/android/internal/telephony/RatRatcheter.java +48 −29 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.internal.telephony; import android.annotation.NonNull; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -26,6 +27,7 @@ import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.TelephonyManager.NetworkType; import android.util.SparseArray; import android.util.SparseIntArray; Loading Loading @@ -86,23 +88,32 @@ public class RatRatcheter { resetRatFamilyMap(); } private int ratchetRat(int oldRat, int newRat) { private @NetworkType int ratchetRat(@NetworkType int oldNetworkType, @NetworkType int newNetworkType) { int oldRat = ServiceState.networkTypeToRilRadioTechnology(oldNetworkType); int newRat = ServiceState.networkTypeToRilRadioTechnology(newNetworkType); synchronized (mRatFamilyMap) { final SparseIntArray oldFamily = mRatFamilyMap.get(oldRat); if (oldFamily == null) return newRat; if (oldFamily == null) { return newNetworkType; } final SparseIntArray newFamily = mRatFamilyMap.get(newRat); if (newFamily != oldFamily) return newRat; if (newFamily != oldFamily) { return newNetworkType; } // now go with the higher of the two final int oldRatRank = newFamily.get(oldRat, -1); final int newRatRank = newFamily.get(newRat, -1); return (oldRatRank > newRatRank ? oldRat : newRat); return ServiceState.rilRadioTechnologyToNetworkType( oldRatRank > newRatRank ? oldRat : newRat); } } /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */ public void ratchet(ServiceState oldSS, ServiceState newSS, boolean locationChange) { public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS, boolean locationChange) { if (!locationChange && isSameRatFamily(oldSS, newSS)) { updateBandwidths(oldSS.getCellBandwidths(), newSS); } Loading @@ -116,32 +127,30 @@ public class RatRatcheter { boolean newUsingCA = oldSS.isUsingCarrierAggregation() || newSS.isUsingCarrierAggregation() || newSS.getCellBandwidths().length > 1; if (mVoiceRatchetEnabled) { int newVoiceRat = ratchetRat(oldSS.getRilVoiceRadioTechnology(), newSS.getRilVoiceRadioTechnology()); NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null) { nri.setAccessNetworkTechnology( ServiceState.rilRadioTechnologyToNetworkType(newVoiceRat)); newSS.addNetworkRegistrationInfo(nri); } } else if (oldSS.getRilVoiceRadioTechnology() != newSS.getRilVoiceRadioTechnology()) { NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (mVoiceRatchetEnabled) { int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(), newCsNri.getAccessNetworkTechnology()); newCsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newCsNri); } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mVoiceRatchetEnabled = true; } if (mDataRatchetEnabled) { int newDataRat = ratchetRat(oldSS.getRilDataRadioTechnology(), newSS.getRilDataRadioTechnology()); NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null) { nri.setAccessNetworkTechnology( ServiceState.rilRadioTechnologyToNetworkType(newDataRat)); newSS.addNetworkRegistrationInfo(nri); } } else if (oldSS.getRilDataRadioTechnology() != newSS.getRilDataRadioTechnology()) { 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); } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mDataRatchetEnabled = true; } Loading @@ -153,10 +162,20 @@ public class RatRatcheter { synchronized (mRatFamilyMap) { // Either the two technologies are the same or their families must be non-null // and the same. if (ss1.getRilDataRadioTechnology() == ss2.getRilDataRadioTechnology()) return true; if (mRatFamilyMap.get(ss1.getRilDataRadioTechnology()) == null) return false; return mRatFamilyMap.get(ss1.getRilDataRadioTechnology()) == mRatFamilyMap.get(ss2.getRilDataRadioTechnology()); int dataRat1 = ServiceState.networkTypeToRilRadioTechnology( ss1.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getAccessNetworkTechnology()); int dataRat2 = ServiceState.networkTypeToRilRadioTechnology( ss2.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getAccessNetworkTechnology()); if (dataRat1 == dataRat2) return true; if (mRatFamilyMap.get(dataRat1) == null) { return false; } return mRatFamilyMap.get(dataRat1) == mRatFamilyMap.get(dataRat2); } } Loading Loading
src/java/com/android/internal/telephony/RatRatcheter.java +48 −29 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.internal.telephony; import android.annotation.NonNull; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -26,6 +27,7 @@ import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.TelephonyManager.NetworkType; import android.util.SparseArray; import android.util.SparseIntArray; Loading Loading @@ -86,23 +88,32 @@ public class RatRatcheter { resetRatFamilyMap(); } private int ratchetRat(int oldRat, int newRat) { private @NetworkType int ratchetRat(@NetworkType int oldNetworkType, @NetworkType int newNetworkType) { int oldRat = ServiceState.networkTypeToRilRadioTechnology(oldNetworkType); int newRat = ServiceState.networkTypeToRilRadioTechnology(newNetworkType); synchronized (mRatFamilyMap) { final SparseIntArray oldFamily = mRatFamilyMap.get(oldRat); if (oldFamily == null) return newRat; if (oldFamily == null) { return newNetworkType; } final SparseIntArray newFamily = mRatFamilyMap.get(newRat); if (newFamily != oldFamily) return newRat; if (newFamily != oldFamily) { return newNetworkType; } // now go with the higher of the two final int oldRatRank = newFamily.get(oldRat, -1); final int newRatRank = newFamily.get(newRat, -1); return (oldRatRank > newRatRank ? oldRat : newRat); return ServiceState.rilRadioTechnologyToNetworkType( oldRatRank > newRatRank ? oldRat : newRat); } } /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */ public void ratchet(ServiceState oldSS, ServiceState newSS, boolean locationChange) { public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS, boolean locationChange) { if (!locationChange && isSameRatFamily(oldSS, newSS)) { updateBandwidths(oldSS.getCellBandwidths(), newSS); } Loading @@ -116,32 +127,30 @@ public class RatRatcheter { boolean newUsingCA = oldSS.isUsingCarrierAggregation() || newSS.isUsingCarrierAggregation() || newSS.getCellBandwidths().length > 1; if (mVoiceRatchetEnabled) { int newVoiceRat = ratchetRat(oldSS.getRilVoiceRadioTechnology(), newSS.getRilVoiceRadioTechnology()); NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null) { nri.setAccessNetworkTechnology( ServiceState.rilRadioTechnologyToNetworkType(newVoiceRat)); newSS.addNetworkRegistrationInfo(nri); } } else if (oldSS.getRilVoiceRadioTechnology() != newSS.getRilVoiceRadioTechnology()) { NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (mVoiceRatchetEnabled) { int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(), newCsNri.getAccessNetworkTechnology()); newCsNri.setAccessNetworkTechnology(newPsNetworkType); newSS.addNetworkRegistrationInfo(newCsNri); } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mVoiceRatchetEnabled = true; } if (mDataRatchetEnabled) { int newDataRat = ratchetRat(oldSS.getRilDataRadioTechnology(), newSS.getRilDataRadioTechnology()); NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo( NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null) { nri.setAccessNetworkTechnology( ServiceState.rilRadioTechnologyToNetworkType(newDataRat)); newSS.addNetworkRegistrationInfo(nri); } } else if (oldSS.getRilDataRadioTechnology() != newSS.getRilDataRadioTechnology()) { 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); } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) { // resume rat ratchet on following rat change within the same location mDataRatchetEnabled = true; } Loading @@ -153,10 +162,20 @@ public class RatRatcheter { synchronized (mRatFamilyMap) { // Either the two technologies are the same or their families must be non-null // and the same. if (ss1.getRilDataRadioTechnology() == ss2.getRilDataRadioTechnology()) return true; if (mRatFamilyMap.get(ss1.getRilDataRadioTechnology()) == null) return false; return mRatFamilyMap.get(ss1.getRilDataRadioTechnology()) == mRatFamilyMap.get(ss2.getRilDataRadioTechnology()); int dataRat1 = ServiceState.networkTypeToRilRadioTechnology( ss1.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getAccessNetworkTechnology()); int dataRat2 = ServiceState.networkTypeToRilRadioTechnology( ss2.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getAccessNetworkTechnology()); if (dataRat1 == dataRat2) return true; if (mRatFamilyMap.get(dataRat1) == null) { return false; } return mRatFamilyMap.get(dataRat1) == mRatFamilyMap.get(dataRat2); } } Loading