Android - Disable/Enable charging - android

I would like to know how could I force android to stop charging at a certain level, and then re-enable charging at a lower level.Mainly, I want to avoid the overheating of the battery and always keeping the battery at 100% is not good for li-ion batteries.
Device is Samsung Galaxy Tab 2 10.1
Can it be done in /sys/class/power_supply... in modifying a certain file?
If it can be done in the kernel, what would be the files I should be looking at?
Why I want to do that?Because...
I have few of these tablets ALWAYS plugged and YES the batteries SWOLLEN and I would like to avoid this.
Thanks.

I think it can not be achieved with sysfs level.
How about some applications like task? Latest android has a new quick panel for charging. I saw it can limit to charge if you want to stop, though the TA is connected.
I think you can fix kernel charging driver, however it will definitely be a tough way...

Related

Android tablet kiosk development

I am trying to develop a kiosk application on Android.
I am facing two challenges.
Once the tablet getting off due to a battery drain it is not turning on even after the battery reached 100%. Is there a workaround for this? I have seen regarding editing some files in /system/init of Android after rooting. But I have not seen any file related to battery or charging. I am using 4.1 and higher
I am experiencing a problem of battery draining. As it continuously keep display on, battery drains gradually even if the charger is connected.
Has anybody came across similar problems and find any solutions ?
Is there android devices available which , power on automatically after connecting wall charger ?
Is there tablets that doesn't have battery and directly works from charger connection ?
Please provide your suggestions.

Nexus 7 NFC interfering with Wireless charging

From my initial research and experience with wireless chargers for my Nexus 7, it appears that there are issues with wireless chargers interfering and causing issues with NFC functionality. Note, I am not talking about doing both simultaneously. Rather, I am speaking of whether there are detrimental effects on the NFC antenna due to wireless charging over time. I gather that both inductive charging and NFC use the same coil on Nexus 7 (?)
I have personally seen wirelessly charged Nexus 7's NFC scans/tags not registered, but do not know for sure if these two are related for sure. My basic understanding is that the NFC antenna is right near the wireless charging area in the back of the device.
Moreover, wireless charging it's too slow; often times, it seems as though it's slowing down the battery drainage than actively charging it.
Questions to the community are
1- what's the best wireless charger out there? Specifically, one that does not interfere with NFC functionality both at a hardware and software level?
2- if the NFC functionality is hurt, what's the best way to troubleshoot it? I am experiencing inconsistent scans-- 1 out 5 scans are not registered and the device needs to be powe cycled.
We've had some experience with this behavior. Specifically with our NFC Patch Kit products rather than wireless charging. The issue is with the Automatic Gain Control (AGC) system built into NFC controllers. It's main purpose is to adjust the power output on the antenna coil to optimize the field while minimizing battery drain. Here's a snap shot from the BCM20793S spec sheet (same as BCM20793M in Nexus 7 only without Secure Element):
A “false alarm rate” can occur when the [low power target detect] can be triggered by
metallic objects, but any trigger will be qualified by a full poll
event and therefore can be discounted if it is not a real target. The
control algorithm includes a background calibration, so it
auto-adjusts to a background baseline to account for drift and
changing conditions.
So what's happening is that the Nexus 7 antenna is getting desensitized as the wireless charging pad is put in the field. If seems the Nexus 7 firmware stack is not smart enough to detect the wireless charging presence and deactivate the NFC controller altogether to prevent the problem. Or at least trigger a recalibration of the LPTD mode. We do this with our FloBLE product.
So to answer your questions explicitly:
what's the best wireless charger out there? Specifically, one that does not interfere with NFC functionality both at a hardware and software level?
In order to achieve good coupling between wireless charger and device, they need to have a tuned induction coil. So you can't really swap out the Nexus charger for another and expect to improve anything. The issues above will remain and you'll probably end up with a weakened recharge experience. That said, I've found the Duracell Powermats effective in good wireless charging performance.
if the NFC functionality is hurt, what's the best way to troubleshoot it? I am experiencing inconsistent scans-- 1 out 5 scans are not registered and the device needs to be power cycled.
This is a SW bug of the Nexus 7 low level NFC management system. You should be able to reset the LPTD calibration by enabling/disabling NFC from the device Settings screen. I've found power cycling is the only way to achieve it though. You could log a defect against the Nexus 7 2013 board support package (BSP) and reference this post.

Why does my Android application drain battery?

