power-management

How is the Android battery health determined?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 18:03:59
问题 I am not talking about how to read the value. Rather, I am interested in how the value of BatteryManager.EXTRA_HEALTH is being set. Does it come from the firmware? Manufacturer specific? What determines these values? int BATTERY_HEALTH_COLD int BATTERY_HEALTH_DEAD int BATTERY_HEALTH_GOOD int BATTERY_HEALTH_OVERHEAT int BATTERY_HEALTH_OVER_VOLTAGE int BATTERY_HEALTH_UNKNOWN int BATTERY_HEALTH_UNSPECIFIED_FAILURE Thanks, Simon 回答1: To be more specific: The battery health is determined by the

Android accelerometer, sensor usage and power consumption

醉酒当歌 提交于 2019-12-03 12:46:41
I have a quick question about the accelerometer in Android devices. Is it always on/active? Given that accelerometer is used to detect the orientation of the device, either landscape or portrait. In the official documentation ( SensorManager ) it states that sensors should be turned off to save power. But I wonder if this only applies to others sensors like magnetic field sensors, gyroscope, light sensor and so on. I need to make a case for power conservation and I don't want to make the mistake of saying that the accelerometer can at times be disabled, and instead use it for the purpose of

How can I programmatically stop a notebook battery from charging

给你一囗甜甜゛ 提交于 2019-12-03 12:40:43
There is some easily available information on finding the status of a battery, or weather it's charging or not. (GetSystemPowerStatus API or System.Windows.Forms.SystemInformation.PowerStatus). I want to be able to stop a battery from charging based on some criteria, e.g. battery power > 20%. Is there an API to do this? I think it's impossible, because you have need some API for battery or battery charger. And this API can provide to you manufacturer of notebook and battery or battery charger support this. I honestly don't know, but I'd have a look at the APM or ACPI APIs. Other than that, the

iPhone4 how to find out if the power cable is plugged in?

隐身守侯 提交于 2019-12-03 08:36:12
I would like to know if my app is running with an external power cable attached. Is it possible to find out this state at runtime? An extra question: would this be able to differentiate between true USB power and those external "battery packs"? Thank you! Use UIDevice property batteryState : [[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging From UIDevice Docs : typedef enum { UIDeviceBatteryStateUnknown, UIDeviceBatteryStateUnplugged, UIDeviceBatteryStateCharging, UIDeviceBatteryStateFull, } UIDeviceBatteryState; As for your 2nd question. I don't believe you can determine

Android : Do something when battery is at a defined level

流过昼夜 提交于 2019-12-03 03:59:09
I'm stuck with a little problem here. I want my app to do something, but only when the battery is at 10%. My app doesn't watch the battery level constantly; it just waits for a LOW_BATTERY intent. It works if i don't specify a level, but it works 3 times: 15%, 10%, and 5% I only want it to do something at 10%. Here is my code : public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(ACTION_BATTERY_LOW)) { int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100); int percent = (level*100)/scale;

how to hook to events / messages in windows using python

吃可爱长大的小学妹 提交于 2019-12-02 22:31:58
in short: i want to intercept suspend/standby messages on my laptop, but my program doesn't receives all relevant messages. background: there's a bug in ms-excel on windows xp/2k, which prevents system suspend if a file is opened on a network/usb drive. i'm trying to work-around it programmatically (my toolbox include python, vb6, or command line tools). i know nothing about windows instrumentation :-) i have a sysinternals utility that suspends the system anyhow. i want to hook it to the close-lid event! in long: The notebook lid close (fujitsu u810) initiate the standby procedure [how?] The

How to keep android device from sleeping while plugged in

一世执手 提交于 2019-12-01 22:19:51
I'd like to keep the screen on whenever one of my Activities are running and the phone is plugged in to a power source. I know that Wakelocks are tricky, so I'm looking for an example or some documentation on how to accomplish this specific goal. hackbod Don't use wake locks for this -- just set and clear the window flag WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON based on whether the device is currently plugged in. You can set the flag with Activity.getWindow().addFlags() . So the code would be getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); A WakeLock isn't that

Read Magic Mouse and Apple Wireless Keyboard Battery percentage

拜拜、爱过 提交于 2019-12-01 19:22:07
I want to ask you If anybody know a simple way to access Mouse and Keyboard battery state in Mac OS. There are some API to access this information? Thanks! For the Keyboard it is: ioreg -n "IOAppleBluetoothHIDDriver" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g' and for the Magic Mouse it is: ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g' 来源: https://stackoverflow.com/questions/3547797/read-magic-mouse-and-apple-wireless-keyboard-battery-percentage

OS Reboot, Shutdown, Hibernate, Sleep, Wakeup (Windows Python)

扶醉桌前 提交于 2019-12-01 17:08:35
I'm looking for an automatize way of doing Windows Power Management functions: - Reboot - Shutdown - Hibernate - Sleep - Wakeup Is there a Python module to cover this functionality? Of course any other solutions are also appreciated... I also went with the command line: import os os.system(r'%windir%\system32\rundll32.exe powrprof.dll,SetSuspendState Hibernate') sherpya See win32api.ExitWindowsEx() ActiveState documentation. for flags: http://msdn.microsoft.com/en-us/library/aa376868%28v=vs.85%29.aspx for hybernate/sleep: http://msdn.microsoft.com/en-us/library/aa373201%28v=vs.85%29.aspx to

Battery status is always not charging

放肆的年华 提交于 2019-12-01 17:01:05
@Override public void onReceive(Context context, Intent intent) { int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); if (status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL) Toast.makeText(context, "Charging!", Toast.LENGTH_SHORT).show(); else Toast.makeText(context, "Not Charging!", Toast.LENGTH_SHORT).show(); } Manifest: <receiver android:name=".receiver.BatteryReceiver"> <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> <action android:name="android.intent