Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic turn-on/turn off does not work #34

Closed
breversa opened this issue Apr 6, 2016 · 20 comments
Closed

Automatic turn-on/turn off does not work #34

breversa opened this issue Apr 6, 2016 · 20 comments
Labels

Comments

@breversa
Copy link

breversa commented Apr 6, 2016

Hi there !

I happily discovered Red Moon as an alternative to Twilight on F-Droid.

However, automatic turn-on/turn at custom times does not seem to work : I set it to run between 20:00 and 06:00, but it did not stop at 06:00.

Also, I'm not quite sure what the two startup options do ("Keep running after reboot" and "Alway open on startup") : do they mean that Red Moon doesn't normally start at boot to monitor automatic turn on/off times, and that reboot behaves differently than normal boot ?

@raatmarien
Copy link
Member

Hey, thanks for the feedback!

However, automatic turn-on/turn at custom times does not seem to work : I set it to run between 20:00 and 06:00, but it did not stop at 06:00.

That is weird, sorry for the inconvenience. Was the filter still running or only the notification? Could your phone have been turned off at 06:00?

Also, I'm not quite sure what the two startup options do ("Keep running after reboot" and "Alway open on startup") : do they mean that Red Moon doesn't normally start at boot to monitor automatic turn on/off times, and that reboot behaves differently than normal boot ?

The "Keep running after reboot" determines if the state of the filter is restored after reboot and if the "Always open on startup" preference is checked the filter will always open when the device is booted, even if it wasn't open when the device was turned off. However both these settings will be removed in the next version, because they are quite ambiguous and confusing as pointed out in #29.

@raatmarien raatmarien added the bug label Apr 6, 2016
@breversa
Copy link
Author

breversa commented Apr 6, 2016

Wow, I did not expect such a fast answer ! :D

I did some more tests inbetween : turning ON works fine, but turning OFF does not.

Thanks for the info regarding the startup options. Also, the toggle at the top of the UX is a bit misleading : I first thought it toggles the automatic start on/off, while it actually simply turns the FILTER on/off.

@breversa
Copy link
Author

breversa commented Apr 6, 2016

Er… that's wierd : I tried again and it turned off, although not precisely at 10:39'00", but more like 10:39'30"

@raatmarien
Copy link
Member

Ah okay, thanks for testing!

When you select a minute and an hour, it actually schedules the alarm for hour:minute:current seconds, where current seconds is the seconds of the time when you schedule it. Red Moon does this to ensure that it doesn't miss an alarm, however I will be looking into other solutions in the future.

With that said, it is still very peculiar that the filter didn't turn off at 06:00. I've looked into the code and it seems that if the device is turned off when the filter should be turned off, the filter can keep running. Could this also be the reason the filter didn't turn off for you?

@breversa
Copy link
Author

breversa commented Apr 6, 2016

Okay, that explains the seconds thing.

Sorry for not replying earlier : no, my phone was not off. I usually turn it to airplane mode during the night, though I did not do it last night.

But come to think of it : my phone sometimes experiences random (soft) reboot, so it might have rebooted during the night without me noticing. I guess you can close that issue : I'll keep an eye out for any strange behaviour and comment back if something is wrong.

@raatmarien
Copy link
Member

Great, I will look into making sure that the filter is turned off/on if the device is off when the turn off/on signal is given.

Thanks for the quick replies and please let me know if you encounter any more problems!

@smichel17
Copy link
Member

@breversa the top-level switch is confusing right now. It toggles the Red Moon service on and off. If you turn it off, Red Moon should be completely disabled, as if it were uninstalled. It will never display the filter and never automatically turn on.

The confusing part is: When you pause the filter, the top-level switch shows itself as off when the setting it controls is actually on. There's an item in #29 to address this.

@breversa
Copy link
Author

breversa commented Apr 6, 2016

Okay, I'm now officially lost ! :D

Just how do you turn on the service without turning on the filter ?