I've written a simple application that displays some text and a little bit of graphics on screen. I'm using a Nexus 7, this is for an installation, and as such needs to be on continuously as much as 12 hours a day. However, despite being plugged in and charging, my application drains the battery completely in about 8 hours (10-15% / hour).
Apart from the infrequently-changing text and graphics, my application does two things:
It keeps the screen on, at full brightness (via WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); and
It opens two DatagramSockets, one to act as a UDP client, and one to act as a UDP server. These sockets are both opened automatically and managed by the library I'm using, OSCP5. It's open source, so I can hack it as needed, though the less the better. (KISS.)
I've tested the Nexus 7 battery life with no apps running, screen at full brightness, with a tickle every 29 minutes to keep it from sleeping, for a few hours with no battery drain at all. So, signs seem to point to the sockets. I don't have frequent communication on those sockets, they receive approximately a few KB every minute (based on user interaction with another part of the installation).
Is there anything I can do, specifically with the sockets, or any other general testing, to minimize or eliminate the battery drain? I only need to get through 12 hours, but keeping full charge while plugged in doesn't seem like it should be such a tall order...
However, despite being plugged in and charging, my application drains the battery completely in about 8 hours (10-15% / hour).
What do you have the Nexus 7 plugged into? I think it can take advantage of a high-speed charging USB port, the kind you need for most tablets (Android + iPad). I could see your results being more likely if you have this plugged into a garden-variety USB port.
So, signs seem to point to the sockets.
They're certainly a candidate, though since the WiFi radio would probably say on while the device is charging anyway, I'd be a bit surprised. To me, this feels like a CPU issue, where you're busy-waiting or something rather than blocking.
Is there anything I can do, specifically with the sockets, or any other general testing, to minimize or eliminate the battery drain?
I'd see if Traceview points out where you're consuming lots of CPU time. I'd investigate the charging port issue. I'd modify your app to mock the socket work and try to see if your problem persists -- if it does, then the issue isn't the sockets.
Well, keeping the screen on full brightness will really suck down the power. The GPS will do it too; I think those are the two biggest power sinks.
Keeping the network radios busy and keeping the cpu busy will also suck down the power. I hope you're not busy-waiting in any of your software.
Other than that, all I can suggest is that you use the high-power charger that likely came with the tablet. USB data ports are limited to 500mA current, and I've worked with more than one device that can require more than that to keep the battery alive.
Three months and endless head-desk-banging later, it turns out the culprit was my USB run. The total length is around 20'-25', and the length is attenuating the power that gets all the way through the line. Solution: powered USB hub.
So, the answer ended up having nothing to do with Android or programming at all. Sorry, SO.

Auto shut down event when battery is low

I am trying to find where in the android source code the event that tells the device to shut down due to low battery it located.
I am currently looking at cyanogenmod source but I imagine this is a common area for all mod sources.
Can anyone point out where this is and if possible how to prevent the phone from shutting down?
To clarify why I want to do this:
I have a faulty phone that always reports the battery level to be zero when I know it is not (I have tested the battery in other phones and other batteries in the faulty phone). Preventing it from shutting down would just extend the life of this otherwise useless phone.
in BatteryService.java ,when the battery lvl is too low (0%, lower than 3.4v),the service will call shutdownIfNoPower to shutdown system.
By the way, is your phone has been ADC calibrated ? or the calibration data had been destoryed....

How to stop an android device from being charged programmatically?

Is there an Android API for stop charging even though physically the charging is on?
Reading previous answers, it looks like there's no way to do this exclusively in software. However, it should be relatively easy to do it with a little hardware help - i.e. by using any Bluetooth- or WiFi-enabled smart electrical switch with open API. The phone could then switch the charger on or off programmatically whenever it feels like it.
Is there an Android API for stop charging even though physically the charging is on?
AFAIK no.
Justification:
android.intent.action.BATTERY_CHANGED is a protected intent that can only be sent by the system. Therefore you cannot duplicate or override the functionality.
You guys are all missing the point - the purpose of limiting charging is to increase battery lifespan by keeping it away from fully charged conditions (and near empty but that's a different issue). If you anticipate needing a full charge then tell it to charge to 100.
If you can't set a charge limit then the battery would rarely be idle and ideally charged when on the charger. It probably requires device level support though.
https://play.google.com/store/apps/details?id=es.guille.stopcharge uses echo "0" > /sys/class/power_supply/battery/device/charge. It works for me on a nexus 4 (rooted), as long as the device isn't fully charged (in a charging state).
Also relevant: https://android.stackexchange.com/questions/15001/how-can-i-avoid-the-battery-charging-when-connected-via-usb
Contrary to some answers indicating it's not possible, it is, indeed possible with ROOT. You can find some apps on the Play Store that will allow you to do this (with root permission, of course).
The best app that works on every phone I've tried it on is Battery Charge Limit. You can download it from the Play Store or the XDA discussion thread. The app is under active development so, if you find that your phone isn't supported, just submit an issue on its GitHub page.
NB: I am not the developer of this application.
This is unfortunately not possible. Android only have read APIs for battery data.
Battery charging control is internal to the Android kernel and battery IC modules. Manufacturers do change it from time to time, like HTC is having small cycles from 95-100% (a bad idea IMO), Samsung does stop charges as soon as it reaches 100%, but I've never seen a device able to stop charging before 100% to reduce battery aging :(.
At best if we're lucky, a sysfs interface might help do that, but it requires root and will differ from device to device.
Just to add to this. Samsung phones do not stop charging after 100%. As far as I'm aware they "trickle" charge past this point however they recommend you do not charge your phone past 100% for over 1 hour. Battery manufacturers like Anker also state the same so the idea of stopping the charge at 100% would be really useful. The risks of leaving the phone on charge are battery bloat and eventually cell rupture. I wasn't aware of this to start off with an killed my samsung battery within 3 months of owning the phone.
To expand on the original question. I've noticed some kernels allow fast charging. If they are able to alter the charge rate up could we alter the charge rate down (trickle) to meet a desired finish time (when your morning alarm goes off)??
I have installed a timer on the AC receptacle where I plug my Moto E's charger into. After guestimating how much time the battery needs to charge to about 85%, I set the timer. This is not my idea of a solution, but at least it keeps my phone from being charged to 100%, as I usually err on the short side when setting the timer.
I dont think there would be such an api. If it does exist it needs to be supported by the device manufacture as its not a pure OS lever feature. The same reason would make it a bad idea to use it as not all devices will support it.
That being said it would be a bad idea to use/implement it , mobile devices are not built to directly run from the power supply and a user will not plug in the cable if he/she did not want to actually charge the device.

Categories

Resources