Night Mode Not Working - Android N DP4

556 views
Skip to first unread message

Aaron Unpublished

unread,
Jun 16, 2016, 11:38:28 AM6/16/16
to Tasker
Just FYI, Night Mode toggle doesn't work in Tasker on Android N.  

Unless I am not sure what Night Mode does, Android N has an option for Night Mode.  When turned on, it removes BLUE light on phone for easier nighttime viewing.   I assume "Night Mode" in Tasker is suppose to toggle this on/off, but it doesn't do anything.

Pent

unread,
Jun 18, 2016, 3:45:56 AM6/18/16
to Tasker
Thanks, will check it out.

Pent

Pent

unread,
Oct 30, 2016, 5:45:16 AM10/30/16
to Tasker


Just FYI, Night Mode toggle doesn't work in Tasker on Android N.  

Tasker's night mode action refers to a system feature that Android has had for many years
now (I've never been sure what it actually does, not having used it).

The Night Mode you're referring to is some new thing Google have come up with
which isn't even in standard settings as far as I can tell (or it is, for you ?)

Sum: maybe Google will merge these two things at some point, but the blueless screen
seems to be still experimental for them ATM.

Pent

Dirty Droids

unread,
Dec 21, 2016, 5:57:53 AM12/21/16
to Tasker
"Night light" has made it in to the final 7.0 release, is there any chance in getting a toggle added to Tasker? Thanks!

Pent

unread,
Dec 30, 2016, 4:32:18 AM12/30/16
to Tasker


"Night light" has made it in to the final 7.0 release,

Where exactly in settings is that ? On what device ?

Pent

Phil Bilton

unread,
Dec 30, 2016, 8:43:18 AM12/30/16
to Tasker
On my pixel it is under display settings. It's also available in the quick settings menu.

Pent

unread,
Dec 30, 2016, 10:11:26 AM12/30/16
to Tasker
I couldn't find it in either N6 (7.0) or Pixel C (7.1.1) with the UI Tuner enabled.

In any case, there's also no API for it, so I've no idea how to change it.
Perhaps it's a system setting.

Pent

John Doe

unread,
Dec 30, 2016, 12:51:45 PM12/30/16
to Tasker
You can use SecureTask plugin in order to change the settings. Use the secure settings action and look for "night display activated" set 0/1 to enable/disable.

Dirty Droids

unread,
Dec 31, 2016, 11:49:11 PM12/31/16
to Tasker
Sorry Pent. Some further research indicates that this feature may require a driver present only on the Pixel and Pixel XL handsets.

Thanks John Doe for pointing me towards SecureTask. I'm hesitant to install what appears to be a new app from an unfamiliar developer which requests such permissions, however I've been able to determine how it enables the setting and hope to do the same thing using just Tasker.

There is an Android secure system setting called NIGHT_DISPLAY_ACTIVATED which can be used to control the night light, I've tested it over adb with the following commands:

settings get secure night_display_activated
settings put secure night_display_activated 1
settings put secure night_display_activated 0

Tasker is unable to run these commands using a run shell task though as it lacks the appropriate permissions. The SecureTask plugin seems to get around this by requesting the user to grant the following permission through adb:

pm grant com.balda.securetask android.permission.WRITE_SECURE_SETTINGS

I've tried to grant this permission to the Tasker package but receive the following error:

Operation not allowed: java.lang.SecurityException: Package net.dinglisch.android.taskerm has not requested permission android.permission.WRITE_SECURE_SETTINGS

Some research indicates the permission must be present in the AndroidManifest.xml file of the specific app before it can be granted via adb. Indeed I can see this permission in the SecureTask manifest file but not in the Tasker manifest file.

Pent, would it be possible to add this permission to the Tasker manifest so it can be granted via adb to allow for control of secure settings?

Regards,

Dirty

John Doe

unread,
Jan 1, 2017, 2:06:40 AM1/1/17
to Tasker
Usually I write apps for myself and I'm the first user, I wrote SecureTask simply because Secure Settings plugin is now a closed project and I prefer to use my apps to know how data are used, where they are sent, who uses them and so on. However I can understand that the special permissions required by SecureTask can scare you. I let you note however that the plugin doesn't require extra permissions, only what required to work. In addition it uses runtime permissions so for example if you don't use a feature you can avoid to grant the permission. It doesn't have internet permission and it can't send data anywhere. Privacy policy is linked on the store. However if you want to perform the same using Tasker, you can create a task to change the setting, export the task as app, add the permission, grant the permission with ADB. Tasker doesn't need to be changed.

Dirty Droids

unread,
Jan 1, 2017, 3:39:49 AM1/1/17
to Tasker
Thanks again John Doe, your technical assistance has been a great help.

I tried what you suggested with regards to exporting the task as an app but I just couldn't get it to work. I granted both the android.permission.WRITE_SETTINGS and android.permission.WRITE_SECURE_SETTINGS as extra permissions in Tasker, granted the android.permission.WRITE_SECURE_SETTINGS permission through adb after installing and ensured "Modify system settings" was enabled in the Android app settings but I kept getting the following error:

Error while accessing settings provider java.lang.SecurityException: Permission Denial: Do not have permission in call getContentProviderExternal() from pid=22506, uid=10132 requires android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY at...

I did try adding android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY to the extra permissions list while exporting in Tasker but it didn't help. I also see your app doesn't have this permission defined in the manifest.

After consideration regarding your post on permissions (no internet permission & runtime permissions used) though I have decided to go ahead and use SecureTask, it's working very well. Thanks for providing such a tool.

If you have any idea why my exported apps weren't working I'd be interested to know but it's not a big concern.

Dirty

John Doe

unread,
Jan 1, 2017, 3:50:37 AM1/1/17
to Tasker
Hard to say. I guess it's something related to the task you used. Did you use getContentProviderExternal()? You need to use something like:

ContentResolver cr = CONTEXT.getContentResolver();
Settings.Secure.putInt(cr, "a setting name here", a setting value here);

Dirty Droids

unread,
Jan 1, 2017, 3:57:54 AM1/1/17
to Tasker
Ah I should have mentioned, the task simply had a single "run shell" action which ran this command:


settings put secure night_display_activated 1

I then added some flashes afterwards for testing so I could see the error output.

Anyway it doesn't matter, I am content to use SecureTask for now. Thanks again.
Reply all
Reply to author
Forward
0 new messages