use of uk.co.yahoo.p1rpp.calendartrigger.MyLog in project CalendarTrigger by rparkins999.
the class MuteService method StartStepCounter.
// FIXME can we use a similar power saving trick as accelerometer?
// return true if step counter is now running
private boolean StartStepCounter(int classNum) {
if (PrefsManager.getStepCount(this) == PrefsManager.STEP_COUNTER_IDLE) {
SensorManager sensorManager = (SensorManager) getSystemService(Activity.SENSOR_SERVICE);
Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER, true);
if (sensor == null) {
// if we can't get a wakeup step counter, try without
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
if (sensor == null) {
// no step counter at all
return false;
}
}
if (sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL)) {
new MyLog(this, "Step counter activated for class ".concat(PrefsManager.getClassName(this, classNum)));
if (sensor.isWakeUpSensor()) {
PrefsManager.setStepCount(this, PrefsManager.STEP_COUNTER_WAKEUP);
} else {
PrefsManager.setStepCount(this, PrefsManager.STEP_COUNTER_WAKE_LOCK);
lock();
}
return true;
} else {
// could not activate step counter
return false;
}
} else {
// already starting it for another class
return true;
}
}
Aggregations