Request for help: Android app to shut down a smartphone late at night

by The_Jaded_One1 min read2nd Apr 201530 comments


Personal Blog

I have been playing around with life hacking ideas inspired by hyperbolic discounting.

One idea that seems to have worked reasonably well is was the idea that I could get to bed on time better if my computer simply switched itself off at a certain time, with absolutely no way (that I am capable of executing!) to make it work until the morning. I found and paid for a piece of software that does this - isurveillance shutdown timer. Unfortnately, this seems to have just shifted my late night computer use to my android mobile device, though gaming sessions that last till 5am are a thing of the past. 

So, I'd like an android app that shuts down your (rooted) android phone if it is ever detected on within a prespecified time window on a particular day - e.g. between 11pm and 6am, with no way for the user to circumvent the shutdown. If the user restarts the phone, it should shut down again immediately when it finds out that the time is not within the specified window. 

I have looked for something like this on Google Play, however most offerings will shut down the phone *once*, but it will stay on if you switch it on again. 

LW being a community of tech-savvy people, I was wondering whether anyone was interested in building such an app? It probably isn't hard to do if you are already an android developer, and I think it would really improve my life, and possibly the lives of other people. You could even make it a paid app - I'd pay. In fact I will commit to paying $50 for the app if someone develops this app and it works as described. If the community finds it useful, I'd expect there'd be some karma in it too. Alternatively if anyone can *find* such an app, I'd be extremely grateful. 

A more advanced version of this would be to lock the phone into "emergency calls only" mode within a specific time window. I don't know how hard that would be to pull off. 

This idea might even be good enough to turn into a business - millions of people around the world have the same problem. The requirement to root the device obviously puts something of a dampener on the viability of a business, there may be legal issues with rooting devices as part of a business. 


30 comments, sorted by Highlighting new comments since Today at 3:59 PM
New Comment

Tasker is an Android app that lets you specify "contexts" (specific states of the phone), and carry out actions depending on these contexts. An example use-case might be something like "when I am connected to my home WiFi network, disable my screen lock".

One of the actions available under Tasker is "Run Shell", which lets you issue shell commands to the underlying operating system. To achieve your desired effect, you could:

  • Acquire Tasker (a few dollars)
  • Set it up to run with root privileges
  • Set a context of "between 11pm and 6am"
  • Set an action of the shell command "su -c shutdown -h now" (or something similar) to run under that context

This does seem quite hazardous, though. If an emergency happened at 3am, I'm pretty sure I'd want my phone easily available and usable.

ETA: I just Googled to see if there was an existing recipe for this. It turns out Android doesn't have a conventional shutdown terminal command, but does have the "reboot" command, with the switch -p for powering down. Tasker also has a "reboot" under System->Misc, with a power-down option on rooted phones. This can absolutely do what you want it to do. Just don't go having any emergencies between 11 and 6.

This does seem quite hazardous, though. If an emergency happened at 3am, I'm pretty sure I'd want my phone easily available and usable.

I was going to say this too, it's a good point. Potential fix: have a cheap non-smartphone on standby at home.

I already have another phone. Yes, this is a good point though.

Thanks! This will be useful for me as well, it definitely seems better than my current solution: leaving my cell phone locked in my office(EDIT: at work).

I tried leaving it in another room for a while, but that lead to other problems, including trips to the other room at night to just look at one more message etc

Sorry, I meant my office at work (yeap...). Fixed that.

That's great!

I'll see if I can implement this.

A general observation on Tasker: when I first got it (a few years ago) I thought I'd use it for all sorts of things. In reality, whenever I set something up in Tasker, it's usually either superseded by a more appropriate service or app a few months later, or broken by security fixes in subsequent versions of Android.

What are the most important things you replaced with other apps?

