How does Android's scan-only mode work? - android

Android 4.3 added new 'software' feature that keeps Wifi get scan results even if Wifi is off. It says that this mode consumes very low power.
My question is how this technically done, and how much power saved compared to just enabling Wifi?

The logic is simple: driver and wpa_supplicant is never unloaded from the memory, unless scan-only mode is disabled in WiFi advanced menu via Scanning always available option.
In terms of power consumption - the numbers will differ for every WiFi solution, but according to my experience (being an WiFi engineer for one of the Android OEM's for last 4 years), the difference is minor. Below is an example of some average consumption numbers:
Phone is awake, WiFi disabled: ~220mA (depends on many factors, just an example)
Phone sleeps, WiFi disabled: ~5mA
Phone sleeps, WiFi enabled (sure, applies to Scan-Only mode as well): +5mA
So, if you are an active user, turning Scan-Only off will not give you huge power savings. On the other hand, if the phone usage is somewhat passive, turning this option off could give some extra battery life.
Personally, I keep this option on, since I prefer immediate WiFi availability when I enable it over that minor battery win.

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.

Is there any way to keep WIFI always ON, ignoring even the Power mode set by the user?

I am making an android app which requires WIFI to be always ON even if phone gets locked. Also, power mode selected by user shouldn't make WIFI to turn OFF. For example, if user selects "Power Saving" mode than OS will automatically turn OFF the WIFI which I want to ignore & just keep it ON forever?
Is it achievable?
The only thing that you can do is use WifiLock. This keeps the WiFi radio on when it was already on. However:
It does not override manual user control (e.g., airplane mode)
AFAIK it will not change full Doze behavior, where network access is suspended (though the user could add your app to the battery optimization whitelist)
Some device manufacturers have added more aggressive power management features, and it is possible that WifiLock is ignored for them
Users may get irritated if they feel that you are using an excessive amount of power, and users can express their irritation in a variety of ways, few of which are pleasant

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.

Can Android be woken up from sleep by a peripheral device?

Can Android be woken up from sleep by a peripheral device such as an arduino microcontroller?
Additional details:
I am looking to save power by putting the Android device to sleep and having the low-power peripheral device wake up the Android device only when an "interesting event" occurs (e.g. abnormal sensor reading)
The device probably cannot be woken from true CPU sleep (which is a level beyond having the screen off) by ordinary software/signalling means.
However, enabling a 5v power source to the USB jack probably will wake up the majority of devices which can charge via USB.
If they are connected to an actual USB host (vs a simple power supply/charger) my suspicion is that they would not enter CPU sleep at all. Both the android accessory kit and IOIO schemes have the external microcontroller functioning as a USB host and providing power, so it's likely sleep would not be an issue. Or if you need to save power, you could probably make the externally sourced power switchable.
Two additional possibilities to consider are using a partial wakelock to prevent CPU sleep, or setting alarms to wake the device periodically so that background code can check for some event.
Just tested this. I have some USB thumb drive OTG adapters and when I connect the adapter without thumbdrive, the phone woke up. I think it has something to do with two pins on the micro USB socket, pin 5 and pin 4 tight up together.
Adapter I am talking about:
Pins:

Android Hardware Battery temperature, where is the sensor?

I have a stupid idea. With android is simple to get battery state (volt, charge, temperature, ecc).
BatteryManager.EXTRA_TEMPERATURE
I think that the sensor is located inside lithium battery pack, in fact there are 3 pins over it connecting to the phone. Maybe that one of them is the battery sensor temperature. How it works? It's possible, but i know that damage may be relevant, isolate that pin and connect the phone pin to an external sensor?
So we can catch outside temperature using battery manager....without using Google IOIO or Arduino just for reading a temperature.
THAT'S ONLY FOR STUDY INFORMATION! PLEASE DON'T TALK ABOUT DANGER OF LITHIUM BATTERIES...
Thanx a lot!
In theory, yes, but the battery temperature is critical in the charge/discharge cycle of the phone. Phone batteries charge by applying a constant current to the battery. When the phone is charging the battery temp will rise (a byproduct of mixing electricity with chemicals). If it rises too far, the battery will fail (and could [in theory at least] explode).
Thus the phone's charging circuitry needs to monitor the battery temp so if it rises beyond a given threshold it backs the charging current off until the temperature stablises, ensuring the battery remains within safe limits.
In other words -- if you do override it, do so at your own risk.
Yes, the temperature sensor is located inside the battery pack. The standard setup is a 103 NTC (negative temperature coefficient) thermistor to ground. The 103 means that is has a 10K resistance at 25C.
Yes, you can measure ambient temperature using this. It may read higher if the battery is either charging or discharging (as the battery will get warm). It will respond fairly slowly to environmental changes due to the isolation and thermal mass of the battery.

Categories

Resources