1 package com.android.server.wifi; 2 3 import android.content.Context; 4 import android.telephony.SubscriptionManager; 5 import android.telephony.TelephonyManager; 6 7 import java.util.ArrayList; 8 import java.util.List; 9 10 public class SIMAccessor { 11 private final TelephonyManager mTelephonyManager; 12 private final SubscriptionManager mSubscriptionManager; 13 14 public SIMAccessor(Context context) { 15 mTelephonyManager = TelephonyManager.from(context); 16 mSubscriptionManager = SubscriptionManager.from(context); 17 } 18 19 public List<String> getMatchingImsis(IMSIParameter mccMnc) { 20 if (mccMnc == null) { 21 return null; 22 } 23 List<String> imsis = new ArrayList<>(); 24 for (int subId : mSubscriptionManager.getActiveSubscriptionIdList()) { 25 String imsi = mTelephonyManager.getSubscriberId(subId); 26 if (mccMnc.matches(imsi)) { 27 imsis.add(imsi); 28 } 29 } 30 return imsis.isEmpty() ? null : imsis; 31 } 32 } 33