Beispiel #1
0
void battery_set_wakeup_percentage(bool charging, bool suspend)
{
	int battlowpercent[] = {20,13,11,9,6,5,4,3,2,1,0};
	nyx_battery_status_t batt;
	int nextchk = 0,i = 0;

	if(!battDev)
		return;

	POWERDLOG(LOG_DEBUG, "In %s\n",__FUNCTION__);
	battery_read(&batt);
	sendBatteryStatus();

	if(charging) {
		nextchk = 0;
	}
	else if(suspend) {
		for(i=0; battlowpercent[i]!=0; i++) {
			if(batt.percentage > battlowpercent[i])
			{
				nextchk=battlowpercent[i];
				break;
			}
		}
	}
	else
		nextchk=batt.percentage;

	POWERDLOG(LOG_DEBUG, "Setting percent limit to %d\n",nextchk);

	nyx_battery_set_wakeup_percentage(battDev, nextchk);
}
Beispiel #2
0
static BatteryState StateAuthenticOrNot(void)
{
    nyx_battery_status_t battery;

    battery_read(&battery);

    if(ChargerIsCharging() && battery.current <= 0 )
    {
    	POWERDLOG(LOG_INFO,"%d: BATTERY DISCHARGING ....",discharge_count);
    	discharge_count++;
    }
    else
    	discharge_count = 0;

    if(discharge_count == MAX_DISCHARGE_COUNT)
    {
    	POWERDLOG(LOG_CRIT,"Battery discharging while on charger");
        discharge_count = 0;
    }

    if(!battery.present)
    {
        return kBatteryDebounce;
    }

    if(sample_is_new(&battery))
    	sendBatteryStatus();

    return kBatteryLast;
}
Beispiel #3
0
bool batteryStatusQuerySignal(LSHandle *sh,
                   LSMessage *message, void *user_data)
{
	sendBatteryStatus();
	return true;
}
Beispiel #4
0
void notifyBatteryStatus(nyx_device_handle_t handle, nyx_callback_status_t status, void* data)
{
	sendBatteryStatus();
}