Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android TV sendevent not working on GoogleTV (CCwGTV) and input method slow. #73147

Closed
gnoric opened this issue Jun 6, 2022 · 5 comments
Closed

Comments

@gnoric
Copy link

gnoric commented Jun 6, 2022

The problem

The sendevent method is not working on the CCwGTV since permission error is returned. The device cannot be rooted to circumvent this issue. Using the default input command is quite slow. This is a known issue and has been documented in quite a few forums. However, I'd like to make a recommendation for a solution:

SCRCPY has a working solution which is fast and supports unrooted devices. It would be great if that snappy functionality could also be implemented into HomeAssistant. It works on unrooted devices and nothing needs to be installed on the device. And it is open source, so it shouldn't be too much effort identifying and copying the relevant functionality.

https://github.com/Genymobile/scrcpy
Genymobile/scrcpy#2248

What version of Home Assistant Core has the issue?

2022.6.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Android TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/androidtv/

Diagnostics information

No response

Example YAML snippet

# Send the "UP" command using `sendevent` (faster)
- service: androidtv.adb_command
  target:
    entity_id: media_player.fire_tv_living_room
  data:
    command: "sendevent /dev/input/event4 4 4 786979 && sendevent /dev/input/event4 1 172 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786979 && sendevent /dev/input/event4 1 172 0 && sendevent /dev/input/event4 0 0 0"

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

androidtv documentation
androidtv source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @JeffLIrion, @ollo69, mind taking a look at this issue as it has been labeled with an integration (androidtv) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@gnoric
Copy link
Author

gnoric commented Jun 7, 2022

@cdce8p Maybe you can also have a look, please?

@droans
Copy link

droans commented Jun 18, 2022

Looks like this comes down to SELinux policy. Android 10 added this policy to shell.te:

# b/30861057: Shell access to existing input devices is an abuse
# vector. The shell user can inject events that look like they
# originate from the touchscreen etc.
# Everyone should have already moved to UiAutomation#injectInputEvent
# if they are running instrumentation tests (i.e. CTS), Monkey for
# their stress tests, and the input command (adb shell input ...) for
# injecting swipes and things.
neverallow shell input_device:chr_file no_w_file_perms;

https://android.googlesource.com/platform/system/sepolicy/+/refs/heads/android-s-beta-4/public/shell.te#222

@that1guy
Copy link

that1guy commented Aug 12, 2022

Seems the new SELinux policy causes the user to receive: adb_response: sendevent: /dev/input/event3: Permission denied when following the instructions titled ANDROIDTV.LEARN_SENDEVENT (FOR FASTER ADB COMMANDS).

I'd recommend updating the documentation if there really is no solution to this problem.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants