I want to write code that will disable battery charge when reaching 80% and enable when gets to 20%, should work on LG K4 5.0.
I have been looking around and tested a lot of solutions but none of them work.
Changing sys/devices/platform/battery/power_supply/ac/online to 0 or
sys/devices/platform/battery/power_supply/ac/present to 0,
cause android to crash and reboot.
I have found a file called LGBM_AtCmdChargingModeOff when changed to 1 it stops charging but can't change it back to 0, after reboot, it's 0 again.
Any idea on how to change this file back to 0 without a reboot?
cat doesn't work.
vi doesn't work.
paste with value = 1 doesn't work.
Just use Chargie (google for "chargie stick"). It's a Bluetooth charge limiter that does exactly what you want (hysteretic charging).
Related
Android 5.0 includes a new way to control which apps are allowed to make noise on your device: when you press the volume button, the popup now lets you to choose None (completely silent), Priority (only priority notifications make sound), or All (everything is allowed to make noise.)
I would like my app to be able to query the device to find out which of these three modes is currently active, and also I would like to be able to change these modes (without requiring the device to be rooted). Does anyone know how to do this?
So far, all I can find is a brief reference on this changelog:
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
This works as described, which allows me a very limited ability to change "priority mode" by modifying the ringer mode in AudioManager. That's not enough, though, as I need to be able to know exactly which of the three priority mode settings is currently active, and it would also be nice if I could change them more precisely than AudioManager allows.
I've found a solution, but this requires root to change, because this setting is in Settings.Global.
Name of setting is "zen_mode".
Values are:
ZENMODE_ALL = 0;
ZENMODE_PRIORITY = 1;
ZENMODE_NONE = 2;
EDIT: I've found another solution. Check NotificationListenerService.requestInterruptionFilter(int interruptionFilter). https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
Implementation example: https://github.com/kpbird/NotificationListenerService-Example
Just tested my app on new Android 5.0 and found that it have some bug in switching ringer mode via Audio Manager. After set RINGER_MODE_SILENT it comes to "Allow only priority interruptions" mode and it's ok, it's how described in what's new document. But after set RINGER_MODE_NORMAL phone doesn't come back to "Always interrupt" and this is not expected behavior. User can miss the call because of it.
Does someone find solution/work around this problem? How can I turn off this filtration mode?
Update
Found this code in Android src. This settings is Global.ZEN_MODE. And code that should change it on set NORMAL_MODE looks like correct, but it doesn't work in Emulator and Nexus ROM. Had try to set via Settings.Global.putInt, but got error about permissions. Have no idea how to fix it =(
Made bug report: https://code.google.com/p/android/issues/detail?id=78158&thanks=78158&ts=1414182304
And in preview tracker https://code.google.com/p/android-developer-preview/issues/detail?id=1780&thanks=1780&ts=1414218141
Just found some work around. We can use NotificationListenerService.requestInterruptionFilter to change filtration mode. It works, but you have to add your service in "Notification access" list (it's in Sound & notification settings), otherwise you will have no permissions.
I have a problem with my Eclipse. LogCat just holds messages about 10 seconds and after that they will disappear before i can read them.
Anyone knows how to avoid hiding logCat messages?
Edit:I don't know what's going wrong with my LogCat. When i connect my galaxy s2 device it shows around 1000 messages in just 2 or 3 seconds!
here is one of them.they are mostly like this:
01-24 16:56:47.353: D/(2001): [HYPOS] NOMOVE Time 24653125, PowerMode 2, GPSWeakSignal 54, GPSFixTime 0, IsPedestrian 0, DOE 3editcode here
LogCat view got limit on number of lines it keeps in scroll buffer. By default it is set to 5000 lines. On some devices, where activity is high, this can be not sufficient. To increase the limit go to Ecplise settings: Window -> Preferences -> LogCat and increase value of Maximum number of logcat messages.
Note that freezing autoscroll is NOT a solution. You just freeze the autoscroll but data are still being read from the device and placed in logcat buffer.
Another option is the use of the following command in command prompt which will provide you all logs,
adb logcat > LogFileName.txt
Again you can customize this based on your device or emulator names when more than one devices or emulators are available by specifying their names.
Before i ask this question, i've realized it, but it is based on some conditions.
Try1: Change the chmod of file '/sys/class/leds/button-backlight/brightness' to 777, the original file is readable but not writeable, then write '1' to this file to turn on led backlight, '0' to turn off. However, i don't want to change the property of this file.
Try2: something like 'Try 1', that is: Runtime.getRuntime().exec("echo 0 > /sys/class/leds/button-backlight/brightness"); to turn off, Runtime.getRuntime().exec("echo 1 > /sys/class/leds/button-backlight/brightness"); to turn on, but this requires your phone has been rooted or you're a super user when execute the code. So, it isn't the solution that i want.
My thought: i can follow the way that Android System itself turn on/off the led backlight when we touch key like 'Menu', 'Home', 'Back'. But, i don't know how to track or find the ralated code in Android Open Source Code.
I do really appreciate any tip, any thought or any possible way that you provide.
until recently my logcat has been fine but all of the sudden whenever i try to view it in eclipse it just keeps clearing itself whenever anything is displayed making it impossible to read. viewing it in the adb works but I never bother with that since it is just such a pain to read and find anything you are looking for.
is there a way to fix this problem?
The Logcat messages were simple getting cleared because the buffer had run out of space (receiving too many new messages), which is a simple setting change in Eclipse.
To fix, go to Window > Preferences > Android > LogCat
and increase the limit for "Maximum number of LogCat messages to buffer". Set it to 0 for unlimited size, or a really big number. But keep in mind, anything below 10000 fills up real fast.
Been answered already:
Eclipse Android - Logcat Clearing too Fast
It will show one line before erasing it to show the next one? Just click the verbose button again.
There's a workaround for this bug. Click active mode button (usually verbose), choose another device from device list and choose previous device again. It will restore all logcat messages.
LogCat is really annoying for this. In Ubuntu, I found the following works really well:
Open a terminal and type adb logcat | grep MYINFO
This will only show adb messages filtered by the MYINFO string.
So, you can code something like:
Log.v("MYINFO", "x" + x_value + ", etc...");
This is such a relief to use. A life saver! See this for more info.
You may find sometimes the logcat buffer repeats previous logs on starting again. To overcome this, type
adb logcat -c