Skip to content

Commit

Permalink
Added new mnc/mcc white list + support for concise list format
Browse files Browse the repository at this point in the history
Updated tests
  • Loading branch information
andybeardedhen committed Oct 27, 2015
1 parent fb96042 commit f3cf541
Show file tree
Hide file tree
Showing 7 changed files with 966 additions and 840 deletions.
30 changes: 25 additions & 5 deletions app/src/main/java/com/vasilitate/vapp/sdk/Vapp.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,32 @@ private static void addBillingRouteToMap(Context context, int mccMncArrayResId,

String[] mccMncs = context.getResources().getStringArray(mccMncArrayResId);

// format is mcc, mcc, ... / mnc, mnc,....

for (String mccMnc : mccMncs) {
if (billingRouteMap.containsKey(mccMncs)) {
throw new VappException("MCC/MNC combination is assigned to more than one billing route: " + mccMnc);
}
else {
billingRouteMap.put(mccMnc, billingRoute);

String[] mccAndMnc = mccMnc.split( "/" );

if( mccAndMnc.length == 2 ) {

String[] mccs = mccAndMnc[0].split(",");
String[] mncs = mccAndMnc[1].split(",");

if( mccs.length > 0 && mncs.length > 0 ) {

for( String mcc : mccs ) {
for( String mnc : mncs ) {

String combination = mcc.trim() + "/" + mnc.trim();
if (billingRouteMap.containsKey(combination)) {
throw new VappException("MCC/MNC combination is assigned to more than one billing route: " + combination);
}
else {
billingRouteMap.put(combination, billingRoute);
}
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ public long getStartOfRange() {
public long getEndOfRange() {
return endOfRange;
}

@Override
public String toString() {
return String.format( "%d - %d", startOfRange, endOfRange );
}
}
Loading

0 comments on commit f3cf541

Please sign in to comment.