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,268 @@
|
||||
"""
|
||||
Android People API — PeopleManager, ConversationStatus, PeopleManager.Person, PeopleManager.Conversation
|
||||
方法签名完全对齐 Android SDK
|
||||
"""
|
||||
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Callable
|
||||
|
||||
from .._core import Stub, AndroidOnlyError
|
||||
from ..java.lang import RuntimeException
|
||||
|
||||
|
||||
IllegalArgumentException = type("IllegalArgumentException", (RuntimeException,), {})
|
||||
|
||||
__all__ = [
|
||||
"PeopleManager",
|
||||
"ConversationStatus",
|
||||
]
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# PeopleManager
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
class PeopleManager(Stub):
|
||||
"""PeopleManager — 人物管理器 (桌面存根)"""
|
||||
|
||||
ACTION_PEOPLE_CONVERSATION = "android.app.people.action.PEOPLE_CONVERSATION"
|
||||
ACTION_REMOVE_STATUS = "android.app.people.action.REMOVE_STATUS"
|
||||
|
||||
def __init__(self, context: Any = None):
|
||||
super().__init__()
|
||||
self._context = context
|
||||
self._statuses: Dict[str, "ConversationStatus"] = {}
|
||||
self._people: Dict[str, "PeopleManager.Person"] = {}
|
||||
self._conversations: Dict[str, "PeopleManager.Conversation"] = {}
|
||||
self._listeners: List[Callable] = []
|
||||
|
||||
def getStatus(self, packageName: str, personUri: str) -> Optional["ConversationStatus"]:
|
||||
"""获取指定人的状态"""
|
||||
key = f"{packageName}:{personUri}"
|
||||
return self._statuses.get(key)
|
||||
|
||||
def getDataIdFromPhoneNumber(self, phoneNumber: str) -> Optional[str]:
|
||||
"""根据电话号码获取数据 ID"""
|
||||
return None
|
||||
|
||||
def addOrUpdateStatus(
|
||||
self, packageName: str, status: "ConversationStatus"
|
||||
):
|
||||
"""添加或更新状态"""
|
||||
key = f"{packageName}:{status.getPersonUri()}"
|
||||
self._statuses[key] = status
|
||||
|
||||
def removeStatus(self, packageName: str, personUri: str):
|
||||
"""移除状态"""
|
||||
key = f"{packageName}:{personUri}"
|
||||
self._statuses.pop(key, None)
|
||||
|
||||
def getStoredPeople(self) -> List["PeopleManager.Person"]:
|
||||
"""获取已存储的人物列表"""
|
||||
return list(self._people.values())
|
||||
|
||||
def isConversation(self, packageName: str, personUri: str) -> bool:
|
||||
"""检查是否为对话"""
|
||||
key = f"{packageName}:{personUri}"
|
||||
return key in self._conversations
|
||||
|
||||
def getConversation(
|
||||
self, packageName: str, personUri: str
|
||||
) -> Optional["PeopleManager.Conversation"]:
|
||||
"""获取对话信息"""
|
||||
key = f"{packageName}:{personUri}"
|
||||
return self._conversations.get(key)
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# Status - 状态内部类
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class Status(Stub):
|
||||
"""PeopleManager.Status — 状态基类"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def toString(self) -> str:
|
||||
return f"Status@{hex(id(self))}"
|
||||
|
||||
def equals(self, other) -> bool:
|
||||
return self is other
|
||||
|
||||
def hashCode(self) -> int:
|
||||
return id(self) & 0x7FFFFFFF
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# Person - 人物内部类
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class Person(Stub):
|
||||
"""PeopleManager.Person — 人物信息"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str = "",
|
||||
key: str = "",
|
||||
uri: str = "",
|
||||
importantForPeople: bool = False,
|
||||
):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
self._key = key
|
||||
self._uri = uri
|
||||
self._important_for_people = importantForPeople
|
||||
|
||||
def getName(self) -> str:
|
||||
return self._name
|
||||
|
||||
def getKey(self) -> str:
|
||||
return self._key
|
||||
|
||||
def getUri(self) -> str:
|
||||
return self._uri
|
||||
|
||||
def getImportantForPeople(self) -> bool:
|
||||
return self._important_for_people
|
||||
|
||||
def toString(self) -> str:
|
||||
return f"Person(name={self._name}, key={self._key})"
|
||||
|
||||
def equals(self, other) -> bool:
|
||||
if not isinstance(other, PeopleManager.Person):
|
||||
return False
|
||||
return self._key == other._key
|
||||
|
||||
def hashCode(self) -> int:
|
||||
return hash(self._key) & 0x7FFFFFFF
|
||||
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
# Conversation - 对话内部类
|
||||
# ═══════════════════════════════════════════════════════════
|
||||
|
||||
class Conversation(Stub):
|
||||
"""PeopleManager.Conversation — 对话信息"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
conv_id: str = "",
|
||||
person: "PeopleManager.Person" = None,
|
||||
notificationChannelId: str = "",
|
||||
shortcutInfo: Any = None,
|
||||
parentUserHandle: Any = None,
|
||||
):
|
||||
super().__init__()
|
||||
self._id = conv_id
|
||||
self._person = person
|
||||
self._notification_channel_id = notificationChannelId
|
||||
self._shortcut_info = shortcutInfo
|
||||
self._parent_user_handle = parentUserHandle
|
||||
|
||||
def getId(self) -> str:
|
||||
return self._id
|
||||
|
||||
def getPerson(self) -> Optional["PeopleManager.Person"]:
|
||||
return self._person
|
||||
|
||||
def getNotificationChannelId(self) -> str:
|
||||
return self._notification_channel_id
|
||||
|
||||
def getShortcutInfo(self) -> Optional[Any]:
|
||||
return self._shortcut_info
|
||||
|
||||
def getParentUserHandle(self) -> Optional[Any]:
|
||||
return self._parent_user_handle
|
||||
|
||||
def toString(self) -> str:
|
||||
return f"Conversation(id={self._id})"
|
||||
|
||||
def equals(self, other) -> bool:
|
||||
if not isinstance(other, PeopleManager.Conversation):
|
||||
return False
|
||||
return self._id == other._id
|
||||
|
||||
def hashCode(self) -> int:
|
||||
return hash(self._id) & 0x7FFFFFFF
|
||||
|
||||
def toString(self) -> str:
|
||||
return f"PeopleManager@{hex(id(self))}"
|
||||
|
||||
def equals(self, other) -> bool:
|
||||
return self is other
|
||||
|
||||
def hashCode(self) -> int:
|
||||
return id(self) & 0x7FFFFFFF
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ConversationStatus
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
class ConversationStatus(Stub):
|
||||
"""ConversationStatus — 对话状态"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
userId: int = 0,
|
||||
packageName: str = "",
|
||||
personUri: str = "",
|
||||
status: int = 0,
|
||||
statusIcon: int = 0,
|
||||
notificationKey: str = "",
|
||||
notificationContentDescription: str = "",
|
||||
):
|
||||
super().__init__()
|
||||
self._user_id = userId
|
||||
self._package_name = packageName
|
||||
self._person_uri = personUri
|
||||
self._status = status
|
||||
self._status_icon = statusIcon
|
||||
self._notification_key = notificationKey
|
||||
self._notification_content_description = notificationContentDescription
|
||||
self._active = False
|
||||
self._muted = False
|
||||
|
||||
def getUserId(self) -> int:
|
||||
return self._user_id
|
||||
|
||||
def getPackageName(self) -> str:
|
||||
return self._package_name
|
||||
|
||||
def getPersonUri(self) -> str:
|
||||
return self._person_uri
|
||||
|
||||
def getStatus(self) -> int:
|
||||
return self._status
|
||||
|
||||
def getStatusIcon(self) -> int:
|
||||
return self._status_icon
|
||||
|
||||
def getNotificationKey(self) -> str:
|
||||
return self._notification_key
|
||||
|
||||
def getNotificationContentDescription(self) -> str:
|
||||
return self._notification_content_description
|
||||
|
||||
def isActive(self) -> bool:
|
||||
return self._active
|
||||
|
||||
def isMuted(self) -> bool:
|
||||
return self._muted
|
||||
|
||||
def setActive(self, active: bool):
|
||||
self._active = active
|
||||
|
||||
def setMuted(self, muted: bool):
|
||||
self._muted = muted
|
||||
|
||||
def toString(self) -> str:
|
||||
return (f"ConversationStatus(pkg={self._package_name}, "
|
||||
f"uri={self._person_uri}, active={self._active})")
|
||||
|
||||
def equals(self, other) -> bool:
|
||||
if not isinstance(other, ConversationStatus):
|
||||
return False
|
||||
return (self._package_name == other._package_name
|
||||
and self._person_uri == other._person_uri)
|
||||
|
||||
def hashCode(self) -> int:
|
||||
return hash((self._package_name, self._person_uri)) & 0x7FFFFFFF
|
||||
Reference in new issue
Block a user