Here's what I did :

  • set turn on filter to custom time
  • set on/off times to 22:00-06:00
  • turned on the main toggle (the time is now 15:50, so off custom range)
    -> Filter turns on !
    I had to force-kill Red Moon then start it again to have the main toggle on but filter off.

@smichel17
Copy link
Member

Just how do you turn on the service without turning on the filter ?

@raatmarien Haha, this is why we should remove all references to "the service".

@breversa In the next version of Red Moon you will not need to know the answer to this question to use the app :). The service is the process that runs in the background when Red Moon is enabled. I'm just going to call it the process from now on because that's clearer. When you pause the filter, the background process is still running -- that's what keeps the notification alive so you can resume again. It's also how the filter can automatically start at a certain time (the process is running always, doing mostly nothing except watching the time). When you stop the filter, the process is killed, which is why the notification stops showing. For now, I think the easiest way to think about it is "service = notification." The top-level switch should turn the notification (and all the features that go along with it) on and off.

@breversa
Copy link
Author

breversa commented Apr 6, 2016

@smichel17 :
Yup, that's how I understood it. Services/processes are common notion to me. However, I was puzzled that toggling Red Moon on would instantly tint my screen though I was NOT within the custom time range.

@smichel17
Copy link
Member

When you select a minute and an hour, it actually schedules the alarm for hour:minute:current seconds, where current seconds is the seconds of the time when you schedule it. Red Moon does this to ensure that it doesn't miss an alarm, however I will be looking into other solutions in the future.

What edge case does this solve?

Here's what I did :

  • set turn on filter to custom time
  • set on/off times to 22:00-06:00
  • turned on the main toggle (the time is now 15:50, so off custom range) -> Filter turns on ! I had to force-kill Red Moon then start it again to have the main toggle on but filter off.
    [...]
    I was puzzled that toggling Red Moon on would instantly tint my screen though I was NOT within the custom time range.

This hits the nail on the head.

@raatmarien I think these are the to-do's that come out of this ticket. First:

  • The logic for deciding filter state when Red Moon gets enabled should be re-used for deciding filter state on boot.

Second, what is that logic? I'd like to see the 'Complex' logic, which is why I did not include this in #29.

  • Simple: If automatic filter is on, when Red Moon is enabled, filter state should reflect whether the current time is within the time range.
  • Complex: when Red Moon is enabled, it uses the state it would have been had the service been running the whole time.

The best way to clarify what I mean in the complex version is to write out all the edge cases. If you replace "powering off/on" with "enabling/disabling Red Moon", the filter state should respond the same way.

I enable Red Moon and set the filter to 'sun'. It is currently night and the filter is on. If I...

  • Power off, wait 5 minutes, then boot
    • filter is on.
  • Pause, Power off, wait 5 minutes, then boot
    • filter is paused.
  • Power off, wait until daylight, then boot
    • filter is paused.
  • Power off, wait 24 hours, then boot
    • filter is on.
  • Pause, power off, wait 24 hours, then boot:
    • filter is on.

I enable Red Moon and set the filter to 'sun'. It is currently day and the filter is paused. If I...

  • Power off, wait 5 minutes, then boot
    • filter is off
  • Turn filter is on, Power off, wait 5 minutes, then boot
    • filter is on
  • Power off, wait until night, then boot
    • filter is on
  • Power off, wait 24 hours, then boot
    • filter is off
  • Turn filter on, power off, wait 24 hours, then boot:
    • filter is off

@breversa
Copy link
Author

breversa commented Apr 7, 2016

What are the use cases that the complex logic would address ?

I for one would be perfectly happy with the simple logic, as the only time I'd need to pause the filter (if on, of course) is to install APKs (I solely use Red Moon to filter out the blue light, not to dim the screen).

The complex logic would actually bother me more if I rebooted straight after an install (hence still in pause), since I'd have to de-pause after reboot, while I'd expect a simple logic behaviour : device boots, Red Moon starts (and applies the filter according to the settings).

