power-management

Workaround for a certain IOServiceOpen() call requiring root privileges

自作多情 提交于 2019-12-11 15:33:17
问题 Background It is possible to perform a software-controlled disconnection of the power adapter of a Mac laptop by creating an DisableInflow power management assertion. Code from this answer to an SO question can be used to create said assertion. The following is a working example that creates this assertion until the process is killed: #include <IOKit/pwr_mgt/IOPMLib.h> #include <unistd.h> int main() { IOPMAssertionID neverSleep = 0; IOPMAssertionCreateWithName(kIOPMAssertionTypeDisableInflow,

Stop the screen saver and hibernation temporarily in VB.Net

China☆狼群 提交于 2019-12-11 12:53:57
问题 I have a very long running syncronization task that cannot be interrupted by the screen saver or aggressive power saving modes. I want to make a single api call to stop power save mode and then restore it once the task is done. The following code is peaced together from various other posts but it has no effect on XP's power management settings. What am I doing wrong? TIA! Private Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As Long) As Long Public Enum EXECUTION

Reset FPGA based PCIe card and restore its Config Space

陌路散爱 提交于 2019-12-11 08:24:08
问题 I am adapting a Windows / Linux driver of a FPGA based PCIe card. (using a LatticeECP3 with PCIe Endpoint) I need to add a driver function to allow a host driven bitstream update of the FPGA without the need of rebooting the host afterwards. I.e. after flashing I would need to reset the FPGA to let the bitstream be reloaded. This of course would lead to a loss of the Config Space settings of PCIe endpoint. My first approach was to implement following steps: Save the PCI config space of the

Detect battery warning was shown iPhone

六眼飞鱼酱① 提交于 2019-12-11 05:08:58
问题 Is there a way to detect whether a battery level warning was shown? I registered a notification to UIApplicationDidBecomeActiveNotification and I want to know whether it was triggered due to a low battery warning so I can handle it differently. 回答1: You can monitor the battery level programmatically, and when it reaches a certain level, you can handle your event then. -(NSString*)batteryStateStatus:(UIDeviceBatteryState)state{ switch ( state ) { case UIDeviceBatteryStateUnknown: return @

Is it ok to update a widget frequently for a short period of time?

房东的猫 提交于 2019-12-11 04:24:39
问题 in numerous places, it is mentioned that app widgets should not get updated often, to minimize power consumption. But, let's consider that an application is doing something important (such as audio recording) for a short period of time, say 30min. In this case, is it acceptable to update the widget every second from a service? How can it be that this would consume so much power? Please consider that this is different from a widget which would update very often during the whole day. And in my

Computer not obeying powercfg GUID command line instructions

醉酒当歌 提交于 2019-12-11 02:58:55
问题 I am trying to write a script to toggle the lid action between sleep/do nothing by using powercfg.exe and the relevant GUID. powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0 powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0 To do nothing, and powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89

android.permission.BATTERY_STATS usage

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 23:47:52
问题 I'm exploring the Android API options about the battery. what possibilities grants the permission android.permission.BATTERY_STATS . I know how to use it if I can read the android.intent.action.BATTERY_CHANGED intent for the battery levels without declare such permission. Maybe I'm missing something 回答1: This permission is used internal to Android -- AFAIK, SDK applications gain nothing by requesting it. 来源: https://stackoverflow.com/questions/8225926/android-permission-battery-stats-usage

Creating a graph similar to Battery usage in Gingerbread

孤街醉人 提交于 2019-12-10 21:39:31
问题 I just wanted to create a trend in my activity that would look like the Gingerbread battery one (see picture above) I am looking deeply in the Android git and found what seem to be the correct activity Unfortunately, I cannot find something related to canvas or drawing and how I can use this code to create my own trend. If someone could point me where I could find the drawing process or point me another open source sample with a trend activity, would be very helpful. 回答1: I believe the

Android App programming and energy-efficiency [closed]

心不动则不痛 提交于 2019-12-10 11:36:40
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . ATM, I'm searching through open source/close source android applications to identify particular concerns (code blocks, code patterns)

How to enable proximity sensor in android

筅森魡賤 提交于 2019-12-10 11:04:22
问题 I have configured proximeter successfully in my code. Now I want to turn off & on screen programmatically. Code of sensor is working just fine and following method is also getting called. @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock screenWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"screenWakeLock"); if (event.values[0] == 0) { screenWakeLock.acquire