None of them were that important, really. They were more customisations to how I wanted the device to work. "Make sure GPS is turned on when Maps is turned on" sort of thing (which you now can't do without rooting the device and jumping through a few hoops, so I just turn it on manually these days).

I had some stuff to conserve and report on battery consumption, which now has a zillion different apps. I also had some location-based contexts and automatic email actions which are now handled by IFTTT. It's easy to forget how rudimentary smartphone apps and services were, even just a few years ago.

Made the phone report it's location if you texted it the password. Security updates added hoops to jump through, and FindMyDroid came out for free with all the functionality.

Made the phone autoplay music when headphones were plugged in. I stopped needing these when I got a new car with a bluetooth stereo and stopped using the aux plug in.

Made the phone report it's location if you texted it the password. Security updates added hoops to jump through, and FindMyDroid came out for free with all the functionality.

Even without an App there's also the Android Device Manager.

Thank you kind stranger for showing me something new. I'm glad to have learnt that.

But to paint the full picture, I used that location password to find my lost phone very rarely. It was mostly used during festivals, conventions, and travelling so that my friends and co-travelers could easily find me. People are uncomfortable adopting it, but it is a real easy fix to the 'I'm here, where are you?' coordination problem.

[-][anonymous]6y 1

Do you really need to be as strict with yourself as offering absolutely no way, or just putting an obstacle on it - like this - would be enough?

I think the obstacle would have to be sufficiently annoying. E.g. copying out 50 random characters for 5 minutes of extra time. Even then, it's so tempting.

A more advanced version of this would be to lock the phone into "emergency calls only" mode within a specific time window. I don't know how hard that would be to pull off.

This appears to be possible with the Device Administration API to relock the screen upon receiving an ACTION_USER_PRESENT intent. Neither of which requires a rooted phone.

If you can write an app that kicks the user back to the lock screen within a specific time window, that would be fantastic

Basic version debug apk here, (more recent) source on GitHub, and Google Play.

The most notable feature lacking is locking the phone when the start time arrives. PM me if you run into problems. Don't set the end time one minute before the start time, or you'll only be able to unlock the phone in that minute.

Is there a thread with suggestions/requests for non-obvious productivity apps like that? Because I do have a few requests:

1) One chrome extension that would do this, but for search results. That is, that upon highlighting/double-clicking a term would display a short list of top Google search results in a context/drop-box menu on the same page.

2) Something like the StayFocusd extension that blocks sites like Facebook and YouTube for a given time of the day, but which would be extremely hard to remove. Some people suggested to block these websites IPs directly on the router, but I don't have access to routers on my network.

3) Something that would turn-off the internet for a given set of time in a way completely impossible to put it back up. I use Freedom, but sometimes it's not enough. My current strategy is removing the Ethernet cable, locking it in my drawer and throwing the keys behind my desk (I have to get a stick to pick it up). But it would be nice something that would cost me as much willpower as clicking a button.

[-][anonymous]6y 0

Why is it so hard for you to, say, dump the computer and go to sleep at [desired time]?

Replace computer with any other activity you think does less good than you could have done.

Probably because of hyperbolic discounting. Actually the topic of "not doing what you really want to do" AKA Akrasia has been discussed to death on here and AFAIK there isn't a full consensus on what causes it.

[+][anonymous]6y -6

Alternative implementation: an android widget that posts a "snitch" message somewhere online if ever your phone is unlocked in certain time frames; such that other people can easily see online whether you unlocked your phone in the "forbidden" timeframe.

there are already severe consequences the next day - being tired, grumpy etc. I already don't want to stay up late on my phone. The problem is the "hyperbolic discount"/time preference inconsistency.

[-][anonymous]6y -1

Seriously though, if you say "akrasia" is a codeword for "lazy as fuck" (or whatever), you've just replaced one symbol with another. Have you made any progress?

Well, for starters, you aren't using a who-knows-where-it-came-from word. You're thinking more simply, which is good.

If you found yourself going to bed an hour or two later than is optimal, and you said "aha! I'm not akraitic, I'm lazy as fuck!", how would that help you?

Second.. that's not going to help you. You should've gone to bed already. But that means you're aware of the problem.

People often say "just have some self discipline!", but that is like saying to a beggar "just cause money to exist in your pocket!" - it's stating the obvious.

Then, why do you not do it? You're aware of both the problem and the solution - why aren't you implementing them?

Having an app that shuts the phone down is a way of achieving your goals with the self discipline you already have, and it is something you can actually do. It's specific and actionable.

With respect to anything that's not your brain, I think you still should self-improve rather than rely on other things. You've yourself said that you haven't found anything optimal and even admitted that it might not exist, so I think the self-improvement way is probably more reliable.

Another problem I have with this is that it seems to be badness-avoidance, rather than goodness-maximizing. Again, once you've shut off your phone, what are you going to do?

Well if you don't know what it is then how do you know ... Anyway if you don't care about any of this then why are you even participating? The internet is a big place man with plenty of other fora...

Because when you post links instead of being able to explain things yourself means that you cannot explain why you hold a certain belief or perform a certain action, but it's all justified as long as you have that piece of information somewhere.

Then, why do you not do it? You're aware of both the problem and the solution

Because whilst I'd like to have more self discipline, I don't: just do what you cannot do isn't a solution, it's an oxymoron. By analogy, it's like saying to a beggar: just walk into that office and pick up your paycheck.