Add function to get APN types as ints from bitmask

Bug: 181889657
Test: atest DataConnectionTest
Change-Id: I473b6bc3341bc3782b9c53eeca58c2ede18b6702
This commit is contained in:
Sarah Chin
2021-05-12 13:52:04 -07:00
parent 82c953e97f
commit 6ca27717b2

View File

@@ -1550,6 +1550,20 @@ public class ApnSetting implements Parcelable {
return TextUtils.join(",", types);
}
/**
* Converts the APN type bitmask to an array of all APN types
* @param apnTypeBitmask bitmask of APN types.
* @return int array of APN types
* @hide
*/
@NonNull
public static int[] getApnTypesFromBitmask(int apnTypeBitmask) {
return APN_TYPE_INT_MAP.keySet().stream()
.filter(type -> ((apnTypeBitmask & type) == type))
.mapToInt(Integer::intValue)
.toArray();
}
/**
* Converts the integer representation of APN type to its string representation.
*