ticky

im in ur web site

  • she/her

web dracat

made:
internet-ti.me, @Watch, Wayback Classic, etc.

avatars appearing:

in 2D by nox lucent
in 3D by Zcythe

"If it were me, I'd have [changed] her design to make [her species] more visually clear" - some internet rando

I post embeds of other peoples' things at @ticky-reposts



ticky
@ticky

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


ticky
@ticky

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


  1. 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.

  2. 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.


You must log in to comment.

in reply to @ticky's post:

might not work (the perm in question is restricted to system apps usually), but: pm grant your.package.name android.permission.SHUTDOWN from adb, and then use intent: android.intent.action.ACTION_SHUTDOWN within your app.

A second option: You could turn on wifi debugging, pair it to a server or something in your house running cron, and/or have that server listen for device activity (e.g., a background app pinging it from the device) and dispatch the intent to your device remotely through adb shell am broadcast -a android.intent.action.ACTION_SHUTDOWN...

though at that point, adb shell reboot -p likely works too

everything I’m reading about that permission seems to suggest that it can’t be done from userspace at all

it appears that Wi-Fi debugging is killed each reboot, which would break this being anywhere near seamless sadly

ah, damn. I'd still give the permission/intent one a shot. this is a heavily vendorized Android after all, perhaps Meta made changes to the usual AOSP permissions?

and yeah, wifi debug being non-persistent is a bummer, in this case.

in reply to @ticky's post:

i think you might be able to do with with automate? it can send inputs and i think if you check with delays & "is screen on" you might be able to do this

as already mentioned, you can just install it from an .apk file. you can either use a tool to get it from a device with the play store or a website like APKMirror to get it