Related
Hi. This is a question for a rooted Droid /Milestone, but should be applicable to other models as well. I'd like to know if there's a command or any other functionality I can use to "lock" the brightness setting so that other applications can't change it.
I know it's possible, because there's an app in the Market called AdjBrightness (looks like the developer posts here, as well) that is capable of locking it, but I don't quite need all the functionality it provides, and I can't work out how to reverse its home row backlight disabling, which means I ALSO have to run LEDs Hack... I'd like to just write something simple for my specific settings to replace both.
I'm trying to create a very short script I can run with Tasker and set to a widget that will accomplish 3 things: Disable the home row backlights, set the brightness to 2/255, and then "lock" that setting so that other apps can't affect it. I want to run Aldiko for reading in pretty much total darkness, and this is the ideal setting for me.
So far, I can get it set properly using the following:
su
echo 2 > /sys/class/leds/lcd-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness
and with Tasker I can run that as a script and set it to a widget, with another widget to complement it that runs:
su
echo 100 > /sys/class/leds/lcd-backlight/brightness
echo 1 > /sys/class/leds/button-backlight/brightness
which reverses the process and sets everything back to normal.
What I need is to figure out how to lock in that "2" brightness setting, which at this time persists only until some other app affects the brightness. When I run Aldkio, its built-in brightness control feature overrides my setting and lights the thing back up too bright.
So, can this be done with a script? I imagine a chown command that temporarily takes ownership of that function could work, but I'm not smart enough to know how, and I've exhausted Google and the forum search. As I mentioned, this thing would always be run with a complimentary script that could later reverse the chown and give it back to whatever process it ought to belong to... I KNOW it's possible because there's at least one app that does it perfectly; the AdjBrightness setting change persists after I open Aldiko, indeed it persists basically forever; you've got to kill the app or reboot to be able to adjust the brightness with any other means.
Can anyone point me in the right direction?
Bump? Still trying to figure this out.
Bump
Still wondering if there's a way to do this.
+ 1 - if you find a way to lock it via command line, do post back, as will i
i am currently using adjbrightness it to control my button backlights on my dell streak
its great as it locks it on for that session. but after reboot have to manually renable
so i have written an execute entry in tasker to control all or just some of the leds for various notifications
but would love a command line way to lock these as adjbrightness does, i cant find out how its doing that!!!
jdb1981 said:
Hi. This is a question for a rooted Droid /Milestone, but should be applicable to other models as well. I'd like to know if there's a command or any other functionality I can use to "lock" the brightness setting so that other applications can't change it.
I know it's possible, because there's an app in the Market called AdjBrightness (looks like the developer posts here, as well) that is capable of locking it, but I don't quite need all the functionality it provides, and I can't work out how to reverse its home row backlight disabling, which means I ALSO have to run LEDs Hack... I'd like to just write something simple for my specific settings to replace both.
I'm trying to create a very short script I can run with Tasker and set to a widget that will accomplish 3 things: Disable the home row backlights, set the brightness to 2/255, and then "lock" that setting so that other apps can't affect it. I want to run Aldiko for reading in pretty much total darkness, and this is the ideal setting for me.
So far, I can get it set properly using the following:
su
echo 2 > /sys/class/leds/lcd-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness
and with Tasker I can run that as a script and set it to a widget, with another widget to complement it that runs:
su
echo 100 > /sys/class/leds/lcd-backlight/brightness
echo 1 > /sys/class/leds/button-backlight/brightness
which reverses the process and sets everything back to normal.
What I need is to figure out how to lock in that "2" brightness setting, which at this time persists only until some other app affects the brightness. When I run Aldkio, its built-in brightness control feature overrides my setting and lights the thing back up too bright.
So, can this be done with a script? I imagine a chown command that temporarily takes ownership of that function could work, but I'm not smart enough to know how, and I've exhausted Google and the forum search. As I mentioned, this thing would always be run with a complimentary script that could later reverse the chown and give it back to whatever process it ought to belong to... I KNOW it's possible because there's at least one app that does it perfectly; the AdjBrightness setting change persists after I open Aldiko, indeed it persists basically forever; you've got to kill the app or reboot to be able to adjust the brightness with any other means.
Can anyone point me in the right direction?
Click to expand...
Click to collapse
In my device adjbrightness app lock the brightness just by changing the permission of "/sys/.. /brightness" file to 444. So even system can't change the brightness value if requested by any other apps. To unlock the brightness permission of "/sys... /brightness" is restored to previous state, 644.
So in terminal the commands can be "for changing brightness to 2 and lock it"
su
echo 2>/sys/class/leds/lcd-backlight/brightness
chmod 444 /sys/class/leds/lcd-backlight/brightness
"for unlock and restore "
su
chmod 644 /sys/class/leds/lcd-backlight/brightness
echo 100> /sys/class/leds/lcd-backlight/brightness
Same goes for button backlight brightness file
But I found it "not suitable" for my device even with adjbrightness. If I lock brightness using adjbrightness after my screen turns off normally or by using power button , I can't turn it on using power button, so I have to open the battery and reboot the device. Same thing happens if I do it using "commands" or script. So "something" should be done so that the permission of ".. /brightness" file is set to 644 before the screen turns off normally or by other means.And after the screen is on the file permission will be 444 again. I think it may be done using tasker but still don't know how.
Hope someone will help.
Thanks.
Hi
I am not sure why, but I can't turn off screen, with "echo 0 >" into brightness.
It seems that there is some minimum brightness somewhere which I need to configure ?
I really struggle with it.
Any idea how to do that ?
Thanks,
Ranchu
I originally found the fix in the SuperCharger Thread when I found that my Flush-O-Matic script wasn't working properly on my Sony Z1.
See original posting here.
zeppelinrox said:
Hey I realized yesterday that Flush O Matic doens't work properly on newer kernels.
Well it works, but it doesn't wait for the screen to go off before flushing.
A little googlie told me that the newer kernels no longer have the /sys/power/wait_for_fb_sleep file.
Normally, FOM will try and read it's contents (but it's unreadable) and it just hangs until the device goes to sleep.
When it goes to sleep, that file can be read and the script gets "unhung" and flushes.
And when the file is missing, well FOM will just spit out errors (check the log) and dump cache without uh... waiting for the fan to be turned on...
BUTT (yeah, thats a big butt!) I fingered out another way for newer kernels... heh.
Check it via PC... with the screen on do this
Code:
adb shell
su
while [ "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 1; done; echo " OK Flush Time!"
Who's your daddy!? LOL
While the screen is on it should hang there until you turn off the screen.
When the screen goes off, it will pronounce what "time" it is...
I'll probably do sleep 10 instead of sleep 1 tho to minimize battery suckage.
Click to expand...
Click to collapse
This fix would be applicable to various scripts on xda that will get outdated due to the missing wait_for_fb_sleep/wake files on some device/kernel combinations.
Currently effected hardware, that I'm aware so far: some Sony, Moto and Nexus devices using kernel version 3.3 or above.
These scripts change things or do things depending on whether the screen turns off or turns on.
Examples are cpu governor scripts or other screen state scaling scripts.
As mentioned above, it had effected my FOM script which dumps caches at a user defined interval.
However, when the time is up, it will actually wait until the screen is off if the screen happens to be on at the time.
So if you have a misbehaving script due to the missing /sys/power/wait_for_fb_sleep/wake files, you should have 2 other files that you can use.
1. /sys/class/graphics/fb0/dynamic_fps
2. /sys/class/graphics/fb0/show_blank_event
File contents with screen off:
Code:
[email protected]:/ $ cat /sys/class/graphics/fb0/dynamic_fps
[email protected]:/ $ cat /sys/class/graphics/fb0/show_blank_event
panel_power_on = 0
[email protected]:/ $
File contents with screen on:
Code:
[email protected]:/ $ cat /sys/class/graphics/fb0/dynamic_fps
60
[email protected]:/ $ cat /sys/class/graphics/fb0/show_blank_event
panel_power_on = 1
[email protected]:/ $
So when the screen is off, dynamic_fps is empty but has a value (60 in my case) when the screen is on.
I preferred to take advantage of that file.
However some may like to use the contents of show_blank_event and check whether panel_power_on = 0 (off) or panel_power_on = 1 (on).
Of course, a script will have to check and decide whether to use the wait_for_fb_sleep file or use the new way.
So a fixed script will look something like:
Code:
if [ -f "/sys/power/wait_for_fb_sleep" ]; then
echo "Android is now `cat /sys/power/wait_for_fb_sleep`!"
else while [ "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 10; done
echo "Android is now sleeping!"
fi
So if that code is ran when the screen is on, when the screen is off, the output would be Android is now sleeping! and it won't matter if you have the wait_for_fb_sleep file
Alternately, to do something when the screen turns on...
Code:
if [ -f "/sys/power/wait_for_fb_wake" ]; then
echo "Android is now `cat /sys/power/wait_for_fb_wake`!"
else while [ ! "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 10; done
echo "Android is now awake!"
fi
Of course, when the screen comes on, the output will be Android is now awake!
I used sleep 10 so that it doesn't do any needless work.
Of course sleep 1 would give an instant reaction but isn't very battery or cpu friendly.
You can decide for yourself how long is a good sleep interval between checks.
Anyhow, hope that helped
Nice! Will try on my VU
sent from my LG-P895 using Tapatalk bajakan
Thank you
I wanted this to implement a small idea of mine ,also scanned through the 11k+ lines from supercharger script but couldn't find screen off thingy
Yeah,finding a small line in FastEngineFlush.sh also was hard
But this post helped!
The reason why your are called a XDA Scripting Genius! :good:
Really useful!
Madaditya said:
I wanted this to implement a small idea of mine ,also scanned through the 11k+ lines from supercharger script but couldn't find screen off thingy
Yeah,finding a small line in FastEngineFlush.sh also was hard
But this post helped!
The reason why your are called a XDA Scripting Genius! :good:
Really useful!
Click to expand...
Click to collapse
Whats your idea?
And yeah, even the flush script is rather complex lol
zeppelinrox said:
Whats your idea?
And yeah, even the flush script is rather complex lol
Click to expand...
Click to collapse
LOL yeah.
Wanted to make a background script that turns your data connection off on screen off + one minute and enables data on screen on.
Something close to Stamina mode in Sony Devices.
Reason,i face considerable battery drain on Custom roms,and a xperia user always misses Stamina mode
Madaditya said:
LOL yeah.
Wanted to make a background script that turns your data connection off on screen off + one minute and enables data on screen on.
Something close to Stamina mode in Sony Devices.
Reason,i face considerable battery drain on Custom roms,and a xperia user always misses Stamina mode
Click to expand...
Click to collapse
Nice idea!
Whats the command to disable data?
zeppelinrox said:
Nice idea!
Whats the command to disable data?
Click to expand...
Click to collapse
svc data enable/disble
for wifi:
svc wifi enable/disable
Madaditya said:
svc data enable/disble
for wifi:
svc wifi enable/disable
Click to expand...
Click to collapse
Oh nice.
You learned me something lol
I couldn't find /sys/class/graphics/fb0/show_blank_event or /sys/class/graphics/fb0/dynamic_fps or /sys/power/wait_for_fb_wake/sleep. Instead i am using this /sys/class/leds/lcd-backlight/brightness. 0 will mean screen is off, any other value for screen on. Thanks You could add this in OP
Hi there,
im searching for the shell-code for just a "screen-off" but no lock.
Do u have any idea?
thank you
@warp2;
Have a look here: http://forum.xda-developers.com/showthread.php?t=883099
Read all posts in this thread.
Example:
Code:
cat /sys/class/leds/lcd-backlight/brightness (get's the current brightness level - i.e. 100)
echo 0 > /sys/class/leds/lcd-backlight/brightness (sets Screen full dark/aka 'Screen OFF'' - but device is still running)
echo 100 > /sys/class/leds/lcd-backlight/brightness (sets the brightness to level found via cat...)
...this should work on all devices.
Hi,
i was really annoyed by not having a Status LED on this phone and digged into this. First i tried Setting the Battery level to something below 15 to make the Breathlight come on but as soon as a system Battery update was triggered the Light went off ... Next: Created a App to send a fake SMS to my phone (triggering the SMS_RECEIVED intend) - failed to get it running, needs to be a prviliged system app (priv-app), gave up on this ... looked into the sys interface ... and tadaaa:
Code:
cat /sys/class/breathlightdrv/breathlight/rgb
gave me "this rgb has four parameter R_level G_level B_level mode" ... so lets try this ...
Switching the light full on (steady)
Code:
echo "255 255 255 0" > /sys/class/breathlightdrv/breathlight/rgb
Switching the light full on (pulse)
Code:
echo "255 255 255 1" > /sys/class/breathlightdrv/breathlight/rgb
Switching the light full off (= dark steady)
Code:
echo "0 0 0 0" > /sys/class/breathlightdrv/breathlight/rgb
now with this info and Tasker you can add your Breath Notification to e.g. K9 Mail Events, i have to look into tasker to catch e.g.Whatsapp, Threema etc incoming Messages events to notify with a nice pulsing Breathlight
Here is my working tasker definition, rename to backup.prj.xml enjoy!
don't forget to run the task as root!
dfs_ said:
Hi,
i was really annoyed by not having a Status LED on this phone and digged into this. First i tried Setting the Battery level to something below 15 to make the Breathlight come on but as soon as a system Battery update was triggered the Light went off ... Next: Created a App to send a fake SMS to my phone (triggering the SMS_RECEIVED intend) - failed to get it running, needs to be a prviliged system app (priv-app), gave up on this ... looked into the sys interface ... and tadaaa:
Code:
cat /sys/class/breathlightdrv/breathlight/rgb
gave me "this rgb has four parameter R_level G_level B_level mode" ... so lets try this ...
Switching the light full on (steady)
Code:
echo "255 255 255 0" > /sys/class/breathlightdrv/breathlight/rgb
Switching the light full on (pulse)
Code:
echo "255 255 255 1" > /sys/class/breathlightdrv/breathlight/rgb
Switching the light full off (= dark steady)
Code:
echo "0 0 0 0" > /sys/class/breathlightdrv/breathlight/rgb
now with this info and Tasker you can add your Breath Notification to e.g. K9 Mail Events, i have to look into tasker to catch e.g.Whatsapp, Threema etc incoming Messages events to notify with a nice pulsing Breathlight
Click to expand...
Click to collapse
Can you help me how I can change the notification led on my vowney lite
arpagr said:
Can you help me how I can change the notification led on my vowney lite
Click to expand...
Click to collapse
What do you want to have exactly? Install tasker and use my posted config should be all there is to it
Help
I tried these profile in my lite vowney and does not work it teaches profiles no
active What?, Can you help? Thanks
The profiles don't have to show as active, they are only active when messages are new, does the blink on/blink off actions work when started manually?
dfs_ said:
The profiles don't have to show as active, they are only active when messages are new, does the blink on/blink off actions work when started manually?
Click to expand...
Click to collapse
I did not try it manually
lebrillo said:
I did not try it manually
Click to expand...
Click to collapse
go to tasker / Tasks / Blink On/ press the play button in the lower left corner.
does it blink?
dfs_ said:
go to tasker / Tasks / Blink On/ press the play button in the lower left corner.
does it blink?
Click to expand...
Click to collapse
no, /rgb root: false timeout:-1
now work, is root. Than´s for you work
Thank you so much!
I have zopo zp920, and it works flawlessly.
Do you think that steady light will drain way more battery than pulse one? I am thinking that I will use both (steady and pulse) notifications on different occasions..
Dunlop77 said:
Thank you so much!
I have zopo zp920, and it works flawlessly.
Do you think that steady light will drain way more battery than pulse one? I am thinking that I will use both (steady and pulse) notifications on different occasions..
Click to expand...
Click to collapse
great to hear it works the same on your device; regarding battery life - i have no idea i guess you will have to test if the drain is even noticable
dfs_ said:
Here is my working tasker definition, rename to backup.xml enjoy!
don't forget to run the task as root!
Click to expand...
Click to collapse
If I try to import your tasker definition as tasker profile I get a error message: Error: the imported file contains more than one profile. Any advice to import your profile correctly.
quick google showed this - rename file to backup.prj.xml
Hello everyone,
I have used so many times the XDA forums to find some answers and I have found mostly all the answers I needed on other threads. But for once, I might have a more complicated problem to submit to the experts on this forum.
My use case is to create the lightest app that can do a job (namely taking a picture) on a regular interval of time and consume the least battery possible to be able to run for the most time without external power source (that is to say, the phone plugged in a wall outlet).
From what I experienced so far, I managed to have my application run for about 10 straight days doing the job every 10 minutes on a rooted Moto G5 phone. To achieve this, I force the phone to go in Doze mode at the beggining, by calling :
Code:
dumpsys deviceidle force-idle
Doing that, I schedule my jobs using the AlarmManager with the "setExactAndAllowWhileIdle" method thus respecting the super-9 minutes window my alarms should respect in order to be triggered correctly while the phone gets in deep sleep (following the official documentation).
For the moment, this is working as expected, because when I make a bugreport and import it into the Battery Historian tool, I can see that the phone is awake only when my job is running (for around 1 minute) and all the rest of the time, the device is sleeping and even better when I look in logcat, the phone suspends the CPU's for most of the time, which is great to consume less battery when not needed.
Now comes my problem, in order to make the app run for a longer period of time without having a wall outlet nearby, AND without touching the phone, I want to extend my battery life by using an external power bank plugged into my phone. My problem is that I cannot manage to make the phone not be awake while charging the phone. I guess that the phone is keeping some kind of wakelock when charging, so the USB connection keeps the phone awake and make my phone consume 3x more than when it goes in deep sleep, suspending the CPUs and is not awake. I tried to put some flags in a lot of files in order to trick the phone to think nothing is connected to the USB port but it didn't work. I tried those files:
Code:
"echo 0 > /sys/class/power_supply/battery/charging_enabled"
"echo 0 > /sys/devices/virtual/android_usb/android0/enable"
"echo 0 > /sys/class/power_supply/usb/present"
"echo 0 > /sys/class/power_supply/usb/ch_present"
"echo 0 > /sys/class/power_supply/usb/online"
"echo 0 > /sys/class/android_usb/android0/enable"
"echo 0 > /sys/class/android_usb/android0/remote_wakeup"
The only thing that stops the charge is when I put a 0 in the following file:
Code:
"echo 0 > /sys/class/power_supply/battery/charging_enabled"
It effectively stops the charge but the CPUs are still in an "awake" state, meaning there is probably still a wakelock being kept.
Do you have any idea how can I do, only using software, other than what I tried to stop the phone from being awake while having a charger plugged in (even if not charging) ?
Thanks a lot in advance for your answers.
Hi,
I am Aurelien, a colleague of Rafouuuuuu. Some precisions:
We use a "always-on" battery.
Phone awake = cpu is not stopped.
According to the historian report, the wakeup reason is "unknown".
These lines:
Code:
"echo 0 > /sys/class/power_supply/usb/present"
"echo 0 > /sys/class/power_supply/usb/ch_present"
"echo 0 > /sys/class/power_supply/usb/online"
"echo 0 > /sys/class/android_usb/android0/enable"
disable usb connection and charge but the cpu is always on.
We try to stop adbd service (if adbd get a wakelock if usb plugged)
We try to disable developer option.