Skip to content

Portal client ignores the foreground Android user (content calls hit user 0; state falls back to uiautomator) #554

Done

Description

@Eyalm321

What happens

With a secondary Android user in the foreground (multi-user device, e.g. user 10), PortalClient in
mobilerun_core_local (0.6.3, transport/android/portal_client.py) runs its content-provider commands without
--user:

content query --uri content://com.mobilerun.portal/state_full

content without --user addresses user 0, so the call reaches user 0's Portal, whose accessibility service is not
running while user 10 is in front:

$ adb shell content query --uri content://com.mobilerun.portal/ping
Row: 0 result={"status":"error","error":"Accessibility service not available"}
$ adb shell content query --user 10 --uri content://com.mobilerun.portal/ping
Row: 0 result={"status":"success","result":"pong"}

The Portal probe then fails and state falls back to uiautomator dump, which on a screen with playing video (TikTok's
For You feed) never goes idle (ERROR: could not get idle state.), so every get_state attempt fails with
uiautomator output did not contain XML and the run stalls at step 1. Keyboard input through the Portal
(keyboard/input) goes to the wrong user the same way.

Expected

Portal calls address the foreground user's Portal (the one whose accessibility service sees the screen).

Repro

  1. Device with a second user (id 10), Portal installed and its accessibility service on in that user.
  2. adb shell am switch-user 10, open an app with autoplaying video.
  3. Run any task with portal_mode: auto, use_tcp: false.

Fix we run locally

At connect(), read am get-current-user; when it is not 0, add --user <id> to every content query /
content insert the client sends. User 0 behaviour is unchanged. The content helpers in
driver/android/portal.py (overlay offset, visibility, ping) have the same gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions