Revert "utils.py: Fix for parsing MNC"

This reverts commit bdf3d3597b, which
broke pySim.utils.dec_mnc_from_plmn().  According to 3GPP TS 31.102,
which points to TS 24.008, the three-digit EHPLMN shall be encoded
as shown below (ASCII-art interpretation):

    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+
  |  MCC Digit 2  |  MCC Digit 1  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 3  |  MCC Digit 3  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 2  |  MNC Digit 1  |
  +---+---+---+---+---+---+---+---+

So the original implementation was correct, and we even had a unit
test for it.  Most likely, the SIM card itself was programmed
incorrectly?

Makes 'testDecMNCfromPLMN_threeDigitMNC' pass again.

Change-Id: If6bf5383988ad442e275efc7c5a159327d104879
This commit is contained in:
Vadim Yanitskiy
2021-03-11 23:56:58 +01:00
parent 4ae7c49076
commit b271be3dc0

View File

@@ -140,9 +140,9 @@ def dec_mcc_from_plmn(plmn):
def dec_mnc_from_plmn(plmn):
ia = h2i(plmn)
digit1 = (ia[1] & 0xF0) >>4 # 2nd byte, MSB
digit2 = ia[2] & 0x0F # 3rd byte, LSB
digit3 = (ia[2] & 0xF0) >> 4 # 3nd byte, MSB
digit1 = ia[2] & 0x0F # 3rd byte, LSB
digit2 = (ia[2] & 0xF0) >> 4 # 3rd byte, MSB
digit3 = (ia[1] & 0xF0) >> 4 # 2nd byte, MSB
if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
return 0xFFF # 4095
return derive_mnc(digit1, digit2, digit3)