Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,729,908 Members 53,539 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
ihtfp69
Old
#1  
ihtfp69's Avatar
Senior Member - OP
Thanks Meter 807
Posts: 1,875
Join Date: Feb 2009

 
DONATE TO ME
Lightbulb [MOD][DEVS][SENSE ONLY] Night Mode Feature

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)
Phone #1: Rooted Droid Incredible - SkyRaider ROMs
Phone #2: Rooted Thunderbolt - SkyRaider Zeus
Tablet: Motorola Xoom

Click to follow me on Twitter!

If you like something I did, donate to my beer fund and click the Thanks button!
 
ihtfp69
Old
#2  
ihtfp69's Avatar
Senior Member - OP
Thanks Meter 807
Posts: 1,875
Join Date: Feb 2009

 
DONATE TO ME
Reserved for future use ...
Phone #1: Rooted Droid Incredible - SkyRaider ROMs
Phone #2: Rooted Thunderbolt - SkyRaider Zeus
Tablet: Motorola Xoom

Click to follow me on Twitter!

If you like something I did, donate to my beer fund and click the Thanks button!
 
incubus26jc
Old
#3  
incubus26jc's Avatar
Recognized Developer
Thanks Meter 3571
Posts: 4,086
Join Date: Feb 2009
Location: Illinois

 
DONATE TO ME
Thanks bud, Ill try my luck with it
 
rosser725
Old
#4  
rosser725's Avatar
Senior Member
Thanks Meter 28
Posts: 903
Join Date: Feb 2011
Location: MA

 
DONATE TO ME
Cool!!! I'll have to try this
Device: Samsung Galaxy S4 (SCH-i545)
ROM: Stock Rooted
Kernel: Stock
Radios:I545VRUAMDK
Tags
mode, night, sense
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes