abrenoch / hyperion-android-grabber

Screen grabber for hyperion
MIT License
193 stars 31 forks source link

Allow the HyperionScreenService to be exportable. #149

Closed boralyl closed 4 years ago

boralyl commented 4 years ago

I'm looking for a way to allow automation through tasker/home assistant/etc. to be able to start/stop the hyperion screen service on my nvidia shield. I know it's possible to launch the ToggleActivity using adb:

adb shell am start com.abrenoch.hyperiongrabber/com.abrenoch.hyperiongrabber.common.ToggleActivity

This works, but it still starts the activity and requires me to click the power button then back out to my playing media. Ideally I'd like to be able to use adb to start and stop the service so that the lights turning on are more seamless and doesn't require user interaction. I attempted to change the exported attribute to True and run a debug apk on my device but I can't seem to get the service to start.

adb -s HT64NBN00639 shell am startservice -n com.abrenoch.hyperiongrabber.common/.HyperionScreenService
Starting service: Intent { cmp=com.abrenoch.hyperiongrabber.common/.HyperionScreenService }
Error: Not found; no service started.

I'm not super familiar with services so I may be missing something in the manifest or the adb command isn't quite right. Would it be possible to make this work?

boralyl commented 4 years ago

After doing some more research I realized that you can't start capturing the screen without an activity. I was able to get this working with these changes: https://github.com/abrenoch/hyperion-android-grabber/compare/master...boralyl:feature%2Fmake-exportable?diff=unified&expand=1

To start the service:

adb shell am start com.abrenoch.hyperiongrabber/com.abrenoch.hyperiongrabber.common.BootActivity

To stop the service:

adb shell am startservice -a com.abrenoch.hyperiongrabber.service.ACTION_EXIT --ei com.abrenoch.hyperiongrabber.service.EXTRA_RESULT_CODE -1
Paulchen-Panther commented 4 years ago

Please make an PR. Thank you for your commitment

boralyl commented 4 years ago

Fixed in #150