Open DrR955 opened 1 month ago
Hello,
I'm surprised that the focus failed when no activity was running. But note that even if we succeeded in taking the focus out of an activity, it would probably cause the activity to stop working correctly. The QiSDK was not meant to be manipulated from outside of an Android application, and all of this is very subject to breaking.
The focus token is a mix of the Activity ID and an UUID if I recall correctly. However, I need to check if I'm permitted to share more information on that matter, as all of this is supposed to be private and internal API.
Thank you for your reply and the insight into the token structure. Since you were surprised about the case with no activity, I just retested it with a freshly booted robot. I also made sure that no previously opened applications were kept in memory (even though that shouldn't make a difference). Unfortunately, it resulted in the same exception. Maybe there is a default FocusOwner or something.
If it is not too much trouble, I would be very grateful if you could check whether you are allowed to share this information.
Follow-up to https://github.com/aldebaran/libqi-python/issues/26#issuecomment-2218316353 (so as not to interfere with #26).
Goal
Use this library to control a Pepper robot running on NAOqi 2.9 (QiSDK).
Problems
focus.take()
fails and causes the exeception from the title (tested while the tablet only had the launcher open, while a QiSDK app was running and while a default app - in this case Chrome - was running).focus.take has another overload that takes a String token as parameter to specify the owner of the current focus. However, I currently don't know how I would acquire said token. I've tried using both the package name of my QiSDK app as well as just the app name. But unfortunately neither worked.
Code
Logs
``` [V] 1720601125.123717 15670 qi.Application: Program path guessed as [W] 1720601125.123813 15670 qi.path.sdklayout: No Application was created, trying to deduce paths [V] 1720601125.123845 15670 qi.path.sdklayout: Prefix: bin [V] 1720601125.123848 15670 qi.path.sdklayout: Prefix: /usr [V] 1720601125.123902 15670 qi.applicationsession: Connect URL is now: tcps://192.168.1.59:9503 [V] 1720601125.123948 15670 qi.applicationsession: Listen URLs are now: tcp://127.0.0.1:0 [V] 1720601125.124100 15670 qi.eventloop: start: thread count limits: initial (minimum, maximum) before any adjustment = (-1, 0) [V] 1720601125.124155 15670 qi.eventloop: start: thread count limits: min <- 8 (read from environment variable QI_EVENTLOOP_MIN_THREADS, with default 8) [V] 1720601125.124161 15670 qi.eventloop: start: thread count limits: max <- 150 (read from environment variable QI_EVENTLOOP_MAX_THREADS, with default 150) [V] 1720601125.124164 15670 qi.eventloop: start: thread count limits: final (minimum, maximum) after potential adjustment = (8, 150) [V] 1720601125.124167 15670 qi.eventloop: start: number of threads that will be launched = 8 (between (min, max) = (8, 150)) [V] 1720601125.125973 15670 qitype.type: Shared pointer to unknown type N2qi13MessageSocketE, assuming object not yet registered [V] 1720601125.126032 15670 qitype.type: Shared pointer to unknown type N2qi13MessageSocketE, assuming object not yet registered [V] 1720601125.126505 15670 qitype.type: Shared pointer to unknown type N2qi13MessageSocketE, assuming object not yet registered [V] 1720601125.126505 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi16ServiceDirectoryE [V] 1720601125.126505 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi6FutureImEE [V] 1720601125.126633 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi6FutureINS_8AnyValueEEE [V] 1720601125.126790 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi11BoundObjectE [V] 1720601125.126887 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi10FutureSyncINS_8AnyValueEEE [V] 1720601125.127015 15670 qitype.type: registerType: access to type factory before registration detected for type N2qi7PromiseINS_8AnyValueEEE [V] 1720601125.127239 15670 qi.python.object: Registration of method __class__ is ignored as it is private. [V] 1720601125.127288 15670 qi.python.object: Registration of method __delattr__ is ignored as it is private. [V] 1720601125.127297 15670 qi.python.object: Registration of method __dir__ is ignored as it is private. [V] 1720601125.127301 15670 qi.python.object: The object attribute '__doc__' has value 'None', and will therefore be ignored. [V] 1720601125.127305 15670 qi.python.object: Registration of method __eq__ is ignored as it is private. [V] 1720601125.127309 15670 qi.python.object: Registration of method __format__ is ignored as it is private. [V] 1720601125.127314 15670 qi.python.object: Registration of method __ge__ is ignored as it is private. [V] 1720601125.127318 15670 qi.python.object: Registration of method __getattribute__ is ignored as it is private. [V] 1720601125.127356 15670 qi.python.object: Registration of method __gt__ is ignored as it is private. [V] 1720601125.127364 15670 qi.python.object: Registration of method __hash__ is ignored as it is private. [V] 1720601125.127371 15670 qi.python.object: Registration of method __init__ is ignored as it is private. [V] 1720601125.127376 15670 qi.python.object: Registration of method __init_subclass__ is ignored as it is private. [V] 1720601125.127381 15670 qi.python.object: Registration of method __le__ is ignored as it is private. [V] 1720601125.127696 15670 qi.python.object: Registration of method __lt__ is ignored as it is private. [V] 1720601125.127745 15670 qi.python.object: Registration of method __ne__ is ignored as it is private. [V] 1720601125.127753 15670 qi.python.object: Registration of method __new__ is ignored as it is private. [V] 1720601125.127757 15670 qi.python.object: Registration of method __reduce__ is ignored as it is private. [V] 1720601125.127761 15670 qi.python.object: Registration of method __reduce_ex__ is ignored as it is private. [V] 1720601125.127766 15670 qi.python.object: Registration of method __repr__ is ignored as it is private. [V] 1720601125.127771 15670 qi.python.object: Registration of method __setattr__ is ignored as it is private. [V] 1720601125.127775 15670 qi.python.object: Registration of method __sizeof__ is ignored as it is private. [V] 1720601125.127840 15670 qi.python.object: Registration of method __str__ is ignored as it is private. [V] 1720601125.127880 15670 qi.python.object: Registration of method __subclasshook__ is ignored as it is private. [V] 1720601125.127917 15670 qi.python.object: The object attribute '__weakref__' has value 'None', and will therefore be ignored. [V] 1720601125.128038 15670 qi.python.object: Registration of method newAuthenticator with signature () -> m. [V] 1720601125.128150 15670 qi.python.object: Registration of method __class__ is ignored as it is private. [V] 1720601125.128191 15670 qi.python.object: Registration of method __delattr__ is ignored as it is private. [V] 1720601125.128201 15670 qi.python.object: Registration of method __dir__ is ignored as it is private. [V] 1720601125.128205 15670 qi.python.object: The object attribute '__doc__' has value 'None', and will therefore be ignored. [V] 1720601125.128209 15670 qi.python.object: Registration of method __eq__ is ignored as it is private. [V] 1720601125.128213 15670 qi.python.object: Registration of method __format__ is ignored as it is private. [V] 1720601125.128217 15670 qi.python.object: Registration of method __ge__ is ignored as it is private. [V] 1720601125.128248 15670 qi.python.object: Registration of method __getattribute__ is ignored as it is private. [V] 1720601125.128256 15670 qi.python.object: Registration of method __gt__ is ignored as it is private. [V] 1720601125.128262 15670 qi.python.object: Registration of method __hash__ is ignored as it is private. [V] 1720601125.128267 15670 qi.python.object: Registration of method __init__ is ignored as it is private. [V] 1720601125.128298 15670 qi.python.object: Registration of method __init_subclass__ is ignored as it is private. [V] 1720601125.128307 15670 qi.python.object: Registration of method __le__ is ignored as it is private. [V] 1720601125.128312 15670 qi.python.object: Registration of method __lt__ is ignored as it is private. [V] 1720601125.128317 15670 qi.python.object: Registration of method __ne__ is ignored as it is private. [V] 1720601125.128321 15670 qi.python.object: Registration of method __new__ is ignored as it is private. [V] 1720601125.128356 15670 qi.python.object: Registration of method __reduce__ is ignored as it is private. [V] 1720601125.128364 15670 qi.python.object: Registration of method __reduce_ex__ is ignored as it is private. [V] 1720601125.128369 15670 qi.python.object: Registration of method __repr__ is ignored as it is private. [V] 1720601125.128373 15670 qi.python.object: Registration of method __setattr__ is ignored as it is private. [V] 1720601125.128407 15670 qi.python.object: Registration of method __sizeof__ is ignored as it is private. [V] 1720601125.128416 15670 qi.python.object: Registration of method __str__ is ignored as it is private. [V] 1720601125.128469 15670 qi.python.object: Registration of method __subclasshook__ is ignored as it is private. [V] 1720601125.128478 15670 qi.python.object: Registration of method __weakref__ is ignored as it is private. [V] 1720601125.128523 15670 qi.python.object: Registration of method newAuthenticator with signature () -> m. [V] 1720601125.128923 15670 qi.eventloop: start: thread count limits: initial (minimum, maximum) before any adjustment = (1, 1) [V] 1720601125.128969 15670 qi.eventloop: start: thread count limits: final (minimum, maximum) after potential adjustment = (1, 1) [V] 1720601125.128976 15670 qi.eventloop: start: number of threads that will be launched = 1 (between (min, max) = (1, 1)) [V] 1720601125.129207 15670 qimessaging.messagesocket: (ResolverUrlList)0x627ab121dce0: Trying to connect to 192.168.1.59:9503 [V] 1720601125.221899 15676 qitype.dynamicobject: Return signature might be incorrect depending on the value, from m to o [V] 1720601125.222053 15678 qi.python.object: Registration of method __class__ is ignored as it is private. [V] 1720601125.222107 15678 qi.python.object: Registration of method __delattr__ is ignored as it is private. [V] 1720601125.222121 15678 qi.python.object: Registration of method __dir__ is ignored as it is private. [V] 1720601125.222124 15678 qi.python.object: The object attribute '__doc__' has value 'None', and will therefore be ignored. [V] 1720601125.222176 15678 qi.python.object: Registration of method __eq__ is ignored as it is private. [V] 1720601125.222218 15678 qi.python.object: Registration of method __format__ is ignored as it is private. [V] 1720601125.222266 15678 qi.python.object: Registration of method __ge__ is ignored as it is private. [V] 1720601125.222306 15678 qi.python.object: Registration of method __getattribute__ is ignored as it is private. [V] 1720601125.222314 15678 qi.python.object: Registration of method __gt__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __hash__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __init__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __init_subclass__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __le__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __lt__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __ne__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __new__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __reduce__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __reduce_ex__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __repr__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __setattr__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __sizeof__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __str__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: Registration of method __subclasshook__ is ignored as it is private. [V] 1720601125.222504 15678 qi.python.object: The object attribute '__weakref__' has value 'None', and will therefore be ignored. [V] 1720601125.222704 15678 qi.python.object: Registration of method initialAuthData with signature () -> m. [V] 1720601125.222906 15676 qitype.dynamicobject: Return signature might be incorrect depending on the value, from m to {sm} [V] 1720601125.712055 15677 qimessaging.remoteobject: Requesting metaobject [V] 1720601125.736526 15674 qimessaging.remoteobject: Fetched metaobject [V] 1720601125.746481 15676 qimessaging.server: 0x627ab12002f0 - New socket 0x627ab122a5c0 added to the server. [V] 1720601125.753472 15677 qimessaging.session: Inserting sd to cache for c4538afe-edff-4afa-9c5d-762abce92211 tcps://192.168.1.59:9503 started [V] 1720601125.753774 15670 qimessaging.sessionservice: Asynchronously asking service 'ContextFactory' to SD client. requestId = 1 [V] 1720601125.779454 15674 qimessaging.sessionservice: Received answer from SD client for service 'ContextFactory'. requestId = 1 [V] 1720601125.779521 15674 qimessaging.sessionservice: Requesting socket from cache. service = 'ContextFactory', requestId = 1 [V] 1720601125.779583 15674 qimessaging.sessionservice: Got transport socket for service. requestId = 1 [V] 1720601125.779710 15674 qimessaging.remoteobject: Requesting metaobject [V] 1720601125.779822 15674 qimessaging.sessionservice: Fetching metaobject (2) for requestId = 1 [V] 1720601125.792403 15676 qimessaging.remoteobject: Fetched metaobject [V] 1720601125.792477 15676 qimessaging.sessionservice: Got metaobject for request id = 1 [V] 1720601125.792662 15670 qimessaging.sessionservice: Asynchronously asking service 'Focus' to SD client. requestId = 2 [V] 1720601125.821754 15676 qimessaging.sessionservice: Received answer from SD client for service 'Focus'. requestId = 2 [V] 1720601125.821785 15676 qimessaging.sessionservice: Requesting socket from cache. service = 'Focus', requestId = 2 [V] 1720601125.821572 15678 qimessaging.sessionservice: Got transport socket for service. requestId = 2 [V] 1720601125.821678 15678 qimessaging.remoteobject: Requesting metaobject [V] 1720601125.821735 15678 qimessaging.sessionservice: Fetching metaobject (2) for requestId = 2 [V] 1720601125.832664 15671 qimessaging.remoteobject: Fetched metaobject [V] 1720601125.833153 15671 qimessaging.sessionservice: Got metaobject for request id = 2 [V] 1720601125.856880 15671 qimessaging.remoteobject: Received error message{54.1.101, id:14}:could not take the focus: focus is owned by another activity Traceback (most recent call last): File "/home/pepper/playground/contextTest.py", line 39, in
focusOwner = focus.take()
RuntimeError: could not take the focus: focus is owned by another activity
```