Post Reply

[MOD][DEVS][SENSE ONLY] Night Mode Feature

OP ihtfp69

27th June 2011, 06:11 PM   |  #1  
ihtfp69's Avatar
OP Senior Member
Thanks Meter: 810
 
1,875 posts
Join Date:Joined: Feb 2009
Donate to Me
More
I had a couple people ask me how to do this. I figured I would put together a brief thread on how to accomplish this. I may expand it later if people need more help. This is intended for ROM devs only; however, that should not stop anyone from trying.

The snippet of code below will allow you to turn night mode on/off. Night mode essentially turns off all of the led lights on your phone. I believe the method setNightMode is in most, if not all, Sense roms. I do not believe it is in AOSP.

This can be added as a setting in your Display preferences with a little work. I will attach what I changed on my rom to add the setting. If your rom is based off of the stock inc rom, then you can just replace your files with mine and recompile to get the feature. In addition, you will need to add two strings (night_mode_title & night_mode_summary) to public.xml and strings.xml.


Code:
    const-string v1, "power"

    const/4 v2, 0x1

    const/4, v3, 0x0

    invoke-static {v1}, Landroid/os/ServiceManager;->getService(Ljava/lang/String;)Landroid/os/IBinder;

    move-result-object v1

    invoke-static {v1}, Landroid/os/IPowerManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/os/IPowerManager;

    move-result-object v1

    #turn on
    invoke-interface {v1, v2}, Landroid/os/IPowerManager;->setNightMode(I)V

    #turn off
    invoke-interface {v1, v3}, Landroid/os/IPowerManager;->setNightMode(I)V
Attached Files
File Type: zip NightModeMod.zip - [Click for QR Code] (4.2 KB, 28 views)
27th June 2011, 06:11 PM   |  #2  
ihtfp69's Avatar
OP Senior Member
Thanks Meter: 810
 
1,875 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Reserved for future use ...
27th June 2011, 06:18 PM   |  #3  
incubus26jc's Avatar
Recognized Developer
Flag Illinois
Thanks Meter: 3,572
 
4,087 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Thanks bud, Ill try my luck with it
27th June 2011, 08:07 PM   |  #4  
rosser725's Avatar
Senior Member
Flag MA
Thanks Meter: 28
 
903 posts
Join Date:Joined: Feb 2011
Donate to Me
More
Cool!!! I'll have to try this
Post Reply Subscribe to Thread

Tags
mode, night, sense
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes