personalization: set default values

For all ConfigurableParameter subclasses, set a default_value.

This is useful for user interaction, to prefill an input field that
indicates a valid input to modify to taste.

Related: SYS#6768
Change-Id: I2672fedcbc32cb7a6cb0c233a4a22112bd9aae03
This commit is contained in:
Neels Hofmeyr
2025-03-01 03:58:31 +01:00
parent d2373008f6
commit 90c8fa63d8

View File

@@ -103,6 +103,7 @@ class ConfigurableParameter:
min_len = None min_len = None
max_len = None max_len = None
allow_len = None # a list of specific lengths allow_len = None # a list of specific lengths
default_value = None
def __init__(self, input_value=None): def __init__(self, input_value=None):
self.input_value = input_value # the raw input value as given by caller self.input_value = input_value # the raw input value as given by caller
@@ -274,6 +275,7 @@ class Iccid(DecimalParam):
name = 'ICCID' name = 'ICCID'
min_len = 18 min_len = 18
max_len = 20 max_len = 20
default_value = '0' * 18
@classmethod @classmethod
def validate_val(cls, val): def validate_val(cls, val):
@@ -294,6 +296,7 @@ class Imsi(DecimalParam):
name = 'IMSI' name = 'IMSI'
min_len = 6 min_len = 6
max_len = 15 max_len = 15
default_value = '00101' + ('0' * 10)
@classmethod @classmethod
def apply_val(cls, pes: ProfileElementSequence, val): def apply_val(cls, pes: ProfileElementSequence, val):
@@ -461,6 +464,7 @@ class Puk(DecimalHexParam):
allow_len = 8 allow_len = 8
rpad = 16 rpad = 16
keyReference = None keyReference = None
default_value = '0' * allow_len
@classmethod @classmethod
def apply_val(cls, pes: ProfileElementSequence, val): def apply_val(cls, pes: ProfileElementSequence, val):
@@ -487,6 +491,7 @@ class Pin(DecimalHexParam):
rpad = 16 rpad = 16
min_len = 4 min_len = 4
max_len = 8 max_len = 8
default_value = '0' * max_len
keyReference = None keyReference = None
@staticmethod @staticmethod
@@ -510,9 +515,10 @@ class Pin(DecimalHexParam):
class Pin1(Pin): class Pin1(Pin):
name = 'PIN1' name = 'PIN1'
default_value = '0' * 4 # PIN are usually 4 digits
keyReference = 0x01 keyReference = 0x01
class Pin2(Pin): class Pin2(Pin1):
name = 'PIN2' name = 'PIN2'
keyReference = 0x81 keyReference = 0x81
@@ -532,7 +538,7 @@ class Adm1(Pin):
name = 'ADM1' name = 'ADM1'
keyReference = 0x0A keyReference = 0x0A
class Adm2(Pin): class Adm2(Adm1):
name = 'ADM2' name = 'ADM2'
keyReference = 0x0B keyReference = 0x0B
@@ -556,6 +562,7 @@ class AlgoConfig(ConfigurableParameter):
class AlgorithmID(DecimalParam, AlgoConfig): class AlgorithmID(DecimalParam, AlgoConfig):
algo_config_key = 'algorithmID' algo_config_key = 'algorithmID'
allow_len = 1 allow_len = 1
default_value = 1 # Milenage
@classmethod @classmethod
def validate_val(cls, val): def validate_val(cls, val):
@@ -572,6 +579,7 @@ class K(BinaryParam, AlgoConfig):
name = 'K' name = 'K'
algo_config_key = 'key' algo_config_key = 'key'
allow_len = int(128/8) # length in bytes (from BinaryParam) allow_len = int(128/8) # length in bytes (from BinaryParam)
default_value = '00' * allow_len
class Opc(K): class Opc(K):
name = 'OPc' name = 'OPc'