Android : Difference between BATTERY_STATUS_DISCHARGING and BATTERY_STATUS_NOT_CHARGING - android

I want to know the difference between the two flags
BatteryManager.BATTERY_STATUS_DISCHARGING
And
BatteryManager.BATTERY_STATUS_NOT_CHARGING
I developed an application that uses these two flags, and I expected to see "discharging" when I unplugged the phone from the charger, but instead it simply says "not charging".
What is the difference between the two ?

from : Battery is low. Charging current not enough...Is there intent before this message is shown?
Some devices (tablets?) consume more power than what can be provided via USB port.

I can find no clear definition of the two in the Android APIs or elsewhere online.
My best guess is that BATTERY_STATUS_DISCHARGING indicates that the device is actively draining power, while BATTERY_STATUS_NOT_CHARGING indicates that the device is plugged in but is not receiving enough power to actually charge -- for instance, if it is plugged into a low-power USB port.
However, there are other reports from developers that certain devices never return BATTERY_STATUS_DISCHARGING, even when completely unplugged: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-reviews/1AjyPYt0tQs
In particular, the Nexus 7 2013 seems to have this bug (confirmed by personal experience): https://code.google.com/p/android/issues/detail?id=124768.
Presumably, you ran into a similar bug.

The other option for not charging is simply that the battery is full, hence no need for charging or that there is no battery at all.

Related

How to check within an app if the device is connected to a power supply?

I see many reasons why an app should behave different if the device is connected to a power supply, via USB cable ore otherwise.
For example, with power on and effectively charging, it could be used as an image viewer, which would be prohibitive if running on battery.
So, how to let an app check if power supply is on, and, if the battery is charging or still running low (due to other power consuming processes or perhaps just because it's old and leaking).
Edit: in view of the comment that points to a method to get noticed of changes of power supply:
This is valuable, maybe for other applications, but I'm asking for actual power supply minus battery need for recharging.

[Android]: prevent USB device from sleeping when Android device sleeps

We are making a SIP-related solution and I am requested to compose an app on a customized android pad(4.4.*). Unluckily, the pad is from 3rd party and accordingly we hardly do further jobs on the framework or driver......
On the Pad, a LAN port is designed over USB and we plan to access network via LAN. Besides, no power key is populated on the cover.....
Now the question is: Since the pad sleeps, the LAN connection is stopped soon. I fully understand it's a normal behavior that android conducts. I am trying to acquire known wake lock(partial or WIFI lock) to stop USB controller from sleeping ... but, currently, little progress. is there any usb-related wake lock, just like wifi lock ?
I have solved the problem from the perspective of HW .... I am not sure the solution is really meaningful to the current topic. But I think that sharing the idea with you is the major goal of the forum running.
a MOS component is added along the power line controlling Screen. Then I manipulate the connection/disconnection by sending command to MCU....
Based on my experiences , it is really hard to extend functionality on a poor quality of pad ... poor post-sales support.......
Hope you it's helpful to you.

Android BLE disconnected when screen off (without charger)

It's working well on most Android devices.
Other device's screen gets locked after 1 minutes BLE device gets disconnected,if device without charger.
Thanks for any suggestions!
this might come from the Keep Wi-Fi on during sleep option (which might affect all radios) - as it seems this only exists in 8.0 but not in 8.1 (at least on the Pixel 2 XL, according to this article).
You might be having this problem because your app is not properly configured to handle Doze mode.
While there do not seem to be any restrictions on using BLE itself, doze mode might be messing with the control mechanism for your bluetooth connection (ex: a background service).
To see if this is the issue, you can whitelist your app manually via Settings > Battery > Battery Optimization and disabling optimization for your app.
Furthermore, as of Android 8.0, there are restrictions on background services when your app is not in the foreground. So, you may need to create a foreground service to handle the connection.

Is it possible to start the phone without pressing power button?

I have an app which is running on an android device which has no battery. It's just charging all the time and the app is running. But sometimes the device is not charging and logical to that the phone will turn off.
When it's charging again the device should start from itself and boot. The user shouldn't press the power button. That's the requirement.
Is this possible anyway?
Can I achieve this when I root the device?
Has anybody experiences with that case?
in short: No.
ADB is not running when the phone is powered off, and as #langerhans said, wake on alarm is proprietary
You could do a hardware solution where you hijack the battery pins to a power station or modified charger. (make sure you do not feed any power through usb at the same time)
It should be cheap and quite easy to build.
Generally, this is not possible. It is highly device dependant. Some devices allow alarms turning on the phone to ring as an alarm clock even if they are turned off. But this is a proprietary feature and therefore not easily accesible to custom applications.
I have basically the same problem running an Odroid device which luckily turns itself on after power loss, but if I shut it down manually, I can only turn back on with pulling the power.
The only thing I could think off would be an extra watchdog device, but I have no idea if something like that exists. Maybe you'd need to build it yourself.

Android charging behavior when in use

I'm working on a hardware/firmware/Android app project where the Android (in this case a Nexus 7 tablet) connects to a custom hardware platform via USB. The Android is in Accessory mode, which means the other end of the wire (the Host) supplies power to the Android. The hardware has a dedicated 5V 2A switching supply for the USB connector so there is plenty of current available for the tablet.
When the Android is plugged in to the hardware, it reports that the battery is charging and it requests 500mA from the USB connection (for those who don't know, the USB protocol requires the device to inform the host of its current requirements). The hardware easily provides this current and the 5V stays rock-solid.
Despite this, the charge level never changes as long as the device remains in use. This application uses the tablet in what is basically a kiosk mode - the display stays on at full brightness continuously. Sleep the tablet and the battery charges, but leave it on and there is no reported change in the battery level.
The only explanation I can think of is that the Android's power supply circuitry cannot simultaneously handle the current requirements of both full operation and battery charging. But I wonder if this is a conscious decision based on expected power availability, and if there may be some sort of configuration option in the OS that would inform the OS that more current is, indeed, available. Perhaps then the OS would request more current from the Host and have enough to both charge the battery and run the device at the same time.
Anyone have any data on this? Thanks!
When I started a company that designed battery chargers for cell phones and the like, I didn't realize that it took more than providing a voltage source to a USB connector. At first we encountered having to provide different voltages on the data pins to tell the connected device how much current it could expect to draw. Now there are several manufacturers of USB interface ICs that do all the dirty work of handshaking and act as current limiters as well. Most smartphones today draw an average of 1A from the 5V USB bus. Some can, and will (especially Apple products) draw up to 2.1A if allowed. Most tablets run in the range of 1.5A to 2.1A. Any of the above will run in a mode drawing lesser current, if the device finds the charger unable to supply the full current. This will sometimes, as in your case, allow the device to either run or charge, but not both. In some cases, the available current isn't enough to maintain a charge level , and the device's battery slowly discharges, even though it's connected to a charger. If you Google "USB charger data pin voltages" you can see how to tell your device it can draw more current. The proper method though would be to use a controller IC something like TI's TPS2511 "USB Dedicated Charging Port Controller and Current Limiting Power Switch". Hope this helps and isn't too too late.

Categories

Resources