Skip to content

Commit

Permalink
companion: Fix credentials not saved
Browse files Browse the repository at this point in the history
Relates to #2216
  • Loading branch information
postlund committed Sep 27, 2023
1 parent 1c4b4d3 commit e551954
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pyatv/protocols/companion/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, core: Core, **kwargs):
self.protocol = CompanionProtocol(self.connection, self.srp, core.service)
self.pairing_procedure = CompanionPairSetupProcedure(self.protocol, self.srp)
self.pin_code: Optional[str] = None
self._settings = core.settings
self._has_paired: bool = False

async def close(self) -> None:
Expand Down Expand Up @@ -62,6 +63,7 @@ async def finish(self) -> None:
self._name,
)
)
self._settings.protocols.companion.credentials = self.service.credentials
self._has_paired = True

@property
Expand Down
12 changes: 12 additions & 0 deletions pyatv/protocols/mrp/protobuf/DeviceInfoMessage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ extend ProtocolMessage {
optional DeviceInfoMessage deviceInfoMessage = 20;
}

message PreferredEncoding {
enum Enum {
Default = 0;
JSON = 1;
}
}

message DeviceInfoMessage {
optional string uniqueIdentifier = 1; // Example: B8D8678C-9DA9-4D29-9338-5D6B827B8063
required string name = 2; // Example: Jean's iPhone
Expand Down Expand Up @@ -54,4 +61,9 @@ message DeviceInfoMessage {
optional uint32 parentGroupContainsDiscoverableGroupLeader = 45;
optional uint32 groupContainsDiscoverableGroupLeader = 46;
optional uint32 lastKnownClusterType = 47;
// repeated ... allClusteredDevices = 48;
optional bool supportsOutputContextSync = 49;
optional string computerName = 50;
optional uint32 configuredClusterSize = 51;
optional PreferredEncoding.Enum preferredEncoding = 52;
}
10 changes: 7 additions & 3 deletions pyatv/protocols/mrp/protobuf/DeviceInfoMessage_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 41 additions & 3 deletions pyatv/protocols/mrp/protobuf/DeviceInfoMessage_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,44 @@ import builtins
import collections.abc
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.internal.enum_type_wrapper
import google.protobuf.internal.extension_dict
import google.protobuf.message
import pyatv.protocols.mrp.protobuf.Common_pb2
import pyatv.protocols.mrp.protobuf.ProtocolMessage_pb2
import sys
import typing

if sys.version_info >= (3, 8):
if sys.version_info >= (3, 10):
import typing as typing_extensions
else:
import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing_extensions.final
class PreferredEncoding(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class _Enum:
ValueType = typing.NewType("ValueType", builtins.int)
V: typing_extensions.TypeAlias = ValueType

class _EnumEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[PreferredEncoding._Enum.ValueType], builtins.type): # noqa: F821
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
Default: PreferredEncoding._Enum.ValueType # 0
JSON: PreferredEncoding._Enum.ValueType # 1

class Enum(_Enum, metaclass=_EnumEnumTypeWrapper): ...
Default: PreferredEncoding.Enum.ValueType # 0
JSON: PreferredEncoding.Enum.ValueType # 1

def __init__(
self,
) -> None: ...

global___PreferredEncoding = PreferredEncoding

@typing_extensions.final
class DeviceInfoMessage(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand Down Expand Up @@ -69,6 +94,10 @@ class DeviceInfoMessage(google.protobuf.message.Message):
PARENTGROUPCONTAINSDISCOVERABLEGROUPLEADER_FIELD_NUMBER: builtins.int
GROUPCONTAINSDISCOVERABLEGROUPLEADER_FIELD_NUMBER: builtins.int
LASTKNOWNCLUSTERTYPE_FIELD_NUMBER: builtins.int
SUPPORTSOUTPUTCONTEXTSYNC_FIELD_NUMBER: builtins.int
COMPUTERNAME_FIELD_NUMBER: builtins.int
CONFIGUREDCLUSTERSIZE_FIELD_NUMBER: builtins.int
PREFERREDENCODING_FIELD_NUMBER: builtins.int
uniqueIdentifier: builtins.str
"""Example: B8D8678C-9DA9-4D29-9338-5D6B827B8063"""
name: builtins.str
Expand Down Expand Up @@ -128,6 +157,11 @@ class DeviceInfoMessage(google.protobuf.message.Message):
parentGroupContainsDiscoverableGroupLeader: builtins.int
groupContainsDiscoverableGroupLeader: builtins.int
lastKnownClusterType: builtins.int
supportsOutputContextSync: builtins.bool
"""repeated ... allClusteredDevices = 48;"""
computerName: builtins.str
configuredClusterSize: builtins.int
preferredEncoding: global___PreferredEncoding.Enum.ValueType
def __init__(
self,
*,
Expand Down Expand Up @@ -177,9 +211,13 @@ class DeviceInfoMessage(google.protobuf.message.Message):
parentGroupContainsDiscoverableGroupLeader: builtins.int | None = ...,
groupContainsDiscoverableGroupLeader: builtins.int | None = ...,
lastKnownClusterType: builtins.int | None = ...,
supportsOutputContextSync: builtins.bool | None = ...,
computerName: builtins.str | None = ...,
configuredClusterSize: builtins.int | None = ...,
preferredEncoding: global___PreferredEncoding.Enum.ValueType | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["airPlayGroupID", b"airPlayGroupID", "allowsPairing", b"allowsPairing", "applicationBundleIdentifier", b"applicationBundleIdentifier", "applicationBundleVersion", b"applicationBundleVersion", "bluetoothAddress", b"bluetoothAddress", "clusterID", b"clusterID", "clusterLeaderID", b"clusterLeaderID", "clusterType", b"clusterType", "connected", b"connected", "deviceClass", b"deviceClass", "deviceUID", b"deviceUID", "groupContainsDiscoverableGroupLeader", b"groupContainsDiscoverableGroupLeader", "groupName", b"groupName", "groupUID", b"groupUID", "isAirplayActive", b"isAirplayActive", "isClusterAware", b"isClusterAware", "isGroupLeader", b"isGroupLeader", "isProxyGroupPlayer", b"isProxyGroupPlayer", "lastKnownClusterType", b"lastKnownClusterType", "lastSupportedMessageType", b"lastSupportedMessageType", "linkAgent", b"linkAgent", "localizedModelName", b"localizedModelName", "logicalDeviceCount", b"logicalDeviceCount", "managedConfigDeviceID", b"managedConfigDeviceID", "modelID", b"modelID", "name", b"name", "parentGroupContainsDiscoverableGroupLeader", b"parentGroupContainsDiscoverableGroupLeader", "protocolVersion", b"protocolVersion", "routingContextID", b"routingContextID", "senderDefaultGroupUID", b"senderDefaultGroupUID", "sharedQueueVersion", b"sharedQueueVersion", "supportsACL", b"supportsACL", "supportsExtendedMotion", b"supportsExtendedMotion", "supportsMultiplayer", b"supportsMultiplayer", "supportsSharedQueue", b"supportsSharedQueue", "supportsSystemPairing", b"supportsSystemPairing", "systemBooksApplication", b"systemBooksApplication", "systemBuildVersion", b"systemBuildVersion", "systemMediaApplication", b"systemMediaApplication", "systemPodcastApplication", b"systemPodcastApplication", "tightSyncUID", b"tightSyncUID", "tightlySyncedGroup", b"tightlySyncedGroup", "uniqueIdentifier", b"uniqueIdentifier"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["airPlayGroupID", b"airPlayGroupID", "airplayReceivers", b"airplayReceivers", "allowsPairing", b"allowsPairing", "applicationBundleIdentifier", b"applicationBundleIdentifier", "applicationBundleVersion", b"applicationBundleVersion", "bluetoothAddress", b"bluetoothAddress", "clusterID", b"clusterID", "clusterLeaderID", b"clusterLeaderID", "clusterType", b"clusterType", "clusteredDevices", b"clusteredDevices", "connected", b"connected", "deviceClass", b"deviceClass", "deviceUID", b"deviceUID", "groupContainsDiscoverableGroupLeader", b"groupContainsDiscoverableGroupLeader", "groupName", b"groupName", "groupUID", b"groupUID", "groupedDevices", b"groupedDevices", "isAirplayActive", b"isAirplayActive", "isClusterAware", b"isClusterAware", "isGroupLeader", b"isGroupLeader", "isProxyGroupPlayer", b"isProxyGroupPlayer", "lastKnownClusterType", b"lastKnownClusterType", "lastSupportedMessageType", b"lastSupportedMessageType", "linkAgent", b"linkAgent", "localizedModelName", b"localizedModelName", "logicalDeviceCount", b"logicalDeviceCount", "managedConfigDeviceID", b"managedConfigDeviceID", "modelID", b"modelID", "name", b"name", "parentGroupContainsDiscoverableGroupLeader", b"parentGroupContainsDiscoverableGroupLeader", "protocolVersion", b"protocolVersion", "routingContextID", b"routingContextID", "senderDefaultGroupUID", b"senderDefaultGroupUID", "sharedQueueVersion", b"sharedQueueVersion", "supportsACL", b"supportsACL", "supportsExtendedMotion", b"supportsExtendedMotion", "supportsMultiplayer", b"supportsMultiplayer", "supportsSharedQueue", b"supportsSharedQueue", "supportsSystemPairing", b"supportsSystemPairing", "systemBooksApplication", b"systemBooksApplication", "systemBuildVersion", b"systemBuildVersion", "systemMediaApplication", b"systemMediaApplication", "systemPodcastApplication", b"systemPodcastApplication", "tightSyncUID", b"tightSyncUID", "tightlySyncedGroup", b"tightlySyncedGroup", "uniqueIdentifier", b"uniqueIdentifier"]) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["airPlayGroupID", b"airPlayGroupID", "allowsPairing", b"allowsPairing", "applicationBundleIdentifier", b"applicationBundleIdentifier", "applicationBundleVersion", b"applicationBundleVersion", "bluetoothAddress", b"bluetoothAddress", "clusterID", b"clusterID", "clusterLeaderID", b"clusterLeaderID", "clusterType", b"clusterType", "computerName", b"computerName", "configuredClusterSize", b"configuredClusterSize", "connected", b"connected", "deviceClass", b"deviceClass", "deviceUID", b"deviceUID", "groupContainsDiscoverableGroupLeader", b"groupContainsDiscoverableGroupLeader", "groupName", b"groupName", "groupUID", b"groupUID", "isAirplayActive", b"isAirplayActive", "isClusterAware", b"isClusterAware", "isGroupLeader", b"isGroupLeader", "isProxyGroupPlayer", b"isProxyGroupPlayer", "lastKnownClusterType", b"lastKnownClusterType", "lastSupportedMessageType", b"lastSupportedMessageType", "linkAgent", b"linkAgent", "localizedModelName", b"localizedModelName", "logicalDeviceCount", b"logicalDeviceCount", "managedConfigDeviceID", b"managedConfigDeviceID", "modelID", b"modelID", "name", b"name", "parentGroupContainsDiscoverableGroupLeader", b"parentGroupContainsDiscoverableGroupLeader", "preferredEncoding", b"preferredEncoding", "protocolVersion", b"protocolVersion", "routingContextID", b"routingContextID", "senderDefaultGroupUID", b"senderDefaultGroupUID", "sharedQueueVersion", b"sharedQueueVersion", "supportsACL", b"supportsACL", "supportsExtendedMotion", b"supportsExtendedMotion", "supportsMultiplayer", b"supportsMultiplayer", "supportsOutputContextSync", b"supportsOutputContextSync", "supportsSharedQueue", b"supportsSharedQueue", "supportsSystemPairing", b"supportsSystemPairing", "systemBooksApplication", b"systemBooksApplication", "systemBuildVersion", b"systemBuildVersion", "systemMediaApplication", b"systemMediaApplication", "systemPodcastApplication", b"systemPodcastApplication", "tightSyncUID", b"tightSyncUID", "tightlySyncedGroup", b"tightlySyncedGroup", "uniqueIdentifier", b"uniqueIdentifier"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["airPlayGroupID", b"airPlayGroupID", "airplayReceivers", b"airplayReceivers", "allowsPairing", b"allowsPairing", "applicationBundleIdentifier", b"applicationBundleIdentifier", "applicationBundleVersion", b"applicationBundleVersion", "bluetoothAddress", b"bluetoothAddress", "clusterID", b"clusterID", "clusterLeaderID", b"clusterLeaderID", "clusterType", b"clusterType", "clusteredDevices", b"clusteredDevices", "computerName", b"computerName", "configuredClusterSize", b"configuredClusterSize", "connected", b"connected", "deviceClass", b"deviceClass", "deviceUID", b"deviceUID", "groupContainsDiscoverableGroupLeader", b"groupContainsDiscoverableGroupLeader", "groupName", b"groupName", "groupUID", b"groupUID", "groupedDevices", b"groupedDevices", "isAirplayActive", b"isAirplayActive", "isClusterAware", b"isClusterAware", "isGroupLeader", b"isGroupLeader", "isProxyGroupPlayer", b"isProxyGroupPlayer", "lastKnownClusterType", b"lastKnownClusterType", "lastSupportedMessageType", b"lastSupportedMessageType", "linkAgent", b"linkAgent", "localizedModelName", b"localizedModelName", "logicalDeviceCount", b"logicalDeviceCount", "managedConfigDeviceID", b"managedConfigDeviceID", "modelID", b"modelID", "name", b"name", "parentGroupContainsDiscoverableGroupLeader", b"parentGroupContainsDiscoverableGroupLeader", "preferredEncoding", b"preferredEncoding", "protocolVersion", b"protocolVersion", "routingContextID", b"routingContextID", "senderDefaultGroupUID", b"senderDefaultGroupUID", "sharedQueueVersion", b"sharedQueueVersion", "supportsACL", b"supportsACL", "supportsExtendedMotion", b"supportsExtendedMotion", "supportsMultiplayer", b"supportsMultiplayer", "supportsOutputContextSync", b"supportsOutputContextSync", "supportsSharedQueue", b"supportsSharedQueue", "supportsSystemPairing", b"supportsSystemPairing", "systemBooksApplication", b"systemBooksApplication", "systemBuildVersion", b"systemBuildVersion", "systemMediaApplication", b"systemMediaApplication", "systemPodcastApplication", b"systemPodcastApplication", "tightSyncUID", b"tightSyncUID", "tightlySyncedGroup", b"tightlySyncedGroup", "uniqueIdentifier", b"uniqueIdentifier"]) -> None: ...

global___DeviceInfoMessage = DeviceInfoMessage

Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/mrp/protobuf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
from .ContentItem_pb2 import LanguageOptionGroup
from .CryptoPairingMessage_pb2 import CryptoPairingMessage
from .DeviceInfoMessage_pb2 import DeviceInfoMessage
from .DeviceInfoMessage_pb2 import PreferredEncoding
from .GenericMessage_pb2 import GenericMessage
from .GetKeyboardSessionMessage_pb2 import GetKeyboardSessionMessage
from .GetRemoteTextInputSessionMessage_pb2 import GetRemoteTextInputSessionMessage
Expand Down

0 comments on commit e551954

Please sign in to comment.