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 
SIMAccessor(Context context)14     public SIMAccessor(Context context) {
15         // TODO(b/132188983): Inject this using WifiInjector
16         mTelephonyManager = TelephonyManager.from(context);
17         // TODO(b/132188983): Inject this using WifiInjector
18         mSubscriptionManager = SubscriptionManager.from(context);
19     }
20 
getMatchingImsis(IMSIParameter mccMnc)21     public List<String> getMatchingImsis(IMSIParameter mccMnc) {
22         if (mccMnc == null) {
23             return null;
24         }
25         List<String> imsis = new ArrayList<>();
26         for (int subId : mSubscriptionManager.getActiveSubscriptionIdList()) {
27             String imsi = mTelephonyManager.getSubscriberId(subId);
28             if (imsi != null && mccMnc.matchesImsi(imsi)) {
29                 imsis.add(imsi);
30             }
31         }
32         return imsis.isEmpty() ? null : imsis;
33     }
34 }
35