What's more, I don't readily understand why the behaviour should change between reboot and power off/on… and I'm pretty sure other users wouldn't either. And what about the difference between standard reboot and soft boot that some ROMs (like CyanogenMod) offer ?

@varhub
Copy link

varhub commented Apr 7, 2016

Hi all!
Just to defend the counterpart, I am happy with top-right toggle behavior of 2.5.0
It almost behaves like the toggle of any xposed module. And this is good because one can ensure that service is off (although it does not drain batery)

@smichel17
Copy link
Member

@varhub This is not going away -- actually, it's becoming exactly what you expect: a universal on/off switch to disable the service. See #29 (warning: it's long).

@smichel17
Copy link
Member

@breversa In reverse order...

What's more, I don't readily understand why the behaviour should change between reboot and power off/on… and I'm pretty sure other users wouldn't either. And what about the difference between standard reboot and soft boot that some ROMs (like CyanogenMod) offer?

The important variable is not reboot vs boot, it is the amount of time that passes. So a soft reboot acts just like a normal reboot, which acts just like powering off and then powering immediately on.

I have updated the post above so that I never use the word "reboot", to clarify this.

What are the use cases that the complex logic would address ?

Replace "power off" and "power on" with "my phone dies" and "I charge the phone" in any of the edge cases, and you have your use cases. But -- I think the real question here is why would you expect that behavior? I tried to communicate that in the original comment but was tired and not very ariculate 😴

Complex: when Red Moon is enabled, it uses the state it would have been had the service been running the whole time.

Let me try to clarify: The premise is "If I leave my phone on and service enabled all the time, Red Moon will have a certain behavior. This is the desired behavior: If I turn my phone off or disable the service, when I power on or enable the service, the state should be the same as if I had left my phone on & service enabled the entire time."

The current behavior does very poorly at following this premise. The simple behavior fixes the most egregious departures from this premise but regresses in some edge cases. The complex behavior fixes the edge cases.

If you agree with this premise, I can pick a few specific scenarios and explain why they are good or bad.

@smichel17
Copy link
Member

@varhub

#36 affects this issue, making it much clearer. It adds a 'stop' state.

I have an analogy! A helpful way to think of the settings is like one of those white noise makers that people use when they sleep. Plugging it into the wall is like enabling the top switch. Start/stop is like hitting the power button to turn it on and off. This particular model makes noise whenever it is turned on, unless you pause it. You can also schedule times for it to automatically turn on and off (but of course those won't do anything if you unplug it).

  • It'll forget the pause state when you turn if off, unplug it, or lose power.
  • It'll remember if it was on or off when it gets unplugged or loses power.
    • ie, if it was on and paused, it will turn on and unpause

Note: the above two rules summarize ALL of the "complex logic." It's just shorter because I don't need to write out "paused and notification off" etc.

@varhub
Copy link

varhub commented Apr 7, 2016 via email

raatmarien added a commit that referenced this issue Apr 9, 2016
See #34

When automatic filter is enabled and the device is booted, it doesn't
restore the state from before the reboot, but determines if it is
currently 'on-time' or 'off-time'. This is the simple logic as described
in smichel17's post in #34.
@raatmarien
Copy link
Member

Second, what is that logic? I'd like to see the 'Complex' logic, which is why I did not include this in #29.

  • Simple: If automatic filter is on, when Red Moon is enabled, filter state should reflect whether the current time is within the time range.
  • Complex: when Red Moon is enabled, it uses the state it would have been had the service been running the whole time.

I've implemented the simple logic for now. Although I do see the merits of the complex system, it would be quite a bit of work to implement for a few edge cases. I may however implement the complex logic when I have the time (or someone else can if they want 😄).

@smichel17
Copy link
Member

@raatmarien Yeah, definitely not worth trying to implement the complex logic, at least until #36 is implemented, since that will make the complex logic much simpler (though figuring out the hours passed is still a bit of a pain. You'd have to track time of power off or something).

@breversa
Copy link
Author

@smichel17 :
Though a bit late, thank you for your clarification. I'm still totally happy with the simple logic though. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants