SensitivePhoneNumbers: Load numbers only at first actual call to method
* Constructor is called during boot, adding boot time where it's not necessary * Use the first actual call to a function to parse the list Change-Id: I02548d004c5d78db65c872247cd36a0405d826ea
This commit is contained in:
@@ -51,12 +51,11 @@ public class SensitivePhoneNumbers {
|
||||
private static final String ns = null;
|
||||
|
||||
private static SensitivePhoneNumbers sInstance = null;
|
||||
private static boolean sNumbersLoaded;
|
||||
|
||||
private HashMap<String, ArrayList<String>> mSensitiveNumbersMap = new HashMap<>();
|
||||
|
||||
private SensitivePhoneNumbers() {
|
||||
loadSensiblePhoneNumbers();
|
||||
}
|
||||
private SensitivePhoneNumbers() { }
|
||||
|
||||
public static SensitivePhoneNumbers getInstance() {
|
||||
if (sInstance == null) {
|
||||
@@ -66,6 +65,10 @@ public class SensitivePhoneNumbers {
|
||||
}
|
||||
|
||||
private void loadSensiblePhoneNumbers() {
|
||||
if (sNumbersLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileReader sensiblePNReader;
|
||||
|
||||
File sensiblePNFile = new File(Environment.getRootDirectory(),
|
||||
@@ -89,6 +92,8 @@ public class SensitivePhoneNumbers {
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
Log.w(LOG_TAG, "Exception in spn-conf parser", e);
|
||||
}
|
||||
|
||||
sNumbersLoaded = true;
|
||||
}
|
||||
|
||||
private void readSensitivePNS(XmlPullParser parser)
|
||||
@@ -113,6 +118,7 @@ public class SensitivePhoneNumbers {
|
||||
}
|
||||
|
||||
public boolean isSensitiveNumber(Context context, String numberToCheck, int subId) {
|
||||
loadSensiblePhoneNumbers();
|
||||
String nationalNumber = formatNumberToNational(context, numberToCheck);
|
||||
|
||||
SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
|
||||
|
||||
Reference in New Issue
Block a user