Loading src/java/com/android/internal/telephony/NetworkScanRequestTracker.java +19 −10 Original line number Original line Diff line number Diff line Loading @@ -38,13 +38,16 @@ import android.telephony.LocationAccessPolicy; import android.telephony.NetworkScan; import android.telephony.NetworkScan; import android.telephony.NetworkScanRequest; import android.telephony.NetworkScanRequest; import android.telephony.RadioAccessSpecifier; import android.telephony.RadioAccessSpecifier; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyScanManager; import android.telephony.TelephonyScanManager; import android.util.Log; import android.util.Log; import java.util.Collection; import java.util.Collection; import java.util.List; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.Collectors; import java.util.stream.Stream; /** /** * Manages radio access network scan requests. * Manages radio access network scan requests. Loading Loading @@ -172,15 +175,22 @@ public final class NetworkScanRequestTracker { } } /** /** * @return S list of MCC/MNC ids that apps should be allowed to see as results from a network * @return A list of MCC/MNC ids that apps should be allowed to see as results from a network * scan when scan results are restricted due to location privacy. * scan when scan results are restricted due to location privacy. */ */ public static List<String> getAllowedMccMncsForLocationRestrictedScan(Context context) { public static Set<String> getAllowedMccMncsForLocationRestrictedScan(Context context) { return withCleanCallingIdentity(() -> SubscriptionController.getInstance() return withCleanCallingIdentity(() -> SubscriptionController.getInstance() .getAllSubInfoList(context.getOpPackageName()).stream() .getAvailableSubscriptionInfoList(context.getOpPackageName()).stream() .filter(subInfo -> subInfo.getMccString() != null) .flatMap(NetworkScanRequestTracker::getAllowableMccMncsFromSubscriptionInfo) .map(subInfo -> subInfo.getMccString() + subInfo.getMncString()) .collect(Collectors.toSet())); .collect(Collectors.toList())); } private static Stream<String> getAllowableMccMncsFromSubscriptionInfo(SubscriptionInfo info) { Stream<String> plmns = Stream.of(info.getEhplmns(), info.getHplmns()).flatMap(List::stream); if (info.getMccString() != null && info.getMncString() != null) { plmns = Stream.concat(plmns, Stream.of(info.getMccString() + info.getMncString())); } return plmns; } } /** Sends a message back to the application via its callback. */ /** Sends a message back to the application via its callback. */ Loading @@ -194,12 +204,11 @@ public final class NetworkScanRequestTracker { if (result != null) { if (result != null) { if (what == TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS) { if (what == TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS) { //List<String> allowedMccMncs = Set<String> allowedMccMncs = // getAllowedMccMncsForLocationRestrictedScan(nsri.mPhone.getContext()); getAllowedMccMncsForLocationRestrictedScan(nsri.mPhone.getContext()); result = result.stream().map(CellInfo::sanitizeLocationInfo) result = result.stream().map(CellInfo::sanitizeLocationInfo) // STOPSHIP Revisit PLMN check (b/130253962). .filter(ci -> doesCellInfoCorrespondToKnownMccMnc(ci, allowedMccMncs)) //.filter(ci -> doesCellInfoCorrespondToKnownMccMnc(ci, allowedMccMncs)) .collect(Collectors.toList()); .collect(Collectors.toList()); } } Loading src/java/com/android/internal/telephony/SubscriptionController.java +44 −4 Original line number Original line Diff line number Diff line Loading @@ -389,6 +389,13 @@ public class SubscriptionController extends ISub.Stub { SubscriptionManager.MCC_STRING)); SubscriptionManager.MCC_STRING)); String mnc = cursor.getString(cursor.getColumnIndexOrThrow( String mnc = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.MNC_STRING)); SubscriptionManager.MNC_STRING)); String ehplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.EHPLMNS)); String hplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.HPLMNS)); String[] ehplmns = ehplmnsRaw == null ? null : ehplmnsRaw.split(","); String[] hplmns = hplmnsRaw == null ? null : hplmnsRaw.split(","); // cardId is the private ICCID/EID string, also known as the card string // cardId is the private ICCID/EID string, also known as the card string String cardId = cursor.getString(cursor.getColumnIndexOrThrow( String cardId = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.CARD_ID)); SubscriptionManager.CARD_ID)); Loading Loading @@ -435,10 +442,12 @@ public class SubscriptionController extends ISub.Stub { if (!TextUtils.isEmpty(line1Number) && !line1Number.equals(number)) { if (!TextUtils.isEmpty(line1Number) && !line1Number.equals(number)) { number = line1Number; number = line1Number; } } return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName, SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso, carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, groupUUID, countryIso, isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, false /* isGroupDisabled */, carrierId, profileClass, subType); groupUUID, false /* isGroupDisabled */, carrierId, profileClass, subType); info.setAssociatedPlmns(ehplmns, hplmns); return info; } } /** /** Loading Loading @@ -1648,6 +1657,37 @@ public class SubscriptionController extends ISub.Stub { } } } } /** * Set the EHPLMNs and HPLMNs associated with the subscription. */ public void setAssociatedPlmns(String[] ehplmns, String[] hplmns, int subId) { if (DBG) logd("[setAssociatedPlmns]+ subId:" + subId); validateSubId(subId); int phoneId = getPhoneId(subId); if (phoneId < 0 || phoneId >= mTelephonyManager.getPhoneCount()) { if (DBG) logd("[setAssociatedPlmns]- fail"); return; } String formattedEhplmns = ehplmns == null ? "" : String.join(",", ehplmns); String formattedHplmns = hplmns == null ? "" : String.join(",", hplmns); ContentValues value = new ContentValues(2); value.put(SubscriptionManager.EHPLMNS, formattedEhplmns); value.put(SubscriptionManager.HPLMNS, formattedHplmns); int count = mContext.getContentResolver().update( SubscriptionManager.getUriForSubscriptionId(subId), value, null, null); // Refresh the Cache of Active Subscription Info List refreshCachedActiveSubscriptionInfoList(); if (DBG) logd("[setAssociatedPlmns]- update result :" + count); notifySubscriptionInfoChanged(); } /** /** * Set data roaming by simInfo index * Set data roaming by simInfo index * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -439,6 +439,12 @@ public class SubscriptionInfoUpdater extends Handler { SubscriptionController.getInstance().setDisplayNumber(msisdn, subId); SubscriptionController.getInstance().setDisplayNumber(msisdn, subId); } } String[] ehplmns = records.getEhplmns(); String[] hplmns = records.getHplmns(); if (ehplmns != null || hplmns != null) { SubscriptionController.getInstance().setAssociatedPlmns(ehplmns, hplmns, subId); } SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); String nameToSet; String nameToSet; String simCarrierName = tm.getSimOperatorName(subId); String simCarrierName = tm.getSimOperatorName(subId); Loading src/java/com/android/internal/telephony/uicc/IccRecords.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -988,6 +988,25 @@ public abstract class IccRecords extends Handler implements IccConstants { */ */ protected abstract void loge(String s); protected abstract void loge(String s); /** * @return String array containing EHPLMNs associated with the card. */ public String[] getEhplmns() { return mEhplmns; } /** * @return String array containing HPLMNs associated with the card. */ public String[] getHplmns() { if (mHplmnActRecords == null) return null; String[] hplmns = new String[mHplmnActRecords.length]; for (int i = 0; i < mHplmnActRecords.length; i++) { hplmns[i] = mHplmnActRecords[i].plmn; } return hplmns; } /** /** * Return an interface to retrieve the ISIM records for IMS, if available. * Return an interface to retrieve the ISIM records for IMS, if available. * @return the interface to retrieve the ISIM records, or null if not supported * @return the interface to retrieve the ISIM records, or null if not supported Loading tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,8 @@ public class FakeTelephonyProvider extends MockContentProvider { + SubscriptionManager.MNC + " INTEGER DEFAULT 0," + SubscriptionManager.MNC + " INTEGER DEFAULT 0," + SubscriptionManager.MCC_STRING + " TEXT," + SubscriptionManager.MCC_STRING + " TEXT," + SubscriptionManager.MNC_STRING + " TEXT," + SubscriptionManager.MNC_STRING + " TEXT," + SubscriptionManager.EHPLMNS + " TEXT," + SubscriptionManager.HPLMNS + " TEXT," + SubscriptionManager.SIM_PROVISIONING_STATUS + SubscriptionManager.SIM_PROVISIONING_STATUS + " INTEGER DEFAULT " + SubscriptionManager.SIM_PROVISIONED + "," + " INTEGER DEFAULT " + SubscriptionManager.SIM_PROVISIONED + "," + SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0," + SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0," Loading Loading
src/java/com/android/internal/telephony/NetworkScanRequestTracker.java +19 −10 Original line number Original line Diff line number Diff line Loading @@ -38,13 +38,16 @@ import android.telephony.LocationAccessPolicy; import android.telephony.NetworkScan; import android.telephony.NetworkScan; import android.telephony.NetworkScanRequest; import android.telephony.NetworkScanRequest; import android.telephony.RadioAccessSpecifier; import android.telephony.RadioAccessSpecifier; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyScanManager; import android.telephony.TelephonyScanManager; import android.util.Log; import android.util.Log; import java.util.Collection; import java.util.Collection; import java.util.List; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.Collectors; import java.util.stream.Stream; /** /** * Manages radio access network scan requests. * Manages radio access network scan requests. Loading Loading @@ -172,15 +175,22 @@ public final class NetworkScanRequestTracker { } } /** /** * @return S list of MCC/MNC ids that apps should be allowed to see as results from a network * @return A list of MCC/MNC ids that apps should be allowed to see as results from a network * scan when scan results are restricted due to location privacy. * scan when scan results are restricted due to location privacy. */ */ public static List<String> getAllowedMccMncsForLocationRestrictedScan(Context context) { public static Set<String> getAllowedMccMncsForLocationRestrictedScan(Context context) { return withCleanCallingIdentity(() -> SubscriptionController.getInstance() return withCleanCallingIdentity(() -> SubscriptionController.getInstance() .getAllSubInfoList(context.getOpPackageName()).stream() .getAvailableSubscriptionInfoList(context.getOpPackageName()).stream() .filter(subInfo -> subInfo.getMccString() != null) .flatMap(NetworkScanRequestTracker::getAllowableMccMncsFromSubscriptionInfo) .map(subInfo -> subInfo.getMccString() + subInfo.getMncString()) .collect(Collectors.toSet())); .collect(Collectors.toList())); } private static Stream<String> getAllowableMccMncsFromSubscriptionInfo(SubscriptionInfo info) { Stream<String> plmns = Stream.of(info.getEhplmns(), info.getHplmns()).flatMap(List::stream); if (info.getMccString() != null && info.getMncString() != null) { plmns = Stream.concat(plmns, Stream.of(info.getMccString() + info.getMncString())); } return plmns; } } /** Sends a message back to the application via its callback. */ /** Sends a message back to the application via its callback. */ Loading @@ -194,12 +204,11 @@ public final class NetworkScanRequestTracker { if (result != null) { if (result != null) { if (what == TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS) { if (what == TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS) { //List<String> allowedMccMncs = Set<String> allowedMccMncs = // getAllowedMccMncsForLocationRestrictedScan(nsri.mPhone.getContext()); getAllowedMccMncsForLocationRestrictedScan(nsri.mPhone.getContext()); result = result.stream().map(CellInfo::sanitizeLocationInfo) result = result.stream().map(CellInfo::sanitizeLocationInfo) // STOPSHIP Revisit PLMN check (b/130253962). .filter(ci -> doesCellInfoCorrespondToKnownMccMnc(ci, allowedMccMncs)) //.filter(ci -> doesCellInfoCorrespondToKnownMccMnc(ci, allowedMccMncs)) .collect(Collectors.toList()); .collect(Collectors.toList()); } } Loading
src/java/com/android/internal/telephony/SubscriptionController.java +44 −4 Original line number Original line Diff line number Diff line Loading @@ -389,6 +389,13 @@ public class SubscriptionController extends ISub.Stub { SubscriptionManager.MCC_STRING)); SubscriptionManager.MCC_STRING)); String mnc = cursor.getString(cursor.getColumnIndexOrThrow( String mnc = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.MNC_STRING)); SubscriptionManager.MNC_STRING)); String ehplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.EHPLMNS)); String hplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.HPLMNS)); String[] ehplmns = ehplmnsRaw == null ? null : ehplmnsRaw.split(","); String[] hplmns = hplmnsRaw == null ? null : hplmnsRaw.split(","); // cardId is the private ICCID/EID string, also known as the card string // cardId is the private ICCID/EID string, also known as the card string String cardId = cursor.getString(cursor.getColumnIndexOrThrow( String cardId = cursor.getString(cursor.getColumnIndexOrThrow( SubscriptionManager.CARD_ID)); SubscriptionManager.CARD_ID)); Loading Loading @@ -435,10 +442,12 @@ public class SubscriptionController extends ISub.Stub { if (!TextUtils.isEmpty(line1Number) && !line1Number.equals(number)) { if (!TextUtils.isEmpty(line1Number) && !line1Number.equals(number)) { number = line1Number; number = line1Number; } } return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName, SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso, carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, groupUUID, countryIso, isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, false /* isGroupDisabled */, carrierId, profileClass, subType); groupUUID, false /* isGroupDisabled */, carrierId, profileClass, subType); info.setAssociatedPlmns(ehplmns, hplmns); return info; } } /** /** Loading Loading @@ -1648,6 +1657,37 @@ public class SubscriptionController extends ISub.Stub { } } } } /** * Set the EHPLMNs and HPLMNs associated with the subscription. */ public void setAssociatedPlmns(String[] ehplmns, String[] hplmns, int subId) { if (DBG) logd("[setAssociatedPlmns]+ subId:" + subId); validateSubId(subId); int phoneId = getPhoneId(subId); if (phoneId < 0 || phoneId >= mTelephonyManager.getPhoneCount()) { if (DBG) logd("[setAssociatedPlmns]- fail"); return; } String formattedEhplmns = ehplmns == null ? "" : String.join(",", ehplmns); String formattedHplmns = hplmns == null ? "" : String.join(",", hplmns); ContentValues value = new ContentValues(2); value.put(SubscriptionManager.EHPLMNS, formattedEhplmns); value.put(SubscriptionManager.HPLMNS, formattedHplmns); int count = mContext.getContentResolver().update( SubscriptionManager.getUriForSubscriptionId(subId), value, null, null); // Refresh the Cache of Active Subscription Info List refreshCachedActiveSubscriptionInfoList(); if (DBG) logd("[setAssociatedPlmns]- update result :" + count); notifySubscriptionInfoChanged(); } /** /** * Set data roaming by simInfo index * Set data roaming by simInfo index * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -439,6 +439,12 @@ public class SubscriptionInfoUpdater extends Handler { SubscriptionController.getInstance().setDisplayNumber(msisdn, subId); SubscriptionController.getInstance().setDisplayNumber(msisdn, subId); } } String[] ehplmns = records.getEhplmns(); String[] hplmns = records.getHplmns(); if (ehplmns != null || hplmns != null) { SubscriptionController.getInstance().setAssociatedPlmns(ehplmns, hplmns, subId); } SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); String nameToSet; String nameToSet; String simCarrierName = tm.getSimOperatorName(subId); String simCarrierName = tm.getSimOperatorName(subId); Loading
src/java/com/android/internal/telephony/uicc/IccRecords.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -988,6 +988,25 @@ public abstract class IccRecords extends Handler implements IccConstants { */ */ protected abstract void loge(String s); protected abstract void loge(String s); /** * @return String array containing EHPLMNs associated with the card. */ public String[] getEhplmns() { return mEhplmns; } /** * @return String array containing HPLMNs associated with the card. */ public String[] getHplmns() { if (mHplmnActRecords == null) return null; String[] hplmns = new String[mHplmnActRecords.length]; for (int i = 0; i < mHplmnActRecords.length; i++) { hplmns[i] = mHplmnActRecords[i].plmn; } return hplmns; } /** /** * Return an interface to retrieve the ISIM records for IMS, if available. * Return an interface to retrieve the ISIM records for IMS, if available. * @return the interface to retrieve the ISIM records, or null if not supported * @return the interface to retrieve the ISIM records, or null if not supported Loading
tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,8 @@ public class FakeTelephonyProvider extends MockContentProvider { + SubscriptionManager.MNC + " INTEGER DEFAULT 0," + SubscriptionManager.MNC + " INTEGER DEFAULT 0," + SubscriptionManager.MCC_STRING + " TEXT," + SubscriptionManager.MCC_STRING + " TEXT," + SubscriptionManager.MNC_STRING + " TEXT," + SubscriptionManager.MNC_STRING + " TEXT," + SubscriptionManager.EHPLMNS + " TEXT," + SubscriptionManager.HPLMNS + " TEXT," + SubscriptionManager.SIM_PROVISIONING_STATUS + SubscriptionManager.SIM_PROVISIONING_STATUS + " INTEGER DEFAULT " + SubscriptionManager.SIM_PROVISIONED + "," + " INTEGER DEFAULT " + SubscriptionManager.SIM_PROVISIONED + "," + SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0," + SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0," Loading