feat: 新增 42 个 Android API 模块
新增模块覆盖: 系统层 (14): system, security, print, opengl, renderscript, transition, test, service_notification, service_controls, service_quicksettings, service_wallpaper, service_autofill, service_dreams, service_vr 应用层 (13): app_admin, app_backup, app_job, app_usage, app_role, app_people, appwidget, companion, credentials, mtp, sip, telecom, speech 硬件媒体层 (15): hardware_display, hardware_fingerprint, hardware_usb, hardware_input, media_audiofx, media_browse, media_session, media_tv, media_midi, media_projection, uwb, se, view_autofill, view_textclassifier, view_translation 总计 94 个模块,75,342 行代码
This commit is contained in:
1 parent
8ad62be068
commit
506f9ac725
43 files changed
+16704
-23
No files matched your search
@@ -0,0 +1,179 @@
|
||||
"""
|
||||
Android hardware.fingerprint 组件 — FingerprintManager, Fingerprint 等
|
||||
方法签名完全对齐 Android SDK
|
||||
"""
|
||||
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from .._core import Stub, AndroidOnlyError
|
||||
from ..java.lang import RuntimeException
|
||||
|
||||
|
||||
IllegalArgumentException = type("IllegalArgumentException", (RuntimeException,), {})
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# FingerprintManager
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
class FingerprintManager(Stub):
|
||||
"""FingerprintManager — 指纹管理器"""
|
||||
|
||||
FINGERPRINT_ACQUIRED_GOOD = 0
|
||||
FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3
|
||||
FINGERPRINT_ACQUIRED_INSUFFICIENT = 2
|
||||
FINGERPRINT_ACQUIRED_PARTIAL = 1
|
||||
FINGERPRINT_ACQUIRED_TOO_FAST = 5
|
||||
FINGERPRINT_ACQUIRED_TOO_SLOW = 4
|
||||
|
||||
FINGERPRINT_ERROR_HW_UNAVAILABLE = 1
|
||||
FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2
|
||||
FINGERPRINT_ERROR_TIMEOUT = 3
|
||||
FINGERPRINT_ERROR_NO_SPACE = 4
|
||||
FINGERPRINT_ERROR_CANCELED = 5
|
||||
FINGERPRINT_ERROR_LOCKOUT = 7
|
||||
FINGERPRINT_ERROR_VENDOR = 8
|
||||
FINGERPRINT_ERROR_USER_CANCELED = 10
|
||||
FINGERPRINT_ERROR_BAD_CALIBRATION = 11
|
||||
FINGERPRINT_ERROR_POWER_PRESS = 12
|
||||
FINGERPRINT_ERROR_IDLE_NOT_ENROLLED = 13
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# AuthenticationCallback
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class AuthenticationCallback(Stub):
|
||||
"""FingerprintManager.AuthenticationCallback — 认证回调"""
|
||||
|
||||
def onAuthenticationError(self, errorCode: int, errString: str):
|
||||
pass
|
||||
|
||||
def onAuthenticationHelp(self, helpCode: int, helpString: str):
|
||||
pass
|
||||
|
||||
def onAuthenticationSucceeded(self, result: "FingerprintManager.AuthenticationResult"):
|
||||
pass
|
||||
|
||||
def onAuthenticationFailed(self):
|
||||
pass
|
||||
|
||||
def onAuthenticationAcquired(self, acquireInfo: int):
|
||||
pass
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# AuthenticationResult
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class AuthenticationResult(Stub):
|
||||
"""FingerprintManager.AuthenticationResult — 认证结果"""
|
||||
|
||||
def __init__(self, fingerprint: "Fingerprint" = None,
|
||||
cryptoObject: "FingerprintManager.CryptoObject" = None):
|
||||
super().__init__()
|
||||
self._fingerprint = fingerprint
|
||||
self._crypto_object = cryptoObject
|
||||
|
||||
def getFingerprint(self) -> Optional["Fingerprint"]:
|
||||
return self._fingerprint
|
||||
|
||||
def getCryptoObject(self) -> Optional["FingerprintManager.CryptoObject"]:
|
||||
return self._crypto_object
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# CryptoObject
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class CryptoObject(Stub):
|
||||
"""FingerprintManager.CryptoObject — 加密对象"""
|
||||
|
||||
def __init__(self, cipher: Any = None, signature: Any = None, mac: Any = None):
|
||||
super().__init__()
|
||||
self._cipher = cipher
|
||||
self._signature = signature
|
||||
self._mac = mac
|
||||
|
||||
def getCipher(self) -> Any:
|
||||
return self._cipher
|
||||
|
||||
def getSignature(self) -> Any:
|
||||
return self._signature
|
||||
|
||||
def getMac(self) -> Any:
|
||||
return self._mac
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._enrolled_fingerprints: List[Fingerprint] = []
|
||||
self._callbacks: Dict[int, FingerprintManager.AuthenticationCallback] = {}
|
||||
|
||||
def isHardwareDetected(self) -> bool:
|
||||
return False
|
||||
|
||||
def hasEnrolledFingerprints(self) -> bool:
|
||||
return len(self._enrolled_fingerprints) > 0
|
||||
|
||||
def authenticate(self, crypto: Optional[CryptoObject] = None,
|
||||
cancel: Any = None, flags: int = 0,
|
||||
callback: Optional[AuthenticationCallback] = None,
|
||||
handler: Any = None):
|
||||
if callback:
|
||||
callback.onAuthenticationError(
|
||||
FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE,
|
||||
"Fingerprint hardware not available on desktop"
|
||||
)
|
||||
|
||||
def enroll(self, token: Any, userId: int = 0,
|
||||
callback: Optional[AuthenticationCallback] = None):
|
||||
raise AndroidOnlyError("FingerprintManager.enroll() is not available on desktop")
|
||||
|
||||
def remove(self, fingerprint: "Fingerprint", userId: int = 0):
|
||||
if fingerprint in self._enrolled_fingerprints:
|
||||
self._enrolled_fingerprints.remove(fingerprint)
|
||||
|
||||
def rename(self, fingerprint: "Fingerprint", newName: str):
|
||||
if fingerprint:
|
||||
fingerprint._name = newName
|
||||
|
||||
def getEnrolledFingerprints(self) -> List["Fingerprint"]:
|
||||
return list(self._enrolled_fingerprints)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# Fingerprint
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
class Fingerprint(Stub):
|
||||
"""Fingerprint — 指纹数据"""
|
||||
|
||||
def __init__(self, name: str = "", fingerId: int = 0, groupId: int = 0,
|
||||
deviceId: int = 0):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
self._finger_id = fingerId
|
||||
self._group_id = groupId
|
||||
self._device_id = deviceId
|
||||
|
||||
def getName(self) -> str:
|
||||
return self._name
|
||||
|
||||
def getFingerId(self) -> int:
|
||||
return self._finger_id
|
||||
|
||||
def getGroupId(self) -> int:
|
||||
return self._group_id
|
||||
|
||||
def getDeviceId(self) -> int:
|
||||
return self._device_id
|
||||
|
||||
def toString(self) -> str:
|
||||
return f"Fingerprint(name={self._name}, fingerId={self._finger_id})"
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# __all__
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
__all__ = [
|
||||
"FingerprintManager",
|
||||
"Fingerprint",
|
||||
]
|
||||
Reference in new issue
Block a user