abrenoch / hyperion-android-grabber

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

Updates the manifest to allow accessing services and activities. #150

Closed boralyl closed 4 years ago

boralyl commented 4 years ago

This addresses #149 I wanted to be able to start/stop the screen recording service without any user input. This way I could use homeassistant/tasker/etc. to send an adb command when it notices media is playing on my android device then stop it when the media stops.

I've tested these changes out on both a mobile device and an android tv device and I've got it working as expected.

To start:

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

To stop:

adb shell am startservice -a com.abrenoch.hyperiongrabber.service.ACTION_EXIT --ei com.abrenoch.hyperiongrabber.service.EXTRA_RESULT_CODE -1

The only caveat is the first time you start the service you will have to check the box so that it doesn't ask again for the permission. After that it will work w/o user interaction.

abrenoch commented 4 years ago

Looks very straightforward, nice work!

I'll be sure to try this out soon & merge!

boralyl commented 4 years ago

Just wanted to provide an update. I compiled the apk with this branch and installed it on my nvidia shield. It's been working flawlessly for the past 20 days or so with homeassistant starting/stopping the hyperion service on my nvidia shield when the media state changes from play/standby.

abrenoch commented 4 years ago

Apologies for not getting around to this sooner... Since this is only a tweak to the manifest I feel alright taking your word that is functions as intended! I'll merge this now.

fraser-mendeco commented 2 years ago

I'm not sure if this is working anymore. I get the following error:

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

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.abrenoch.hyperiongrabber/.common.BootActivity }

Exception occurred while executing 'start':
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.abrenoch.hyperiongrabber/.common.BootActivity } from null (pid=23542, uid=2000) not exported from uid 10078
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043)
        at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1052)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:712)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1107)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1079)
        at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3694)
        at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:543)
        at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:185)
        at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
        at android.os.ShellCommand.exec(ShellCommand.java:44)
        at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10611)
        at android.os.Binder.shellCommand(Binder.java:929)
        at android.os.Binder.onTransact(Binder.java:813)
        at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5073)
        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2899)
        at android.os.Binder.execTransactInternal(Binder.java:1159)
        at android.os.Binder.execTransact(Binder.java:1123)
abrenoch commented 2 years ago

Hey @fraser-mendeco could you give the latest beta (available in the releases section) a shot? I saw a couple issues similar to this while testing, it might be resolved already.

fraser-mendeco commented 2 years ago

@abrenoch Thanks, that seems to have fixed it :)