Loading src/java/com/android/internal/telephony/LocaleTracker.java +3 −32 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ import android.os.Looper; import android.os.Message; import android.sysprop.TelephonyProperties; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -295,7 +292,7 @@ public class LocaleTracker extends Handler { Map<String, Integer> mccMap = new HashMap<>(); int maxCount = 0; for (CellInfo cellInfo : mCellInfoList) { String mcc = getNetworkMcc(cellInfo); String mcc = cellInfo.getCellIdentity().getMccString(); if (mcc != null) { int count = 1; if (mccMap.containsKey(mcc)) { Loading Loading @@ -330,9 +327,9 @@ public class LocaleTracker extends Handler { Map<MccMnc, Integer> mccMncMap = new HashMap<>(); int maxCount = 0; for (CellInfo cellInfo : mCellInfoList) { String mcc = getNetworkMcc(cellInfo); String mcc = cellInfo.getCellIdentity().getMccString(); if (Objects.equals(mcc, mccToMatch)) { String mnc = getNetworkMnc(cellInfo); String mnc = cellInfo.getCellIdentity().getMncString(); MccMnc mccMnc = new MccMnc(mcc, mnc); int count = 1; if (mccMncMap.containsKey(mccMnc)) { Loading @@ -352,32 +349,6 @@ public class LocaleTracker extends Handler { return selectedMccMnc; } @Nullable private static String getNetworkMcc(CellInfo cellInfo) { String mccString = null; if (cellInfo instanceof CellInfoGsm) { mccString = ((CellInfoGsm) cellInfo).getCellIdentity().getMccString(); } else if (cellInfo instanceof CellInfoLte) { mccString = ((CellInfoLte) cellInfo).getCellIdentity().getMccString(); } else if (cellInfo instanceof CellInfoWcdma) { mccString = ((CellInfoWcdma) cellInfo).getCellIdentity().getMccString(); } return mccString; } @Nullable private static String getNetworkMnc(CellInfo cellInfo) { String mccString = null; if (cellInfo instanceof CellInfoGsm) { mccString = ((CellInfoGsm) cellInfo).getCellIdentity().getMncString(); } else if (cellInfo instanceof CellInfoLte) { mccString = ((CellInfoLte) cellInfo).getCellIdentity().getMncString(); } else if (cellInfo instanceof CellInfoWcdma) { mccString = ((CellInfoWcdma) cellInfo).getCellIdentity().getMncString(); } return mccString; } /** * Called when SIM card state changed. Only when we absolutely know the SIM is absent, we get * cell info from the network. Other SIM states like NOT_READY might be just a transitioning Loading src/java/com/android/internal/telephony/MissedIncomingCallSmsFilter.java +9 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -97,14 +98,17 @@ public class MissedIncomingCallSmsFilter { } if (mCarrierConfig != null) { SmsMessage message = SmsMessage.createFromPdu(pdus[0], format); String[] originators = mCarrierConfig.getStringArray(CarrierConfigManager .KEY_MISSED_INCOMING_CALL_SMS_ORIGINATOR_STRING_ARRAY); if (originators != null if (originators != null) { SmsMessage message = SmsMessage.createFromPdu(pdus[0], format); if (message != null && !TextUtils.isEmpty(message.getOriginatingAddress()) && Arrays.asList(originators).contains(message.getOriginatingAddress())) { return processSms(message); } } } return false; } Loading Loading @@ -147,7 +151,7 @@ public class MissedIncomingCallSmsFilter { * * @return {@code true} if the SMS message has been processed as a missed incoming call SMS. */ private boolean processSms(SmsMessage message) { private boolean processSms(@NonNull SmsMessage message) { long missedCallTime = 0; String callerId = null; Loading tests/telephonytests/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ android_test { jarjar_rules: ":jarjar-rules-telephony-tests", test_suites: [ "mts", "device-tests", ], } Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -22,11 +22,15 @@ import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityNr; import android.telephony.CellIdentityTdscdma; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class CellIdentityTest extends AndroidTestCase { Loading @@ -46,6 +50,9 @@ public class CellIdentityTest extends AndroidTestCase { private static final String MNC_STR = "260"; private static final String ALPHA_LONG = "long"; private static final String ALPHA_SHORT = "short"; private static final int CPID = 127; private static final int UARFCN = 16383; private static final int PSC = 511; // Network Id ranges from 0 to 65535. private static final int NETWORK_ID = 65535; Loading Loading @@ -183,4 +190,46 @@ public class CellIdentityTest extends AndroidTestCase { ALPHA_SHORT, Collections.emptyList()); assertFalse(ciA.isSameCell(cellIdentityNr)); } @SmallTest public void testGetMccMncString() { List<CellIdentity> identities = new ArrayList<>(5); CellIdentityGsm gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, MCC_STR, MNC_STR, null, null, Collections.emptyList()); identities.add(gsm); CellIdentityCdma cdma = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, ALPHA_LONG, ALPHA_SHORT); identities.add(cdma); CellIdentity lte = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(lte); CellIdentityWcdma wcdma = new CellIdentityWcdma(MAX_LAC, MAX_CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(wcdma); CellIdentityTdscdma tdscdma = new CellIdentityTdscdma(MCC_STR, MNC_STR, MAX_LAC, MAX_CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(tdscdma); CellIdentityNr nr = new CellIdentityNr(PCI, TAC, EARFCN, BANDS, MCC_STR, MNC_STR, CI, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); identities.add(nr); for (CellIdentity identity : identities) { final String mccStr = identity.getMccString(); final String mncStr = identity.getMncString(); if (identity instanceof CellIdentityCdma) { assertNull(mccStr); assertNull(mncStr); } else { assertEquals(MCC_STR, mccStr); assertEquals(MNC_STR, mncStr); } } } } Loading
src/java/com/android/internal/telephony/LocaleTracker.java +3 −32 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ import android.os.Looper; import android.os.Message; import android.sysprop.TelephonyProperties; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -295,7 +292,7 @@ public class LocaleTracker extends Handler { Map<String, Integer> mccMap = new HashMap<>(); int maxCount = 0; for (CellInfo cellInfo : mCellInfoList) { String mcc = getNetworkMcc(cellInfo); String mcc = cellInfo.getCellIdentity().getMccString(); if (mcc != null) { int count = 1; if (mccMap.containsKey(mcc)) { Loading Loading @@ -330,9 +327,9 @@ public class LocaleTracker extends Handler { Map<MccMnc, Integer> mccMncMap = new HashMap<>(); int maxCount = 0; for (CellInfo cellInfo : mCellInfoList) { String mcc = getNetworkMcc(cellInfo); String mcc = cellInfo.getCellIdentity().getMccString(); if (Objects.equals(mcc, mccToMatch)) { String mnc = getNetworkMnc(cellInfo); String mnc = cellInfo.getCellIdentity().getMncString(); MccMnc mccMnc = new MccMnc(mcc, mnc); int count = 1; if (mccMncMap.containsKey(mccMnc)) { Loading @@ -352,32 +349,6 @@ public class LocaleTracker extends Handler { return selectedMccMnc; } @Nullable private static String getNetworkMcc(CellInfo cellInfo) { String mccString = null; if (cellInfo instanceof CellInfoGsm) { mccString = ((CellInfoGsm) cellInfo).getCellIdentity().getMccString(); } else if (cellInfo instanceof CellInfoLte) { mccString = ((CellInfoLte) cellInfo).getCellIdentity().getMccString(); } else if (cellInfo instanceof CellInfoWcdma) { mccString = ((CellInfoWcdma) cellInfo).getCellIdentity().getMccString(); } return mccString; } @Nullable private static String getNetworkMnc(CellInfo cellInfo) { String mccString = null; if (cellInfo instanceof CellInfoGsm) { mccString = ((CellInfoGsm) cellInfo).getCellIdentity().getMncString(); } else if (cellInfo instanceof CellInfoLte) { mccString = ((CellInfoLte) cellInfo).getCellIdentity().getMncString(); } else if (cellInfo instanceof CellInfoWcdma) { mccString = ((CellInfoWcdma) cellInfo).getCellIdentity().getMncString(); } return mccString; } /** * Called when SIM card state changed. Only when we absolutely know the SIM is absent, we get * cell info from the network. Other SIM states like NOT_READY might be just a transitioning Loading
src/java/com/android/internal/telephony/MissedIncomingCallSmsFilter.java +9 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -97,14 +98,17 @@ public class MissedIncomingCallSmsFilter { } if (mCarrierConfig != null) { SmsMessage message = SmsMessage.createFromPdu(pdus[0], format); String[] originators = mCarrierConfig.getStringArray(CarrierConfigManager .KEY_MISSED_INCOMING_CALL_SMS_ORIGINATOR_STRING_ARRAY); if (originators != null if (originators != null) { SmsMessage message = SmsMessage.createFromPdu(pdus[0], format); if (message != null && !TextUtils.isEmpty(message.getOriginatingAddress()) && Arrays.asList(originators).contains(message.getOriginatingAddress())) { return processSms(message); } } } return false; } Loading Loading @@ -147,7 +151,7 @@ public class MissedIncomingCallSmsFilter { * * @return {@code true} if the SMS message has been processed as a missed incoming call SMS. */ private boolean processSms(SmsMessage message) { private boolean processSms(@NonNull SmsMessage message) { long missedCallTime = 0; String callerId = null; Loading
tests/telephonytests/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ android_test { jarjar_rules: ":jarjar-rules-telephony-tests", test_suites: [ "mts", "device-tests", ], } Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -22,11 +22,15 @@ import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityNr; import android.telephony.CellIdentityTdscdma; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class CellIdentityTest extends AndroidTestCase { Loading @@ -46,6 +50,9 @@ public class CellIdentityTest extends AndroidTestCase { private static final String MNC_STR = "260"; private static final String ALPHA_LONG = "long"; private static final String ALPHA_SHORT = "short"; private static final int CPID = 127; private static final int UARFCN = 16383; private static final int PSC = 511; // Network Id ranges from 0 to 65535. private static final int NETWORK_ID = 65535; Loading Loading @@ -183,4 +190,46 @@ public class CellIdentityTest extends AndroidTestCase { ALPHA_SHORT, Collections.emptyList()); assertFalse(ciA.isSameCell(cellIdentityNr)); } @SmallTest public void testGetMccMncString() { List<CellIdentity> identities = new ArrayList<>(5); CellIdentityGsm gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, MCC_STR, MNC_STR, null, null, Collections.emptyList()); identities.add(gsm); CellIdentityCdma cdma = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, ALPHA_LONG, ALPHA_SHORT); identities.add(cdma); CellIdentity lte = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(lte); CellIdentityWcdma wcdma = new CellIdentityWcdma(MAX_LAC, MAX_CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(wcdma); CellIdentityTdscdma tdscdma = new CellIdentityTdscdma(MCC_STR, MNC_STR, MAX_LAC, MAX_CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); identities.add(tdscdma); CellIdentityNr nr = new CellIdentityNr(PCI, TAC, EARFCN, BANDS, MCC_STR, MNC_STR, CI, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); identities.add(nr); for (CellIdentity identity : identities) { final String mccStr = identity.getMccString(); final String mncStr = identity.getMncString(); if (identity instanceof CellIdentityCdma) { assertNull(mccStr); assertNull(mncStr); } else { assertEquals(MCC_STR, mccStr); assertEquals(MNC_STR, mncStr); } } } }