is there any utility which can make an (non-Play Store, non-rooted) Android device power off after a period of inactivity? my Quest likes to drain battery when not in use and it would be better if it just knew to power down when I don't touch it for a couple of hours
beginning with the main problem of "shutdown from user space”1, there appears to be no API for this in Android
your only option is to call reboot -p in the shell, which requires either root or ADB access
root is off the table, so, let's have a quick look at ADB - there's a neat tool called Shizuku which effectively (ab)uses the ADB network socket to shell in to the local device with somewhat elevated privileges. it's like a halfway to root solution
via Shizuku, it is possible to call reboot -p from userspace! there are apps which can do this! I can install them on my Quest via F-Droid!
however, Shizuku does not maintain its connection to ADB between reboots without root
meaning that, in my case, where I am looking to use it to automatically shut off the device, it requires manual intervention in order to then be able to do it again on the next boot
so, ADB and reboot -p seem like they need to be shelved
what else is there? well, there's one potential vector, though it feels like it would be fragile; accessibility services
Android lets apps request access to view and control the screen, effectively allowing for screen readers and automation apps in one fell swoop
one application which permits this is AutoInput, which can be plugged into Tasker to automate UI inputs, and indeed, it is seemingly possible with this combination to open the power menu and click the "power off" button
however
this combination of apps cannot be installed on a device which isn't connected to the Google Play Store2, and Meta in their wisdom do not include the Play Store on the Quest
so close and yet so far
-
The other issue, of course, being detecting when the user hasn't used the device in a while. There don't seem to be any automation apps which can do this specific thing from what I've seen.
-
Tasker can in fact be bought individually if you back the author's Patreon, but AutoInput is not, seemingly, included in that, and the author does not make any means of contact available on their website to ask for a way around that.