Loading src/java/com/android/internal/telephony/RIL.java +59 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ import android.service.carrier.CarrierIdentifier; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthNr; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; import android.telephony.ModemActivityInfo; Loading @@ -82,6 +88,7 @@ import android.telephony.RadioAccessFamily; import android.telephony.RadioAccessSpecifier; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyHistogram; import android.telephony.TelephonyManager; Loading Loading @@ -5853,6 +5860,58 @@ public class RIL extends BaseCommands implements CommandsInterface { return response; } /** * Fixup for SignalStrength 1.0 to Assume GSM to WCDMA when * The current RAT type is one of the UMTS RATs. * @param signalStrength the initial signal strength * @return a new SignalStrength if RAT is UMTS or existing SignalStrength */ public SignalStrength fixupSignalStrength10(SignalStrength signalStrength) { List<CellSignalStrengthGsm> gsmList = signalStrength.getCellSignalStrengths( CellSignalStrengthGsm.class); // If GSM is not the primary type, then bail out; no fixup needed. if (gsmList == null || gsmList.get(0) == null || !gsmList.get(0).isValid()) { return signalStrength; } CellSignalStrengthGsm gsmStrength = gsmList.get(0); // Use the voice RAT which is a guarantee in GSM and UMTS int voiceRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { voiceRat = ss.getRilVoiceRadioTechnology(); } } switch (voiceRat) { case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: /* fallthrough */ break; default: // If we are not currently on WCDMA/HSPA, then we don't need to do a fixup. return signalStrength; } // The service state reports WCDMA, and the SignalStrength is reported for GSM, so at this // point we take an educated guess that the GSM SignalStrength report is actually for // WCDMA. Also, if we are in WCDMA/GSM we can safely assume that there are no other valid // signal strength reports (no SRLTE, which is the only supported case in HAL 1.0). // Thus, we just construct a new SignalStrength and migrate RSSI and BER from the // GSM report to the WCDMA report, leaving everything else empty. return new SignalStrength( new CellSignalStrengthCdma(), new CellSignalStrengthGsm(), new CellSignalStrengthWcdma(gsmStrength.getRssi(), gsmStrength.getBitErrorRate(), CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE), new CellSignalStrengthTdscdma(), new CellSignalStrengthLte(), new CellSignalStrengthNr()); } /** * Convert CellInfo defined in 1.4/types.hal to CellInfo type. * @param records List of CellInfo defined in 1.4/types.hal. Loading src/java/com/android/internal/telephony/RadioIndication.java +3 −1 Original line number Diff line number Diff line Loading @@ -229,7 +229,9 @@ public class RadioIndication extends IRadioIndication.Stub { android.hardware.radio.V1_0.SignalStrength signalStrength) { mRil.processIndication(indicationType); SignalStrength ss = new SignalStrength(signalStrength); SignalStrength ssInitial = new SignalStrength(signalStrength); SignalStrength ss = mRil.fixupSignalStrength10(ssInitial); // Note this is set to "verbose" because it happens frequently if (RIL.RILJ_LOGV) mRil.unsljLogvRet(RIL_UNSOL_SIGNAL_STRENGTH, ss); Loading tests/telephonytests/src/com/android/internal/telephony/RILTest.java +32 −2 Original line number Diff line number Diff line Loading @@ -129,8 +129,11 @@ import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthNr; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; Loading @@ -147,7 +150,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -284,7 +286,6 @@ public class RILTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp(RILTest.class.getSimpleName()); MockitoAnnotations.initMocks(this); mTestHandler = new RILTestHandler(getClass().getSimpleName()); mTestHandler.start(); waitUntilReady(); Loading Loading @@ -1837,6 +1838,35 @@ public class RILTest extends TelephonyTest { assertEquals(MTU, dpi.mtu); } @Test public void testFixupSignalStrength10() { final int gsmWcdmaRssiDbm = -65; // Test the positive case where rat=UMTS and SignalStrength=GSM doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS) .when(mServiceState).getRilVoiceRadioTechnology(); SignalStrength gsmSignalStrength = new SignalStrength( new CellSignalStrengthCdma(), new CellSignalStrengthGsm(gsmWcdmaRssiDbm, 1, CellInfo.UNAVAILABLE), new CellSignalStrengthWcdma(), new CellSignalStrengthTdscdma(), new CellSignalStrengthLte(), new CellSignalStrengthNr()); SignalStrength result = mRILUnderTest.fixupSignalStrength10(gsmSignalStrength); assertTrue(result.getCellSignalStrengths(CellSignalStrengthGsm.class).isEmpty()); assertFalse(result.getCellSignalStrengths(CellSignalStrengthWcdma.class).isEmpty()); // Even though the dBm values are equal, the above checks ensure that the value has // been migrated to WCDMA (with no change in the top-level getDbm() result). assertEquals(result.getDbm(), gsmSignalStrength.getDbm()); // Test the no-op case where rat=GSM and SignalStrength=GSM doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_GSM) .when(mServiceState).getRilVoiceRadioTechnology(); result = mRILUnderTest.fixupSignalStrength10(gsmSignalStrength); assertEquals(result, gsmSignalStrength); } @Test public void testCreateCarrierRestrictionList() { ArrayList<CarrierIdentifier> carriers = new ArrayList<>(); Loading Loading
src/java/com/android/internal/telephony/RIL.java +59 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ import android.service.carrier.CarrierIdentifier; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthNr; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; import android.telephony.ModemActivityInfo; Loading @@ -82,6 +88,7 @@ import android.telephony.RadioAccessFamily; import android.telephony.RadioAccessSpecifier; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyHistogram; import android.telephony.TelephonyManager; Loading Loading @@ -5853,6 +5860,58 @@ public class RIL extends BaseCommands implements CommandsInterface { return response; } /** * Fixup for SignalStrength 1.0 to Assume GSM to WCDMA when * The current RAT type is one of the UMTS RATs. * @param signalStrength the initial signal strength * @return a new SignalStrength if RAT is UMTS or existing SignalStrength */ public SignalStrength fixupSignalStrength10(SignalStrength signalStrength) { List<CellSignalStrengthGsm> gsmList = signalStrength.getCellSignalStrengths( CellSignalStrengthGsm.class); // If GSM is not the primary type, then bail out; no fixup needed. if (gsmList == null || gsmList.get(0) == null || !gsmList.get(0).isValid()) { return signalStrength; } CellSignalStrengthGsm gsmStrength = gsmList.get(0); // Use the voice RAT which is a guarantee in GSM and UMTS int voiceRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { voiceRat = ss.getRilVoiceRadioTechnology(); } } switch (voiceRat) { case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: /* fallthrough */ case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: /* fallthrough */ break; default: // If we are not currently on WCDMA/HSPA, then we don't need to do a fixup. return signalStrength; } // The service state reports WCDMA, and the SignalStrength is reported for GSM, so at this // point we take an educated guess that the GSM SignalStrength report is actually for // WCDMA. Also, if we are in WCDMA/GSM we can safely assume that there are no other valid // signal strength reports (no SRLTE, which is the only supported case in HAL 1.0). // Thus, we just construct a new SignalStrength and migrate RSSI and BER from the // GSM report to the WCDMA report, leaving everything else empty. return new SignalStrength( new CellSignalStrengthCdma(), new CellSignalStrengthGsm(), new CellSignalStrengthWcdma(gsmStrength.getRssi(), gsmStrength.getBitErrorRate(), CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE), new CellSignalStrengthTdscdma(), new CellSignalStrengthLte(), new CellSignalStrengthNr()); } /** * Convert CellInfo defined in 1.4/types.hal to CellInfo type. * @param records List of CellInfo defined in 1.4/types.hal. Loading
src/java/com/android/internal/telephony/RadioIndication.java +3 −1 Original line number Diff line number Diff line Loading @@ -229,7 +229,9 @@ public class RadioIndication extends IRadioIndication.Stub { android.hardware.radio.V1_0.SignalStrength signalStrength) { mRil.processIndication(indicationType); SignalStrength ss = new SignalStrength(signalStrength); SignalStrength ssInitial = new SignalStrength(signalStrength); SignalStrength ss = mRil.fixupSignalStrength10(ssInitial); // Note this is set to "verbose" because it happens frequently if (RIL.RILJ_LOGV) mRil.unsljLogvRet(RIL_UNSOL_SIGNAL_STRENGTH, ss); Loading
tests/telephonytests/src/com/android/internal/telephony/RILTest.java +32 −2 Original line number Diff line number Diff line Loading @@ -129,8 +129,11 @@ import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthNr; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; Loading @@ -147,7 +150,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -284,7 +286,6 @@ public class RILTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp(RILTest.class.getSimpleName()); MockitoAnnotations.initMocks(this); mTestHandler = new RILTestHandler(getClass().getSimpleName()); mTestHandler.start(); waitUntilReady(); Loading Loading @@ -1837,6 +1838,35 @@ public class RILTest extends TelephonyTest { assertEquals(MTU, dpi.mtu); } @Test public void testFixupSignalStrength10() { final int gsmWcdmaRssiDbm = -65; // Test the positive case where rat=UMTS and SignalStrength=GSM doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS) .when(mServiceState).getRilVoiceRadioTechnology(); SignalStrength gsmSignalStrength = new SignalStrength( new CellSignalStrengthCdma(), new CellSignalStrengthGsm(gsmWcdmaRssiDbm, 1, CellInfo.UNAVAILABLE), new CellSignalStrengthWcdma(), new CellSignalStrengthTdscdma(), new CellSignalStrengthLte(), new CellSignalStrengthNr()); SignalStrength result = mRILUnderTest.fixupSignalStrength10(gsmSignalStrength); assertTrue(result.getCellSignalStrengths(CellSignalStrengthGsm.class).isEmpty()); assertFalse(result.getCellSignalStrengths(CellSignalStrengthWcdma.class).isEmpty()); // Even though the dBm values are equal, the above checks ensure that the value has // been migrated to WCDMA (with no change in the top-level getDbm() result). assertEquals(result.getDbm(), gsmSignalStrength.getDbm()); // Test the no-op case where rat=GSM and SignalStrength=GSM doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_GSM) .when(mServiceState).getRilVoiceRadioTechnology(); result = mRILUnderTest.fixupSignalStrength10(gsmSignalStrength); assertEquals(result, gsmSignalStrength); } @Test public void testCreateCarrierRestrictionList() { ArrayList<CarrierIdentifier> carriers = new ArrayList<>(); Loading