- android/ 167个模块 (app/content/os/view/widget/graphics/media/hardware/net/telephony/provider等) - java/ 35个模块 (lang/io/util/net/nio/security/crypto/sql/beans/rmi/awt等) - javax/ 4个模块 (net/crypto/security/sql) - org/ 5个模块 (json/w3c_dom/xml_sax/xml_pull/apache_http) - dalvik/ 1个模块 (system) - ~3053个类/接口,方法签名完全对齐Android SDK - 桌面跨平台运行 (Windows/macOS/Linux) - 修复所有导入错误和Python关键字冲突
1200 lines
37 KiB
Python
1200 lines
37 KiB
Python
"""
|
|
Android Telephony Data 组件 — TelephonyManager.Data, DataConnection, ApnSetting, DataProfile 等
|
|
方法签名完全对齐 Android SDK (android.telephony.data 包)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
|
|
|
|
from .._core import Stub, AndroidOnlyError
|
|
from ..java.lang import RuntimeException
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# ApnSetting
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class ApnSetting(Stub):
|
|
"""ApnSetting — APN 设置"""
|
|
|
|
TYPE_DEFAULT = 1 << 0
|
|
TYPE_MMS = 1 << 1
|
|
TYPE_SUPL = 1 << 2
|
|
TYPE_DUN = 1 << 3
|
|
TYPE_HIPRI = 1 << 4
|
|
TYPE_FOTA = 1 << 5
|
|
TYPE_IMS = 1 << 6
|
|
TYPE_CBS = 1 << 7
|
|
TYPE_IA = 1 << 8
|
|
TYPE_EMERGENCY = 1 << 9
|
|
TYPE_MCX = 1 << 10
|
|
TYPE_XCAP = 1 << 11
|
|
TYPE_BIP = 1 << 12
|
|
TYPE_VSIM = 1 << 13
|
|
TYPE_ENTERPRISE = 1 << 14
|
|
TYPE_ALL = 0xFFFFFFFF
|
|
|
|
PROTOCOL_IP = "IP"
|
|
PROTOCOL_IPV6 = "IPV6"
|
|
PROTOCOL_IPV4V6 = "IPV4V6"
|
|
PROTOCOL_PPP = "PPP"
|
|
PROTOCOL_NON_IP = "NON-IP"
|
|
PROTOCOL_UNSTRUCTURED = "UNSTRUCTURED"
|
|
|
|
AUTH_TYPE_NONE = 0
|
|
AUTH_TYPE_PAP = 1
|
|
AUTH_TYPE_CHAP = 2
|
|
AUTH_TYPE_PAP_OR_CHAP = 3
|
|
|
|
MVNO_TYPE_IMSI = 0
|
|
MVNO_TYPE_GID = 1
|
|
MVNO_TYPE_SPN = 2
|
|
MVNO_TYPE_PNN = 3
|
|
MVNO_TYPE_ACQ = 4
|
|
MVNO_TYPE_ICCID = 5
|
|
MVNO_TYPE_PLMN = 6
|
|
MVNO_TYPE_SIP = 7
|
|
MVNO_TYPE_NONE = -1
|
|
|
|
def __init__(self, apn: str = "", numeric: str = "",
|
|
carrier: str = "", mcc: str = "", mnc: str = "",
|
|
user: str = "", password: str = ""):
|
|
super().__init__()
|
|
self._apn = apn
|
|
self._numeric = numeric
|
|
self._carrier = carrier
|
|
self._mcc = mcc
|
|
self._mnc = mnc
|
|
self._user = user
|
|
self._password = password
|
|
self._proxy: str = ""
|
|
self._port: int = 0
|
|
self._server: str = ""
|
|
self._mmsc: str = ""
|
|
self._mms_proxy: str = ""
|
|
self._mms_port: int = 0
|
|
self._types: int = ApnSetting.TYPE_DEFAULT
|
|
self._protocol: str = ApnSetting.PROTOCOL_IP
|
|
self._roaming_protocol: str = ApnSetting.PROTOCOL_IP
|
|
self._auth_type: int = ApnSetting.AUTH_TYPE_NONE
|
|
self._carrier_enabled: bool = True
|
|
self._bearer: int = 0
|
|
self._bearer_bitmask: int = 0
|
|
self._roaming_bearer_bitmask: int = 0
|
|
self._mtu: int = 0
|
|
self._mvno_type: int = ApnSetting.MVNO_TYPE_NONE
|
|
self._mvno_match_data: str = ""
|
|
self._edited: int = 0
|
|
self._id: int = 0
|
|
self._network_type_bitmask: int = 0
|
|
self._entry_name: str = ""
|
|
self._entry_for_apn: str = ""
|
|
self._always_on: bool = False
|
|
self._skip_464xlat: bool = False
|
|
self._persistent: bool = True
|
|
|
|
def getApn(self) -> str:
|
|
return self._apn
|
|
|
|
def setApn(self, apn: str):
|
|
self._apn = apn
|
|
|
|
def getNumeric(self) -> str:
|
|
return self._numeric
|
|
|
|
def setNumeric(self, numeric: str):
|
|
self._numeric = numeric
|
|
|
|
def getCarrier(self) -> str:
|
|
return self._carrier
|
|
|
|
def setCarrier(self, carrier: str):
|
|
self._carrier = carrier
|
|
|
|
def getMcc(self) -> str:
|
|
return self._mcc
|
|
|
|
def setMcc(self, mcc: str):
|
|
self._mcc = mcc
|
|
|
|
def getMnc(self) -> str:
|
|
return self._mnc
|
|
|
|
def setMnc(self, mnc: str):
|
|
self._mnc = mnc
|
|
|
|
def getUser(self) -> str:
|
|
return self._user
|
|
|
|
def setUser(self, user: str):
|
|
self._user = user
|
|
|
|
def getPassword(self) -> str:
|
|
return self._password
|
|
|
|
def setPassword(self, password: str):
|
|
self._password = password
|
|
|
|
def getProxy(self) -> str:
|
|
return self._proxy
|
|
|
|
def setProxy(self, proxy: str):
|
|
self._proxy = proxy
|
|
|
|
def getPort(self) -> int:
|
|
return self._port
|
|
|
|
def setPort(self, port: int):
|
|
self._port = port
|
|
|
|
def getServer(self) -> str:
|
|
return self._server
|
|
|
|
def setServer(self, server: str):
|
|
self._server = server
|
|
|
|
def getMmsc(self) -> str:
|
|
return self._mmsc
|
|
|
|
def setMmsc(self, mmsc: str):
|
|
self._mmsc = mmsc
|
|
|
|
def getMmsProxy(self) -> str:
|
|
return self._mms_proxy
|
|
|
|
def setMmsProxy(self, proxy: str):
|
|
self._mms_proxy = proxy
|
|
|
|
def getMmsPort(self) -> int:
|
|
return self._mms_port
|
|
|
|
def setMmsPort(self, port: int):
|
|
self._mms_port = port
|
|
|
|
def getTypes(self) -> int:
|
|
return self._types
|
|
|
|
def setTypes(self, types: int):
|
|
self._types = types
|
|
|
|
def getProtocol(self) -> str:
|
|
return self._protocol
|
|
|
|
def setProtocol(self, protocol: str):
|
|
self._protocol = protocol
|
|
|
|
def getRoamingProtocol(self) -> str:
|
|
return self._roaming_protocol
|
|
|
|
def setRoamingProtocol(self, protocol: str):
|
|
self._roaming_protocol = protocol
|
|
|
|
def getAuthType(self) -> int:
|
|
return self._auth_type
|
|
|
|
def setAuthType(self, auth_type: int):
|
|
self._auth_type = auth_type
|
|
|
|
def isCarrierEnabled(self) -> bool:
|
|
return self._carrier_enabled
|
|
|
|
def setCarrierEnabled(self, enabled: bool):
|
|
self._carrier_enabled = enabled
|
|
|
|
def getBearer(self) -> int:
|
|
return self._bearer
|
|
|
|
def setBearer(self, bearer: int):
|
|
self._bearer = bearer
|
|
|
|
def hasType(self, type_: int) -> bool:
|
|
return bool(self._types & type_)
|
|
|
|
def isAlwaysOn(self) -> bool:
|
|
return self._always_on
|
|
|
|
def setAlwaysOn(self, always_on: bool):
|
|
self._always_on = always_on
|
|
|
|
def getMtu(self) -> int:
|
|
return self._mtu
|
|
|
|
def setMtu(self, mtu: int):
|
|
self._mtu = mtu
|
|
|
|
def getMvnoType(self) -> int:
|
|
return self._mvno_type
|
|
|
|
def setMvnoType(self, mvno_type: int):
|
|
self._mvno_type = mvno_type
|
|
|
|
def getMvnoMatchData(self) -> str:
|
|
return self._mvno_match_data
|
|
|
|
def setMvnoMatchData(self, data: str):
|
|
self._mvno_match_data = data
|
|
|
|
def getId(self) -> int:
|
|
return self._id
|
|
|
|
def setId(self, id_: int):
|
|
self._id = id_
|
|
|
|
def getEntryName(self) -> str:
|
|
return self._entry_name
|
|
|
|
def setEntryName(self, name: str):
|
|
self._entry_name = name
|
|
|
|
def toString(self) -> str:
|
|
return f"ApnSetting(apn={self._apn}, carrier={self._carrier})"
|
|
|
|
class Builder(Stub):
|
|
"""ApnSetting.Builder — APN 构建器"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._apn = ""
|
|
self._numeric = ""
|
|
self._carrier = ""
|
|
self._mcc = ""
|
|
self._mnc = ""
|
|
self._user = ""
|
|
self._password = ""
|
|
self._proxy = ""
|
|
self._port = 0
|
|
self._server = ""
|
|
self._mmsc = ""
|
|
self._mms_proxy = ""
|
|
self._mms_port = 0
|
|
self._types = ApnSetting.TYPE_DEFAULT
|
|
self._protocol = ApnSetting.PROTOCOL_IP
|
|
self._roaming_protocol = ApnSetting.PROTOCOL_IP
|
|
self._auth_type = ApnSetting.AUTH_TYPE_NONE
|
|
self._carrier_enabled = True
|
|
self._bearer = 0
|
|
self._mvno_type = ApnSetting.MVNO_TYPE_NONE
|
|
self._mvno_match_data = ""
|
|
self._always_on = False
|
|
self._mtu = 0
|
|
|
|
def setApn(self, apn: str) -> ApnSetting.Builder:
|
|
self._apn = apn; return self
|
|
|
|
def setNumeric(self, numeric: str) -> ApnSetting.Builder:
|
|
self._numeric = numeric; return self
|
|
|
|
def setCarrier(self, carrier: str) -> ApnSetting.Builder:
|
|
self._carrier = carrier; return self
|
|
|
|
def setMcc(self, mcc: str) -> ApnSetting.Builder:
|
|
self._mcc = mcc; return self
|
|
|
|
def setMnc(self, mnc: str) -> ApnSetting.Builder:
|
|
self._mnc = mnc; return self
|
|
|
|
def setUser(self, user: str) -> ApnSetting.Builder:
|
|
self._user = user; return self
|
|
|
|
def setPassword(self, password: str) -> ApnSetting.Builder:
|
|
self._password = password; return self
|
|
|
|
def setProxy(self, proxy: str) -> ApnSetting.Builder:
|
|
self._proxy = proxy; return self
|
|
|
|
def setPort(self, port: int) -> ApnSetting.Builder:
|
|
self._port = port; return self
|
|
|
|
def setMmsc(self, mmsc: str) -> ApnSetting.Builder:
|
|
self._mmsc = mmsc; return self
|
|
|
|
def setMmsProxy(self, proxy: str) -> ApnSetting.Builder:
|
|
self._mms_proxy = proxy; return self
|
|
|
|
def setMmsPort(self, port: int) -> ApnSetting.Builder:
|
|
self._mms_port = port; return self
|
|
|
|
def setTypes(self, types: int) -> ApnSetting.Builder:
|
|
self._types = types; return self
|
|
|
|
def setProtocol(self, protocol: str) -> ApnSetting.Builder:
|
|
self._protocol = protocol; return self
|
|
|
|
def setRoamingProtocol(self, protocol: str) -> ApnSetting.Builder:
|
|
self._roaming_protocol = protocol; return self
|
|
|
|
def setAuthType(self, auth_type: int) -> ApnSetting.Builder:
|
|
self._auth_type = auth_type; return self
|
|
|
|
def setCarrierEnabled(self, enabled: bool) -> ApnSetting.Builder:
|
|
self._carrier_enabled = enabled; return self
|
|
|
|
def setAlwaysOn(self, always_on: bool) -> ApnSetting.Builder:
|
|
self._always_on = always_on; return self
|
|
|
|
def build(self) -> ApnSetting:
|
|
apn = ApnSetting(self._apn, self._numeric, self._carrier,
|
|
self._mcc, self._mnc, self._user, self._password)
|
|
apn.setProxy(self._proxy)
|
|
apn.setPort(self._port)
|
|
apn.setMmsc(self._mmsc)
|
|
apn.setMmsProxy(self._mms_proxy)
|
|
apn.setMmsPort(self._mms_port)
|
|
apn.setTypes(self._types)
|
|
apn.setProtocol(self._protocol)
|
|
apn.setRoamingProtocol(self._roaming_protocol)
|
|
apn.setAuthType(self._auth_type)
|
|
apn.setCarrierEnabled(self._carrier_enabled)
|
|
apn.setAlwaysOn(self._always_on)
|
|
return apn
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataProfile
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataProfile(Stub):
|
|
"""DataProfile — 数据配置文件"""
|
|
|
|
TYPE_COMMON = 0
|
|
TYPE_3GPP = 1
|
|
TYPE_3GPP2 = 2
|
|
TYPE_IMS = 3
|
|
TYPE_FOTA = 4
|
|
TYPE_CBS = 5
|
|
TYPE_IA = 6
|
|
TYPE_EMERGENCY = 7
|
|
TYPE_MCX = 8
|
|
TYPE_XCAP = 9
|
|
TYPE_ENTERPRISE = 10
|
|
|
|
PROTOCOL_IPV4 = 0
|
|
PROTOCOL_IPV6 = 1
|
|
PROTOCOL_IPV4V6 = 2
|
|
PROTOCOL_PPP = 3
|
|
PROTOCOL_UNKNOWN = -1
|
|
|
|
def __init__(self, profile_id: int = 0, apn: str = "",
|
|
protocol: int = PROTOCOL_IPV4):
|
|
super().__init__()
|
|
self._profile_id = profile_id
|
|
self._apn = apn
|
|
self._protocol = protocol
|
|
self._roaming_protocol: int = DataProfile.PROTOCOL_IPV4
|
|
self._auth_type: int = 0
|
|
self._user: str = ""
|
|
self._password: str = ""
|
|
self._type: int = DataProfile.TYPE_COMMON
|
|
self._max_connections: int = 0
|
|
self._wait_time: int = 0
|
|
self._enabled: bool = True
|
|
self._supported_apn_types_bitmask: int = 0
|
|
self._bearer_bitmask: int = 0
|
|
self._mtu: int = 0
|
|
self._persistent: bool = True
|
|
self._preferred: bool = False
|
|
|
|
def getProfileId(self) -> int:
|
|
return self._profile_id
|
|
|
|
def setProfileId(self, profile_id: int):
|
|
self._profile_id = profile_id
|
|
|
|
def getApn(self) -> str:
|
|
return self._apn
|
|
|
|
def setApn(self, apn: str):
|
|
self._apn = apn
|
|
|
|
def getProtocol(self) -> int:
|
|
return self._protocol
|
|
|
|
def setProtocol(self, protocol: int):
|
|
self._protocol = protocol
|
|
|
|
def getRoamingProtocol(self) -> int:
|
|
return self._roaming_protocol
|
|
|
|
def setRoamingProtocol(self, protocol: int):
|
|
self._roaming_protocol = protocol
|
|
|
|
def getAuthType(self) -> int:
|
|
return self._auth_type
|
|
|
|
def setAuthType(self, auth_type: int):
|
|
self._auth_type = auth_type
|
|
|
|
def getUser(self) -> str:
|
|
return self._user
|
|
|
|
def setUser(self, user: str):
|
|
self._user = user
|
|
|
|
def getPassword(self) -> str:
|
|
return self._password
|
|
|
|
def setPassword(self, password: str):
|
|
self._password = password
|
|
|
|
def getType(self) -> int:
|
|
return self._type
|
|
|
|
def setType(self, type_: int):
|
|
self._type = type_
|
|
|
|
def getMaxConnections(self) -> int:
|
|
return self._max_connections
|
|
|
|
def setMaxConnections(self, max_conn: int):
|
|
self._max_connections = max_conn
|
|
|
|
def getWaitTime(self) -> int:
|
|
return self._wait_time
|
|
|
|
def setWaitTime(self, wait: int):
|
|
self._wait_time = wait
|
|
|
|
def isEnabled(self) -> bool:
|
|
return self._enabled
|
|
|
|
def setEnabled(self, enabled: bool):
|
|
self._enabled = enabled
|
|
|
|
def isPersistent(self) -> bool:
|
|
return self._persistent
|
|
|
|
def setPersistent(self, persistent: bool):
|
|
self._persistent = persistent
|
|
|
|
def isPreferred(self) -> bool:
|
|
return self._preferred
|
|
|
|
def setPreferred(self, preferred: bool):
|
|
self._preferred = preferred
|
|
|
|
def getMtu(self) -> int:
|
|
return self._mtu
|
|
|
|
def setMtu(self, mtu: int):
|
|
self._mtu = mtu
|
|
|
|
def getSupportedApnTypesBitmask(self) -> int:
|
|
return self._supported_apn_types_bitmask
|
|
|
|
def setSupportedApnTypesBitmask(self, bitmask: int):
|
|
self._supported_apn_types_bitmask = bitmask
|
|
|
|
def toString(self) -> str:
|
|
return f"DataProfile(id={self._profile_id}, apn={self._apn})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataConnection
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataConnection(Stub):
|
|
"""DataConnection — 数据连接"""
|
|
|
|
STATE_DISCONNECTED = 0
|
|
STATE_CONNECTING = 1
|
|
STATE_CONNECTED = 2
|
|
STATE_DISCONNECTING = 3
|
|
STATE_SUSPENDED = 4
|
|
STATE_UNKNOWN = -1
|
|
|
|
LINK_PROPERTIES_IFACE_NAME = "iface"
|
|
LINK_PROPERTIES_DNS1 = "dns1"
|
|
LINK_PROPERTIES_DNS2 = "dns2"
|
|
LINK_PROPERTIES_GATEWAY = "gateway"
|
|
LINK_PROPERTIES_MTU = "mtu"
|
|
LINK_PROPERTIES_ADDRESS = "address"
|
|
LINK_PROPERTIES_PREFIX_LENGTH = "prefix_length"
|
|
LINK_PROPERTIES_HTTP_PROXY = "http_proxy"
|
|
LINK_PROPERTIES_PCSCF = "pcscf"
|
|
|
|
def __init__(self, cid: int = 0):
|
|
super().__init__()
|
|
self._cid = cid
|
|
self._state: int = DataConnection.STATE_DISCONNECTED
|
|
self._apn: str = ""
|
|
self._apn_type: int = ApnSetting.TYPE_DEFAULT
|
|
self._network_type: int = 0
|
|
self._link_properties: Dict[str, Any] = {}
|
|
self._data_profile: Optional[DataProfile] = None
|
|
self._is_internet: bool = False
|
|
self._fail_cause: int = 0
|
|
self._suggested_retry_time: int = 0
|
|
self._time_connected: int = 0
|
|
self._bearer_id: int = 0
|
|
self._rat: int = 0
|
|
self._is_roaming: bool = False
|
|
|
|
def getCid(self) -> int:
|
|
return self._cid
|
|
|
|
def setCid(self, cid: int):
|
|
self._cid = cid
|
|
|
|
def getState(self) -> int:
|
|
return self._state
|
|
|
|
def setState(self, state: int):
|
|
self._state = state
|
|
|
|
def getApn(self) -> str:
|
|
return self._apn
|
|
|
|
def setApn(self, apn: str):
|
|
self._apn = apn
|
|
|
|
def getApnType(self) -> int:
|
|
return self._apn_type
|
|
|
|
def setApnType(self, apn_type: int):
|
|
self._apn_type = apn_type
|
|
|
|
def getNetworkType(self) -> int:
|
|
return self._network_type
|
|
|
|
def setNetworkType(self, network_type: int):
|
|
self._network_type = network_type
|
|
|
|
def getLinkProperties(self) -> Dict[str, Any]:
|
|
return dict(self._link_properties)
|
|
|
|
def setLinkProperties(self, props: Dict[str, Any]):
|
|
self._link_properties = dict(props)
|
|
|
|
def getDataProfile(self) -> Optional[DataProfile]:
|
|
return self._data_profile
|
|
|
|
def setDataProfile(self, profile: DataProfile):
|
|
self._data_profile = profile
|
|
|
|
def isInternet(self) -> bool:
|
|
return self._is_internet
|
|
|
|
def setInternet(self, internet: bool):
|
|
self._is_internet = internet
|
|
|
|
def getFailCause(self) -> int:
|
|
return self._fail_cause
|
|
|
|
def setFailCause(self, cause: int):
|
|
self._fail_cause = cause
|
|
|
|
def getSuggestedRetryTime(self) -> int:
|
|
return self._suggested_retry_time
|
|
|
|
def setSuggestedRetryTime(self, time_ms: int):
|
|
self._suggested_retry_time = time_ms
|
|
|
|
def getTimeConnected(self) -> int:
|
|
return self._time_connected
|
|
|
|
def setTimeConnected(self, time_ms: int):
|
|
self._time_connected = time_ms
|
|
|
|
def getBearerId(self) -> int:
|
|
return self._bearer_id
|
|
|
|
def setBearerId(self, bearer_id: int):
|
|
self._bearer_id = bearer_id
|
|
|
|
def isRoaming(self) -> bool:
|
|
return self._is_roaming
|
|
|
|
def setRoaming(self, roaming: bool):
|
|
self._is_roaming = roaming
|
|
|
|
def isConnected(self) -> bool:
|
|
return self._state == DataConnection.STATE_CONNECTED
|
|
|
|
def toString(self) -> str:
|
|
return f"DataConnection(cid={self._cid}, state={self._state}, apn={self._apn})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataSpecificRegistrationInfo
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataSpecificRegistrationInfo(Stub):
|
|
"""DataSpecificRegistrationInfo — 数据特定注册信息"""
|
|
|
|
LVC_AVAILABLE = 0
|
|
LVC_NOT_AVAILABLE = 1
|
|
LVC_UNKNOWN = 2
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._lvc_state: int = DataSpecificRegistrationInfo.LVC_UNKNOWN
|
|
self._is_dc_over_nr: bool = False
|
|
self._is_enhanced_voice_roaming: bool = False
|
|
self._is_endc_available: bool = False
|
|
self._max_data_connectivity: int = 0
|
|
self._nr_available: bool = False
|
|
self._en_dc_available: bool = False
|
|
self._voice_over_nr: bool = False
|
|
self._is_roaming: bool = False
|
|
self._registration_network_type: int = 0
|
|
self._voice_registration_network_type: int = 0
|
|
self._available_services: Set[int] = set()
|
|
self._voice_registration_info: Any = None
|
|
self._nr_voice_available: bool = False
|
|
self._lte_voice_available: bool = False
|
|
|
|
def getLvcState(self) -> int:
|
|
return self._lvc_state
|
|
|
|
def setLvcState(self, state: int):
|
|
self._lvc_state = state
|
|
|
|
def isDcOverNr(self) -> bool:
|
|
return self._is_dc_over_nr
|
|
|
|
def setDcOverNr(self, dc_over_nr: bool):
|
|
self._is_dc_over_nr = dc_over_nr
|
|
|
|
def isEnhancedVoiceRoaming(self) -> bool:
|
|
return self._is_enhanced_voice_roaming
|
|
|
|
def setEnhancedVoiceRoaming(self, roaming: bool):
|
|
self._is_enhanced_voice_roaming = roaming
|
|
|
|
def isEndcAvailable(self) -> bool:
|
|
return self._is_endc_available
|
|
|
|
def setEndcAvailable(self, available: bool):
|
|
self._is_endc_available = available
|
|
|
|
def getMaxDataConnectivity(self) -> int:
|
|
return self._max_data_connectivity
|
|
|
|
def setMaxDataConnectivity(self, max_: int):
|
|
self._max_data_connectivity = max_
|
|
|
|
def isNrAvailable(self) -> bool:
|
|
return self._nr_available
|
|
|
|
def setNrAvailable(self, available: bool):
|
|
self._nr_available = available
|
|
|
|
def isEnDcAvailable(self) -> bool:
|
|
return self._en_dc_available
|
|
|
|
def setEnDcAvailable(self, available: bool):
|
|
self._en_dc_available = available
|
|
|
|
def isVoiceOverNr(self) -> bool:
|
|
return self._voice_over_nr
|
|
|
|
def setVoiceOverNr(self, voice_over_nr: bool):
|
|
self._voice_over_nr = voice_over_nr
|
|
|
|
def getRegistrationNetworkType(self) -> int:
|
|
return self._registration_network_type
|
|
|
|
def setRegistrationNetworkType(self, type_: int):
|
|
self._registration_network_type = type_
|
|
|
|
def getVoiceRegistrationNetworkType(self) -> int:
|
|
return self._voice_registration_network_type
|
|
|
|
def setVoiceRegistrationNetworkType(self, type_: int):
|
|
self._voice_registration_network_type = type_
|
|
|
|
def getAvailableServices(self) -> Set[int]:
|
|
return set(self._available_services)
|
|
|
|
def setAvailableServices(self, services: Set[int]):
|
|
self._available_services = set(services)
|
|
|
|
def toString(self) -> str:
|
|
return f"DataSpecificRegistrationInfo(nr={self._nr_available}, dcNr={self._is_dc_over_nr})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# NetworkSlicingConfig
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class NetworkSlicingConfig(Stub):
|
|
"""NetworkSlicingConfig — 网络切片配置"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._ursp_rules: List[UrspRule] = []
|
|
self._nssais: List[Nssai] = []
|
|
self._configured_s_nssais: List[Any] = []
|
|
self._requested_s_nssais: List[Any] = []
|
|
self._allowed_s_nssais: List[Any] = []
|
|
self._default_s_nssai: Any = None
|
|
self._mapped_hplmn_s_nssais: List[Any] = []
|
|
self._rejected_s_nssais: List[Any] = []
|
|
|
|
def getUrspRules(self) -> List[UrspRule]:
|
|
return list(self._ursp_rules)
|
|
|
|
def setUrspRules(self, rules: List[UrspRule]):
|
|
self._ursp_rules = list(rules)
|
|
|
|
def getNssais(self) -> List[Nssai]:
|
|
return list(self._nssais)
|
|
|
|
def setNssais(self, nssais: List[Nssai]):
|
|
self._nssais = list(nssais)
|
|
|
|
def getConfiguredSNssais(self) -> List[Any]:
|
|
return list(self._configured_s_nssais)
|
|
|
|
def setConfiguredSNssais(self, nssais: List[Any]):
|
|
self._configured_s_nssais = list(nssais)
|
|
|
|
def getRequestedSNssais(self) -> List[Any]:
|
|
return list(self._requested_s_nssais)
|
|
|
|
def setRequestedSNssais(self, nssais: List[Any]):
|
|
self._requested_s_nssais = list(nssais)
|
|
|
|
def addUrspRule(self, rule: UrspRule):
|
|
self._ursp_rules.append(rule)
|
|
|
|
def addNssai(self, nssai: Nssai):
|
|
self._nssais.append(nssai)
|
|
|
|
def toString(self) -> str:
|
|
return f"NetworkSlicingConfig(ursp={len(self._ursp_rules)}, nssais={len(self._nssais)})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# UrspRule
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class UrspRule(Stub):
|
|
"""UrspRule — URSP (UE Route Selection Policy) 规则"""
|
|
|
|
def __init__(self, precedence: int = 0, rule_id: int = 0):
|
|
super().__init__()
|
|
self._precedence = precedence
|
|
self._rule_id = rule_id
|
|
self._traffic_descriptors: List[TrafficDescriptor] = []
|
|
self._route_selection_descriptors: List[RouteSelectionDescriptor] = []
|
|
|
|
def getPrecedence(self) -> int:
|
|
return self._precedence
|
|
|
|
def setPrecedence(self, precedence: int):
|
|
self._precedence = precedence
|
|
|
|
def getRuleId(self) -> int:
|
|
return self._rule_id
|
|
|
|
def setRuleId(self, rule_id: int):
|
|
self._rule_id = rule_id
|
|
|
|
def getTrafficDescriptors(self) -> List[TrafficDescriptor]:
|
|
return list(self._traffic_descriptors)
|
|
|
|
def setTrafficDescriptors(self, descriptors: List[TrafficDescriptor]):
|
|
self._traffic_descriptors = list(descriptors)
|
|
|
|
def getRouteSelectionDescriptors(self) -> List[RouteSelectionDescriptor]:
|
|
return list(self._route_selection_descriptors)
|
|
|
|
def setRouteSelectionDescriptors(self, descriptors: List[RouteSelectionDescriptor]):
|
|
self._route_selection_descriptors = list(descriptors)
|
|
|
|
def addTrafficDescriptor(self, descriptor: TrafficDescriptor):
|
|
self._traffic_descriptors.append(descriptor)
|
|
|
|
def addRouteSelectionDescriptor(self, descriptor: RouteSelectionDescriptor):
|
|
self._route_selection_descriptors.append(descriptor)
|
|
|
|
def toString(self) -> str:
|
|
return f"UrspRule(id={self._rule_id}, precedence={self._precedence})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# TrafficDescriptor
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class TrafficDescriptor(Stub):
|
|
"""TrafficDescriptor — 流量描述符"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._dnn: str = ""
|
|
self._os_app_id: str = ""
|
|
self._fqdn: str = ""
|
|
self._ip_descriptors: List[Any] = []
|
|
self._domain_descriptors: List[Any] = []
|
|
self._connection_capabilities: List[int] = []
|
|
|
|
def getDnn(self) -> str:
|
|
return self._dnn
|
|
|
|
def setDnn(self, dnn: str):
|
|
self._dnn = dnn
|
|
|
|
def getOsAppId(self) -> str:
|
|
return self._os_app_id
|
|
|
|
def setOsAppId(self, app_id: str):
|
|
self._os_app_id = app_id
|
|
|
|
def getFqdn(self) -> str:
|
|
return self._fqdn
|
|
|
|
def setFqdn(self, fqdn: str):
|
|
self._fqdn = fqdn
|
|
|
|
def getIpDescriptors(self) -> List[Any]:
|
|
return list(self._ip_descriptors)
|
|
|
|
def setIpDescriptors(self, descriptors: List[Any]):
|
|
self._ip_descriptors = list(descriptors)
|
|
|
|
def getDomainDescriptors(self) -> List[Any]:
|
|
return list(self._domain_descriptors)
|
|
|
|
def setDomainDescriptors(self, descriptors: List[Any]):
|
|
self._domain_descriptors = list(descriptors)
|
|
|
|
def getConnectionCapabilities(self) -> List[int]:
|
|
return list(self._connection_capabilities)
|
|
|
|
def setConnectionCapabilities(self, caps: List[int]):
|
|
self._connection_capabilities = list(caps)
|
|
|
|
def toString(self) -> str:
|
|
return f"TrafficDescriptor(dnn={self._dnn})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# RouteSelectionDescriptor
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class RouteSelectionDescriptor(Stub):
|
|
"""RouteSelectionDescriptor — 路由选择描述符"""
|
|
|
|
SSC_MODE_1 = 1
|
|
SSC_MODE_2 = 2
|
|
SSC_MODE_3 = 3
|
|
SSC_MODE_UNKNOWN = 0
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._ssc_mode: int = RouteSelectionDescriptor.SSC_MODE_UNKNOWN
|
|
self._s_nssai: Optional[Any] = None
|
|
self._dnn: str = ""
|
|
self._route_selection_info: bytes = b""
|
|
self._precedence: int = 0
|
|
self._pdu_session_type: int = 0
|
|
self._access_type: int = 0
|
|
self._data_network_name: str = ""
|
|
|
|
def getSscMode(self) -> int:
|
|
return self._ssc_mode
|
|
|
|
def setSscMode(self, mode: int):
|
|
self._ssc_mode = mode
|
|
|
|
def getSNssai(self) -> Optional[Any]:
|
|
return self._s_nssai
|
|
|
|
def setSNssai(self, nssai: Any):
|
|
self._s_nssai = nssai
|
|
|
|
def getDnn(self) -> str:
|
|
return self._dnn
|
|
|
|
def setDnn(self, dnn: str):
|
|
self._dnn = dnn
|
|
|
|
def getPrecedence(self) -> int:
|
|
return self._precedence
|
|
|
|
def setPrecedence(self, prec: int):
|
|
self._precedence = prec
|
|
|
|
def getPduSessionType(self) -> int:
|
|
return self._pdu_session_type
|
|
|
|
def setPduSessionType(self, type_: int):
|
|
self._pdu_session_type = type_
|
|
|
|
def toString(self) -> str:
|
|
return f"RouteSelectionDescriptor(sscMode={self._ssc_mode}, dnn={self._dnn})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# Nssai
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class Nssai(Stub):
|
|
"""Nssai — 网络切片选择辅助信息"""
|
|
|
|
SST_EMBB = 1
|
|
SST_URLLC = 2
|
|
SST_MIOT = 3
|
|
SST_V2X = 4
|
|
|
|
def __init__(self, sst: int = 0, sd: int = 0):
|
|
super().__init__()
|
|
self._sst = sst
|
|
self._sd = sd
|
|
self._sd_string: str = ""
|
|
self._mapped_hplmn_sst: int = 0
|
|
self._mapped_hplmn_sd: int = 0
|
|
|
|
def getSst(self) -> int:
|
|
return self._sst
|
|
|
|
def setSst(self, sst: int):
|
|
self._sst = sst
|
|
|
|
def getSd(self) -> int:
|
|
return self._sd
|
|
|
|
def setSd(self, sd: int):
|
|
self._sd = sd
|
|
|
|
def getSdString(self) -> str:
|
|
return self._sd_string
|
|
|
|
def setSdString(self, sd_str: str):
|
|
self._sd_string = sd_str
|
|
|
|
def getMappedHplmnSst(self) -> int:
|
|
return self._mapped_hplmn_sst
|
|
|
|
def setMappedHplmnSst(self, sst: int):
|
|
self._mapped_hplmn_sst = sst
|
|
|
|
def getMappedHplmnSd(self) -> int:
|
|
return self._mapped_hplmn_sd
|
|
|
|
def setMappedHplmnSd(self, sd: int):
|
|
self._mapped_hplmn_sd = sd
|
|
|
|
def toString(self) -> str:
|
|
return f"Nssai(sst={self._sst}, sd={self._sd})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# TelephonyManager.Data
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class TelephonyManager_Data(Stub):
|
|
"""TelephonyManager.Data — TelephonyManager 数据相关子类"""
|
|
|
|
DATA_DISCONNECTED = 0
|
|
DATA_CONNECTING = 1
|
|
DATA_CONNECTED = 2
|
|
DATA_SUSPENDED = 3
|
|
DATA_HANDOVER_IN_PROGRESS = 4
|
|
DATA_UNKNOWN = -1
|
|
|
|
DATA_ACTIVITY_NONE = 0
|
|
DATA_ACTIVITY_IN = 1
|
|
DATA_ACTIVITY_OUT = 2
|
|
DATA_ACTIVITY_INOUT = 3
|
|
DATA_ACTIVITY_DORMANT = 4
|
|
|
|
def __init__(self, telephony_manager: Any = None):
|
|
super().__init__()
|
|
self._manager = telephony_manager
|
|
self._data_connections: Dict[int, DataConnection] = {}
|
|
self._data_state: int = TelephonyManager_Data.DATA_DISCONNECTED
|
|
|
|
def getDataState(self) -> int:
|
|
return self._data_state
|
|
|
|
def setDataState(self, state: int):
|
|
self._data_state = state
|
|
|
|
def getDataActivity(self) -> int:
|
|
return TelephonyManager_Data.DATA_ACTIVITY_NONE
|
|
|
|
def getDataConnections(self) -> List[DataConnection]:
|
|
return list(self._data_connections.values())
|
|
|
|
def getDataConnection(self, cid: int) -> Optional[DataConnection]:
|
|
return self._data_connections.get(cid)
|
|
|
|
def addDataConnection(self, conn: DataConnection):
|
|
self._data_connections[conn.getCid()] = conn
|
|
|
|
def removeDataConnection(self, cid: int):
|
|
self._data_connections.pop(cid, None)
|
|
|
|
def isDataEnabled(self) -> bool:
|
|
return True
|
|
|
|
def isDataRoamingEnabled(self) -> bool:
|
|
return False
|
|
|
|
def getDataNetworkType(self) -> int:
|
|
return 0
|
|
|
|
def toString(self) -> str:
|
|
return f"TelephonyManager.Data(state={self._data_state})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataFailCause
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataFailCause(Stub):
|
|
"""DataFailCause — 数据连接失败原因码"""
|
|
|
|
NONE = 0
|
|
OPERATOR_BARRED = 8
|
|
INSUFFICIENT_RESOURCES = 26
|
|
MISSING_UKNOWN_APN = 27
|
|
UNKNOWN_PDP_ADDRESS_TYPE = 28
|
|
USER_AUTHENTICATION = 29
|
|
ACTIVATION_REJECT_GGSN = 30
|
|
ACTIVATION_REJECT_UNSPECIFIED = 31
|
|
SERVICE_OPTION_NOT_SUPPORTED = 32
|
|
SERVICE_OPTION_NOT_SUBSCRIBED = 33
|
|
SERVICE_OPTION_OUT_OF_ORDER = 34
|
|
NSAPI_IN_USE = 35
|
|
REGULAR_DEACTIVATION = 36
|
|
QOS_NOT_ACCEPTED = 37
|
|
NETWORK_FAILURE = 38
|
|
REACTIVATION_REQUESTED = 39
|
|
PDP_DUPLICATE = 40
|
|
PDP_AUTH_FAILURE = 41
|
|
MAX_ACTIVE_PDP_CONTEXT_REACHED = 65
|
|
UNSUPPORTED_APN_IN_CURRENT_PLMN = 66
|
|
INVALID_TRANSACTION_ID = 81
|
|
MESSAGE_INCORRECT_SEMANTIC = 83
|
|
INVALID_MANDATORY_INFO = 84
|
|
MESSAGE_TYPE_UNSUPPORTED = 97
|
|
MSG_TYPE_NONCOMPATIBLE_STATE = 98
|
|
UNKNOWN_INFO_ELEMENT = 99
|
|
CONDITIONAL_IE_ERROR = 100
|
|
PROTOCOL_ERRORS = 111
|
|
APN_TYPE_CONFLICT = 112
|
|
INVALID_PCO = 113
|
|
INTERNAL_RETRY = 114
|
|
PDP_ACTIVATE_MAX_RETRY_FAILED = 115
|
|
RADIO_ACCESS_BEARER_FAILURE = 116
|
|
RADIO_ACCESS_BEARER_SETUP_FAILURE = 117
|
|
RADIO_ACCESS_BEARER_RELEASE_FAILURE = 118
|
|
PDP_MODIFY_FAILURE = 119
|
|
MAX_ACTIVE_NETWORK_TYPE = 120
|
|
ONLY_SINGLE_BEARER_ALLOWED = 121
|
|
ERROR_UNSPECIFIED = 65535
|
|
|
|
@staticmethod
|
|
def toString(cause: int) -> str:
|
|
names = {v: k for k, v in DataFailCause.__dict__.items()
|
|
if isinstance(v, int) and not k.startswith("_")}
|
|
return names.get(cause, f"UNKNOWN({cause})")
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataServiceProvider
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataServiceProvider(Stub):
|
|
"""DataServiceProvider — 数据服务提供商"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._name: str = ""
|
|
self._plmn: str = ""
|
|
self._is_roaming: bool = False
|
|
self._is_registered: bool = False
|
|
|
|
def getName(self) -> str:
|
|
return self._name
|
|
|
|
def setName(self, name: str):
|
|
self._name = name
|
|
|
|
def getPlmn(self) -> str:
|
|
return self._plmn
|
|
|
|
def setPlmn(self, plmn: str):
|
|
self._plmn = plmn
|
|
|
|
def isRoaming(self) -> bool:
|
|
return self._is_roaming
|
|
|
|
def setRoaming(self, roaming: bool):
|
|
self._is_roaming = roaming
|
|
|
|
def isRegistered(self) -> bool:
|
|
return self._is_registered
|
|
|
|
def setRegistered(self, registered: bool):
|
|
self._is_registered = registered
|
|
|
|
def toString(self) -> str:
|
|
return f"DataServiceProvider(name={self._name}, plmn={self._plmn})"
|
|
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DataRegistrationState (helper)
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
class DataRegistrationState(Stub):
|
|
"""DataRegistrationState — 数据注册状态"""
|
|
|
|
REGISTRATION_STATE_NOT_REGISTERED = 0
|
|
REGISTRATION_STATE_REGISTERED_HOME = 1
|
|
REGISTRATION_STATE_REGISTERED_ROAMING = 2
|
|
REGISTRATION_STATE_REGISTERED_NOT_KNOWN = 3
|
|
REGISTRATION_STATE_DENIED = 4
|
|
REGISTRATION_STATE_UNKNOWN = 5
|
|
REGISTRATION_STATE_SCANNING = 6
|
|
|
|
def __init__(self, state: int = REGISTRATION_STATE_UNKNOWN):
|
|
super().__init__()
|
|
self._state = state
|
|
self._domain: int = 0
|
|
self._transport_type: int = 0
|
|
self._specific_info: Optional[DataSpecificRegistrationInfo] = None
|
|
self._rat: int = 0
|
|
self._reason_for_denial: int = 0
|
|
|
|
def getState(self) -> int:
|
|
return self._state
|
|
|
|
def setState(self, state: int):
|
|
self._state = state
|
|
|
|
def getDomain(self) -> int:
|
|
return self._domain
|
|
|
|
def setDomain(self, domain: int):
|
|
self._domain = domain
|
|
|
|
def getTransportType(self) -> int:
|
|
return self._transport_type
|
|
|
|
def setTransportType(self, transport: int):
|
|
self._transport_type = transport
|
|
|
|
def getSpecificInfo(self) -> Optional[DataSpecificRegistrationInfo]:
|
|
return self._specific_info
|
|
|
|
def setSpecificInfo(self, info: DataSpecificRegistrationInfo):
|
|
self._specific_info = info
|
|
|
|
def getRat(self) -> int:
|
|
return self._rat
|
|
|
|
def setRat(self, rat: int):
|
|
self._rat = rat
|
|
|
|
def isRegistered(self) -> bool:
|
|
return self._state in (DataRegistrationState.REGISTRATION_STATE_REGISTERED_HOME,
|
|
DataRegistrationState.REGISTRATION_STATE_REGISTERED_ROAMING)
|
|
|
|
def toString(self) -> str:
|
|
return f"DataRegistrationState(state={self._state})" |