when android phone is in SLEEP State 0r Locked State What is the state of WIFI ?
is it active or not?
It's depend on application. By default in Sleep mode wifi state is inactive. Application need to take a wifi lock to keep it acive.
It depends on many factors, including those that others have metioned:
In your android settings, wireless settings, advanced settings- there is a wifi sleep policy which can somewhat answer your question.
However, an application (with the appropriate permission) can change this setting or temporarily change it to bypass the setting.
"Sleep" is pretty vague because some consider this when your display is turned off, however a device actually has different levels of sleep, and deep sleep. Deep sleep doesn't kick in as soon as the display is off, and often these rules are referring to deep sleep.
Applications can also obtain a wifi lock (with the appropriate permission) which will wake up the Wi-Fi radio even though the phone is in deep sleep.
Must be active, I've downloaded stuff from the Market place whilst my phone (HTC Desire) has gone to sleep, and the download has finished the next time I unlock (wake) it.
Related
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
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.
I have been reading as much as I can regarding the developer docs for the Android SDK about the following:
Wifi wakelock
WifiManager.WIFI_MODE_FULL_HIGH_PERF
Wifi sleep policy
They all make sense in their own context but I can't see the "big picture" so to speak.
I guess that both the wifi wakelock and the WIFI_MODE_FULL_HIGH_PERF setting overrides the user sleep policy. Is that right?
If I have the sleep policy on "Never", and I just make experimental APK:s for myself which is downloading stuff in the background via wifi, I guess I don't need the wifi wake lock nor the WIFI_MODE_FULL_HIGH_PERF?
The code I have seen using a wifi wake lock has also acquired a power wake lock. Is there any occasion where I only want to acquire the wifi lock but not the power lock?
If the device goes into a deep sleep and shuts down wi-fi radio, the wi-fi lock will wake it back up when the lock is acquired. Correct, this is regardless of your wi-fi policy.
I think you have it backwards- the policy question says "Keep Wi-Fi on during sleep" so if you want to avoid the need for wifi locks, you would choose the "Always" option value. I'd like to see a battery consumption analysis of Wi-Fi stay connected, versus sporadic 4G in deep sleep...
I have never needed or used a power wake lock. Just system and wifi, and everything has worked fine for me to perform the functions desired.
I'm Developing an Android Application where it's constantly required to keep the App up an running at all time. with the phone connected to a power outlet at all time, Is it possible that if the phone's battery died to Auto-start up the app with no user intervention . *i.e to power up the phone automatically without hitting any power button and start up android since charger is connected. *
then start up my app with android.intent.action.BOOT_COMPLETED and RECEIVE_BOOT_COMPLETED permission
PS: I have tried android.intent.action.ACTION_POWER_CONNECTED but it only works if the phone is already powered up.
I have exactly same requirement as yours.
Can we plan a solution like this:
The Android device is always connected to charger's output.
Charger's power supply is connected to a custom made hardware device which controls power supply to charger.
This hardware device puts charger off until battery is getting low. i.e. 20% remaining.
Once battery is less than 20%, that device automatically switch on the charger.
The "custom made hardware" gets it input from android device itself via USB/WiFi/Bluetooth.
Just a thought. May not be practically possible.
No way doing it if you do not root your device and add reboot scripts to the programs running to show battery charging pictures when device is turned off and charging.for Samsung s2 here is an answer
Maybe you can make an additional app that waits for the BOOT_COMPLETED with its BroadcastReceiver and then check wether the power is connected and start as a new Intent your application?
Just a quick thought..
I have the same problem.
The solution that i will to implement:
1.- get out two(here is my doubt, ¿what two wires?, because i see three, i will use my multimeter for see continuity between wires when i push the button) wires from the power button phone.(when you push that button, it just connect two poles like a switch).
2.- When you have the two wires, so, we build a little circuit with a timer like a 555(integrated circuit). The purpose of the circuit will connect the two wires(from power button phone) by a 5 seconds period every 15minutes.
Obviously this circuit will be running always.
My objective is to be able to scan changes in Wi-Fi networks (mainly to check what networks are available). Right know I'm doing it by registering a reciever:
registerReceiver(wifiReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
where WifiReceiver is my BroadcastReceiver.
The problem is that it works only when the phone is on. As soon as it goes to sleep mode (either by pushing the power button or after some time), the receiver stops receiving. I already acquired a wake lock in onCreate of my main class and releasing it in onDestroy (it's a partial wake lock). Additionally I've tried this:
Settings.System.putInt(getContentResolver(),Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_NEVER);
to keep wifi from sleeping. Unfortunately that didn't help.
Is there any possibility to scan for network changes, even when phone is asleep? I want to be able to check what networks are in range (by SSID). Maybe I should use another action?
Appreciate your help.
Literally, no, the hardware isn't typically designed nor the low level drivers written to allow wifi to operate while the application CPU is in sleep mode - unlike the case with the mobile network interface which is intended to receive push events like phone calls, sms, and gmail "tickles".
So your choices are to either manage to successfully prevent the device from sleeping (good bye battery) or wake up periodically using an alarm, kick the wifi active, and poll the situation (still not good for battery life, but not as drastically so).
I'm afraid this sleep behaviour is managed by the system under (on Android 2.3.4) Settings > Wireless & Networks > Wi-Fi Settings > Press Menu > Advanced > Wi-Fi Sleep policy.
This could actually go against the users will, careful with that.
However I think there has to be a way to modify this param. programmatically, using this settings : Settings.System, and of course the corresponding permission in your manifest.